PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.12
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.12
1.1.12 1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 All 36 releases
← All changes | assets/js/file-drop.min.js +77 -50 1.1.4 → 1.1.12 View file →
@@ -1,5 +1,5 @@
1 -(function(){"use strict";function Z(){const o=window.wp?.hooks;if(!o)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 o}function N(o,t,e,n){Z().addAction(o,t,e,n)}function ot(o,t){return Z().removeAction(o,t)}function z(o,t,...e){return Z().applyFilters(o,t,...e)}function E(o,...t){Z().doAction(o,...t)}const nt="os.activity.";function le(o){return nt+String(o).replace(/[^a-zA-Z0-9_.-]/g,".")}let rt=0;const de={publish(o,t){E(le(o),t)},subscribe(o,t){const e=`os/activity-sub/${++rt}`,n=le(o);N(n,e,s=>t(s));let r=!1;return()=>{r||(r=!0,ot(n,e))}},filter(o,t,...e){return z(le(o),t,...e)}};let ce=null;function Q(){return!!window.openStationShellOverlays}function st(o){return new Promise((t,e)=>{const n=document.querySelector('script[data-os-shell-overlays="1"]'),r=()=>{if(Q()){t();return}e(new Error("[openstation] shell-overlays bundle loaded but did not set `window.openStationShellOverlays`."))};if(n){Q()?r():(n.addEventListener("load",r),n.addEventListener("error",()=>e(new Error("failed to load shell-overlays bundle"))));return}const s=document.createElement("script");s.src=o,s.async=!0,s.dataset.osShellOverlays="1",s.addEventListener("load",r),s.addEventListener("error",()=>e(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(s)})}function it(o){return Q()||!o?Promise.resolve():(ce||(ce=st(o)),ce)}function at(){return window.openStationConfig?.shellOverlaysBundleUrl??""}function lt(o,t){const e=at();if(Q()||!e){t();return}it(e).then(()=>{o()&&t()}).catch(n=>{typeof console<"u"&&console.warn("[openstation] shell-overlays failed to load; menu/dialog suppressed:",n)})}const dt=4e3,ct=200,ut=1200;function C(o){const t=de.filter("os/toast-requested",{...o});if(!t||t.cancel===!0)return()=>{};let e=!1,n=null;return lt(()=>!e,()=>{n=pt(t)}),()=>{e=!0,n&&n()}}function pt(o){const t=bt(),e=document.createElement("os-toast");e.textContent=o.message,o.action&&(e.setAttribute("action",o.action.label),e.addEventListener("os-toast-action",()=>{o.action?.onClick(),c()})),o.dismissible&&(e.setAttribute("dismissible",""),e.addEventListener("os-toast-dismiss",()=>{o.onDismiss?.(),c()})),t.appendChild(e);let n=!1,r=null,s=o.duration??dt,i=0;const l=()=>{r!==null&&(window.clearTimeout(r),r=null)},c=()=>{n||(n=!0,l(),mt(e),e.setAttribute("state","out"),window.setTimeout(()=>{e.remove(),ht()},ct))},p=()=>{n||o.persistent||r!==null||(i=Date.now(),r=window.setTimeout(c,s))},a=()=>{r!==null&&(s=Math.max(0,s-(Date.now()-i)),l())};return requestAnimationFrame(()=>{e.setAttribute("state","in")}),e.addEventListener("os-toast-hold",d=>{if(d.detail?.held){a();return}s=Math.max(s,ut),p()}),ft(e),p(),de.publish("os/toast-shown",{...o}),c}let ee=null,O=0;function Te(o){const t=o.target;t instanceof HTMLElement&&(t.closest("os-toast-container")||(ee=t))}function ft(o){O===0&&document.addEventListener("focusin",Te,!0),O+=1;const t=o.ownerDocument,e=t.activeElement;e instanceof HTMLElement&&e!==t.body&&!e.closest("os-toast-container")&&(ee=e)}function ht(){O=Math.max(0,O-1),O===0&&document.removeEventListener("focusin",Te,!0)}function mt(o){const t=o.ownerDocument.activeElement;t!==o&&!o.contains(t)||ee?.isConnected===!0&&ee.focus()}function bt(){const o=document.querySelector("os-toast-container");if(o)return o;const t=document.createElement("os-toast-container");return document.body.appendChild(t),t}const gt=Object.freeze(Object.defineProperty({__proto__:null,showToast:C},Symbol.toStringTag,{value:"Module"})),x={FILES_DETECTED:"os.drop.files-detected",FILES_REJECTED:"os.drop.files-rejected",DIALOG_FIELDS:"os.drop.dialog-fields",BEFORE_UPLOAD:"os.drop.before-upload",UPLOAD_STARTED:"os.drop.upload-started",UPLOAD_PROGRESS:"os.drop.upload-progress",AFTER_UPLOAD:"os.drop.after-upload",UPLOAD_FAILED:"os.drop.upload-failed"},vt=32;function xt(o){if(!o)return[];const t=[];for(let e=0;e<o.length;e++){const n=o[e];if(n.kind!=="file")continue;const r=typeof n.webkitGetAsEntry=="function"?n.webkitGetAsEntry():null;r&&t.push(r)}return t}function yt(o){const t=o.createReader();return new Promise((e,n)=>{const r=[],s=()=>{t.readEntries(i=>{if(i.length===0){e(r);return}r.push(...i),s()},n)};s()})}function wt(o){return new Promise((t,e)=>{o.file(t,e)})}async function _t(o){const t={files:[],emptyDirs:[],hadDirectory:!1};for(const e of o)await Fe(e,"",t,0);return t}async function Fe(o,t,e,n){if(n>vt)return;if(o.isFile){try{const i=await wt(o);e.files.push({file:i,relativePath:t?`${t}${i.name}`:""})}catch{}return}if(!o.isDirectory)return;e.hadDirectory=!0;const r=`${t}${o.name}`;let s=[];try{s=await yt(o)}catch{s=[]}if(s.length===0){e.emptyDirs.push(r);return}for(const i of s)await Fe(i,`${r}/`,e,n+1)}const Pe=[".components-drop-zone","[data-drop-zone]",".uploader-window",".media-frame-content"];function q(o){const t=o.dataTransfer?.types;if(!t)return!1;const e=t;if(typeof e.includes=="function")return e.includes("Files");if(typeof e.contains=="function")return e.contains("Files");for(let n=0;n<e.length;n++)if(e[n]==="Files")return!0;return!1}function te(o){const t=o?.closest?.(".os-window");if(!t)return;const e=/^wp-window-(.+)$/.exec(t.id||"");return e?e[1]:void 0}function kt(o){if(!o)return;const t=document.querySelectorAll("iframe");for(const e of Array.from(t))if(e.contentWindow===o){const n=te(e);return n||e.closest("[data-window-id]")?.getAttribute("data-window-id")||void 0}}function Ue(o){const t=window;if(t.__openStationOsFileDropMounted)return t.__openStationOsFileDropMounted;if(!o.config.enabled)return At();const e=Et();let n=0,r=null;const s=()=>{n=0,e.classList.remove("is-active"),r!==null&&(clearTimeout(r),r=null)},i=()=>{r!==null&&clearTimeout(r),r=setTimeout(s,250)},l=f=>{q(f)&&(f.preventDefault(),n++,e.classList.add("is-active"),i())},c=f=>{if(q(f)){if(f.defaultPrevented){s();return}f.preventDefault(),f.dataTransfer&&(f.dataTransfer.dropEffect="copy"),i()}},p=()=>{n=Math.max(0,n-1),n===0&&e.classList.remove("is-active")},a=f=>{if(!q(f))return;if(f.defaultPrevented){s();return}f.preventDefault(),s();const b=xt(f.dataTransfer?.items),v=ue(f);if(b.some(w=>w.isDirectory)){Ie(b,v,o);return}const g=f.dataTransfer?.files?Array.from(f.dataTransfer.files):[];g.length!==0&&oe(g,v,o)},d=()=>s(),u=()=>{document.visibilityState==="hidden"&&s()},h=f=>{if(f.origin!==window.location.origin)return;const b=f.data;if(!b||b.type!=="os-file-drop"||!Array.isArray(b.files)||b.files.length===0)return;const v=b.files.filter(_=>_ instanceof File);if(v.length===0)return;const g=kt(f.source);if(!g)return;const w={surface:"iframe",windowId:g,x:typeof b.x=="number"?b.x:0,y:typeof b.y=="number"?b.y:0};n=0,e.classList.remove("is-active"),oe(v,w,o)};window.addEventListener("dragenter",l),window.addEventListener("dragover",c),window.addEventListener("dragleave",p),window.addEventListener("drop",a),window.addEventListener("dragend",d),document.addEventListener("visibilitychange",u),window.addEventListener("blur",d),window.addEventListener("message",h);const m={dispose:()=>{window.removeEventListener("dragenter",l),window.removeEventListener("dragover",c),window.removeEventListener("dragleave",p),window.removeEventListener("drop",a),window.removeEventListener("dragend",d),document.removeEventListener("visibilitychange",u),window.removeEventListener("blur",d),window.removeEventListener("message",h),e.remove(),delete window.__openStationOsFileDropMounted}};return t.__openStationOsFileDropMounted=m,m}function Et(){const o=document.querySelector(".os-drop-overlay");if(o)return o;const t=document.createElement("div");t.className="os-drop-overlay",t.setAttribute("aria-hidden","true"),t.style.cssText=["position:fixed","inset:0","pointer-events:none","z-index:200","opacity:0","transition:opacity 120ms ease","background:radial-gradient(circle at center, rgba(34,113,177,0.18) 0%, rgba(34,113,177,0.06) 60%, transparent 100%)","box-shadow:inset 0 0 0 3px rgba(34,113,177,0.55)"].join(";");const e=document.createElement("div");e.style.cssText=["position:absolute","top:50%","left:50%","transform:translate(-50%,-50%)","padding:14px 22px","border-radius:12px","background:rgba(20,20,24,0.78)","color:#fff","font:600 14px/1.2 -apple-system,BlinkMacSystemFont,sans-serif","letter-spacing:0.02em"].join(";"),e.textContent="Drop to upload",t.appendChild(e),document.body.appendChild(t);const n=document.createElement("style");return n.textContent=".os-drop-overlay.is-active{opacity:1!important;}",document.head.appendChild(n),t}function At(){const o=n=>{if(!q(n))return;const r=n.target;r?.closest&&Pe.some(s=>r.closest(s))||n.preventDefault()};window.addEventListener("dragover",o),window.addEventListener("drop",o);const t=window,e={dispose:()=>{window.removeEventListener("dragover",o),window.removeEventListener("drop",o),delete t.__openStationOsFileDropMounted}};return t.__openStationOsFileDropMounted=e,e}function ue(o){const t=o.clientX,e=o.clientY;let n=o.target;for(;n&&n!==document.body;){if(n.classList.contains("os-file-tile")&&n.dataset.fileType==="folder"){const r=Number(n.dataset.fileRef??0);if(Number.isFinite(r)&&r>0)return{surface:"folder",folderId:r,x:t,y:e}}if(n.tagName==="IFRAME")return{surface:"iframe",windowId:te(n),x:t,y:e};if(n.classList.contains("os-window")||n.hasAttribute("data-window-id")){const r=te(n)??(n.getAttribute("data-window-id")||void 0),s=r?/^os-folder-(\d+)/.exec(r):null;return s?{surface:"folder",folderId:Number(s[1]),windowId:r,x:t,y:e}:{surface:"window",windowId:r,x:t,y:e}}if(n.dataset?.folderId!==void 0){const r=Number(n.dataset.folderId);return Number.isFinite(r)&&r>0?{surface:"folder",folderId:r,x:t,y:e}:{surface:"wallpaper",x:t,y:e}}if(n.id==="os-wallpaper"||n.classList.contains("os-wallpaper")||n.classList.contains("os-desktop"))return{surface:"wallpaper",x:t,y:e};n=n.parentElement}return{surface:"unknown",x:t,y:e}}async function oe(o,t,e){const n=z(x.FILES_DETECTED,o,t);if(!Array.isArray(n)||n.length===0)return;const{accepted:r,rejected:s}=pe(n,e.config);if(s.length>0&&(E(x.FILES_REJECTED,{rejections:s,context:t}),C({message:s.length===1?s[0].message:`${s.length} files couldn't be uploaded.`})),r.length===0)return;const i=r.map(({file:l,mime:c})=>{const p={file:l,mime:c,fields:fe(l,c)},a=z(x.DIALOG_FIELDS,p,t);return!a||typeof a!="object"||!("fields"in a)||typeof a.fields!="object"?p:a});await e.openDialog(i,t)}async function Ie(o,t,e){if(!e.storage?.canUpload||!e.filesUrl){C({message:"Folder uploads need desktop storage, which is not available for your account."});return}const n=await _t(o),r=z(x.FILES_DETECTED,n.files.map(d=>d.file),t);if(!Array.isArray(r))return;const s=new Set(r),i=n.files.filter(d=>s.has(d.file));if(i.length===0&&n.emptyDirs.length===0)return;const{accepted:l,rejected:c}=pe(i.map(d=>d.file),e.config);c.length>0&&(E(x.FILES_REJECTED,{rejections:c,context:t}),C({message:c.length===1?c[0].message:`${c.length} files couldn't be uploaded.`}));const p=new Map(i.map(d=>[d.file,d.relativePath])),a=l.map(({file:d,mime:u})=>({file:d,mime:u,fields:fe(d,u),relativePath:p.get(d)??""}));a.length===0&&n.emptyDirs.length===0||await e.openDialog(a,t,{forceDesktop:!0,emptyDirs:n.emptyDirs})}function pe(o,t){const e=[],n=[];for(const r of o){if(r.size===0){n.push({file:r,reason:"empty",message:`“${r.name}” is empty.`});continue}if(t.maxSize>0&&r.size>t.maxSize){n.push({file:r,reason:"size",message:`“${r.name}” exceeds the ${St(t.maxSize)} upload limit.`});continue}const s=Re(r,t.allowedMimes,t.extToMime);if(!s){n.push({file:r,reason:"mime",message:`“${r.name}” is not an allowed file type.`});continue}e.push({file:r,mime:s})}return{accepted:e,rejected:n}}function Re(o,t,e){if(t.length===0)return null;const n=o.type.toLowerCase();if(n&&t.includes(n))return n;const r=Ne(o.name);if(!r)return null;if(e){for(const[i,l]of Object.entries(e))if(i.split("|").includes(r)&&t.includes(l))return l;return null}const s=Ct[r];return s&&t.includes(s)?s:null}const Ct={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",avif:"image/avif",heic:"image/heic",heif:"image/heif",svg:"image/svg+xml",mp4:"video/mp4",mov:"video/quicktime",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav",pdf:"application/pdf"};function Ne(o){const t=o.lastIndexOf(".");return t<0?"":o.slice(t+1).toLowerCase()}function fe(o,t){const e=ze(o.name),n=Ne(e),r=n?e.slice(0,e.length-n.length-1):e,s=Me(r);return{title:s,altText:t.startsWith("image/")?s:"",caption:"",description:"",filename:e}}function ze(o){return o.replace(/[\\/]/g,"-").replace(/[\x00-\x1f\x7f]/g,"").replace(/\s+/g," ").replace(/ *- */g,"-").replace(/-+/g,"-").trim().replace(/^[-.]+|[-.]+$/g,"")||"upload"}function Me(o){const t=o.replace(/[-_]+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):"Upload"}function St(o){return o>=1024*1024?`${(o/(1024*1024)).toFixed(0)} MB`:o>=1024?`${(o/1024).toFixed(0)} KB`:`${o} B`}const $t=Object.freeze(Object.defineProperty({__proto__:null,IFRAME_PASSTHROUGH_SELECTORS:Pe,classifyDropTarget:ue,defaultFields:fe,dragHasFiles:q,handleFiles:oe,handleTreeDrop:Ie,humanize:Me,mountOsFileDropManager:Ue,partitionByPolicy:pe,resolveAllowedMime:Re,sanitizeFilename:ze,windowIdFromElement:te},Symbol.toStringTag,{value:"Module"}));function B(o){if(!Number.isFinite(o)||o<=0)return"0 B";const t=["B","KB","MB","GB","TB"];let e=o,n=0;for(;e>=1024&&n<t.length-1;)e/=1024,n++;const r=e>=100||n===0?0:1;return`${e.toFixed(r)} ${t[n]}`}function y(o,...t){return{__wpdHtml:!0,strings:o,values:t}}function Dt(o){return!!o&&o.__wpdHtml===!0}const Lt="$$wpd$$",A=/\$\$wpd\$\$(\d+)\$\$/g;function Tt(o){let t=o[0];for(let e=1;e<o.length;e++)t+=`${Lt}${e-1}$$`+o[e];return t}const Oe=new WeakMap;function qe(o){const t=Oe.get(o);if(t)return t;const e=document.createElement("template");e.innerHTML=Tt(o);const n=[],r=(l,c)=>{if(l.nodeType===Node.ELEMENT_NODE){const d=l;for(const u of Array.from(d.attributes)){const h=u.name,m=u.value,f=h[0];if(A.test(m))if(A.lastIndex=0,f==="@"){const b=A.exec(m);A.lastIndex=0,n.push({path:c,kind:"event",name:h.slice(1),valueIndex:b?Number(b[1]):0}),d.removeAttribute(h)}else if(f==="."){const b=A.exec(m);A.lastIndex=0,n.push({path:c,kind:"prop",name:h.slice(1),valueIndex:b?Number(b[1]):0}),d.removeAttribute(h)}else if(f==="?"){const b=A.exec(m);A.lastIndex=0,n.push({path:c,kind:"bool",name:h.slice(1),valueIndex:b?Number(b[1]):0}),d.removeAttribute(h)}else{const b=[],v=[];let g=0,w;for(A.lastIndex=0;(w=A.exec(m))!==null;)b.push(m.slice(g,w.index)),v.push(Number(w[1])),g=w.index+w[0].length;b.push(m.slice(g)),n.push({path:c,kind:"attr",name:h,template:b,valueIndices:v}),d.setAttribute(h,"")}}}const p=Array.from(l.childNodes);let a=0;for(let d=0;d<p.length;d++){const u=p[d],h=d+a;if(u.nodeType===Node.TEXT_NODE){const m=u.textContent||"";if(!A.test(m)){A.lastIndex=0;continue}A.lastIndex=0;const f=u.parentNode;let b=0,v;const g=[],w=[];for(A.lastIndex=0;(v=A.exec(m))!==null;){v.index>b&&g.push(document.createTextNode(m.slice(b,v.index)));const _=document.createTextNode("");g.push(_),w.push({path:[...c,h+g.length-1],kind:"node",valueIndex:Number(v[1])}),b=v.index+v[0].length}b<m.length&&g.push(document.createTextNode(m.slice(b)));for(const _ of g)f.insertBefore(_,u);f.removeChild(u),a+=g.length-1,n.push(...w)}else r(u,[...c,h])}};r(e.content,[]);const i={template:e,buildParts:l=>{const c=[];for(const p of n){let a=l;for(const d of p.path)a=a.childNodes[d];p.kind==="node"?c.push({kind:"node",valueIndex:p.valueIndex,child:{anchor:a,state:null}}):p.kind==="attr"?c.push({kind:"attr",element:a,name:p.name,template:p.template,valueIndices:p.valueIndices}):p.kind==="event"?c.push({kind:"event",valueIndex:p.valueIndex,element:a,name:p.name}):p.kind==="prop"?c.push({kind:"prop",valueIndex:p.valueIndex,element:a,name:p.name}):p.kind==="bool"&&c.push({kind:"bool",valueIndex:p.valueIndex,element:a,name:p.name})}return c}};return Oe.set(o,i),i}const Be=new WeakMap;function Ft(o,t){for(const e of o.nodes)if(e.parentNode!==t)return!1;return!0}function Pt(o,t){const e=Be.get(t);if(e&&e.strings===o.strings&&Ft(e,t)){ne(e.parts,o.values);return}const n=qe(o.strings),r=n.template.content.cloneNode(!0),s=n.buildParts(r),i=Array.from(r.childNodes);for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(r),ne(s,o.values),Be.set(t,{strings:o.strings,parts:s,nodes:i})}function ne(o,t){for(const e of o)if(e.kind==="node")he(e.child,t[e.valueIndex]);else if(e.kind==="attr"){let n=e.template[0];for(let r=0;r<e.valueIndices.length;r++)n+=je(t[e.valueIndices[r]]),n+=e.template[r+1];n!==e.last&&(e.last=n,n===""?e.element.removeAttribute(e.name):e.element.setAttribute(e.name,n))}else if(e.kind==="event"){const n=t[e.valueIndex];n!==e.current&&(e.current&&e.element.removeEventListener(e.name,e.current),n&&e.element.addEventListener(e.name,n),e.current=n)}else if(e.kind==="prop"){const n=t[e.valueIndex];n!==e.last&&(e.last=n,e.element[e.name]=n)}else if(e.kind==="bool"){const n=!!t[e.valueIndex];n!==e.last&&(e.last=n,n?e.element.setAttribute(e.name,""):e.element.removeAttribute(e.name))}}function he(o,t){if(t==null||t===!1){o.state&&(P(o.state),o.state=null);return}if(Array.isArray(t)){Nt(o,t);return}if(Dt(t)){Rt(o,t);return}if(t instanceof Node){Ut(o,t);return}It(o,je(t))}function Ut(o,t){const e=o.state;e?.shape==="node"&&e.node===t||(e&&P(e),re(o,[t]),o.state={shape:"node",node:t})}function It(o,t){const e=o.state;if(e?.shape==="text"){e.text!==t&&(e.node.textContent=t,e.text=t);return}e&&P(e);const n=document.createTextNode(t);re(o,[n]),o.state={shape:"text",node:n,text:t}}function Rt(o,t){const e=o.state;if(e?.shape==="template"&&e.strings===t.strings){ne(e.parts,t.values);return}e&&P(e);const n=qe(t.strings),r=n.template.content.cloneNode(!0),s=n.buildParts(r),i=Array.from(r.childNodes);re(o,[r]),ne(s,t.values),o.state={shape:"template",strings:t.strings,parts:s,nodes:i}}function Nt(o,t){const e=o.state;if(e?.shape==="array"&&e.entries.length===t.length){for(let r=0;r<t.length;r++)he(e.entries[r],t[r]);return}e&&P(e);const n=[];for(const r of t){const s=document.createTextNode("");re(o,[s]);const i={anchor:s,state:null};he(i,r),n.push(i)}o.state={shape:"array",entries:n}}function re(o,t){const e=o.anchor.parentNode;if(e)for(const n of t)e.insertBefore(n,o.anchor)}function P(o){if(o.shape==="text"){o.node.remove();return}if(o.shape==="template"){for(const t of o.parts)t.kind==="node"&&t.child.state&&(P(t.child.state),t.child.state=null);for(const t of o.nodes)t.parentNode&&t.parentNode.removeChild(t);return}if(o.shape==="node"){o.node.parentNode&&o.node.parentNode.removeChild(o.node);return}for(const t of o.entries)t.state&&P(t.state),t.anchor.remove()}function je(o){return o==null||o===!1?"":String(o)}const F=class F 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(He)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(t,e,n){if(e===n)return;const r=zt(t);this._propValues[r]=n,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(t){if(t==null){this.removeAttribute("class");return}const n=(Array.isArray(t)?t:String(t).split(/\s+/)).map(r=>String(r).trim()).filter(r=>r!=="");this.className=n.join(" ")}requestUpdate(){this._scheduleRender()}emit(t,e){return this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))}_installPropAccessors(){const t=this.constructor;for(const e of t.props){if(Object.getOwnPropertyDescriptor(this,e))continue;const n=He(e);Object.defineProperty(this,e,{get:()=>e in this._propValues?this._propValues[e]:this.getAttribute(n),set:r=>{let s;r==null||r===!1?s=null:r===!0?s="":s=String(r),this._propValues[e]=s,s===null?this.removeAttribute(n):this.setAttribute(n,s),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&Pt(this.render(),this._renderRoot)}))}_adoptStyles(){const t=this.constructor;if(t.styles.length!==0)if(t.shadow&&this.shadowRoot){const e=t.styles.map(n=>n.sheet).filter(n=>n!==null);if(this.shadowRoot.adoptedStyleSheets=e,e.length!==t.styles.length){for(const n of t.styles)if(!n.sheet){const r=document.createElement("style");r.textContent=n.cssText,this.shadowRoot.appendChild(r)}}}else this._adoptLightStyles(t)}_adoptLightStyles(t){if(!F._lightStylesAdopted.has(t)){F._lightStylesAdopted.add(t);for(const e of t.styles){const n=document.createElement("style");n.dataset.osUi=this.tagName.toLowerCase(),n.textContent=e.cssText,document.head.appendChild(n)}}}};F.props=[],F.styles=[],F.shadow=!0,F._lightStylesAdopted=new WeakSet;let D=F;function U(o,t){customElements.get(o)||customElements.define(o,t)}function He(o){return o.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function zt(o){return o.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}const Mt=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function k(o,...t){let e=o[0];for(let n=1;n<o.length;n++){const r=t[n-1];if(typeof r=="string"||typeof r=="number")e+=String(r);else if(r&&r.__wpdCss)e+=r.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof r);e+=o[n]}if(Mt){const n=new CSSStyleSheet;return n.replaceSync(e),{__wpdCss:!0,sheet:n,cssText:e}}return{__wpdCss:!0,sheet:null,cssText:e}}function Ot(o){const t=[],e=[];let n=null,r=o.parentElement;for(;r&&!(r===document.body||r===document.documentElement);){const i=r.id||"";if(i.startsWith("wp-window-")){n=i.slice(10);break}if(r.tagName.toLowerCase()==="os-tabpanel"){const l=r.getAttribute("for");l&&e.unshift(l)}r=r.parentElement}n&&t.push(me(n));for(const i of e)t.push("tab-"+me(i));const s=o.getAttribute("label");return s&&t.push(me(s)),t.length===0?"os-unnamed":"os-"+t.filter(i=>i!=="").join("-")}function me(o){return o.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ke(o){if(o.id)return o.id;const t=Ot(o);return o.id=t,t}const T=k`: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 ) )}`,qt=k` .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%}}`,be=k` .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%}}`,We=k` .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}}`,Xe=k` .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}}`,Ge=k` .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}}`,Ve=k` .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%}}`,Bt=k` .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}}`,ge=k` 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}}`,jt=k` 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-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-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-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}}`,Je=k` @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}}`;k` ${T} ${qt} ${be} ${We} ${Xe} ${Ge} ${Ve} ${Bt} ${ge} ${jt} ${Je} `;const Ht=k` ${T} ${Ve}:host{display:block;--_track-bg:var( --os-ui-progress-track-bg,var( --os-ui-surface-sunken,rgba( 0,0,0,0.08 ) ) );--_fill:var( --os-ui-progress-fill,var( --wp-admin-theme-color,#2271b1 ) );--_height:var( --os-ui-progress-height,6px );--_radius:var( --os-ui-progress-radius,999px );--_label-color:var( --os-ui-progress-label-color,inherit );--_label-size:var( --os-ui-progress-label-size,12px );--_label-gap:var( --os-ui-progress-label-gap,4px );width:100%;font:inherit;color:var( --_label-color )}:host( [ hidden ] ){display:none}.header{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:var( --_label-gap );font-size:var( --_label-size );line-height:1.3}.label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.percent{font-variant-numeric:tabular-nums;opacity:0.75;flex-shrink:0}.track{position:relative;width:100%;height:var( --_height );background:var( --_track-bg );border-radius:var( --_radius );overflow:hidden}.fill{position:absolute;inset-block:0;inset-inline-start:0;width:0;background:var( --_fill );border-radius:inherit;transition:width 0.18s ease-out}:host( [ tone='success' ] ){--os-ui-progress-fill:var( --os-ui-success-fg,#3a8a3a )}:host( [ tone='warning' ] ){--os-ui-progress-fill:var( --os-ui-warning-fg,#dba617 )}:host( [ tone='danger' ] ){--os-ui-progress-fill:var( --os-ui-danger,#d63638 )}:host( [ indeterminate ] ) .fill{width:100%;transition:none;background-image:var( --_fill );background-size:300% 300%;background-repeat:no-repeat;animation:os-holo-shimmer 2.4s var( --_holo-loop ) infinite}:host( [ indeterminate ][ tone ] ) .fill{width:33%;background-image:none;animation:os-progress-sweep 1.1s linear infinite}@keyframes os-progress-sweep{0%{transform:translateX( -120% )}100%{transform:translateX( 320% )}}@media ( prefers-reduced-motion:reduce ){.fill{transition:none}:host( [ indeterminate ] ) .fill,:host( [ indeterminate ][ tone ] ) .fill{animation:none;width:100%;opacity:0.6}}`,H=class H extends D{constructor(){super(...arguments),this._ownedAriaLabel=null}render(){return y`<div class="root" part="root">
1 +(function(){"use strict";function Q(){const o=window.wp?.hooks;if(!o)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 o}function I(o,e,t,n){Q().addAction(o,e,t,n)}function dt(o,e){return Q().removeAction(o,e)}function N(o,e,...t){return Q().applyFilters(o,e,...t)}function A(o,...e){Q().doAction(o,...e)}const ct="data-os-mode";function ut(o=typeof document<"u"?document.documentElement:null){return!!o&&o.getAttribute(ct)==="mobile"}const ft="os.activity.";function ue(o){return ft+String(o).replace(/[^a-zA-Z0-9_.-]/g,".")}let pt=0;const fe={publish(o,e){A(ue(o),e)},subscribe(o,e){const t=`os/activity-sub/${++pt}`,n=ue(o);I(n,t,s=>e(s));let r=!1;return()=>{r||(r=!0,dt(n,t))}},filter(o,e,...t){return N(ue(o),e,...t)}};let pe=null;function ee(){return!!window.openStationShellOverlays}function ht(o){return new Promise((e,t)=>{const n=document.querySelector('script[data-os-shell-overlays="1"]'),r=()=>{if(ee()){e();return}t(new Error("[openstation] shell-overlays bundle loaded but did not set `window.openStationShellOverlays`."))};if(n){ee()?r():(n.addEventListener("load",r),n.addEventListener("error",()=>t(new Error("failed to load shell-overlays bundle"))));return}const s=document.createElement("script");s.src=o,s.async=!0,s.dataset.osShellOverlays="1",s.addEventListener("load",r),s.addEventListener("error",()=>t(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(s)})}function mt(o){return ee()||!o?Promise.resolve():(pe||(pe=ht(o)),pe)}function bt(){return window.openStationConfig?.shellOverlaysBundleUrl??""}function gt(o,e){const t=bt();if(ee()||!t){e();return}mt(t).then(()=>{o()&&e()}).catch(n=>{typeof console<"u"&&console.warn("[openstation] shell-overlays failed to load; menu/dialog suppressed:",n)})}const vt=4e3,xt=200,wt=1200;function $(o){const e=fe.filter("os/toast-requested",{...o});if(!e||e.cancel===!0)return()=>{};let t=!1,n=null;return gt(()=>!t,()=>{n=kt(e)}),()=>{t=!0,n&&n()}}const yt={success:"positive",warning:"warning",error:"critical","shell-error":"critical"};function _t(o){return o?window.openStationConfig?.toastTypes?.find(n=>n.id===o)?.tone??yt[o]??null:null}function kt(o){const e=$t(),t=document.createElement("os-toast");t.textContent=o.message;const n=_t(o.type);n&&t.setAttribute("tone",n),o.action&&(t.setAttribute("action",o.action.label),t.addEventListener("os-toast-action",()=>{o.action?.onClick(),f()})),o.dismissible&&(t.setAttribute("dismissible",""),t.addEventListener("os-toast-dismiss",()=>{o.onDismiss?.(),f()})),e.appendChild(t);let r=!1,s=null,i=o.duration??vt,l=0;const c=()=>{s!==null&&(window.clearTimeout(s),s=null)},f=()=>{r||(r=!0,c(),Ct(t),t.setAttribute("state","out"),window.setTimeout(()=>{t.remove(),At()},xt))},a=()=>{r||o.persistent||s!==null||(l=Date.now(),s=window.setTimeout(f,i))},d=()=>{s!==null&&(i=Math.max(0,i-(Date.now()-l)),c())};return requestAnimationFrame(()=>{t.setAttribute("state","in")}),t.addEventListener("os-toast-hold",u=>{if(u.detail?.held){d();return}i=Math.max(i,wt),a()}),Et(t),a(),fe.publish("os/toast-shown",{...o}),f}let te=null,O=0;function Te(o){const e=o.target;e instanceof HTMLElement&&(e.closest("os-toast-container")||(te=e))}function Et(o){O===0&&document.addEventListener("focusin",Te,!0),O+=1;const e=o.ownerDocument,t=e.activeElement;t instanceof HTMLElement&&t!==e.body&&!t.closest("os-toast-container")&&(te=t)}function At(){O=Math.max(0,O-1),O===0&&document.removeEventListener("focusin",Te,!0)}function Ct(o){const e=o.ownerDocument.activeElement;e!==o&&!o.contains(e)||te?.isConnected===!0&&te.focus()}function $t(){const o=document.querySelector("os-toast-container");if(o)return o;const e=document.createElement("os-toast-container");return document.body.appendChild(e),e}const St=Object.freeze(Object.defineProperty({__proto__:null,showToast:$},Symbol.toStringTag,{value:"Module"})),w={FILES_DETECTED:"os.drop.files-detected",FILES_REJECTED:"os.drop.files-rejected",DIALOG_FIELDS:"os.drop.dialog-fields",BEFORE_UPLOAD:"os.drop.before-upload",UPLOAD_STARTED:"os.drop.upload-started",UPLOAD_PROGRESS:"os.drop.upload-progress",AFTER_UPLOAD:"os.drop.after-upload",UPLOAD_FAILED:"os.drop.upload-failed"},Lt=32;function Dt(o){if(!o)return[];const e=[];for(let t=0;t<o.length;t++){const n=o[t];if(n.kind!=="file")continue;const r=typeof n.webkitGetAsEntry=="function"?n.webkitGetAsEntry():null;r&&e.push(r)}return e}function Tt(o){const e=o.createReader();return new Promise((t,n)=>{const r=[],s=()=>{e.readEntries(i=>{if(i.length===0){t(r);return}r.push(...i),s()},n)};s()})}function Ft(o){return new Promise((e,t)=>{o.file(e,t)})}async function Rt(o){const e={files:[],emptyDirs:[],hadDirectory:!1};for(const t of o)await Fe(t,"",e,0);return e}async function Fe(o,e,t,n){if(n>Lt)return;if(o.isFile){try{const i=await Ft(o);t.files.push({file:i,relativePath:e?`${e}${i.name}`:""})}catch{}return}if(!o.isDirectory)return;t.hadDirectory=!0;const r=`${e}${o.name}`;let s=[];try{s=await Tt(o)}catch{s=[]}if(s.length===0){t.emptyDirs.push(r);return}for(const i of s)await Fe(i,`${r}/`,t,n+1)}const Re=[".components-drop-zone","[data-drop-zone]",".uploader-window",".media-frame-content"];function B(o){const e=o.dataTransfer?.types;if(!e)return!1;const t=e;if(typeof t.includes=="function")return t.includes("Files");if(typeof t.contains=="function")return t.contains("Files");for(let n=0;n<t.length;n++)if(t[n]==="Files")return!0;return!1}function oe(o){const e=o?.closest?.(".os-window");if(!e)return;const t=/^wp-window-(.+)$/.exec(e.id||"");return t?t[1]:void 0}function Pt(o){if(!o)return;const e=document.querySelectorAll("iframe");for(const t of Array.from(e))if(t.contentWindow===o){const n=oe(t);return n||t.closest("[data-window-id]")?.getAttribute("data-window-id")||void 0}}function Pe(o){const e=window;if(e.__openStationOsFileDropMounted)return e.__openStationOsFileDropMounted;if(!o.config.enabled||ut())return Mt();const t=Ut();let n=0,r=null;const s=()=>{n=0,t.classList.remove("is-active"),r!==null&&(clearTimeout(r),r=null)},i=()=>{r!==null&&clearTimeout(r),r=setTimeout(s,250)},l=h=>{B(h)&&(h.preventDefault(),n++,t.classList.add("is-active"),i())},c=h=>{if(B(h)){if(h.defaultPrevented){s();return}h.preventDefault(),h.dataTransfer&&(h.dataTransfer.dropEffect="copy"),i()}},f=()=>{n=Math.max(0,n-1),n===0&&t.classList.remove("is-active")},a=h=>{if(!B(h))return;if(h.defaultPrevented){s();return}h.preventDefault(),s();const b=Dt(h.dataTransfer?.items),v=he(h);if(b.some(y=>y.isDirectory)){Ue(b,v,o);return}const g=h.dataTransfer?.files?Array.from(h.dataTransfer.files):[];g.length!==0&&ne(g,v,o)},d=()=>s(),u=()=>{document.visibilityState==="hidden"&&s()},p=h=>{if(h.origin!==window.location.origin)return;const b=h.data;if(!b||b.type!=="os-file-drop"||!Array.isArray(b.files)||b.files.length===0)return;const v=b.files.filter(_=>_ instanceof File);if(v.length===0)return;const g=Pt(h.source);if(!g)return;const y={surface:"iframe",windowId:g,x:typeof b.x=="number"?b.x:0,y:typeof b.y=="number"?b.y:0};n=0,t.classList.remove("is-active"),ne(v,y,o)};window.addEventListener("dragenter",l),window.addEventListener("dragover",c),window.addEventListener("dragleave",f),window.addEventListener("drop",a),window.addEventListener("dragend",d),document.addEventListener("visibilitychange",u),window.addEventListener("blur",d),window.addEventListener("message",p);const m={dispose:()=>{window.removeEventListener("dragenter",l),window.removeEventListener("dragover",c),window.removeEventListener("dragleave",f),window.removeEventListener("drop",a),window.removeEventListener("dragend",d),document.removeEventListener("visibilitychange",u),window.removeEventListener("blur",d),window.removeEventListener("message",p),t.remove(),delete window.__openStationOsFileDropMounted}};return e.__openStationOsFileDropMounted=m,m}function Ut(){const o=document.querySelector(".os-drop-overlay");if(o)return o;const e=document.createElement("div");e.className="os-drop-overlay",e.setAttribute("aria-hidden","true"),e.style.cssText=["position:fixed","inset:0","pointer-events:none","z-index:200","opacity:0","transition:opacity 120ms ease","background:radial-gradient(circle at center, rgba(34,113,177,0.18) 0%, rgba(34,113,177,0.06) 60%, transparent 100%)","box-shadow:inset 0 0 0 3px rgba(34,113,177,0.55)"].join(";");const t=document.createElement("div");t.style.cssText=["position:absolute","top:50%","left:50%","transform:translate(-50%,-50%)","padding:14px 22px","border-radius:12px","background:rgba(20,20,24,0.78)","color:#fff","font:600 14px/1.2 -apple-system,BlinkMacSystemFont,sans-serif","letter-spacing:0.02em"].join(";"),t.textContent="Drop to upload",e.appendChild(t),document.body.appendChild(e);const n=document.createElement("style");return n.textContent=".os-drop-overlay.is-active{opacity:1!important;}",document.head.appendChild(n),e}function Mt(){const o=n=>{if(!B(n))return;const r=n.target;r?.closest&&Re.some(s=>r.closest(s))||n.preventDefault()};window.addEventListener("dragover",o),window.addEventListener("drop",o);const e=window,t={dispose:()=>{window.removeEventListener("dragover",o),window.removeEventListener("drop",o),delete e.__openStationOsFileDropMounted}};return e.__openStationOsFileDropMounted=t,t}function he(o){const e=o.clientX,t=o.clientY;let n=o.target;for(;n&&n!==document.body;){if(n.classList.contains("os-file-tile")&&n.dataset.fileType==="folder"){const r=Number(n.dataset.fileRef??0);if(Number.isFinite(r)&&r>0)return{surface:"folder",folderId:r,x:e,y:t}}if(n.tagName==="IFRAME")return{surface:"iframe",windowId:oe(n),x:e,y:t};if(n.classList.contains("os-window")||n.hasAttribute("data-window-id")){const r=oe(n)??(n.getAttribute("data-window-id")||void 0),s=r?/^os-folder-(\d+)/.exec(r):null;return s?{surface:"folder",folderId:Number(s[1]),windowId:r,x:e,y:t}:{surface:"window",windowId:r,x:e,y:t}}if(n.dataset?.folderId!==void 0){const r=Number(n.dataset.folderId);return Number.isFinite(r)&&r>0?{surface:"folder",folderId:r,x:e,y:t}:{surface:"wallpaper",x:e,y:t}}if(n.id==="os-wallpaper"||n.classList.contains("os-wallpaper")||n.classList.contains("os-desktop"))return{surface:"wallpaper",x:e,y:t};n=n.parentElement}return{surface:"unknown",x:e,y:t}}async function ne(o,e,t){const n=N(w.FILES_DETECTED,o,e);if(!Array.isArray(n)||n.length===0)return;const{accepted:r,rejected:s}=me(n,t.config);if(s.length>0&&(A(w.FILES_REJECTED,{rejections:s,context:e}),$({message:s.length===1?s[0].message:`${s.length} files couldn't be uploaded.`})),r.length===0)return;const i=r.map(({file:l,mime:c})=>{const f={file:l,mime:c,fields:be(l,c)},a=N(w.DIALOG_FIELDS,f,e);return!a||typeof a!="object"||!("fields"in a)||typeof a.fields!="object"?f:a});await t.openDialog(i,e)}async function Ue(o,e,t){if(!t.storage?.canUpload||!t.filesUrl){$({message:"Folder uploads need desktop storage, which is not available for your account."});return}const n=await Rt(o),r=N(w.FILES_DETECTED,n.files.map(d=>d.file),e);if(!Array.isArray(r))return;const s=new Set(r),i=n.files.filter(d=>s.has(d.file));if(i.length===0&&n.emptyDirs.length===0)return;const{accepted:l,rejected:c}=me(i.map(d=>d.file),t.config);c.length>0&&(A(w.FILES_REJECTED,{rejections:c,context:e}),$({message:c.length===1?c[0].message:`${c.length} files couldn't be uploaded.`}));const f=new Map(i.map(d=>[d.file,d.relativePath])),a=l.map(({file:d,mime:u})=>({file:d,mime:u,fields:be(d,u),relativePath:f.get(d)??""}));a.length===0&&n.emptyDirs.length===0||await t.openDialog(a,e,{forceDesktop:!0,emptyDirs:n.emptyDirs})}function me(o,e){const t=[],n=[];for(const r of o){if(r.size===0){n.push({file:r,reason:"empty",message:`“${r.name}” is empty.`});continue}if(e.maxSize>0&&r.size>e.maxSize){n.push({file:r,reason:"size",message:`“${r.name}” exceeds the ${Nt(e.maxSize)} upload limit.`});continue}const s=Me(r,e.allowedMimes,e.extToMime);if(!s){n.push({file:r,reason:"mime",message:`“${r.name}” is not an allowed file type.`});continue}t.push({file:r,mime:s})}return{accepted:t,rejected:n}}function Me(o,e,t){if(e.length===0)return null;const n=o.type.toLowerCase();if(n&&e.includes(n))return n;const r=Ie(o.name);if(!r)return null;if(t){for(const[i,l]of Object.entries(t))if(i.split("|").includes(r)&&e.includes(l))return l;return null}const s=It[r];return s&&e.includes(s)?s:null}const It={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",avif:"image/avif",heic:"image/heic",heif:"image/heif",svg:"image/svg+xml",mp4:"video/mp4",mov:"video/quicktime",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav",pdf:"application/pdf"};function Ie(o){const e=o.lastIndexOf(".");return e<0?"":o.slice(e+1).toLowerCase()}function be(o,e){const t=Ne(o.name),n=Ie(t),r=n?t.slice(0,t.length-n.length-1):t,s=ze(r);return{title:s,altText:e.startsWith("image/")?s:"",caption:"",description:"",filename:t}}function Ne(o){return o.replace(/[\\/]/g,"-").replace(/[\x00-\x1f\x7f]/g,"").replace(/\s+/g," ").replace(/ *- */g,"-").replace(/-+/g,"-").trim().replace(/^[-.]+|[-.]+$/g,"")||"upload"}function ze(o){const e=o.replace(/[-_]+/g," ").trim();return e?e.charAt(0).toUpperCase()+e.slice(1):"Upload"}function Nt(o){return o>=1024*1024?`${(o/(1024*1024)).toFixed(0)} MB`:o>=1024?`${(o/1024).toFixed(0)} KB`:`${o} B`}const zt=Object.freeze(Object.defineProperty({__proto__:null,IFRAME_PASSTHROUGH_SELECTORS:Re,classifyDropTarget:he,defaultFields:be,dragHasFiles:B,handleFiles:ne,handleTreeDrop:Ue,humanize:ze,mountOsFileDropManager:Pe,partitionByPolicy:me,resolveAllowedMime:Me,sanitizeFilename:Ne,windowIdFromElement:oe},Symbol.toStringTag,{value:"Module"}));function q(o){if(!Number.isFinite(o)||o<=0)return"0 B";const e=["B","KB","MB","GB","TB"];let t=o,n=0;for(;t>=1024&&n<e.length-1;)t/=1024,n++;const r=t>=100||n===0?0:1;return`${t.toFixed(r)} ${e[n]}`}function x(o,...e){return{__wpdHtml:!0,strings:o,values:e}}function Ot(o){return!!o&&o.__wpdHtml===!0}const Bt="$$wpd$$",C=/\$\$wpd\$\$(\d+)\$\$/g,qt="$$wpd-node$$",Ht=/^\$\$wpd-node\$\$(\d+)\$\$$/,jt=new Set(["style","script","textarea","title"]);function Wt(o){let e="",t=!1,n=null,r=!1,s=null,i="",l=!1;for(let c=0;c<o.length;c++){const f=o[c];e+=f;for(let a=0;a<f.length;a++){const d=f[a];if(r){f.startsWith("-->",a)&&(r=!1,a+=2);continue}if(s!==null){d==="<"&&f[a+1]==="/"&&f.slice(a+2,a+2+s.length).toLowerCase()===s&&(a+=1+s.length,s=null,t=!0,l=!1,i="");continue}if(n!==null){d===n&&(n=null);continue}if(t){d==='"'||d==="'"?(n=d,l=!1):d===">"?(t=!1,l=!1,jt.has(i)&&(s=i),i=""):l&&(/[a-zA-Z0-9-]/.test(d)?i+=d.toLowerCase():l=!1);continue}if(f.startsWith("<!--",a)){r=!0,a+=3;continue}const u=f[a+1]??"";d==="<"&&/[a-zA-Z/!]/.test(u)&&(t=!0,i="",l=/[a-zA-Z]/.test(u))}c<o.length-1&&(e+=t||r||s!==null?`${Bt}${c}$$`:`<!--${qt}${c}$$-->`)}return e}const Oe=new WeakMap;function Be(o){const e=Oe.get(o);if(e)return e;const t=document.createElement("template");t.innerHTML=Wt(o);const n=[],r=(l,c)=>{if(l.nodeType===Node.ELEMENT_NODE){const d=l;for(const u of Array.from(d.attributes)){const p=u.name,m=u.value,h=p[0];if(C.test(m))if(C.lastIndex=0,h==="@"){const b=C.exec(m);C.lastIndex=0,n.push({path:c,kind:"event",name:p.slice(1),valueIndex:b?Number(b[1]):0}),d.removeAttribute(p)}else if(h==="."){const b=C.exec(m);C.lastIndex=0,n.push({path:c,kind:"prop",name:p.slice(1),valueIndex:b?Number(b[1]):0}),d.removeAttribute(p)}else if(h==="?"){const b=C.exec(m);C.lastIndex=0,n.push({path:c,kind:"bool",name:p.slice(1),valueIndex:b?Number(b[1]):0}),d.removeAttribute(p)}else{const b=[],v=[];let g=0,y;for(C.lastIndex=0;(y=C.exec(m))!==null;)b.push(m.slice(g,y.index)),v.push(Number(y[1])),g=y.index+y[0].length;b.push(m.slice(g)),n.push({path:c,kind:"attr",name:p,template:b,valueIndices:v}),d.setAttribute(p,"")}}}const f=Array.from(l.childNodes);let a=0;for(let d=0;d<f.length;d++){const u=f[d],p=d+a;if(u.nodeType===Node.COMMENT_NODE){const m=Ht.exec(u.data);if(m){const h=document.createTextNode("");u.parentNode.replaceChild(h,u),n.push({path:[...c,p],kind:"node",valueIndex:Number(m[1])})}continue}if(u.nodeType===Node.TEXT_NODE){const m=u.textContent||"";if(!C.test(m)){C.lastIndex=0;continue}C.lastIndex=0;const h=u.parentNode;let b=0,v;const g=[],y=[];for(C.lastIndex=0;(v=C.exec(m))!==null;){v.index>b&&g.push(document.createTextNode(m.slice(b,v.index)));const _=document.createTextNode("");g.push(_),y.push({path:[...c,p+g.length-1],kind:"node",valueIndex:Number(v[1])}),b=v.index+v[0].length}b<m.length&&g.push(document.createTextNode(m.slice(b)));for(const _ of g)h.insertBefore(_,u);h.removeChild(u),a+=g.length-1,n.push(...y)}else r(u,[...c,p])}};r(t.content,[]);const i={template:t,buildParts:l=>{const c=[];for(const f of n){let a=l;for(const d of f.path)a=a.childNodes[d];f.kind==="node"?c.push({kind:"node",valueIndex:f.valueIndex,child:{anchor:a,state:null}}):f.kind==="attr"?c.push({kind:"attr",element:a,name:f.name,template:f.template,valueIndices:f.valueIndices}):f.kind==="event"?c.push({kind:"event",valueIndex:f.valueIndex,element:a,name:f.name}):f.kind==="prop"?c.push({kind:"prop",valueIndex:f.valueIndex,element:a,name:f.name}):f.kind==="bool"&&c.push({kind:"bool",valueIndex:f.valueIndex,element:a,name:f.name})}return c}};return Oe.set(o,i),i}const qe=new WeakMap;function Kt(o,e){for(const t of o.nodes)if(t.parentNode!==e)return!1;return!0}function Xt(o,e){const t=qe.get(e);if(t&&t.strings===o.strings&&Kt(t,e)){re(t.parts,o.values);return}const n=Be(o.strings),r=n.template.content.cloneNode(!0),s=n.buildParts(r),i=Array.from(r.childNodes);for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(r),re(s,o.values),qe.set(e,{strings:o.strings,parts:s,nodes:i})}function re(o,e){for(const t of o)if(t.kind==="node")se(t.child,e[t.valueIndex]);else if(t.kind==="attr"){let n=t.template[0];for(let r=0;r<t.valueIndices.length;r++)n+=He(e[t.valueIndices[r]]),n+=t.template[r+1];n!==t.last&&(t.last=n,n===""?t.element.removeAttribute(t.name):t.element.setAttribute(t.name,n))}else if(t.kind==="event"){const n=e[t.valueIndex];n!==t.current&&(t.current&&t.element.removeEventListener(t.name,t.current),n&&t.element.addEventListener(t.name,n),t.current=n)}else if(t.kind==="prop"){const n=e[t.valueIndex];n!==t.last&&(t.last=n,t.element[t.name]=n)}else if(t.kind==="bool"){const n=!!e[t.valueIndex];n!==t.last&&(t.last=n,n?t.element.setAttribute(t.name,""):t.element.removeAttribute(t.name))}}function se(o,e){if(e==null||e===!1){o.state&&(T(o.state),o.state=null);return}if(Array.isArray(e)){Yt(o,e);return}if(Ot(e)){Jt(o,e);return}if(e instanceof Node){Gt(o,e);return}Vt(o,He(e))}function Gt(o,e){const t=o.state;t?.shape==="node"&&t.node===e||(t&&T(t),H(o,[e]),o.state={shape:"node",node:e})}function Vt(o,e){const t=o.state;if(t?.shape==="text"){t.text!==e&&(t.node.textContent=e,t.text=e);return}t&&T(t);const n=document.createTextNode(e);H(o,[n]),o.state={shape:"text",node:n,text:e}}function Jt(o,e){const t=o.state;if(t?.shape==="template"&&t.strings===e.strings){re(t.parts,e.values);return}t&&T(t);const n=Be(e.strings),r=n.template.content.cloneNode(!0),s=n.buildParts(r),i=Array.from(r.childNodes);H(o,[r]),re(s,e.values),o.state={shape:"template",strings:e.strings,parts:s,nodes:i}}function Yt(o,e){const t=o.state;if(t?.shape==="array"){const r=Math.min(t.entries.length,e.length);for(let s=0;s<r;s++)se(t.entries[s],e[s]);if(e.length<t.entries.length){for(let s=e.length;s<t.entries.length;s++){const i=t.entries[s];i.state&&T(i.state),i.anchor.remove()}t.entries.length=e.length}else for(let s=t.entries.length;s<e.length;s++){const i=document.createTextNode("");H(o,[i]);const l={anchor:i,state:null};se(l,e[s]),t.entries.push(l)}return}t&&T(t);const n=[];for(const r of e){const s=document.createTextNode("");H(o,[s]);const i={anchor:s,state:null};se(i,r),n.push(i)}o.state={shape:"array",entries:n}}function H(o,e){const t=o.anchor.parentNode;if(t)for(const n of e)t.insertBefore(n,o.anchor)}function T(o){if(o.shape==="text"){o.node.remove();return}if(o.shape==="template"){for(const e of o.parts)e.kind==="node"&&e.child.state&&(T(e.child.state),e.child.state=null);for(const e of o.nodes)e.parentNode&&e.parentNode.removeChild(e);return}if(o.shape==="node"){o.node.parentNode&&o.node.parentNode.removeChild(o.node);return}for(const e of o.entries)e.state&&T(e.state),e.anchor.remove()}function He(o){return o==null||o===!1?"":String(o)}const R=class R 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(je)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,t,n){if(t===n)return;const r=Zt(e);this._propValues[r]=n,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(e){if(e==null){this.removeAttribute("class");return}const n=(Array.isArray(e)?e:String(e).split(/\s+/)).map(r=>String(r).trim()).filter(r=>r!=="");this.className=n.join(" ")}requestUpdate(){this._scheduleRender()}emit(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_installPropAccessors(){const e=this.constructor;for(const t of e.props){if(Object.getOwnPropertyDescriptor(this,t))continue;const n=je(t);Object.defineProperty(this,t,{get:()=>t in this._propValues?this._propValues[t]:this.getAttribute(n),set:r=>{let s;r==null||r===!1?s=null:r===!0?s="":s=String(r),this._propValues[t]=s,s===null?this.removeAttribute(n):this.setAttribute(n,s),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&Xt(this.render(),this._renderRoot)}))}_adoptStyles(){const e=this.constructor;if(e.styles.length!==0)if(e.shadow&&this.shadowRoot){const t=e.styles.map(n=>n.sheet).filter(n=>n!==null);if(this.shadowRoot.adoptedStyleSheets=t,t.length!==e.styles.length){for(const n of e.styles)if(!n.sheet){const r=document.createElement("style");r.textContent=n.cssText,this.shadowRoot.appendChild(r)}}}else this._adoptLightStyles(e)}_adoptLightStyles(e){if(!R._lightStylesAdopted.has(e)){R._lightStylesAdopted.add(e);for(const t of e.styles){const n=document.createElement("style");n.dataset.osUi=this.tagName.toLowerCase(),n.textContent=t.cssText,document.head.appendChild(n)}}}};R.props=[],R.styles=[],R.shadow=!0,R._lightStylesAdopted=new WeakSet;let L=R;function P(o,e){customElements.get(o)||customElements.define(o,e)}function je(o){return o.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function Zt(o){return o.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}const Qt=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function k(o,...e){let t=o[0];for(let n=1;n<o.length;n++){const r=e[n-1];if(typeof r=="string"||typeof r=="number")t+=String(r);else if(r&&r.__wpdCss)t+=r.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof r);t+=o[n]}if(Qt){const n=new CSSStyleSheet;return n.replaceSync(t),{__wpdCss:!0,sheet:n,cssText:t}}return{__wpdCss:!0,sheet:null,cssText:t}}function eo(o){const e=[],t=[];let n=null,r=o.parentElement;for(;r&&!(r===document.body||r===document.documentElement);){const i=r.id||"";if(i.startsWith("wp-window-")){n=i.slice(10);break}if(r.tagName.toLowerCase()==="os-tabpanel"){const l=r.getAttribute("for");l&&t.unshift(l)}r=r.parentElement}n&&e.push(ge(n));for(const i of t)e.push("tab-"+ge(i));const s=o.getAttribute("label");return s&&e.push(ge(s)),e.length===0?"os-unnamed":"os-"+e.filter(i=>i!=="").join("-")}function ge(o){return o.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function We(o){if(o.id)return o.id;const e=eo(o);return o.id=e,e}const F=k`: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 ) )}`,to=k` .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%}}`,ve=k` .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%}}`,Ke=k` .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}}`,Xe=k` .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}}`,Ge=k` .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}}`,Ve=k` .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=k` .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}}`,xe=k` 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}}`,no=k` 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}}`,Je=k` @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}}`;k` ${F} ${to} ${ve} ${Ke} ${Xe} ${Ge} ${Ve} ${oo} ${xe} ${no} ${Je} `;const ro=k` ${F} ${Ve}:host{display:block;--_track-bg:var( --os-ui-progress-track-bg,var( --os-ui-surface-sunken,rgba( 0,0,0,0.08 ) ) );--_fill:var( --os-ui-progress-fill,var( --wp-admin-theme-color,#2271b1 ) );--_height:var( --os-ui-progress-height,6px );--_radius:var( --os-ui-progress-radius,999px );--_label-color:var( --os-ui-progress-label-color,inherit );--_label-size:var( --os-ui-progress-label-size,12px );--_label-gap:var( --os-ui-progress-label-gap,4px );width:100%;font:inherit;color:var( --_label-color )}:host( [ hidden ] ){display:none}.header{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:var( --_label-gap );font-size:var( --_label-size );line-height:1.3}.label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.percent{font-variant-numeric:tabular-nums;opacity:0.75;flex-shrink:0}.track{position:relative;width:100%;height:var( --_height );background:var( --_track-bg );border-radius:var( --_radius );overflow:hidden}.fill{position:absolute;inset-block:0;inset-inline-start:0;width:0;background:var( --_fill );border-radius:inherit;transition:width 0.18s ease-out}:host( [ tone='success' ] ){--os-ui-progress-fill:var( --os-ui-success-fg,#3a8a3a )}:host( [ tone='warning' ] ){--os-ui-progress-fill:var( --os-ui-warning-fg,#dba617 )}:host( [ tone='danger' ] ){--os-ui-progress-fill:var( --os-ui-danger,#d63638 )}:host( [ indeterminate ] ) .fill{width:100%;transition:none;background-image:var( --_fill );background-size:300% 300%;background-repeat:no-repeat;animation:os-holo-shimmer 2.4s var( --_holo-loop ) infinite}:host( [ indeterminate ][ tone ] ) .fill{width:33%;background-image:none;animation:os-progress-sweep 1.1s linear infinite}@keyframes os-progress-sweep{0%{transform:translateX( -120% )}100%{transform:translateX( 320% )}}@media ( prefers-reduced-motion:reduce ){.fill{transition:none}:host( [ indeterminate ] ) .fill,:host( [ indeterminate ][ tone ] ) .fill{animation:none;width:100%;opacity:0.6}}`,W=class W extends L{constructor(){super(...arguments),this._ownedAriaLabel=null}render(){return x`<div class="root" part="root">
2 2 <div class="header" part="header" hidden>
3 3 <span class="label" part="label"></span>
4 4 <span class="percent" part="percent"></span>
5 5 </div>
@@ -5,17 +5,18 @@
5 5 </div>
6 6 <div class="track" part="track">
7 7 <div class="fill" part="fill"></div>
8 8 </div>
9 - </div>`}requestUpdate(){super.requestUpdate(),queueMicrotask(()=>this._paint())}connectedCallback(){super.connectedCallback(),queueMicrotask(()=>this._paint())}_paint(){const t=this.shadowRoot;if(!t)return;const e=this._readMax(),n=this.hasAttribute("indeterminate")||e<=0,r=n?0:this._readValue(e),s=n?0:r/e,i=Math.round(s*100),l=this.getAttribute("label")??"",c=this.hasAttribute("show-percent"),p=t.querySelector(".fill");p&&!n?p.style.width=`${(s*100).toFixed(2)}%`:p&&n&&p.style.removeProperty("width");const a=t.querySelector(".header"),d=t.querySelector(".label"),u=t.querySelector(".percent");if(a&&d&&u){const m=l||c&&!n;a.hidden=!m,d.textContent=l,u.hidden=!(c&&!n),u.textContent=`${i}%`}this._syncAria(e,r,n,l);const h=t.querySelector(".track");h&&(h.setAttribute("role","progressbar"),h.setAttribute("aria-valuemin","0"),n?(h.removeAttribute("aria-valuenow"),h.removeAttribute("aria-valuemax")):(h.setAttribute("aria-valuemax",String(e)),h.setAttribute("aria-valuenow",String(r))),l?h.setAttribute("aria-label",l):h.removeAttribute("aria-label"))}_syncAria(t,e,n,r){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),n?(this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuemax")):(this.setAttribute("aria-valuemax",String(t)),this.setAttribute("aria-valuenow",String(e)));const s=this.getAttribute("aria-label");r?(s===null||s===this._ownedAriaLabel)&&(this.setAttribute("aria-label",r),this._ownedAriaLabel=r):s!==null&&s===this._ownedAriaLabel&&(this.removeAttribute("aria-label"),this._ownedAriaLabel=null)}_readMax(){const t=this.getAttribute("max");if(t===null)return 100;const e=parseFloat(t);return Number.isFinite(e)?e:100}_readValue(t){const e=parseFloat(this.getAttribute("value")??"0");return!Number.isFinite(e)||e<0?0:e>t?t:e}};H.props=["value","max","indeterminate","tone","label","showPercent"],H.styles=[Ht],H.help=void 0;let ve=H;U("os-progress-bar",ve);const Kt=k` ${T} ${be} ${We} ${Xe} ${Ge} ${Je}:host{display:inline-flex}:host( [ fill-cell ] ){display:flex;width:100%}button{appearance:none;display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:var( --os-ui-button-padding,6px 12px );border-radius:var( --os-ui-button-border-radius,6px );font:inherit;font-weight:500;cursor:pointer;transition:background-color var( --_holo-t ) ease,color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,transform 80ms ease;background:var( --os-ui-button-bg,transparent );background-image:var( --os-ui-button-bg-image,none );background-repeat:var( --os-ui-button-bg-image-repeat,repeat );background-size:var( --os-ui-button-bg-image-size,auto );background-position:var( --os-ui-button-bg-image-position,center );color:var( --os-ui-button-fg,var( --os-ui-fg,#1d2327 ) );border:var( --os-ui-button-border,1px solid var( --os-ui-border,#c3c4c7 ) )}:host( [ fill-cell ] ) button{width:100%;min-height:var( --os-ui-button-min-height,44px )}button:disabled{opacity:0.5;cursor:not-allowed}button:active:not(:disabled ){transform:translateY( 1px )}button:hover:not(:disabled ){background-color:var( --os-ui-button-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.04 ) ) )}button:focus-visible{outline:none;box-shadow:var( --_holo-focus )}button:disabled::before,button:disabled::after,button:disabled .os-holo-glint{opacity:0 !important}:host( [ variant='primary' ] ) button{background-color:var( --os-ui-button-bg,var( --wp-admin-theme-color,#2271b1 ) );color:var( --os-ui-button-fg,var( --os-ui-fg-on-accent,#fff ) );border:var( --os-ui-button-border,1px solid transparent )}:host( [ variant='primary' ] ) button:hover:not(:disabled ){filter:brightness( 1.06 );background-color:var( --os-ui-button-bg,var( --wp-admin-theme-color,#2271b1 ) );box-shadow:var( --_holo-glow )}:host( [ variant='holo' ] ) button{background-color:transparent;background-image:var( --_holo-fill );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;color:var( --os-ui-button-fg,var( --_holo-ink ) );border:var( --os-ui-button-border,1px solid transparent );box-shadow:var( --_holo-glow );font-weight:600;transition:background-position var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,filter var( --_holo-t ) ease,transform 80ms ease}:host( [ variant='holo' ] ) button:hover:not(:disabled ){background-color:transparent;background-position:74% 66%;box-shadow:var( --_holo-glow-strong )}:host( [ variant='holo' ] ) button:active:not(:disabled ){background-position:88% 82%;filter:brightness( 0.94 )}:host( [ variant='holo' ] ) button::before{display:none}@media ( prefers-reduced-motion:reduce ){:host( [ variant='holo' ] ) button:hover:not(:disabled ),:host( [ variant='holo' ] ) button:active:not(:disabled ){background-position:22% 28%}}:host( [ variant='secondary' ] ) button{background-color:var( --os-ui-button-bg,var( --os-ui-hover,rgba( 0,0,0,0.06 ) ) );color:var( --os-ui-button-fg,var( --os-ui-fg,#1d2327 ) );border:var( --os-ui-button-border,1px solid transparent )}:host( [ variant='secondary' ] ) button:hover:not(:disabled ){background-color:var( --os-ui-button-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.1 ) ) )}:host( [ variant='danger' ] ) button{background-color:var( --os-ui-button-bg,transparent );color:var( --os-ui-button-fg,var( --os-ui-danger,#d63638 ) );border:var( --os-ui-button-border,1px solid currentColor )}:host( [ variant='danger' ] ) button:hover:not(:disabled ){background-color:var( --os-ui-danger,#d63638 );color:var( --os-ui-fg-on-accent,#fff )}:host( [ variant='danger' ] ) button::after{display:none}:host( [ variant='link' ] ) button{background-color:transparent;background-image:none;color:var( --os-ui-button-fg,var( --wp-admin-theme-color,#2271b1 ) );border:0;padding:0;text-decoration:underline}:host( [ variant='link' ] ) button::before,:host( [ variant='link' ] ) button::after,:host( [ variant='link' ] ) .os-holo-glint,:host( [ variant='link' ] ) .os-holo-ring{display:none}:host( [ variant='link' ] ) button:active:not(:disabled ){transform:none}:host( [ busy ] ) button{pointer-events:none;opacity:0.75}:host( [ variant='holo' ][ busy ] ) button{animation:os-holo-drift 12s ease-in-out infinite}@media ( prefers-reduced-motion:reduce ){:host( [ variant='holo' ][ busy ] ) button{animation:none}}.os-button__spinner{box-sizing:border-box;display:inline-block;width:12px;height:12px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:os-button-spin 0.6s linear infinite;flex-shrink:0}@keyframes os-button-spin{to{transform:rotate( 360deg )}}`,K=class K extends D{render(){const t=this.disabled!==null,e=this.busy!==null,n=this.type||"button";return y`
9 + </div>`}requestUpdate(){super.requestUpdate(),queueMicrotask(()=>this._paint())}connectedCallback(){super.connectedCallback(),queueMicrotask(()=>this._paint())}_paint(){const e=this.shadowRoot;if(!e)return;const t=this._readMax(),n=this.hasAttribute("indeterminate")||t<=0,r=n?0:this._readValue(t),s=n?0:r/t,i=Math.round(s*100),l=this.getAttribute("label")??"",c=this.hasAttribute("show-percent"),f=e.querySelector(".fill");f&&!n?f.style.width=`${(s*100).toFixed(2)}%`:f&&n&&f.style.removeProperty("width");const a=e.querySelector(".header"),d=e.querySelector(".label"),u=e.querySelector(".percent");if(a&&d&&u){const m=l||c&&!n;a.hidden=!m,d.textContent=l,u.hidden=!(c&&!n),u.textContent=`${i}%`}this._syncAria(t,r,n,l);const p=e.querySelector(".track");p&&(p.setAttribute("role","progressbar"),p.setAttribute("aria-valuemin","0"),n?(p.removeAttribute("aria-valuenow"),p.removeAttribute("aria-valuemax")):(p.setAttribute("aria-valuemax",String(t)),p.setAttribute("aria-valuenow",String(r))),l?p.setAttribute("aria-label",l):p.removeAttribute("aria-label"))}_syncAria(e,t,n,r){this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),n?(this.removeAttribute("aria-valuenow"),this.removeAttribute("aria-valuemax")):(this.setAttribute("aria-valuemax",String(e)),this.setAttribute("aria-valuenow",String(t)));const s=this.getAttribute("aria-label");r?(s===null||s===this._ownedAriaLabel)&&(this.setAttribute("aria-label",r),this._ownedAriaLabel=r):s!==null&&s===this._ownedAriaLabel&&(this.removeAttribute("aria-label"),this._ownedAriaLabel=null)}_readMax(){const e=this.getAttribute("max");if(e===null)return 100;const t=parseFloat(e);return Number.isFinite(t)?t:100}_readValue(e){const t=parseFloat(this.getAttribute("value")??"0");return!Number.isFinite(t)||t<0?0:t>e?e:t}};W.props=["value","max","indeterminate","tone","label","showPercent"],W.styles=[ro],W.help=void 0;let we=W;P("os-progress-bar",we);const so=k` ${F} ${ve} ${Ke} ${Xe} ${Ge} ${Je}:host{display:inline-flex}:host( [ fill-cell ] ){display:flex;width:100%}button{appearance:none;display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:var( --os-ui-button-padding,6px 12px );border-radius:var( --os-ui-button-border-radius,6px );font:inherit;font-weight:500;cursor:pointer;transition:background-color var( --_holo-t ) ease,color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,transform 80ms ease;background:var( --os-ui-button-bg,transparent );background-image:var( --os-ui-button-bg-image,none );background-repeat:var( --os-ui-button-bg-image-repeat,repeat );background-size:var( --os-ui-button-bg-image-size,auto );background-position:var( --os-ui-button-bg-image-position,center );color:var( --os-ui-button-fg,var( --os-ui-fg,#1d2327 ) );border:var( --os-ui-button-border,1px solid var( --os-ui-border,#c3c4c7 ) )}:host( [ fill-cell ] ) button{width:100%;min-height:var( --os-ui-button-min-height,44px )}button:disabled{opacity:0.5;cursor:not-allowed}button:active:not(:disabled ){transform:translateY( 1px )}button:hover:not(:disabled ){background-color:var( --os-ui-button-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.04 ) ) )}button:focus-visible{outline:none;box-shadow:var( --_holo-focus )}button:disabled::before,button:disabled::after,button:disabled .os-holo-glint{opacity:0 !important}:host( [ variant='primary' ] ) button{background-color:var( --os-ui-button-bg,var( --wp-admin-theme-color,#2271b1 ) );color:var( --os-ui-button-fg,var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) ) );border:var( --os-ui-button-border,1px solid transparent )}:host( [ variant='primary' ] ) button:hover:not(:disabled ){filter:brightness( 1.06 );background-color:var( --os-ui-button-bg,var( --wp-admin-theme-color,#2271b1 ) );box-shadow:var( --_holo-glow )}:host( [ variant='holo' ] ) button{background-color:transparent;background-image:var( --_holo-fill );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;color:var( --os-ui-button-fg,var( --_holo-ink ) );border:var( --os-ui-button-border,1px solid transparent );box-shadow:var( --_holo-glow );font-weight:600;transition:background-position var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,filter var( --_holo-t ) ease,transform 80ms ease}:host( [ variant='holo' ] ) button:hover:not(:disabled ){background-color:transparent;background-position:74% 66%;box-shadow:var( --_holo-glow-strong )}:host( [ variant='holo' ] ) button:active:not(:disabled ){background-position:88% 82%;filter:brightness( 0.94 )}:host( [ variant='holo' ] ) button::before{display:none}@media ( prefers-reduced-motion:reduce ){:host( [ variant='holo' ] ) button:hover:not(:disabled ),:host( [ variant='holo' ] ) button:active:not(:disabled ){background-position:22% 28%}}:host( [ variant='secondary' ] ) button{background-color:var( --os-ui-button-bg,var( --os-ui-hover,rgba( 0,0,0,0.06 ) ) );color:var( --os-ui-button-fg,var( --os-ui-fg,#1d2327 ) );border:var( --os-ui-button-border,1px solid transparent )}:host( [ variant='secondary' ] ) button:hover:not(:disabled ){background-color:var( --os-ui-button-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.1 ) ) )}:host( [ variant='danger' ] ) button{background-color:var( --os-ui-button-bg,transparent );color:var( --os-ui-button-fg,var( --os-ui-danger,#d63638 ) );border:var( --os-ui-button-border,1px solid currentColor )}:host( [ variant='danger' ] ) button:hover:not(:disabled ){background-color:var( --os-ui-danger,#d63638 );color:var( --os-ui-fg-on-accent,#fff )}:host( [ variant='danger' ] ) button::after{display:none}:host( [ variant='link' ] ) button{background-color:transparent;background-image:none;color:var( --os-ui-button-fg,var( --wp-admin-theme-color,#2271b1 ) );border:0;padding:0;text-decoration:underline}:host( [ variant='link' ] ) button::before,:host( [ variant='link' ] ) button::after,:host( [ variant='link' ] ) .os-holo-glint,:host( [ variant='link' ] ) .os-holo-ring{display:none}:host( [ variant='link' ] ) button:active:not(:disabled ){transform:none}:host( [ busy ] ) button{pointer-events:none;opacity:0.75}:host( [ variant='holo' ][ busy ] ) button{animation:os-holo-drift 12s ease-in-out infinite}@media ( prefers-reduced-motion:reduce ){:host( [ variant='holo' ][ busy ] ) button{animation:none}}.os-button__spinner{box-sizing:border-box;display:inline-block;width:12px;height:12px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:os-button-spin 0.6s linear infinite;flex-shrink:0}@keyframes os-button-spin{to{transform:rotate( 360deg )}}`,K=class K extends L{static get observedAttributes(){return[...super.observedAttributes,"aria-label"]}render(){const e=this.disabled!==null,t=this.busy!==null,n=this.type||"button",r=this.getAttribute("aria-label")||"";return x`
10 10 <button
11 11 part="button"
12 12 class="os-holo-edge os-holo-sheen"
13 13 type=${n}
14 - ?disabled=${t||e}
15 - aria-busy=${e?"true":"false"}
14 + ?disabled=${e||t}
15 + aria-busy=${t?"true":"false"}
16 + aria-label=${r}
16 17 >
17 - ${e?y`<span class="os-button__spinner" aria-hidden="true"></span>`:""}
18 + ${t?x`<span class="os-button__spinner" aria-hidden="true"></span>`:""}
18 19 <slot></slot>
19 20 <!--
20 21 The two motion layers. Elements rather than
21 22 pseudo-elements because the sheen and the hairline
@@ -25,16 +26,16 @@
25 26 -->
26 27 <span class="os-holo-glint" aria-hidden="true"></span>
27 28 <span class="os-holo-ring" aria-hidden="true"></span>
28 29 </button>
29 - `}};K.props=["variant","disabled","type","busy","fill-cell"],K.styles=[Kt],K.help=void 0;let xe=K;U("os-button",xe);const $=new Map;let L=null;function Wt(){if(document.body.hasAttribute("data-os-suppress-upload-hud")||window.__wpdUploadHud)return;window.__wpdUploadHud=!0;const o="desktop-mode/os-file-drop-hud";N(x.UPLOAD_STARTED,o,t=>Xt(t.file,t.fields,t.abort)),N(x.UPLOAD_PROGRESS,o,t=>Gt(t.file,t.loaded,t.total,t.indeterminate)),N(x.AFTER_UPLOAD,o,t=>Vt(t.file,t.fields,t.result)),N(x.UPLOAD_FAILED,o,t=>Jt(t.file,t.error))}function Xt(o,t,e){const n=Yt(),r=document.createElement("div");r.className="os-upload-hud__row";const s=document.createElement("div");s.className="os-upload-hud__meta";const i=document.createElement("div");i.className="os-upload-hud__name",i.textContent=t.filename||o.name,i.title=t.filename||o.name;const l=document.createElement("div");l.className="os-upload-hud__status",l.textContent="Uploading…",s.append(i,l);const c=document.createElement("os-progress-bar");c.setAttribute("indeterminate",""),c.setAttribute("show-percent","");const p=document.createElement("div");p.className="os-upload-hud__actions";const a=document.createElement("os-button");a.setAttribute("variant","tertiary"),a.setAttribute("size","small"),a.textContent="Cancel",a.addEventListener("click",()=>{const d=$.get(o);d&&(d.state==="running"?(d.statusEl.textContent="Cancelling…",d.cancelBtn.disabled=!0,d.abort()):ye(d))}),p.appendChild(a),r.append(s,c,p),n.querySelector(".os-upload-hud__list").appendChild(r),$.set(o,{file:o,abort:e,root:r,bar:c,statusEl:l,cancelBtn:a,state:"running",lingerTimer:null}),se()}function Gt(o,t,e,n){const r=$.get(o);!r||r.state!=="running"||(n||e<=0?(r.bar.setAttribute("indeterminate",""),r.statusEl.textContent=`${B(t)} sent`):(r.bar.removeAttribute("indeterminate"),r.bar.setAttribute("max",String(e)),r.bar.setAttribute("value",String(t)),r.statusEl.textContent=`${B(t)} / ${B(e)}`))}function Vt(o,t,e){const n=$.get(o);n&&(n.state="success",n.bar.removeAttribute("indeterminate"),n.bar.setAttribute("value","100"),n.bar.setAttribute("max","100"),n.bar.setAttribute("tone","success"),n.statusEl.textContent="Uploaded",n.cancelBtn.textContent="Dismiss",n.lingerTimer=setTimeout(()=>ye(n),2500),se(),de.publish("os/upload-hud-complete",{filename:t.filename||e.filename,attachmentId:e.id}))}function Jt(o,t){const e=$.get(o);e&&(e.bar.removeAttribute("indeterminate"),e.bar.setAttribute("tone","danger"),e.cancelBtn.textContent="Dismiss",e.cancelBtn.disabled=!1,t.name==="UploadAbortedError"?(e.state="aborted",e.statusEl.textContent="Cancelled"):(e.state="failed",e.statusEl.textContent=t.message||"Upload failed"),se())}function ye(o){o.lingerTimer&&clearTimeout(o.lingerTimer),$.delete(o.file),o.root.remove(),se(),$.size===0&&L&&(L.hidden=!0)}function Yt(){if(L&&L.isConnected)return L.hidden=!1,L;const o=document.createElement("div");o.className="os-upload-hud",o.setAttribute("role","region"),o.setAttribute("aria-label","Uploads");const t=document.createElement("div");t.className="os-upload-hud__header";const e=document.createElement("div");e.className="os-upload-hud__title",e.textContent="Uploads";const n=document.createElement("button");n.type="button",n.className="os-upload-hud__close",n.setAttribute("aria-label","Hide upload panel"),n.textContent="×",n.addEventListener("click",()=>{for(const s of[...$.values()])s.state!=="running"&&ye(s);$.size===0&&(o.hidden=!0)}),t.append(e,n);const r=document.createElement("div");return r.className="os-upload-hud__list",o.append(t,r),document.body.appendChild(o),L=o,o}function se(){if(!L)return;const o=L.querySelector(".os-upload-hud__title");if(!o)return;const t=$.size,e=[...$.values()].filter(n=>n.state==="running").length;e>0?o.textContent=e===t?`Uploading ${e} file${e===1?"":"s"}…`:`${e} of ${t} uploading…`:t>0?o.textContent=`Uploads (${t})`:o.textContent="Uploads"}function Zt(){if(document.body.hasAttribute("data-os-suppress-media-library-refresh"))return;const o=window;o.__wpdMediaLibraryRefresher||(o.__wpdMediaLibraryRefresher=!0,N(x.AFTER_UPLOAD,"desktop-mode/os-file-drop-library-refresh",()=>Qt()))}function Qt(){const o=document.querySelectorAll("iframe");for(const t of Array.from(o))if(eo(Ye(t)))try{t.contentWindow?.location.reload()}catch{const e=Ye(t);e&&t.setAttribute("src",e)}}function Ye(o){try{return o.contentWindow?.location.href??o.src??""}catch{return o.src??""}}function eo(o){return o?/\/wp-admin\/upload\.php(?:[?#]|$)/.test(o):!1}let ie=null;function to(o){if(!ie||o.files.length===0||o.alreadyClaimed||!ie.config.enabled)return;const t=ue(o);oe(o.files,t,ie)}function oo(o){const t=o.config||{enabled:!1,allowedMimes:[],maxSize:0};Wt(),Zt();const e={config:t,mediaUrl:o.mediaUrl,restNonce:o.restNonce,filesUrl:o.filesUrl,storage:o.storage,openDialog:async(n,r,s)=>{const{openUploadDialog:i}=await Promise.resolve().then(()=>tt);await i({entries:n,context:r,mediaUrl:o.mediaUrl,restNonce:o.restNonce,filesUrl:o.filesUrl,storage:o.storage,forceDesktop:s?.forceDesktop,emptyDirs:s?.emptyDirs,mediaMaxBytes:t.maxSize})}};Ue(e),ie=e}async function no(o,t){const e=window.openStationConfig,n=e?.dropConfig??{enabled:!1,allowedMimes:[],maxSize:0},{partitionByPolicy:r,defaultFields:s}=await Promise.resolve().then(()=>$t),{accepted:i,rejected:l}=r(o,n);if(l.length>0){const{showToast:a}=await Promise.resolve().then(()=>gt);a({message:l.length===1?l[0].message:`${l.length} files can't be uploaded.`})}if(i.length===0)return;const c=i.map(({file:a,mime:d})=>({file:a,mime:d,fields:s(a,d),relativePath:t?a.webkitRelativePath??"":""})),{openUploadDialog:p}=await Promise.resolve().then(()=>tt);await p({entries:c,context:{surface:"folder",folderId:0,x:0,y:0},mediaUrl:e?.mediaUrl??"",restNonce:e?.restNonce??"",filesUrl:e?.filesUrl,storage:e?.desktopStorage,forceDesktop:t,preferDesktop:!0,mediaMaxBytes:n.maxSize})}window.openStationFileDrop={boot:oo,replayCapturedDrop:to,routePickedFiles:no};const ro=k` ${T}: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;--os-ui-fg:var( --os-ui-modal-text,#f0f0f1 );--os-ui-fg-muted:var( --os-ui-modal-text-muted,#a7aaad );--os-ui-border:var( --os-ui-modal-border,rgba( 255,255,255,0.25 ) );--os-window-bg:var( --os-ui-modal-field-bg,#2c3338 );--os-ui-button-bg-hover:var( --os-ui-modal-button-bg-hover,rgba( 255,255,255,0.08 ) );--os-ui-surface:var( --os-ui-modal-surface,#2c3338 );--os-ui-surface-elevated:var( --os-ui-modal-surface-elevated,#3c434a );--os-ui-border-strong:var( --os-ui-modal-border-strong,rgba( 255,255,255,0.35 ) );--os-ui-hover:var( --os-ui-modal-hover,rgba( 255,255,255,0.08 ) )}:host( [ open ] ){display:flex;animation:os-modal-scrim var( --_holo-t ) var( --_holo-ease )}:host( [ open ] ) .dialog{animation:os-modal-dialog var( --_holo-t ) var( --_holo-spring )}@keyframes os-modal-scrim{from{opacity:0}}@keyframes os-modal-dialog{from{opacity:0;transform:scale( 0.96 ) translateY( 8px )}}@media ( prefers-reduced-motion:reduce ){:host( [ open ] ),:host( [ open ] ) .dialog{animation:none}}.dialog{max-width:92vw;max-height:90vh;background-color:var( --os-ui-modal-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-modal-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 );display:flex;flex-direction:column;overflow:hidden}:host( [ size='sm' ] ) .dialog{width:min( 360px,92vw )}:host(:not( [ size ] ) ) .dialog,:host( [ size='md' ] ) .dialog{width:min( 540px,92vw )}:host( [ size='lg' ] ) .dialog{width:min( 760px,94vw )}.header{display:flex;align-items:center;gap:10px;padding:16px 20px 12px;border-bottom:1px solid var( --os-ui-border,rgba( 255,255,255,0.06 ) )}.title{margin:0;flex:1;font-size:15px;font-weight:600}.header-actions{display:flex;gap:6px}.header-actions::slotted( * ){margin-inline-start:6px}.close{background:transparent;border:0;color:inherit;font-size:18px;line-height:1;padding:4px 8px;border-radius:4px;cursor:pointer;opacity:0.7}.close:hover{opacity:1;background:var( --os-ui-hover,rgba( 255,255,255,0.08 ) )}.body{padding:16px 20px;overflow:auto;flex:1 1 auto;font-size:13px;line-height:1.5}.footer{padding:12px 20px 16px;border-top:1px solid var( --os-ui-border,rgba( 255,255,255,0.06 ) )}.footer slot{display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap}:host( [ mandatory ] ) .close{display:none}`,Ze='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',W=class W extends D{constructor(){super(...arguments),this._prevFocus=null,this._onKey=t=>{if(t.key==="Escape"&&!this.hasAttribute("mandatory")){t.preventDefault(),this._cancel();return}if(t.key==="Tab"){const e=this._focusables();if(e.length===0)return;const n=e[0],r=e[e.length-1],s=this.ownerDocument,i=s?s.activeElement:null,l=t.composedPath()[0]||i;t.shiftKey&&l===n?(t.preventDefault(),r.focus()):!t.shiftKey&&l===r&&(t.preventDefault(),n.focus())}},this._onBackdrop=t=>{if(this.hasAttribute("mandatory"))return;const e=t.composedPath();(e.length>0?e[0]:t.target)===this&&this._cancel()}}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)}attributeChangedCallback(t,e,n){if(super.attributeChangedCallback?.(t,e,n),t==="open"){if(n!==null){const r=this.ownerDocument;this._prevFocus=r?r.activeElement:null,queueMicrotask(()=>this._focusFirst())}else if(this._prevFocus){try{this._prevFocus.focus()}catch{}this._prevFocus=null}}}showModal(){this.setAttribute("open","")}hideModal(){this.removeAttribute("open")}_focusables(){const t=this.shadowRoot;if(!t)return[];const e=Array.from(this.querySelectorAll(Ze)),n=Array.from(t.querySelectorAll(Ze));return[...e,...n].filter(r=>r.offsetParent!==null||r.tagName==="BUTTON")}_focusFirst(){const t=this._focusables();t.length>0?t[0].focus():this.shadowRoot?.querySelector(".dialog")?.focus?.()}_cancel(){const t=new CustomEvent("os-modal-cancel",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(t)&&this.hideModal()}render(){const t=this.getAttribute("title")??"",e=this.hasAttribute("mandatory");return y`
30 + `}};K.props=["variant","disabled","type","busy","fill-cell"],K.styles=[so],K.help=void 0;let ye=K;P("os-button",ye);const S=new Map;let D=null;function io(){if(document.body.hasAttribute("data-os-suppress-upload-hud")||window.__wpdUploadHud)return;window.__wpdUploadHud=!0;const o="desktop-mode/os-file-drop-hud";I(w.UPLOAD_STARTED,o,e=>ao(e.file,e.fields,e.abort)),I(w.UPLOAD_PROGRESS,o,e=>lo(e.file,e.loaded,e.total,e.indeterminate)),I(w.AFTER_UPLOAD,o,e=>co(e.file,e.fields,e.result)),I(w.UPLOAD_FAILED,o,e=>uo(e.file,e.error))}function ao(o,e,t){const n=fo(),r=document.createElement("div");r.className="os-upload-hud__row";const s=document.createElement("div");s.className="os-upload-hud__meta";const i=document.createElement("div");i.className="os-upload-hud__name",i.textContent=e.filename||o.name,i.title=e.filename||o.name;const l=document.createElement("div");l.className="os-upload-hud__status",l.textContent="Uploading…",s.append(i,l);const c=document.createElement("os-progress-bar");c.setAttribute("indeterminate",""),c.setAttribute("show-percent","");const f=document.createElement("div");f.className="os-upload-hud__actions";const a=document.createElement("os-button");a.setAttribute("variant","tertiary"),a.setAttribute("size","small"),a.textContent="Cancel",a.addEventListener("click",()=>{const d=S.get(o);d&&(d.state==="running"?(d.statusEl.textContent="Cancelling…",d.cancelBtn.disabled=!0,d.abort()):_e(d))}),f.appendChild(a),r.append(s,c,f),n.querySelector(".os-upload-hud__list").appendChild(r),S.set(o,{file:o,abort:t,root:r,bar:c,statusEl:l,cancelBtn:a,state:"running",lingerTimer:null}),ie()}function lo(o,e,t,n){const r=S.get(o);!r||r.state!=="running"||(n||t<=0?(r.bar.setAttribute("indeterminate",""),r.statusEl.textContent=`${q(e)} sent`):(r.bar.removeAttribute("indeterminate"),r.bar.setAttribute("max",String(t)),r.bar.setAttribute("value",String(e)),r.statusEl.textContent=`${q(e)} / ${q(t)}`))}function co(o,e,t){const n=S.get(o);n&&(n.state="success",n.bar.removeAttribute("indeterminate"),n.bar.setAttribute("value","100"),n.bar.setAttribute("max","100"),n.bar.setAttribute("tone","success"),n.statusEl.textContent="Uploaded",n.cancelBtn.textContent="Dismiss",n.lingerTimer=setTimeout(()=>_e(n),2500),ie(),fe.publish("os/upload-hud-complete",{filename:e.filename||t.filename,attachmentId:t.id}))}function uo(o,e){const t=S.get(o);t&&(t.bar.removeAttribute("indeterminate"),t.bar.setAttribute("tone","danger"),t.cancelBtn.textContent="Dismiss",t.cancelBtn.disabled=!1,e.name==="UploadAbortedError"?(t.state="aborted",t.statusEl.textContent="Cancelled"):(t.state="failed",t.statusEl.textContent=e.message||"Upload failed"),ie())}function _e(o){o.lingerTimer&&clearTimeout(o.lingerTimer),S.delete(o.file),o.root.remove(),ie(),S.size===0&&D&&(D.hidden=!0)}function fo(){if(D&&D.isConnected)return D.hidden=!1,D;const o=document.createElement("div");o.className="os-upload-hud",o.setAttribute("role","region"),o.setAttribute("aria-label","Uploads");const e=document.createElement("div");e.className="os-upload-hud__header";const t=document.createElement("div");t.className="os-upload-hud__title",t.textContent="Uploads";const n=document.createElement("button");n.type="button",n.className="os-upload-hud__close",n.setAttribute("aria-label","Hide upload panel"),n.textContent="×",n.addEventListener("click",()=>{for(const s of[...S.values()])s.state!=="running"&&_e(s);S.size===0&&(o.hidden=!0)}),e.append(t,n);const r=document.createElement("div");return r.className="os-upload-hud__list",o.append(e,r),document.body.appendChild(o),D=o,o}function ie(){if(!D)return;const o=D.querySelector(".os-upload-hud__title");if(!o)return;const e=S.size,t=[...S.values()].filter(n=>n.state==="running").length;t>0?o.textContent=t===e?`Uploading ${t} file${t===1?"":"s"}…`:`${t} of ${e} uploading…`:e>0?o.textContent=`Uploads (${e})`:o.textContent="Uploads"}function po(){if(document.body.hasAttribute("data-os-suppress-media-library-refresh"))return;const o=window;o.__wpdMediaLibraryRefresher||(o.__wpdMediaLibraryRefresher=!0,I(w.AFTER_UPLOAD,"desktop-mode/os-file-drop-library-refresh",()=>ho()))}function ho(){const o=document.querySelectorAll("iframe");for(const e of Array.from(o))if(mo(Ye(e)))try{e.contentWindow?.location.reload()}catch{const t=Ye(e);t&&e.setAttribute("src",t)}}function Ye(o){try{return o.contentWindow?.location.href??o.src??""}catch{return o.src??""}}function mo(o){return o?/\/wp-admin\/upload\.php(?:[?#]|$)/.test(o):!1}let ae=null;function bo(o){if(!ae||o.files.length===0||o.alreadyClaimed||!ae.config.enabled)return;const e=he(o);ne(o.files,e,ae)}function go(o){const e=o.config||{enabled:!1,allowedMimes:[],maxSize:0};io(),po();const t={config:e,mediaUrl:o.mediaUrl,restNonce:o.restNonce,filesUrl:o.filesUrl,storage:o.storage,openDialog:async(n,r,s)=>{const{openUploadDialog:i}=await Promise.resolve().then(()=>at);await i({entries:n,context:r,mediaUrl:o.mediaUrl,restNonce:o.restNonce,filesUrl:o.filesUrl,storage:o.storage,forceDesktop:s?.forceDesktop,emptyDirs:s?.emptyDirs,mediaMaxBytes:e.maxSize})}};Pe(t),ae=t}async function vo(o,e){const t=window.openStationConfig,n=t?.dropConfig??{enabled:!1,allowedMimes:[],maxSize:0},{partitionByPolicy:r,defaultFields:s}=await Promise.resolve().then(()=>zt),{accepted:i,rejected:l}=r(o,n);if(l.length>0){const{showToast:a}=await Promise.resolve().then(()=>St);a({message:l.length===1?l[0].message:`${l.length} files can't be uploaded.`})}if(i.length===0)return;const c=i.map(({file:a,mime:d})=>({file:a,mime:d,fields:s(a,d),relativePath:e?a.webkitRelativePath??"":""})),{openUploadDialog:f}=await Promise.resolve().then(()=>at);await f({entries:c,context:{surface:"folder",folderId:0,x:0,y:0},mediaUrl:t?.mediaUrl??"",restNonce:t?.restNonce??"",filesUrl:t?.filesUrl,storage:t?.desktopStorage,forceDesktop:e,preferDesktop:!0,mediaMaxBytes:n.maxSize})}window.openStationFileDrop={boot:go,replayCapturedDrop:bo,routePickedFiles:vo};const xo=k` ${F}: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;--os-ui-fg:var( --os-ui-modal-text,#f0f0f1 );--os-ui-fg-muted:var( --os-ui-modal-text-muted,#a7aaad );--os-ui-border:var( --os-ui-modal-border,rgba( 255,255,255,0.25 ) );--os-window-bg:var( --os-ui-modal-field-bg,#2c3338 );--os-ui-button-bg-hover:var( --os-ui-modal-button-bg-hover,rgba( 255,255,255,0.08 ) );--os-ui-surface:var( --os-ui-modal-surface,#2c3338 );--os-ui-surface-elevated:var( --os-ui-modal-surface-elevated,#3c434a );--os-ui-border-strong:var( --os-ui-modal-border-strong,rgba( 255,255,255,0.35 ) );--os-ui-hover:var( --os-ui-modal-hover,rgba( 255,255,255,0.08 ) );--os-ui-notice-color:var( --os-ui-modal-text,#f0f0f1 );--os-ui-card-bg:var( --os-ui-modal-surface,#2c3338 );--os-ui-card-fg:var( --os-ui-modal-text,#f0f0f1 );--os-ui-card-border:var( --os-ui-modal-border,rgba( 255,255,255,0.25 ) );--os-ui-card-border-hover:var( --os-ui-modal-border-strong,rgba( 255,255,255,0.35 ) )}:host( [ open ] ){display:flex;animation:os-modal-scrim var( --_holo-t ) var( --_holo-ease )}:host( [ open ] ) .dialog{animation:os-modal-dialog var( --_holo-t ) var( --_holo-spring )}@keyframes os-modal-scrim{from{opacity:0}}@keyframes os-modal-dialog{from{opacity:0;transform:scale( 0.96 ) translateY( 8px )}}@media ( prefers-reduced-motion:reduce ){:host( [ open ] ),:host( [ open ] ) .dialog{animation:none}}.dialog{max-width:92vw;max-height:90vh;background-color:var( --os-ui-modal-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-modal-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 );display:flex;flex-direction:column;overflow:hidden}:host( [ size='sm' ] ) .dialog{width:min( 360px,92vw )}:host(:not( [ size ] ) ) .dialog,:host( [ size='md' ] ) .dialog{width:min( 540px,92vw )}:host( [ size='lg' ] ) .dialog{width:min( 760px,94vw )}.header{display:flex;align-items:center;gap:10px;padding:16px 20px 12px;border-bottom:1px solid var( --os-ui-border,rgba( 255,255,255,0.06 ) )}.title{margin:0;flex:1;font-size:15px;font-weight:600}.header-actions{display:flex;gap:6px}.header-actions::slotted( * ){margin-inline-start:6px}.close{background:transparent;border:0;color:inherit;font-size:18px;line-height:1;padding:4px 8px;border-radius:4px;cursor:pointer;opacity:0.7}.close:hover{opacity:1;background:var( --os-ui-hover,rgba( 255,255,255,0.08 ) )}.body{padding:16px 20px;overflow:auto;flex:1 1 auto;font-size:13px;line-height:1.5}.footer{padding:12px 20px 16px;border-top:1px solid var( --os-ui-border,rgba( 255,255,255,0.06 ) )}.footer slot{display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap}:host( [ mandatory ] ) .close{display:none}`,Ze='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',X=class X extends L{constructor(){super(...arguments),this._prevFocus=null,this._onKey=e=>{if(e.key==="Escape"&&!this.hasAttribute("mandatory")){e.preventDefault(),this._cancel();return}if(e.key==="Tab"){const t=this._focusables();if(t.length===0)return;const n=t[0],r=t[t.length-1],s=this.ownerDocument,i=s?s.activeElement:null,l=e.composedPath()[0]||i;e.shiftKey&&l===n?(e.preventDefault(),r.focus()):!e.shiftKey&&l===r&&(e.preventDefault(),n.focus())}},this._onBackdrop=e=>{if(this.hasAttribute("mandatory"))return;const t=e.composedPath();(t.length>0?t[0]:e.target)===this&&this._cancel()}}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)}attributeChangedCallback(e,t,n){if(super.attributeChangedCallback?.(e,t,n),e==="open"){if(n!==null){const r=this.ownerDocument;this._prevFocus=r?r.activeElement:null,queueMicrotask(()=>this._focusFirst())}else if(this._prevFocus){try{this._prevFocus.focus()}catch{}this._prevFocus=null}}}showModal(){this.setAttribute("open","")}hideModal(){this.removeAttribute("open")}_focusables(){const e=this.shadowRoot;if(!e)return[];const t=Array.from(this.querySelectorAll(Ze)),n=Array.from(e.querySelectorAll(Ze));return[...t,...n].filter(r=>r.offsetParent!==null||r.tagName==="BUTTON")}_focusFirst(){const e=this._focusables();e.length>0?e[0].focus():this.shadowRoot?.querySelector(".dialog")?.focus?.()}_cancel(){const e=new CustomEvent("os-modal-cancel",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e)&&this.hideModal()}render(){const e=this.getAttribute("title")??"",t=this.hasAttribute("mandatory");return x`
30 31 <div part="dialog" class="dialog" tabindex="-1">
31 - ${t?y`
32 + ${e?x`
32 33 <div class="header">
33 - <h2 class="title">${t}</h2>
34 + <h2 class="title">${e}</h2>
34 35 <div class="header-actions">
35 36 <slot name="header-actions"></slot>
36 - ${e?y``:y`<button
37 + ${t?x``:x`<button
37 38 type="button"
38 39 class="close"
39 40 aria-label="Close"
40 41 @click=${()=>this._cancel()}
@@ -40,9 +41,9 @@
40 41 @click=${()=>this._cancel()}
41 42 >×</button>`}
42 43 </div>
43 44 </div>
44 - `:y``}
45 + `:x``}
45 46 <div class="body">
46 47 <slot></slot>
47 48 </div>
48 49 <div class="footer">
@@ -48,49 +49,61 @@
48 49 <div class="footer">
49 50 <slot name="footer"></slot>
50 51 </div>
51 52 </div>
52 - `}};W.props=["open","title","size","mandatory"],W.styles=[ro],W.help=void 0;let we=W;U("os-modal",we);const so=k` ${T} ${ge}:host{display:flex;flex-direction:column;gap:4px;font-size:13px;color:var( --os-ui-fg,#1d2327 );min-width:0}:host( [ hidden ] ){display:none}.os-text-field__label{font-size:12px;color:var( --os-ui-fg-muted,#646970 )}.os-text-field__row{position:relative;display:flex;align-items:center;width:100%}input{appearance:none;-webkit-appearance:none;display:block;width:100%;min-width:0;box-sizing:border-box;padding:7px 10px;background:var( --os-window-bg,#fff );border:1px solid var( --os-ui-border,#dcdcde );border-radius:6px;font:inherit;font-size:13px;color:var( --os-ui-fg,#1d2327 )}.os-text-field__suffix{position:absolute;inset-inline-end:10px;top:50%;transform:translateY( -50% );pointer-events:none;font-size:12px;color:var( --os-ui-fg-muted,#646970 )}.os-text-field__row--has-reveal input{padding-inline-end:36px}.os-text-field__reveal{position:absolute;inset-inline-end:0;top:0;bottom:0;width:34px;display:flex;align-items:center;justify-content:center;padding:0;border:none;background:transparent;color:var( --os-ui-fg-muted,#646970 );cursor:pointer;border-radius:0 6px 6px 0;transition:color 0.12s ease}.os-text-field__reveal:hover{color:var( --os-ui-accent,#2271b1 )}.os-text-field__reveal:focus-visible{outline:none;color:var( --os-ui-accent,#2271b1 );box-shadow:inset 0 0 0 2px var( --os-ui-accent,#2271b1 );border-radius:0 6px 6px 0}.os-text-field__reveal:disabled{opacity:0.45;cursor:not-allowed}.os-text-field__input--masked{-webkit-text-security:disc;text-security:disc}@supports not ( ( -webkit-text-security:disc ) or ( text-security:disc ) ){.os-text-field__input--masked{font-family:text-security-disc,"password",monospace;letter-spacing:0.2em}}input:disabled{opacity:0.55;cursor:not-allowed;background:var( --os-ui-hover,rgba( 0,0,0,0.03 ) )}input[ aria-invalid='true' ],input[ aria-invalid='true' ]:hover:not(:disabled ){border-color:var( --os-ui-danger,#d63638 )}input[ aria-invalid='true' ]:focus,input[ aria-invalid='true' ]:focus-visible{border-color:var( --os-ui-danger,#d63638 );box-shadow:0 0 0 1px var( --os-ui-danger,#d63638 ),0 0 0 4px rgba( 214,54,56,0.18 )}input[ type='number' ]::-webkit-inner-spin-button,input[ type='number' ]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}input[ type='number' ]{-moz-appearance:textfield}`,X=class X extends D{constructor(){super(...arguments),this._revealed=!1}connectedCallback(){super.connectedCallback(),Ke(this)}render(){const t=this.label||"",e=this.value??"",n=this.placeholder||"",r=this.disabled!==null,s=this.readonly!==null,i=this.autocomplete,l=this.type||"text",c=l==="password";let p=i||"off";c&&(!i||p==="off")&&(p="new-password");const a=this.maxlength,d=this.minlength,u=this.pattern||"",h=this.name||"",m=this.suffix||"",f=this.invalid!==null,b=this.reveal!==null,v=l==="password",g=v&&!(b&&this._revealed);let w;v||b&&this._revealed?w="text":w=l;const _=b?"os-text-field__row os-text-field__row--has-reveal":"os-text-field__row",S=g?"os-text-field__input os-text-field__input--masked":"os-text-field__input",R=`${this.id||"os-unnamed"}__input`;return y`
53 - ${t?y`<label
54 - class="os-text-field__label"
55 - for=${R}
56 - >${t}</label>`:y``}
57 - <span class=${_}>
53 + `}};X.props=["open","title","size","mandatory"],X.styles=[xo],X.help=void 0;let ke=X;P("os-modal",ke);const wo=k` ${F} ${xe}:host{--_field-size:var( --os-ui-field-font-size,13px );--_field-radius:var( --os-ui-field-radius,6px );display:flex;flex-direction:column;gap:4px;font-size:var( --_field-size );color:var( --os-ui-fg,#1d2327 );min-width:0}:host( [ hidden ] ){display:none}.os-text-field__label{font-size:12px;color:var( --os-ui-fg-muted,#646970 )}.os-text-field__label--hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;white-space:nowrap;clip-path:inset( 50% )}.os-text-field__row{position:relative;display:flex;align-items:center;width:100%}input{appearance:none;-webkit-appearance:none;display:block;width:100%;min-width:0;box-sizing:border-box;padding:7px 10px;background:var( --os-window-bg,#fff );border:1px solid var( --os-ui-border,#dcdcde );border-radius:var( --_field-radius );font:inherit;font-size:var( --_field-size );color:var( --os-ui-fg,#1d2327 )}input:is( [ type='date' ],[ type='datetime-local' ],[ type='month' ],[ type='week' ] )::-webkit-calendar-picker-indicator{--_calendar-icon:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5'%3E%3Cpath d='M4.75 7.25L4.75 18C4.75 18.6904 5.30964 19.25 6 19.25H18C18.6904 19.25 19.25 18.6904 19.25 18V7.25V6C19.25 5.30964 18.6904 4.75 18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V7.25ZM19.25 7.25H4.75M7.25 10.75H9.25M11 10.75H13M14.75 10.75H16.75M7.25 14.5H9.25M11 14.5H13M14.75 14.5H16.75' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M18 4.75H6C5.30964 4.75 4.75 5.30964 4.75 6V7.25H19.25V6C19.25 5.30964 18.6904 4.75 18 4.75Z' fill='currentColor' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E");background:var( --os-ui-fg-muted,#646970 );-webkit-mask:var( --_calendar-icon ) center / contain no-repeat;mask:var( --_calendar-icon ) center / contain no-repeat;width:16px;height:16px;cursor:pointer}@media ( forced-colors:active ){input:is( [ type='date' ],[ type='datetime-local' ],[ type='month' ],[ type='week' ] )::-webkit-calendar-picker-indicator{background:ButtonText;forced-color-adjust:none}}.os-text-field__suffix{position:absolute;inset-inline-end:10px;top:50%;transform:translateY( -50% );pointer-events:none;font-size:12px;color:var( --os-ui-fg-muted,#646970 )}.os-text-field__row--has-reveal input{padding-inline-end:36px}:host( [ clearable ] ) input::-webkit-search-cancel-button{-webkit-appearance:none;display:none}.os-text-field__row--has-clear input{padding-inline-end:36px}.os-text-field__row--has-reveal.os-text-field__row--has-clear input{padding-inline-end:68px}.os-text-field__clear{position:absolute;inset-inline-end:0;top:0;bottom:0;width:34px;display:flex;align-items:center;justify-content:center;padding:0;border:none;background:transparent;color:var( --os-ui-fg-muted,#646970 );cursor:pointer;border-radius:0 6px 6px 0}.os-text-field__row--has-reveal .os-text-field__clear{inset-inline-end:34px;border-radius:0}.os-text-field__clear:hover{color:var( --os-ui-accent,#2271b1 )}.os-text-field__clear:focus-visible{outline:none;color:var( --os-ui-accent,#2271b1 );box-shadow:inset 0 0 0 2px var( --os-ui-accent,#2271b1 )}.os-text-field__clear:disabled{opacity:0.45;cursor:default}.os-text-field__reveal{position:absolute;inset-inline-end:0;top:0;bottom:0;width:34px;display:flex;align-items:center;justify-content:center;padding:0;border:none;background:transparent;color:var( --os-ui-fg-muted,#646970 );cursor:pointer;border-radius:0 6px 6px 0;transition:color 0.12s ease}.os-text-field__reveal:hover{color:var( --os-ui-accent,#2271b1 )}.os-text-field__reveal:focus-visible{outline:none;color:var( --os-ui-accent,#2271b1 );box-shadow:inset 0 0 0 2px var( --os-ui-accent,#2271b1 );border-radius:0 6px 6px 0}.os-text-field__reveal:disabled{opacity:0.45;cursor:not-allowed}.os-text-field__input--masked{-webkit-text-security:disc;text-security:disc}@supports not ( ( -webkit-text-security:disc ) or ( text-security:disc ) ){.os-text-field__input--masked{font-family:text-security-disc,"password",monospace;letter-spacing:0.2em}}input:disabled{opacity:0.55;cursor:not-allowed;background:var( --os-ui-hover,rgba( 0,0,0,0.03 ) )}input[ aria-invalid='true' ],input[ aria-invalid='true' ]:hover:not(:disabled ){border-color:var( --os-ui-danger,#d63638 )}input[ aria-invalid='true' ]:focus,input[ aria-invalid='true' ]:focus-visible{border-color:var( --os-ui-danger,#d63638 );box-shadow:0 0 0 1px var( --os-ui-danger,#d63638 ),0 0 0 4px rgba( 214,54,56,0.18 )}input[ type='number' ]::-webkit-inner-spin-button,input[ type='number' ]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}input[ type='number' ]{-moz-appearance:textfield}`,G=class G extends L{constructor(){super(...arguments),this._revealed=!1}connectedCallback(){super.connectedCallback(),We(this)}render(){const e=this.label||"",t=this.hideLabel!==null,n=this.value??"",r=this.placeholder||"",s=this.disabled!==null,i=this.readonly!==null,l=this.autocomplete,c=this.type||"text",f=c==="password";let a=l||"off";f&&(!l||a==="off")&&(a="new-password");const d=this.maxlength,u=this.minlength,p=this.pattern||"",m=this.name||"",h=this.suffix||"",b=this.invalid!==null,v=this.reveal!==null,g=this.clearable!==null,y=c==="password",_=y&&!(v&&this._revealed);let E;y||v&&this._revealed?E="text":E=c;const M=["os-text-field__row",v?"os-text-field__row--has-reveal":"",g?"os-text-field__row--has-clear":""].filter(Boolean).join(" "),z=_?"os-text-field__input os-text-field__input--masked":"os-text-field__input",lt=`${this.id||"os-unnamed"}__input`;return x`
54 + ${e?x`<label
55 + class=${t?"os-text-field__label os-text-field__label--hidden":"os-text-field__label"}
56 + for=${lt}
57 + >${e}</label>`:x``}
58 + <span class=${M}>
58 59 <input
59 - id=${R}
60 - class=${S}
61 - type=${w}
62 - .value=${e}
63 - placeholder=${n}
64 - ?disabled=${r}
65 - ?readonly=${s}
66 - autocomplete=${p}
67 - maxlength=${a??""}
68 - minlength=${d??""}
69 - pattern=${u}
70 - name=${h}
71 - aria-invalid=${f?"true":"false"}
72 - aria-label=${t||""}
73 - @input=${Y=>this._onInput(Y)}
74 - @change=${Y=>this._onChange(Y)}
75 - @keydown=${Y=>this._onKeyDown(Y)}
60 + id=${lt}
61 + class=${z}
62 + type=${E}
63 + .value=${n}
64 + placeholder=${r}
65 + ?disabled=${s}
66 + ?readonly=${i}
67 + autocomplete=${a}
68 + maxlength=${d??""}
69 + minlength=${u??""}
70 + pattern=${p}
71 + name=${m}
72 + aria-invalid=${b?"true":"false"}
73 + aria-label=${e||""}
74 + @input=${Z=>this._onInput(Z)}
75 + @change=${Z=>this._onChange(Z)}
76 + @keydown=${Z=>this._onKeyDown(Z)}
76 77 />
77 - ${m?y`<span class="os-text-field__suffix">${m}</span>`:y``}
78 - ${b?this._renderRevealButton(r):y``}
78 + ${h?x`<span class="os-text-field__suffix">${h}</span>`:x``}
79 + ${g&&n!==""?this._renderClearButton(s):x``}
80 + ${v?this._renderRevealButton(s):x``}
79 81 </span>
80 - `}_renderRevealButton(t){const e=this._revealed?"Hide":"Show";return y`
82 + `}_renderClearButton(e){return x`
81 83 <button
82 84 type="button"
85 + class="os-text-field__clear"
86 + aria-label="Clear"
87 + ?disabled=${e}
88 + tabindex="0"
89 + @click=${()=>this._onClear()}
90 + >
91 + ${yo()}
92 + </button>
93 + `}_onClear(){this.value="",this.emit("os-input-change",{value:""}),this.emit("os-input-commit",{value:""}),this.shadowRoot?.querySelector("input")?.focus()}_renderRevealButton(e){const t=this._revealed?"Hide":"Show";return x`
94 + <button
95 + type="button"
83 96 class="os-text-field__reveal"
84 - aria-label=${e}
97 + aria-label=${t}
85 98 aria-pressed=${this._revealed?"true":"false"}
86 - ?disabled=${t}
99 + ?disabled=${e}
87 100 tabindex="0"
88 101 @click=${()=>this._onToggleReveal()}
89 102 >
90 - ${this._revealed?ao():io()}
103 + ${this._revealed?ko():_o()}
91 104 </button>
92 - `}_onToggleReveal(){this._revealed=!this._revealed,this.requestUpdate()}_onInput(t){const e=t.target;this.value=e.value,this.emit("os-input-change",{value:e.value})}_onChange(t){const e=t.target;this.emit("os-input-commit",{value:e.value})}_onKeyDown(t){if(t.key==="Enter"&&!t.shiftKey&&!t.altKey&&!t.metaKey){const e=t.target;this.emit("os-submit",{value:e.value})}}};X.props=["label","value","placeholder","disabled","readonly","autocomplete","type","maxlength","minlength","pattern","name","suffix","invalid","reveal"],X.styles=[so],X.help=void 0;let _e=X;U("os-text-field",_e);function io(){return y`
105 + `}_onToggleReveal(){this._revealed=!this._revealed,this.requestUpdate()}_onInput(e){const t=e.target;this.value=t.value,this.emit("os-input-change",{value:t.value})}_onChange(e){const t=e.target;this.emit("os-input-commit",{value:t.value})}_onKeyDown(e){if(e.key==="Enter"&&!e.shiftKey&&!e.altKey&&!e.metaKey){const t=e.target;this.emit("os-submit",{value:t.value})}}};G.props=["label","hideLabel","value","placeholder","disabled","readonly","autocomplete","type","maxlength","minlength","pattern","name","suffix","invalid","reveal","clearable"],G.styles=[wo],G.help=void 0;let Ee=G;P("os-text-field",Ee);function yo(){return x`
93 106 <svg
94 107 viewBox="0 0 16 16"
95 108 width="14"
96 109 height="14"
@@ -97,8 +110,22 @@
97 110 fill="none"
98 111 stroke="currentColor"
99 112 stroke-width="1.5"
100 113 stroke-linecap="round"
114 + aria-hidden="true"
115 + focusable="false"
116 + >
117 + <path d="M4 4l8 8M12 4l-8 8" />
118 + </svg>
119 + `}function _o(){return x`
120 + <svg
121 + viewBox="0 0 16 16"
122 + width="14"
123 + height="14"
124 + fill="none"
125 + stroke="currentColor"
126 + stroke-width="1.5"
127 + stroke-linecap="round"
101 128 stroke-linejoin="round"
102 129 aria-hidden="true"
103 130 focusable="false"
104 131 >
@@ -104,9 +131,9 @@
104 131 >
105 132 <path d="M1 8C1 8 3.5 3 8 3s7 5 7 5-2.5 5-7 5S1 8 1 8z" />
106 133 <circle cx="8" cy="8" r="2" />
107 134 </svg>
108 - `}function ao(){return y`
135 + `}function ko(){return x`
109 136 <svg
110 137 viewBox="0 0 16 16"
111 138 width="14"
112 139 height="14"
@@ -121,19 +148,19 @@
121 148 <path d="M1 8C1 8 3.5 3 8 3s7 5 7 5-2.5 5-7 5S1 8 1 8z" />
122 149 <circle cx="8" cy="8" r="2" />
123 150 <line x1="2" y1="2" x2="14" y2="14" />
124 151 </svg>
125 - `}const lo=k` ${T} ${ge}:host{display:flex;flex-direction:column;gap:4px;font-size:13px;color:var( --os-ui-fg,#1d2327 );min-width:0}:host( [ hidden ] ){display:none}.os-textarea__label{font-size:12px;color:var( --os-ui-fg-muted,#646970 )}textarea{appearance:none;-webkit-appearance:none;display:block;width:100%;min-width:0;box-sizing:border-box;padding:8px 10px;background:var( --os-window-bg,#fff );border:1px solid var( --os-ui-border,#dcdcde );border-radius:6px;font:inherit;font-size:13px;line-height:1.45;color:var( --os-ui-fg,#1d2327 );resize:vertical}textarea:disabled{opacity:0.55;cursor:not-allowed;background:var( --os-ui-hover,rgba( 0,0,0,0.03 ) )}textarea[ aria-invalid='true' ],textarea[ aria-invalid='true' ]:hover:not(:disabled ){border-color:var( --os-ui-danger,#d63638 )}textarea[ aria-invalid='true' ]:focus,textarea[ aria-invalid='true' ]:focus-visible{border-color:var( --os-ui-danger,#d63638 );box-shadow:0 0 0 1px var( --os-ui-danger,#d63638 ),0 0 0 4px rgba( 214,54,56,0.18 )}:host( [ auto-grow ] ) textarea{resize:none;overflow:hidden}`,G=class G extends D{constructor(){super(...arguments),this._textareaEl=null}connectedCallback(){super.connectedCallback(),Ke(this)}render(){const t=this._attr("label")||"",e=this._attr("value")??"",n=this._attr("placeholder")||"",r=this._boolAttr("disabled"),s=this._boolAttr("readonly"),i=this._attr("aria-label")||t,l=this._attr("name")||"",c=Number(this._attr("rows"))||3,p=this._attr("maxlength"),a=this._attr("minlength"),d=this._boolAttr("invalid"),h=`${this.id||"os-unnamed"}__field`;return y`
126 - ${t?y`<label class="os-textarea__label" for=${h}>${t}</label>`:y``}
152 + `}const Eo=k` ${F} ${xe}:host{--_field-size:var( --os-ui-field-font-size,13px );--_field-radius:var( --os-ui-field-radius,6px );display:flex;flex-direction:column;gap:4px;font-size:var( --_field-size );color:var( --os-ui-fg,#1d2327 );min-width:0}:host( [ hidden ] ){display:none}.os-textarea__label{font-size:12px;color:var( --os-ui-fg-muted,#646970 )}textarea{appearance:none;-webkit-appearance:none;display:block;width:100%;min-width:0;box-sizing:border-box;padding:8px 10px;background:var( --os-window-bg,#fff );border:1px solid var( --os-ui-border,#dcdcde );border-radius:var( --_field-radius );font:inherit;font-size:var( --_field-size );line-height:1.45;color:var( --os-ui-fg,#1d2327 );resize:vertical}textarea:disabled{opacity:0.55;cursor:not-allowed;background:var( --os-ui-hover,rgba( 0,0,0,0.03 ) )}textarea[ aria-invalid='true' ],textarea[ aria-invalid='true' ]:hover:not(:disabled ){border-color:var( --os-ui-danger,#d63638 )}textarea[ aria-invalid='true' ]:focus,textarea[ aria-invalid='true' ]:focus-visible{border-color:var( --os-ui-danger,#d63638 );box-shadow:0 0 0 1px var( --os-ui-danger,#d63638 ),0 0 0 4px rgba( 214,54,56,0.18 )}:host( [ auto-grow ] ) textarea{resize:none;overflow:hidden}`,V=class V extends L{constructor(){super(...arguments),this._textareaEl=null}connectedCallback(){super.connectedCallback(),We(this)}render(){const e=this._attr("label")||"",t=this._attr("value")??"",n=this._attr("placeholder")||"",r=this._boolAttr("disabled"),s=this._boolAttr("readonly"),i=this._attr("aria-label")||e,l=this._attr("name")||"",c=Number(this._attr("rows"))||3,f=this._attr("maxlength"),a=this._attr("minlength"),d=this._boolAttr("invalid"),p=`${this.id||"os-unnamed"}__field`;return x`
153 + ${e?x`<label class="os-textarea__label" for=${p}>${e}</label>`:x``}
127 154 <textarea
128 - id=${h}
155 + id=${p}
129 156 part="textarea"
130 - .value=${e}
157 + .value=${t}
131 158 placeholder=${n}
132 159 ?disabled=${r}
133 160 ?readonly=${s}
134 161 rows=${c}
135 - maxlength=${p??""}
162 + maxlength=${f??""}
136 163 minlength=${a??""}
137 164 name=${l}
138 165 aria-invalid=${d?"true":"false"}
139 166 aria-label=${i||""}
@@ -140,9 +167,9 @@
140 167 @input=${m=>this._onInput(m)}
141 168 @change=${m=>this._onChange(m)}
142 169 @keydown=${m=>this._onKeyDown(m)}
143 170 ></textarea>
144 - `}_attr(t){return this.getAttribute(t)}_boolAttr(t){return this.getAttribute(t)!==null}_onInput(t){const e=t.target;this._textareaEl=e,this.setAttribute("value",e.value),this.emit("os-input-change",{value:e.value}),this._boolAttr("auto-grow")&&this._autosize(e)}_onChange(t){const e=t.target;this.emit("os-input-commit",{value:e.value})}_onKeyDown(t){if(this._boolAttr("submit-on-enter")&&t.key==="Enter"&&!t.shiftKey&&!t.altKey&&!t.metaKey&&!t.ctrlKey){t.preventDefault();const e=t.target;this.emit("os-submit",{value:e.value})}}_autosize(t){const e=Number(this._attr("max-rows"))||8,n=window.getComputedStyle(t),r=parseFloat(n.fontSize)||13,s=n.lineHeight,i=s==="normal"?r*1.45:parseFloat(s)||r*1.45,l=parseFloat(n.paddingTop)||0,c=parseFloat(n.paddingBottom)||0,p=i*e+l+c;t.style.height="auto";const a=Math.min(t.scrollHeight,p);t.style.height=`${a}px`}refreshAutosize(){this._textareaEl&&this._boolAttr("auto-grow")&&this._autosize(this._textareaEl)}focusInput(){(this.shadowRoot??this).querySelector("textarea")?.focus()}clear(){this.setAttribute("value","");const e=(this.shadowRoot??this).querySelector("textarea");e&&(e.value="",this._boolAttr("auto-grow")&&this._autosize(e))}};G.props=["label","value","placeholder","disabled","readonly","ariaLabel","name","rows","maxlength","minlength","invalid","autoGrow","maxRows","submitOnEnter"],G.styles=[lo],G.help=void 0;let ke=G;U("os-textarea",ke);const co=k` ${T}:host{display:inline-flex;position:relative;padding:3px;background:var( --os-ui-segmented-bg,var( --os-ui-hover,rgba( 0,0,0,0.05 ) ) );border-radius:8px;gap:2px}.os-segmented__thumb{position:absolute;top:3px;bottom:3px;left:0;width:var( --_thumb-w,0px );border-radius:6px;background-color:var( --os-ui-segmented-selected-bg,var( --os-ui-accent,#2271b1 ) );background-image:var( --os-ui-segmented-selected-image,none );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;transform:translateX( var( --_thumb-x,0px ) );pointer-events:none;opacity:0}:host( [ data-thumb ] ) .os-segmented__thumb{opacity:1}:host( [ data-thumb-ready ] ) .os-segmented__thumb{transition:transform var( --_holo-t-slow ) var( --_holo-spring ),width var( --_holo-t-slow ) var( --_holo-ease ),opacity var( --_holo-t-fast ) linear}@media ( prefers-reduced-motion:reduce ){:host( [ data-thumb-ready ] ) .os-segmented__thumb{transition-duration:1ms}}`,uo=k` ${T} ${be}:host{flex:1 1 auto;min-width:0}button{appearance:none;display:block;width:100%;padding:6px 13px;background:transparent;border:0;font:inherit;font-size:13px;color:var( --os-ui-fg-muted,#646970 );cursor:pointer;border-radius:6px;transition:background-color var( --_holo-t ) ease,color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,background-position var( --_holo-t ) ease;white-space:nowrap}button:hover{color:var( --os-ui-fg,#1d2327 )}button:focus-visible{outline:none;box-shadow:var( --_holo-focus )}:host( [ aria-checked='true' ] ) button{color:var( --os-ui-segmented-selected-fg,var( --os-ui-fg-on-accent,#fff ) );transition-duration:var( --_holo-t-fast )}:host( [ aria-checked='true' ] ) button::before{display:none}`,V=class V extends D{render(){return this.setAttribute("role","radio"),y`
171 + `}_attr(e){return this.getAttribute(e)}_boolAttr(e){return this.getAttribute(e)!==null}_onInput(e){const t=e.target;this._textareaEl=t,this.setAttribute("value",t.value),this.emit("os-input-change",{value:t.value}),this._boolAttr("auto-grow")&&this._autosize(t)}_onChange(e){const t=e.target;this.emit("os-input-commit",{value:t.value})}_onKeyDown(e){if(!(!this._boolAttr("submit-on-enter")||e.isComposing||e.keyCode===229)&&e.key==="Enter"&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey){e.preventDefault();const t=e.target;this.emit("os-submit",{value:t.value})}}_autosize(e){const t=Number(this._attr("max-rows"))||8,n=window.getComputedStyle(e),r=parseFloat(n.fontSize)||13,s=n.lineHeight,i=s==="normal"?r*1.45:parseFloat(s)||r*1.45,l=parseFloat(n.paddingTop)||0,c=parseFloat(n.paddingBottom)||0,f=(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0),a=i*t+l+c+f;e.style.height="auto",e.style.overflowY="hidden";const d=e.value?e.scrollHeight+f:i*(Number(this._attr("rows"))||3)+l+c+f,u=Math.min(d,a);e.style.height=`${Math.ceil(u)}px`,e.style.overflowY=d>Math.ceil(a)?"auto":"hidden"}refreshAutosize(){this._textareaEl&&this._boolAttr("auto-grow")&&this._autosize(this._textareaEl)}focusInput(){(this.shadowRoot??this).querySelector("textarea")?.focus()}clear(){this.setAttribute("value","");const t=(this.shadowRoot??this).querySelector("textarea");t&&(t.value="",this._boolAttr("auto-grow")&&this._autosize(t))}};V.props=["label","value","placeholder","disabled","readonly","ariaLabel","name","rows","maxlength","minlength","invalid","autoGrow","maxRows","submitOnEnter"],V.styles=[Eo],V.help=void 0;let Ae=V;P("os-textarea",Ae);const Ao=k` ${F}:host{display:inline-flex;position:relative;padding:3px;background:var( --os-ui-segmented-bg,var( --os-ui-hover,rgba( 0,0,0,0.05 ) ) );border-radius:8px;gap:2px;box-shadow:var( --os-ui-segmented-edge,none )}.os-segmented__thumb{position:absolute;top:3px;bottom:3px;left:0;width:var( --_thumb-w,0px );border-radius:6px;background-color:var( --os-ui-segmented-selected-bg,color-mix( in srgb,var( --os-ui-accent,#2271b1 ) var( --os-ui-segmented-selected-accent,100% ),var( --os-ui-segmented-selected-base,var( --os-ui-surface,#fff ) ) ) );background-image:var( --os-ui-segmented-selected-image,none );box-shadow:var( --os-ui-segmented-selected-shadow,none );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;transform:translateX( var( --_thumb-x,0px ) );pointer-events:none;opacity:0}:host( [ data-thumb ] ) .os-segmented__thumb{opacity:1}:host( [ data-thumb-ready ] ) .os-segmented__thumb{transition:transform var( --_holo-t-slow ) var( --_holo-spring ),width var( --_holo-t-slow ) var( --_holo-ease ),opacity var( --_holo-t-fast ) linear}@media ( prefers-reduced-motion:reduce ){:host( [ data-thumb-ready ] ) .os-segmented__thumb{transition-duration:1ms}}`,Co=k` ${F} ${ve}:host{flex:1 1 auto;min-width:0;--_holo-sheen:var( --os-ui-segmented-hover-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% ) ) )}button{appearance:none;display:block;width:100%;padding:6px 13px;background:transparent;border:0;font:inherit;font-size:13px;color:var( --os-ui-fg-muted,#646970 );cursor:pointer;border-radius:6px;transition:background-color var( --_holo-t ) ease,color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,background-position var( --_holo-t ) ease;white-space:nowrap}button:hover{color:var( --os-ui-fg,#1d2327 )}:host(:not( [ aria-checked='true' ] ) ) button:hover{background-color:var( --os-ui-segmented-hover-bg,transparent )}button:focus-visible{outline:none;box-shadow:var( --_holo-focus )}:host( [ aria-checked='true' ] ) button{color:var( --os-ui-segmented-selected-fg,color-mix( in srgb,var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) ) var( --os-ui-segmented-selected-accent,100% ),var( --os-ui-fg,#1d2327 ) ) );transition-duration:var( --_holo-t-fast )}:host( [ aria-checked='true' ] ) button::before{display:none}`,J=class J extends L{render(){return this.setAttribute("role","radio"),x`
145 172 <button
146 173 type="button"
147 174 class="os-holo-sheen"
148 175 @click=${()=>this._onPick()}
@@ -148,12 +175,12 @@
148 175 @click=${()=>this._onPick()}
149 176 >
150 177 <slot></slot>
151 178 </button>
152 - `}_onPick(){this.emit("os-segment-pick",{value:this.value})}};V.props=["value"],V.styles=[uo],V.help=void 0;let Ee=V;U("os-segment",Ee);const J=class J extends D{constructor(){super(...arguments),this._resizeObserver=null}connectedCallback(){super.connectedCallback(),this.addEventListener("os-segment-pick",t=>{const e=t.detail;t.stopPropagation(),this.value=e.value,this.emit("os-pick",{value:e.value})}),typeof ResizeObserver<"u"&&(this._resizeObserver=new ResizeObserver(()=>this._placeThumb()),this._resizeObserver.observe(this))}disconnectedCallback(){this._resizeObserver?.disconnect(),this._resizeObserver=null}_placeThumb(){if(!this.shadowRoot?.querySelector(".os-segmented__thumb"))return;const e=this.value,n=Array.from(this.querySelectorAll(":scope > os-segment")).find(p=>p.getAttribute("value")===e);if(!n||this.offsetWidth===0){this.removeAttribute("data-thumb");return}const r=this.getBoundingClientRect(),s=r.width/this.offsetWidth,i=Math.abs(s-1)<.02?1:s;if(!(i>0))return;const l=n.getBoundingClientRect(),c=p=>`${Math.round(p*100)/100}px`;this.style.setProperty("--_thumb-x",c((l.left-r.left)/i)),this.style.setProperty("--_thumb-w",c(l.width/i)),this.setAttribute("data-thumb",""),this.hasAttribute("data-thumb-ready")||requestAnimationFrame(()=>this.setAttribute("data-thumb-ready",""))}set items(t){const e=this.querySelectorAll(":scope > os-segment");for(const s of Array.from(e))s.remove();for(const s of t){const i=document.createElement("os-segment");i.setAttribute("value",s.value),i.textContent=s.label,this.appendChild(i)}const n=this.value;!(n!==null&&t.some(s=>s.value===n))&&t.length>0?this.value=t[0].value:this.requestUpdate()}render(){const t=this.label||"";t&&this.setAttribute("aria-label",t),this.setAttribute("role","radiogroup");const e=this.value;return queueMicrotask(()=>{const n=this.querySelectorAll("os-segment");for(const r of Array.from(n)){const s=r.getAttribute("value");r.setAttribute("aria-checked",s===e?"true":"false")}this._placeThumb()}),y`<span class="os-segmented__thumb" aria-hidden="true"></span
153 - ><slot></slot>`}};J.props=["value","label"],J.styles=[co],J.help={title:"Segmented",summary:"iOS-style segmented radio group. Pill-shaped bar of equal-width <os-segment> children where exactly one is active.",status:"stable",props:[{name:"value",type:"string",description:"Currently selected segment value. Mirrored onto child aria-checked."},{name:"label",type:"string",description:"aria-label for the radiogroup."}],slots:[{name:"(default)",description:'<os-segment value="…"> children.'}],events:[{name:"os-pick",description:"Fires when the selected segment changes.",detail:"{ value: string }"}],cssProps:[{name:"--os-window-bg",description:"Pill background."},{name:"--os-ui-fg",description:"Active label colour."},{name:"--os-ui-fg-muted",description:"Inactive label colour."}],example:y`
179 + `}_onPick(){this.emit("os-segment-pick",{value:this.value})}};J.props=["value"],J.styles=[Co],J.help=void 0;let Ce=J;P("os-segment",Ce);const Y=class Y extends L{constructor(){super(...arguments),this._resizeObserver=null}connectedCallback(){super.connectedCallback(),this.addEventListener("os-segment-pick",e=>{const t=e.detail;e.stopPropagation(),this.value=t.value,this.emit("os-pick",{value:t.value})}),typeof ResizeObserver<"u"&&(this._resizeObserver=new ResizeObserver(()=>this._placeThumb()),this._resizeObserver.observe(this))}disconnectedCallback(){this._resizeObserver?.disconnect(),this._resizeObserver=null}_placeThumb(){if(!this.shadowRoot?.querySelector(".os-segmented__thumb"))return;const t=this.value,n=Array.from(this.querySelectorAll(":scope > os-segment")).find(f=>f.getAttribute("value")===t);if(!n||this.offsetWidth===0){this.removeAttribute("data-thumb");return}const r=this.getBoundingClientRect(),s=r.width/this.offsetWidth,i=Math.abs(s-1)<.02?1:s;if(!(i>0))return;const l=n.getBoundingClientRect(),c=f=>`${Math.round(f*100)/100}px`;this.style.setProperty("--_thumb-x",c((l.left-r.left)/i)),this.style.setProperty("--_thumb-w",c(l.width/i)),this.setAttribute("data-thumb",""),this.hasAttribute("data-thumb-ready")||requestAnimationFrame(()=>this.setAttribute("data-thumb-ready",""))}set items(e){const t=this.querySelectorAll(":scope > os-segment");for(const s of Array.from(t))s.remove();for(const s of e){const i=document.createElement("os-segment");i.setAttribute("value",s.value),i.textContent=s.label,this.appendChild(i)}const n=this.value;!(n!==null&&e.some(s=>s.value===n))&&e.length>0?this.value=e[0].value:this.requestUpdate()}render(){const e=this.label||"";e&&this.setAttribute("aria-label",e),this.setAttribute("role","radiogroup");const t=this.value;return queueMicrotask(()=>{const n=this.querySelectorAll("os-segment");for(const r of Array.from(n)){const s=r.getAttribute("value");r.setAttribute("aria-checked",s===t?"true":"false")}this._placeThumb()}),x`<span class="os-segmented__thumb" aria-hidden="true"></span
180 + ><slot></slot>`}};Y.props=["value","label"],Y.styles=[Ao],Y.help={title:"Segmented",summary:"iOS-style segmented radio group. Pill-shaped bar of equal-width <os-segment> children where exactly one is active.",status:"stable",props:[{name:"value",type:"string",description:"Currently selected segment value. Mirrored onto child aria-checked."},{name:"label",type:"string",description:"aria-label for the radiogroup."}],slots:[{name:"(default)",description:'<os-segment value="…"> children.'}],events:[{name:"os-pick",description:"Fires when the selected segment changes.",detail:"{ value: string }"}],cssProps:[{name:"--os-window-bg",description:"Pill background."},{name:"--os-ui-fg",description:"Active label colour."},{name:"--os-ui-fg-muted",description:"Inactive label colour."}],example:x`
154 181 <os-segmented value="md" label="Dock size">
155 182 <os-segment value="sm">Small</os-segment>
156 183 <os-segment value="md">Medium</os-segment>
157 184 <os-segment value="lg">Large</os-segment>
158 185 </os-segmented>
159 - `};let Ae=J;U("os-segmented",Ae);async function po(o){const t={file:o.file,mime:o.mime,fields:o.fields},e=z(x.BEFORE_UPLOAD,t,o.context);if(!e)throw new Ce;const n=new FormData,r=e.fields.filename!==e.file.name?new File([e.file],e.fields.filename,{type:e.mime||e.file.type}):e.file;return n.append("file",r),n.append("title",e.fields.title),n.append("alt_text",e.fields.altText),n.append("caption",e.fields.caption),n.append("description",e.fields.description),new Promise((s,i)=>{const l=new XMLHttpRequest;l.open("POST",o.mediaUrl,!0),l.withCredentials=!0,l.setRequestHeader("X-WP-Nonce",o.restNonce),l.responseType="text";let c=!1,p=!1,a=!1;const d=()=>{if(a=!0,!p){c=!0;try{l.abort()}catch{}}};E(x.UPLOAD_STARTED,{file:e.file,fields:e.fields,context:o.context,abort:d}),l.upload.addEventListener("progress",u=>{E(x.UPLOAD_PROGRESS,{file:e.file,fields:e.fields,context:o.context,loaded:u.loaded,total:u.lengthComputable?u.total:0,indeterminate:!u.lengthComputable})}),l.upload.addEventListener("load",()=>{p=!0,E(x.UPLOAD_PROGRESS,{file:e.file,fields:e.fields,context:o.context,loaded:e.file.size,total:e.file.size,indeterminate:!1})}),l.addEventListener("error",()=>{if(c)return;const u=new Error("Network error during upload.");E(x.UPLOAD_FAILED,{file:e.file,error:u,context:o.context}),i(u)}),l.addEventListener("abort",()=>{const u=new ae;E(x.UPLOAD_FAILED,{file:e.file,error:u,context:o.context}),i(u)}),l.addEventListener("load",()=>{if(c)return;if(l.status<200||l.status>=300){const m=ho(l),f=new Error(m);E(x.UPLOAD_FAILED,{file:e.file,error:f,context:o.context}),i(f);return}let u;try{u=JSON.parse(l.responseText)}catch(m){const f=m instanceof Error?m:new Error("Could not parse server response.");E(x.UPLOAD_FAILED,{file:e.file,error:f,context:o.context}),i(f);return}if(a&&u.id){fo(o.mediaUrl,o.restNonce,u.id);const m=new ae;E(x.UPLOAD_FAILED,{file:e.file,error:m,context:o.context}),i(m);return}const h={id:u.id,url:u.source_url,mime:u.mime_type||e.mime,title:u.title?.rendered||e.fields.title,filename:u.media_details?.file||e.fields.filename};E(x.AFTER_UPLOAD,{file:e.file,result:h,fields:e.fields,context:o.context}),s(h)}),l.send(n)})}class Ce extends Error{constructor(){super("Upload cancelled by os.drop.before-upload filter."),this.name="UploadCancelledError"}}class ae extends Error{constructor(){super("Upload aborted by the caller."),this.name="UploadAbortedError"}}function fo(o,t,e){const n=`${o.replace(/\/$/,"")}/${e}?force=true`,r=new XMLHttpRequest;return r.open("DELETE",n,!0),r.withCredentials=!0,r.setRequestHeader("X-WP-Nonce",t),new Promise(s=>{r.addEventListener("loadend",()=>{(r.status<200||r.status>=300)&&console.warn(`[os-file-drop] late-cancel cleanup failed for attachment ${e} (HTTP ${r.status}). The attachment remains in the Media Library; delete it manually.`),s()}),r.addEventListener("error",()=>{console.warn(`[os-file-drop] late-cancel cleanup network error for attachment ${e}. The attachment remains in the Media Library; delete it manually.`),s()});try{r.send()}catch(i){console.warn(`[os-file-drop] late-cancel cleanup could not be dispatched for attachment ${e}:`,i),s()}})}function ho(o){const t=`Upload failed (HTTP ${o.status}).`,e=o.responseText;if(!e)return t;try{const n=JSON.parse(e);if(n&&typeof n.message=="string")return n.message}catch{}return t}const Qe="__openStationSharedStores";function mo(){const o=window;let t=o[Qe];return t||(t=new Map,o[Qe]=t),t}function bo(o,t){const e=mo();let n=e.get(o);n||(n={state:t(),listeners:new Set,rebuild:t},e.set(o,n));const r={get state(){return n.state},set state(s){n.state=s},getState(){return n.state},notify(){for(const s of Array.from(n.listeners))try{s(n.state)}catch(i){console.error(`[desktop-mode/shared-store:${o}] subscriber threw:`,i)}},subscribe(s){return n.listeners.add(s),()=>{n.listeners.delete(s)}},setState(s){const i=n.state;if(typeof i!="object"||i===null){console.warn(`[desktop-mode/shared-store:${o}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(i,s),r.notify()},reset(){const s=n.rebuild(),i=n.state;if(typeof i=="object"&&i!==null&&typeof s=="object"&&s!==null){const l=i;for(const c of Object.keys(l))delete l[c];Object.assign(l,s)}else n.state=s;n.listeners.clear()}};return r}const go="desktop-mode/files";function Se(){return bo(go,()=>({placementsByFolder:new Map,folders:new Map,hydratedFolders:new Set}))}function $e(o){typeof document>"u"||document.dispatchEvent(new CustomEvent("os-files-changed",{detail:{source:"local",...o}}))}function vo(o,t){const e=Se(),n=new Map(e.state.placementsByFolder);n.set(o,t.slice());const r=new Set(e.state.hydratedFolders);r.add(o),e.state={...e.state,placementsByFolder:n,hydratedFolders:r},e.notify(),$e({kind:"placements-set",folderId:o})}function xo(o,t="local"){if(!o||typeof o.id!="number"){console.warn("[openstation] upsertPlacement called with a non-placement value; ignoring.",o);return}const e=Se(),n=new Map(e.state.placementsByFolder);for(const[l,c]of n)if(c.findIndex(a=>a&&a.id===o.id)>=0&&l!==o.parentId){const a=c.filter(Boolean),d=a.findIndex(u=>u.id===o.id);d>=0&&a.splice(d,1),n.set(l,a)}const s=(n.get(o.parentId)?.slice()??[]).filter(Boolean),i=s.findIndex(l=>l.id===o.id);i>=0?s[i]=o:s.push(o),n.set(o.parentId,s),e.state={...e.state,placementsByFolder:n},e.notify(),$e({kind:"placement-upserted",placementId:o.id,folderId:o.parentId,source:t})}function yo(o){const t=Se(),e=new Map;for(const n of o)e.set(n.id,n);t.state={...t.state,folders:e},t.notify(),$e({kind:"folders-set"})}async function wo(o){const t={file:o.file,mime:o.mime,fields:o.fields},e=z(x.BEFORE_UPLOAD,t,o.context);if(!e)throw new Ce;const n=new FormData,r=e.fields.filename!==e.file.name?new File([e.file],e.fields.filename,{type:e.mime||e.file.type}):e.file;n.append("file",r),n.append("parentId",String(o.parentId)),o.relativePath&&n.append("relativePath",o.relativePath),o.coords&&(n.append("x",String(o.coords.x)),n.append("y",String(o.coords.y)));const s=`${o.filesUrl.replace(/\/$/,"")}/uploads`;return new Promise((i,l)=>{const c=new XMLHttpRequest;c.open("POST",s,!0),c.withCredentials=!0,c.setRequestHeader("X-WP-Nonce",o.restNonce),c.responseType="text";let p=!1;const a=()=>{p=!0;try{c.abort()}catch{}};E(x.UPLOAD_STARTED,{file:e.file,fields:e.fields,context:o.context,abort:a}),c.upload.addEventListener("progress",u=>{E(x.UPLOAD_PROGRESS,{file:e.file,fields:e.fields,context:o.context,loaded:u.loaded,total:u.lengthComputable?u.total:0,indeterminate:!u.lengthComputable})});const d=u=>{E(x.UPLOAD_FAILED,{file:e.file,error:u,context:o.context}),l(u)};c.addEventListener("error",()=>{p||d(new Error("Network error during upload."))}),c.addEventListener("abort",()=>d(new ae)),c.addEventListener("load",()=>{if(p)return;if(c.status<200||c.status>=300){d(new Error(_o(c,e.file.name)));return}let u;try{u=JSON.parse(c.responseText)}catch{d(new Error("Could not parse server response."));return}if(!u.placement||typeof u.storedFileId!="number"){d(new Error("Unexpected server response."));return}xo(u.placement,"local");const h={placement:u.placement,storedFileId:u.storedFileId};E(x.AFTER_UPLOAD,{file:e.file,result:h,fields:e.fields,context:o.context}),i(h)}),c.send(n)})}function _o(o,t){if(o.status===413)return`“${t}” is larger than this server accepts.`;const e=`Upload failed (HTTP ${o.status}).`,n=o.responseText;if(!n)return e;try{const r=JSON.parse(n);if(r&&typeof r.message=="string"&&r.message)return r.message}catch{}return e}const et="X-WP-Nonce";function ko(o,t){const e=Eo();if(!e)return t;const n=Ao(o);if(!n||!Co(n))return t;const r=t?.headers??(typeof Request<"u"&&o instanceof Request?o.headers:void 0),s=new Headers(r??{});return s.has(et)?t:(s.set(et,e),{...t??{},headers:s})}function Eo(){if(typeof window>"u")return;const t=window.openStationConfig?.restNonce;return typeof t=="string"&&t.length>0?t:void 0}function Ao(o){try{const t=typeof window<"u"&&window.location?window.location.href:void 0;return typeof o=="string"?new URL(o,t):o instanceof URL?o:typeof Request<"u"&&o instanceof Request?new URL(o.url,t):null}catch{return null}}function Co(o){return typeof window>"u"||!window.location||o.origin!==window.location.origin?!1:!!(o.pathname.includes("/wp-json/")||o.searchParams.has("rest_route"))}function So(o,t,e={}){const n=window.wp?.os?.fetch;if(typeof n=="function")return n(o,t,e);const r=ko(o,t);return fetch(o,r)}const $o="http://localhost/";function Do(o,t){const e=typeof window<"u"&&window.location?window.location.href:$o,n=new URL(o,e),r=t.replace(/^\/+/,""),s=r.indexOf("?"),i=s===-1?r:r.slice(0,s),l=s===-1?"":r.slice(s+1);if(n.searchParams.has("rest_route")){const c=n.searchParams.get("rest_route")??"/",p=c.endsWith("/")?c:c+"/";n.searchParams.set("rest_route",p+i)}else{const c=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";n.pathname=c+i}return l&&new URLSearchParams(l).forEach((p,a)=>{n.searchParams.append(a,p)}),n.toString()}function Lo(){throw new Error("[openstation] files REST client called before installRestDeps().")}class To extends Error{constructor(t){super(`Row was changed by ${t.actor.name||"another session"} (parent="${t.current.parentName}")`),this.name="FilesConflictError",this.status=409,this.detail=t}}async function De(o,t){const{baseUrl:e,nonce:n}=Lo(),r=Do(e,o),s=new Headers(t.headers??{});s.set("X-WP-Nonce",n),t.body&&!s.has("Content-Type")&&s.set("Content-Type","application/json");const i=await So(r,{...t,headers:s,credentials:"same-origin"},{source:"desktop-mode/files"}),l=await i.text();let c=null,p=null;if(l)try{c=JSON.parse(l)}catch(a){c=null,p=a}if(!i.ok){if(i.status===409){const d=c?.data?.data??c?.data;if(d&&typeof d=="object")throw new To(d)}const a=c;throw new Error(`[openstation] files REST ${i.status}: ${a?.code??""} ${a?.message??""}`.trim())}if(c===null){if(p&&l){const a=l.slice(0,120).replace(/\s+/g," ");throw new Error(`[openstation] files REST ${i.status} returned non-JSON body — ${p.message}. First 120 chars: ${a}`)}throw new Error(`[openstation] files REST ${i.status}: empty or unparseable body.`)}return c}function Fo(o=0){return De(`/placements?folder=${encodeURIComponent(String(o))}`,{method:"GET"})}function Po(){return De("/folders",{method:"GET"})}function Uo(o,t){return De("/uploads/paths",{method:"POST",body:JSON.stringify({parentId:o,relativePath:t})})}function Io(o,t){const e=Math.max(0,Math.round((o-16)/96)),n=Math.max(0,Math.round((t-16)/110));return{x:16+e*96,y:16+n*110}}const Ro=/^(image|video|audio)\//;function Le(o){return o.desktopAllowed?o.forceDesktop||o.preferDesktop?"desktop":o.surface==="window"||o.surface==="iframe"?"media":(o.folderId??0)>0?"desktop":o.mimes.length>0&&o.mimes.every(e=>Ro.test(e))?"media":"desktop":"media"}let I=null;async function No(o){if(o.entries.length===0&&!o.emptyDirs?.length)return;if(I){I.replace(o);return}const t=!!(o.storage?.canUpload&&o.filesUrl);let e=Le({desktopAllowed:t,surface:o.context.surface,folderId:o.context.folderId,forceDesktop:o.forceDesktop,preferDesktop:o.preferDesktop,mimes:o.entries.map(a=>a.mime)});const n=document.createElement("os-modal");n.setAttribute("open",""),n.setAttribute("size","md"),document.body.appendChild(n);const r=()=>{const a=o.entries.length;let d="Media Library";e==="desktop"&&(d=(o.context.folderId??0)>0?"this folder":"Desktop");let u=`Upload ${a} files to ${d}`;a===0?u=(o.context.folderId??0)>0?"Create folders in this folder":"Create folders on Desktop":a===1&&(u=`Upload to ${d}`),n.setAttribute("title",u)};r();const s=o.entries.map(a=>({...a.fields})),i=()=>{if(n.innerHTML="",t&&!o.forceDesktop){const f=document.createElement("div");f.style.cssText="display:flex;align-items:center;gap:10px;margin-bottom:14px;";const b=document.createElement("span");b.textContent="Upload to",b.style.cssText="font-weight:600;",f.appendChild(b);const v=document.createElement("os-segmented");v.setAttribute("value",e),v.setAttribute("label","Destination"),v.style.setProperty("--os-ui-segmented-bg","rgba(255,255,255,0.06)");const g=document.createElement("os-segment");g.setAttribute("value","desktop"),g.textContent="Desktop",v.appendChild(g);const w=document.createElement("os-segment");w.setAttribute("value","media"),w.textContent="Media Library",v.appendChild(w),v.addEventListener("os-pick",_=>{e=_.detail.value,r(),i()}),f.appendChild(v),n.appendChild(f)}else if(o.forceDesktop){const f=document.createElement("div");f.style.cssText="opacity:0.7;font-size:12px;margin-bottom:14px;",f.textContent="Folder uploads land in your desktop storage, preserving the folder structure.",n.appendChild(f)}const a=e==="desktop"?o.storage?.maxBytes??0:o.mediaMaxBytes??0;if(a>0){const f=document.createElement("div");f.className="os-upload-dialog__max-size",f.style.cssText="opacity:0.6;font-size:12px;margin-bottom:14px;",f.textContent=`Maximum file size: ${B(a)}`,n.appendChild(f)}const d=document.createElement("div");d.style.cssText="display:flex;flex-direction:column;gap:18px;max-height:60vh;overflow:auto;padding-right:6px;",o.entries.forEach((f,b)=>{d.appendChild(l(f,s[b],b+1))}),n.appendChild(d);const u=document.createElement("div");u.setAttribute("slot","footer"),u.style.cssText="display:flex;gap:8px;justify-content:flex-end;";const h=document.createElement("os-button");h.setAttribute("variant","secondary"),h.textContent="Cancel",h.addEventListener("click",()=>{n.remove()});const m=document.createElement("os-button");m.setAttribute("variant","primary"),o.entries.length===0?m.textContent="Create folders":m.textContent=o.entries.length===1?"Upload":`Upload ${o.entries.length} files`,m.addEventListener("click",()=>{c(m,h)}),u.appendChild(h),u.appendChild(m),n.appendChild(u)},l=(a,d,u)=>{const h=document.createElement("div");h.style.cssText="display:flex;flex-direction:column;gap:8px;border:1px solid rgba(255,255,255,0.08);border-radius:10px;padding:14px;";const m=document.createElement("div");m.style.cssText="display:flex;gap:10px;align-items:center;font-weight:600;";const f=document.createElement("span");f.textContent=o.entries.length===1?"":`#${u} · `,f.style.opacity="0.6";const b=document.createElement("span");b.textContent=a.file.name,b.style.cssText="flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;";const v=document.createElement("span");if(v.textContent=`${a.mime||"unknown"} · ${B(a.file.size)}`,v.style.cssText="opacity:0.6;font-size:12px;",m.appendChild(f),m.appendChild(b),m.appendChild(v),h.appendChild(m),e==="desktop"){if(a.relativePath){const g=document.createElement("div");g.textContent=a.relativePath,g.style.cssText="opacity:0.55;font-size:12px;",h.appendChild(g)}return h.appendChild(j("Filename",d.filename,g=>d.filename=g)),h}return h.appendChild(j("Title",d.title,g=>d.title=g)),h.appendChild(j("Filename",d.filename,g=>d.filename=g)),a.mime.startsWith("image/")&&h.appendChild(j("Alt text",d.altText,g=>d.altText=g)),h.appendChild(j("Caption",d.caption,g=>d.caption=g)),h.appendChild(zo("Description",d.description,g=>d.description=g)),h},c=async(a,d)=>{I===p&&(I=null),a.disabled=!0,d.disabled=!0,a.textContent="Uploading…";const u=o.entries.length;let h=0,m=0,f=0;const b=[],v=o.context.folderId??0;let g=!1;for(let _=0;_<u;_++){const S=o.entries[_];try{if(e==="desktop"&&o.filesUrl){const R=!S.relativePath&&!g&&o.context.surface==="wallpaper"?Io(o.context.x,o.context.y):void 0;R&&(g=!0),await wo({file:S.file,mime:S.mime,fields:s[_],context:o.context,filesUrl:o.filesUrl,restNonce:o.restNonce,parentId:v,relativePath:S.relativePath??"",coords:R})}else await po({file:S.file,mime:S.mime,fields:s[_],context:o.context,mediaUrl:o.mediaUrl,restNonce:o.restNonce});h++}catch(M){if(M instanceof Ce){f++;continue}if(M instanceof ae){f++;continue}m++;const R=M instanceof Error?M.message:"Upload failed.";b.push(`“${S.file.name}” — ${R}`)}}if(e==="desktop"&&o.emptyDirs?.length)for(const _ of o.emptyDirs)try{await Uo(v,_)}catch{}const w=o.entries.some(_=>_.relativePath)||!!o.emptyDirs?.length;if(e==="desktop"&&w)try{const[_,S]=await Promise.all([Po(),Fo(v)]);yo(_.folders),vo(v,S.placements)}catch{}n.remove(),Mo({total:u,successes:h,failures:m,cancelled:f,failureDetails:b,destination:e})},p={replace:a=>{o.entries=a.entries,o.emptyDirs=a.emptyDirs,o.forceDesktop=a.forceDesktop,o.preferDesktop=a.preferDesktop,o.context=a.context,o.mediaMaxBytes=a.mediaMaxBytes??o.mediaMaxBytes,s.length=0;for(const d of a.entries)s.push({...d.fields});e=Le({desktopAllowed:t,surface:a.context.surface,folderId:a.context.folderId,forceDesktop:a.forceDesktop,preferDesktop:a.preferDesktop,mimes:a.entries.map(d=>d.mime)}),r(),i()}};I=p,i(),await new Promise(a=>{const d=()=>{I===p&&(I=null),a()};n.addEventListener("os-modal-cancel",()=>{n.remove(),d()});const u=new MutationObserver(()=>{n.isConnected||(u.disconnect(),d())});u.observe(document.body,{childList:!0,subtree:!0})})}function j(o,t,e){const n=document.createElement("os-text-field");return n.setAttribute("label",o),n.setAttribute("value",t),n.addEventListener("input",()=>{const r=n.value;typeof r=="string"&&e(r)}),n}function zo(o,t,e){const n=document.createElement("os-textarea");return n.setAttribute("label",o),n.setAttribute("value",t),n.setAttribute("rows","3"),n.addEventListener("input",()=>{const r=n.value;typeof r=="string"&&e(r)}),n}function Mo(o){const{total:t,successes:e,failures:n,cancelled:r,failureDetails:s}=o,i=o.destination==="desktop"?"your desktop":"Media Library";if(t===0){o.destination==="desktop"&&C({message:"Folder created on your desktop."});return}if(t===1){e===1?C({message:`Uploaded to ${i}.`}):n===1&&s[0]?C({message:s[0]}):r===1&&C({message:"Upload cancelled."});return}if(e===t){C({message:`Uploaded ${e} files to ${i}.`});return}if(r===t){C({message:"All uploads cancelled."});return}if(n===t){C({message:n===1&&s[0]?s[0]:`${n} uploads failed.`});return}const l=[];e>0&&l.push(`Uploaded ${e} file${e===1?"":"s"}.`),r>0&&l.push(`Cancelled ${r}.`),n>0&&l.push(`Failed ${n}.`),C({message:l.join(" ")})}const tt=Object.freeze(Object.defineProperty({__proto__:null,openUploadDialog:No,resolveDefaultDestination:Le},Symbol.toStringTag,{value:"Module"}))})();
186 + `};let $e=Y;P("os-segmented",$e);async function $o(o){const e={file:o.file,mime:o.mime,fields:o.fields},t=N(w.BEFORE_UPLOAD,e,o.context);if(!t)throw new Se;const n=new FormData,r=t.fields.filename!==t.file.name?new File([t.file],t.fields.filename,{type:t.mime||t.file.type}):t.file;return n.append("file",r),n.append("title",t.fields.title),n.append("alt_text",t.fields.altText),n.append("caption",t.fields.caption),n.append("description",t.fields.description),new Promise((s,i)=>{const l=new XMLHttpRequest;l.open("POST",o.mediaUrl,!0),l.withCredentials=!0,l.setRequestHeader("X-WP-Nonce",o.restNonce),l.responseType="text";let c=!1,f=!1,a=!1;const d=()=>{if(a=!0,!f){c=!0;try{l.abort()}catch{}}};A(w.UPLOAD_STARTED,{file:t.file,fields:t.fields,context:o.context,abort:d}),l.upload.addEventListener("progress",u=>{A(w.UPLOAD_PROGRESS,{file:t.file,fields:t.fields,context:o.context,loaded:u.loaded,total:u.lengthComputable?u.total:0,indeterminate:!u.lengthComputable})}),l.upload.addEventListener("load",()=>{f=!0,A(w.UPLOAD_PROGRESS,{file:t.file,fields:t.fields,context:o.context,loaded:t.file.size,total:t.file.size,indeterminate:!1})}),l.addEventListener("error",()=>{if(c)return;const u=new Error("Network error during upload.");A(w.UPLOAD_FAILED,{file:t.file,error:u,context:o.context}),i(u)}),l.addEventListener("abort",()=>{const u=new le;A(w.UPLOAD_FAILED,{file:t.file,error:u,context:o.context}),i(u)}),l.addEventListener("load",()=>{if(c)return;if(l.status<200||l.status>=300){const m=Lo(l),h=new Error(m);A(w.UPLOAD_FAILED,{file:t.file,error:h,context:o.context}),i(h);return}let u;try{u=JSON.parse(l.responseText)}catch(m){const h=m instanceof Error?m:new Error("Could not parse server response.");A(w.UPLOAD_FAILED,{file:t.file,error:h,context:o.context}),i(h);return}if(a&&u.id){So(o.mediaUrl,o.restNonce,u.id);const m=new le;A(w.UPLOAD_FAILED,{file:t.file,error:m,context:o.context}),i(m);return}const p={id:u.id,url:u.source_url,mime:u.mime_type||t.mime,title:u.title?.rendered||t.fields.title,filename:u.media_details?.file||t.fields.filename};A(w.AFTER_UPLOAD,{file:t.file,result:p,fields:t.fields,context:o.context}),s(p)}),l.send(n)})}class Se extends Error{constructor(){super("Upload cancelled by os.drop.before-upload filter."),this.name="UploadCancelledError"}}class le extends Error{constructor(){super("Upload aborted by the caller."),this.name="UploadAbortedError"}}function So(o,e,t){const n=`${o.replace(/\/$/,"")}/${t}?force=true`,r=new XMLHttpRequest;return r.open("DELETE",n,!0),r.withCredentials=!0,r.setRequestHeader("X-WP-Nonce",e),new Promise(s=>{r.addEventListener("loadend",()=>{(r.status<200||r.status>=300)&&console.warn(`[os-file-drop] late-cancel cleanup failed for attachment ${t} (HTTP ${r.status}). The attachment remains in the Media Library; delete it manually.`),s()}),r.addEventListener("error",()=>{console.warn(`[os-file-drop] late-cancel cleanup network error for attachment ${t}. The attachment remains in the Media Library; delete it manually.`),s()});try{r.send()}catch(i){console.warn(`[os-file-drop] late-cancel cleanup could not be dispatched for attachment ${t}:`,i),s()}})}function Lo(o){const e=`Upload failed (HTTP ${o.status}).`,t=o.responseText;if(!t)return e;try{const n=JSON.parse(t);if(n&&typeof n.message=="string")return n.message}catch{}return e}const Qe="__openStationSharedStores";function Do(){const o=window;let e=o[Qe];return e||(e=new Map,o[Qe]=e),e}function To(o,e){const t=Do();let n=t.get(o);n||(n={state:e(),listeners:new Set,rebuild:e},t.set(o,n));const r={get state(){return n.state},set state(s){n.state=s},getState(){return n.state},notify(){for(const s of Array.from(n.listeners))try{s(n.state)}catch(i){console.error(`[desktop-mode/shared-store:${o}] subscriber threw:`,i)}},subscribe(s){return n.listeners.add(s),()=>{n.listeners.delete(s)}},setState(s){const i=n.state;if(typeof i!="object"||i===null){console.warn(`[desktop-mode/shared-store:${o}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(i,s),r.notify()},reset(){const s=n.rebuild(),i=n.state;if(typeof i=="object"&&i!==null&&typeof s=="object"&&s!==null){const l=i;for(const c of Object.keys(l))delete l[c];Object.assign(l,s)}else n.state=s;n.listeners.clear()}};return r}const Fo="desktop-mode/files";function de(){return To(Fo,()=>({placementsByFolder:new Map,folders:new Map,hydratedFolders:new Set}))}function ce(o){typeof document>"u"||document.dispatchEvent(new CustomEvent("os-files-changed",{detail:{source:"local",...o}}))}function Ro(o,e){const t=de(),n=new Map(t.state.placementsByFolder);n.set(o,e.slice());const r=new Set(t.state.hydratedFolders);r.add(o),t.state={...t.state,placementsByFolder:n,hydratedFolders:r},t.notify(),ce({kind:"placements-set",folderId:o})}function et(o,e="local"){if(!o||typeof o.id!="number"){console.warn("[openstation] upsertPlacement called with a non-placement value; ignoring.",o);return}const t=de(),n=new Map(t.state.placementsByFolder);for(const[l,c]of n)if(c.findIndex(a=>a&&a.id===o.id)>=0&&l!==o.parentId){const a=c.filter(Boolean),d=a.findIndex(u=>u.id===o.id);d>=0&&a.splice(d,1),n.set(l,a)}const s=(n.get(o.parentId)?.slice()??[]).filter(Boolean),i=s.findIndex(l=>l.id===o.id);i>=0?s[i]=o:s.push(o),n.set(o.parentId,s),t.state={...t.state,placementsByFolder:n},t.notify(),ce({kind:"placement-upserted",placementId:o.id,folderId:o.parentId,source:e})}function Po(o){const e=de(),t=new Map;for(const n of o)t.set(n.id,n);e.state={...e.state,folders:t},e.notify(),ce({kind:"folders-set"})}function Uo(o,e="local"){const t=de(),n=new Map(t.state.folders);n.set(o.id,o),t.state={...t.state,folders:n},t.notify(),ce({kind:"folder-upserted",folderRowId:o.id,source:e})}function tt(o,e="local"){if(Array.isArray(o))for(const t of o)!t||!t.folder||typeof t.folder.id!="number"||(Uo(t.folder,e),t.placement&&et(t.placement,e))}async function Mo(o){const e={file:o.file,mime:o.mime,fields:o.fields},t=N(w.BEFORE_UPLOAD,e,o.context);if(!t)throw new Se;const n=new FormData,r=t.fields.filename!==t.file.name?new File([t.file],t.fields.filename,{type:t.mime||t.file.type}):t.file;n.append("file",r),n.append("parentId",String(o.parentId)),o.relativePath&&n.append("relativePath",o.relativePath),o.coords&&(n.append("x",String(o.coords.x)),n.append("y",String(o.coords.y)));const s=`${o.filesUrl.replace(/\/$/,"")}/uploads`;return new Promise((i,l)=>{const c=new XMLHttpRequest;c.open("POST",s,!0),c.withCredentials=!0,c.setRequestHeader("X-WP-Nonce",o.restNonce),c.responseType="text";let f=!1;const a=()=>{f=!0;try{c.abort()}catch{}};A(w.UPLOAD_STARTED,{file:t.file,fields:t.fields,context:o.context,abort:a}),c.upload.addEventListener("progress",u=>{A(w.UPLOAD_PROGRESS,{file:t.file,fields:t.fields,context:o.context,loaded:u.loaded,total:u.lengthComputable?u.total:0,indeterminate:!u.lengthComputable})});const d=u=>{A(w.UPLOAD_FAILED,{file:t.file,error:u,context:o.context}),l(u)};c.addEventListener("error",()=>{f||d(new Error("Network error during upload."))}),c.addEventListener("abort",()=>d(new le)),c.addEventListener("load",()=>{if(f)return;if(c.status<200||c.status>=300){d(new Error(Io(c,t.file.name)));return}let u;try{u=JSON.parse(c.responseText)}catch{d(new Error("Could not parse server response."));return}if(!u.placement||typeof u.storedFileId!="number"){d(new Error("Unexpected server response."));return}const p=Array.isArray(u.createdFolders)?u.createdFolders:[];tt(p,"local"),et(u.placement,"local");const m={placement:u.placement,storedFileId:u.storedFileId,createdFolders:p};A(w.AFTER_UPLOAD,{file:t.file,result:m,fields:t.fields,context:o.context}),i(m)}),c.send(n)})}function Io(o,e){if(o.status===413)return`“${e}” is larger than this server accepts.`;const t=`Upload failed (HTTP ${o.status}).`,n=o.responseText;if(!n)return t;try{const r=JSON.parse(n);if(r&&typeof r.message=="string"&&r.message)return r.message}catch{}return t}const ot="X-WP-Nonce";function No(o,e){const t=zo();if(!t)return e;const n=Oo(o);if(!n||!Bo(n))return e;const r=e?.headers??(typeof Request<"u"&&o instanceof Request?o.headers:void 0),s=new Headers(r??{});return s.has(ot)?e:(s.set(ot,t),{...e??{},headers:s})}function zo(){if(typeof window>"u")return;const e=window.openStationConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function Oo(o){try{const e=typeof window<"u"&&window.location?window.location.href:void 0;return typeof o=="string"?new URL(o,e):o instanceof URL?o:typeof Request<"u"&&o instanceof Request?new URL(o.url,e):null}catch{return null}}function Bo(o){return typeof window>"u"||!window.location||o.origin!==window.location.origin?!1:!!(o.pathname.includes("/wp-json/")||o.searchParams.has("rest_route"))}function qo(o,e,t={}){const n=window.wp?.os?.fetch;if(typeof n=="function")return n(o,e,t);const r=No(o,e);return fetch(o,r)}class nt extends Error{constructor(e,t){super(e||t.serverMessage||`HTTP ${t.status}`),this.name="RestError",this.status=t.status,this.code=t.code,this.data=t.data,this.serverMessage=t.serverMessage??""}}function rt(o){const e=typeof o=="object"&&o!==null?o:void 0;return{code:typeof e?.code=="string"?e.code:void 0,data:e?.data,serverMessage:typeof e?.message=="string"?e.message:""}}function Ho(o,e,t=""){return new nt(t,{status:o,...rt(e)})}function st(o,e){return new nt(e,{status:o,code:"openstation_bad_response"})}function jo(o){const{prefix:e,source:t,conflict:n}=o;return async(r,s={})=>{const i=new Headers(s.headers??{});i.set("X-WP-Nonce",o.nonce()),s.body&&!i.has("Content-Type")&&i.set("Content-Type","application/json");const l=await qo(o.url(r),{...s,headers:i,credentials:"same-origin"},{source:t}),c=await l.text();let f=null,a=null;if(c)try{f=JSON.parse(c)}catch(d){a=d}if(!l.ok){if(l.status===409&&n){const p=n(f);if(p)throw p}const{code:d,serverMessage:u}=rt(f);throw Ho(l.status,f,`${e} ${l.status}: ${d??""} ${u}`.trim())}if(f===null){if(a&&c){const d=c.slice(0,120).replace(/\s+/g," ");throw st(l.status,`${e} ${l.status} returned non-JSON body — ${a.message}. First 120 chars: ${d}`)}throw st(l.status,`${e} ${l.status}: empty or unparseable body.`)}return f}}const Wo="http://localhost/";function Ko(o,e){const t=typeof window<"u"&&window.location?window.location.href:Wo,n=new URL(o,t),r=e.replace(/^\/+/,""),s=r.indexOf("?"),i=s===-1?r:r.slice(0,s),l=s===-1?"":r.slice(s+1);if(n.searchParams.has("rest_route")){const c=n.searchParams.get("rest_route")??"/",f=c.endsWith("/")?c:c+"/";n.searchParams.set("rest_route",f+i)}else{const c=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";n.pathname=c+i}return l&&new URLSearchParams(l).forEach((f,a)=>{n.searchParams.append(a,f)}),n.toString()}function it(){throw new Error("[openstation] files REST client called before installRestDeps().")}class Xo extends Error{constructor(e){super(`Row was changed by ${e.actor.name||"another session"} (parent="${e.current.parentName}")`),this.name="FilesConflictError",this.status=409,this.detail=e}}const Le=jo({prefix:"[openstation] files REST",source:"desktop-mode/files",url:o=>Ko(it().baseUrl,o),nonce:()=>it().nonce,conflict:o=>{const e=o?.data?.data??o?.data;return e&&typeof e=="object"?new Xo(e):null}});function Go(o=0){return Le(`/placements?folder=${encodeURIComponent(String(o))}`,{method:"GET"})}function Vo(){return Le("/folders",{method:"GET"})}function Jo(o,e){return Le("/uploads/paths",{method:"POST",body:JSON.stringify({parentId:o,relativePath:e})})}function Yo(o,e){const t=Math.max(0,Math.round((o-16)/96)),n=Math.max(0,Math.round((e-16)/110));return{x:16+t*96,y:16+n*110}}const Zo=/^(image|video|audio)\//;function De(o){return o.desktopAllowed?o.forceDesktop||o.preferDesktop?"desktop":o.surface==="window"||o.surface==="iframe"?"media":(o.folderId??0)>0?"desktop":o.mimes.length>0&&o.mimes.every(t=>Zo.test(t))?"media":"desktop":"media"}let U=null;async function Qo(o){if(o.entries.length===0&&!o.emptyDirs?.length)return;if(U){U.replace(o);return}const e=!!(o.storage?.canUpload&&o.filesUrl);let t=De({desktopAllowed:e,surface:o.context.surface,folderId:o.context.folderId,forceDesktop:o.forceDesktop,preferDesktop:o.preferDesktop,mimes:o.entries.map(a=>a.mime)});const n=document.createElement("os-modal");n.setAttribute("open",""),n.setAttribute("size","md"),document.body.appendChild(n);const r=()=>{const a=o.entries.length;let d="Media Library";t==="desktop"&&(d=(o.context.folderId??0)>0?"this folder":"Desktop");let u=`Upload ${a} files to ${d}`;a===0?u=(o.context.folderId??0)>0?"Create folders in this folder":"Create folders on Desktop":a===1&&(u=`Upload to ${d}`),n.setAttribute("title",u)};r();const s=o.entries.map(a=>({...a.fields})),i=()=>{if(n.innerHTML="",e&&!o.forceDesktop){const h=document.createElement("div");h.style.cssText="display:flex;align-items:center;gap:10px;margin-bottom:14px;";const b=document.createElement("span");b.textContent="Upload to",b.style.cssText="font-weight:600;",h.appendChild(b);const v=document.createElement("os-segmented");v.setAttribute("value",t),v.setAttribute("label","Destination"),v.style.setProperty("--os-ui-segmented-bg","rgba(255,255,255,0.06)");const g=document.createElement("os-segment");g.setAttribute("value","desktop"),g.textContent="Desktop",v.appendChild(g);const y=document.createElement("os-segment");y.setAttribute("value","media"),y.textContent="Media Library",v.appendChild(y),v.addEventListener("os-pick",_=>{t=_.detail.value,r(),i()}),h.appendChild(v),n.appendChild(h)}else if(o.forceDesktop){const h=document.createElement("div");h.style.cssText="opacity:0.7;font-size:12px;margin-bottom:14px;",h.textContent="Folder uploads land in your desktop storage, preserving the folder structure.",n.appendChild(h)}const a=t==="desktop"?o.storage?.maxBytes??0:o.mediaMaxBytes??0;if(a>0){const h=document.createElement("div");h.className="os-upload-dialog__max-size",h.style.cssText="opacity:0.6;font-size:12px;margin-bottom:14px;",h.textContent=`Maximum file size: ${q(a)}`,n.appendChild(h)}const d=document.createElement("div");d.style.cssText="display:flex;flex-direction:column;gap:18px;max-height:60vh;overflow:auto;padding-right:6px;",o.entries.forEach((h,b)=>{d.appendChild(l(h,s[b],b+1))}),n.appendChild(d);const u=document.createElement("div");u.setAttribute("slot","footer"),u.style.cssText="display:flex;gap:8px;justify-content:flex-end;";const p=document.createElement("os-button");p.setAttribute("variant","secondary"),p.textContent="Cancel",p.addEventListener("click",()=>{n.remove()});const m=document.createElement("os-button");m.setAttribute("variant","primary"),o.entries.length===0?m.textContent="Create folders":m.textContent=o.entries.length===1?"Upload":`Upload ${o.entries.length} files`,m.addEventListener("click",()=>{c(m,p)}),u.appendChild(p),u.appendChild(m),n.appendChild(u)},l=(a,d,u)=>{const p=document.createElement("div");p.style.cssText="display:flex;flex-direction:column;gap:8px;border:1px solid rgba(255,255,255,0.08);border-radius:10px;padding:14px;";const m=document.createElement("div");m.style.cssText="display:flex;gap:10px;align-items:center;font-weight:600;";const h=document.createElement("span");h.textContent=o.entries.length===1?"":`#${u} · `,h.style.opacity="0.6";const b=document.createElement("span");b.textContent=a.file.name,b.style.cssText="flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;";const v=document.createElement("span");if(v.textContent=`${a.mime||"unknown"} · ${q(a.file.size)}`,v.style.cssText="opacity:0.6;font-size:12px;",m.appendChild(h),m.appendChild(b),m.appendChild(v),p.appendChild(m),t==="desktop"){if(a.relativePath){const g=document.createElement("div");g.textContent=a.relativePath,g.style.cssText="opacity:0.55;font-size:12px;",p.appendChild(g)}return p.appendChild(j("Filename",d.filename,g=>d.filename=g)),p}return p.appendChild(j("Title",d.title,g=>d.title=g)),p.appendChild(j("Filename",d.filename,g=>d.filename=g)),a.mime.startsWith("image/")&&p.appendChild(j("Alt text",d.altText,g=>d.altText=g)),p.appendChild(j("Caption",d.caption,g=>d.caption=g)),p.appendChild(en("Description",d.description,g=>d.description=g)),p},c=async(a,d)=>{U===f&&(U=null),a.disabled=!0,d.disabled=!0,a.textContent="Uploading…";const u=o.entries.length;let p=0,m=0,h=0;const b=[],v=o.context.folderId??0;let g=!1;for(let _=0;_<u;_++){const E=o.entries[_];try{if(t==="desktop"&&o.filesUrl){const z=!E.relativePath&&!g&&o.context.surface==="wallpaper"?Yo(o.context.x,o.context.y):void 0;z&&(g=!0),await Mo({file:E.file,mime:E.mime,fields:s[_],context:o.context,filesUrl:o.filesUrl,restNonce:o.restNonce,parentId:v,relativePath:E.relativePath??"",coords:z})}else await $o({file:E.file,mime:E.mime,fields:s[_],context:o.context,mediaUrl:o.mediaUrl,restNonce:o.restNonce});p++}catch(M){if(M instanceof Se){h++;continue}if(M instanceof le){h++;continue}m++;const z=M instanceof Error?M.message:"Upload failed.";b.push(`“${E.file.name}” — ${z}`)}}if(t==="desktop"&&o.emptyDirs?.length)for(const _ of o.emptyDirs)try{const E=await Jo(v,_);tt(E.createdFolders,"local")}catch{}const y=o.entries.some(_=>_.relativePath)||!!o.emptyDirs?.length;if(t==="desktop"&&y)try{const[_,E]=await Promise.all([Vo(),Go(v)]);Po(_.folders),Ro(v,E.placements)}catch{}n.remove(),tn({total:u,successes:p,failures:m,cancelled:h,failureDetails:b,destination:t})},f={replace:a=>{o.entries=a.entries,o.emptyDirs=a.emptyDirs,o.forceDesktop=a.forceDesktop,o.preferDesktop=a.preferDesktop,o.context=a.context,o.mediaMaxBytes=a.mediaMaxBytes??o.mediaMaxBytes,s.length=0;for(const d of a.entries)s.push({...d.fields});t=De({desktopAllowed:e,surface:a.context.surface,folderId:a.context.folderId,forceDesktop:a.forceDesktop,preferDesktop:a.preferDesktop,mimes:a.entries.map(d=>d.mime)}),r(),i()}};U=f,i(),await new Promise(a=>{const d=()=>{U===f&&(U=null),a()};n.addEventListener("os-modal-cancel",()=>{n.remove(),d()});const u=new MutationObserver(()=>{n.isConnected||(u.disconnect(),d())});u.observe(document.body,{childList:!0,subtree:!0})})}function j(o,e,t){const n=document.createElement("os-text-field");return n.setAttribute("label",o),n.setAttribute("value",e),n.addEventListener("input",()=>{const r=n.value;typeof r=="string"&&t(r)}),n}function en(o,e,t){const n=document.createElement("os-textarea");return n.setAttribute("label",o),n.setAttribute("value",e),n.setAttribute("rows","3"),n.addEventListener("input",()=>{const r=n.value;typeof r=="string"&&t(r)}),n}function tn(o){const{total:e,successes:t,failures:n,cancelled:r,failureDetails:s}=o,i=o.destination==="desktop"?"your desktop":"Media Library";if(e===0){o.destination==="desktop"&&$({message:"Folder created on your desktop."});return}if(e===1){t===1?$({message:`Uploaded to ${i}.`}):n===1&&s[0]?$({message:s[0]}):r===1&&$({message:"Upload cancelled."});return}if(t===e){$({message:`Uploaded ${t} files to ${i}.`});return}if(r===e){$({message:"All uploads cancelled."});return}if(n===e){$({message:n===1&&s[0]?s[0]:`${n} uploads failed.`});return}const l=[];t>0&&l.push(`Uploaded ${t} file${t===1?"":"s"}.`),r>0&&l.push(`Cancelled ${r}.`),n>0&&l.push(`Failed ${n}.`),$({message:l.join(" ")})}const at=Object.freeze(Object.defineProperty({__proto__:null,openUploadDialog:Qo,resolveDefaultDestination:De},Symbol.toStringTag,{value:"Module"}))})();