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.13 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 All 37 releases
← All changes | assets/js/apps/my-wordpress.min.js +462 -457 1.1.7 → 1.1.12 View file →
@@ -1,20 +1,20 @@
1 -var openStationApp_myWordpress=function(E){"use strict";const Ye="desktop-mode";function Se(){return window.wp?.i18n}function r(e,t=Ye){return Se()?.__(e,t)??e}function B(e,t,s,n=Ye){return Se()?._n(e,t,s,n)??(s===1?e:t)}function b(e,...t){const s=Se()?.sprintf;if(s)return s(e,...t);let n=0;return e.replace(/%(?:(\d+)\$)?[sd]/g,(i,o)=>{const a=o?Number.parseInt(o,10)-1:n++;return String(t[a]??"")})}function l(e,...t){return{__wpdHtml:!0,strings:e,values:t}}function Kt(e){return!!e&&e.__wpdHtml===!0}const zt="$$wpd$$",D=/\$\$wpd\$\$(\d+)\$\$/g,Ht="$$wpd-node$$",Xt=/^\$\$wpd-node\$\$(\d+)\$\$$/,Yt=new Set(["style","script","textarea","title"]);function Gt(e){let t="",s=!1,n=null,i=!1,o=null,a="",c=!1;for(let u=0;u<e.length;u++){const p=e[u];t+=p;for(let d=0;d<p.length;d++){const f=p[d];if(i){p.startsWith("-->",d)&&(i=!1,d+=2);continue}if(o!==null){f==="<"&&p[d+1]==="/"&&p.slice(d+2,d+2+o.length).toLowerCase()===o&&(d+=1+o.length,o=null,s=!0,c=!1,a="");continue}if(n!==null){f===n&&(n=null);continue}if(s){f==='"'||f==="'"?(n=f,c=!1):f===">"?(s=!1,c=!1,Yt.has(a)&&(o=a),a=""):c&&(/[a-zA-Z0-9-]/.test(f)?a+=f.toLowerCase():c=!1);continue}if(p.startsWith("<!--",d)){i=!0,d+=3;continue}const m=p[d+1]??"";f==="<"&&/[a-zA-Z/!]/.test(m)&&(s=!0,a="",c=/[a-zA-Z]/.test(m))}u<e.length-1&&(t+=s||i||o!==null?`${zt}${u}$$`:`<!--${Ht}${u}$$-->`)}return t}const Ge=new WeakMap;function Ve(e){const t=Ge.get(e);if(t)return t;const s=document.createElement("template");s.innerHTML=Gt(e);const n=[],i=(c,u)=>{if(c.nodeType===Node.ELEMENT_NODE){const f=c;for(const m of Array.from(f.attributes)){const h=m.name,w=m.value,v=h[0];if(D.test(w))if(D.lastIndex=0,v==="@"){const g=D.exec(w);D.lastIndex=0,n.push({path:u,kind:"event",name:h.slice(1),valueIndex:g?Number(g[1]):0}),f.removeAttribute(h)}else if(v==="."){const g=D.exec(w);D.lastIndex=0,n.push({path:u,kind:"prop",name:h.slice(1),valueIndex:g?Number(g[1]):0}),f.removeAttribute(h)}else if(v==="?"){const g=D.exec(w);D.lastIndex=0,n.push({path:u,kind:"bool",name:h.slice(1),valueIndex:g?Number(g[1]):0}),f.removeAttribute(h)}else{const g=[],$=[];let y=0,_;for(D.lastIndex=0;(_=D.exec(w))!==null;)g.push(w.slice(y,_.index)),$.push(Number(_[1])),y=_.index+_[0].length;g.push(w.slice(y)),n.push({path:u,kind:"attr",name:h,template:g,valueIndices:$}),f.setAttribute(h,"")}}}const p=Array.from(c.childNodes);let d=0;for(let f=0;f<p.length;f++){const m=p[f],h=f+d;if(m.nodeType===Node.COMMENT_NODE){const w=Xt.exec(m.data);if(w){const v=document.createTextNode("");m.parentNode.replaceChild(v,m),n.push({path:[...u,h],kind:"node",valueIndex:Number(w[1])})}continue}if(m.nodeType===Node.TEXT_NODE){const w=m.textContent||"";if(!D.test(w)){D.lastIndex=0;continue}D.lastIndex=0;const v=m.parentNode;let g=0,$;const y=[],_=[];for(D.lastIndex=0;($=D.exec(w))!==null;){$.index>g&&y.push(document.createTextNode(w.slice(g,$.index)));const A=document.createTextNode("");y.push(A),_.push({path:[...u,h+y.length-1],kind:"node",valueIndex:Number($[1])}),g=$.index+$[0].length}g<w.length&&y.push(document.createTextNode(w.slice(g)));for(const A of y)v.insertBefore(A,m);v.removeChild(m),d+=y.length-1,n.push(..._)}else i(m,[...u,h])}};i(s.content,[]);const a={template:s,buildParts:c=>{const u=[];for(const p of n){let d=c;for(const f of p.path)d=d.childNodes[f];p.kind==="node"?u.push({kind:"node",valueIndex:p.valueIndex,child:{anchor:d,state:null}}):p.kind==="attr"?u.push({kind:"attr",element:d,name:p.name,template:p.template,valueIndices:p.valueIndices}):p.kind==="event"?u.push({kind:"event",valueIndex:p.valueIndex,element:d,name:p.name}):p.kind==="prop"?u.push({kind:"prop",valueIndex:p.valueIndex,element:d,name:p.name}):p.kind==="bool"&&u.push({kind:"bool",valueIndex:p.valueIndex,element:d,name:p.name})}return u}};return Ge.set(e,a),a}const Qe=new WeakMap;function Vt(e,t){for(const s of e.nodes)if(s.parentNode!==t)return!1;return!0}function Qt(e,t){const s=Qe.get(t);if(s&&s.strings===e.strings&&Vt(s,t)){ne(s.parts,e.values);return}const n=Ve(e.strings),i=n.template.content.cloneNode(!0),o=n.buildParts(i),a=Array.from(i.childNodes);for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(i),ne(o,e.values),Qe.set(t,{strings:e.strings,parts:o,nodes:a})}function ne(e,t){for(const s of e)if(s.kind==="node")oe(s.child,t[s.valueIndex]);else if(s.kind==="attr"){let n=s.template[0];for(let i=0;i<s.valueIndices.length;i++)n+=Ze(t[s.valueIndices[i]]),n+=s.template[i+1];n!==s.last&&(s.last=n,n===""?s.element.removeAttribute(s.name):s.element.setAttribute(s.name,n))}else if(s.kind==="event"){const n=t[s.valueIndex];n!==s.current&&(s.current&&s.element.removeEventListener(s.name,s.current),n&&s.element.addEventListener(s.name,n),s.current=n)}else if(s.kind==="prop"){const n=t[s.valueIndex];n!==s.last&&(s.last=n,s.element[s.name]=n)}else if(s.kind==="bool"){const n=!!t[s.valueIndex];n!==s.last&&(s.last=n,n?s.element.setAttribute(s.name,""):s.element.removeAttribute(s.name))}}function oe(e,t){if(t==null||t===!1){e.state&&(R(e.state),e.state=null);return}if(Array.isArray(t)){es(e,t);return}if(Kt(t)){xt(e,t);return}if(t instanceof Node){Zt(e,t);return}Jt(e,Ze(t))}function Zt(e,t){const s=e.state;s?.shape==="node"&&s.node===t||(s&&R(s),G(e,[t]),e.state={shape:"node",node:t})}function Jt(e,t){const s=e.state;if(s?.shape==="text"){s.text!==t&&(s.node.textContent=t,s.text=t);return}s&&R(s);const n=document.createTextNode(t);G(e,[n]),e.state={shape:"text",node:n,text:t}}function xt(e,t){const s=e.state;if(s?.shape==="template"&&s.strings===t.strings){ne(s.parts,t.values);return}s&&R(s);const n=Ve(t.strings),i=n.template.content.cloneNode(!0),o=n.buildParts(i),a=Array.from(i.childNodes);G(e,[i]),ne(o,t.values),e.state={shape:"template",strings:t.strings,parts:o,nodes:a}}function es(e,t){const s=e.state;if(s?.shape==="array"){const i=Math.min(s.entries.length,t.length);for(let o=0;o<i;o++)oe(s.entries[o],t[o]);if(t.length<s.entries.length){for(let o=t.length;o<s.entries.length;o++){const a=s.entries[o];a.state&&R(a.state),a.anchor.remove()}s.entries.length=t.length}else for(let o=s.entries.length;o<t.length;o++){const a=document.createTextNode("");G(e,[a]);const c={anchor:a,state:null};oe(c,t[o]),s.entries.push(c)}return}s&&R(s);const n=[];for(const i of t){const o=document.createTextNode("");G(e,[o]);const a={anchor:o,state:null};oe(a,i),n.push(a)}e.state={shape:"array",entries:n}}function G(e,t){const s=e.anchor.parentNode;if(s)for(const n of t)s.insertBefore(n,e.anchor)}function R(e){if(e.shape==="text"){e.node.remove();return}if(e.shape==="template"){for(const t of e.parts)t.kind==="node"&&t.child.state&&(R(t.child.state),t.child.state=null);for(const t of e.nodes)t.parentNode&&t.parentNode.removeChild(t);return}if(e.shape==="node"){e.node.parentNode&&e.node.parentNode.removeChild(e.node);return}for(const t of e.entries)t.state&&R(t.state),t.anchor.remove()}function Ze(e){return e==null||e===!1?"":String(e)}function I(e,t="short"){if(e===""||e===null||e===void 0)return"";const s=typeof e=="string"&&/^\d{4}-\d{2}$/.test(e)?`${e}-01T00:00:00`:e,n=s instanceof Date?s:new Date(s);if(Number.isNaN(n.getTime()))return String(e);try{switch(t){case"long":return n.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});case"month":return n.toLocaleDateString(void 0,{year:"numeric",month:"long"});case"datetime":return n.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"});case"iso":return n.toISOString();default:return n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}}catch{return String(e)}}function ts(){let e="";const t=new Map;let s=0,n=1,i=0,o=!1,a=!0,c=null,u,p=async()=>{},d=()=>{};const f=()=>{const w=[],v=new Set;for(const g of Array.from(t.keys()).sort(($,y)=>$-y))for(const $ of t.get(g)??[])v.has($.id)||(v.add($.id),w.push($));return w},m=()=>n>Math.max(...Array.from(t.keys()),1),h=w=>{!w.some(v=>v.isIntersecting)||o||!a||(a=!1,o=!0,i=Math.max(1,...Array.from(t.keys()))+1,d(),p().finally(()=>{o=!1,i=0,d()}))};return{accumulate(w,v){return v?(e!==w&&(e=w,t.clear()),t.set(v.page,v.items),s=v.total,n=v.pages,f()):(e="",t.clear(),s=0,n=1,[])},items:f,get total(){return s},get pageCount(){return n},get loadingPage(){return i},hasMore:m,ghosts(w){return i===0||t.has(i)||!m()?0:Math.max(1,Math.min(w,s-f().length))},sync(w){p=w.load,d=w.repaint,!u&&typeof IntersectionObserver<"u"&&(u=new IntersectionObserver(h)),u?.disconnect(),w.sentinel&&u?.observe(w.sentinel),w.canvas!==c&&(c=w.canvas,c?.addEventListener("scroll",()=>{a=!0},{passive:!0})),c&&c.scrollHeight<=c.clientHeight+4&&(a=!0)},dispose(){u?.disconnect(),u=void 0}}}function Je(e,t,s,n){if(n.shift&&e.length>0){const i=e[e.length-1],o=t.indexOf(i),a=t.indexOf(s);if(o!==-1&&a!==-1){const c=t.slice(Math.min(o,a),Math.max(o,a)+1),u=new Set([...e,...c]);return Array.from(u)}}return n.ctrl?e.includes(s)?e.filter(i=>i!==s):[...e,s]:[s]}function ss(e){const{root:t,select:s}=e,n=e.item??"[data-item-id]";let i=null;const o=u=>{if(u.button!==0||!u.target?.closest(e.canvas)||u.target.closest(n))return;const d=document.createElement("div");d.className=e.className??"os-app__marquee",document.body.appendChild(d),i={x:u.clientX,y:u.clientY,box:d},!u.ctrlKey&&!u.metaKey&&!u.shiftKey&&s([])},a=u=>{if(!i)return;const p=Math.min(i.x,u.clientX),d=Math.min(i.y,u.clientY),f=Math.abs(u.clientX-i.x),m=Math.abs(u.clientY-i.y);Object.assign(i.box.style,{left:`${p}px`,top:`${d}px`,width:`${f}px`,height:`${m}px`});const h=[];for(const w of Array.from(t.querySelectorAll(n))){const v=w.getBoundingClientRect();v.left<p+f&&v.right>p&&v.top<d+m&&v.bottom>d&&h.push(Number(w.getAttribute("data-item-id")))}s(h)},c=()=>{i&&(i.box.remove(),i=null)};return t.addEventListener("pointerdown",o),document.addEventListener("pointermove",a),document.addEventListener("pointerup",c),()=>{t.removeEventListener("pointerdown",o),document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",c),c()}}async function ns(e){if(e==="")return!1;const t=globalThis.navigator?.clipboard;if(t?.writeText)try{return await t.writeText(e),!0}catch{}return os(e)}function os(e){const t=globalThis.document;if(!t?.body||typeof t.execCommand!="function")return!1;const s=t.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.setAttribute("aria-hidden","true"),s.style.position="fixed",s.style.insetInlineStart="-9999px",s.style.opacity="0",t.body.appendChild(s);const n=t.activeElement;s.select();let i=!1;try{i=t.execCommand("copy")}catch{i=!1}return s.remove(),n?.focus?.(),i}const is="data-os-mode";function K(e=typeof document<"u"?document.documentElement:null){return!!e&&e.getAttribute(is)==="mobile"}function rs(e,t){const s=t.local??{},n={id:e,hasLocal:a=>Object.prototype.hasOwnProperty.call(s,a),runLocal:(a,c,u,p)=>{const d=s[a];if(!d)return c;const f={...c},m=d(f,u,p);return m===void 0?f:m},render:a=>{Qt(t.view(a),a.root),t.updated?.(a)},mounted:a=>t.mounted?.(a)},{placeholder:i}=t;i&&(n.placeholder=a=>i(a));const o=window;return(o.openStationApps??(o.openStationApps={}))[e]=n,n}function T(){return window.wp?.os??{}}function as(){return{menu:null,folderSel:null,quickEdit:null,zoom:!1,columnsMenu:null,revealSelection:!1,list:ts(),abilityQuery:"",abilityOpen:new Map,nameError:"",agentDraft:null,agentDraftFor:0,agentBusy:!1,agentBackfilled:new Set,agentDropTargets:new Map,rosterStamp:"",chatAfterCreate:!1,fp:null}}function k(e){return e.ui(as)}function ie(e=null){const t=e??(typeof document<"u"?document.documentElement:null);return t&&K(t)?!0:typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function xe(e){return[e.section,e.query,e.sort].join("|")}function re(e,t,s){const n=e.filter(o=>{if(o.sections&&o.sections.length>0&&!(o.sections.includes(t.entityId)||o.sections.includes("*")||!!t.postType&&o.sections.includes(t.postType)))return!1;if(o.mime){if(!t.mime)return!1;try{if(!new RegExp(o.mime).test(t.mime))return!1}catch{return!1}}return!0}),i=s?.applyFilters("os.my-wordpress.preview-actions",n,t);return Array.isArray(i)?i:n}function V(e,t,s){return{entityId:e.id,kind:e.kind,postType:e.post_type,mime:t.mime||void 0,item:t,itemId:t.id,surface:s}}function et(e,t){try{e.onSelect?.(t)}catch{console.error(`[my-wordpress] preview action ${e.id} threw.`)}}function ae(e,t){return e.sections.find(s=>s.id===t)??null}function tt(e,t){const s=e?.applyFilters("os.my-wordpress.list-bands",null,t);return!s||!Array.isArray(s.bands)||s.bands.length===0||typeof s.assign!="function"?null:s}function Ae(e,t){return e.startsWith("dashicons-")?l`<span class="${t} dashicons ${e}" aria-hidden="true"></span>`:l`<span
1 +var openStationApp_myWordpress=function(E){"use strict";const st="desktop-mode";function Le(){return window.wp?.i18n}function r(e,t=st){return Le()?.__(e,t)??e}function B(e,t,s,n=st){return Le()?._n(e,t,s,n)??(s===1?e:t)}function b(e,...t){const s=Le()?.sprintf;if(s)return s(e,...t);let n=0;return e.replace(/%(?:(\d+)\$)?[sd]/g,(o,i)=>{const a=i?Number.parseInt(i,10)-1:n++;return String(t[a]??"")})}function c(e,...t){return{__wpdHtml:!0,strings:e,values:t}}function es(e){return!!e&&e.__wpdHtml===!0}const ts="$$wpd$$",D=/\$\$wpd\$\$(\d+)\$\$/g,ss="$$wpd-node$$",ns=/^\$\$wpd-node\$\$(\d+)\$\$$/,os=new Set(["style","script","textarea","title"]);function is(e){let t="",s=!1,n=null,o=!1,i=null,a="",l=!1;for(let u=0;u<e.length;u++){const d=e[u];t+=d;for(let p=0;p<d.length;p++){const f=d[p];if(o){d.startsWith("-->",p)&&(o=!1,p+=2);continue}if(i!==null){f==="<"&&d[p+1]==="/"&&d.slice(p+2,p+2+i.length).toLowerCase()===i&&(p+=1+i.length,i=null,s=!0,l=!1,a="");continue}if(n!==null){f===n&&(n=null);continue}if(s){f==='"'||f==="'"?(n=f,l=!1):f===">"?(s=!1,l=!1,os.has(a)&&(i=a),a=""):l&&(/[a-zA-Z0-9-]/.test(f)?a+=f.toLowerCase():l=!1);continue}if(d.startsWith("<!--",p)){o=!0,p+=3;continue}const m=d[p+1]??"";f==="<"&&/[a-zA-Z/!]/.test(m)&&(s=!0,a="",l=/[a-zA-Z]/.test(m))}u<e.length-1&&(t+=s||o||i!==null?`${ts}${u}$$`:`<!--${ss}${u}$$-->`)}return t}const nt=new WeakMap;function ot(e){const t=nt.get(e);if(t)return t;const s=document.createElement("template");s.innerHTML=is(e);const n=[],o=(l,u)=>{if(l.nodeType===Node.ELEMENT_NODE){const f=l;for(const m of Array.from(f.attributes)){const h=m.name,$=m.value,_=h[0];if(D.test($))if(D.lastIndex=0,_==="@"){const w=D.exec($);D.lastIndex=0,n.push({path:u,kind:"event",name:h.slice(1),valueIndex:w?Number(w[1]):0}),f.removeAttribute(h)}else if(_==="."){const w=D.exec($);D.lastIndex=0,n.push({path:u,kind:"prop",name:h.slice(1),valueIndex:w?Number(w[1]):0}),f.removeAttribute(h)}else if(_==="?"){const w=D.exec($);D.lastIndex=0,n.push({path:u,kind:"bool",name:h.slice(1),valueIndex:w?Number(w[1]):0}),f.removeAttribute(h)}else{const w=[],g=[];let y=0,v;for(D.lastIndex=0;(v=D.exec($))!==null;)w.push($.slice(y,v.index)),g.push(Number(v[1])),y=v.index+v[0].length;w.push($.slice(y)),n.push({path:u,kind:"attr",name:h,template:w,valueIndices:g}),f.setAttribute(h,"")}}}const d=Array.from(l.childNodes);let p=0;for(let f=0;f<d.length;f++){const m=d[f],h=f+p;if(m.nodeType===Node.COMMENT_NODE){const $=ns.exec(m.data);if($){const _=document.createTextNode("");m.parentNode.replaceChild(_,m),n.push({path:[...u,h],kind:"node",valueIndex:Number($[1])})}continue}if(m.nodeType===Node.TEXT_NODE){const $=m.textContent||"";if(!D.test($)){D.lastIndex=0;continue}D.lastIndex=0;const _=m.parentNode;let w=0,g;const y=[],v=[];for(D.lastIndex=0;(g=D.exec($))!==null;){g.index>w&&y.push(document.createTextNode($.slice(w,g.index)));const M=document.createTextNode("");y.push(M),v.push({path:[...u,h+y.length-1],kind:"node",valueIndex:Number(g[1])}),w=g.index+g[0].length}w<$.length&&y.push(document.createTextNode($.slice(w)));for(const M of y)_.insertBefore(M,m);_.removeChild(m),p+=y.length-1,n.push(...v)}else o(m,[...u,h])}};o(s.content,[]);const a={template:s,buildParts:l=>{const u=[];for(const d of n){let p=l;for(const f of d.path)p=p.childNodes[f];d.kind==="node"?u.push({kind:"node",valueIndex:d.valueIndex,child:{anchor:p,state:null}}):d.kind==="attr"?u.push({kind:"attr",element:p,name:d.name,template:d.template,valueIndices:d.valueIndices}):d.kind==="event"?u.push({kind:"event",valueIndex:d.valueIndex,element:p,name:d.name}):d.kind==="prop"?u.push({kind:"prop",valueIndex:d.valueIndex,element:p,name:d.name}):d.kind==="bool"&&u.push({kind:"bool",valueIndex:d.valueIndex,element:p,name:d.name})}return u}};return nt.set(e,a),a}const it=new WeakMap;function rs(e,t){for(const s of e.nodes)if(s.parentNode!==t)return!1;return!0}function as(e,t){const s=it.get(t);if(s&&s.strings===e.strings&&rs(s,t)){le(s.parts,e.values);return}const n=ot(e.strings),o=n.template.content.cloneNode(!0),i=n.buildParts(o),a=Array.from(o.childNodes);for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(o),le(i,e.values),it.set(t,{strings:e.strings,parts:i,nodes:a})}function le(e,t){for(const s of e)if(s.kind==="node")de(s.child,t[s.valueIndex]);else if(s.kind==="attr"){let n=s.template[0];for(let o=0;o<s.valueIndices.length;o++)n+=rt(t[s.valueIndices[o]]),n+=s.template[o+1];n!==s.last&&(s.last=n,n===""?s.element.removeAttribute(s.name):s.element.setAttribute(s.name,n))}else if(s.kind==="event"){const n=t[s.valueIndex];n!==s.current&&(s.current&&s.element.removeEventListener(s.name,s.current),n&&s.element.addEventListener(s.name,n),s.current=n)}else if(s.kind==="prop"){const n=t[s.valueIndex];n!==s.last&&(s.last=n,s.element[s.name]=n)}else if(s.kind==="bool"){const n=!!t[s.valueIndex];n!==s.last&&(s.last=n,n?s.element.setAttribute(s.name,""):s.element.removeAttribute(s.name))}}function de(e,t){if(t==null||t===!1){e.state&&(F(e.state),e.state=null);return}if(Array.isArray(t)){us(e,t);return}if(es(t)){cs(e,t);return}if(t instanceof Node){ls(e,t);return}ds(e,rt(t))}function ls(e,t){const s=e.state;s?.shape==="node"&&s.node===t||(s&&F(s),x(e,[t]),e.state={shape:"node",node:t})}function ds(e,t){const s=e.state;if(s?.shape==="text"){s.text!==t&&(s.node.textContent=t,s.text=t);return}s&&F(s);const n=document.createTextNode(t);x(e,[n]),e.state={shape:"text",node:n,text:t}}function cs(e,t){const s=e.state;if(s?.shape==="template"&&s.strings===t.strings){le(s.parts,t.values);return}s&&F(s);const n=ot(t.strings),o=n.template.content.cloneNode(!0),i=n.buildParts(o),a=Array.from(o.childNodes);x(e,[o]),le(i,t.values),e.state={shape:"template",strings:t.strings,parts:i,nodes:a}}function us(e,t){const s=e.state;if(s?.shape==="array"){const o=Math.min(s.entries.length,t.length);for(let i=0;i<o;i++)de(s.entries[i],t[i]);if(t.length<s.entries.length){for(let i=t.length;i<s.entries.length;i++){const a=s.entries[i];a.state&&F(a.state),a.anchor.remove()}s.entries.length=t.length}else for(let i=s.entries.length;i<t.length;i++){const a=document.createTextNode("");x(e,[a]);const l={anchor:a,state:null};de(l,t[i]),s.entries.push(l)}return}s&&F(s);const n=[];for(const o of t){const i=document.createTextNode("");x(e,[i]);const a={anchor:i,state:null};de(a,o),n.push(a)}e.state={shape:"array",entries:n}}function x(e,t){const s=e.anchor.parentNode;if(s)for(const n of t)s.insertBefore(n,e.anchor)}function F(e){if(e.shape==="text"){e.node.remove();return}if(e.shape==="template"){for(const t of e.parts)t.kind==="node"&&t.child.state&&(F(t.child.state),t.child.state=null);for(const t of e.nodes)t.parentNode&&t.parentNode.removeChild(t);return}if(e.shape==="node"){e.node.parentNode&&e.node.parentNode.removeChild(e.node);return}for(const t of e.entries)t.state&&F(t.state),t.anchor.remove()}function rt(e){return e==null||e===!1?"":String(e)}function I(e,t="short"){if(e===""||e===null||e===void 0)return"";const s=typeof e=="string"&&/^\d{4}-\d{2}$/.test(e)?`${e}-01T00:00:00`:e,n=s instanceof Date?s:new Date(s);if(Number.isNaN(n.getTime()))return String(e);try{switch(t){case"long":return n.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});case"month":return n.toLocaleDateString(void 0,{year:"numeric",month:"long"});case"datetime":return n.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"});case"iso":return n.toISOString();default:return n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}}catch{return String(e)}}function ps(){let e="";const t=new Map;let s=0,n=1,o=0,i=!1,a=!0,l=null,u,d=async()=>{},p=()=>{};const f=()=>{const $=[],_=new Set;for(const w of Array.from(t.keys()).sort((g,y)=>g-y))for(const g of t.get(w)??[])_.has(g.id)||(_.add(g.id),$.push(g));return $},m=()=>n>Math.max(...Array.from(t.keys()),1),h=$=>{!$.some(_=>_.isIntersecting)||i||!a||(a=!1,i=!0,o=Math.max(1,...Array.from(t.keys()))+1,p(),d().finally(()=>{i=!1,o=0,p()}))};return{accumulate($,_){return _?(e!==$&&(e=$,t.clear()),t.set(_.page,_.items),s=_.total,n=_.pages,f()):(e="",t.clear(),s=0,n=1,[])},items:f,get total(){return s},get pageCount(){return n},get loadingPage(){return o},hasMore:m,ghosts($){return o===0||t.has(o)||!m()?0:Math.max(1,Math.min($,s-f().length))},sync($){d=$.load,p=$.repaint,!u&&typeof IntersectionObserver<"u"&&(u=new IntersectionObserver(h)),u?.disconnect(),$.sentinel&&u?.observe($.sentinel),$.canvas!==l&&(l=$.canvas,l?.addEventListener("scroll",()=>{a=!0},{passive:!0})),l&&l.scrollHeight<=l.clientHeight+4&&(a=!0)},dispose(){u?.disconnect(),u=void 0}}}function at(e,t,s,n){if(n.shift&&e.length>0){const o=e[e.length-1],i=t.indexOf(o),a=t.indexOf(s);if(i!==-1&&a!==-1){const l=t.slice(Math.min(i,a),Math.max(i,a)+1),u=new Set([...e,...l]);return Array.from(u)}}return n.ctrl?e.includes(s)?e.filter(o=>o!==s):[...e,s]:[s]}function fs(e){const{root:t,select:s}=e,n=e.item??"[data-item-id]";let o=null;const i=u=>{if(u.button!==0||!u.target?.closest(e.canvas)||u.target.closest(n))return;const p=document.createElement("div");p.className=e.className??"os-app__marquee",document.body.appendChild(p),o={x:u.clientX,y:u.clientY,box:p},!u.ctrlKey&&!u.metaKey&&!u.shiftKey&&s([])},a=u=>{if(!o)return;const d=Math.min(o.x,u.clientX),p=Math.min(o.y,u.clientY),f=Math.abs(u.clientX-o.x),m=Math.abs(u.clientY-o.y);Object.assign(o.box.style,{left:`${d}px`,top:`${p}px`,width:`${f}px`,height:`${m}px`});const h=[];for(const $ of Array.from(t.querySelectorAll(n))){const _=$.getBoundingClientRect();_.left<d+f&&_.right>d&&_.top<p+m&&_.bottom>p&&h.push(Number($.getAttribute("data-item-id")))}s(h)},l=()=>{o&&(o.box.remove(),o=null)};return t.addEventListener("pointerdown",i),document.addEventListener("pointermove",a),document.addEventListener("pointerup",l),()=>{t.removeEventListener("pointerdown",i),document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",l),l()}}async function ms(e){if(e==="")return!1;const t=globalThis.navigator?.clipboard;if(t?.writeText)try{return await t.writeText(e),!0}catch{}return hs(e)}function hs(e){const t=globalThis.document;if(!t?.body||typeof t.execCommand!="function")return!1;const s=t.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.setAttribute("aria-hidden","true"),s.style.position="fixed",s.style.insetInlineStart="-9999px",s.style.opacity="0",t.body.appendChild(s);const n=t.activeElement;s.select();let o=!1;try{o=t.execCommand("copy")}catch{o=!1}return s.remove(),n?.focus?.(),o}const gs="data-os-mode";function H(e=typeof document<"u"?document.documentElement:null){return!!e&&e.getAttribute(gs)==="mobile"}function ys(e,t){const s=t.local??{},n={id:e,hasLocal:a=>Object.prototype.hasOwnProperty.call(s,a),runLocal:(a,l,u,d)=>{const p=s[a];if(!p)return l;const f={...l},m=p(f,u,d);return m===void 0?f:m},render:a=>{as(t.view(a),a.root),t.updated?.(a)},mounted:a=>t.mounted?.(a)},{placeholder:o}=t;o&&(n.placeholder=a=>o(a));const i=window;return(i.openStationApps??(i.openStationApps={}))[e]=n,n}function T(){return window.wp?.os??{}}function $s(){return{menu:null,folderSel:null,quickEdit:null,trashHidden:new Map,trashPage:null,previewTarget:0,previewScope:"",previewLoading:!1,previewRevision:0,previewError:!1,zoom:!1,columnsMenu:null,revealSelection:!1,list:ps(),abilityQuery:"",abilityOpen:new Map,nameError:"",agentDraft:null,agentDraftFor:0,agentBusy:!1,agentBackfilled:new Set,agentDropTargets:new Map,rosterStamp:"",chatAfterCreate:!1,fp:null}}function k(e){return e.ui($s)}const lt="__openStationSharedStores";function ws(){const e=window;let t=e[lt];return t||(t=new Map,e[lt]=t),t}function ce(e,t){const s=ws();let n=s.get(e);n||(n={state:t(),listeners:new Set,rebuild:t},s.set(e,n));const o={get state(){return n.state},set state(i){n.state=i},getState(){return n.state},notify(){for(const i of Array.from(n.listeners))try{i(n.state)}catch(a){console.error(`[desktop-mode/shared-store:${e}] subscriber threw:`,a)}},subscribe(i){return n.listeners.add(i),()=>{n.listeners.delete(i)}},setState(i){const a=n.state;if(typeof a!="object"||a===null){console.warn(`[desktop-mode/shared-store:${e}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(a,i),o.notify()},reset(){const i=n.rebuild(),a=n.state;if(typeof a=="object"&&a!==null&&typeof i=="object"&&i!==null){const l=a;for(const u of Object.keys(l))delete l[u];Object.assign(l,i)}else n.state=i;n.listeners.clear()}};return o}const L=ce("openstation/trash-optimistic",()=>({changes:new Map,reconcile:new Set})),vs=e=>`${e.type}:${e.id}`;function _s(e){return{subtitle:"",mime:"",preview:"",icon:"",deleted_at:new Date().toISOString(),deleted_by:"",deleted_by_id:0,can_restore:!1,can_purge:!1,edit_link:"",...e}}function ue(){return Array.from(L.state.changes.values())}function bs(e,t){const s=L.subscribe(e);return t&&L.state.reconcile.add(t),()=>{s(),t&&L.state.reconcile.delete(t)}}function ks(e,t="in"){const s=vs(e);if(L.state.changes.get(s)?.pending)return null;const n={item:e,direction:t,pending:!0};return L.state.changes.set(s,n),L.notify(),{async finish(o){L.state.changes.get(s)!==n||!n.pending||(n.pending=!1,o&&(L.notify(),await Promise.allSettled(Array.from(L.state.reconcile,async i=>i()))),L.state.changes.get(s)===n&&(L.state.changes.delete(s),L.notify()))}}}function pe(e=null){const t=e??(typeof document<"u"?document.documentElement:null);return t&&H(t)?!0:typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function fe(e){return[e.section,e.query,e.sort].join("|")}function me(e,t,s){const n=e.filter(i=>{if(i.sections&&i.sections.length>0&&!(i.sections.includes(t.entityId)||i.sections.includes("*")||!!t.postType&&i.sections.includes(t.postType)))return!1;if(i.mime){if(!t.mime)return!1;try{if(!new RegExp(i.mime).test(t.mime))return!1}catch{return!1}}return!0}),o=s?.applyFilters("os.my-wordpress.preview-actions",n,t);return Array.isArray(o)?o:n}function ee(e,t,s){return{entityId:e.id,kind:e.kind,postType:e.post_type,mime:t.mime||void 0,item:t,itemId:t.id,surface:s}}function dt(e,t){try{e.onSelect?.(t)}catch{console.error(`[my-wordpress] preview action ${e.id} threw.`)}}function X(e,t){return e.sections.find(s=>s.id===t)??null}function ct(e,t){const s=e?.applyFilters("os.my-wordpress.list-bands",null,t);return!s||!Array.isArray(s.bands)||s.bands.length===0||typeof s.assign!="function"?null:s}function Pe(e,t){return e.startsWith("dashicons-")?c`<span class="${t} dashicons ${e}" aria-hidden="true"></span>`:c`<span
2 2 class="${t} os-mywp__icon-mask"
3 3 style="--mywp-icon:url(&quot;${e.replace(/"/g,"%22")}&quot;)"
4 4 aria-hidden="true"
5 - ></span>`}function st(e,t){if(t.length<=e.length||!e.every((o,a)=>t[a]?.id===o.id))return t;const s=t.slice(e.length),n=s.filter(o=>o.id.startsWith("agent-send-to-"));if(n.length===0)return t;const i=s.filter(o=>!o.id.startsWith("agent-send-to-"));return[...t.slice(0,e.length),...i,{id:"send-to-heading",label:r("Send to"),heading:!0},...n]}function nt(e,t,s){const n=[];t.canEdit&&n.push({id:"edit",label:e.kind==="user"?r("Edit profile"):r("Open in editor")}),n.push({id:"open",label:r("Navigate into")}),e.kind==="post"&&t.canEdit&&!e.flat&&(n.push({id:"quick-edit",label:r("Edit…")}),t.status!=="publish"&&n.push({id:"publish",label:r("Publish")})),t.link&&n.push({id:"copy-link",label:r("Copy link")}),t.shortlink&&n.push({id:"copy-shortlink",label:r("Copy shortlink")}),n.push({id:"copy-id",label:r("Copy ID")}),e.kind==="post"&&!e.flat&&n.push({id:"trash",label:r("Move to Trash"),danger:!0,disabled:!t.canDelete});for(const i of s)n.push({id:i.id,label:i.label,icon:i.icon});return n}const ot="desktop-mode-user-edit";function Q(e,t={}){if(!Number.isFinite(e)||e<=0)return!1;const s=window.wp?.os;return s?.openWindow?.(ot,{source:t.source??"user-edit/open",params:{userId:e}})?(s?.relations?.set?.(ot,{type:"user",id:e}),!0):(t.fallback?.(),!1)}const ls=500,cs=10,z=new WeakMap;function le(e){const t=z.get(e);t&&(clearTimeout(t.timer),z.delete(e))}function ds(e){return e.isPrimary&&(e.pointerType==="touch"||e.pointerType==="pen")}function Me(e,t=()=>!0){return{pointerdown:s=>{const n=s.currentTarget;if(le(n),!ds(s)||!t(s))return;const i=s.clientX,o=s.clientY,a=setTimeout(()=>{z.delete(n);const c=u=>{u.stopPropagation(),u.preventDefault()};n.addEventListener("click",c,{capture:!0,once:!0}),setTimeout(()=>n.removeEventListener("click",c,{capture:!0}),700),e(i,o)},ls);z.set(n,{pointerId:s.pointerId,x:i,y:o,timer:a})},pointermove:s=>{const n=s.currentTarget,i=z.get(n);!i||i.pointerId!==s.pointerId||Math.hypot(s.clientX-i.x,s.clientY-i.y)>cs&&le(n)},pointerup:s=>{const n=s.currentTarget;z.get(n)?.pointerId===s.pointerId&&le(n)},pointercancel:s=>{le(s.currentTarget)}}}function Te(e,t,s,n){const i=(a,c)=>{k(e).menu={x:a,y:c,item:s},e.repaint()},o=()=>{if(t.kind==="user"){if(T().hooks?.applyFilters("os.my-wordpress.user-activate",!1,{entityId:t.id,kind:t.kind,item:s})===!0)return;e.dispatch("footprint",{user:s.id,name:s.title});return}s.canEdit&&e.dispatch("edit",{item:s.id})};return{select:a=>{if(e.local("select",{item:s.id,ctrl:a.ctrlKey||a.metaKey,shift:a.shiftKey,order:n}),!(a.ctrlKey||a.metaKey||a.shiftKey)){if(ie()&&(t.kind==="user"||s.canEdit)){o();return}e.dispatch("open",{item:s.id})}},activate:o,menu:a=>{a.preventDefault(),a.stopPropagation(),i(a.clientX,a.clientY)},menuAt:a=>{const c=a.getBoundingClientRect();i(c.left,c.bottom+2)},press:Me(i)}}async function Ce(e,t,s){const n=await ns(t);e.host.toast?.({message:n?s:r("Could not copy — the clipboard is not available here.")})}function it(e){return b(r("Copied ID %d."),e)}function Ee(e,t,s){const n=t.map(o=>String(o[s]??"")).filter(Boolean);let i=b(r("Copied %d links."),n.length);n.length===1&&(i=r(s==="shortlink"?"Copied the shortlink.":"Copied the link.")),Ce(e,n.join(`
6 -`),i)}function us(e,t){const s=t.map(n=>n.id);Ce(e,s.join(", "),s.length===1?it(s[0]):b(r("Copied %d IDs."),s.length))}function ps(e){if(e===""||e==="publish")return"";const t={draft:"warning",pending:"info",future:"info",private:"neutral"},s={draft:r("Draft"),pending:r("Pending"),future:r("Scheduled"),private:r("Private")};return l`<os-badge tone=${t[e]??"neutral"} no-dot class="os-mywp__cell-badge">${s[e]??e}</os-badge>`}function Ie(e,t){const s=e.thumb?l`<img class="os-mywp__cell-thumb" src=${e.thumb} alt="" loading="lazy" />`:Ae(t.icon,"os-mywp__cell-glyph");return l`
5 + ></span>`}function ut(e,t){if(t.length<=e.length||!e.every((i,a)=>t[a]?.id===i.id))return t;const s=t.slice(e.length),n=s.filter(i=>i.id.startsWith("agent-send-to-"));if(n.length===0)return t;const o=s.filter(i=>!i.id.startsWith("agent-send-to-"));return[...t.slice(0,e.length),...o,{id:"send-to-heading",label:r("Send to"),heading:!0},...n]}function pt(e,t,s){const n=[];t.canEdit&&n.push({id:"edit",label:e.kind==="user"?r("Edit profile"):r("Open in editor")}),n.push({id:"open",label:r("Navigate into")}),e.kind==="post"&&t.canEdit&&!e.flat&&(n.push({id:"quick-edit",label:r("Edit…")}),t.status!=="publish"&&n.push({id:"publish",label:r("Publish")})),t.link&&n.push({id:"copy-link",label:r("Copy link")}),t.shortlink&&n.push({id:"copy-shortlink",label:r("Copy shortlink")}),n.push({id:"copy-id",label:r("Copy ID")}),e.kind==="post"&&!e.flat&&n.push({id:"trash",label:r("Move to Trash"),danger:!0,disabled:!t.canDelete});for(const o of s)n.push({id:o.id,label:o.label,icon:o.icon});return n}const he=e=>JSON.stringify([e.state.group,e.state.section,e.state.query,e.state.into,e.state.relation,e.state.footprint]);function ft(e){const t=Object.create(e);return Object.defineProperty(t,"state",{get:()=>{const s=k(e);return s.previewLoading&&s.previewScope===he(e)?{...e.state,item:s.previewTarget}:e.state}}),t}function mt(e){e=ft(e);const t=e.data.detail,s=X(e.data,e.state.section);return t?.id===e.state.item&&t.kind===s?.kind?t:null}function Ss(e){const t=k(e);return t.previewError?r("Could not load details."):t.previewLoading?r("Loading details…"):r("Details are not available for this item.")}function O(e,t){const s=k(e),n=s.previewLoading;s.previewTarget=t,s.previewScope=he(e),s.previewError=!1,s.previewRevision++,s.previewLoading=n||t>0,e.local("preview",{item:t}),!(n||t===0)&&(s.previewLoading=!0,(async()=>{try{let o;do{o=s.previewRevision;const i=s.previewTarget,a=s.previewScope,l=await e.dispatch("open",{item:i});if(a!==he(e)){if(o!==s.previewRevision&&s.previewScope===he(e))continue;break}e.local("preview",{item:s.previewTarget}),o===s.previewRevision&&(s.previewError=!l)}while(o!==s.previewRevision&&s.previewTarget>0)}catch{s.previewError=!0}finally{s.previewLoading=!1,e.repaint()}})())}function As(e,t,s){const n=k(e),o=fe(e.state),i=n.trashHidden.get(o)??new Set;if(n.trashPage!==e.data.list){n.trashPage=e.data.list;for(const l of e.data.list?.items??[])ge(t,l.id)||i.delete(l.id)}const a=new Set(ue().filter(l=>l.direction==="in"&&l.item.type===t.post_type).map(l=>l.item.id));return s.filter(l=>!i.has(l.id)&&!a.has(l.id))}function ge(e,t){return ue().some(s=>s.direction==="in"&&s.item.type===e.post_type&&s.item.id===t)}function Ms(e){let t=null;return bs(()=>e.repaint(),()=>(t??(t=Promise.resolve().then(async()=>{if(t=null,await e.dispatch("refresh")){const n=k(e),o=X(e.data,e.state.section),i=fe(e.state),a=n.trashHidden.get(i)??new Set;for(const u of ue())u.direction==="in"&&!u.pending&&u.item.type===o?.post_type&&!e.data.list?.items.some(d=>d.id===u.item.id)&&a.add(u.item.id);n.trashHidden.set(i,a);const l=ue().filter(u=>!u.pending&&u.direction==="in"&&u.item.type===o?.post_type).map(u=>u.item.id);e.local("select-set",{ids:e.state.selected.filter(u=>!l.includes(u))}),l.includes(e.state.item)&&O(e,0)}})),t))}async function ht(e,t,s){if(s.length===0||!await e.host.confirm?.({message:s.length>1?b(r("Move %d items to the Trash?"),s.length):r("Move this to the Trash?"),confirmLabel:r("Trash"),danger:!0}))return;const o=s.flatMap(u=>{const d=ks(_s({id:u.id,type:t.post_type??"post",title:u.title,subtitle:u.subtitle,preview:u.thumb}));return d?[{row:u,operation:d}]:[]});if(o.length===0)return;if(!t.restPath){let u=!1;try{o.length===1?u=await e.dispatch("trash",{item:o[0].row.id}):(e.local("select-set",{ids:o.map(({row:d})=>d.id)}),u=await e.dispatch("bulk-trash"))}finally{o.forEach(({operation:d})=>void d.finish(u))}return}const i=await Promise.allSettled(o.map(async({row:u})=>{if(!(await e.fetch(`${t.restPath.replace(/\/+$/,"")}/${u.id}`,{method:"DELETE"})).ok)throw new Error(r("Could not move this item to Trash."))})),a=o.filter((u,d)=>i[d].status==="fulfilled").map(({row:u})=>u.id);a.length>0&&(e.host.announce?.(t.post_type??"post","trashed",a),e.local("select-set",{ids:e.state.selected.filter(u=>!a.includes(u))}),a.includes(e.state.item)&&O(e,0)),i.forEach((u,d)=>{o[d].operation.finish(u.status==="fulfilled")});const l=i.length-a.length;e.host.toast?.({message:l>0?b(r("%d item(s) could not be moved to Trash."),l):b(r("Moved %d item(s) to the Trash."),a.length)})}const gt="desktop-mode-user-edit";function te(e,t={}){if(!Number.isFinite(e)||e<=0)return!1;const s=window.wp?.os;return s?.openWindow?.(gt,{source:t.source??"user-edit/open",params:{userId:e}})?(s?.relations?.set?.(gt,{type:"user",id:e}),!0):(t.fallback?.(),!1)}const Ts=500,Cs=10,Y=new WeakMap;function ye(e){const t=Y.get(e);t&&(clearTimeout(t.timer),Y.delete(e))}function Es(e){return e.isPrimary&&(e.pointerType==="touch"||e.pointerType==="pen")}function Re(e,t=()=>!0){return{pointerdown:s=>{const n=s.currentTarget;if(ye(n),!Es(s)||!t(s))return;const o=s.clientX,i=s.clientY,a=setTimeout(()=>{Y.delete(n);const l=u=>{u.stopPropagation(),u.preventDefault()};n.addEventListener("click",l,{capture:!0,once:!0}),setTimeout(()=>n.removeEventListener("click",l,{capture:!0}),700),e(o,i)},Ts);Y.set(n,{pointerId:s.pointerId,x:o,y:i,timer:a})},pointermove:s=>{const n=s.currentTarget,o=Y.get(n);!o||o.pointerId!==s.pointerId||Math.hypot(s.clientX-o.x,s.clientY-o.y)>Cs&&ye(n)},pointerup:s=>{const n=s.currentTarget;Y.get(n)?.pointerId===s.pointerId&&ye(n)},pointercancel:s=>{ye(s.currentTarget)}}}function Oe(e,t,s,n){const o=(a,l)=>{k(e).menu={x:a,y:l,item:s},e.repaint()},i=()=>{if(t.kind==="user"){if(T().hooks?.applyFilters("os.my-wordpress.user-activate",!1,{entityId:t.id,kind:t.kind,item:s})===!0)return;e.dispatch("footprint",{user:s.id,name:s.title});return}s.canEdit&&e.dispatch("edit",{item:s.id})};return{select:a=>{if(e.local("select",{item:s.id,ctrl:a.ctrlKey||a.metaKey,shift:a.shiftKey,order:n}),!(a.ctrlKey||a.metaKey||a.shiftKey)){if(pe()&&(t.kind==="user"||s.canEdit)){i();return}O(e,s.id)}},activate:i,menu:a=>{a.preventDefault(),a.stopPropagation(),o(a.clientX,a.clientY)},menuAt:a=>{const l=a.getBoundingClientRect();o(l.left,l.bottom+2)},press:Re(o)}}async function Fe(e,t,s){const n=await ms(t);e.host.toast?.({message:n?s:r("Could not copy — the clipboard is not available here.")})}function yt(e){return b(r("Copied ID %d."),e)}function We(e,t,s){const n=t.map(i=>String(i[s]??"")).filter(Boolean);let o=b(r("Copied %d links."),n.length);n.length===1&&(o=r(s==="shortlink"?"Copied the shortlink.":"Copied the link.")),Fe(e,n.join(`
6 +`),o)}function Is(e,t){const s=t.map(n=>n.id);Fe(e,s.join(", "),s.length===1?yt(s[0]):b(r("Copied %d IDs."),s.length))}function Ns(e){if(e===""||e==="publish")return"";const t={draft:"warning",pending:"info",future:"info",private:"neutral"},s={draft:r("Draft"),pending:r("Pending"),future:r("Scheduled"),private:r("Private")};return c`<os-badge tone=${t[e]??"neutral"} no-dot class="os-mywp__cell-badge">${s[e]??e}</os-badge>`}function Ue(e,t){const s=e.thumb?c`<img class="os-mywp__cell-thumb" src=${e.thumb} alt="" loading="lazy" />`:Pe(t.icon,"os-mywp__cell-glyph");return c`
7 7 <span class="os-mywp__cell-title">
8 8 ${s}
9 9 <span class="os-mywp__cell-text">${e.title}</span>
10 - ${t.kind==="post"?ps(e.status):""}
11 - ${e.lockedBy?l`<span
10 + ${t.kind==="post"?Ns(e.status):""}
11 + ${e.lockedBy?c`<span
12 12 class="dashicons dashicons-lock os-mywp__cell-lock"
13 13 title=${b(r("%s is editing"),e.lockedBy)}
14 14 ></span>`:""}
15 15 </span>
16 - `}function Ne(e){return e?l`<time datetime=${e} title=${I(e,"datetime")}>${I(e,"long")}</time>`:""}function rt(e){return e?l`<os-relative-time datetime=${e} title=${I(e,"datetime")}></os-relative-time>`:""}const De={id:"id",label:r("ID"),sort:{asc:"id-asc",desc:"id-desc",first:"desc"},mono:!0,align:"end",locked:!0,render:e=>e.id},ce={id:"actions",label:r("Actions"),align:"end",locked:!0,render:()=>""};function fs(e){const t=[De,{id:"title",label:r("Title"),sort:{asc:"title-asc",desc:"title-desc",first:"asc"},width:"1fr",locked:!0,render:Ie},{id:"slug",label:r("Slug"),sort:{asc:"slug-asc",desc:"slug-desc",first:"asc"},mono:!0,render:s=>s.slug??""},{id:"author",label:r("Author"),render:s=>s.author??""},{id:"status",label:r("Status"),render:s=>s.status},{id:"date",label:r("Date"),sort:{asc:"oldest",desc:"default",first:"desc"},render:s=>Ne(s.date)},{id:"modified",label:r("Modified"),sort:{asc:"modified-asc",desc:"modified",first:"desc"},render:s=>rt(s.modified)},{id:"comments",label:r("Comments"),sort:{asc:"comments-asc",desc:"comments",first:"desc"},align:"end",mono:!0,render:s=>s.comments??0}];return e.hierarchical&&t.push({id:"parent",label:r("Parent"),render:s=>s.parent&&s.parent>0?l`<span class="os-mywp__cell-parent"><span class="os-mywp__cell-id">#${s.parent}</span> ${s.parentTitle??""}</span>`:""}),t.push({id:"words",label:r("Words"),align:"end",mono:!0,hidden:!0,render:s=>s.words??0},ce),t}function ms(){return[De,{id:"title",label:r("File"),sort:{asc:"title-asc",desc:"title-desc",first:"asc"},width:"1fr",locked:!0,render:Ie},{id:"file",label:r("File name"),sort:{asc:"slug-asc",desc:"slug-desc",first:"asc"},mono:!0,render:e=>e.file??""},{id:"mime",label:r("Type"),mono:!0,render:e=>e.mime},{id:"size",label:r("Size"),align:"end",mono:!0,render:e=>e.size??""},{id:"dimensions",label:r("Dimensions"),mono:!0,render:e=>e.dimensions??""},{id:"parent",label:r("Attached to"),render:e=>e.parent&&e.parent>0?l`<span class="os-mywp__cell-parent"><span class="os-mywp__cell-id">#${e.parent}</span> ${e.parentTitle??""}</span>`:l`<span class="os-mywp__cell-muted">${r("Unattached")}</span>`},{id:"author",label:r("Uploaded by"),hidden:!0,render:e=>e.author??""},{id:"date",label:r("Uploaded"),sort:{asc:"oldest",desc:"default",first:"desc"},render:e=>Ne(e.date)},{id:"modified",label:r("Modified"),sort:{asc:"modified-asc",desc:"modified",first:"desc"},hidden:!0,render:e=>rt(e.modified)},ce]}function hs(){return[De,{id:"title",label:r("Name"),sort:{asc:"default",desc:"title-desc",first:"asc"},width:"1fr",locked:!0,render:Ie},{id:"login",label:r("Username"),sort:{asc:"login-asc",desc:"login-desc",first:"asc"},mono:!0,render:e=>e.login??""},{id:"email",label:r("Email"),sort:{asc:"email-asc",desc:"email-desc",first:"asc"},render:e=>e.email??e.subtitle},{id:"roles",label:r("Role"),render:e=>e.status},{id:"posts",label:r("Posts"),sort:{asc:"posts-asc",desc:"posts",first:"desc"},align:"end",mono:!0,render:e=>e.posts??0},{id:"registered",label:r("Registered"),sort:{asc:"oldest",desc:"newest",first:"desc"},render:e=>Ne(e.registered)},ce]}function de(e){let t;e.kind==="user"?t=hs():e.kind==="media"?t=ms():t=fs(e);const s=T().hooks?.applyFilters("os.my-wordpress.list-columns",t,e);if(!Array.isArray(s))return t;const n=s.filter(o=>{if(!o||typeof o!="object")return!1;const a=o;return typeof a.id=="string"&&a.id!==""&&typeof a.render=="function"}),i=new Set(n.map(o=>o.id));return i.has("title")||n.unshift(t.find(o=>o.id==="title")),i.has("actions")||n.push(ce),n}function ue(e,t,s){const n=e.data.hiddenColumns?.[t.id];return Array.isArray(n)?new Set(n.map(String)):new Set(s.filter(i=>i.hidden).map(i=>i.id))}function at(e,t){if(!e.sort)return t;const{asc:s,desc:n,first:i}=e.sort,o=i==="asc"?s:n;return t===o?i==="asc"?n:s:o}function gs(e,t){return!!e.sort&&e.sort.asc in t&&e.sort.desc in t}function pe(e,t,s){return l`
16 + `}function qe(e){return e?c`<time datetime=${e} title=${I(e,"datetime")}>${I(e,"long")}</time>`:""}function $t(e){return e?c`<os-relative-time datetime=${e} title=${I(e,"datetime")}></os-relative-time>`:""}const Be={id:"id",label:r("ID"),sort:{asc:"id-asc",desc:"id-desc",first:"desc"},mono:!0,align:"end",locked:!0,render:e=>e.id},$e={id:"actions",label:r("Actions"),align:"end",locked:!0,render:()=>""};function Ds(e){const t=[Be,{id:"title",label:r("Title"),sort:{asc:"title-asc",desc:"title-desc",first:"asc"},width:"1fr",locked:!0,render:Ue},{id:"slug",label:r("Slug"),sort:{asc:"slug-asc",desc:"slug-desc",first:"asc"},mono:!0,render:s=>s.slug??""},{id:"author",label:r("Author"),render:s=>s.author??""},{id:"status",label:r("Status"),render:s=>s.status},{id:"date",label:r("Date"),sort:{asc:"oldest",desc:"default",first:"desc"},render:s=>qe(s.date)},{id:"modified",label:r("Modified"),sort:{asc:"modified-asc",desc:"modified",first:"desc"},render:s=>$t(s.modified)},{id:"comments",label:r("Comments"),sort:{asc:"comments-asc",desc:"comments",first:"desc"},align:"end",mono:!0,render:s=>s.comments??0}];return e.hierarchical&&t.push({id:"parent",label:r("Parent"),render:s=>s.parent&&s.parent>0?c`<span class="os-mywp__cell-parent"><span class="os-mywp__cell-id">#${s.parent}</span> ${s.parentTitle??""}</span>`:""}),t.push({id:"words",label:r("Words"),align:"end",mono:!0,hidden:!0,render:s=>s.words??0},$e),t}function Ls(){return[Be,{id:"title",label:r("File"),sort:{asc:"title-asc",desc:"title-desc",first:"asc"},width:"1fr",locked:!0,render:Ue},{id:"file",label:r("File name"),sort:{asc:"slug-asc",desc:"slug-desc",first:"asc"},mono:!0,render:e=>e.file??""},{id:"mime",label:r("Type"),mono:!0,render:e=>e.mime},{id:"size",label:r("Size"),align:"end",mono:!0,render:e=>e.size??""},{id:"dimensions",label:r("Dimensions"),mono:!0,render:e=>e.dimensions??""},{id:"parent",label:r("Attached to"),render:e=>e.parent&&e.parent>0?c`<span class="os-mywp__cell-parent"><span class="os-mywp__cell-id">#${e.parent}</span> ${e.parentTitle??""}</span>`:c`<span class="os-mywp__cell-muted">${r("Unattached")}</span>`},{id:"author",label:r("Uploaded by"),hidden:!0,render:e=>e.author??""},{id:"date",label:r("Uploaded"),sort:{asc:"oldest",desc:"default",first:"desc"},render:e=>qe(e.date)},{id:"modified",label:r("Modified"),sort:{asc:"modified-asc",desc:"modified",first:"desc"},hidden:!0,render:e=>$t(e.modified)},$e]}function Ps(){return[Be,{id:"title",label:r("Name"),sort:{asc:"default",desc:"title-desc",first:"asc"},width:"1fr",locked:!0,render:Ue},{id:"login",label:r("Username"),sort:{asc:"login-asc",desc:"login-desc",first:"asc"},mono:!0,render:e=>e.login??""},{id:"email",label:r("Email"),sort:{asc:"email-asc",desc:"email-desc",first:"asc"},render:e=>e.email??e.subtitle},{id:"roles",label:r("Role"),render:e=>e.status},{id:"posts",label:r("Posts"),sort:{asc:"posts-asc",desc:"posts",first:"desc"},align:"end",mono:!0,render:e=>e.posts??0},{id:"registered",label:r("Registered"),sort:{asc:"oldest",desc:"newest",first:"desc"},render:e=>qe(e.registered)},$e]}function we(e){let t;e.kind==="user"?t=Ps():e.kind==="media"?t=Ls():t=Ds(e);const s=T().hooks?.applyFilters("os.my-wordpress.list-columns",t,e);if(!Array.isArray(s))return t;const n=s.filter(i=>{if(!i||typeof i!="object")return!1;const a=i;return typeof a.id=="string"&&a.id!==""&&typeof a.render=="function"}),o=new Set(n.map(i=>i.id));return o.has("title")||n.unshift(t.find(i=>i.id==="title")),o.has("actions")||n.push($e),n}function ve(e,t,s){const n=e.data.hiddenColumns?.[t.id];return Array.isArray(n)?new Set(n.map(String)):new Set(s.filter(o=>o.hidden).map(o=>o.id))}function wt(e,t){if(!e.sort)return t;const{asc:s,desc:n,first:o}=e.sort,i=o==="asc"?s:n;return t===i?o==="asc"?n:s:i}function Rs(e,t){return!!e.sort&&e.sort.asc in t&&e.sort.desc in t}function _e(e,t,s){return c`
17 17 <os-button
18 18 variant="ghost"
19 19 class="os-mywp__row-action"
20 20 title=${t}
@@ -23,9 +23,9 @@
23 23 @dblclick=${n=>n.stopPropagation()}
24 24 >
25 25 <span class="dashicons ${e}" aria-hidden="true"></span>
26 26 </os-button>
27 - `}function $s(e,t,s,n){const i=Te(e,t,s,n),o=[];return s.canEdit&&o.push(pe("dashicons-edit",t.kind==="user"?r("Edit profile"):r("Open in editor"),()=>{t.kind==="user"?Q(s.id,{source:"my-wordpress-app/list-view",fallback:()=>void e.dispatch("edit",{item:s.id})}):e.dispatch("edit",{item:s.id})})),t.kind==="user"&&o.push(pe("dashicons-chart-area",r("View activity footprint"),()=>void e.dispatch("footprint",{user:s.id,name:s.title}))),s.link&&o.push(pe("dashicons-admin-links",t.kind==="media"?r("Copy URL"):r("Copy link"),()=>Ee(e,[s],"link"))),s.shortlink&&o.push(pe("dashicons-shortcode",r("Copy shortlink"),()=>Ee(e,[s],"shortlink"))),o.push(l`
27 + `}function Os(e,t,s,n){const o=Oe(e,t,s,n),i=[];return s.canEdit&&i.push(_e("dashicons-edit",t.kind==="user"?r("Edit profile"):r("Open in editor"),()=>{t.kind==="user"?te(s.id,{source:"my-wordpress-app/list-view",fallback:()=>void e.dispatch("edit",{item:s.id})}):e.dispatch("edit",{item:s.id})})),t.kind==="user"&&i.push(_e("dashicons-chart-area",r("View activity footprint"),()=>void e.dispatch("footprint",{user:s.id,name:s.title}))),s.link&&i.push(_e("dashicons-admin-links",t.kind==="media"?r("Copy URL"):r("Copy link"),()=>We(e,[s],"link"))),s.shortlink&&i.push(_e("dashicons-shortcode",r("Copy shortlink"),()=>We(e,[s],"shortlink"))),i.push(c`
28 28 <os-button
29 29 variant="ghost"
30 30 class="os-mywp__row-action"
31 31 title=${r("More actions")}
@@ -30,26 +30,26 @@
30 30 class="os-mywp__row-action"
31 31 title=${r("More actions")}
32 32 aria-label=${r("More actions")}
33 33 aria-haspopup="menu"
34 - @click=${a=>{a.stopPropagation(),i.menuAt(a.currentTarget)}}
34 + @click=${a=>{a.stopPropagation(),o.menuAt(a.currentTarget)}}
35 35 @dblclick=${a=>a.stopPropagation()}
36 36 >
37 37 <span class="dashicons dashicons-ellipsis" aria-hidden="true"></span>
38 38 </os-button>
39 - `),l`<span class="os-mywp__row-actions">${o}</span>`}function ys(e,t,s,n,i){const o=["os-mywp__td",t.align==="end"?"os-mywp__td--end":"",t.mono?"os-mywp__td--mono":"",`os-mywp__td--${t.id}`].filter(Boolean).join(" ");if(t.id==="id")return l`
40 - <td class=${o}>
39 + `),c`<span class="os-mywp__row-actions">${i}</span>`}function Fs(e,t,s,n,o){const i=["os-mywp__td",t.align==="end"?"os-mywp__td--end":"",t.mono?"os-mywp__td--mono":"",`os-mywp__td--${t.id}`].filter(Boolean).join(" ");if(t.id==="id")return c`
40 + <td class=${i}>
41 41 <button
42 42 type="button"
43 43 class="os-mywp__cell-id os-mywp__cell-id--copy"
44 44 title=${r("Copy ID")}
45 - @click=${c=>{c.stopPropagation(),Ce(e,String(s.id),it(s.id))}}
46 - @dblclick=${c=>c.stopPropagation()}
45 + @click=${l=>{l.stopPropagation(),Fe(e,String(s.id),yt(s.id))}}
46 + @dblclick=${l=>l.stopPropagation()}
47 47 >${s.id}</button>
48 48 </td>
49 - `;if(t.id==="actions")return l`<td class=${o}>${$s(e,n,s,i)}</td>`;let a;try{a=t.render(s,n)}catch{a=""}return l`<td class=${o}>${a}</td>`}function ws(e,t,s,n,i){const{state:o}=e,a=o.selected.includes(s.id),c=o.item===s.id,u=Te(e,t,s,i),p=d=>{const f=d.currentTarget;d.key==="Enter"?(d.preventDefault(),u.activate()):d.key===" "?(d.preventDefault(),e.local("select",{item:s.id,ctrl:d.ctrlKey||d.metaKey,shift:d.shiftKey,order:i}),e.dispatch("open",{item:s.id})):(d.key==="ArrowDown"||d.key==="ArrowUp")&&(d.preventDefault(),(d.key==="ArrowDown"?f.nextElementSibling:f.previousElementSibling)?.focus?.())};return l`
49 + `;if(t.id==="actions")return c`<td class=${i}>${Os(e,n,s,o)}</td>`;let a;try{a=t.render(s,n)}catch{a=""}return c`<td class=${i}>${a}</td>`}function Ws(e,t,s,n,o){const{state:i}=e,a=i.selected.includes(s.id),l=i.item===s.id,u=Oe(e,t,s,o),d=p=>{const f=p.currentTarget;p.key==="Enter"?(p.preventDefault(),u.activate()):p.key===" "?(p.preventDefault(),e.local("select",{item:s.id,ctrl:p.ctrlKey||p.metaKey,shift:p.shiftKey,order:o}),O(e,s.id)):(p.key==="ArrowDown"||p.key==="ArrowUp")&&(p.preventDefault(),(p.key==="ArrowDown"?f.nextElementSibling:f.previousElementSibling)?.focus?.())};return c`
50 50 <tr
51 - class="os-mywp__row ${c?"is-open":""} ${a?"is-selected":""}"
51 + class="os-mywp__row ${l?"is-open":""} ${a?"is-selected":""}"
52 52 data-item-id=${String(s.id)}
53 53 data-mywp-drag=${t.kind==="user"?"user":t.post_type}
54 54 role="row"
55 55 aria-selected=${a?"true":"false"}
@@ -60,13 +60,13 @@
60 60 @pointerdown=${u.press.pointerdown}
61 61 @pointermove=${u.press.pointermove}
62 62 @pointerup=${u.press.pointerup}
63 63 @pointercancel=${u.press.pointercancel}
64 - @keydown=${p}
64 + @keydown=${d}
65 65 >
66 - ${n.map(d=>ys(e,d,s,t,i))}
66 + ${n.map(p=>Fs(e,p,s,t,o))}
67 67 </tr>
68 - `}function _s(e,t,s){const n=k(e),i=de(t),o=ue(e,t,i),a=i.filter($=>!o.has($.id)),c=s.map($=>$.id),u=e.state.sort||"default",p=e.data.sortOptions??{},d=n.list.hasMore(),f=n.list.ghosts(e.data.list?.perPage??24),m=$=>{const y=at($,u);e.local("set-sort",{sort:y==="default"?"":y}),e.dispatch("sort")},h=$=>$.sort?u===$.sort.asc?"ascending":u===$.sort.desc?"descending":"none":"none",w=$=>{const y=["os-mywp__th",$.align==="end"?"os-mywp__th--end":"",`os-mywp__th--${$.id}`].filter(Boolean).join(" ");if($.id==="actions")return l`
68 + `}function Us(e,t,s){const n=k(e),o=we(t),i=ve(e,t,o),a=o.filter(g=>!i.has(g.id)),l=s.map(g=>g.id),u=e.state.sort||"default",d=e.data.sortOptions??{},p=n.list.hasMore(),f=n.list.ghosts(e.data.list?.perPage??24),m=g=>{const y=wt(g,u);e.local("set-sort",{sort:y==="default"?"":y}),e.dispatch("sort")},h=g=>g.sort?u===g.sort.asc?"ascending":u===g.sort.desc?"descending":"none":"none",$=g=>{const y=["os-mywp__th",g.align==="end"?"os-mywp__th--end":"",`os-mywp__th--${g.id}`].filter(Boolean).join(" ");if(g.id==="actions")return c`
69 69 <th class=${y} scope="col">
70 70 <os-button
71 71 variant="ghost"
72 72 class="os-mywp__row-action os-mywp__columns-btn"
@@ -72,33 +72,33 @@
72 72 class="os-mywp__row-action os-mywp__columns-btn"
73 73 title=${r("Choose columns")}
74 74 aria-label=${r("Choose columns")}
75 75 aria-haspopup="menu"
76 - @click=${M=>{const S=M.currentTarget.getBoundingClientRect();n.columnsMenu={x:S.left,y:S.bottom+2},e.repaint()}}
76 + @click=${S=>{const A=S.currentTarget.getBoundingClientRect();n.columnsMenu={x:A.left,y:A.bottom+2},e.repaint()}}
77 77 >
78 78 <span class="dashicons dashicons-screenoptions" aria-hidden="true"></span>
79 79 </os-button>
80 80 </th>
81 - `;if(!gs($,p))return l`<th class=${y} scope="col">${$.label}</th>`;const _=h($),A={ascending:"▲",descending:"▼"};return l`
82 - <th class=${y} scope="col" aria-sort=${_}>
81 + `;if(!Rs(g,d))return c`<th class=${y} scope="col">${g.label}</th>`;const v=h(g),M={ascending:"▲",descending:"▼"};return c`
82 + <th class=${y} scope="col" aria-sort=${v}>
83 83 <button
84 84 type="button"
85 - class="os-mywp__sort ${_!=="none"?"is-active":""}"
86 - @click=${()=>m($)}
85 + class="os-mywp__sort ${v!=="none"?"is-active":""}"
86 + @click=${()=>m(g)}
87 87 >
88 - <span>${$.label}</span>
89 - <span class="os-mywp__sort-arrow" aria-hidden="true">${A[_]??""}</span>
88 + <span>${g.label}</span>
89 + <span class="os-mywp__sort-arrow" aria-hidden="true">${M[v]??""}</span>
90 90 </button>
91 91 </th>
92 - `},v=$=>{$.preventDefault(),n.menu={x:$.clientX,y:$.clientY,item:null},e.repaint()},g=Me(($,y)=>{n.menu={x:$,y,item:null},e.repaint()},$=>!$.target?.closest("[data-item-id]"));return l`
92 + `},_=g=>{g.preventDefault(),n.menu={x:g.clientX,y:g.clientY,item:null},e.repaint()},w=Re((g,y)=>{n.menu={x:g,y,item:null},e.repaint()},g=>!g.target?.closest("[data-item-id]"));return c`
93 93 <div
94 94 class="os-mywp__canvas os-mywp__table-wrap"
95 95 data-mywp-list
96 - @contextmenu=${v}
97 - @pointerdown=${g.pointerdown}
98 - @pointermove=${g.pointermove}
99 - @pointerup=${g.pointerup}
100 - @pointercancel=${g.pointercancel}
96 + @contextmenu=${_}
97 + @pointerdown=${w.pointerdown}
98 + @pointermove=${w.pointermove}
99 + @pointerup=${w.pointerup}
100 + @pointercancel=${w.pointercancel}
101 101 >
102 102 <table
103 103 class="os-mywp__table"
104 104 role="grid"
@@ -105,16 +105,16 @@
105 105 aria-multiselectable="true"
106 106 aria-label=${t.label}
107 107 >
108 108 <colgroup>
109 - ${a.map($=>l`<col style=${$.width&&$.width!=="1fr"?`width:${$.width}`:""} />`)}
109 + ${a.map(g=>c`<col style=${g.width&&g.width!=="1fr"?`width:${g.width}`:""} />`)}
110 110 </colgroup>
111 111 <thead>
112 - <tr role="row">${a.map(w)}</tr>
112 + <tr role="row">${a.map($)}</tr>
113 113 </thead>
114 114 <tbody>
115 - ${s.map($=>ws(e,t,$,a,c))}
116 - ${Array.from({length:f},($,y)=>l`
115 + ${s.map(g=>Ws(e,t,g,a,l))}
116 + ${Array.from({length:f},(g,y)=>c`
117 117 <tr class="os-mywp__row os-mywp__row--ghost" data-ghost-index=${String(y)} aria-hidden="true">
118 118 <td colspan=${String(a.length)}><span class="os-mywp__ghost-line"></span></td>
119 119 </tr>
120 120 `)}
@@ -119,67 +119,67 @@
119 119 </tr>
120 120 `)}
121 121 </tbody>
122 122 </table>
123 - ${s.length===0&&f===0?l`<p class="os-mywp__table-empty">${e.state.query?r("Nothing matches the search."):r("Nothing here yet.")}</p>`:""}
124 - ${d?l`<div class="os-mywp__sentinel" data-mywp-sentinel></div>`:""}
123 + ${s.length===0&&f===0?c`<p class="os-mywp__table-empty">${e.state.query?r("Nothing matches the search."):r("Nothing here yet.")}</p>`:""}
124 + ${p?c`<div class="os-mywp__sentinel" data-mywp-sentinel></div>`:""}
125 125 </div>
126 - `}function vs(e,t){const s=k(e);if(!s.columnsMenu||!t)return"";const{x:n,y:i}=s.columnsMenu,o=de(t),a=ue(e,t,o),c=()=>{s.columnsMenu=null,e.repaint()},u=d=>{const f=String(d.detail?.id??"");if(f==="reset"){c(),e.dispatch("set-columns",{reset:!0});return}const m=new Set(a);m.has(f)?m.delete(f):m.add(f),e.dispatch("set-columns",{hidden:Array.from(m)})},p=o.filter(d=>!d.locked);return l`
126 + `}function qs(e,t){const s=k(e);if(!s.columnsMenu||!t)return"";const{x:n,y:o}=s.columnsMenu,i=we(t),a=ve(e,t,i),l=()=>{s.columnsMenu=null,e.repaint()},u=p=>{const f=String(p.detail?.id??"");if(f==="reset"){l(),e.dispatch("set-columns",{reset:!0});return}const m=new Set(a);m.has(f)?m.delete(f):m.add(f),e.dispatch("set-columns",{hidden:Array.from(m)})},d=i.filter(p=>!p.locked);return c`
127 127 <div
128 128 class="os-mywp__menu-backdrop"
129 - @click=${c}
130 - @contextmenu=${d=>{d.preventDefault(),c()}}
129 + @click=${l}
130 + @contextmenu=${p=>{p.preventDefault(),l()}}
131 131 ></div>
132 132 <os-context-menu
133 133 open
134 134 class="os-mywp__menu os-mywp__columns-menu"
135 - style="position:fixed;left:${n}px;top:${i}px;visibility:hidden"
135 + style="position:fixed;left:${n}px;top:${o}px;visibility:hidden"
136 136 @os-context-menu-pick=${u}
137 137 >
138 138 <os-context-menu-option heading>${r("Columns")}</os-context-menu-option>
139 - ${p.map(d=>l`
140 - <os-context-menu-option id=${d.id} ?checked=${!a.has(d.id)}>
141 - ${d.label}
139 + ${d.map(p=>c`
140 + <os-context-menu-option id=${p.id} ?checked=${!a.has(p.id)}>
141 + ${p.label}
142 142 </os-context-menu-option>
143 143 `)}
144 144 <os-context-menu-option id="reset">${r("Reset columns")}</os-context-menu-option>
145 145 </os-context-menu>
146 - `}function bs(e){const t=e.state.sort||"default",s=e.data.sortOptions?.[t];return s?b(r("Sorted by %s"),s):""}function ks(e,t){const s=de(t),n=ue(e,t,s),i=s.filter(o=>n.has(o.id)).length;return i===0?"":b(B("%d column hidden","%d columns hidden",i),i)}function Ss(e){const{data:t,state:s}=e,n=s.group,i=t.sections.filter(p=>n?p.group===n:!p.group),o=n?[]:t.groups.map(p=>({...p,count:t.sections.filter(d=>d.group===p.id).reduce((d,f)=>d+f.count,0)})),a=k(e),c=(p,d,f,m,h)=>l`
146 + `}function Bs(e){const t=e.state.sort||"default",s=e.data.sortOptions?.[t];return s?b(r("Sorted by %s"),s):""}function js(e,t){const s=we(t),n=ve(e,t,s),o=s.filter(i=>n.has(i.id)).length;return o===0?"":b(B("%d column hidden","%d columns hidden",o),o)}function Ks(e){const{data:t,state:s}=e,n=s.group,o=t.sections.filter(d=>n?d.group===n:!d.group),i=n?[]:t.groups.map(d=>({...d,count:t.sections.filter(p=>p.group===d.id).reduce((p,f)=>p+f.count,0)})),a=k(e),l=(d,p,f,m,h)=>c`
147 147 <button
148 148 type="button"
149 - class="os-mywp__tile ${a.folderSel===p?"is-selected":""}"
150 - aria-pressed=${a.folderSel===p?"true":"false"}
151 - @click=${()=>{if(ie()){a.folderSel=null,h();return}a.folderSel=p,e.repaint()}}
149 + class="os-mywp__tile ${a.folderSel===d?"is-selected":""}"
150 + aria-pressed=${a.folderSel===d?"true":"false"}
151 + @click=${()=>{if(pe()){a.folderSel=null,h();return}a.folderSel=d,e.repaint()}}
152 152 @dblclick=${()=>{a.folderSel=null,h()}}
153 - @keydown=${w=>{w.key==="Enter"&&(w.preventDefault(),a.folderSel=null,h())}}
153 + @keydown=${$=>{$.key==="Enter"&&($.preventDefault(),a.folderSel=null,h())}}
154 154 >
155 155 ${f}
156 - <span class="os-mywp__tile-label">${d} · ${m}</span>
156 + <span class="os-mywp__tile-label">${p} · ${m}</span>
157 157 </button>
158 - `,u=p=>p.kind==="agent"&&/^(https?:|data:)/.test(p.icon)?l`<img class="os-mywp__icon-img" src=${p.icon} alt="" width="48" height="48" />`:Ae(p.icon,"os-mywp__tile-icon");return l`
159 - ${n?l`<div
158 + `,u=d=>d.kind==="agent"&&/^(https?:|data:)/.test(d.icon)?c`<img class="os-mywp__icon-img" src=${d.icon} alt="" width="48" height="48" />`:Pe(d.icon,"os-mywp__tile-icon");return c`
159 + ${n?c`<div
160 160 class="os-my-wordpress__group-extras"
161 161 data-mywp-group-extras=${n}
162 162 os-preserve
163 163 ></div>`:""}
164 164 <div class="os-mywp__root" role="list">
165 - ${i.map(p=>c(`section:${p.id}`,p.label,u(p),p.count,()=>void e.dispatch("go",{group:n,section:p.id})))}
166 - ${o.map(p=>c(`group:${p.id}`,p.label,Ae(p.icon,"os-mywp__tile-icon"),p.count,()=>void e.dispatch("go",{group:p.id})))}
165 + ${o.map(d=>l(`section:${d.id}`,d.label,u(d),d.count,()=>void e.dispatch("go",{group:n,section:d.id})))}
166 + ${i.map(d=>l(`group:${d.id}`,d.label,Pe(d.icon,"os-mywp__tile-icon"),d.count,()=>void e.dispatch("go",{group:d.id})))}
167 167 </div>
168 - `}function Le(e,t,s,n){const{state:i}=e,o=i.selected.includes(s.id),a=i.item===s.id,c=Te(e,t,s,n);return l`
168 + `}function je(e,t,s,n){const{state:o}=e,i=o.selected.includes(s.id),a=o.item===s.id,l=Oe(e,t,s,n);return c`
169 169 <div
170 170 class="os-mywp__cell ${a?"is-open":""}"
171 171 data-item-id=${String(s.id)}
172 172 data-mywp-drag=${t.kind==="user"?"user":t.post_type}
173 173 role="option"
174 - aria-selected=${o?"true":"false"}
175 - @click=${c.select}
176 - @dblclick=${c.activate}
177 - @contextmenu=${c.menu}
178 - @pointerdown=${c.press.pointerdown}
179 - @pointermove=${c.press.pointermove}
180 - @pointerup=${c.press.pointerup}
181 - @pointercancel=${c.press.pointercancel}
174 + aria-selected=${i?"true":"false"}
175 + @click=${l.select}
176 + @dblclick=${l.activate}
177 + @contextmenu=${l.menu}
178 + @pointerdown=${l.press.pointerdown}
179 + @pointermove=${l.press.pointermove}
180 + @pointerup=${l.press.pointerup}
181 + @pointercancel=${l.press.pointercancel}
182 182 >
183 183 <span class="os-mywp__tilebox">
184 184 <os-tile
185 185 kind="entry"
@@ -188,19 +188,19 @@
188 188 label=${s.title}
189 189 icon=${s.thumb?"":t.icon}
190 190 thumbnail=${s.thumb}
191 191 status=${s.status&&s.status!=="publish"&&t.kind==="post"?s.status:""}
192 - ?selected=${o}
192 + ?selected=${i}
193 193 ></os-tile>
194 - ${s.lockedBy?l`<span class="os-mywp__lock" title=${b(r("%s is editing"),s.lockedBy)}>🔒</span>`:""}
194 + ${s.lockedBy?c`<span class="os-mywp__lock" title=${b(r("%s is editing"),s.lockedBy)}>🔒</span>`:""}
195 195 </span>
196 196 </div>
197 - `}function As(e,t,s){if(e.state.view==="list")return _s(e,t,s);if(s.length===0)return l`
197 + `}function zs(e,t,s){if(e.state.view==="list")return Us(e,t,s);if(s.length===0)return c`
198 198 <os-empty-state icon=${t.icon.startsWith("dashicons-")?t.icon:"dashicons-portfolio"}>
199 199 ${e.state.query?r("Nothing matches the search."):r("Nothing here yet.")}
200 200 </os-empty-state>
201 - `;const n=k(e),i=f=>{f.preventDefault(),n.menu={x:f.clientX,y:f.clientY,item:null},e.repaint()},o=Me((f,m)=>{n.menu={x:f,y:m,item:null},e.repaint()},f=>!f.target?.closest("[data-item-id]")),a=n.list.hasMore(),c=n.list.ghosts(e.data.list?.perPage??24),u=l`
202 - ${Array.from({length:c},(f,m)=>l`
201 + `;const n=k(e),o=f=>{f.preventDefault(),n.menu={x:f.clientX,y:f.clientY,item:null},e.repaint()},i=Re((f,m)=>{n.menu={x:f,y:m,item:null},e.repaint()},f=>!f.target?.closest("[data-item-id]")),a=n.list.hasMore(),l=n.list.ghosts(e.data.list?.perPage??24),u=c`
202 + ${Array.from({length:l},(f,m)=>c`
203 203 <div class="os-mywp__cell os-mywp__cell--ghost" data-ghost-index=${String(m)} aria-hidden="true">
204 204 <span class="os-mywp__ghost">
205 205 <span class="os-mywp__ghost-visual"></span>
206 206 <span class="os-mywp__ghost-label"></span>
@@ -206,52 +206,52 @@
206 206 <span class="os-mywp__ghost-label"></span>
207 207 </span>
208 208 </div>
209 209 `)}
210 - `,p=tt(T().hooks,t);if(p){const f=new Set(p.bands.map(g=>g.id)),m=new Map,h=[];for(const g of s){const $=p.assign(g);$!==null&&f.has($)?m.set($,[...m.get($)??[],g]):h.push(g)}const w=[...p.bands].sort((g,$)=>(g.order??0)-($.order??0)),v=[...w.flatMap(g=>m.get(g.id)??[]),...h].map(g=>g.id);return l`
210 + `,d=ct(T().hooks,t);if(d){const f=new Set(d.bands.map(w=>w.id)),m=new Map,h=[];for(const w of s){const g=d.assign(w);g!==null&&f.has(g)?m.set(g,[...m.get(g)??[],w]):h.push(w)}const $=[...d.bands].sort((w,g)=>(w.order??0)-(g.order??0)),_=[...$.flatMap(w=>m.get(w.id)??[]),...h].map(w=>w.id);return c`
211 211 <div
212 212 class="os-mywp__tiles os-mywp__canvas os-mywp__tiles--banded"
213 213 role="listbox"
214 214 aria-multiselectable="true"
215 - @contextmenu=${i}
216 - @pointerdown=${o.pointerdown}
217 - @pointermove=${o.pointermove}
218 - @pointerup=${o.pointerup}
219 - @pointercancel=${o.pointercancel}
215 + @contextmenu=${o}
216 + @pointerdown=${i.pointerdown}
217 + @pointermove=${i.pointermove}
218 + @pointerup=${i.pointerup}
219 + @pointercancel=${i.pointercancel}
220 220 >
221 - ${w.map(g=>{const $=m.get(g.id)??[];return $.length===0&&!((g.count??0)>0)?"":l`
222 - <section class="os-mywp__band" data-band=${g.id}>
223 - <h3 class="os-mywp__band-head ${g.tone?`os-mywp__band-head--${g.tone}`:""}">
224 - <span>${g.label}</span>
225 - <span class="os-mywp__band-count">${$.length}</span>
221 + ${$.map(w=>{const g=m.get(w.id)??[];return g.length===0&&!((w.count??0)>0)?"":c`
222 + <section class="os-mywp__band" data-band=${w.id}>
223 + <h3 class="os-mywp__band-head ${w.tone?`os-mywp__band-head--${w.tone}`:""}">
224 + <span>${w.label}</span>
225 + <span class="os-mywp__band-count">${g.length}</span>
226 226 </h3>
227 227 <div class="os-mywp__band-grid" role="presentation">
228 - ${$.map(y=>Le(e,t,y,v))}
228 + ${g.map(y=>je(e,t,y,_))}
229 229 </div>
230 230 </section>
231 231 `})}
232 - ${h.length>0?l`<div class="os-mywp__band-grid" role="presentation">
233 - ${h.map(g=>Le(e,t,g,v))}
232 + ${h.length>0?c`<div class="os-mywp__band-grid" role="presentation">
233 + ${h.map(w=>je(e,t,w,_))}
234 234 </div>`:""}
235 - ${c>0?l`<div class="os-mywp__band-grid" role="presentation">${u}</div>`:""}
236 - ${a?l`<div class="os-mywp__sentinel" data-mywp-sentinel></div>`:""}
235 + ${l>0?c`<div class="os-mywp__band-grid" role="presentation">${u}</div>`:""}
236 + ${a?c`<div class="os-mywp__sentinel" data-mywp-sentinel></div>`:""}
237 237 </div>
238 - `}const d=s.map(f=>f.id);return l`
238 + `}const p=s.map(f=>f.id);return c`
239 239 <div
240 240 class="os-mywp__tiles os-mywp__canvas"
241 241 role="listbox"
242 242 aria-multiselectable="true"
243 - @contextmenu=${i}
244 - @pointerdown=${o.pointerdown}
245 - @pointermove=${o.pointermove}
246 - @pointerup=${o.pointerup}
247 - @pointercancel=${o.pointercancel}
243 + @contextmenu=${o}
244 + @pointerdown=${i.pointerdown}
245 + @pointermove=${i.pointermove}
246 + @pointerup=${i.pointerup}
247 + @pointercancel=${i.pointercancel}
248 248 >
249 - ${s.map(f=>Le(e,t,f,d))}
249 + ${s.map(f=>je(e,t,f,p))}
250 250 ${u}
251 - ${a?l`<div class="os-mywp__sentinel" data-mywp-sentinel></div>`:""}
251 + ${a?c`<div class="os-mywp__sentinel" data-mywp-sentinel></div>`:""}
252 252 </div>
253 - `}function Ms(e,t){const s=k(e);if(!s.menu)return"";const{x:n,y:i,item:o}=s.menu,a=()=>{k(e).menu=null,e.repaint()},c=e.state.sort||"default";let u=[];o&&(u=e.state.selected.includes(o.id)&&e.state.selected.length>1?e.state.selected:[o.id]);const p=s.list.items();let d=[];if(o){const m=re(e.data.previewActions,V(t,o,"menu"),T().hooks);d=nt(t,o,m);const h=T().hooks?.applyFilters("os.my-wordpress.tile-context-menu",d,{entityId:t.id,kind:t.kind,item:o});Array.isArray(h)&&(d=st(d,h))}return l`
253 + `}function Hs(e,t){const s=k(e);if(!s.menu)return"";const{x:n,y:o,item:i}=s.menu,a=()=>{k(e).menu=null,e.repaint()},l=e.state.sort||"default";let u=[];i&&(u=e.state.selected.includes(i.id)&&e.state.selected.length>1?e.state.selected:[i.id]);const d=s.list.items();let p=[];if(i){const m=me(e.data.previewActions,ee(t,i,"menu"),T().hooks);p=pt(t,i,m);const h=T().hooks?.applyFilters("os.my-wordpress.tile-context-menu",p,{entityId:t.id,kind:t.kind,item:i});Array.isArray(h)&&(p=ut(p,h))}return c`
254 254 <div
255 255 class="os-mywp__menu-backdrop"
256 256 @click=${a}
257 257 @contextmenu=${m=>{m.preventDefault(),a()}}
@@ -258,12 +258,12 @@
258 258 ></div>
259 259 <os-context-menu
260 260 open
261 261 class="os-mywp__menu"
262 - style="position:fixed;left:${n}px;top:${i}px;visibility:hidden"
263 - @os-context-menu-pick=${m=>{const h=String(m.detail?.id??"");if(a(),h.startsWith("sort:")){e.local("set-sort",{sort:h.slice(5)}),e.dispatch("sort");return}if(h==="refresh"){e.dispatch("refresh");return}if(!o)return;const w=d.find(v=>v.id===h);if(w?.onSelect){w.onSelect();return}if(h==="open")t.kind==="post"&&!t.flat?e.dispatch("into",{item:o.id}):e.dispatch("open",{item:o.id});else if(h==="edit")t.kind==="user"?Q(o.id,{source:"my-wordpress-app/context-menu",fallback:()=>void e.dispatch("edit",{item:o.id})}):e.dispatch("edit",{item:o.id});else if(h==="quick-edit")k(e).quickEdit={ids:u,status:"",comments:"",author:"",sticky:"",categories:[],tags:[]},e.repaint();else if(h==="publish")e.dispatch("quick-edit",{items:u,status:"publish"});else if(h==="copy-link"||h==="copy-shortlink"||h==="copy-id"){const v=p.filter(g=>u.includes(g.id));h==="copy-id"?us(e,v):Ee(e,v,h==="copy-link"?"link":"shortlink")}else if(h==="trash"){const v={message:u.length>1?b(r("Move %d items to the Trash?"),u.length):r("Move this to the Trash?"),label:r("Trash"),danger:!0};u.length>1?e.dispatch("bulk-trash",{},{confirm:v}):e.dispatch("trash",{item:o.id},{confirm:v})}else{const v=re(e.data.previewActions,V(t,o,"menu"),T().hooks).find(g=>g.id===h);v&&et(v,V(t,o,"menu"))}}}
262 + style="position:fixed;left:${n}px;top:${o}px;visibility:hidden"
263 + @os-context-menu-pick=${m=>{const h=String(m.detail?.id??"");if(a(),h.startsWith("sort:")){e.local("set-sort",{sort:h.slice(5)}),e.dispatch("sort");return}if(h==="refresh"){e.dispatch("refresh");return}if(!i)return;const $=p.find(_=>_.id===h);if($?.onSelect){$.onSelect();return}if(h==="open")t.kind==="post"&&!t.flat?e.dispatch("into",{item:i.id}):O(e,i.id);else if(h==="edit")t.kind==="user"?te(i.id,{source:"my-wordpress-app/context-menu",fallback:()=>void e.dispatch("edit",{item:i.id})}):e.dispatch("edit",{item:i.id});else if(h==="quick-edit")k(e).quickEdit={ids:u,status:"",comments:"",author:"",sticky:"",categories:[],tags:[]},e.repaint();else if(h==="publish")e.dispatch("quick-edit",{items:u,status:"publish"});else if(h==="copy-link"||h==="copy-shortlink"||h==="copy-id"){const _=d.filter(w=>u.includes(w.id));h==="copy-id"?Is(e,_):We(e,_,h==="copy-link"?"link":"shortlink")}else if(h==="trash")ht(e,t,d.filter(_=>u.includes(_.id)));else{const _=me(e.data.previewActions,ee(t,i,"menu"),T().hooks).find(w=>w.id===h);_&&dt(_,ee(t,i,"menu"))}}}
264 264 >
265 - ${o?d.map(m=>m.heading?l`<os-context-menu-option heading>${m.label}</os-context-menu-option>`:l`
265 + ${i?p.map(m=>m.heading?c`<os-context-menu-option heading>${m.label}</os-context-menu-option>`:c`
266 266 <os-context-menu-option
267 267 id=${m.id}
268 268 icon=${m.icon??""}
269 269 ?danger=${!!m.danger}
@@ -268,12 +268,12 @@
268 268 icon=${m.icon??""}
269 269 ?danger=${!!m.danger}
270 270 ?disabled=${!!m.disabled}
271 271 >${m.label}</os-context-menu-option>
272 - `):l`
272 + `):c`
273 273 <os-context-menu-option heading>${r("Sort by")}</os-context-menu-option>
274 - ${Object.entries(e.data.sortOptions).map(([m,h])=>l`
275 - <os-context-menu-option id=${"sort:"+m} ?checked=${m===c}>
274 + ${Object.entries(e.data.sortOptions).map(([m,h])=>c`
275 + <os-context-menu-option id=${"sort:"+m} ?checked=${m===l}>
276 276 ${h}
277 277 </os-context-menu-option>
278 278 `)}
279 279 <os-context-menu-option id="refresh" icon="dashicons-update">${r("Refresh")}</os-context-menu-option>
@@ -278,23 +278,23 @@
278 278 `)}
279 279 <os-context-menu-option id="refresh" icon="dashicons-update">${r("Refresh")}</os-context-menu-option>
280 280 `}
281 281 </os-context-menu>
282 - `}function Ts(e,t){const s=k(e),n=s.quickEdit;if(!n||!t)return"";const i=()=>{s.quickEdit=null,e.repaint()},o=()=>{const d={items:n.ids};n.status&&(d.status=n.status),n.comments&&(d.comments=n.comments),n.author&&(d.author=Number(n.author)),n.sticky&&(d.sticky=n.sticky),n.categories.length>0&&(d.categories=n.categories),n.tags.length>0&&(d.tags=n.tags.map(f=>f.label).join(", ")),i(),e.dispatch("quick-edit",d)},a=["",r("— No change —")],c=d=>f=>{n[d]=String(f.detail?.value??"")},u=(d,f,m)=>l`
282 + `}function Xs(e,t){const s=k(e),n=s.quickEdit;if(!n||!t)return"";const o=()=>{s.quickEdit=null,e.repaint()},i=()=>{const p={items:n.ids};n.status&&(p.status=n.status),n.comments&&(p.comments=n.comments),n.author&&(p.author=Number(n.author)),n.sticky&&(p.sticky=n.sticky),n.categories.length>0&&(p.categories=n.categories),n.tags.length>0&&(p.tags=n.tags.map(f=>f.label).join(", ")),o(),e.dispatch("quick-edit",p)},a=["",r("— No change —")],l=p=>f=>{n[p]=String(f.detail?.value??"")},u=(p,f,m)=>c`
283 283 <label class="os-mywp__qe-row">
284 - <span>${d}</span>
285 - <os-select value=${n[f]} @os-pick=${c(f)}>
286 - ${m.map(([h,w])=>l`
287 - <os-option value=${h} ?selected=${h===n[f]}>${w}</os-option>
284 + <span>${p}</span>
285 + <os-select value=${n[f]} @os-pick=${l(f)}>
286 + ${m.map(([h,$])=>c`
287 + <os-option value=${h} ?selected=${h===n[f]}>${$}</os-option>
288 288 `)}
289 289 </os-select>
290 290 </label>
291 - `,p=t.post_type==="post";return l`
291 + `,d=t.post_type==="post";return c`
292 292 <os-modal
293 293 open
294 294 size="sm"
295 295 title=${b(r("Edit %1$d %2$s"),n.ids.length,t.label)}
296 - @os-modal-cancel=${i}
296 + @os-modal-cancel=${o}
297 297 >
298 298 <os-notice tone="info" class="os-mywp__qe-notice" not-dismissible>
299 299 ${r("Only the fields you change are applied. Categories and tags are added to what each entry already has.")}
300 300 </os-notice>
@@ -299,22 +299,22 @@
299 299 ${r("Only the fields you change are applied. Categories and tags are added to what each entry already has.")}
300 300 </os-notice>
301 301 <div class="os-mywp__qe">
302 302 ${u(r("Status"),"status",[a,["publish",r("Published")],["pending",r("Pending Review")],["draft",r("Draft")],["private",r("Private")]])}
303 - ${e.data.authors.length>0?u(r("Author"),"author",[a,...e.data.authors.map(d=>[String(d.id),d.name])]):""}
303 + ${e.data.authors.length>0?u(r("Author"),"author",[a,...e.data.authors.map(p=>[String(p.id),p.name])]):""}
304 304 ${u(r("Comments"),"comments",[a,["open",r("Allow")],["closed",r("Do not allow")]])}
305 - ${p?u(r("Sticky"),"sticky",[a,["sticky",r("Sticky")],["not-sticky",r("Not sticky")]]):""}
306 - ${p&&e.data.categories.length>0?l`
305 + ${d?u(r("Sticky"),"sticky",[a,["sticky",r("Sticky")],["not-sticky",r("Not sticky")]]):""}
306 + ${d&&e.data.categories.length>0?c`
307 307 <div class="os-mywp__qe-row">
308 308 <span>${r("Add categories")}</span>
309 309 <os-category-picker
310 310 .items=${e.data.categories}
311 311 .value=${n.categories}
312 - @os-categories-change=${d=>{n.categories=[...d.detail?.value??[]],e.repaint()}}
312 + @os-categories-change=${p=>{n.categories=[...p.detail?.value??[]],e.repaint()}}
313 313 ></os-category-picker>
314 314 </div>
315 315 `:""}
316 - ${p?l`
316 + ${d?c`
317 317 <div class="os-mywp__qe-row">
318 318 <span>${r("Add tags")}</span>
319 319 <os-tag-input
320 320 creatable
@@ -320,68 +320,75 @@
320 320 creatable
321 321 placeholder=${r("Add tags…")}
322 322 .value=${n.tags}
323 323 .suggestions=${[]}
324 - @os-tag-suggest=${d=>{const f=(d.detail?.query??"").toLowerCase();d.target.suggestions=e.data.tags.filter(m=>m.name.toLowerCase().includes(f)).map(m=>({id:m.id,label:m.name}))}}
325 - @os-tag-add=${d=>{const f=d.detail?.tag;f&&!n.tags.some(m=>m.label===f.label)&&(n.tags=[...n.tags,f]),e.repaint()}}
326 - @os-tag-remove=${d=>{const f=d.detail?.tag;f&&(n.tags=n.tags.filter(m=>m.label!==f.label)),e.repaint()}}
324 + @os-tag-suggest=${p=>{const f=(p.detail?.query??"").toLowerCase();p.target.suggestions=e.data.tags.filter(m=>m.name.toLowerCase().includes(f)).map(m=>({id:m.id,label:m.name}))}}
325 + @os-tag-add=${p=>{const f=p.detail?.tag;f&&!n.tags.some(m=>m.label===f.label)&&(n.tags=[...n.tags,f]),e.repaint()}}
326 + @os-tag-remove=${p=>{const f=p.detail?.tag;f&&(n.tags=n.tags.filter(m=>m.label!==f.label)),e.repaint()}}
327 327 ></os-tag-input>
328 328 </div>
329 329 `:""}
330 330 </div>
331 331 <div slot="footer">
332 - <os-button variant="ghost" @click=${i}>${r("Cancel")}</os-button>
333 - <os-button variant="primary" @click=${o}>${r("Update")}</os-button>
332 + <os-button variant="ghost" @click=${o}>${r("Cancel")}</os-button>
333 + <os-button variant="primary" @click=${i}>${r("Update")}</os-button>
334 334 </div>
335 335 </os-modal>
336 - `}function Cs(e){const t=k(e),s=e.data.detail;return!t.zoom||!s?.full?"":l`
336 + `}function Ys(e){const t=k(e),s=e.data.detail;return!t.zoom||!s?.full?"":c`
337 337 <div class="os-mywp__zoom" @click=${()=>{t.zoom=!1,e.repaint()}}>
338 338 <img src=${s.full} alt=${s.title} />
339 339 </div>
340 - `}const Es=["bio","stats","activity","milestones","recent","terms"];function Is(e,t){if(e.kind!=="user")return null;const s=T().hooks?.applyFilters("os.my-wordpress.user-dossier-sections",Es,{entityId:t.id,kind:t.kind,userId:e.id});return Array.isArray(s)?new Set(s):null}function Ns(e,t){return t?e.facts.filter(s=>!s[2]||t.has(s[2])):e.facts}function Ds(e,t,s){const n=t.kind==="user"?t.stats:null;if(!n)return"";const i=d=>!s||s.has(d),o=n.counts?.posts??{},a=n.counts?.pages??{},c=d=>b(r("%d published"),d.publish??0),u=[];n.profile?.registered&&u.push([r("Member since"),I(n.profile.registered,"month")]),n.milestones?.firstPublished&&u.push([r("First published"),I(n.milestones.firstPublished,"month")]),n.milestones?.lastPublished&&u.push([r("Last published"),I(n.milestones.lastPublished,"month")]);const p=n.topTerms??[];return l`
341 - ${i("stats")?l`<div class="os-mywp__stats">
342 - ${U(o.total??0,r("Posts"),c(o))}
343 - ${U(a.total??0,r("Pages"))}
344 - ${U(n.counts?.commentsReceived??0,r("Comments received"))}
345 - ${U(n.counts?.commentsLeft??0,r("Comments left"))}
340 + `}const Gs=["bio","stats","activity","milestones","recent","terms"];function Vs(e,t){if(e.kind!=="user")return null;const s=T().hooks?.applyFilters("os.my-wordpress.user-dossier-sections",Gs,{entityId:t.id,kind:t.kind,userId:e.id});return Array.isArray(s)?new Set(s):null}function Qs(e,t){return t?e.facts.filter(s=>!s[2]||t.has(s[2])):e.facts}function Js(e,t,s){const n=t.kind==="user"?t.stats:null;if(!n)return"";const o=p=>!s||s.has(p),i=n.counts?.posts??{},a=n.counts?.pages??{},l=p=>b(r("%d published"),p.publish??0),u=[];n.profile?.registered&&u.push([r("Member since"),I(n.profile.registered,"month")]),n.milestones?.firstPublished&&u.push([r("First published"),I(n.milestones.firstPublished,"month")]),n.milestones?.lastPublished&&u.push([r("Last published"),I(n.milestones.lastPublished,"month")]);const d=n.topTerms??[];return c`
341 + ${o("stats")?c`<div class="os-mywp__stats">
342 + ${j(i.total??0,r("Posts"),l(i))}
343 + ${j(a.total??0,r("Pages"))}
344 + ${j(n.counts?.commentsReceived??0,r("Comments received"))}
345 + ${j(n.counts?.commentsLeft??0,r("Comments left"))}
346 346 </div>`:""}
347 - ${i("activity")?Pe(n.activity??[]):""}
348 - ${i("milestones")&&u.length>0?me(u):""}
349 - ${i("recent")?Re(e,n.recent??[]):""}
350 - ${i("terms")&&p.length>0?l`
347 + ${o("activity")?Ke(n.activity??[]):""}
348 + ${o("milestones")&&u.length>0?ke(u):""}
349 + ${o("recent")?ze(e,n.recent??[]):""}
350 + ${o("terms")&&d.length>0?c`
351 351 <h3 class="os-mywp__pane-h">${r("Top categories & tags")}</h3>
352 352 <div class="os-mywp__chips">
353 - ${p.map(d=>l`<span class="os-mywp__chip os-mywp__chip--static">${d.name} · ${d.count}</span>`)}
353 + ${d.map(p=>c`<span class="os-mywp__chip os-mywp__chip--static">${p.name} · ${p.count}</span>`)}
354 354 </div>
355 355 `:""}
356 - `}function Ls(e,t,s,n){const i=[{id:"footprint",label:r("View activity footprint"),title:r("Open the full activity footprint surface for this user."),variant:"primary",onSelect:()=>void e.dispatch("footprint",{user:s.id,name:s.title})}];s.canEdit&&i.push({id:"open-profile",label:r("Edit profile"),variant:"secondary",onSelect:()=>Q(s.id,{source:"my-wordpress-app/user-pane",fallback:()=>void e.dispatch("edit",{item:s.id})})});const o=T().hooks?.applyFilters("os.my-wordpress.user-preview-actions",i,{entityId:t.id,kind:t.kind,item:{...n??{},...s}});return(Array.isArray(o)?o:i).filter(c=>!!c&&typeof c.onSelect=="function")}function lt(e,t){return l`
356 + `}function Zs(e,t,s,n){const o=[{id:"footprint",label:r("View activity footprint"),title:r("Open the full activity footprint surface for this user."),variant:"primary",onSelect:()=>void e.dispatch("footprint",{user:s.id,name:s.title})}];s.canEdit&&o.push({id:"open-profile",label:r("Edit profile"),variant:"secondary",onSelect:()=>te(s.id,{source:"my-wordpress-app/user-pane",fallback:()=>void e.dispatch("edit",{item:s.id})})});const i=T().hooks?.applyFilters("os.my-wordpress.user-preview-actions",o,{entityId:t.id,kind:t.kind,item:{...n??{},...s}});return(Array.isArray(i)?i:o).filter(l=>!!l&&typeof l.onSelect=="function")}function vt(e,t){return c`
357 357 <div class="os-mywp__split ${t?"":"os-mywp__split--solo"}">
358 358 <div class="os-mywp__list-pane">${e}</div>
359 - ${t?l`<aside class="os-mywp__detail-pane">${t}</aside>`:""}
359 + ${t?c`<aside class="os-mywp__detail-pane">${t}</aside>`:""}
360 360 </div>
361 - `}function fe(e,t){return l`<div
361 + `}function be(e,t){return c`<div
362 362 class="os-my-wordpress__article-slot os-my-wordpress__article-slot--${e}"
363 363 data-mywp-slot=${e}
364 364 data-mywp-extras-item=${String(t)}
365 365 os-preserve
366 - ></div>`}function ct(e,t){const{data:s}=e,n=s.detail;if(!n)return l`<os-empty-state>${r("This item no longer exists.")}</os-empty-state>`;const i=(s.list?.items??[]).find(f=>f.id===n.id),o=i?re(s.previewActions,V(t,i,"pane"),T().hooks):[],a=Is(n,t),c=Ns(n,a),u=n.kind==="user"?n.stats?.profile?.roleLabels?.[0]??"":"",p=n.kind==="user"?n.stats?.profile?.link??"":"";let d="";return n.kind==="user"?d=Ls(e,t,n,i??null).map(f=>l`
366 + ></div>`}function _t(e,t){const{data:s}=e,n=mt(e);if(!n){const f=k(e).list.items().find(m=>m.id===e.state.item);return c`<article class="os-mywp__detail" aria-busy=${k(e).previewLoading?"true":"false"}>
367 + <os-button variant="ghost" class="os-mywp__pane-close" aria-label=${r("Close details")} @click=${()=>O(e,0)}>✕</os-button>
368 + ${f?.thumb?c`<img class="os-mywp__hero" src=${f.thumb} alt=${f.title}/>`:""}
369 + <h2 class="os-mywp__detail-title">${f?.title??""}</h2>
370 + <p>${f?.subtitle??""}</p>
371 + <p>${f?.excerpt??""}</p>
372 + <p role="status">${Ss(e)}</p>
373 + </article>`}const o=k(e).list.items().find(f=>f.id===n.id)??(s.list?.items??[]).find(f=>f.id===n.id),i=o?me(s.previewActions,ee(t,o,"pane"),T().hooks):[],a=Vs(n,t),l=Qs(n,a),u=n.kind==="user"?n.stats?.profile?.roleLabels?.[0]??"":"",d=n.kind==="user"?n.stats?.profile?.link??"":"";let p="";return n.kind==="user"?p=Zs(e,t,n,o??null).map(f=>c`
367 374 <os-button
368 375 variant=${f.variant??"secondary"}
369 376 title=${f.title??""}
370 377 @click=${()=>f.onSelect()}
371 378 >${f.label}</os-button>
372 - `):n.canEdit&&(d=l`<os-button variant="primary" @click=${()=>void e.dispatch("edit",{item:n.id})}>
379 + `):n.canEdit&&(p=c`<os-button variant="primary" @click=${()=>void e.dispatch("edit",{item:n.id})}>
373 380 ${r("Open in editor")}
374 - </os-button>`),l`
381 + </os-button>`),c`
375 382 <article class="os-mywp__detail">
376 383 <os-button
377 384 variant="ghost"
378 385 class="os-mywp__pane-close"
379 386 aria-label=${r("Close details")}
380 - @click=${()=>void e.dispatch("open",{item:0})}
387 + @click=${()=>O(e,0)}
381 388 >✕</os-button>
382 - ${n.avatar?l`<os-avatar src=${n.avatar} name=${n.title} size="xl"></os-avatar>`:""}
383 - ${n.image?l`<img
389 + ${n.avatar?c`<os-avatar src=${n.avatar} name=${n.title} size="xl"></os-avatar>`:""}
390 + ${n.image?c`<img
384 391 class="os-mywp__hero ${n.kind==="media"?"is-zoomable":""}"
385 392 src=${n.image}
386 393 alt=${n.title}
387 394 @click=${()=>{n.kind==="media"&&(k(e).zoom=!0,e.repaint())}}
@@ -386,50 +393,46 @@
386 393 alt=${n.title}
387 394 @click=${()=>{n.kind==="media"&&(k(e).zoom=!0,e.repaint())}}
388 395 />`:""}
389 396 <h2 class="os-mywp__detail-title">${n.title}</h2>
390 - ${u||p?l`<p class="os-mywp__user-meta">
391 - ${u?l`<os-badge no-dot>${u.toUpperCase()}</os-badge>`:""}
392 - ${p?l`<a class="os-mywp__crumb-link" href=${p} target="_blank" rel="noreferrer">${r("Author archive")}</a>`:""}
397 + ${u||d?c`<p class="os-mywp__user-meta">
398 + ${u?c`<os-badge no-dot>${u.toUpperCase()}</os-badge>`:""}
399 + ${d?c`<a class="os-mywp__crumb-link" href=${d} target="_blank" rel="noreferrer">${r("Author archive")}</a>`:""}
393 400 </p>`:""}
394 - ${fe("header",n.id)}
395 - ${n.lockedBy?l`<os-notice tone="warning" not-dismissible>${b(r("%s is editing this right now."),n.lockedBy)}</os-notice>`:""}
396 - ${me(c)}
397 - ${dt(n.usedIn)}
398 - ${n.content!==void 0?l`
401 + ${be("header",n.id)}
402 + ${n.lockedBy?c`<os-notice tone="warning" not-dismissible>${b(r("%s is editing this right now."),n.lockedBy)}</os-notice>`:""}
403 + ${ke(l)}
404 + ${bt(n.usedIn)}
405 + ${n.content!==void 0?c`
399 406 <h3 class="os-mywp__pane-h">${r("Preview")}</h3>
400 407 <div class="os-mywp__content" data-mywp-content="detail" os-preserve></div>
401 408 `:""}
402 - ${fe("meta",n.id)}
403 - ${Ds(e,n,a)}
409 + ${be("meta",n.id)}
410 + ${Js(e,n,a)}
404 411 <div class="os-mywp__actions">
405 - ${n.kind==="post"&&!t.flat?l`<os-button
412 + ${n.kind==="post"&&!t.flat?c`<os-button
406 413 variant="secondary"
407 414 title=${r("See author, comments, categories, tags, attached media, and revisions for this entry.")}
408 415 @click=${()=>void e.dispatch("into",{item:n.id})}
409 416 >${r("Explore details")}</os-button>`:""}
410 - ${d}
411 - ${o.map(f=>l`
412 - <os-button variant="secondary" @click=${()=>i&&et(f,V(t,i,"pane"))}>
417 + ${p}
418 + ${i.map(f=>c`
419 + <os-button variant="secondary" @click=${()=>o&&dt(f,ee(t,o,"pane"))}>
413 420 ${f.label}
414 421 </os-button>
415 422 `)}
416 - ${n.kind==="post"&&n.canDelete?l`<os-button
423 + ${n.kind==="post"&&n.canDelete?c`<os-button
417 424 variant="danger"
418 - os-action="trash"
419 - os-arg-item=${String(n.id)}
420 - os-confirm=${r("Move this to the Trash?")}
421 - os-confirm-label=${r("Trash")}
422 - os-confirm-danger
425 + @click=${()=>o&&void ht(e,t,[o])}
423 426 >${r("Trash")}</os-button>`:""}
424 427 </div>
425 - ${fe("footer",n.id)}
428 + ${be("footer",n.id)}
426 429 </article>
427 - `}function Ps(e){const t=e.data.folder;return t?l`
430 + `}function xs(e){const t=e.data.folder;return t?c`
428 431 <div class="os-mywp__split">
429 432 <div class="os-mywp__list-pane">
430 433 <div class="os-mywp__tiles" role="list">
431 - ${t.folders.map(s=>l`
434 + ${t.folders.map(s=>c`
432 435 <div class="os-mywp__cell ${s.disabled?"is-disabled":""}" role="listitem">
433 436 <span class="os-mywp__tilebox">
434 437 <os-tile
435 438 kind="folder"
@@ -437,9 +440,9 @@
437 440 ref=${s.relation}
438 441 label=${`${s.label} · ${s.count}`}
439 442 icon=${s.icon}
440 443 ?selected=${k(e).folderSel===`relation:${s.relation}`}
441 - @click=${()=>{if(ie()){s.disabled||(k(e).folderSel=null,e.dispatch("relation",{relation:s.relation}));return}k(e).folderSel=`relation:${s.relation}`,e.repaint()}}
444 + @click=${()=>{if(pe()){s.disabled||(k(e).folderSel=null,e.dispatch("relation",{relation:s.relation}));return}k(e).folderSel=`relation:${s.relation}`,e.repaint()}}
442 445 @dblclick=${()=>{s.disabled||(k(e).folderSel=null,e.dispatch("relation",{relation:s.relation}))}}
443 446 ></os-tile>
444 447 </span>
445 448 </div>
@@ -449,26 +452,26 @@
449 452 <aside class="os-mywp__detail-pane">
450 453 <article class="os-mywp__detail">
451 454 <h2 class="os-mywp__detail-title">${t.title}</h2>
452 455 <div class="os-mywp__content" data-mywp-content="folder" os-preserve></div>
453 - ${fe("meta",t.id)}
456 + ${be("meta",t.id)}
454 457 </article>
455 458 </aside>
456 459 </div>
457 - `:l`<os-empty-state>${r("This item no longer exists.")}</os-empty-state>`}function U(e,t,s=""){return l`<os-stat value=${String(e)} label=${t} caption=${s}></os-stat>`}function Pe(e){const t=new Map(e.map(o=>[o.ym,o.count])),s=[],n=new Date;n.setDate(1),n.setMonth(n.getMonth()-11);for(let o=0;o<12;o++){const a=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}`;s.push({ym:a,label:n.toLocaleDateString(void 0,{month:"short"}),count:t.get(a)??0}),n.setMonth(n.getMonth()+1)}const i=Math.max(1,...s.map(o=>o.count));return l`
460 + `:c`<os-empty-state>${r("This item no longer exists.")}</os-empty-state>`}function j(e,t,s=""){return c`<os-stat value=${String(e)} label=${t} caption=${s}></os-stat>`}function Ke(e){const t=new Map(e.map(i=>[i.ym,i.count])),s=[],n=new Date;n.setDate(1),n.setMonth(n.getMonth()-11);for(let i=0;i<12;i++){const a=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}`;s.push({ym:a,label:n.toLocaleDateString(void 0,{month:"short"}),count:t.get(a)??0}),n.setMonth(n.getMonth()+1)}const o=Math.max(1,...s.map(i=>i.count));return c`
458 461 <h3 class="os-mywp__pane-h">${r("Activity (last 12 months)")}</h3>
459 462 <div class="os-mywp__activity" role="img" aria-label=${r("Posts per month")}>
460 - ${s.map(o=>l`
461 - <div class="os-mywp__activity-col" title="${o.label} · ${o.count}">
462 - <span class="os-mywp__activity-bar" style="block-size:${Math.round(o.count/i*100)}%"></span>
463 - <span class="os-mywp__activity-label">${o.label}</span>
463 + ${s.map(i=>c`
464 + <div class="os-mywp__activity-col" title="${i.label} · ${i.count}">
465 + <span class="os-mywp__activity-bar" style="block-size:${Math.round(i.count/o*100)}%"></span>
466 + <span class="os-mywp__activity-label">${i.label}</span>
464 467 </div>
465 468 `)}
466 469 </div>
467 - `}function Re(e,t){return t.length===0?"":l`
470 + `}function ze(e,t){return t.length===0?"":c`
468 471 <h3 class="os-mywp__pane-h">${r("Recent posts")}</h3>
469 472 <div class="os-mywp__recent">
470 - ${t.slice(0,6).map(s=>l`
473 + ${t.slice(0,6).map(s=>c`
471 474 <button
472 475 type="button"
473 476 class="os-mywp__recent-row"
474 477 @click=${()=>void e.dispatch("sub-open-post",{post:s.id})}
@@ -477,26 +480,26 @@
477 480 <span class="os-mywp__subtitle">${new Date(s.date).toLocaleString()}${s.status?` · ${s.status}`:""}</span>
478 481 </button>
479 482 `)}
480 483 </div>
481 - `}function me(e){return l`
482 - <dl class="os-mywp__facts">
483 - ${e.map(([t,s])=>l`
484 - <div class="os-mywp__fact"><dt>${t}</dt><dd>${s}</dd></div>
484 + `}function ke(e){return c`
485 + <os-facts>
486 + ${e.map(([t,s])=>c`
487 + <os-fact label=${t}>${s}</os-fact>
485 488 `)}
486 - </dl>
487 - `}function dt(e){return e?l`
489 + </os-facts>
490 + `}function bt(e){return e?c`
488 491 <h3 class="os-mywp__pane-h">${r("Used in")}</h3>
489 - ${e.length>0?l`<ul class="os-mywp__used-in">
490 - ${e.map(t=>l`<li>${t.title} <span class="os-mywp__subtitle">${t.usedAs}</span></li>`)}
491 - </ul>`:l`<p class="os-mywp__subtitle">${r("Not used anywhere yet.")}</p>`}
492 - `:""}function ut(e){return l`
493 - ${e.avatar?l`<os-avatar src=${e.avatar} name=${e.title} size="xl"></os-avatar>`:""}
494 - ${e.image?l`<img class="os-mywp__hero" src=${e.image} alt=${e.title} />`:""}
492 + ${e.length>0?c`<ul class="os-mywp__used-in">
493 + ${e.map(t=>c`<li>${t.title} <span class="os-mywp__subtitle">${t.usedAs}</span></li>`)}
494 + </ul>`:c`<p class="os-mywp__subtitle">${r("Not used anywhere yet.")}</p>`}
495 + `:""}function kt(e){return c`
496 + ${e.avatar?c`<os-avatar src=${e.avatar} name=${e.title} size="xl"></os-avatar>`:""}
497 + ${e.image?c`<img class="os-mywp__hero" src=${e.image} alt=${e.title} />`:""}
495 498 <h2 class="os-mywp__detail-title">${e.title}</h2>
496 - ${me(e.facts)}
497 - ${dt(e.usedIn)}
498 - `}function Rs(e){const t=e.data.subDetail;if(!t)return null;if(t.kind==="term"){const s=t.stats,n=s.counts?.posts??{},i=n.publish??0;return l`
499 + ${ke(e.facts)}
500 + ${bt(e.usedIn)}
501 + `}function en(e){const t=e.data.subDetail;if(!t)return null;if(t.kind==="term"){const s=t.stats,n=s.counts?.posts??{},o=n.publish??0;return c`
499 502 <article class="os-mywp__detail">
500 503 <header class="os-mywp__term-head">
501 504 <span class="os-mywp__term-swatch" aria-hidden="true"></span>
502 505 <div>
@@ -501,60 +504,60 @@
501 504 <span class="os-mywp__term-swatch" aria-hidden="true"></span>
502 505 <div>
503 506 <h2 class="os-mywp__detail-title">${s.profile?.name??""}</h2>
504 507 <os-badge no-dot>${(s.profile?.taxonomyLabel??"").toUpperCase()}</os-badge>
505 - ${s.profile?.link?l`<a class="os-mywp__crumb-link" href=${s.profile.link} target="_blank" rel="noreferrer">${r("View archive")}</a>`:""}
508 + ${s.profile?.link?c`<a class="os-mywp__crumb-link" href=${s.profile.link} target="_blank" rel="noreferrer">${r("View archive")}</a>`:""}
506 509 </div>
507 510 </header>
508 511 <div class="os-mywp__stats">
509 - ${U(n.total??0,r("Posts"),b(r("%d published"),i))}
510 - ${U(s.counts?.commentsReceived??0,r("Comments"))}
511 - ${U(s.counts?.distinctAuthors??0,r("Authors"))}
512 + ${j(n.total??0,r("Posts"),b(r("%d published"),o))}
513 + ${j(s.counts?.commentsReceived??0,r("Comments"))}
514 + ${j(s.counts?.distinctAuthors??0,r("Authors"))}
512 515 </div>
513 - ${Pe(s.activity??[])}
514 - ${me([...s.milestones?.firstPosted?[[r("First post"),I(s.milestones.firstPosted,"month")]]:[],...s.milestones?.lastPosted?[[r("Last post"),I(s.milestones.lastPosted,"month")]]:[]])}
515 - ${(s.topAuthors??[]).length>0?l`
516 + ${Ke(s.activity??[])}
517 + ${ke([...s.milestones?.firstPosted?[[r("First post"),I(s.milestones.firstPosted,"month")]]:[],...s.milestones?.lastPosted?[[r("Last post"),I(s.milestones.lastPosted,"month")]]:[]])}
518 + ${(s.topAuthors??[]).length>0?c`
516 519 <h3 class="os-mywp__pane-h">${r("Top contributors")}</h3>
517 520 <div class="os-mywp__people">
518 - ${(s.topAuthors??[]).map(o=>l`
521 + ${(s.topAuthors??[]).map(i=>c`
519 522 <div class="os-mywp__person">
520 - <os-avatar src=${o.userAvatarUrl} name=${o.userName} size="sm"></os-avatar>
521 - <span class="os-mywp__person-name">${o.userName}</span>
522 - <span class="os-mywp__subtitle">${b(B("%d post","%d posts",o.count),o.count)}</span>
523 + <os-avatar src=${i.userAvatarUrl} name=${i.userName} size="sm"></os-avatar>
524 + <span class="os-mywp__person-name">${i.userName}</span>
525 + <span class="os-mywp__subtitle">${b(B("%d post","%d posts",i.count),i.count)}</span>
523 526 </div>
524 527 `)}
525 528 </div>
526 529 `:""}
527 - ${(s.coTerms??[]).length>0?l`
530 + ${(s.coTerms??[]).length>0?c`
528 531 <h3 class="os-mywp__pane-h">${r("Often paired with")}</h3>
529 532 <div class="os-mywp__chips">
530 - ${(s.coTerms??[]).map(o=>l`
533 + ${(s.coTerms??[]).map(i=>c`
531 534 <button
532 535 type="button"
533 536 class="os-mywp__chip"
534 - @click=${()=>void e.dispatch("open",{item:o.id})}
535 - >${o.name} · ${o.count}</button>
537 + @click=${()=>void e.dispatch("open",{item:i.id})}
538 + >${i.name} · ${i.count}</button>
536 539 `)}
537 540 </div>
538 541 `:""}
539 - ${Re(e,s.recent??[])}
542 + ${ze(e,s.recent??[])}
540 543 </article>
541 - `}if(t.kind==="user")return l`
544 + `}if(t.kind==="user")return c`
542 545 <article class="os-mywp__detail">
543 - ${ut(t.detail)}
544 - ${Pe(t.stats?.activity??[])}
545 - ${Re(e,t.stats?.recent??[])}
546 + ${kt(t.detail)}
547 + ${Ke(t.stats?.activity??[])}
548 + ${ze(e,t.stats?.recent??[])}
546 549 </article>
547 - `;if(t.kind==="comment"){const s=t.stats;return l`
550 + `;if(t.kind==="comment"){const s=t.stats;return c`
548 551 <article class="os-mywp__detail">
549 552 <h2 class="os-mywp__detail-title">${s.author?.name??r("Comment")}</h2>
550 - ${s.comment?.date?l`<p class="os-mywp__subtitle">${new Date(String(s.comment.date)).toLocaleString()}${s.comment?.status?` · ${s.comment.status}`:""}</p>`:""}
553 + ${s.comment?.date?c`<p class="os-mywp__subtitle">${new Date(String(s.comment.date)).toLocaleString()}${s.comment?.status?` · ${s.comment.status}`:""}</p>`:""}
551 554 <div class="os-mywp__content" data-mywp-content="sub" os-preserve></div>
552 - ${s.post?.id?l`<os-button variant="secondary" @click=${()=>void e.dispatch("sub-open-post",{post:s.post?.id})}>
555 + ${s.post?.id?c`<os-button variant="secondary" @click=${()=>void e.dispatch("sub-open-post",{post:s.post?.id})}>
553 556 ${r("Open the post")}
554 557 </os-button>`:""}
555 558 </article>
556 - `}return t.kind==="media"?l`<article class="os-mywp__detail">${ut(t.detail)}</article>`:l`
559 + `}return t.kind==="media"?c`<article class="os-mywp__detail">${kt(t.detail)}</article>`:c`
557 560 <article class="os-mywp__detail">
558 561 <h2 class="os-mywp__detail-title">${t.title}</h2>
559 562 <p class="os-mywp__subtitle">${t.author}${t.date?` · ${t.date}`:""}</p>
560 563 <h3 class="os-mywp__pane-h">${r("Preview")}</h3>
@@ -559,12 +562,12 @@
559 562 <p class="os-mywp__subtitle">${t.author}${t.date?` · ${t.date}`:""}</p>
560 563 <h3 class="os-mywp__pane-h">${r("Preview")}</h3>
561 564 <div class="os-mywp__content" data-mywp-content="sub" os-preserve></div>
562 565 </article>
563 - `}function Os(e){const t=e.data.sub;return t?lt(l`
564 - ${t.rows.length===0?l`<os-empty-state>${r("Nothing here yet.")}</os-empty-state>`:l`
566 + `}function tn(e){const t=e.data.sub;return t?vt(c`
567 + ${t.rows.length===0?c`<os-empty-state>${r("Nothing here yet.")}</os-empty-state>`:c`
565 568 <div class="os-mywp__tiles" role="list">
566 - ${t.rows.map(s=>l`
569 + ${t.rows.map(s=>c`
567 570 <div
568 571 class="os-mywp__cell ${e.state.item===s.id?"is-open":""}"
569 572 role="listitem"
570 573 title=${s.subtitle}
@@ -577,9 +580,9 @@
577 580 label=${s.title}
578 581 icon=${s.thumb?"":s.icon??"dashicons-media-default"}
579 582 thumbnail=${s.thumb??""}
580 583 ?selected=${e.state.item===s.id}
581 - @click=${()=>{if(ie()&&s.editUrl){e.dispatch("sub-open",{row:s.id});return}e.dispatch("open",{item:s.id})}}
584 + @click=${()=>{if(pe()&&s.editUrl){e.dispatch("sub-open",{row:s.id});return}e.dispatch("open",{item:s.id})}}
582 585 @dblclick=${()=>s.editUrl&&void e.dispatch("sub-open",{row:s.id})}
583 586 ></os-tile>
584 587 </span>
585 588 </div>
@@ -585,131 +588,131 @@
585 588 </div>
586 589 `)}
587 590 </div>
588 591 `}
589 - `,Rs(e)):l`<os-empty-state>${r("This item no longer exists.")}</os-empty-state>`}function Fs(e,t){const s=k(e);if(s.fp&&s.fp.userId===t)return s.fp;const n={userId:t,status:"loading",payload:null};return s.fp=n,e.fetch(`desktop-mode/v1/user-footprint/${t}`).then(async i=>{if(!i.ok)throw new Error(String(i.status));return await i.json()}).then(i=>{s.fp===n&&(n.status="ready",n.payload=i,e.repaint())}).catch(()=>{s.fp===n&&(n.status="error",e.repaint())}),n}function Ws(e){const t=Number(e.state.footprint);if(!(t>0))return null;const s=k(e).fp;if(!s||s.userId!==t||s.status==="loading")return[r("Loading footprint…"),""];if(s.status==="error"||!s.payload)return[r("Could not load footprint."),""];const n=s.payload;return[b(r("%1$d posts · %2$d comments tracked"),n.totals.posts+n.totals.pages,n.totals.comments),b(r("Window %1$s → %2$s"),I(n.range.from),I(n.range.to))]}function Bs(e){const t=e.trim().split(/\s+/).filter(s=>s.length>0);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase()}function Z(e,t,s){return l`
592 + `,en(e)):c`<os-empty-state>${r("This item no longer exists.")}</os-empty-state>`}const St="X-WP-Nonce";function sn(e,t){const s=nn();if(!s)return t;const n=on(e);if(!n||!rn(n))return t;const o=t?.headers??(typeof Request<"u"&&e instanceof Request?e.headers:void 0),i=new Headers(o??{});return i.has(St)?t:(i.set(St,s),{...t??{},headers:i})}function nn(){if(typeof window>"u")return;const t=window.openStationConfig?.restNonce;return typeof t=="string"&&t.length>0?t:void 0}function on(e){try{const t=typeof window<"u"&&window.location?window.location.href:void 0;return typeof e=="string"?new URL(e,t):e instanceof URL?e:typeof Request<"u"&&e instanceof Request?new URL(e.url,t):null}catch{return null}}function rn(e){return typeof window>"u"||!window.location||e.origin!==window.location.origin?!1:!!(e.pathname.includes("/wp-json/")||e.searchParams.has("rest_route"))}function He(e,t,s={}){const n=window.wp?.os?.fetch;if(typeof n=="function")return n(e,t,s);const o=sn(e,t);return fetch(e,o)}class Xe extends Error{constructor(t,s){super(t||s.serverMessage||`HTTP ${s.status}`),this.name="RestError",this.status=s.status,this.code=s.code,this.data=s.data,this.serverMessage=s.serverMessage??""}}function an(e){const t=typeof e=="object"&&e!==null?e:void 0;return{code:typeof t?.code=="string"?t.code:void 0,data:t?.data,serverMessage:typeof t?.message=="string"?t.message:""}}function se(e,t,s=""){return new Xe(s,{status:e,...an(t)})}async function ln(e,t=""){let s=null;try{s=await e.json()}catch{s=null}return se(e.status,s,t)}function dn(e,t){const s=k(e);if(s.fp&&s.fp.userId===t)return s.fp;const n={userId:t,status:"loading",payload:null};return s.fp=n,e.fetch(`desktop-mode/v1/user-footprint/${t}`).then(async o=>{if(!o.ok)throw await ln(o);return await o.json()}).then(o=>{s.fp===n&&(n.status="ready",n.payload=o,e.repaint())}).catch(()=>{s.fp===n&&(n.status="error",e.repaint())}),n}function cn(e){const t=Number(e.state.footprint);if(!(t>0))return null;const s=k(e).fp;if(!s||s.userId!==t||s.status==="loading")return[r("Loading footprint…"),""];if(s.status==="error"||!s.payload)return[r("Could not load footprint."),""];const n=s.payload;return[b(r("%1$d posts · %2$d comments tracked"),n.totals.posts+n.totals.pages,n.totals.comments),b(r("Window %1$s → %2$s"),I(n.range.from),I(n.range.to))]}function un(e){const t=e.trim().split(/\s+/).filter(s=>s.length>0);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase()}function ne(e,t,s){return c`
590 593 <div class="os-my-wordpress__user-stat">
591 594 <span class="os-my-wordpress__user-stat-value">${e}</span>
592 595 <span class="os-my-wordpress__user-stat-label">${t}</span>
593 - ${s?l`<span class="os-my-wordpress__user-stat-caption">${s}</span>`:""}
596 + ${s?c`<span class="os-my-wordpress__user-stat-caption">${s}</span>`:""}
594 597 </div>
595 - `}function Us(e){const t=e.profile.roleLabels??[];return l`
598 + `}function pn(e){const t=e.profile.roleLabels??[];return c`
596 599 <header class="os-my-wordpress__footprint-hero">
597 600 <div class="os-my-wordpress__footprint-avatar">
598 - ${e.profile.avatarUrl?l`<img src=${e.profile.avatarUrl} alt="" />`:l`<span class="os-my-wordpress__user-tile-initials">${Bs(e.profile.name)}</span>`}
601 + ${e.profile.avatarUrl?c`<img src=${e.profile.avatarUrl} alt="" />`:c`<span class="os-my-wordpress__user-tile-initials">${un(e.profile.name)}</span>`}
599 602 </div>
600 603 <div class="os-my-wordpress__footprint-headline">
601 604 <h1 class="os-my-wordpress__footprint-title">${e.profile.name}</h1>
602 605 <div class="os-my-wordpress__footprint-meta">
603 - ${t.map(s=>l`<span class="os-my-wordpress__user-role">${s}</span>`)}
604 - ${e.profile.registered?l`<span class="os-my-wordpress__user-role os-my-wordpress__footprint-since">${b(r("Member since %s"),I(e.profile.registered,"month"))}</span>`:""}
606 + ${t.map(s=>c`<span class="os-my-wordpress__user-role">${s}</span>`)}
607 + ${e.profile.registered?c`<span class="os-my-wordpress__user-role os-my-wordpress__footprint-since">${b(r("Member since %s"),I(e.profile.registered,"month"))}</span>`:""}
605 608 </div>
606 - ${e.profile.link?l`<div class="os-my-wordpress__user-links">
609 + ${e.profile.link?c`<div class="os-my-wordpress__user-links">
607 610 <a href=${e.profile.link} target="_blank" rel="noopener noreferrer">${r("Author archive")}</a>
608 611 </div>`:""}
609 612 </div>
610 613 </header>
611 - `}function qs(e){const t=e.totals.posts+e.totals.pages,s=e.totals.updates??0,n=e.streak.longestRange;return l`
614 + `}function fn(e){const t=e.totals.posts+e.totals.pages,s=e.totals.updates??0,n=e.streak.longestRange;return c`
612 615 <section class="os-my-wordpress__footprint-section os-my-wordpress__footprint-stats-row">
613 - ${Z(t.toLocaleString(),r("Total content"),e.totals.posts>0&&e.totals.pages>0?b(r("%1$d posts · %2$d pages"),e.totals.posts,e.totals.pages):"")}
614 - ${Z(e.totals.comments.toLocaleString(),r("Comments left"),"")}
615 - ${s>0?Z(s.toLocaleString(),r("Updates"),r("Saves on existing posts")):""}
616 - ${Z(b(B("%d day","%d days",e.streak.longest),e.streak.longest),r("Longest streak"),n.from&&n.to?b(r("%1$s → %2$s"),I(n.from),I(n.to)):"")}
617 - ${Z(b(B("%d day","%d days",e.streak.current),e.streak.current),r("Current streak"),e.streak.current===0?r("No activity today"):r("Including today"))}
616 + ${ne(t.toLocaleString(),r("Total content"),e.totals.posts>0&&e.totals.pages>0?b(r("%1$d posts · %2$d pages"),e.totals.posts,e.totals.pages):"")}
617 + ${ne(e.totals.comments.toLocaleString(),r("Comments left"),"")}
618 + ${s>0?ne(s.toLocaleString(),r("Updates"),r("Saves on existing posts")):""}
619 + ${ne(b(B("%d day","%d days",e.streak.longest),e.streak.longest),r("Longest streak"),n.from&&n.to?b(r("%1$s → %2$s"),I(n.from),I(n.to)):"")}
620 + ${ne(b(B("%d day","%d days",e.streak.current),e.streak.current),r("Current streak"),e.streak.current===0?r("No activity today"):r("Including today"))}
618 621 </section>
619 - `}function js(e){const t=f=>f.posts+f.comments+(f.updates??0),s=e.daily.reduce((f,m)=>{const h=t(m);return h>f?h:f},0),n=f=>{if(f<=0||s<=0)return 0;const m=f/s;return m>.75?4:m>.5?3:m>.25?2:1},i=e.daily.map(f=>new Date(f.date+"T00:00:00Z"));if(i.length===0)return l`
622 + `}function mn(e){const t=f=>f.posts+f.comments+(f.updates??0),s=e.daily.reduce((f,m)=>{const h=t(m);return h>f?h:f},0),n=f=>{if(f<=0||s<=0)return 0;const m=f/s;return m>.75?4:m>.5?3:m>.25?2:1},o=e.daily.map(f=>new Date(f.date+"T00:00:00Z"));if(o.length===0)return c`
620 623 <section class="os-my-wordpress__footprint-section os-my-wordpress__footprint-calendar-section">
621 624 <h3>${r("A year of activity")}</h3>
622 625 <p class="os-my-wordpress__article-meta">${r("No activity recorded in the last year.")}</p>
623 626 </section>
624 - `;const o=i[0].getUTCDay(),a=f=>`grid-row:${f%7+2};grid-column:${Math.floor(f/7)+2}`,c=[new Date(Date.UTC(2024,11,2)),new Date(Date.UTC(2024,11,4)),new Date(Date.UTC(2024,11,6))],u=[3,5,7],p=[];let d=-1;for(let f=0;f<e.daily.length;f+=1){const m=i[f].getUTCMonth();if(m===d)continue;d=m;const h=o+f,w=Math.floor(h/7);w===0&&h%7!==0||p.push(l`<span
627 + `;const i=o[0].getUTCDay(),a=f=>`grid-row:${f%7+2};grid-column:${Math.floor(f/7)+2}`,l=[new Date(Date.UTC(2024,11,2)),new Date(Date.UTC(2024,11,4)),new Date(Date.UTC(2024,11,6))],u=[3,5,7],d=[];let p=-1;for(let f=0;f<e.daily.length;f+=1){const m=o[f].getUTCMonth();if(m===p)continue;p=m;const h=i+f,$=Math.floor(h/7);$===0&&h%7!==0||d.push(c`<span
625 628 class="os-my-wordpress__footprint-month"
626 - style="grid-row:1;grid-column:${w+2}"
627 - >${i[f].toLocaleDateString(void 0,{month:"short"})}</span>`)}return l`
629 + style="grid-row:1;grid-column:${$+2}"
630 + >${o[f].toLocaleDateString(void 0,{month:"short"})}</span>`)}return c`
628 631 <section class="os-my-wordpress__footprint-section os-my-wordpress__footprint-calendar-section">
629 632 <h3>${r("A year of activity")}</h3>
630 633 <div class="os-my-wordpress__footprint-calendar">
631 634 <div class="os-my-wordpress__footprint-grid">
632 - ${c.map((f,m)=>l`<span
635 + ${l.map((f,m)=>c`<span
633 636 class="os-my-wordpress__footprint-weekday"
634 637 style="grid-column:1;grid-row:${u[m]+1}"
635 638 >${f.toLocaleDateString(void 0,{weekday:"short"})}</span>`)}
636 - ${p}
637 - ${Array.from({length:o},(f,m)=>l`<span
639 + ${d}
640 + ${Array.from({length:i},(f,m)=>c`<span
638 641 class="os-my-wordpress__footprint-cell os-my-wordpress__footprint-cell--pad"
639 642 aria-hidden="true"
640 643 style=${a(m)}
641 644 ></span>`)}
642 - ${e.daily.map((f,m)=>l`<span
645 + ${e.daily.map((f,m)=>c`<span
643 646 class="os-my-wordpress__footprint-cell os-my-wordpress__footprint-cell--l${n(t(f))}"
644 647 title=${b(r("%1$s — %2$d posts, %3$d comments, %4$d updates"),I(f.date,"long"),f.posts,f.comments,f.updates??0)}
645 648 data-date=${f.date}
646 - style=${a(o+m)}
649 + style=${a(i+m)}
647 650 ></span>`)}
648 651 </div>
649 652 <div class="os-my-wordpress__footprint-legend">
650 653 <span class="os-my-wordpress__footprint-legend-label">${r("Less")}</span>
651 - ${[0,1,2,3,4].map(f=>l`<span class="os-my-wordpress__footprint-cell os-my-wordpress__footprint-cell--l${f}"></span>`)}
654 + ${[0,1,2,3,4].map(f=>c`<span class="os-my-wordpress__footprint-cell os-my-wordpress__footprint-cell--l${f}"></span>`)}
652 655 <span class="os-my-wordpress__footprint-legend-label">${r("More")}</span>
653 656 </div>
654 657 </div>
655 658 </section>
656 - `}function pt(e,t,s){const n=Math.max(1,...e);return l`
659 + `}function At(e,t,s){const n=Math.max(1,...e);return c`
657 660 <div class="os-my-wordpress__footprint-bars">
658 - ${e.map((i,o)=>l`
661 + ${e.map((o,i)=>c`
659 662 <div class="os-my-wordpress__footprint-bar-col">
660 663 <div
661 - class="os-my-wordpress__footprint-bar ${i===0?"os-my-wordpress__footprint-bar--empty":""}"
662 - style="height:${Math.round(i/n*100)}%"
663 - title=${b(r("%1$s · %2$d"),s[o]??t[o]??String(o),i)}
664 + class="os-my-wordpress__footprint-bar ${o===0?"os-my-wordpress__footprint-bar--empty":""}"
665 + style="height:${Math.round(o/n*100)}%"
666 + title=${b(r("%1$s · %2$d"),s[i]??t[i]??String(i),o)}
664 667 ></div>
665 - <span class="os-my-wordpress__footprint-bar-label">${t[o]??""}</span>
668 + <span class="os-my-wordpress__footprint-bar-label">${t[i]??""}</span>
666 669 </div>
667 670 `)}
668 671 </div>
669 - `}function Ks(e){const t=[r("S"),r("M"),r("T"),r("W"),r("T"),r("F"),r("S")],s=[r("Sunday"),r("Monday"),r("Tuesday"),r("Wednesday"),r("Thursday"),r("Friday"),r("Saturday")],n=Array.from({length:24},(o,a)=>a%3===0?String(a):""),i=Array.from({length:24},(o,a)=>b(r("%d:00"),a));return l`
672 + `}function hn(e){const t=[r("S"),r("M"),r("T"),r("W"),r("T"),r("F"),r("S")],s=[r("Sunday"),r("Monday"),r("Tuesday"),r("Wednesday"),r("Thursday"),r("Friday"),r("Saturday")],n=Array.from({length:24},(i,a)=>a%3===0?String(a):""),o=Array.from({length:24},(i,a)=>b(r("%d:00"),a));return c`
670 673 <section class="os-my-wordpress__footprint-section os-my-wordpress__footprint-rhythm">
671 674 <h3>${r("Publishing rhythm")}</h3>
672 675 <div class="os-my-wordpress__footprint-rhythm-grid">
673 676 <div class="os-my-wordpress__footprint-chart">
674 677 <div class="os-my-wordpress__footprint-chart-caption">${r("By weekday")}</div>
675 - ${pt(e.weekday,t,s)}
678 + ${At(e.weekday,t,s)}
676 679 </div>
677 680 <div class="os-my-wordpress__footprint-chart">
678 681 <div class="os-my-wordpress__footprint-chart-caption">${r("By hour of day (site time)")}</div>
679 - ${pt(e.hour,n,i)}
682 + ${At(e.hour,n,o)}
680 683 </div>
681 684 </div>
682 685 </section>
683 - `}function zs(e){const t=e.totals.mostProlificMonth;return t?l`
686 + `}function gn(e){const t=e.totals.mostProlificMonth;return t?c`
684 687 <section class="os-my-wordpress__footprint-section os-my-wordpress__footprint-callout">
685 688 <span class="os-my-wordpress__footprint-callout-label">${r("Most prolific month")}</span>
686 689 <h3 class="os-my-wordpress__footprint-callout-value">${I(t.ym,"month")}</h3>
687 690 <p class="os-my-wordpress__footprint-callout-detail">${b(B("%d post published — their personal record.","%d posts published — their personal record.",t.n),t.n)}</p>
688 691 </section>
689 - `:""}function Hs(e){const t=i=>i==="comment"?"dashicons-admin-comments":i==="post-update"?"dashicons-edit":"dashicons-admin-post",s=i=>{const o=i.title||r("(no title)");return i.kind==="comment"?b(r("Commented on “%s”"),o):i.kind==="post-update"?b(r("Updated “%s”"),o):o},n=i=>{const o=[I(i.date,"long")];return i.status&&i.status!=="publish"&&i.status!=="approved"&&o.push(i.status),o.join(" · ")};return l`
692 + `:""}function yn(e){const t=o=>o==="comment"?"dashicons-admin-comments":o==="post-update"?"dashicons-edit":"dashicons-admin-post",s=o=>{const i=o.title||r("(no title)");return o.kind==="comment"?b(r("Commented on “%s”"),i):o.kind==="post-update"?b(r("Updated “%s”"),i):i},n=o=>{const i=[I(o.date,"long")];return o.status&&o.status!=="publish"&&o.status!=="approved"&&i.push(o.status),i.join(" · ")};return c`
690 693 <section class="os-my-wordpress__footprint-section os-my-wordpress__footprint-timeline-section">
691 694 <h3>${r("Recent activity")}</h3>
692 - ${e.timeline.length===0?l`<p class="os-my-wordpress__article-meta">${r("Nothing to show yet.")}</p>`:l`<ul class="os-my-wordpress__footprint-timeline">
693 - ${e.timeline.map(i=>l`
694 - <li class="os-my-wordpress__footprint-event os-my-wordpress__footprint-event--${i.kind}">
695 + ${e.timeline.length===0?c`<p class="os-my-wordpress__article-meta">${r("Nothing to show yet.")}</p>`:c`<ul class="os-my-wordpress__footprint-timeline">
696 + ${e.timeline.map(o=>c`
697 + <li class="os-my-wordpress__footprint-event os-my-wordpress__footprint-event--${o.kind}">
695 698 <span class="os-my-wordpress__footprint-dot">
696 - <span class="dashicons ${t(i.kind)}" aria-hidden="true"></span>
699 + <span class="dashicons ${t(o.kind)}" aria-hidden="true"></span>
697 700 </span>
698 701 <div class="os-my-wordpress__footprint-event-body">
699 - ${i.link?l`<a
702 + ${o.link?c`<a
700 703 class="os-my-wordpress__footprint-event-title"
701 - href=${i.link}
704 + href=${o.link}
702 705 target="_blank"
703 706 rel="noopener noreferrer"
704 - >${s(i)}</a>`:l`<span class="os-my-wordpress__footprint-event-title">${s(i)}</span>`}
705 - <span class="os-my-wordpress__footprint-event-meta">${n(i)}</span>
707 + >${s(o)}</a>`:c`<span class="os-my-wordpress__footprint-event-title">${s(o)}</span>`}
708 + <span class="os-my-wordpress__footprint-event-meta">${n(o)}</span>
706 709 </div>
707 710 </li>
708 711 `)}
709 712 </ul>`}
710 713 </section>
711 - `}function Xs(e,t,s){return l`
714 + `}function $n(e,t,s){return c`
712 715 <footer class="os-my-wordpress__footprint-section os-my-wordpress__footprint-footer">
713 716 <os-button
714 717 variant="ghost"
715 718 ?disabled=${!t.profile.link}
@@ -716,63 +719,63 @@
716 719 @click=${()=>{t.profile.link&&window.open(t.profile.link,"_blank","noopener,noreferrer")}}
717 720 >${r("View author archive")}</os-button>
718 721 <os-button
719 722 variant="primary"
720 - @click=${()=>Q(s,{source:"my-wordpress-app/footprint",fallback:()=>void e.dispatch("edit",{item:s})})}
723 + @click=${()=>te(s,{source:"my-wordpress-app/footprint",fallback:()=>void e.dispatch("edit",{item:s})})}
721 724 >${r("Show profile")}</os-button>
722 725 </footer>
723 - `}function Ys(e){const t=Number(e.state.footprint),s=Fs(e,t);if(s.status==="loading")return l`
726 + `}function wn(e){const t=Number(e.state.footprint),s=dn(e,t);if(s.status==="loading")return c`
724 727 <div class="os-my-wordpress__footprint">
725 728 <div class="os-my-wordpress__preview-loading"><os-spinner></os-spinner></div>
726 729 </div>
727 - `;if(s.status==="error"||!s.payload)return l`
730 + `;if(s.status==="error"||!s.payload)return c`
728 731 <div class="os-my-wordpress__footprint">
729 732 <os-empty-state>${r("Could not load footprint.")}</os-empty-state>
730 733 </div>
731 - `;const n=s.payload;return l`
734 + `;const n=s.payload;return c`
732 735 <div class="os-my-wordpress__footprint">
733 - ${Us(n)}
734 - ${qs(n)}
735 - ${js(n)}
736 - ${Ks(n)}
737 - ${zs(n)}
738 - ${Hs(n)}
739 - ${Xs(e,n,t)}
736 + ${pn(n)}
737 + ${fn(n)}
738 + ${mn(n)}
739 + ${hn(n)}
740 + ${gn(n)}
741 + ${yn(n)}
742 + ${$n(e,n,t)}
740 743 </div>
741 - `}const O={appearance:{radius:56,bodyColor:789263,bodyAlpha:1,hueStart:296.5,hueSpan:-52.5,hueAngle:225,hueDrift:0,hueSpin:0,hueLoop:!0,saturation:1,lightness:.75,iridescence:0,outlineWidth:4,linerWidth:2,linerColor:16776191,glow:10,glowBlur:!0,eyeColor:16776191,eyeScale:.3},physics:{points:12,shapePreset:"blob",shapeLobes:3,shapeAmount:1,shapeAngle:0,shapeShuffle:60,radialStiffness:460,edgeStiffness:540,bendStiffness:170,pressure:2400,damping:9,airDamping:.5,magnetStrength:2200,magnetRange:260,magnetGrip:.24,magnetDamping:7,floatAmplitude:10,floatSpeed:1.1,idleWobble:.085,idleWobbleSpeed:.55,speedStretch:.3,friction:.86,restitution:.2,dragStiffness:480,throwBoost:1,minStretch:.55,maxStretch:1.7,minAngularGap:.25,limitIterations:3,dragMaxAccel:9e3,subStep:1/240,maxSubSteps:8}};function Gs(e,t,s){const n=(e%360+360)%360,i=Math.min(1,Math.max(0,t)),o=Math.min(1,Math.max(0,s)),a=(1-Math.abs(2*o-1))*i,c=n/60,u=a*(1-Math.abs(c%2-1));let p=0,d=0,f=0;c<1?(p=a,d=u):c<2?(p=u,d=a):c<3?(d=a,f=u):c<4?(d=u,f=a):c<5?(p=u,f=a):(p=a,f=u);const m=o-a/2,h=w=>Math.min(255,Math.max(0,Math.round((w+m)*255)));return h(p)<<16|h(d)<<8|h(f)}const Vs=Math.PI*2;function Qs(e,t,s,n,i=0){const o=Math.max(1,Math.round(e)),a=new Array(o);for(let c=0;c<o;c++){const u=c/o,p=((u-(s.hueAngle+i)/360)%1+1)%1,d=s.hueLoop?.5-.5*Math.cos(p*Vs):p;let f=s.hueStart+s.hueSpan*d+t;const m=.5+.5*Math.cos((u-1/3)*Math.PI*2);let h=s.lightness*(.72+.28*m),w=s.saturation;a[c]=Gs(f,w,h)}return a}const ft=Math.PI/2,H=Math.PI*2,Zs=.05;function X(e){return((e+ft)%H+H)%H}function Oe(e,t){return Math.pow(.5+.5*e,t)}function Js(e){const t=Math.max(0,Math.sin(e)),s=2+3.2*t,n=Math.abs(Math.cos(e)),i=Math.abs(Math.sin(e)),o=1/Math.pow(Math.pow(n,s)+Math.pow(i,s),1/s)-1,a=-.17*Math.pow(t,1.4)*Math.cos(6*e);return o+a}function xs(e){return .16*Math.cos(2*e+.9)+.095*Math.cos(3*e-2.1)+.036*Math.cos(5*e+1.3)+.019*Math.cos(7*e-.4)}function en(e){return .58*(Oe(Math.cos(5*e),3)-.3125)}function tn(e){return .34*(Oe(Math.cos(6*e),2)-.375)}function sn(e){return .34*(Oe(Math.cos(4*e),2)-.375)}function nn(e){return .72*(Math.pow(Math.max(0,Math.cos(e)),8)-.1367)}function on(e){const t=Math.max(0,Math.cos(e)),s=Math.max(0,-Math.cos(e));return .34*(Math.sqrt(t)*(.5+.5*Math.cos(5*e))-.7*s*s-.0247)}function rn(e){const t=e>Math.PI?H-e:e,s=-.34*Math.pow(Math.max(0,Math.cos(e)),6),n=.3*Math.pow(Math.max(0,Math.cos(t-1)),3),i=.34*Math.pow(Math.max(0,-Math.cos(e)),8);return s+n+i+.02}function an(e,t){switch(t.shapePreset){case"circle":return 0;case"ghost":return Js(e);case"potato":return xs(e);case"star":return en(X(e));case"flower":return tn(X(e));case"diamond":return sn(X(e));case"drop":return nn(X(e));case"cloud":return on(X(e));case"heart":return rn(X(e));case"custom":{const s=Math.round(t.shapeLobes);return s<2?0:1/(1+s*s)*Math.cos(s*e)}default:return Zs*Math.cos(3*(e+ft))}}function mt(e,t){if(t.shapeAmount<=0)return 1;const s=e-t.shapeAngle*Math.PI/180;return 1+t.shapeAmount*an(s,t)}const he=72,ln=16,ht=[[1,.1],[.6,.14],[.28,.2]];function C(e){const t=Number(e.toFixed(2));return(Object.is(t,-0)?0:t).toFixed(2)}function ge(e){return"#"+(e&16777215).toString(16).padStart(6,"0")}function cn(e,t){const s=[];for(let a=0;a<he;a++){const c=a/he*H,u=t*mt(c,e.physics);s.push([u*Math.cos(c),u*Math.sin(c)])}const n=s.length,i=a=>s[(a%n+n)%n];let o=`M${C(s[0][0])} ${C(s[0][1])}`;for(let a=0;a<n;a++){const c=i(a-1),u=i(a),p=i(a+1),d=i(a+2),f=u[0]+(p[0]-c[0])/6,m=u[1]+(p[1]-c[1])/6,h=p[0]-(d[0]-u[0])/6,w=p[1]-(d[1]-u[1])/6;o+=`C${C(f)} ${C(m)},${C(h)} ${C(w)},${C(p[0])} ${C(p[1])}`}return o+"Z"}function dn(e){let t=0;for(let s=0;s<he;s++)t=Math.max(t,mt(s/he*H,e.physics));return t}function un(e={},t=96,s=""){const n={appearance:{...O.appearance,...e.appearance},physics:{...O.physics,...e.physics}},{appearance:i}=n,o=100,a=o/O.appearance.radius,c=i.outlineWidth*a,u=i.linerWidth*a,p=i.glow/10*o*.18,d=o*dn(n)+c/2+p*ht[0][0],f=C(d),m=C(d*2),h=cn(n,o),w=Qs(ln,0,i),v=String(s).replace(/[^A-Za-z0-9_-]/g,""),g=`r${v}`,$=`s${v}`,y=`c${v}`,_=w.map((F,Y)=>`<stop offset="${C(Y/(w.length-1)*100)}%" stop-color="${ge(F)}"/>`).join(""),A=ht.map(([F,Y])=>`<use href="#${$}" fill="none" stroke="url(#${g})" stroke-width="${C(c+p*F*2)}" stroke-opacity="${C(Y)}" stroke-linejoin="round"/>`).join(""),M=o*i.eyeScale,S=M*.46,N=o*.28,P=-o*.02-M/2,se=F=>`<rect x="${C(F-S/2)}" y="${C(P)}" width="${C(S)}" height="${C(M)}" rx="${C(S/2)}" fill="${ge(i.eyeColor)}"/>`,ke=u>0?`<use href="#${$}" fill="none" stroke="${ge(i.linerColor)}" stroke-width="${C(c+u*2)}" stroke-linejoin="round" clip-path="url(#${y})"/>`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="-${f} -${f} ${m} ${m}"><defs><linearGradient id="${g}" x1="0" y1="0" x2="0.85" y2="1">${_}</linearGradient><path id="${$}" d="${h}"/><clipPath id="${y}"><use href="#${$}"/></clipPath></defs>`+A+`<use href="#${$}" fill="${ge(i.bodyColor)}" fill-opacity="${C(i.bodyAlpha)}"/>`+ke+`<use href="#${$}" fill="none" stroke="url(#${g})" stroke-width="${C(c)}" stroke-linejoin="round"/>`+se(-N)+se(N)+"</svg>"}function pn(e={},t=96){const s=un(e,t);return`data:image/svg+xml;base64,${typeof btoa=="function"?btoa(s):Buffer.from(s,"utf8").toString("base64")}`}const fn=["blob","ghost","potato","star","flower","heart","diamond","drop","cloud"];function mn(e=Math.random){const t=(c,u)=>c+e()*(u-c),s=c=>e()<c,n=c=>c[Math.floor(e()*c.length)%c.length],i=(c,u)=>Math.round(c/u)*u,o=i(t(55,215),1)*(s(.5)?1:-1),a=i(t(2,7),.5);return{appearance:{hueStart:i(t(0,360),1),hueSpan:o,hueAngle:i(t(0,360),1),hueLoop:!0,hueSpin:s(.25)?i(t(-14,14),1):0,hueDrift:s(.15)?i(t(-8,8),1):0,saturation:i(t(.68,1),.01),lightness:i(t(.52,.78),.01),outlineWidth:a,linerWidth:Math.max(1,i(a/2,.5)),linerColor:O.appearance.linerColor,glow:i(t(4,16),.1),iridescence:s(.34)?i(t(.45,1.25),.05):0,bodyColor:s(.25)?hn(e):O.appearance.bodyColor,bodyAlpha:s(.2)?i(t(.78,1),.01):1,eyeColor:O.appearance.eyeColor,eyeScale:i(t(.2,.42),.01)},physics:{shapePreset:n(fn),shapeAmount:i(t(.7,1.15),.05),shapeAngle:0,idleWobble:i(t(.03,.16),.005),idleWobbleSpeed:i(t(.35,1.1),.05)}}}function hn(e){const t=()=>Math.floor(e()*42);return t()<<16|t()<<8|t()}function gn(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let s=t;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296}}const Fe=12;function $e(e){const t=mn(gn(e));return{appearance:t.appearance,physics:t.physics}}function $n(e,t=Fe){return Array.from({length:t},(s,n)=>({seed:e+n,look:$e(e+n)}))}function J(e,t){return pn(e??{},t)}function gt(e){return e?Object.keys(e.appearance??{}).length>0||Object.keys(e.physics??{}).length>0:!1}function yn(e){const t=e?.physics?.shapePreset;return typeof t=="string"&&t!==""?t:O.physics.shapePreset}const wn=["rose","amber","gold","lime","green","mint","teal","azure","blue","violet","purple","magenta"];function _n(e){const t=e?.appearance?.hueStart,n=((typeof t=="number"&&Number.isFinite(t)?t:O.appearance.hueStart)%360+360)%360;return wn[Math.floor((n+15)%360/30)]}const $t="__openStationSharedStores";function vn(){const e=window;let t=e[$t];return t||(t=new Map,e[$t]=t),t}function We(e,t){const s=vn();let n=s.get(e);n||(n={state:t(),listeners:new Set,rebuild:t},s.set(e,n));const i={get state(){return n.state},set state(o){n.state=o},getState(){return n.state},notify(){for(const o of Array.from(n.listeners))try{o(n.state)}catch(a){console.error(`[desktop-mode/shared-store:${e}] subscriber threw:`,a)}},subscribe(o){return n.listeners.add(o),()=>{n.listeners.delete(o)}},setState(o){const a=n.state;if(typeof a!="object"||a===null){console.warn(`[desktop-mode/shared-store:${e}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(a,o),i.notify()},reset(){const o=n.rebuild(),a=n.state;if(typeof a=="object"&&a!==null&&typeof o=="object"&&o!==null){const c=a;for(const u of Object.keys(c))delete c[u];Object.assign(c,o)}else n.state=o;n.listeners.clear()}};return i}const L=We("desktop-mode/agents-chat",()=>({activeAgent:null,transcripts:{},conversationIds:{},conversationsRev:0}));function Be(e){L.state.activeAgent=e,L.state.transcripts[e.id]||(L.state.transcripts[e.id]=[]),L.state.conversationIds||(L.state.conversationIds={},L.state.conversationsRev=0),L.notify()}const bn=["post","page","media","user","comment"],kn=12,Sn=4;function An(){return Math.floor(Math.random()*16777215)+1}function yt(e,t){return{brief:"",name:"",description:"",vibes:"",instructions:"",role:e,abilities:[],triggers:[{kind:"chat",config:{}}],copiedFrom:"",faceSeed:t,face:$e(t),stripSeed:t,drafting:!1}}function wt(e){return!e||e.length===0||e.some(t=>t.slug==="author")?"author":e[0].slug}function ye(e,t){return gt(e.face)&&e.avatarUrl!==""?e.avatarUrl:e.faceSeed>0?J($e(e.faceSeed),t):e.avatarUrl}function _t(e){return e.map(t=>`${t.id}:${t.triggers.map(s=>s.kind).sort().join("+")}`).join("|")}let Mn=0;const vt=new WeakMap;function bt(e){let t=vt.get(e);return t||(t=++Mn,vt.set(e,t)),t}function Tn(){T().openOsSettings?.({tabId:"features"})}function kt(e,t){Be({id:t.id,name:t.name,description:t.description,avatarUrl:t.avatarUrl}),!T().openWindow?.(e.runWindowId,{source:"agents"})&&typeof T().openWindow!="function"&&console.warn("[desktop-mode/agents] wp.os.openWindow is missing — desktop shell may not be ready.")}function Cn(e){Q(e.id,{source:"agents/profile",fallback:()=>{e.profileUrl&&T().windowManager?.open({id:`user-edit-${e.id}`,url:e.profileUrl,title:e.name,icon:"dashicons-admin-users"})}})}function En(e){const t=T();if(!t.windowManager?.open){window.open(e,"_blank","noopener,noreferrer");return}const s=typeof t.deriveWindowId=="function"?t.deriveWindowId(e):"options-connectors";t.windowManager.open({id:s,url:e,title:r("Connectors"),icon:"dashicons-admin-settings"})}async function In(e){const t=T().files;if(!t?.rest?.createPlacement)return r("The desktop files API is not available in this context.");let s=[];try{const o=t.store?.getState?.()?.placementsByFolder?.get(0);Array.isArray(o)&&(s=o)}catch{}let n=16,i=16;for(let o=0;o<200&&(n=16+o%5*96,i=16+Math.floor(o/5)*110,!!s.some(c=>Math.abs((c.x??-9999)-n)<48&&Math.abs((c.y??-9999)-i)<55));o++);try{const o=await t.rest.createPlacement({type:"user",ref:String(e.id),x:n,y:i});return t.store?.upsertPlacement?.(o),r("Agent added to the desktop.")}catch(o){return o instanceof Error?o.message:String(o)}}function St(e,t){const s=e.some(n=>n.slug===t);return l`
742 - ${e.map(n=>l`<os-option value=${n.slug}>${n.label}</os-option>`)}
743 - ${t&&!s?l`<os-option value=${t}>${t}</os-option>`:""}
744 - `}function x(e,t,s){const n=k(e);return n.agentBusy=!0,e.repaint(),e.dispatch(t,s).finally(()=>{n.agentBusy=!1,e.repaint()})}function Nn(e){if(!e.enabled||e.aiReady)return"";const t=r("No AI provider is configured — agents cannot run until a connector is set up."),s=r("This WordPress does not ship the AI Client (WordPress 7.0+). Agents can be defined but not run."),n=l`
744 + `}const W={appearance:{radius:56,bodyColor:789263,bodyAlpha:1,hueStart:296.5,hueSpan:-52.5,hueAngle:225,hueDrift:0,hueSpin:0,hueLoop:!0,saturation:1,lightness:.75,iridescence:0,outlineWidth:4,linerWidth:2,linerColor:16776191,glow:10,glowBlur:!0,eyeColor:16776191,eyeScale:.3},physics:{points:12,shapePreset:"blob",shapeLobes:3,shapeAmount:1,shapeAngle:0,shapeShuffle:60,radialStiffness:460,edgeStiffness:540,bendStiffness:170,pressure:2400,damping:9,airDamping:.5,magnetStrength:2200,magnetRange:260,magnetGrip:.24,magnetDamping:7,floatAmplitude:10,floatSpeed:1.1,idleWobble:.085,idleWobbleSpeed:.55,speedStretch:.3,friction:.86,restitution:.2,dragStiffness:480,throwBoost:1,minStretch:.55,maxStretch:1.7,minAngularGap:.25,limitIterations:3,dragMaxAccel:9e3,subStep:1/240,maxSubSteps:8}};function vn(e,t,s){const n=(e%360+360)%360,o=Math.min(1,Math.max(0,t)),i=Math.min(1,Math.max(0,s)),a=(1-Math.abs(2*i-1))*o,l=n/60,u=a*(1-Math.abs(l%2-1));let d=0,p=0,f=0;l<1?(d=a,p=u):l<2?(d=u,p=a):l<3?(p=a,f=u):l<4?(p=u,f=a):l<5?(d=u,f=a):(d=a,f=u);const m=i-a/2,h=$=>Math.min(255,Math.max(0,Math.round(($+m)*255)));return h(d)<<16|h(p)<<8|h(f)}const _n=Math.PI*2;function bn(e,t,s,n,o=0){const i=Math.max(1,Math.round(e)),a=new Array(i);for(let l=0;l<i;l++){const u=l/i,d=((u-(s.hueAngle+o)/360)%1+1)%1,p=s.hueLoop?.5-.5*Math.cos(d*_n):d;let f=s.hueStart+s.hueSpan*p+t;const m=.5+.5*Math.cos((u-1/3)*Math.PI*2);let h=s.lightness*(.72+.28*m),$=s.saturation;a[l]=vn(f,$,h)}return a}const Mt=Math.PI/2,G=Math.PI*2,kn=.05;function V(e){return((e+Mt)%G+G)%G}function Ye(e,t){return Math.pow(.5+.5*e,t)}function Sn(e){const t=Math.max(0,Math.sin(e)),s=2+3.2*t,n=Math.abs(Math.cos(e)),o=Math.abs(Math.sin(e)),i=1/Math.pow(Math.pow(n,s)+Math.pow(o,s),1/s)-1,a=-.17*Math.pow(t,1.4)*Math.cos(6*e);return i+a}function An(e){return .16*Math.cos(2*e+.9)+.095*Math.cos(3*e-2.1)+.036*Math.cos(5*e+1.3)+.019*Math.cos(7*e-.4)}function Mn(e){return .58*(Ye(Math.cos(5*e),3)-.3125)}function Tn(e){return .34*(Ye(Math.cos(6*e),2)-.375)}function Cn(e){return .34*(Ye(Math.cos(4*e),2)-.375)}function En(e){return .72*(Math.pow(Math.max(0,Math.cos(e)),8)-.1367)}function In(e){const t=Math.max(0,Math.cos(e)),s=Math.max(0,-Math.cos(e));return .34*(Math.sqrt(t)*(.5+.5*Math.cos(5*e))-.7*s*s-.0247)}function Nn(e){const t=e>Math.PI?G-e:e,s=-.34*Math.pow(Math.max(0,Math.cos(e)),6),n=.3*Math.pow(Math.max(0,Math.cos(t-1)),3),o=.34*Math.pow(Math.max(0,-Math.cos(e)),8);return s+n+o+.02}function Dn(e,t){switch(t.shapePreset){case"circle":return 0;case"ghost":return Sn(e);case"potato":return An(e);case"star":return Mn(V(e));case"flower":return Tn(V(e));case"diamond":return Cn(V(e));case"drop":return En(V(e));case"cloud":return In(V(e));case"heart":return Nn(V(e));case"custom":{const s=Math.round(t.shapeLobes);return s<2?0:1/(1+s*s)*Math.cos(s*e)}default:return kn*Math.cos(3*(e+Mt))}}function Tt(e,t){if(t.shapeAmount<=0)return 1;const s=e-t.shapeAngle*Math.PI/180;return 1+t.shapeAmount*Dn(s,t)}const Se=72,Ln=16,Ct=[[1,.1],[.6,.14],[.28,.2]];function C(e){const t=Number(e.toFixed(2));return(Object.is(t,-0)?0:t).toFixed(2)}function Ae(e){return"#"+(e&16777215).toString(16).padStart(6,"0")}function Pn(e,t){const s=[];for(let a=0;a<Se;a++){const l=a/Se*G,u=t*Tt(l,e.physics);s.push([u*Math.cos(l),u*Math.sin(l)])}const n=s.length,o=a=>s[(a%n+n)%n];let i=`M${C(s[0][0])} ${C(s[0][1])}`;for(let a=0;a<n;a++){const l=o(a-1),u=o(a),d=o(a+1),p=o(a+2),f=u[0]+(d[0]-l[0])/6,m=u[1]+(d[1]-l[1])/6,h=d[0]-(p[0]-u[0])/6,$=d[1]-(p[1]-u[1])/6;i+=`C${C(f)} ${C(m)},${C(h)} ${C($)},${C(d[0])} ${C(d[1])}`}return i+"Z"}function Rn(e){let t=0;for(let s=0;s<Se;s++)t=Math.max(t,Tt(s/Se*G,e.physics));return t}function On(e={},t=96,s=""){const n={appearance:{...W.appearance,...e.appearance},physics:{...W.physics,...e.physics}},{appearance:o}=n,i=100,a=i/W.appearance.radius,l=o.outlineWidth*a,u=o.linerWidth*a,d=o.glow/10*i*.18,p=i*Rn(n)+l/2+d*Ct[0][0],f=C(p),m=C(p*2),h=Pn(n,i),$=bn(Ln,0,o),_=String(s).replace(/[^A-Za-z0-9_-]/g,""),w=`r${_}`,g=`s${_}`,y=`c${_}`,v=$.map((U,Z)=>`<stop offset="${C(Z/($.length-1)*100)}%" stop-color="${Ae(U)}"/>`).join(""),M=Ct.map(([U,Z])=>`<use href="#${g}" fill="none" stroke="url(#${w})" stroke-width="${C(l+d*U*2)}" stroke-opacity="${C(Z)}" stroke-linejoin="round"/>`).join(""),S=i*o.eyeScale,A=S*.46,N=i*.28,R=-i*.02-S/2,J=U=>`<rect x="${C(U-A/2)}" y="${C(R)}" width="${C(A)}" height="${C(S)}" rx="${C(A/2)}" fill="${Ae(o.eyeColor)}"/>`,De=u>0?`<use href="#${g}" fill="none" stroke="${Ae(o.linerColor)}" stroke-width="${C(l+u*2)}" stroke-linejoin="round" clip-path="url(#${y})"/>`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="-${f} -${f} ${m} ${m}"><defs><linearGradient id="${w}" x1="0" y1="0" x2="0.85" y2="1">${v}</linearGradient><path id="${g}" d="${h}"/><clipPath id="${y}"><use href="#${g}"/></clipPath></defs>`+M+`<use href="#${g}" fill="${Ae(o.bodyColor)}" fill-opacity="${C(o.bodyAlpha)}"/>`+De+`<use href="#${g}" fill="none" stroke="url(#${w})" stroke-width="${C(l)}" stroke-linejoin="round"/>`+J(-N)+J(N)+"</svg>"}function Fn(e={},t=96){const s=On(e,t);return`data:image/svg+xml;base64,${typeof btoa=="function"?btoa(s):Buffer.from(s,"utf8").toString("base64")}`}const Wn=["blob","ghost","potato","star","flower","heart","diamond","drop","cloud"];function Un(e=Math.random){const t=(l,u)=>l+e()*(u-l),s=l=>e()<l,n=l=>l[Math.floor(e()*l.length)%l.length],o=(l,u)=>Math.round(l/u)*u,i=o(t(55,215),1)*(s(.5)?1:-1),a=o(t(2,7),.5);return{appearance:{hueStart:o(t(0,360),1),hueSpan:i,hueAngle:o(t(0,360),1),hueLoop:!0,hueSpin:s(.25)?o(t(-14,14),1):0,hueDrift:s(.15)?o(t(-8,8),1):0,saturation:o(t(.68,1),.01),lightness:o(t(.52,.78),.01),outlineWidth:a,linerWidth:Math.max(1,o(a/2,.5)),linerColor:W.appearance.linerColor,glow:o(t(4,16),.1),iridescence:s(.34)?o(t(.45,1.25),.05):0,bodyColor:s(.25)?qn(e):W.appearance.bodyColor,bodyAlpha:s(.2)?o(t(.78,1),.01):1,eyeColor:W.appearance.eyeColor,eyeScale:o(t(.2,.42),.01)},physics:{shapePreset:n(Wn),shapeAmount:o(t(.7,1.15),.05),shapeAngle:0,idleWobble:o(t(.03,.16),.005),idleWobbleSpeed:o(t(.35,1.1),.05)}}}function qn(e){const t=()=>Math.floor(e()*42);return t()<<16|t()<<8|t()}function Bn(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let s=t;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296}}const Ge=12;function Me(e){const t=Un(Bn(e));return{appearance:t.appearance,physics:t.physics}}function jn(e,t=Ge){return Array.from({length:t},(s,n)=>({seed:e+n,look:Me(e+n)}))}function oe(e,t){return Fn(e??{},t)}function Et(e){return e?Object.keys(e.appearance??{}).length>0||Object.keys(e.physics??{}).length>0:!1}function Kn(e){const t=e?.physics?.shapePreset;return typeof t=="string"&&t!==""?t:W.physics.shapePreset}const zn=["rose","amber","gold","lime","green","mint","teal","azure","blue","violet","purple","magenta"];function Hn(e){const t=e?.appearance?.hueStart,n=((typeof t=="number"&&Number.isFinite(t)?t:W.appearance.hueStart)%360+360)%360;return zn[Math.floor((n+15)%360/30)]}const P=ce("desktop-mode/agents-chat",()=>({activeAgent:null,transcripts:{},conversationIds:{},conversationsRev:0}));function Ve(e){P.state.activeAgent=e,P.state.transcripts[e.id]||(P.state.transcripts[e.id]=[]),P.state.conversationIds||(P.state.conversationIds={},P.state.conversationsRev=0),P.notify()}const Xn=["post","page","media","user","comment"],Yn=12,Gn=4;function Vn(){return Math.floor(Math.random()*16777215)+1}function It(e,t){return{brief:"",name:"",description:"",vibes:"",instructions:"",role:e,abilities:[],triggers:[{kind:"chat",config:{}}],copiedFrom:"",faceSeed:t,face:Me(t),stripSeed:t,drafting:!1}}function Nt(e){return!e||e.length===0||e.some(t=>t.slug==="author")?"author":e[0].slug}function Te(e,t){return Et(e.face)&&e.avatarUrl!==""?e.avatarUrl:e.faceSeed>0?oe(Me(e.faceSeed),t):e.avatarUrl}function Dt(e){return e.map(t=>`${t.id}:${t.triggers.map(s=>s.kind).sort().join("+")}`).join("|")}let Qn=0;const Lt=new WeakMap;function Pt(e){let t=Lt.get(e);return t||(t=++Qn,Lt.set(e,t)),t}function Jn(){T().openOsSettings?.({tabId:"features"})}function Rt(e,t){Ve({id:t.id,name:t.name,description:t.description,avatarUrl:t.avatarUrl}),!T().openWindow?.(e.runWindowId,{source:"agents"})&&typeof T().openWindow!="function"&&console.warn("[desktop-mode/agents] wp.os.openWindow is missing — desktop shell may not be ready.")}function Zn(e){te(e.id,{source:"agents/profile",fallback:()=>{e.profileUrl&&T().windowManager?.open({id:`user-edit-${e.id}`,url:e.profileUrl,title:e.name,icon:"dashicons-admin-users"})}})}function xn(e){const t=T();if(!t.windowManager?.open){window.open(e,"_blank","noopener,noreferrer");return}const s=typeof t.deriveWindowId=="function"?t.deriveWindowId(e):"options-connectors";t.windowManager.open({id:s,url:e,title:r("Connectors"),icon:"dashicons-admin-settings"})}async function eo(e){const t=T().files;if(!t?.rest?.createPlacement)return r("The desktop files API is not available in this context.");let s=[];try{const i=t.store?.getState?.()?.placementsByFolder?.get(0);Array.isArray(i)&&(s=i)}catch{}let n=16,o=16;for(let i=0;i<200&&(n=16+i%5*96,o=16+Math.floor(i/5)*110,!!s.some(l=>Math.abs((l.x??-9999)-n)<48&&Math.abs((l.y??-9999)-o)<55));i++);try{const i=await t.rest.createPlacement({type:"user",ref:String(e.id),x:n,y:o});return t.store?.upsertPlacement?.(i),r("Agent added to the desktop.")}catch(i){return i instanceof Error?i.message:String(i)}}function Ot(e,t){const s=e.some(n=>n.slug===t);return c`
745 + ${e.map(n=>c`<os-option value=${n.slug}>${n.label}</os-option>`)}
746 + ${t&&!s?c`<os-option value=${t}>${t}</os-option>`:""}
747 + `}function ie(e,t,s){const n=k(e);return n.agentBusy=!0,e.repaint(),e.dispatch(t,s).finally(()=>{n.agentBusy=!1,e.repaint()})}function to(e){if(!e.enabled||e.aiReady)return"";const t=r("No AI provider is configured — agents cannot run until a connector is set up."),s=r("This WordPress does not ship the AI Client (WordPress 7.0+). Agents can be defined but not run."),n=c`
745 748 <a
746 749 href=${e.connectorsUrl}
747 750 rel="noreferrer"
748 - @click=${i=>{i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||(i.preventDefault(),En(e.connectorsUrl))}}
751 + @click=${o=>{o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||(o.preventDefault(),xn(e.connectorsUrl))}}
749 752 >
750 753 ${r("Open Connectors settings")}
751 754 </a>
752 - `;return l`
755 + `;return c`
753 756 <os-notice tone="warning" class="dm-agents__ai-notice">
754 - ${e.aiAvailable?l`${t} ${n}`:s}
757 + ${e.aiAvailable?c`${t} ${n}`:s}
755 758 </os-notice>
756 - `}function At(e,t,s,n,i){return l`
759 + `}function Ft(e,t,s,n,o){return c`
757 760 <div class="dm-agents__cast-inner">
758 761 ${e}
759 762 <span class="dm-agents__cast-name">${t}</span>
760 - ${s?l`<span class="dm-agents__cast-vibes">${s}</span>`:""}
763 + ${s?c`<span class="dm-agents__cast-vibes">${s}</span>`:""}
761 764 <span class="dm-agents__cast-good">${n}</span>
762 - <os-badge>${i}</os-badge>
765 + <os-badge>${o}</os-badge>
763 766 </div>
764 - `}function Dn(e){const t=e.preview??[];return t.length===0?null:l`
767 + `}function so(e){const t=e.preview??[];return t.length===0?null:c`
765 768 <div class="dm-agents__cast-head">
766 769 <h3>${r("The crew you would get")}</h3>
767 770 <span class="dm-agents__cast-count">${t.length}</span>
768 771 </div>
769 772 <div class="dm-agents__cast dm-agents__cast--preview" role="list">
770 - ${t.map(s=>l`
773 + ${t.map(s=>c`
771 774 <os-card class="dm-agents__cast-card" role="listitem">
772 - ${At(l`<img
775 + ${Ft(c`<img
773 776 class="dm-agents__cast-face"
774 - src=${J(s.face,88)}
777 + src=${oe(s.face,88)}
775 778 alt=""
776 779 width="88"
777 780 height="88"
778 781 />`,s.name,s.vibes,s.description,s.roleLabel)}
@@ -778,41 +781,41 @@
778 781 />`,s.name,s.vibes,s.description,s.roleLabel)}
779 782 </os-card>
780 783 `)}
781 784 </div>
782 - `}function Ln(e,t){if(!t.enabled){const i=t.canEnable?r("Turn the Agents framework on in OpenStation Preferences → Features to hire this crew, or cast your own."):r("Ask an administrator to turn the Agents framework on in OpenStation Preferences → Features."),o=t.canEnable?l`
785 + `}function no(e,t){if(!t.enabled){const o=t.canEnable?r("Turn the Agents framework on in OpenStation Preferences → Features to hire this crew, or cast your own."):r("Ask an administrator to turn the Agents framework on in OpenStation Preferences → Features."),i=t.canEnable?c`
783 786 <os-button
784 787 slot="cta"
785 788 class="dm-agents__enable"
786 789 variant="primary"
787 - @click=${()=>Tn()}
790 + @click=${()=>Jn()}
788 791 >
789 792 ${r("Turn on Agents")}
790 793 </os-button>
791 - `:"",a=Dn(t);return a===null?l`
794 + `:"",a=so(t);return a===null?c`
792 795 <os-empty-state
793 796 icon="superhero"
794 797 heading=${r("Agents are turned off")}
795 - description=${i}
798 + description=${o}
796 799 >
797 - ${o}
800 + ${i}
798 801 </os-empty-state>
799 - `:l`
802 + `:c`
800 803 <div class="dm-agents__off-head">
801 804 <div class="dm-agents__off-copy">
802 805 <h3>${r("Agents are turned off")}</h3>
803 - <p>${i}</p>
806 + <p>${o}</p>
804 807 </div>
805 - ${o}
808 + ${i}
806 809 </div>
807 810 ${a}
808 - `}const s=k(e),n=i=>t.roleLabels[i]??i;if(t.list.length===0){const i=t.canManage?r("Cast your first agent: describe what it should do, give it a face and a voice, then pick the abilities it may use."):r("An administrator has not created any agents on this site yet.");return l`
811 + `}const s=k(e),n=o=>t.roleLabels[o]??o;if(t.list.length===0){const o=t.canManage?r("Cast your first agent: describe what it should do, give it a face and a voice, then pick the abilities it may use."):r("An administrator has not created any agents on this site yet.");return c`
809 812 <os-empty-state
810 813 icon="superhero"
811 814 heading=${r("No agents yet")}
812 - description=${i}
815 + description=${o}
813 816 >
814 - ${t.canManage?l`
817 + ${t.canManage?c`
815 818 <os-button
816 819 slot="cta"
817 820 class="dm-agents__create"
818 821 variant="primary"
@@ -822,33 +825,33 @@
822 825 ${r("Cast an agent")}
823 826 </os-button>
824 827 `:""}
825 828 </os-empty-state>
826 - `}return l`
829 + `}return c`
827 830 <div class="dm-agents__cast-head">
828 831 <h3>${r("Your cast")}</h3>
829 832 <span class="dm-agents__cast-count">${t.list.length}</span>
830 833 </div>
831 834 <div class="dm-agents__cast" role="list">
832 - ${t.list.map(i=>l`
835 + ${t.list.map(o=>c`
833 836 <os-card
834 837 class="dm-agents__cast-card"
835 838 role="listitem"
836 839 interactive
837 - data-agent-id=${String(i.id)}
838 - ?selected=${i.id===e.state.item}
839 - @os-card-click=${()=>void e.dispatch("open",{item:i.id})}
840 + data-agent-id=${String(o.id)}
841 + ?selected=${o.id===e.state.item}
842 + @os-card-click=${()=>void e.dispatch("open",{item:o.id})}
840 843 >
841 - ${At(l`<img
844 + ${Ft(c`<img
842 845 class="dm-agents__cast-face"
843 - src=${ye(i,88)}
846 + src=${Te(o,88)}
844 847 alt=""
845 848 width="88"
846 849 height="88"
847 - />`,i.name,i.vibes,i.description||r("No description yet."),n(i.role))}
850 + />`,o.name,o.vibes,o.description||r("No description yet."),n(o.role))}
848 851 </os-card>
849 852 `)}
850 - ${t.canManage?l`
853 + ${t.canManage?c`
851 854 <os-card
852 855 class="dm-agents__cast-new"
853 856 role="listitem"
854 857 interactive
@@ -864,139 +867,139 @@
864 867 </div>
865 868 </os-card>
866 869 `:""}
867 870 </div>
868 - `}const Pn="my-wordpress",Ue=Object.freeze({userId:null,userName:"",requestedAt:0});function Mt(){return window.wp?.os}let we=null;function _e(){if(we)return we;const e=Mt()?.createSharedStore;return typeof e!="function"?null:(we=e("desktop-mode/my-wordpress/footprint-target",()=>({...Ue})),we)}function Rn(e,t=""){const s=_e();if(s){s.state.userId=e,s.state.userName=t,s.state.requestedAt=Date.now(),s.notify();return}window._wpdFootprintTarget={userId:e,userName:t,requestedAt:Date.now()}}function On(){const e=_e();return e?{...e.state}:window._wpdFootprintTarget??{...Ue}}function Fn(){const e=_e();e&&(e.state.userId=null,e.state.userName="",e.state.requestedAt=0,e.notify());const t=window;t._wpdFootprintTarget&&(t._wpdFootprintTarget={...Ue})}function Wn(e){const t=_e();return t?t.subscribe(s=>e({...s})):()=>{}}function Bn(e){const t=Number(e.userId);!Number.isFinite(t)||t<=0||(Rn(t,e.userName??""),Mt()?.openWindow?.(Pn,{source:"my-wordpress/open-user-footprint"}))}function Tt(e,t,s,n,i={}){const o=k(e),a=t.abilities,c=o.abilityQuery.trim().toLowerCase(),u=m=>c===""||m.label.toLowerCase().includes(c)||m.description.toLowerCase().includes(c)||m.slug.toLowerCase().includes(c),p=new Map;for(const m of a.filter(u)){const h=m.category||r("Other");p.set(h,[...p.get(h)??[],m])}const d=a.length>kn,f=(m,h)=>c!==""?!0:o.abilityOpen.get(m)??(!d||h.some(w=>s.includes(w.slug)));return l`
869 - ${d||c!==""?l`
871 + `}const oo="my-wordpress",Qe=Object.freeze({userId:null,userName:"",requestedAt:0});function Wt(){return window.wp?.os}let Ce=null;function Ee(){if(Ce)return Ce;const e=Wt()?.createSharedStore;return typeof e!="function"?null:(Ce=e("desktop-mode/my-wordpress/footprint-target",()=>({...Qe})),Ce)}function io(e,t=""){const s=Ee();if(s){s.state.userId=e,s.state.userName=t,s.state.requestedAt=Date.now(),s.notify();return}window._wpdFootprintTarget={userId:e,userName:t,requestedAt:Date.now()}}function ro(){const e=Ee();return e?{...e.state}:window._wpdFootprintTarget??{...Qe}}function ao(){const e=Ee();e&&(e.state.userId=null,e.state.userName="",e.state.requestedAt=0,e.notify());const t=window;t._wpdFootprintTarget&&(t._wpdFootprintTarget={...Qe})}function lo(e){const t=Ee();return t?t.subscribe(s=>e({...s})):()=>{}}function co(e){const t=Number(e.userId);if(!Number.isFinite(t)||t<=0)return;const s=e.userName??"";io(t,s),Wt()?.openWindow?.(oo,{source:"my-wordpress/open-user-footprint",params:{footprint:t,fpName:s}})}function Ut(e,t,s,n,o={}){const i=k(e),a=t.abilities,l=i.abilityQuery.trim().toLowerCase(),u=m=>l===""||m.label.toLowerCase().includes(l)||m.description.toLowerCase().includes(l)||m.slug.toLowerCase().includes(l),d=new Map;for(const m of a.filter(u)){const h=m.category||r("Other");d.set(h,[...d.get(h)??[],m])}const p=a.length>Yn,f=(m,h)=>l!==""?!0:i.abilityOpen.get(m)??(!p||h.some($=>s.includes($.slug)));return c`
872 + ${p||l!==""?c`
870 873 <os-text-field
871 874 class="dm-agents__ability-search"
872 875 type="search"
873 876 label=${r("Search abilities")}
874 - value=${o.abilityQuery}
877 + value=${i.abilityQuery}
875 878 placeholder=${r("custom fields, orders, media…")}
876 - @os-input-change=${m=>{o.abilityQuery=m.detail?.value??"",e.repaint()}}
879 + @os-input-change=${m=>{i.abilityQuery=m.detail?.value??"",e.repaint()}}
877 880 ></os-text-field>
878 881 `:""}
879 - ${p.size===0?l`<p class="dm-agents__hint">
880 - ${b(r('No ability matches "%s".'),o.abilityQuery.trim())}
882 + ${d.size===0?c`<p class="dm-agents__hint">
883 + ${b(r('No ability matches "%s".'),i.abilityQuery.trim())}
881 884 </p>`:""}
882 - ${[...p.entries()].map(([m,h])=>{const w=h.filter(g=>s.includes(g.slug)).length,v=w>0?b(r("%1$d of %2$d"),w,h.length):String(h.length);return l`
885 + ${[...d.entries()].map(([m,h])=>{const $=h.filter(w=>s.includes(w.slug)).length,_=$>0?b(r("%1$d of %2$d"),$,h.length):String(h.length);return c`
883 886 <details
884 887 class="dm-agents__ability-group"
885 888 ?open=${f(m,h)}
886 - @toggle=${g=>{o.abilityOpen.set(m,g.target.open)}}
889 + @toggle=${w=>{i.abilityOpen.set(m,w.target.open)}}
887 890 >
888 891 <summary class="dm-agents__category">
889 892 <span class="dm-agents__category-name">${m}</span>
890 - <span class="dm-agents__category-count">${v}</span>
893 + <span class="dm-agents__category-count">${_}</span>
891 894 </summary>
892 - ${h.map(g=>l`
895 + ${h.map(w=>c`
893 896 <div class="dm-agents__ability">
894 897 <os-checkbox-label
895 - label=${g.label}
896 - ?checked=${s.includes(g.slug)}
897 - ?disabled=${i.disabled===!0}
898 - @os-checkbox-change=${$=>n(g.slug,$.detail?.checked===!0)}
898 + label=${w.label}
899 + ?checked=${s.includes(w.slug)}
900 + ?disabled=${o.disabled===!0}
901 + @os-checkbox-change=${g=>n(w.slug,g.detail?.checked===!0)}
899 902 ></os-checkbox-label>
900 - <os-badge tone=${g.readonly?"neutral":"warning"}>
901 - ${g.readonly?r("read-only"):r("can modify")}
903 + <os-badge tone=${w.readonly?"neutral":"warning"}>
904 + ${w.readonly?r("read-only"):r("can modify")}
902 905 </os-badge>
903 - <p class="dm-agents__ability-desc">${g.description}</p>
906 + <p class="dm-agents__ability-desc">${w.description}</p>
904 907 </div>
905 908 `)}
906 909 </details>
907 910 `})}
908 - `}function Ct(e,t){return e.findIndex(s=>s.kind===t)}function Un(e){const t=e.config_schema;return!!t?.properties&&"entityKinds"in t.properties}function qe(e,t){e(Ct(t,"chat")===-1?[{kind:"chat",config:{}},...t]:t)}function qn(e,t,s,n){const i=t[s],o=a=>{qe(n,t.map((c,u)=>u===s?{kind:c.kind,config:{...c.config,...a}}:c))};if(i.kind==="hook"){const a=e.hooks.map(c=>c.hook);return l`
911 + `}function qt(e,t){return e.findIndex(s=>s.kind===t)}function uo(e){const t=e.config_schema;return!!t?.properties&&"entityKinds"in t.properties}function Je(e,t){e(qt(t,"chat")===-1?[{kind:"chat",config:{}},...t]:t)}function po(e,t,s,n){const o=t[s],i=a=>{Je(n,t.map((l,u)=>u===s?{kind:l.kind,config:{...l.config,...a}}:l))};if(o.kind==="hook"){const a=e.hooks.map(l=>l.hook);return c`
909 912 <div class="dm-agents__trigger-config">
910 913 <os-text-field
911 914 label=${r("Hook name")}
912 - value=${String(i.config.hook??"")}
915 + value=${String(o.config.hook??"")}
913 916 ?readonly=${!e.canManage}
914 - @os-input-commit=${c=>o({hook:c.detail.value})}
917 + @os-input-commit=${l=>i({hook:l.detail.value})}
915 918 ></os-text-field>
916 - ${a.length>0?l`<p class="dm-agents__hint">
919 + ${a.length>0?c`<p class="dm-agents__hint">
917 920 ${b(r("Suggestions: %s"),a.join(", "))}
918 921 </p>`:""}
919 922 </div>
920 - `}return i.kind==="endpoint"?l`
923 + `}return o.kind==="endpoint"?c`
921 924 <div class="dm-agents__trigger-config">
922 925 <os-text-field
923 926 label=${r("Required capability")}
924 - value=${String(i.config.capability??"")}
927 + value=${String(o.config.capability??"")}
925 928 ?readonly=${!e.canManage}
926 - @os-input-commit=${a=>o({capability:a.detail.value})}
929 + @os-input-commit=${a=>i({capability:a.detail.value})}
927 930 ></os-text-field>
928 931 </div>
929 - `:""}function jn(e,t,s,n,i){const o=Ct(n,s.slug),a=o===-1?null:n[o],c=!t.canManage||k(e).agentBusy,u=()=>n.filter(d=>d.kind!==s.slug);let p="";if(s.slug==="chat")p="";else if(Un(s)){const d=a?.config.entityKinds,f=Array.isArray(d)?d.filter(h=>typeof h=="string"):[],m=(h,w)=>{const v=w?[...new Set([...f,h])]:f.filter($=>$!==h),g=u();v.length>0&&g.push({kind:s.slug,config:{...a?.config??{},entityKinds:v}}),qe(i,g)};p=l`
932 + `:""}function fo(e,t,s,n,o){const i=qt(n,s.slug),a=i===-1?null:n[i],l=!t.canManage||k(e).agentBusy,u=()=>n.filter(p=>p.kind!==s.slug);let d="";if(s.slug==="chat")d="";else if(uo(s)){const p=a?.config.entityKinds,f=Array.isArray(p)?p.filter(h=>typeof h=="string"):[],m=(h,$)=>{const _=$?[...new Set([...f,h])]:f.filter(g=>g!==h),w=u();_.length>0&&w.push({kind:s.slug,config:{...a?.config??{},entityKinds:_}}),Je(o,w)};d=c`
930 933 <div class="dm-agents__trigger-config">
931 - ${bn.map(h=>l`
934 + ${Xn.map(h=>c`
932 935 <os-checkbox-label
933 936 label=${h}
934 937 ?checked=${f.includes(h)}
935 - ?disabled=${c}
936 - @os-checkbox-change=${w=>m(h,w.detail?.checked===!0)}
938 + ?disabled=${l}
939 + @os-checkbox-change=${$=>m(h,$.detail?.checked===!0)}
937 940 ></os-checkbox-label>
938 941 `)}
939 942 </div>
940 - `}else p=l`
943 + `}else d=c`
941 944 <div class="dm-agents__trigger-config">
942 945 <os-checkbox-label
943 946 label=${r("On")}
944 947 ?checked=${a!==null}
945 - ?disabled=${c}
946 - @os-checkbox-change=${d=>qe(i,d.detail?.checked===!0?[...u(),{kind:s.slug,config:{}}]:u())}
948 + ?disabled=${l}
949 + @os-checkbox-change=${p=>Je(o,p.detail?.checked===!0?[...u(),{kind:s.slug,config:{}}]:u())}
947 950 ></os-checkbox-label>
948 951 </div>
949 - ${a?qn(t,n,o,i):""}
950 - `;return l`
952 + ${a?po(t,n,i,o):""}
953 + `;return c`
951 954 <div class="dm-agents__trigger">
952 955 <div class="dm-agents__trigger-head">
953 956 <strong>${s.label}</strong>
954 - ${s.slug==="chat"?l`<os-badge tone="neutral">${r("Always on")}</os-badge>`:""}
957 + ${s.slug==="chat"?c`<os-badge tone="neutral">${r("Always on")}</os-badge>`:""}
955 958 </div>
956 - ${s.description?l`<p class="dm-agents__trigger-desc">${s.description}</p>`:""}
957 - ${p}
959 + ${s.description?c`<p class="dm-agents__trigger-desc">${s.description}</p>`:""}
960 + ${d}
958 961 </div>
959 - `}function Et(e,t,s,n){const i=t.triggerKinds.filter(o=>o.wired!==!1);return l`
962 + `}function Bt(e,t,s,n){const o=t.triggerKinds.filter(i=>i.wired!==!1);return c`
960 963 <div class="dm-agents__pane">
961 964 <p class="dm-agents__hint">
962 965 ${r("Chat is always on. Tick where else this site should reach the agent; a door with nothing ticked stays closed.")}
963 966 </p>
964 - ${i.map(o=>jn(e,t,o,s,n))}
967 + ${o.map(i=>fo(e,t,i,s,n))}
965 968 </div>
966 - `}function Kn(e,t){return(!e.agentDraft||e.agentDraftFor!==t.id)&&(e.agentDraft={name:t.name,description:t.description,instructions:t.instructions,role:t.role},e.agentDraftFor=t.id),e.agentDraft}function zn(e,t,s){const n=k(e),i=!t.canManage,o=Kn(n,s),a=o.name!==s.name||o.description!==s.description||o.instructions!==s.instructions||o.role!==s.role;return l`
969 + `}function mo(e,t){return(!e.agentDraft||e.agentDraftFor!==t.id)&&(e.agentDraft={name:t.name,description:t.description,instructions:t.instructions,role:t.role},e.agentDraftFor=t.id),e.agentDraft}function ho(e,t,s){const n=k(e),o=!t.canManage,i=mo(n,s),a=i.name!==s.name||i.description!==s.description||i.instructions!==s.instructions||i.role!==s.role;return c`
967 970 <div class="dm-agents__pane">
968 971 <os-text-field
969 972 label=${r("Name")}
970 - value=${o.name}
971 - ?readonly=${i}
972 - @os-input-change=${c=>{o.name=c.detail.value,e.repaint()}}
973 + value=${i.name}
974 + ?readonly=${o}
975 + @os-input-change=${l=>{i.name=l.detail.value,e.repaint()}}
973 976 ></os-text-field>
974 977 <os-text-field
975 978 label=${r("When to use (description)")}
976 - value=${o.description}
977 - ?readonly=${i}
978 - @os-input-change=${c=>{o.description=c.detail.value,e.repaint()}}
979 + value=${i.description}
980 + ?readonly=${o}
981 + @os-input-change=${l=>{i.description=l.detail.value,e.repaint()}}
979 982 ></os-text-field>
980 983 <os-textarea
981 984 label=${r("Instructions (system prompt)")}
982 - value=${o.instructions}
985 + value=${i.instructions}
983 986 rows="10"
984 - ?readonly=${i}
985 - @os-input-change=${c=>{o.instructions=c.detail.value,e.repaint()}}
987 + ?readonly=${o}
988 + @os-input-change=${l=>{i.instructions=l.detail.value,e.repaint()}}
986 989 ></os-textarea>
987 - ${i?l`<p class="dm-agents__hint">${r("Role")}: ${s.role}</p>`:l`
988 - ${t.roles?l`
990 + ${o?c`<p class="dm-agents__hint">${r("Role")}: ${s.role}</p>`:c`
991 + ${t.roles?c`
989 992 <os-select
990 993 label=${r("Role")}
991 - value=${o.role}
992 - @os-pick=${c=>{o.role=c.detail?.value??o.role,e.repaint()}}
994 + value=${i.role}
995 + @os-pick=${l=>{i.role=l.detail?.value??i.role,e.repaint()}}
993 996 >
994 - ${St(t.roles,o.role)}
997 + ${Ot(t.roles,i.role)}
995 998 </os-select>
996 - `:l`
997 - <os-select label=${r("Role")} value=${o.role} disabled>
998 - <os-option value=${o.role}>${o.role}</os-option>
999 + `:c`
1000 + <os-select label=${r("Role")} value=${i.role} disabled>
1001 + <os-option value=${i.role}>${i.role}</os-option>
999 1002 </os-select>
1000 1003 `}
1001 1004 <p class="dm-agents__hint">
1002 1005 ${r("The agent acts with this role's capabilities — pick the least privilege that still lets it do its job.")}
@@ -1002,38 +1005,38 @@
1002 1005 ${r("The agent acts with this role's capabilities — pick the least privilege that still lets it do its job.")}
1003 1006 </p>
1004 1007 <os-button
1005 1008 ?disabled=${n.agentBusy||!a}
1006 - @click=${()=>void x(e,"agent-update",{id:s.id,name:o.name,description:o.description,instructions:o.instructions,role:o.role})}
1009 + @click=${()=>void ie(e,"agent-update",{id:s.id,name:i.name,description:i.description,instructions:i.instructions,role:i.role})}
1007 1010 >
1008 1011 ${r("Save")}
1009 1012 </os-button>
1010 1013 `}
1011 1014 </div>
1012 - `}function Hn(e,t,s){return l`
1015 + `}function go(e,t,s){return c`
1013 1016 <div class="dm-agents__pane">
1014 1017 <p class="dm-agents__hint">
1015 1018 ${r("The agent may only call abilities ticked here — and every call is still gated by the ability's own permission check against the agent's role.")}
1016 1019 </p>
1017 - ${Tt(e,t,s.abilities,(n,i)=>{const o=i?Array.from(new Set([...s.abilities,n])):s.abilities.filter(a=>a!==n);x(e,"agent-update",{id:s.id,abilities:o})},{disabled:!t.canManage||k(e).agentBusy})}
1020 + ${Ut(e,t,s.abilities,(n,o)=>{const i=o?Array.from(new Set([...s.abilities,n])):s.abilities.filter(a=>a!==n);ie(e,"agent-update",{id:s.id,abilities:i})},{disabled:!t.canManage||k(e).agentBusy})}
1018 1021 </div>
1019 - `}function Xn(e,t,s){const n=k(e),i=e.state,o=e.data.sections.some(c=>c.id==="users"),a=l`
1022 + `}function yo(e,t,s){const n=k(e),o=e.state,i=e.data.sections.some(l=>l.id==="users"),a=c`
1020 1023 <os-tabs
1021 1024 class="dm-agents__tabs"
1022 - value=${i.pane}
1025 + value=${o.pane}
1023 1026 label=${r("Agent detail")}
1024 - @os-tab-change=${c=>{c.detail.value&&e.local("agent-pane",{pane:c.detail.value})}}
1027 + @os-tab-change=${l=>{l.detail.value&&e.local("agent-pane",{pane:l.detail.value})}}
1025 1028 >
1026 - ${[["define",r("Define")],["tools",r("Tools")],["triggers",r("Triggers")]].map(([c,u])=>l`
1027 - <os-tab value=${c}>${u}</os-tab>
1029 + ${[["define",r("Define")],["tools",r("Tools")],["triggers",r("Triggers")]].map(([l,u])=>c`
1030 + <os-tab value=${l}>${u}</os-tab>
1028 1031 `)}
1029 1032 </os-tabs>
1030 - `;return l`
1033 + `;return c`
1031 1034 <os-button class="dm-agents__back" variant="link" @click=${()=>void e.dispatch("open",{item:0})}>
1032 1035 ${r("‹ Your cast")}
1033 1036 </os-button>
1034 1037 <div class="dm-agents__detail-head">
1035 - <img class="dm-agents__detail-avatar" src=${ye(s,96)} alt="" />
1038 + <img class="dm-agents__detail-avatar" src=${Te(s,96)} alt="" />
1036 1039 <div class="dm-agents__detail-title">
1037 1040 <h3>${s.name}</h3>
1038 1041 <span class="dm-agents__detail-slug">@agent-${s.slug}</span>
1039 1042 </div>
@@ -1038,36 +1041,36 @@
1038 1041 <span class="dm-agents__detail-slug">@agent-${s.slug}</span>
1039 1042 </div>
1040 1043 </div>
1041 1044 <div class="dm-agents__detail-actions">
1042 - <os-button @click=${()=>Cn(s)}>
1045 + <os-button @click=${()=>Zn(s)}>
1043 1046 ${r("Open profile")}
1044 1047 </os-button>
1045 - ${o?l`
1048 + ${i?c`
1046 1049 <os-button
1047 - @click=${()=>Bn({userId:s.id,userName:s.name})}
1050 + @click=${()=>co({userId:s.id,userName:s.name})}
1048 1051 >
1049 1052 ${r("View contributions")}
1050 1053 </os-button>
1051 1054 `:""}
1052 - ${t.canManage?l`
1055 + ${t.canManage?c`
1053 1056 <os-button
1054 1057 ?disabled=${n.agentBusy}
1055 - @click=${()=>void In(s).then(c=>e.local("agent-notice",{notice:c}))}
1058 + @click=${()=>void eo(s).then(l=>e.local("agent-notice",{notice:l}))}
1056 1059 >
1057 1060 ${r("Send to Desktop")}
1058 1061 </os-button>
1059 1062 `:""}
1060 - ${t.canInvoke?l`
1063 + ${t.canInvoke?c`
1061 1064 <os-button
1062 1065 variant="primary"
1063 1066 ?disabled=${!t.aiReady}
1064 - @click=${()=>kt(t,s)}
1067 + @click=${()=>Rt(t,s)}
1065 1068 >
1066 1069 ${r("Chat")}
1067 1070 </os-button>
1068 1071 `:""}
1069 - ${t.canManage?l`
1072 + ${t.canManage?c`
1070 1073 <os-button
1071 1074 ?disabled=${n.agentBusy}
1072 1075 os-action="agent-delete"
1073 1076 os-arg-id=${String(s.id)}
@@ -1079,36 +1082,36 @@
1079 1082 </os-button>
1080 1083 `:""}
1081 1084 </div>
1082 1085 ${a}
1083 - ${i.pane==="define"?zn(e,t,s):""}
1084 - ${i.pane==="tools"?Hn(e,t,s):""}
1085 - ${i.pane==="triggers"?Et(e,t,s.triggers,c=>{x(e,"agent-update",{id:s.id,triggers:c})}):""}
1086 - `}const Yn=()=>[r("Describe"),r("Meet"),r("Powers"),r("Summon"),r("Launch")];function je(e){return e.name.trim()!==""}function Gn(e,t){const s=e.state.cast,n=e.state.wstep,i=l`
1086 + ${o.pane==="define"?ho(e,t,s):""}
1087 + ${o.pane==="tools"?go(e,t,s):""}
1088 + ${o.pane==="triggers"?Bt(e,t,s.triggers,l=>{ie(e,"agent-update",{id:s.id,triggers:l})}):""}
1089 + `}const $o=()=>[r("Describe"),r("Meet"),r("Powers"),r("Summon"),r("Launch")];function Ze(e){return e.name.trim()!==""}function wo(e,t){const s=e.state.cast,n=e.state.wstep,o=c`
1087 1090 <os-steps horizontal class="dm-agents__trail">
1088 - ${Yn().map((o,a)=>l`
1091 + ${$o().map((i,a)=>c`
1089 1092 <os-step
1090 - title=${o}
1093 + title=${i}
1091 1094 ?done=${a<n}
1092 1095 ?current=${a===n}
1093 - ?interactive=${a<n}
1094 - @os-step-click=${()=>{a<n&&e.local("agent-step",{step:a})}}
1096 + ?interactive=${a!==n}
1097 + @os-step-click=${()=>{a!==n&&e.local("agent-step",{step:a})}}
1095 1098 ></os-step>
1096 1099 `)}
1097 1100 </os-steps>
1098 - `;return l`
1101 + `;return c`
1099 1102 <div class="dm-agents__wizard">
1100 1103 <div class="dm-agents__wiz-head">
1101 1104 <h3>${r("New agent")}</h3>
1102 1105 </div>
1103 - ${i}
1104 - ${n===0?Vn(e,t,s):""}
1105 - ${n===1?Qn(e,s):""}
1106 - ${n===2?Zn(e,t,s):""}
1107 - ${n===3?xn(e,t,s):""}
1108 - ${n===4?eo(e,t,s):""}
1106 + ${o}
1107 + ${n===0?vo(e,t,s):""}
1108 + ${n===1?_o(e,s):""}
1109 + ${n===2?bo(e,t,s):""}
1110 + ${n===3?So(e,t,s):""}
1111 + ${n===4?Ao(e,t,s):""}
1109 1112 </div>
1110 - `}function ee(e,t){return l`
1113 + `}function re(e,t){return c`
1111 1114 <os-button
1112 1115 variant="ghost"
1113 1116 ?disabled=${k(e).agentBusy||t.drafting}
1114 1117 @click=${()=>e.local("agent-cancel")}
@@ -1114,16 +1117,16 @@
1114 1117 @click=${()=>e.local("agent-cancel")}
1115 1118 >
1116 1119 ${r("Cancel")}
1117 1120 </os-button>
1118 - `}function Vn(e,t,s){const n=()=>{s.instructions===""&&s.brief.trim()!==""&&(s.instructions=s.brief.trim())},i=()=>{if(s.brief.trim()===""){e.local("agent-brief-error",{msg:r("Describe the agent first. A sentence is enough.")});return}s.drafting=!0,x(e,"agent-draft")};return l`
1119 - ${t.list.length>0?l`
1121 + `}function vo(e,t,s){const n=()=>{if(s.brief.trim()===""){e.local("agent-brief-error",{msg:r("Describe the agent first. A sentence is enough.")});return}s.drafting=!0,ie(e,"agent-draft")};return c`
1122 + ${t.list.length>0?c`
1120 1123 <h4 class="dm-agents__wiz-heading">${r("Start from someone")}</h4>
1121 1124 <p class="dm-agents__hint">
1122 1125 ${r("Copies their instructions and abilities, and rolls a new face. Nothing you pick is changed.")}
1123 1126 </p>
1124 1127 <div class="dm-agents__starters">
1125 - ${t.list.map(o=>l`
1128 + ${t.list.map(o=>c`
1126 1129 <os-card
1127 1130 class="dm-agents__starter"
1128 1131 interactive
1129 1132 @os-card-click=${()=>e.local("agent-start",{from:o})}
@@ -1129,9 +1132,9 @@
1129 1132 @os-card-click=${()=>e.local("agent-start",{from:o})}
1130 1133 >
1131 1134 <img
1132 1135 class="dm-agents__starter-face"
1133 - src=${ye(o,76)}
1136 + src=${Te(o,76)}
1134 1137 alt=""
1135 1138 width="76"
1136 1139 height="76"
1137 1140 />
@@ -1160,13 +1163,13 @@
1160 1163 @os-input-change=${o=>{s.brief=o.detail?.value??"",e.state.briefError!==""&&e.local("agent-brief-error",{msg:""})}}
1161 1164 ></os-textarea>
1162 1165 </os-field-row>
1163 1166 <div class="dm-agents__actions">
1164 - ${t.aiReady?l`
1167 + ${t.aiReady?c`
1165 1168 <os-button
1166 1169 variant="holo"
1167 1170 ?busy=${s.drafting}
1168 - @click=${i}
1171 + @click=${n}
1169 1172 >
1170 1173 ${r("Draft it for me")}
1171 1174 </os-button>
1172 1175 `:""}
@@ -1172,51 +1175,51 @@
1172 1175 `:""}
1173 1176 <os-button
1174 1177 variant=${t.aiReady?"ghost":"primary"}
1175 1178 ?disabled=${s.drafting}
1176 - @click=${()=>{n(),e.local("agent-step",{step:1})}}
1179 + @click=${()=>e.local("agent-step",{step:1})}
1177 1180 >
1178 1181 ${t.aiReady?r("I will fill it in myself"):r("Continue")}
1179 1182 </os-button>
1180 1183 <span class="os-app__spacer"></span>
1181 - ${ee(e,s)}
1184 + ${re(e,s)}
1182 1185 </div>
1183 - `}function Qn(e,t){const s=k(e),n=$n(t.stripSeed,Fe);return l`
1186 + `}function _o(e,t){const s=k(e),n=jn(t.stripSeed,Ge);return c`
1184 1187 <div class="dm-agents__meet">
1185 1188 <div class="dm-agents__portrait">
1186 1189 <img
1187 1190 class="dm-agents__portrait-face"
1188 - src=${J(t.face,176)}
1191 + src=${oe(t.face,176)}
1189 1192 alt=""
1190 1193 width="176"
1191 1194 height="176"
1192 1195 />
1193 1196 <div class="dm-agents__faces" role="radiogroup" aria-label=${r("Face")}>
1194 - ${n.map(i=>l`
1197 + ${n.map(o=>c`
1195 1198 <button
1196 1199 type="button"
1197 - class="dm-agents__face-pick ${i.seed===t.faceSeed?"is-picked":""}"
1200 + class="dm-agents__face-pick ${o.seed===t.faceSeed?"is-picked":""}"
1198 1201 role="radio"
1199 - aria-checked=${i.seed===t.faceSeed?"true":"false"}
1200 - @click=${()=>e.local("agent-wiz",{faceSeed:i.seed,face:i.look})}
1202 + aria-checked=${o.seed===t.faceSeed?"true":"false"}
1203 + @click=${()=>e.local("agent-wiz",{faceSeed:o.seed,face:o.look})}
1201 1204 >
1202 - <img src=${J(i.look,44)} alt="" width="44" height="44" />
1205 + <img src=${oe(o.look,44)} alt="" width="44" height="44" />
1203 1206 </button>
1204 1207 `)}
1205 1208 </div>
1206 1209 <os-button
1207 1210 variant="secondary"
1208 - @click=${()=>e.local("agent-wiz",{stripSeed:t.stripSeed+Fe})}
1211 + @click=${()=>e.local("agent-wiz",{stripSeed:t.stripSeed+Ge})}
1209 1212 >
1210 1213 ${r("Surprise me")}
1211 1214 </os-button>
1212 1215 <div class="dm-agents__portrait-chips">
1213 - <os-chip size="compact" label=${yn(t.face)}></os-chip>
1214 - <os-chip size="compact" label=${_n(t.face)}></os-chip>
1216 + <os-chip size="compact" label=${Kn(t.face)}></os-chip>
1217 + <os-chip size="compact" label=${Hn(t.face)}></os-chip>
1215 1218 </div>
1216 1219 </div>
1217 1220 <div class="dm-agents__meet-fields">
1218 - ${t.copiedFrom?l`<os-notice tone="info">
1221 + ${t.copiedFrom?c`<os-notice tone="info">
1219 1222 ${b(r("Copied from %s, with a face of its own."),t.copiedFrom)}
1220 1223 </os-notice>`:""}
1221 1224 <os-field-row error=${s.nameError}>
1222 1225 <os-text-field
@@ -1223,9 +1226,9 @@
1223 1226 os-field-control
1224 1227 label=${r("Name")}
1225 1228 value=${t.name}
1226 1229 ?invalid=${s.nameError!==""}
1227 - @os-input-change=${i=>{const o=je(t)&&s.nameError==="";t.name=i.detail?.value??"",s.nameError="",o!==je(t)&&e.repaint()}}
1230 + @os-input-change=${o=>{const i=Ze(t)&&s.nameError==="";t.name=o.detail?.value??"",s.nameError="",i!==Ze(t)&&e.repaint()}}
1228 1231 ></os-text-field>
1229 1232 </os-field-row>
1230 1233 <os-text-field
1231 1234 label=${r("Vibes")}
@@ -1231,9 +1234,9 @@
1231 1234 label=${r("Vibes")}
1232 1235 value=${t.vibes}
1233 1236 maxlength="120"
1234 1237 placeholder=${r("blunt, precise, no sugarcoating")}
1235 - @os-input-change=${i=>{t.vibes=i.detail?.value??""}}
1238 + @os-input-change=${o=>{t.vibes=o.detail?.value??""}}
1236 1239 ></os-text-field>
1237 1240 <p class="dm-agents__hint">
1238 1241 ${r("One line of voice. It goes into the agent's instructions, so it is how the agent sounds rather than a label on a card.")}
1239 1242 </p>
@@ -1239,9 +1242,9 @@
1239 1242 </p>
1240 1243 <os-text-field
1241 1244 label=${r("When to use")}
1242 1245 value=${t.description}
1243 - @os-input-change=${i=>{t.description=i.detail?.value??""}}
1246 + @os-input-change=${o=>{t.description=o.detail?.value??""}}
1244 1247 ></os-text-field>
1245 1248 </div>
1246 1249 </div>
1247 1250 <div class="dm-agents__actions">
@@ -1250,16 +1253,16 @@
1250 1253 </os-button>
1251 1254 <span class="os-app__spacer"></span>
1252 1255 <os-button
1253 1256 variant="primary"
1254 - ?disabled=${!je(t)}
1257 + ?disabled=${!Ze(t)}
1255 1258 @click=${()=>e.local("agent-step",{step:2})}
1256 1259 >
1257 1260 ${r("Continue")}
1258 1261 </os-button>
1259 - ${ee(e,t)}
1262 + ${re(e,t)}
1260 1263 </div>
1261 - `}function Zn(e,t,s){return l`
1264 + `}function bo(e,t,s){return c`
1262 1265 <os-select
1263 1266 class="dm-agents__role-select"
1264 1267 label=${r("Role")}
1265 1268 value=${s.role}
@@ -1264,16 +1267,16 @@
1264 1267 label=${r("Role")}
1265 1268 value=${s.role}
1266 1269 @os-pick=${n=>e.local("agent-wiz",{role:n.detail?.value??s.role})}
1267 1270 >
1268 - ${t.roles===null?l`<os-option value=${s.role}>${s.role}</os-option>`:St(t.roles,s.role)}
1271 + ${t.roles===null?c`<os-option value=${s.role}>${s.role}</os-option>`:Ot(t.roles,s.role)}
1269 1272 </os-select>
1270 1273 <p class="dm-agents__hint">
1271 1274 ${r("The agent acts with this role's capabilities. Pick the least privilege that still lets it do its job.")}
1272 1275 </p>
1273 1276 <h4 class="dm-agents__wiz-heading">${r("What it may call (abilities)")}</h4>
1274 - ${t.abilities.length===0?"":l`
1275 - ${Jn(e,t,s)}
1277 + ${t.abilities.length===0?"":c`
1278 + ${ko(e,t,s)}
1276 1279 <p class="dm-agents__hint">
1277 1280 ${r("The agent may only call abilities ticked here, and every call is still gated by the ability's own permission check against the agent's role.")}
1278 1281 </p>
1279 1282 `}
@@ -1284,12 +1287,12 @@
1284 1287 <span class="os-app__spacer"></span>
1285 1288 <os-button variant="primary" @click=${()=>e.local("agent-step",{step:3})}>
1286 1289 ${r("Continue")}
1287 1290 </os-button>
1288 - ${ee(e,s)}
1291 + ${re(e,s)}
1289 1292 </div>
1290 - `}function Jn(e,t,s){return Tt(e,t,s.abilities,(n,i)=>{const o=new Set(s.abilities);i?o.add(n):o.delete(n),e.local("agent-wiz",{abilities:[...o]})})}function xn(e,t,s){return l`
1291 - ${Et(e,t,s.triggers,n=>e.local("agent-wiz",{triggers:n}))}
1293 + `}function ko(e,t,s){return Ut(e,t,s.abilities,(n,o)=>{const i=new Set(s.abilities);o?i.add(n):i.delete(n),e.local("agent-wiz",{abilities:[...i]})})}function So(e,t,s){return c`
1294 + ${Bt(e,t,s.triggers,n=>e.local("agent-wiz",{triggers:n}))}
1292 1295 <div class="dm-agents__actions">
1293 1296 <os-button variant="ghost" @click=${()=>e.local("agent-step",{step:2})}>
1294 1297 ${r("Back")}
1295 1298 </os-button>
@@ -1295,19 +1298,19 @@
1295 1298 </os-button>
1296 1299 <span class="os-app__spacer"></span>
1297 1300 <os-button
1298 1301 variant="primary"
1299 - @click=${()=>e.local("agent-step",{step:Sn})}
1302 + @click=${()=>e.local("agent-step",{step:Gn})}
1300 1303 >
1301 1304 ${r("Continue")}
1302 1305 </os-button>
1303 - ${ee(e,s)}
1306 + ${re(e,s)}
1304 1307 </div>
1305 - `}function eo(e,t,s){const n=k(e),i=t.canInvoke&&t.aiReady,o=d=>t.abilities.find(f=>f.slug===d)?.label??d,a=d=>t.triggerKinds.find(f=>f.slug===d)?.label??d,c=t.roles?.find(d=>d.slug===s.role)?.label??t.roleLabels[s.role]??s.role,u=s.triggers.length===0?r("No triggers configured: reachable in chat."):b(r("Starts from: %s."),s.triggers.map(d=>a(d.kind)).join(", ")),p=d=>{if(s.name.trim()===""){n.nameError=r("Agent name is required."),e.local("agent-step",{step:1});return}n.chatAfterCreate=d,x(e,"agent-create")};return l`
1308 + `}function Ao(e,t,s){const n=k(e),o=t.canInvoke&&t.aiReady,i=p=>t.abilities.find(f=>f.slug===p)?.label??p,a=p=>t.triggerKinds.find(f=>f.slug===p)?.label??p,l=t.roles?.find(p=>p.slug===s.role)?.label??t.roleLabels[s.role]??s.role,u=s.triggers.length===0?r("No triggers configured: reachable in chat."):b(r("Starts from: %s."),s.triggers.map(p=>a(p.kind)).join(", ")),d=p=>{if(s.name.trim()===""){n.nameError=r("Agent name is required."),e.local("agent-step",{step:1});return}n.chatAfterCreate=p,ie(e,"agent-create")};return c`
1306 1309 <os-card class="dm-agents__summary">
1307 1310 <img
1308 1311 class="dm-agents__summary-face"
1309 - src=${J(s.face,96)}
1312 + src=${oe(s.face,96)}
1310 1313 alt=""
1311 1314 width="96"
1312 1315 height="96"
1313 1316 />
@@ -1312,20 +1315,20 @@
1312 1315 height="96"
1313 1316 />
1314 1317 <div class="dm-agents__summary-text">
1315 1318 <h4>${s.name}</h4>
1316 - ${s.vibes?l`<p class="dm-agents__summary-vibes">${s.vibes}</p>`:""}
1319 + ${s.vibes?c`<p class="dm-agents__summary-vibes">${s.vibes}</p>`:""}
1317 1320 <p class="dm-agents__summary-desc">
1318 1321 ${s.description||r("No description yet.")}
1319 1322 </p>
1320 1323 <div class="dm-agents__chips">
1321 - <os-chip size="compact" label=${c}></os-chip>
1322 - ${s.abilities.map(d=>l`<os-chip size="compact" label=${o(d)}></os-chip>`)}
1324 + <os-chip size="compact" label=${l}></os-chip>
1325 + ${s.abilities.map(p=>c`<os-chip size="compact" label=${i(p)}></os-chip>`)}
1323 1326 </div>
1324 - ${s.instructions===""?l`<p class="dm-agents__hint">
1325 - ${r("No instructions yet: the agent will improvise. You can add them any time in Define.")}
1326 - </p>`:l`<p class="dm-agents__summary-instr">${s.instructions}</p>`}
1327 - ${s.abilities.length===0?l`<p class="dm-agents__hint">
1327 + ${s.instructions===""?c`<p class="dm-agents__hint">
1328 + ${r("No instructions yet: the agent will improvise. Add them in Describe, or any time after in Define.")}
1329 + </p>`:c`<p class="dm-agents__summary-instr">${s.instructions}</p>`}
1330 + ${s.abilities.length===0?c`<p class="dm-agents__hint">
1328 1331 ${r("No abilities ticked: the agent can talk, but not touch the site.")}
1329 1332 </p>`:""}
1330 1333 <p class="dm-agents__hint">${u}</p>
1331 1334 </div>
@@ -1335,32 +1338,32 @@
1335 1338 ${r("Back")}
1336 1339 </os-button>
1337 1340 <span class="os-app__spacer"></span>
1338 1341 <os-button
1339 - variant=${i?"secondary":"primary"}
1342 + variant=${o?"secondary":"primary"}
1340 1343 ?disabled=${n.agentBusy}
1341 - @click=${()=>p(!1)}
1344 + @click=${()=>d(!1)}
1342 1345 >
1343 1346 ${r("Create agent")}
1344 1347 </os-button>
1345 - ${i?l`
1348 + ${o?c`
1346 1349 <os-button
1347 1350 variant="primary"
1348 1351 ?disabled=${n.agentBusy}
1349 - @click=${()=>p(!0)}
1352 + @click=${()=>d(!0)}
1350 1353 >
1351 1354 ${r("Create and chat")}
1352 1355 </os-button>
1353 1356 `:""}
1354 - ${ee(e,s)}
1357 + ${re(e,s)}
1355 1358 </div>
1356 - `}function to(e){const t=e.data.agents;if(!t)return l`<os-empty-state>${r("This section is not available.")}</os-empty-state>`;const s=!t.enabled,n=e.state,i=t.list.find(a=>a.id===n.item)??null;let o;return n.casting&&n.cast?o=Gn(e,t):i?o=l`<div class="dm-agents__detail">${Xn(e,t,i)}</div>`:o=Ln(e,t),l`
1359 + `}function Mo(e){const t=e.data.agents;if(!t)return c`<os-empty-state>${r("This section is not available.")}</os-empty-state>`;const s=!t.enabled,n=e.state,o=t.list.find(a=>a.id===n.item)??null;let i;return n.casting&&n.cast?i=wo(e,t):o?i=c`<div class="dm-agents__detail">${yo(e,t,o)}</div>`:i=no(e,t),c`
1357 1360 <div class="dm-agents ${s?"is-disabled":""}">
1358 - ${Nn(t)}
1359 - ${n.agentNotice?l`<os-notice class="dm-agents__notice">${n.agentNotice}</os-notice>`:""}
1360 - <div class="dm-agents__view">${o}</div>
1361 + ${to(t)}
1362 + ${n.agentNotice?c`<os-notice class="dm-agents__notice">${n.agentNotice}</os-notice>`:""}
1363 + <div class="dm-agents__view">${i}</div>
1361 1364 </div>
1362 - `}const It=8;function so(e,t){e.style.visibility="hidden";const s=()=>{e.isConnected&&(t(e.getBoundingClientRect()),e.style.visibility="")};typeof requestAnimationFrame=="function"?requestAnimationFrame(s):s()}function no(e){so(e,t=>{t.right>window.innerWidth&&(e.style.left=`${Math.max(0,window.innerWidth-t.width-It)}px`),t.bottom>window.innerHeight&&(e.style.top=`${Math.max(0,window.innerHeight-t.height-It)}px`)})}const q=We("desktop-mode/my-wordpress/open-target",()=>({kind:null,entityId:"",id:0,title:"",requestedAt:0}));function oo(){return{...q.state}}function io(){q.state.kind=null,q.state.entityId="",q.state.id=0,q.state.title="",q.notify()}function ro(e){return q.subscribe(t=>e({...t}))}const te=We("desktop-mode/agents/editor-target",()=>({agentId:null,requestedAt:0}));function ao(){return{...te.state}}function lo(){te.state.agentId=null,te.state.requestedAt=0,te.notify()}function co(e){return te.subscribe(t=>e({...t}))}function ve(){const e=window.wp?.hooks;if(!e)throw new Error("[openstation] `window.wp.hooks` is not available. The plugin declares `wp-hooks` as a script dependency; if you are seeing this error, verify the enqueue order.");return e}function uo(e,t,s,n){ve().addFilter(e,t,s,n)}function po(e,t,s,n){ve().addAction(e,t,s,n)}function fo(e,t){return ve().removeAction(e,t)}function mo(e,t){return ve().removeFilter(e,t)}const Nt="X-WP-Nonce";function ho(e,t){const s=go();if(!s)return t;const n=$o(e);if(!n||!yo(n))return t;const i=t?.headers??(typeof Request<"u"&&e instanceof Request?e.headers:void 0),o=new Headers(i??{});return o.has(Nt)?t:(o.set(Nt,s),{...t??{},headers:o})}function go(){if(typeof window>"u")return;const t=window.openStationConfig?.restNonce;return typeof t=="string"&&t.length>0?t:void 0}function $o(e){try{const t=typeof window<"u"&&window.location?window.location.href:void 0;return typeof e=="string"?new URL(e,t):e instanceof URL?e:typeof Request<"u"&&e instanceof Request?new URL(e.url,t):null}catch{return null}}function yo(e){return typeof window>"u"||!window.location||e.origin!==window.location.origin?!1:!!(e.pathname.includes("/wp-json/")||e.searchParams.has("rest_route"))}function Ke(e,t,s={}){const n=window.wp?.os?.fetch;if(typeof n=="function")return n(e,t,s);const i=ho(e,t);return fetch(e,i)}const wo="http://localhost/";function Dt(e,t){const s=typeof window<"u"&&window.location?window.location.href:wo,n=new URL(e,s),i=t.replace(/^\/+/,""),o=i.indexOf("?"),a=o===-1?i:i.slice(0,o),c=o===-1?"":i.slice(o+1);if(n.searchParams.has("rest_route")){const u=n.searchParams.get("rest_route")??"/",p=u.endsWith("/")?u:u+"/";n.searchParams.set("rest_route",p+a)}else{const u=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";n.pathname=u+a}return c&&new URLSearchParams(c).forEach((p,d)=>{n.searchParams.append(d,p)}),n.toString()}const Lt="desktop-mode/v1/agents/conversations";async function Pt(e,t,s={}){const n=await Ke(Dt(e.restRoot,t),{...s,headers:{"Content-Type":"application/json","X-WP-Nonce":e.restNonce,...s.headers??{}}},{source:"desktop-mode/agents",silent:!0}),i=await n.json().catch(()=>null);if(!n.ok){const o=i&&typeof i=="object"&&typeof i.message=="string"?i.message:`HTTP ${n.status}`;throw new Error(o)}return i}function _o(e){return e.filter(t=>!t.pending)}async function vo(e,t){const s=L.state,n=_o(s.transcripts[e.id]??[]);if(n.length!==0){s.conversationIds||(s.conversationIds={});try{const i=s.conversationIds[e.id];if(i)await Pt(t,`${Lt}/${i}`,{method:"PUT",body:JSON.stringify({messages:n})});else{const o=await Pt(t,Lt,{method:"POST",body:JSON.stringify({agentId:e.id,messages:n})});s.conversationIds[e.id]=o.id}s.conversationsRev=(s.conversationsRev??0)+1,L.notify()}catch(i){console.warn("[desktop-mode/agents] conversation save failed:",i)}}}const Rt={post:"post",page:"page",attachment:"media",media:"media",user:"user",comment:"comment"};function Ot(e){const t=Number.parseInt(String(e??""),10);return Number.isFinite(t)&&t>0?t:0}function Ft(e){if(e.type==="shortcut"){const t=e.data;let s=Rt[String(t.kind??"")];s==="post"&&t.bridgePayload?.postType==="page"&&(s="page");const n=Ot(t.ref);return!s||!n?null:{kind:s,id:n,title:String(t.title??"")||`#${n}`}}if(e.type==="desktop-file"){const s=e.data.placement?.file;if(!s)return null;const n=Rt[String(s.type??"")],i=Ot(s.ref);return!n||!i?null:{kind:n,id:i,title:String(s.title??"")||`#${i}`}}return null}function bo(e){const t=e.find(n=>n.kind==="drag");if(!t)return null;const s=t.config?.entityKinds;return Array.isArray(s)?s.map(String):[]}function ko(e,t,s){return!t||s&&t.kind==="user"&&t.id===s||e==null?!1:e.length===0?!0:e.includes(t.kind)}function So(e){return b(r('The user dropped the %1$s "%2$s" (id %3$s) onto you. Handle it according to your instructions, using your tools as needed.',"desktop-mode"),e.kind,e.title,String(e.id))}function Ao(e){return b(r('The user sent you the %1$s "%2$s" (id %3$s) from the "Send to" menu. Handle it according to your instructions, using your tools as needed.',"desktop-mode"),e.kind,e.title,String(e.id))}function Mo(e,t,s){return Bt(e,"agents-send-to"),Ut(e,Ao(t),s,"send-to",Wt(t))}function Wt(e){return{kind:e.kind,id:e.id,title:e.title}}function Bt(e,t="agents"){Be(e);const s=window.wp?.os?.openWindow;typeof s=="function"&&s("desktop-mode-agent-run",{source:t})}async function Ut(e,t,s,n,i){Be(e);const o=L.state.transcripts[e.id],a=o.filter(u=>!u.pending&&u.role!=="error").map(u=>({role:u.role,text:u.text}));o.push({role:"user",text:t,at:Date.now(),attachment:i});const c={role:"agent",text:r("Working…","desktop-mode"),at:Date.now(),pending:!0};o.push(c),L.notify();try{const u=await Ke(Dt(s.restRoot,`desktop-mode/v1/agents/${e.id}/invoke`),{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":s.restNonce},body:JSON.stringify({message:t,source:n,history:a})},{source:"desktop-mode/agents"}),p=await u.json().catch(()=>null);if(!u.ok){if(u.status===504)throw new Error(r("The agent took too long to reply, so the answer never arrived. It may still be finishing the work: give it a moment before asking again.","desktop-mode"));const f=p&&typeof p=="object"&&typeof p.message=="string"?p.message:`HTTP ${u.status}`;throw new Error(f)}const d=p;c.text=d.text||r("The agent finished without a text answer.","desktop-mode"),c.toolCalls=d.toolCalls,Array.isArray(d.callToActions)&&d.callToActions.length>0&&(c.callToActions=d.callToActions)}catch(u){c.role="error",c.text=u instanceof Error?u.message:String(u)}c.pending=!1,L.notify(),vo(e,s)}function To(e,t,s){return Bt(e,"agents-drop"),Ut(e,So(t),s,"drag",Wt(t))}const Co={source:"desktop-mode/agents"};function qt(){const e=window.wp?.os?.config;return{restRoot:String(e?.restUrl??""),restNonce:String(e?.restNonce??"")}}function Eo(e=""){return`${qt().restRoot.replace(/\/+$/,"")}/desktop-mode/v1/agents${e}`}async function Io(e,t={}){const s=await Ke(e,{...t,headers:{"Content-Type":"application/json","X-WP-Nonce":qt().restNonce,...t.headers||{}}},Co),n=await s.json().catch(()=>null);if(!s.ok){const i=n&&typeof n=="object"&&typeof n.message=="string"?n.message:`HTTP ${s.status}`;throw new Error(i)}return n}function No(){return Io(Eo())}let j=null,ze=!1,He=null;function jt(e){He===!1&&e&&(j=null),He=e}function Do(){return He===!0}async function Xe(){if(!(ze||j!==null||!Do())){ze=!0;try{j=await No()}catch{j=[]}finally{ze=!1}}}function Lo(){j=null,Xe()}function Po(e){return j===null?(Xe(),[]):j.filter(t=>{const s=t.triggers.find(i=>i.kind==="send-to");if(!s)return!1;const n=Array.isArray(s.config?.entityKinds)?s.config.entityKinds:[];return n.length===0||n.includes(e)})}function Ro(e){return e.kind==="user"?"user":e.kind==="attachment"||e.kind==="media"?"media":e.kind==="post"?e.entityId==="pages"?"page":"post":null}function Oo(e){const t=e.title?.rendered;if(typeof t=="string"&&t!==""){const s=document.createElement("div");return s.innerHTML=t,s.textContent??""}return typeof e.title=="string"&&e.title!==""?e.title:typeof e.name=="string"&&e.name!==""?e.name:""}const be="desktop-mode/agents-send-to";function Fo(){mo("os.my-wordpress.tile-context-menu",be),uo("os.my-wordpress.tile-context-menu",be,Wo),fo("os.agents.roster-changed",be),po("os.agents.roster-changed",be,()=>{Lo()}),Xe()}function Wo(e,t){const s=Ro(t);if(!s)return e;const n=Number.parseInt(String(t.item?.id??""),10);if(!n)return e;const i=Po(s);if(i.length===0)return e;const o=Oo(t.item)||`#${n}`;return[...e,...i.map(a=>({id:`agent-send-to-${a.id}`,label:b(r("Send to %s","desktop-mode"),a.name),icon:"dashicons-share-alt",onSelect:()=>{const c=window.wp?.os?.config;Mo({id:a.id,name:a.name,description:a.description,avatarUrl:a.avatarUrl},{kind:s,id:n,title:o},{restRoot:String(c?.restUrl??""),restNonce:String(c?.restNonce??"")})}}))]}function Bo(e){const{root:t}=e,s=k(e),n=[],i=y=>{if(y.button!==0||y.shiftKey||y.ctrlKey||y.metaKey||K())return;const _=y.target?.closest("[data-mywp-drag][data-item-id]");if(!_)return;const A=T().dragManager;if(!A)return;const M=Number(_.getAttribute("data-item-id")),S=_.getAttribute("data-mywp-drag")??"",N=s.list.items(),P=N.find(W=>W.id===M);if(!P)return;const se=ae(e.data,e.state.section),ke=se?.id??"",F=String(se?.restPath??""),Y=e.state.selected.includes(M)?N.filter(W=>e.state.selected.includes(W.id)):[P];A.start({payload:{type:"shortcut",source:_,data:{kind:S,ref:String(P.id),title:P.title,icon:P.thumb||"",entityId:ke,restPath:F,...Y.length>1?{items:Y.map(W=>({kind:S,ref:String(W.id),title:W.title,icon:W.thumb||"",entityId:ke,restPath:F}))}:{}}},origin:y})};t.addEventListener("pointerdown",i),n.push(()=>t.removeEventListener("pointerdown",i)),K()||n.push(ss({root:t,canvas:".os-mywp__canvas",className:"os-mywp__marquee",select:y=>e.local("select-set",{ids:y})})),n.push(()=>s.list.dispose());const o=T().hooks,a=`openstation-apps/my-wordpress/${bt(t)}`;o?.addAction?.("os.extended-options.changed",a,y=>{const _=y?.options;_&&typeof _.agents=="boolean"&&e.dispatch("refresh")}),n.push(()=>{o?.removeAction?.("os.extended-options.changed",a);for(const y of s.agentDropTargets.values())y();s.agentDropTargets.clear()});let c=null,u=0;const p=()=>{c?.remove(),c=null,u=0},d=(y,_)=>{let M=_.clientX+16,S=_.clientY+16;const N=y.getBoundingClientRect();M+N.width>window.innerWidth-8&&(M=Math.max(8,_.clientX-N.width-16)),S+N.height>window.innerHeight-8&&(S=Math.max(8,_.clientY-N.height-16)),y.style.left=`${M}px`,y.style.top=`${S}px`},f=y=>{const _=document.createElement("div");_.className="os-my-wordpress__tooltip",_.setAttribute("role","tooltip");const A=document.createElement("div");if(A.className="os-my-wordpress__tooltip-title",A.textContent=y.title,_.appendChild(A),y.lockedBy){const S=document.createElement("div");S.className="os-my-wordpress__tooltip-lock";const N=document.createElement("span");N.className="dashicons dashicons-lock",N.setAttribute("aria-hidden","true"),S.appendChild(N);const P=document.createElement("span");P.textContent=b(r("%s is currently editing"),y.lockedBy),S.appendChild(P),_.appendChild(S)}if(y.thumb){const S=document.createElement("img");S.className="os-my-wordpress__tooltip-thumb",S.src=y.thumb,S.alt="",_.appendChild(S)}const M=y.excerpt||y.subtitle;if(M){const S=document.createElement("p");S.className="os-my-wordpress__tooltip-excerpt",S.textContent=M.length>240?M.slice(0,237)+"…":M,_.appendChild(S)}return _},m=y=>{const _=y.target?.closest("[data-mywp-drag][data-item-id]");if(!_||_.closest("[data-mywp-list]"))return;const A=Number(_.getAttribute("data-item-id"));if(A===u)return;const M=s.list.items().find(N=>N.id===A);if(!M)return;p(),u=A;const S=o?.applyFilters("os.my-wordpress.hover-card",null,M,{build:f,cell:_,event:y});S instanceof HTMLElement&&(c=S,document.body.appendChild(c),d(c,y))},h=y=>{if(!c)return;if(!y.target?.closest("[data-mywp-drag][data-item-id]")){p();return}d(c,y)};t.addEventListener("mouseover",m),t.addEventListener("mousemove",h),t.addEventListener("mouseleave",p),t.addEventListener("pointerdown",p),t.addEventListener("contextmenu",p),n.push(()=>{t.removeEventListener("mouseover",m),t.removeEventListener("mousemove",h),t.removeEventListener("mouseleave",p),t.removeEventListener("pointerdown",p),t.removeEventListener("contextmenu",p),p()});const w=y=>{if(y.key!=="Escape")return;const _=k(e);_.menu?(_.menu=null,e.repaint()):_.columnsMenu?(_.columnsMenu=null,e.repaint()):_.zoom?(_.zoom=!1,e.repaint()):e.state.footprint>0?e.dispatch("back"):e.state.item>0&&e.dispatch("open",{item:0})};t.addEventListener("keydown",w),n.push(()=>t.removeEventListener("keydown",w));const v=y=>{const _=Number(y.userId);!Number.isFinite(_)||_<=0||(Fn(),e.dispatch("footprint",{user:_,name:y.userName}))};v(On()),n.push(Wn(v));const g=y=>{!y.kind||!(Number(y.id)>0)||(io(),e.dispatch("go",{section:y.entityId}),y.kind==="media"?e.dispatch("open",{item:y.id}):e.dispatch("into",{item:y.id}))};g(oo()),n.push(ro(g));const $=y=>{const _=Number(y.agentId);!Number.isFinite(_)||_<=0||(lo(),e.dispatch("go",{section:"agents"}),e.dispatch("open",{item:_}))};return $(ao()),n.push(co($)),jt(e.data.agentsEnabled===!0),window.wp?.hooks&&Fo(),()=>n.forEach(y=>y())}function Uo(e){const t=T().hooks;if(!t?.doAction)return;const s=e.root.querySelector("[data-mywp-group-extras]");if(s){const c=s.dataset.mywpGroupExtras??"";if(s.dataset.mywpExtrasFor!==c){s.dataset.mywpExtrasFor=c,s.replaceChildren();try{t.doAction("os.my-wordpress.group-extras",{container:s,groupId:c,group:e.data.groups.find(u=>u.id===c)??null,entityIds:e.data.sections.filter(u=>u.group===c).map(u=>u.id)})}catch(u){console.error("[my-wordpress] a group-extras subscriber threw.",u)}}}const n=ae(e.data,e.state.section);if(!n||n.kind==="agent")return;const i=new Map;for(const c of k(e).list.items())i.set(c.id,c);const o=e.data.detail,a=e.data.folder;for(const c of Array.from(e.root.querySelectorAll("[data-mywp-slot]"))){const u=c.dataset.mywpSlot??"",p=Number(c.dataset.mywpExtrasItem??0),d=`${n.id}:${u}:${p}`;if(c.dataset.mywpExtrasFor===d)continue;c.dataset.mywpExtrasFor=d,c.replaceChildren();let f=null;if(o&&o.id===p?f={...i.get(p)??{},...o}:a&&a.id===p&&(f={...i.get(p)??{},id:a.id,title:a.title,status:a.status}),!!f)try{t.doAction("os.my-wordpress.preview-extras",{slot:u,container:c,entityId:n.id,kind:n.kind,item:f})}catch(m){console.error("[my-wordpress] a preview-extras subscriber threw.",m)}}for(const c of Array.from(e.root.querySelectorAll("[data-mywp-drag][data-item-id]"))){const u=c.querySelector("os-tile"),p=Number(c.getAttribute("data-item-id")),d=i.get(p);if(!(!u||!d||u.dataset.mywpDecorated===String(p))){u.dataset.mywpDecorated=String(p);try{t.doAction("os.my-wordpress.list-tile",{tile:u,entityId:n.id,kind:n.kind,item:d})}catch(f){console.error("[my-wordpress] a list-tile subscriber threw.",f)}}}}function qo(e){const t=k(e);if(jt(e.data.agentsEnabled===!0),jo(e),t.list.sync({sentinel:e.root.querySelector("[data-mywp-sentinel]"),canvas:e.root.querySelector(".os-mywp__canvas"),load:()=>e.dispatch("more"),repaint:()=>e.repaint()}),t.revealSelection){t.revealSelection=!1;const o=e.state.item>0?e.state.item:e.state.selected[0]??0;o>0&&e.root.querySelector(`[data-item-id="${o}"]`)?.scrollIntoView?.({block:"nearest"})}for(const o of Array.from(e.root.querySelectorAll("os-context-menu.os-mywp__menu")))(t.menu||t.columnsMenu)&&no(o);const s=e.data.subDetail;let n;s?.kind==="revision"?n=s.content:s?.kind==="comment"&&(n=String(s.stats.comment?.content??""));const i=s?{id:e.state.item,content:n}:null;for(const[o,a]of[["detail",e.data.detail],["folder",e.data.folder],["sub",i]]){const c=e.root.querySelector(`[data-mywp-content="${o}"]`);if(c&&a?.content!==void 0){const u=`${a.id}:${a.content.length}`;c.dataset.mywpStamp!==u&&(c.dataset.mywpStamp=u,c.innerHTML=a.content)}}Uo(e)}function jo(e){const t=k(e),s=e.data.agents,n=ae(e.data,e.state.section);if(!(!!s&&n?.kind==="agent")||!s){for(const p of t.agentDropTargets.values())p();t.agentDropTargets.clear();return}const o=_t(s.list);if(t.rosterStamp!==o){const p=t.rosterStamp===""&&s.list.length>0;t.rosterStamp=o||"·",!p&&o!==""&&T().hooks?.doAction?.("os.agents.roster-changed")}if(t.chatAfterCreate&&!e.state.casting&&e.state.item>0){const p=s.list.find(d=>d.id===e.state.item);p&&(t.chatAfterCreate=!1,kt(s,p))}t.chatAfterCreate&&e.state.casting&&e.state.agentNotice!==""&&(t.chatAfterCreate=!1);const a=T().dragManager,c=bt(e.root),u=new Set;a?.registerDropTarget&&e.root.querySelectorAll(".dm-agents__cast-card[data-agent-id]").forEach(p=>{const d=Number.parseInt(p.dataset.agentId??"",10),f=s.list.find(m=>m.id===d);f&&(u.add(d),p.dataset.dmAgentDragOut||(p.dataset.dmAgentDragOut="1",p.addEventListener("pointerdown",m=>{if(m.button!==0||m.shiftKey||m.ctrlKey||m.metaKey||K())return;const h=T().dragManager;h&&h.start({payload:{type:"shortcut",source:p,data:{kind:"user",ref:String(d),title:f.name,icon:"dashicons-admin-users",entityId:"agents"}},origin:m})})),t.agentDropTargets.set(d,a.registerDropTarget({id:`dm-agents-row-${c}-${d}`,element:p,accept:m=>ko(bo(f.triggers),Ft(m),f.id),acceptLabel:r("Send to agent"),onDrop:m=>{const h=Ft(m.payload);h&&To({id:f.id,name:f.name,description:f.description,avatarUrl:f.avatarUrl},h,{restRoot:s.restRoot,restNonce:s.restNonce})}})))});for(const[p,d]of t.agentDropTargets)u.has(p)||(d(),t.agentDropTargets.delete(p));if(s.canManage&&!t.agentBusy){const p=s.list.find(d=>!gt(d.face)&&d.faceSeed>0&&!t.agentBackfilled.has(d.id));p&&(t.agentBackfilled.add(p.id),e.dispatch("agent-update",{id:p.id,face:$e(p.faceSeed),faceSeed:p.faceSeed}))}}function Ko(e,t,s,n,i){return e.state.footprint>0?Ys(e):t?t.kind==="agent"?to(e):n?Os(e):s?Ps(e):e.state.item>0&&K()?l`<div class="os-mywp__detail-page">${ct(e,t)}</div>`:lt(As(e,t,i),e.state.item>0?ct(e,t):null):Ss(e)}function zo(e){const{state:t}=e,s=n=>{const i=String(n.detail?.value??"");i!=="icons"&&i!=="list"||i===t.view||(k(e).revealSelection=!0,e.local("set-view",{view:i}),e.dispatch("view"))};return l`
1365 + `}const jt=8;function To(e,t){e.style.visibility="hidden";const s=()=>{e.isConnected&&(t(e.getBoundingClientRect()),e.style.visibility="")};typeof requestAnimationFrame=="function"?requestAnimationFrame(s):s()}function Co(e){To(e,t=>{t.right>window.innerWidth&&(e.style.left=`${Math.max(0,window.innerWidth-t.width-jt)}px`),t.bottom>window.innerHeight&&(e.style.top=`${Math.max(0,window.innerHeight-t.height-jt)}px`)})}const K=ce("desktop-mode/my-wordpress/open-target",()=>({kind:null,entityId:"",id:0,title:"",requestedAt:0}));function Eo(){return{...K.state}}function Io(){K.state.kind=null,K.state.entityId="",K.state.id=0,K.state.title="",K.notify()}function No(e){return K.subscribe(t=>e({...t}))}const ae=ce("desktop-mode/agents/editor-target",()=>({agentId:null,requestedAt:0}));function Do(){return{...ae.state}}function Lo(){ae.state.agentId=null,ae.state.requestedAt=0,ae.notify()}function Po(e){return ae.subscribe(t=>e({...t}))}function Ie(){const e=window.wp?.hooks;if(!e)throw new Error("[openstation] `window.wp.hooks` is not available. The plugin declares `wp-hooks` as a script dependency; if you are seeing this error, verify the enqueue order.");return e}function Ro(e,t,s,n){Ie().addFilter(e,t,s,n)}function Oo(e,t,s,n){Ie().addAction(e,t,s,n)}function Fo(e,t){return Ie().removeAction(e,t)}function Wo(e,t){return Ie().removeFilter(e,t)}const Uo="http://localhost/";function Kt(e,t){const s=typeof window<"u"&&window.location?window.location.href:Uo,n=new URL(e,s),o=t.replace(/^\/+/,""),i=o.indexOf("?"),a=i===-1?o:o.slice(0,i),l=i===-1?"":o.slice(i+1);if(n.searchParams.has("rest_route")){const u=n.searchParams.get("rest_route")??"/",d=u.endsWith("/")?u:u+"/";n.searchParams.set("rest_route",d+a)}else{const u=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";n.pathname=u+a}return l&&new URLSearchParams(l).forEach((d,p)=>{n.searchParams.append(p,d)}),n.toString()}function qo(){const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]%16+64,e[8]=e[8]%64+128;const t=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}class Q extends Xe{constructor(t,s,n=new Xe("",{status:0})){super(t,{status:n.status,code:n.code,data:n.data,serverMessage:n.serverMessage}),this.name="JobRequestError",this.retryable=s}}async function Bo(e,t,s){const n=new AbortController,o=window.setTimeout(()=>n.abort(),15e3);try{const i=await He(Kt(e.restRoot,t),{method:s?"POST":"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":e.restNonce},body:s?JSON.stringify(s):void 0,signal:n.signal,cache:"no-store"},{source:"desktop-mode/agents",silent:!s}),a=await i.json().catch(()=>null);if(!i.ok)throw new Q(a?.message||`HTTP ${i.status}`,i.status>=500&&!a?.code||i.status===408,se(i.status,a));if(!a||!a.jobId&&typeof a.text!="string")throw new Q(r("The job status could not be read.","desktop-mode"),!0,se(i.status,null));return a}finally{window.clearTimeout(o)}}function jo(e){return new Promise(t=>window.setTimeout(t,e))}async function Ko(e,t,s,n,o=()=>{}){const i=`desktop-mode/v1/agents/${e}`,a=Date.now()+2*60*60*1e3;let l=!1,u=2e3;for(;Date.now()<a;){try{const d=await Bo(s,l?`${i}/jobs/${n}`:`${i}/invoke`,l?void 0:{...t,async:!0,requestId:n});if(!("jobId"in d))return d;if(d.jobId!==n)throw new Q(r("The server returned a different job.","desktop-mode"),!1);if(l=!0,d.status==="completed"&&d.result)return d.result;if(d.status==="failed")throw new Q(d.error?.message||r("The agent job failed.","desktop-mode"),!1);if(d.status!=="queued"&&d.status!=="running")throw new Q(r("The server returned an invalid job state.","desktop-mode"),!1);o(d.status),u=Math.min(1e4,Math.max(u*1.25,(d.pollAfter||3)*1e3))}catch(d){if(d instanceof Q&&!d.retryable)throw d;o("reconnecting"),u=Math.min(u*2,3e4)}await jo(document.hidden?Math.max(u,15e3):u)}throw new Error(r("The background job has not returned a result. Some work may already have been applied. Check the site before submitting again.","desktop-mode"))}const zt="desktop-mode/v1/agents/conversations";async function Ht(e,t,s={}){const n=await He(Kt(e.restRoot,t),{...s,headers:{"Content-Type":"application/json","X-WP-Nonce":e.restNonce,...s.headers??{}}},{source:"desktop-mode/agents",silent:!0}),o=await n.json().catch(()=>null);if(!n.ok)throw se(n.status,o);return o}function zo(e){return e.filter(t=>!t.pending)}async function Ho(e,t){const s=P.state,n=zo(s.transcripts[e.id]??[]);if(n.length!==0){s.conversationIds||(s.conversationIds={});try{const o=s.conversationIds[e.id];if(o)await Ht(t,`${zt}/${o}`,{method:"PUT",body:JSON.stringify({messages:n})});else{const i=await Ht(t,zt,{method:"POST",body:JSON.stringify({agentId:e.id,messages:n})});s.conversationIds[e.id]=i.id}s.conversationsRev=(s.conversationsRev??0)+1,P.notify()}catch(o){console.warn("[desktop-mode/agents] conversation save failed:",o)}}}const Xt={post:"post",page:"page",attachment:"media",media:"media",user:"user",comment:"comment"};function Yt(e){const t=Number.parseInt(String(e??""),10);return Number.isFinite(t)&&t>0?t:0}function Gt(e){if(e.type==="shortcut"){const t=e.data;let s=Xt[String(t.kind??"")];s==="post"&&t.bridgePayload?.postType==="page"&&(s="page");const n=Yt(t.ref);return!s||!n?null:{kind:s,id:n,title:String(t.title??"")||`#${n}`}}if(e.type==="desktop-file"){const s=e.data.placement?.file;if(!s)return null;const n=Xt[String(s.type??"")],o=Yt(s.ref);return!n||!o?null:{kind:n,id:o,title:String(s.title??"")||`#${o}`}}return null}function Xo(e){const t=e.find(n=>n.kind==="drag");if(!t)return null;const s=t.config?.entityKinds;return Array.isArray(s)?s.map(String):[]}function Yo(e,t,s){return!t||s&&t.kind==="user"&&t.id===s||e==null?!1:e.length===0?!0:e.includes(t.kind)}function Go(e){return b(r('The user dropped the %1$s "%2$s" (id %3$s) onto you. Handle it according to your instructions, using your tools as needed.',"desktop-mode"),e.kind,e.title,String(e.id))}function Vo(e){return b(r('The user sent you the %1$s "%2$s" (id %3$s) from the "Send to" menu. Handle it according to your instructions, using your tools as needed.',"desktop-mode"),e.kind,e.title,String(e.id))}function Qo(e,t,s){return Qt(e,"agents-send-to"),Jt(e,Vo(t),s,"send-to",Vt(t))}function Vt(e){return{kind:e.kind,id:e.id,title:e.title}}function Qt(e,t="agents"){Ve(e);const s=window.wp?.os?.openWindow;typeof s=="function"&&s("desktop-mode-agent-run",{source:t})}async function Jt(e,t,s,n,o){Ve(e);const i=P.state.transcripts[e.id],a=r("The agent finished without a text answer.","desktop-mode"),l=i.filter(d=>!d.pending&&d.role!=="error"&&!(d.role==="agent"&&d.text===a)).map(d=>({role:d.role,text:d.text}));i.push({role:"user",text:t,at:Date.now(),attachment:o});const u={role:"agent",text:r("Working…","desktop-mode"),at:Date.now(),pending:!0};i.push(u),P.notify();try{const d=await Ko(e.id,{message:t,source:n,history:l},s,qo(),p=>{const f={queued:r("Queued — waiting for a WordPress worker…","desktop-mode"),reconnecting:r("Reconnecting to the background job…","desktop-mode"),running:r("Working in the background…","desktop-mode")};u.text=f[p],P.notify()});d.text?.trim()?u.text=d.text:(u.role="error",u.text=a),u.toolCalls=d.toolCalls,Array.isArray(d.callToActions)&&d.callToActions.length>0&&(u.callToActions=d.callToActions)}catch(d){u.role="error",u.text=d instanceof Error?d.message:String(d)}u.pending=!1,P.notify(),Ho(e,s)}function Jo(e,t,s){return Qt(e,"agents-drop"),Jt(e,Go(t),s,"drag",Vt(t))}const Zo={source:"desktop-mode/agents"};function Zt(){const e=window.wp?.os?.config;return{restRoot:String(e?.restUrl??""),restNonce:String(e?.restNonce??"")}}function xo(e=""){return`${Zt().restRoot.replace(/\/+$/,"")}/desktop-mode/v1/agents${e}`}async function ei(e,t={}){const s=await He(e,{...t,headers:{"Content-Type":"application/json","X-WP-Nonce":Zt().restNonce,...t.headers||{}}},Zo),n=await s.json().catch(()=>null);if(!s.ok)throw se(s.status,n);return n}function ti(){return ei(xo())}let z=null,xe=!1,et=null;function xt(e){et===!1&&e&&(z=null),et=e}function si(){return et===!0}async function tt(){if(!(xe||z!==null||!si())){xe=!0;try{z=await ti()}catch{z=[]}finally{xe=!1}}}function ni(){z=null,tt()}function oi(e){return z===null?(tt(),[]):z.filter(t=>{const s=t.triggers.find(o=>o.kind==="send-to");if(!s)return!1;const n=Array.isArray(s.config?.entityKinds)?s.config.entityKinds:[];return n.length===0||n.includes(e)})}function ii(e){return e.kind==="user"?"user":e.kind==="attachment"||e.kind==="media"?"media":e.kind==="post"?e.entityId==="pages"?"page":"post":null}function ri(e){const t=e.title?.rendered;if(typeof t=="string"&&t!==""){const s=document.createElement("div");return s.innerHTML=t,s.textContent??""}return typeof e.title=="string"&&e.title!==""?e.title:typeof e.name=="string"&&e.name!==""?e.name:""}const Ne="desktop-mode/agents-send-to";function ai(){Wo("os.my-wordpress.tile-context-menu",Ne),Ro("os.my-wordpress.tile-context-menu",Ne,li),Fo("os.agents.roster-changed",Ne),Oo("os.agents.roster-changed",Ne,()=>{ni()}),tt()}function li(e,t){const s=ii(t);if(!s)return e;const n=Number.parseInt(String(t.item?.id??""),10);if(!n)return e;const o=oi(s);if(o.length===0)return e;const i=ri(t.item)||`#${n}`;return[...e,...o.map(a=>({id:`agent-send-to-${a.id}`,label:b(r("Send to %s","desktop-mode"),a.name),icon:"dashicons-share-alt",onSelect:()=>{const l=window.wp?.os?.config;Qo({id:a.id,name:a.name,description:a.description,avatarUrl:a.avatarUrl},{kind:s,id:n,title:i},{restRoot:String(l?.restUrl??""),restNonce:String(l?.restNonce??"")})}}))]}function di(e,t){if(!(!e||!t.link)){if(e.kind==="media")return{kind:"attachment",id:t.id,url:t.link,title:t.title,alt:t.alt??"",mime:t.mime,thumbnailUrl:t.thumb||void 0};if(e.kind==="user")return{kind:"user",id:t.id,url:t.link,title:t.title};if(e.kind==="post"&&!e.flat)return{kind:"post",id:t.id,postType:e.post_type,url:t.link,title:t.title}}}function ci(e){const{root:t}=e,s=k(e),n=[],o=y=>{if(y.button!==0||y.shiftKey||y.ctrlKey||y.metaKey||H())return;const v=y.target?.closest("[data-mywp-drag][data-item-id]");if(!v)return;const M=T().dragManager;if(!M)return;const S=Number(v.getAttribute("data-item-id")),A=v.getAttribute("data-mywp-drag")??"",N=s.list.items(),R=N.find(q=>q.id===S);if(!R)return;const J=X(e.data,e.state.section),De=J?.id??"",U=String(J?.restPath??""),Z=e.state.selected.includes(S)?N.filter(q=>e.state.selected.includes(q.id)):[R];M.start({payload:{type:"shortcut",source:v,data:{kind:A,ref:String(R.id),title:R.title,icon:R.thumb||"",entityId:De,restPath:U,bridgePayload:di(J,R),...Z.length>1?{items:Z.map(q=>({kind:A,ref:String(q.id),title:q.title,icon:q.thumb||"",entityId:De,restPath:U}))}:{}}},origin:y})};t.addEventListener("pointerdown",o),n.push(()=>t.removeEventListener("pointerdown",o)),H()||n.push(fs({root:t,canvas:".os-mywp__canvas",className:"os-mywp__marquee",select:y=>e.local("select-set",{ids:y})})),n.push(()=>s.list.dispose());const i=T().hooks,a=`openstation-apps/my-wordpress/${Pt(t)}`;i?.addAction?.("os.extended-options.changed",a,y=>{const v=y?.options;v&&typeof v.agents=="boolean"&&e.dispatch("refresh")}),n.push(()=>{i?.removeAction?.("os.extended-options.changed",a);for(const y of s.agentDropTargets.values())y();s.agentDropTargets.clear()});let l=null,u=0;const d=()=>{l?.remove(),l=null,u=0},p=(y,v)=>{let S=v.clientX+16,A=v.clientY+16;const N=y.getBoundingClientRect();S+N.width>window.innerWidth-8&&(S=Math.max(8,v.clientX-N.width-16)),A+N.height>window.innerHeight-8&&(A=Math.max(8,v.clientY-N.height-16)),y.style.left=`${S}px`,y.style.top=`${A}px`},f=y=>{const v=document.createElement("div");v.className="os-my-wordpress__tooltip",v.setAttribute("role","tooltip");const M=document.createElement("div");if(M.className="os-my-wordpress__tooltip-title",M.textContent=y.title,v.appendChild(M),y.lockedBy){const A=document.createElement("div");A.className="os-my-wordpress__tooltip-lock";const N=document.createElement("span");N.className="dashicons dashicons-lock",N.setAttribute("aria-hidden","true"),A.appendChild(N);const R=document.createElement("span");R.textContent=b(r("%s is currently editing"),y.lockedBy),A.appendChild(R),v.appendChild(A)}if(y.thumb){const A=document.createElement("img");A.className="os-my-wordpress__tooltip-thumb",A.src=y.thumb,A.alt="",v.appendChild(A)}const S=y.excerpt||y.subtitle;if(S){const A=document.createElement("p");A.className="os-my-wordpress__tooltip-excerpt",A.textContent=S.length>240?S.slice(0,237)+"…":S,v.appendChild(A)}return v},m=y=>{const v=y.target?.closest("[data-mywp-drag][data-item-id]");if(!v||v.closest("[data-mywp-list]"))return;const M=Number(v.getAttribute("data-item-id"));if(M===u)return;const S=s.list.items().find(N=>N.id===M);if(!S)return;d(),u=M;const A=i?.applyFilters("os.my-wordpress.hover-card",null,S,{build:f,cell:v,event:y});A instanceof HTMLElement&&(l=A,document.body.appendChild(l),p(l,y))},h=y=>{if(!l)return;if(!y.target?.closest("[data-mywp-drag][data-item-id]")){d();return}p(l,y)};t.addEventListener("mouseover",m),t.addEventListener("mousemove",h),t.addEventListener("mouseleave",d),t.addEventListener("pointerdown",d),t.addEventListener("contextmenu",d),n.push(()=>{t.removeEventListener("mouseover",m),t.removeEventListener("mousemove",h),t.removeEventListener("mouseleave",d),t.removeEventListener("pointerdown",d),t.removeEventListener("contextmenu",d),d()});const $=y=>{if(y.key!=="Escape")return;const v=k(e);v.menu?(v.menu=null,e.repaint()):v.columnsMenu?(v.columnsMenu=null,e.repaint()):v.zoom?(v.zoom=!1,e.repaint()):e.state.footprint>0?e.dispatch("back"):e.state.item>0&&O(e,0)};t.addEventListener("keydown",$),n.push(()=>t.removeEventListener("keydown",$));const _=y=>{const v=Number(y.userId);!Number.isFinite(v)||v<=0||(ao(),Number(e.state.footprint)!==v&&e.dispatch("footprint",{user:v,name:y.userName}))};_(ro()),n.push(lo(_));const w=y=>{!y.kind||!(Number(y.id)>0)||(Io(),e.dispatch("go",{section:y.entityId}),y.kind==="media"?e.dispatch("open",{item:y.id}):e.dispatch("into",{item:y.id}))};w(Eo()),n.push(No(w));const g=y=>{const v=Number(y.agentId);!Number.isFinite(v)||v<=0||(Lo(),e.dispatch("go",{section:"agents"}),e.dispatch("open",{item:v}))};return g(Do()),n.push(Po(g)),xt(e.data.agentsEnabled===!0),window.wp?.hooks&&ai(),()=>n.forEach(y=>y())}function ui(e){const t=T().hooks;if(!t?.doAction)return;const s=e.root.querySelector("[data-mywp-group-extras]");if(s){const l=s.dataset.mywpGroupExtras??"";if(s.dataset.mywpExtrasFor!==l){s.dataset.mywpExtrasFor=l,s.replaceChildren();try{t.doAction("os.my-wordpress.group-extras",{container:s,groupId:l,group:e.data.groups.find(u=>u.id===l)??null,entityIds:e.data.sections.filter(u=>u.group===l).map(u=>u.id)})}catch(u){console.error("[my-wordpress] a group-extras subscriber threw.",u)}}}const n=X(e.data,e.state.section);if(!n||n.kind==="agent")return;const o=new Map;for(const l of k(e).list.items())o.set(l.id,l);const i=e.data.detail,a=e.data.folder;for(const l of Array.from(e.root.querySelectorAll("[data-mywp-slot]"))){const u=l.dataset.mywpSlot??"",d=Number(l.dataset.mywpExtrasItem??0),p=`${n.id}:${u}:${d}`;if(l.dataset.mywpExtrasFor===p)continue;l.dataset.mywpExtrasFor=p,l.replaceChildren();let f=null;if(i&&i.id===d?f={...o.get(d)??{},...i}:a&&a.id===d&&(f={...o.get(d)??{},id:a.id,title:a.title,status:a.status}),!!f)try{t.doAction("os.my-wordpress.preview-extras",{slot:u,container:l,entityId:n.id,kind:n.kind,item:f})}catch(m){console.error("[my-wordpress] a preview-extras subscriber threw.",m)}}for(const l of Array.from(e.root.querySelectorAll("[data-mywp-drag][data-item-id]"))){const u=l.querySelector("os-tile"),d=Number(l.getAttribute("data-item-id")),p=o.get(d);if(!(!u||!p||u.dataset.mywpDecorated===String(d))){u.dataset.mywpDecorated=String(d);try{t.doAction("os.my-wordpress.list-tile",{tile:u,entityId:n.id,kind:n.kind,item:p})}catch(f){console.error("[my-wordpress] a list-tile subscriber threw.",f)}}}}function pi(e){const t=k(e);if(xt(e.data.agentsEnabled===!0),fi(e),t.list.sync({sentinel:e.root.querySelector("[data-mywp-sentinel]"),canvas:e.root.querySelector(".os-mywp__canvas"),load:()=>e.dispatch("more"),repaint:()=>e.repaint()}),t.revealSelection){t.revealSelection=!1;const i=e.state.item>0?e.state.item:e.state.selected[0]??0;i>0&&e.root.querySelector(`[data-item-id="${i}"]`)?.scrollIntoView?.({block:"nearest"})}for(const i of Array.from(e.root.querySelectorAll("os-context-menu.os-mywp__menu")))(t.menu||t.columnsMenu)&&Co(i);const s=e.data.subDetail;let n;s?.kind==="revision"?n=s.content:s?.kind==="comment"&&(n=String(s.stats.comment?.content??""));const o=s?{id:e.state.item,content:n}:null;for(const[i,a]of[["detail",mt(e)],["folder",e.data.folder],["sub",o]]){const l=e.root.querySelector(`[data-mywp-content="${i}"]`);if(l&&a?.content!==void 0){const u=`${a.id}:${a.content.length}`;l.dataset.mywpStamp!==u&&(l.dataset.mywpStamp=u,l.innerHTML=a.content)}}ui(e)}function fi(e){const t=k(e),s=e.data.agents,n=X(e.data,e.state.section);if(!(!!s&&n?.kind==="agent")||!s){for(const d of t.agentDropTargets.values())d();t.agentDropTargets.clear();return}const i=Dt(s.list);if(t.rosterStamp!==i){const d=t.rosterStamp===""&&s.list.length>0;t.rosterStamp=i||"·",!d&&i!==""&&T().hooks?.doAction?.("os.agents.roster-changed")}if(t.chatAfterCreate&&!e.state.casting&&e.state.item>0){const d=s.list.find(p=>p.id===e.state.item);d&&(t.chatAfterCreate=!1,Rt(s,d))}t.chatAfterCreate&&e.state.casting&&e.state.agentNotice!==""&&(t.chatAfterCreate=!1);const a=T().dragManager,l=Pt(e.root),u=new Set;a?.registerDropTarget&&e.root.querySelectorAll(".dm-agents__cast-card[data-agent-id]").forEach(d=>{const p=Number.parseInt(d.dataset.agentId??"",10),f=s.list.find(m=>m.id===p);f&&(u.add(p),d.dataset.dmAgentDragOut||(d.dataset.dmAgentDragOut="1",d.addEventListener("pointerdown",m=>{if(m.button!==0||m.shiftKey||m.ctrlKey||m.metaKey||H())return;const h=T().dragManager;h&&h.start({payload:{type:"shortcut",source:d,data:{kind:"user",ref:String(p),title:f.name,icon:"dashicons-admin-users",entityId:"agents"}},origin:m})})),t.agentDropTargets.set(p,a.registerDropTarget({id:`dm-agents-row-${l}-${p}`,element:d,accept:m=>Yo(Xo(f.triggers),Gt(m),f.id),acceptLabel:r("Send to agent"),onDrop:m=>{const h=Gt(m.payload);h&&Jo({id:f.id,name:f.name,description:f.description,avatarUrl:f.avatarUrl},h,{restRoot:s.restRoot,restNonce:s.restNonce})}})))});for(const[d,p]of t.agentDropTargets)u.has(d)||(p(),t.agentDropTargets.delete(d));if(s.canManage&&!t.agentBusy){const d=s.list.find(p=>!Et(p.face)&&p.faceSeed>0&&!t.agentBackfilled.has(p.id));d&&(t.agentBackfilled.add(d.id),e.dispatch("agent-update",{id:d.id,face:Me(d.faceSeed),faceSeed:d.faceSeed}))}}function mi(e,t,s,n,o){return e.state.footprint>0?wn(e):t?t.kind==="agent"?Mo(e):n?tn(e):s?xs(e):e.state.item>0&&!ge(t,e.state.item)&&H()?c`<div class="os-mywp__detail-page">${_t(e,t)}</div>`:vt(zs(e,t,o),e.state.item>0&&!ge(t,e.state.item)?_t(e,t):null):Ks(e)}function hi(e){const{state:t}=e,s=n=>{const o=String(n.detail?.value??"");o!=="icons"&&o!=="list"||o===t.view||(k(e).revealSelection=!0,e.local("set-view",{view:o}),e.dispatch("view"))};return c`
1363 1366 <os-segmented
1364 1367 class="os-mywp__view-switch"
1365 1368 value=${t.view}
1366 1369 label=${r("View as")}
@@ -1374,29 +1377,31 @@
1374 1377 <span class="dashicons dashicons-list-view" aria-hidden="true"></span>
1375 1378 <span class="os-mywp__view-label">${r("List")}</span>
1376 1379 </os-segment>
1377 1380 </os-segmented>
1378 - `}const Ho=rs("my-wordpress",{local:{select:(e,t)=>{const s=Array.isArray(t.order)?t.order:[];e.selected=Je(e.selected,s,Number(t.item),{ctrl:!!t.ctrl,shift:!!t.shift})},"select-set":(e,t)=>{e.selected=(Array.isArray(t.ids)?t.ids:[]).slice()},"clear-select":e=>{e.selected=[]},"set-sort":(e,t)=>{e.sort=String(t.sort??"")},"set-view":(e,t)=>{e.view=t.view==="list"?"list":"icons",e.view==="list"&&e.sort===""&&(e.sort="id-desc",e.page=1)},"agent-start":(e,t,s)=>{const n=t.from??null,i=An(),o=yt(wt(s.agents?.roles??null),i);n&&(o.name=b(r("%s copy"),n.name),o.description=n.description,o.vibes=n.vibes,o.instructions=n.instructions,o.role=n.role,o.abilities=[...n.abilities],o.triggers=n.triggers.map(a=>({kind:a.kind,config:{...a.config}})),o.copiedFrom=n.name),e.casting=!0,e.item=0,e.wstep=n?1:0,e.cast=o,e.agentNotice="",e.briefError=""},"agent-cancel":e=>{e.casting=!1,e.wstep=0,e.cast=null,e.agentNotice="",e.briefError=""},"agent-step":(e,t)=>{e.wstep=Math.max(0,Math.min(4,Number(t.step))),e.agentNotice=""},"agent-pane":(e,t)=>{const s=String(t.pane??"define");e.pane=["define","tools","triggers"].includes(s)?s:"define",e.agentNotice=""},"agent-wiz":(e,t)=>{e.cast={...e.cast??{},...t}},"agent-brief-error":(e,t)=>{e.briefError=String(t.msg??"")},"agent-notice":(e,t)=>{e.agentNotice=String(t.notice??"")}},view:e=>{const{state:t,data:s}=e,n=ae(s,t.section),i=s.groups.find(A=>A.id===t.group)??null,o=t.footprint>0,a=!!(i||n)||o,c=(A,M)=>l`<button type="button" class="os-mywp__crumb-link" @click=${M}>${A}</button>`,u=A=>l`<span class="os-mywp__crumb-current" aria-current="page">${A}</span>`,p=()=>l`<span class="os-mywp__sep" aria-hidden="true">›</span>`,d=n&&t.into>0,f=d&&t.relation!=="",m=!!n&&!d&&n.kind!=="agent"&&t.item>0&&K(),h=[];a?(h.push(c(s.siteName,()=>void e.dispatch("go"))),i&&(h.push(p()),h.push(n?c(i.label,()=>void e.dispatch("go",{group:i.id})):u(i.label))),n&&(h.push(p()),h.push(d||o||m?c(n.label,()=>void e.dispatch("go",{group:t.group,section:n.id})):u(n.label))),m&&s.detail&&(h.push(p()),h.push(u(s.detail.title))),o&&(h.push(p()),h.push(u(t.fpName||r("Activity footprint")))),d&&s.folder&&(h.push(p()),h.push(f?c(s.folder.title,()=>void e.dispatch("relation",{relation:""})):u(s.folder.title))),f&&s.sub&&(h.push(p()),h.push(u(s.sub.label)))):h.push(u(s.siteName));const w=n&&!d?k(e).list.accumulate(xe(t),s.list):[],v=w.length;let g=null;f&&s.sub?g=[b(B("%d item","%d items",s.sub.rows.length),s.sub.rows.length),""]:d&&s.folder&&(g=[b(r("%d folders"),s.folder.folders.length),s.folder.status]);const $=n?.kind==="agent";$&&(g=s.agents?.enabled?[b(B("%d agent","%d agents",s.agents.list.length),s.agents.list.length),""]:["",""]),o&&(g=Ws(e));const y=n&&!d?`${b(r("%1$d of %2$d items"),v,s.list?.total??0)}${t.selected.length>0?" — "+b(r("%d selected"),t.selected.length):""}`:b(r("%d folders"),t.group?s.sections.filter(A=>A.group===t.group).length:s.sections.filter(A=>!A.group).length+s.groups.length);let _=n&&!d?b(r("Page %1$d of %2$d"),s.list?.page??1,s.list?.pages??1):"";return n&&!d&&!$&&t.view==="list"&&(_=[ks(e,n),bs(e),_].filter(Boolean).join(" · ")),l`
1381 + `}const gi=ys("my-wordpress",{local:{"search-query":(e,t)=>{e.query=String(t.value??""),e.page=1,e.item=0,e.selected=[]},preview:(e,t)=>{e.item=Number(t.item)||0,e.pane="define",e.agentNotice=""},select:(e,t)=>{const s=Array.isArray(t.order)?t.order:[];e.selected=at(e.selected,s,Number(t.item),{ctrl:!!t.ctrl,shift:!!t.shift})},"select-set":(e,t)=>{e.selected=(Array.isArray(t.ids)?t.ids:[]).slice()},"clear-select":e=>{e.selected=[]},"set-sort":(e,t)=>{e.sort=String(t.sort??"")},"set-view":(e,t)=>{e.view=t.view==="list"?"list":"icons",e.view==="list"&&e.sort===""&&(e.sort="id-desc",e.page=1)},"agent-start":(e,t,s)=>{const n=t.from??null,o=Vn(),i=It(Nt(s.agents?.roles??null),o);n&&(i.name=b(r("%s copy"),n.name),i.description=n.description,i.vibes=n.vibes,i.instructions=n.instructions,i.brief=n.instructions,i.role=n.role,i.abilities=[...n.abilities],i.triggers=n.triggers.map(a=>({kind:a.kind,config:{...a.config}})),i.copiedFrom=n.name),e.casting=!0,e.item=0,e.wstep=n?1:0,e.cast=i,e.agentNotice="",e.briefError=""},"agent-cancel":e=>{e.casting=!1,e.wstep=0,e.cast=null,e.agentNotice="",e.briefError=""},"agent-step":(e,t)=>{const s=Math.max(0,Math.min(4,Number(t.step)));e.wstep===0&&s!==0&&e.cast&&(e.cast={...e.cast,instructions:String(e.cast.brief??"").trim()}),e.wstep=s,e.agentNotice=""},"agent-pane":(e,t)=>{const s=String(t.pane??"define");e.pane=["define","tools","triggers"].includes(s)?s:"define",e.agentNotice=""},"agent-wiz":(e,t)=>{e.cast={...e.cast??{},...t}},"agent-brief-error":(e,t)=>{e.briefError=String(t.msg??"")},"agent-notice":(e,t)=>{e.agentNotice=String(t.notice??"")}},view:e=>{e=ft(e);const{state:t,data:s}=e,n=X(s,t.section),o=s.groups.find(S=>S.id===t.group)??null,i=t.footprint>0,a=!!(o||n)||i,l=(S,A)=>c`<button type="button" class="os-mywp__crumb-link" @click=${A}>${S}</button>`,u=S=>c`<span class="os-mywp__crumb-current" aria-current="page">${S}</span>`,d=()=>c`<span class="os-mywp__sep" aria-hidden="true">›</span>`,p=n&&t.into>0,f=p&&t.relation!=="",m=!!n&&!p&&n.kind!=="agent"&&t.item>0&&H(),h=[];a?(h.push(l(s.siteName,()=>void e.dispatch("go"))),o&&(h.push(d()),h.push(n?l(o.label,()=>void e.dispatch("go",{group:o.id})):u(o.label))),n&&(h.push(d()),h.push(p||i||m?l(n.label,()=>void e.dispatch("go",{group:t.group,section:n.id})):u(n.label))),m&&s.detail&&(h.push(d()),h.push(u(s.detail.title))),i&&(h.push(d()),h.push(u(t.fpName||r("Activity footprint")))),p&&s.folder&&(h.push(d()),h.push(f?l(s.folder.title,()=>void e.dispatch("relation",{relation:""})):u(s.folder.title))),f&&s.sub&&(h.push(d()),h.push(u(s.sub.label)))):h.push(u(s.siteName));const $=n&&!p?As(e,n,k(e).list.accumulate(fe(t),s.list)):[],_=$.length,w=n?t.selected.filter(S=>!ge(n,S)).length:t.selected.length;let g=null;f&&s.sub?g=[b(B("%d item","%d items",s.sub.rows.length),s.sub.rows.length),""]:p&&s.folder&&(g=[b(r("%d folders"),s.folder.folders.length),s.folder.status]);const y=n?.kind==="agent";y&&(g=s.agents?.enabled?[b(B("%d agent","%d agents",s.agents.list.length),s.agents.list.length),""]:["",""]),i&&(g=cn(e));const v=n&&!p?`${b(r("%1$d of %2$d items"),_,s.list?.total??0)}${w>0?" — "+b(r("%d selected"),w):""}`:b(r("%d folders"),t.group?s.sections.filter(S=>S.group===t.group).length:s.sections.filter(S=>!S.group).length+s.groups.length);let M=n&&!p?b(r("Page %1$d of %2$d"),s.list?.page??1,s.list?.pages??1):"";return n&&!p&&!y&&t.view==="list"&&(M=[js(e,n),Bs(e),M].filter(Boolean).join(" · ")),c`
1379 1382 <div class="os-mywp" tabindex="-1">
1380 1383 <header class="os-mywp__header">
1381 - ${a?l`<button
1384 + ${a?c`<button
1382 1385 type="button"
1383 1386 class="os-mywp__back"
1384 1387 aria-label=${r("Back")}
1385 - @click=${()=>void e.dispatch(m?"open":"back",m?{item:0}:void 0)}
1388 + @click=${()=>m?O(e,0):void e.dispatch("back")}
1386 1389 >‹</button>`:""}
1387 1390 <nav class="os-mywp__crumbs">${h}</nav>
1388 1391 </header>
1389 - ${n&&!d&&!$&&!o?l`<div class="os-mywp__search">
1392 + ${n&&!p&&!y&&!i?c`<div class="os-mywp__search">
1390 1393 <os-text-field
1394 + label=${r("Search this section")}
1395 + hide-label
1391 1396 value=${t.query}
1392 1397 placeholder=${b(r("Search %s…"),n.label.toLowerCase())}
1393 1398 clearable
1394 - os-bind="query"
1395 - os-action="search"
1399 + @os-input-change=${S=>e.local("search-query",S.detail)}
1400 + os-action="refresh"
1396 1401 ></os-text-field>
1397 - ${zo(e)}
1398 - ${n.kind==="user"&&n.canAdd?l`<os-button
1402 + ${hi(e)}
1403 + ${n.kind==="user"&&n.canAdd?c`<os-button
1399 1404 variant="secondary"
1400 1405 class="os-mywp__add-user"
1401 1406 @click=${()=>void e.dispatch("add-user")}
1402 1407 >
@@ -1403,16 +1408,16 @@
1403 1408 ${r("Add user")}
1404 1409 </os-button>`:""}
1405 1410 </div>`:""}
1406 1411 <div class="os-mywp__body">
1407 - ${Ko(e,n,!!d,!!f,w)}
1412 + ${mi(e,n,!!p,!!f,$)}
1408 1413 </div>
1409 1414 <footer class="os-mywp__status">
1410 - <span>${g?g[0]:y}</span>
1411 - <span>${g?g[1]:_}</span>
1415 + <span>${g?g[0]:v}</span>
1416 + <span>${g?g[1]:M}</span>
1412 1417 </footer>
1413 - ${n&&!$?Ms(e,n):""}
1414 - ${vs(e,n)}
1415 - ${Ts(e,n)}
1416 - ${Cs(e)}
1418 + ${n&&!y?Hs(e,n):""}
1419 + ${qs(e,n)}
1420 + ${Xs(e,n)}
1421 + ${Ys(e)}
1417 1422 </div>
1418 - `},mounted:e=>{const t=Bo(e),s=()=>e.repaint();return document.addEventListener("os-mode-changed",s),()=>{t(),document.removeEventListener("os-mode-changed",s)}},updated:e=>qo(e)});return E.agentDefaultRole=wt,E.agentFaceSrc=ye,E.agentsRosterStamp=_t,E.applySelection=Je,E.buildMenuOptions=nt,E.columnsFor=de,E.default=Ho,E.emptyCast=yt,E.hiddenFor=ue,E.listKey=xe,E.nextSort=at,E.resolveActions=re,E.resolveBanding=tt,E.withSendToHeading=st,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),E}({});
1423 + `},mounted:e=>{const t=ci(e),s=Ms(e),n=()=>e.repaint();return document.addEventListener("os-mode-changed",n),()=>{s(),t(),document.removeEventListener("os-mode-changed",n)}},updated:e=>pi(e)});return E.agentDefaultRole=Nt,E.agentFaceSrc=Te,E.agentsRosterStamp=Dt,E.applySelection=at,E.buildMenuOptions=pt,E.columnsFor=we,E.default=gi,E.emptyCast=It,E.hiddenFor=ve,E.listKey=fe,E.nextSort=wt,E.resolveActions=me,E.resolveBanding=ct,E.withSendToHeading=ut,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),E}({});