| @@ -1,30 +1,30 @@ | ||
| 1 | -(function(){"use strict";const at="desktop-mode";function ke(){return window.wp?.i18n}function y(o,e=at){return ke()?.__(o,e)??o}function we(o,...e){const t=ke()?.sprintf;if(t)return t(o,...e);let n=0;return o.replace(/%(?:(\d+)\$)?[sd]/g,(s,i)=>{const r=i?Number.parseInt(i,10)-1:n++;return String(e[r]??"")})}function ct(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function ue(o){return o.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>/^https?:\/\//i.test(n.trim())?`<a href="${n.trim()}" target="_blank" rel="noopener noreferrer">${t}</a>`:t).replace(/\*\*([^*\n]+?)\*\*/g,"<strong>$1</strong>").replace(/(?<![*\w])\*([^*\n]+?)\*(?![*\w])/g,"<em>$1</em>").replace(/(?<![_\w])_([^_\n]+?)_(?![_\w])/g,"<em>$1</em>").replace(/`([^`\n]+?)`/g,"<code>$1</code>")}function lt(o){if(!o)return"";const e=ct(o),t=[];let n=[],s=null;const i=()=>{n.length>0&&(t.push(`<p>${n.join("<br>")}</p>`),n=[])},r=()=>{s&&(t.push(`<${s.tag}>${s.items.join("")}</${s.tag}>`),s=null)};for(const l of e.split(/\n/)){const a=l.trim();if(a===""){i(),r();continue}const d=/^(#{1,6})\s+(.*)$/.exec(a);if(d){i(),r();const v=Math.min(6,d[1].length+2);t.push(`<h${v}>${ue(d[2])}</h${v}>`);continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(a)){i(),r(),t.push("<hr>");continue}const u=/^[-*]\s+(.*)$/.exec(a),p=/^\d+\.\s+(.*)$/.exec(a);if(u||p){i();const v=u?"ul":"ol";(!s||s.tag!==v)&&(r(),s={tag:v,items:[]}),s.items.push(`<li>${ue((u??p)[1])}</li>`);continue}r(),n.push(ue(a))}return i(),r(),t.join("")}function k(o,...e){return{__wpdHtml:!0,strings:o,values:e}}function dt(o){return!!o&&o.__wpdHtml===!0}const ut="$$wpd$$",S=/\$\$wpd\$\$(\d+)\$\$/g,ht="$$wpd-node$$",pt=/^\$\$wpd-node\$\$(\d+)\$\$$/,ft=new Set(["style","script","textarea","title"]);function mt(o){let e="",t=!1,n=null,s=!1,i=null,r="",l=!1;for(let a=0;a<o.length;a++){const d=o[a];e+=d;for(let u=0;u<d.length;u++){const p=d[u];if(s){d.startsWith("-->",u)&&(s=!1,u+=2);continue}if(i!==null){p==="<"&&d[u+1]==="/"&&d.slice(u+2,u+2+i.length).toLowerCase()===i&&(u+=1+i.length,i=null,t=!0,l=!1,r="");continue}if(n!==null){p===n&&(n=null);continue}if(t){p==='"'||p==="'"?(n=p,l=!1):p===">"?(t=!1,l=!1,ft.has(r)&&(i=r),r=""):l&&(/[a-zA-Z0-9-]/.test(p)?r+=p.toLowerCase():l=!1);continue}if(d.startsWith("<!--",u)){s=!0,u+=3;continue}const v=d[u+1]??"";p==="<"&&/[a-zA-Z/!]/.test(v)&&(t=!0,r="",l=/[a-zA-Z]/.test(v))}a<o.length-1&&(e+=t||s||i!==null?`${ut}${a}$$`:`<!--${ht}${a}$$-->`)}return e}const $e=new WeakMap;function Ce(o){const e=$e.get(o);if(e)return e;const t=document.createElement("template");t.innerHTML=mt(o);const n=[],s=(l,a)=>{if(l.nodeType===Node.ELEMENT_NODE){const p=l;for(const v of Array.from(p.attributes)){const $=v.name,b=v.value,I=$[0];if(S.test(b))if(S.lastIndex=0,I==="@"){const C=S.exec(b);S.lastIndex=0,n.push({path:a,kind:"event",name:$.slice(1),valueIndex:C?Number(C[1]):0}),p.removeAttribute($)}else if(I==="."){const C=S.exec(b);S.lastIndex=0,n.push({path:a,kind:"prop",name:$.slice(1),valueIndex:C?Number(C[1]):0}),p.removeAttribute($)}else if(I==="?"){const C=S.exec(b);S.lastIndex=0,n.push({path:a,kind:"bool",name:$.slice(1),valueIndex:C?Number(C[1]):0}),p.removeAttribute($)}else{const C=[],c=[];let h=0,f;for(S.lastIndex=0;(f=S.exec(b))!==null;)C.push(b.slice(h,f.index)),c.push(Number(f[1])),h=f.index+f[0].length;C.push(b.slice(h)),n.push({path:a,kind:"attr",name:$,template:C,valueIndices:c}),p.setAttribute($,"")}}}const d=Array.from(l.childNodes);let u=0;for(let p=0;p<d.length;p++){const v=d[p],$=p+u;if(v.nodeType===Node.COMMENT_NODE){const b=pt.exec(v.data);if(b){const I=document.createTextNode("");v.parentNode.replaceChild(I,v),n.push({path:[...a,$],kind:"node",valueIndex:Number(b[1])})}continue}if(v.nodeType===Node.TEXT_NODE){const b=v.textContent||"";if(!S.test(b)){S.lastIndex=0;continue}S.lastIndex=0;const I=v.parentNode;let C=0,c;const h=[],f=[];for(S.lastIndex=0;(c=S.exec(b))!==null;){c.index>C&&h.push(document.createTextNode(b.slice(C,c.index)));const _=document.createTextNode("");h.push(_),f.push({path:[...a,$+h.length-1],kind:"node",valueIndex:Number(c[1])}),C=c.index+c[0].length}C<b.length&&h.push(document.createTextNode(b.slice(C)));for(const _ of h)I.insertBefore(_,v);I.removeChild(v),u+=h.length-1,n.push(...f)}else s(v,[...a,$])}};s(t.content,[]);const r={template:t,buildParts:l=>{const a=[];for(const d of n){let u=l;for(const p of d.path)u=u.childNodes[p];d.kind==="node"?a.push({kind:"node",valueIndex:d.valueIndex,child:{anchor:u,state:null}}):d.kind==="attr"?a.push({kind:"attr",element:u,name:d.name,template:d.template,valueIndices:d.valueIndices}):d.kind==="event"?a.push({kind:"event",valueIndex:d.valueIndex,element:u,name:d.name}):d.kind==="prop"?a.push({kind:"prop",valueIndex:d.valueIndex,element:u,name:d.name}):d.kind==="bool"&&a.push({kind:"bool",valueIndex:d.valueIndex,element:u,name:d.name})}return a}};return $e.set(o,r),r}const Ae=new WeakMap;function gt(o,e){for(const t of o.nodes)if(t.parentNode!==e)return!1;return!0}function bt(o,e){const t=Ae.get(e);if(t&&t.strings===o.strings&>(t,e)){se(t.parts,o.values);return}const n=Ce(o.strings),s=n.template.content.cloneNode(!0),i=n.buildParts(s),r=Array.from(s.childNodes);for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(s),se(i,o.values),Ae.set(e,{strings:o.strings,parts:i,nodes:r})}function se(o,e){for(const t of o)if(t.kind==="node")ie(t.child,e[t.valueIndex]);else if(t.kind==="attr"){let n=t.template[0];for(let s=0;s<t.valueIndices.length;s++)n+=Ee(e[t.valueIndices[s]]),n+=t.template[s+1];n!==t.last&&(t.last=n,n===""?t.element.removeAttribute(t.name):t.element.setAttribute(t.name,n))}else if(t.kind==="event"){const n=e[t.valueIndex];n!==t.current&&(t.current&&t.element.removeEventListener(t.name,t.current),n&&t.element.addEventListener(t.name,n),t.current=n)}else if(t.kind==="prop"){const n=e[t.valueIndex];n!==t.last&&(t.last=n,t.element[t.name]=n)}else if(t.kind==="bool"){const n=!!e[t.valueIndex];n!==t.last&&(t.last=n,n?t.element.setAttribute(t.name,""):t.element.removeAttribute(t.name))}}function ie(o,e){if(e==null||e===!1){o.state&&(F(o.state),o.state=null);return}if(Array.isArray(e)){xt(o,e);return}if(dt(e)){yt(o,e);return}if(e instanceof Node){vt(o,e);return}_t(o,Ee(e))}function vt(o,e){const t=o.state;t?.shape==="node"&&t.node===e||(t&&F(t),K(o,[e]),o.state={shape:"node",node:e})}function _t(o,e){const t=o.state;if(t?.shape==="text"){t.text!==e&&(t.node.textContent=e,t.text=e);return}t&&F(t);const n=document.createTextNode(e);K(o,[n]),o.state={shape:"text",node:n,text:e}}function yt(o,e){const t=o.state;if(t?.shape==="template"&&t.strings===e.strings){se(t.parts,e.values);return}t&&F(t);const n=Ce(e.strings),s=n.template.content.cloneNode(!0),i=n.buildParts(s),r=Array.from(s.childNodes);K(o,[s]),se(i,e.values),o.state={shape:"template",strings:e.strings,parts:i,nodes:r}}function xt(o,e){const t=o.state;if(t?.shape==="array"){const s=Math.min(t.entries.length,e.length);for(let i=0;i<s;i++)ie(t.entries[i],e[i]);if(e.length<t.entries.length){for(let i=e.length;i<t.entries.length;i++){const r=t.entries[i];r.state&&F(r.state),r.anchor.remove()}t.entries.length=e.length}else for(let i=t.entries.length;i<e.length;i++){const r=document.createTextNode("");K(o,[r]);const l={anchor:r,state:null};ie(l,e[i]),t.entries.push(l)}return}t&&F(t);const n=[];for(const s of e){const i=document.createTextNode("");K(o,[i]);const r={anchor:i,state:null};ie(r,s),n.push(r)}o.state={shape:"array",entries:n}}function K(o,e){const t=o.anchor.parentNode;if(t)for(const n of e)t.insertBefore(n,o.anchor)}function F(o){if(o.shape==="text"){o.node.remove();return}if(o.shape==="template"){for(const e of o.parts)e.kind==="node"&&e.child.state&&(F(e.child.state),e.child.state=null);for(const e of o.nodes)e.parentNode&&e.parentNode.removeChild(e);return}if(o.shape==="node"){o.node.parentNode&&o.node.parentNode.removeChild(o.node);return}for(const e of o.entries)e.state&&F(e.state),e.anchor.remove()}function Ee(o){return o==null||o===!1?"":String(o)}const D=class D extends HTMLElement{constructor(){super(),this._renderScheduled=!1,this._propValues={},this.constructor.shadow?(this.attachShadow({mode:"open"}),this._renderRoot=this.shadowRoot):this._renderRoot=this,this._installPropAccessors()}static get observedAttributes(){return this.props.map(Ne)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,t,n){if(t===n)return;const s=kt(e);this._propValues[s]=n,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(e){if(e==null){this.removeAttribute("class");return}const n=(Array.isArray(e)?e:String(e).split(/\s+/)).map(s=>String(s).trim()).filter(s=>s!=="");this.className=n.join(" ")}requestUpdate(){this._scheduleRender()}emit(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_installPropAccessors(){const e=this.constructor;for(const t of e.props){if(Object.getOwnPropertyDescriptor(this,t))continue;const n=Ne(t);Object.defineProperty(this,t,{get:()=>t in this._propValues?this._propValues[t]:this.getAttribute(n),set:s=>{let i;s==null||s===!1?i=null:s===!0?i="":i=String(s),this._propValues[t]=i,i===null?this.removeAttribute(n):this.setAttribute(n,i),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&bt(this.render(),this._renderRoot)}))}_adoptStyles(){const e=this.constructor;if(e.styles.length!==0)if(e.shadow&&this.shadowRoot){const t=e.styles.map(n=>n.sheet).filter(n=>n!==null);if(this.shadowRoot.adoptedStyleSheets=t,t.length!==e.styles.length){for(const n of e.styles)if(!n.sheet){const s=document.createElement("style");s.textContent=n.cssText,this.shadowRoot.appendChild(s)}}}else this._adoptLightStyles(e)}_adoptLightStyles(e){if(!D._lightStylesAdopted.has(e)){D._lightStylesAdopted.add(e);for(const t of e.styles){const n=document.createElement("style");n.dataset.osUi=this.tagName.toLowerCase(),n.textContent=t.cssText,document.head.appendChild(n)}}}};D.props=[],D.styles=[],D.shadow=!0,D._lightStylesAdopted=new WeakSet;let M=D;function H(o,e){customElements.get(o)||customElements.define(o,e)}function Ne(o){return o.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function kt(o){return o.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}const wt=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function A(o,...e){let t=o[0];for(let n=1;n<o.length;n++){const s=e[n-1];if(typeof s=="string"||typeof s=="number")t+=String(s);else if(s&&s.__wpdCss)t+=s.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof s);t+=o[n]}if(wt){const n=new CSSStyleSheet;return n.replaceSync(t),{__wpdCss:!0,sheet:n,cssText:t}}return{__wpdCss:!0,sheet:null,cssText:t}}function $t(o){const e=[],t=[];let n=null,s=o.parentElement;for(;s&&!(s===document.body||s===document.documentElement);){const r=s.id||"";if(r.startsWith("wp-window-")){n=r.slice(10);break}if(s.tagName.toLowerCase()==="os-tabpanel"){const l=s.getAttribute("for");l&&t.unshift(l)}s=s.parentElement}n&&e.push(he(n));for(const r of t)e.push("tab-"+he(r));const i=o.getAttribute("label");return i&&e.push(he(i)),e.length===0?"os-unnamed":"os-"+e.filter(r=>r!=="").join("-")}function he(o){return o.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ct(o){if(o.id)return o.id;const e=$t(o);return o.id=e,e}function At(o){if(!o)return 214;let e=5381;for(let t=0;t<o.length;t++)e=Math.imul(e,33)+o.charCodeAt(t);return(e%360+360)%360}const Et=A`:host{display:inline-flex;position:relative;width:var( --os-ui-avatar-size,32px );height:var( --os-ui-avatar-size,32px );flex:0 0 auto;vertical-align:middle;line-height:0;perspective:calc( var( --os-ui-avatar-size,32px ) * 8 );--os-ui-avatar-tilt-x:0deg;--os-ui-avatar-tilt-y:0deg;--os-ui-avatar-hover:0;--os-ui-avatar-glare-x:50%;--os-ui-avatar-glare-y:50%}:host( [ hidden ] ){display:none}.os-avatar__tile{position:relative;width:100%;height:100%;border-radius:50%;overflow:hidden;background:var( --os-window-bg,#f0f0f1 );color:var( --os-ui-fg-on-accent,#fff );display:flex;align-items:center;justify-content:center;font-weight:700;font-size:calc( var( --os-ui-avatar-size,32px ) * 0.48 );line-height:1;letter-spacing:0;font-feature-settings:'tnum' 1;user-select:none;transform-style:preserve-3d;transform:rotateX( var( --os-ui-avatar-tilt-x ) ) rotateY( var( --os-ui-avatar-tilt-y ) ) scale( calc( 1 + var( --os-ui-avatar-hover ) * 0.07 ) );transition:transform 220ms cubic-bezier( 0.2,0.8,0.2,1 ),box-shadow 220ms cubic-bezier( 0.2,0.8,0.2,1 );box-shadow:inset 0 0 0 1px rgba( 255,255,255,calc( 0.18 + 0.22 * var( --os-ui-avatar-hover ) ) ),inset 0 0 0 calc( 1px + var( --os-ui-avatar-hover ) * 1px ) rgba( 0,0,0,calc( 0.08 + 0.04 * var( --os-ui-avatar-hover ) ) ),0 calc( 1px + var( --os-ui-avatar-hover ) * 8px ) calc( 6px + var( --os-ui-avatar-hover ) * 18px ) rgba( 0,0,0,calc( 0.08 + 0.18 * var( --os-ui-avatar-hover ) ) )}.os-avatar__tile::after{content:'';position:absolute;inset:0;border-radius:50%;background:radial-gradient( circle at var( --os-ui-avatar-glare-x ) var( --os-ui-avatar-glare-y ),var( --os-ui-scrim,rgba( 255,255,255,0.55 ) ) 0%,var( --os-ui-hover,rgba( 255,255,255,0 ) ) 55% );opacity:var( --os-ui-avatar-hover );mix-blend-mode:overlay;pointer-events:none;transition:opacity 220ms cubic-bezier( 0.2,0.8,0.2,1 )}.os-avatar__tile::before{content:'';position:absolute;inset:calc( var( --os-ui-avatar-hover ) * -3px );border-radius:50%;background:radial-gradient( circle at var( --os-ui-avatar-glare-x ) var( --os-ui-avatar-glare-y ),color-mix( in srgb,var( --os-ui-avatar-halo,rgb( 99,102,241 ) ) calc( 35% * var( --os-ui-avatar-hover ) ),transparent ) 0%,transparent 70% );filter:blur( 4px );pointer-events:none;z-index:-1;transition:inset 220ms cubic-bezier( 0.2,0.8,0.2,1 ),background 220ms}.os-avatar__tile img{width:calc( 100% + 2px );height:calc( 100% + 2px );margin:-1px;object-fit:cover;display:block;transform:translateZ( 1px )}.os-avatar__dot{position:absolute;bottom:0;inset-inline-end:0;width:calc( var( --os-ui-avatar-size,32px ) * 0.32 );height:calc( var( --os-ui-avatar-size,32px ) * 0.32 );min-width:8px;min-height:8px;border-radius:50%;box-sizing:border-box;border:2px solid var( --os-ui-avatar-dot-ring,var( --os-window-bg,#fff ) );background:var( --os-ui-avatar-dot-color,transparent );z-index:2}.os-avatar__dot--online{background:var( --os-ui-success-fg,#00a32a )}.os-avatar__dot--online::after{content:'';position:absolute;inset:-2px;border-radius:50%;border:1px solid var( --os-ui-success-fg,#00a32a );animation:os-avatar-presence 6s var( --os-ui-ease-out,cubic-bezier( 0.22,0.9,0.28,1 ) ) infinite;pointer-events:none}@keyframes os-avatar-presence{0%{opacity:0.6;transform:scale( 1 )}20%{opacity:0;transform:scale( 2.2 )}100%{opacity:0;transform:scale( 2.2 )}}.os-avatar__dot--inactive{background:var( --os-ui-warning-fg,#dba617 )}.os-avatar__dot--offline{background:var( --os-ui-fg-muted,#8c8f94 )}@media ( prefers-reduced-motion:reduce ){.os-avatar__dot--online::after{animation:none;opacity:0.6}.os-avatar__tile{transform:none;transition:box-shadow 200ms}.os-avatar__tile::after,.os-avatar__tile::before{display:none}}`,Se={xs:20,sm:24,md:40,lg:64,xl:96},Ie=new Set(["online","inactive","offline"]),V=class V extends M{constructor(){super(...arguments),this._presenceHandler=null,this._imgFailed=!1,this._onPointerMove=null,this._onPointerEnter=null,this._onPointerLeave=null,this._tiltRaf=0,this._pendingTiltX="0deg",this._pendingTiltY="0deg",this._pendingGlareX="50%",this._pendingGlareY="50%"}connectedCallback(){super.connectedCallback(),this._maybeAttachPresenceListener(),this._attachHoverEffect()}disconnectedCallback(){this._presenceHandler&&(document.removeEventListener("os-presence-changed",this._presenceHandler),this._presenceHandler=null),this._detachHoverEffect()}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),e==="src"&&(this._imgFailed=!1),(e==="user-id"||e==="presence")&&this._maybeAttachPresenceListener()}render(){const e=this._attr("src"),t=this._attr("name")||"",n=this._attr("alt"),s=n!==null?n:t,i=this._attr("size"),r=this._resolveSize(i),l=this._presenceForRender(),a=this._attr("clickable")!==null;this.style.setProperty("--os-ui-avatar-size",`${r}px`);const d=e&&!this._imgFailed?"":this._initialsBg(t),u=e&&!this._imgFailed?k`<img | |
| 1 | +(function(){"use strict";const yt="desktop-mode";function Ie(){return window.wp?.i18n}function h(o,e=yt){return Ie()?.__(o,e)??o}function ue(o,...e){const t=Ie()?.sprintf;if(t)return t(o,...e);let n=0;return o.replace(/%(?:(\d+)\$)?[sd]/g,(s,r)=>{const i=r?Number.parseInt(r,10)-1:n++;return String(e[i]??"")})}const ze="X-WP-Nonce";function xt(o,e){const t=kt();if(!t)return e;const n=wt(o);if(!n||!$t(n))return e;const s=e?.headers??(typeof Request<"u"&&o instanceof Request?o.headers:void 0),r=new Headers(s??{});return r.has(ze)?e:(r.set(ze,t),{...e??{},headers:r})}function kt(){if(typeof window>"u")return;const e=window.openStationConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function wt(o){try{const e=typeof window<"u"&&window.location?window.location.href:void 0;return typeof o=="string"?new URL(o,e):o instanceof URL?o:typeof Request<"u"&&o instanceof Request?new URL(o.url,e):null}catch{return null}}function $t(o){return typeof window>"u"||!window.location||o.origin!==window.location.origin?!1:!!(o.pathname.includes("/wp-json/")||o.searchParams.has("rest_route"))}function Pe(o,e,t={}){const n=window.wp?.os?.fetch;if(typeof n=="function")return n(o,e,t);const s=xt(o,e);return fetch(o,s)}class he extends Error{constructor(e,t){super(e||t.serverMessage||`HTTP ${t.status}`),this.name="RestError",this.status=t.status,this.code=t.code,this.data=t.data,this.serverMessage=t.serverMessage??""}}function Me(o){return o instanceof he}function At(o){const e=typeof o=="object"&&o!==null?o:void 0;return{code:typeof e?.code=="string"?e.code:void 0,data:e?.data,serverMessage:typeof e?.message=="string"?e.message:""}}function ye(o,e,t=""){return new he(t,{status:o,...At(e)})}const Ct="rest_cookie_invalid_nonce",Fe=()=>h("Could not reach the site. Check your connection and try again.","desktop-mode");function De(o){return typeof navigator<"u"&&navigator.onLine===!1?!0:o instanceof TypeError}function Et(o){return Me(o)?o.code===Ct||o.status===401?"session":o.status>=200&&o.status<300?"unreadable":o.status===404?"gone":o.status>=500?"server":o.status>=400?"refused":"unknown":De(o)?"offline":"unknown"}function St(o){return Me(o)?o.serverMessage:De(o)?Fe():o instanceof Error?o.message:""}function Nt(o,e){const{fallback:t,lead:n}=e,s=Et(o),r=s==="offline"||s==="unreadable"?"warning":"error";let i="",l=!0;switch(s){case"offline":i=Fe();break;case"session":i=h("Your session has expired. Reload the page and try again.","desktop-mode");break;case"unreadable":i=h("The site sent an unreadable reply. Reload the page to check whether the change went through.","desktop-mode");break;case"gone":case"refused":case"server":{const a=o;a.serverMessage?i=a.serverMessage:s==="gone"?(i=h("It no longer exists. Reload the page to catch up.","desktop-mode"),l=!1):s==="server"?(i=ue(h("The server answered with error %d.","desktop-mode"),a.status),l=!1):(i=ue(h("The server refused the request (HTTP %d).","desktop-mode"),a.status),l=!1);break}case"unknown":default:i=St(o);break}let c;return n?c=i?`${n}: ${i}`:t:i?l?c=i:c=`${t} ${i}`:c=t,{message:c,reason:i,kind:s,type:r}}function Tt(o,e,t){if(!o)return;const{duration:n,...s}=t,r=Nt(e,s),i={message:r.message,type:r.type};n&&(i.duration=n),o(i)}function Rt(o){const e=window.wp?.os;return typeof e?.showToast!="function"?()=>{}:e.showToast(o)??(()=>{})}function Lt(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xe(o){return o.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>/^https?:\/\//i.test(n.trim())?`<a href="${n.trim()}" target="_blank" rel="noopener noreferrer">${t}</a>`:t).replace(/\*\*([^*\n]+?)\*\*/g,"<strong>$1</strong>").replace(/(?<![*\w])\*([^*\n]+?)\*(?![*\w])/g,"<em>$1</em>").replace(/(?<![_\w])_([^_\n]+?)_(?![_\w])/g,"<em>$1</em>").replace(/`([^`\n]+?)`/g,"<code>$1</code>")}function It(o){if(!o)return"";const e=Lt(o),t=[];let n=[],s=null;const r=()=>{n.length>0&&(t.push(`<p>${n.join("<br>")}</p>`),n=[])},i=()=>{s&&(t.push(`<${s.tag}>${s.items.join("")}</${s.tag}>`),s=null)};for(const l of e.split(/\n/)){const c=l.trim();if(c===""){r(),i();continue}const a=/^(#{1,6})\s+(.*)$/.exec(c);if(a){r(),i();const f=Math.min(6,a[1].length+2);t.push(`<h${f}>${xe(a[2])}</h${f}>`);continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(c)){r(),i(),t.push("<hr>");continue}const u=/^[-*]\s+(.*)$/.exec(c),p=/^\d+\.\s+(.*)$/.exec(c);if(u||p){r();const f=u?"ul":"ol";(!s||s.tag!==f)&&(i(),s={tag:f,items:[]}),s.items.push(`<li>${xe((u??p)[1])}</li>`);continue}i(),n.push(xe(c))}return r(),i(),t.join("")}function y(o,...e){return{__wpdHtml:!0,strings:o,values:e}}function zt(o){return!!o&&o.__wpdHtml===!0}const Pt="$$wpd$$",L=/\$\$wpd\$\$(\d+)\$\$/g,Mt="$$wpd-node$$",Ft=/^\$\$wpd-node\$\$(\d+)\$\$$/,Dt=new Set(["style","script","textarea","title"]);function jt(o){let e="",t=!1,n=null,s=!1,r=null,i="",l=!1;for(let c=0;c<o.length;c++){const a=o[c];e+=a;for(let u=0;u<a.length;u++){const p=a[u];if(s){a.startsWith("-->",u)&&(s=!1,u+=2);continue}if(r!==null){p==="<"&&a[u+1]==="/"&&a.slice(u+2,u+2+r.length).toLowerCase()===r&&(u+=1+r.length,r=null,t=!0,l=!1,i="");continue}if(n!==null){p===n&&(n=null);continue}if(t){p==='"'||p==="'"?(n=p,l=!1):p===">"?(t=!1,l=!1,Dt.has(i)&&(r=i),i=""):l&&(/[a-zA-Z0-9-]/.test(p)?i+=p.toLowerCase():l=!1);continue}if(a.startsWith("<!--",u)){s=!0,u+=3;continue}const f=a[u+1]??"";p==="<"&&/[a-zA-Z/!]/.test(f)&&(t=!0,i="",l=/[a-zA-Z]/.test(f))}c<o.length-1&&(e+=t||s||r!==null?`${Pt}${c}$$`:`<!--${Mt}${c}$$-->`)}return e}const je=new WeakMap;function He(o){const e=je.get(o);if(e)return e;const t=document.createElement("template");t.innerHTML=jt(o);const n=[],s=(l,c)=>{if(l.nodeType===Node.ELEMENT_NODE){const p=l;for(const f of Array.from(p.attributes)){const x=f.name,b=f.value,S=x[0];if(L.test(b))if(L.lastIndex=0,S==="@"){const w=L.exec(b);L.lastIndex=0,n.push({path:c,kind:"event",name:x.slice(1),valueIndex:w?Number(w[1]):0}),p.removeAttribute(x)}else if(S==="."){const w=L.exec(b);L.lastIndex=0,n.push({path:c,kind:"prop",name:x.slice(1),valueIndex:w?Number(w[1]):0}),p.removeAttribute(x)}else if(S==="?"){const w=L.exec(b);L.lastIndex=0,n.push({path:c,kind:"bool",name:x.slice(1),valueIndex:w?Number(w[1]):0}),p.removeAttribute(x)}else{const w=[],N=[];let T=0,F;for(L.lastIndex=0;(F=L.exec(b))!==null;)w.push(b.slice(T,F.index)),N.push(Number(F[1])),T=F.index+F[0].length;w.push(b.slice(T)),n.push({path:c,kind:"attr",name:x,template:w,valueIndices:N}),p.setAttribute(x,"")}}}const a=Array.from(l.childNodes);let u=0;for(let p=0;p<a.length;p++){const f=a[p],x=p+u;if(f.nodeType===Node.COMMENT_NODE){const b=Ft.exec(f.data);if(b){const S=document.createTextNode("");f.parentNode.replaceChild(S,f),n.push({path:[...c,x],kind:"node",valueIndex:Number(b[1])})}continue}if(f.nodeType===Node.TEXT_NODE){const b=f.textContent||"";if(!L.test(b)){L.lastIndex=0;continue}L.lastIndex=0;const S=f.parentNode;let w=0,N;const T=[],F=[];for(L.lastIndex=0;(N=L.exec(b))!==null;){N.index>w&&T.push(document.createTextNode(b.slice(w,N.index)));const H=document.createTextNode("");T.push(H),F.push({path:[...c,x+T.length-1],kind:"node",valueIndex:Number(N[1])}),w=N.index+N[0].length}w<b.length&&T.push(document.createTextNode(b.slice(w)));for(const H of T)S.insertBefore(H,f);S.removeChild(f),u+=T.length-1,n.push(...F)}else s(f,[...c,x])}};s(t.content,[]);const i={template:t,buildParts:l=>{const c=[];for(const a of n){let u=l;for(const p of a.path)u=u.childNodes[p];a.kind==="node"?c.push({kind:"node",valueIndex:a.valueIndex,child:{anchor:u,state:null}}):a.kind==="attr"?c.push({kind:"attr",element:u,name:a.name,template:a.template,valueIndices:a.valueIndices}):a.kind==="event"?c.push({kind:"event",valueIndex:a.valueIndex,element:u,name:a.name}):a.kind==="prop"?c.push({kind:"prop",valueIndex:a.valueIndex,element:u,name:a.name}):a.kind==="bool"&&c.push({kind:"bool",valueIndex:a.valueIndex,element:u,name:a.name})}return c}};return je.set(o,i),i}const We=new WeakMap;function Ht(o,e){for(const t of o.nodes)if(t.parentNode!==e)return!1;return!0}function Wt(o,e){const t=We.get(e);if(t&&t.strings===o.strings&&Ht(t,e)){pe(t.parts,o.values);return}const n=He(o.strings),s=n.template.content.cloneNode(!0),r=n.buildParts(s),i=Array.from(s.childNodes);for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(s),pe(r,o.values),We.set(e,{strings:o.strings,parts:r,nodes:i})}function pe(o,e){for(const t of o)if(t.kind==="node")fe(t.child,e[t.valueIndex]);else if(t.kind==="attr"){let n=t.template[0];for(let s=0;s<t.valueIndices.length;s++)n+=qe(e[t.valueIndices[s]]),n+=t.template[s+1];n!==t.last&&(t.last=n,n===""?t.element.removeAttribute(t.name):t.element.setAttribute(t.name,n))}else if(t.kind==="event"){const n=e[t.valueIndex];n!==t.current&&(t.current&&t.element.removeEventListener(t.name,t.current),n&&t.element.addEventListener(t.name,n),t.current=n)}else if(t.kind==="prop"){const n=e[t.valueIndex];n!==t.last&&(t.last=n,t.element[t.name]=n)}else if(t.kind==="bool"){const n=!!e[t.valueIndex];n!==t.last&&(t.last=n,n?t.element.setAttribute(t.name,""):t.element.removeAttribute(t.name))}}function fe(o,e){if(e==null||e===!1){o.state&&(O(o.state),o.state=null);return}if(Array.isArray(e)){Bt(o,e);return}if(zt(e)){Ot(o,e);return}if(e instanceof Node){qt(o,e);return}Ut(o,qe(e))}function qt(o,e){const t=o.state;t?.shape==="node"&&t.node===e||(t&&O(t),Z(o,[e]),o.state={shape:"node",node:e})}function Ut(o,e){const t=o.state;if(t?.shape==="text"){t.text!==e&&(t.node.textContent=e,t.text=e);return}t&&O(t);const n=document.createTextNode(e);Z(o,[n]),o.state={shape:"text",node:n,text:e}}function Ot(o,e){const t=o.state;if(t?.shape==="template"&&t.strings===e.strings){pe(t.parts,e.values);return}t&&O(t);const n=He(e.strings),s=n.template.content.cloneNode(!0),r=n.buildParts(s),i=Array.from(s.childNodes);Z(o,[s]),pe(r,e.values),o.state={shape:"template",strings:e.strings,parts:r,nodes:i}}function Bt(o,e){const t=o.state;if(t?.shape==="array"){const s=Math.min(t.entries.length,e.length);for(let r=0;r<s;r++)fe(t.entries[r],e[r]);if(e.length<t.entries.length){for(let r=e.length;r<t.entries.length;r++){const i=t.entries[r];i.state&&O(i.state),i.anchor.remove()}t.entries.length=e.length}else for(let r=t.entries.length;r<e.length;r++){const i=document.createTextNode("");Z(o,[i]);const l={anchor:i,state:null};fe(l,e[r]),t.entries.push(l)}return}t&&O(t);const n=[];for(const s of e){const r=document.createTextNode("");Z(o,[r]);const i={anchor:r,state:null};fe(i,s),n.push(i)}o.state={shape:"array",entries:n}}function Z(o,e){const t=o.anchor.parentNode;if(t)for(const n of e)t.insertBefore(n,o.anchor)}function O(o){if(o.shape==="text"){o.node.remove();return}if(o.shape==="template"){for(const e of o.parts)e.kind==="node"&&e.child.state&&(O(e.child.state),e.child.state=null);for(const e of o.nodes)e.parentNode&&e.parentNode.removeChild(e);return}if(o.shape==="node"){o.node.parentNode&&o.node.parentNode.removeChild(o.node);return}for(const e of o.entries)e.state&&O(e.state),e.anchor.remove()}function qe(o){return o==null||o===!1?"":String(o)}const B=class B extends HTMLElement{constructor(){super(),this._renderScheduled=!1,this._propValues={},this.constructor.shadow?(this.attachShadow({mode:"open"}),this._renderRoot=this.shadowRoot):this._renderRoot=this,this._installPropAccessors()}static get observedAttributes(){return this.props.map(Ue)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,t,n){if(t===n)return;const s=Kt(e);this._propValues[s]=n,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(e){if(e==null){this.removeAttribute("class");return}const n=(Array.isArray(e)?e:String(e).split(/\s+/)).map(s=>String(s).trim()).filter(s=>s!=="");this.className=n.join(" ")}requestUpdate(){this._scheduleRender()}emit(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_installPropAccessors(){const e=this.constructor;for(const t of e.props){if(Object.getOwnPropertyDescriptor(this,t))continue;const n=Ue(t);Object.defineProperty(this,t,{get:()=>t in this._propValues?this._propValues[t]:this.getAttribute(n),set:s=>{let r;s==null||s===!1?r=null:s===!0?r="":r=String(s),this._propValues[t]=r,r===null?this.removeAttribute(n):this.setAttribute(n,r),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&Wt(this.render(),this._renderRoot)}))}_adoptStyles(){const e=this.constructor;if(e.styles.length!==0)if(e.shadow&&this.shadowRoot){const t=e.styles.map(n=>n.sheet).filter(n=>n!==null);if(this.shadowRoot.adoptedStyleSheets=t,t.length!==e.styles.length){for(const n of e.styles)if(!n.sheet){const s=document.createElement("style");s.textContent=n.cssText,this.shadowRoot.appendChild(s)}}}else this._adoptLightStyles(e)}_adoptLightStyles(e){if(!B._lightStylesAdopted.has(e)){B._lightStylesAdopted.add(e);for(const t of e.styles){const n=document.createElement("style");n.dataset.osUi=this.tagName.toLowerCase(),n.textContent=t.cssText,document.head.appendChild(n)}}}};B.props=[],B.styles=[],B.shadow=!0,B._lightStylesAdopted=new WeakSet;let q=B;function K(o,e){customElements.get(o)||customElements.define(o,e)}function Ue(o){return o.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function Kt(o){return o.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}const Xt=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function E(o,...e){let t=o[0];for(let n=1;n<o.length;n++){const s=e[n-1];if(typeof s=="string"||typeof s=="number")t+=String(s);else if(s&&s.__wpdCss)t+=s.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof s);t+=o[n]}if(Xt){const n=new CSSStyleSheet;return n.replaceSync(t),{__wpdCss:!0,sheet:n,cssText:t}}return{__wpdCss:!0,sheet:null,cssText:t}}function Yt(o){const e=[],t=[];let n=null,s=o.parentElement;for(;s&&!(s===document.body||s===document.documentElement);){const i=s.id||"";if(i.startsWith("wp-window-")){n=i.slice(10);break}if(s.tagName.toLowerCase()==="os-tabpanel"){const l=s.getAttribute("for");l&&t.unshift(l)}s=s.parentElement}n&&e.push(ke(n));for(const i of t)e.push("tab-"+ke(i));const r=o.getAttribute("label");return r&&e.push(ke(r)),e.length===0?"os-unnamed":"os-"+e.filter(i=>i!=="").join("-")}function ke(o){return o.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Gt(o){if(o.id)return o.id;const e=Yt(o);return o.id=e,e}function Vt(o){if(!o)return 214;let e=5381;for(let t=0;t<o.length;t++)e=Math.imul(e,33)+o.charCodeAt(t);return(e%360+360)%360}const Jt=E`:host{display:inline-flex;position:relative;width:var( --os-ui-avatar-size,32px );height:var( --os-ui-avatar-size,32px );flex:0 0 auto;vertical-align:middle;line-height:0;perspective:calc( var( --os-ui-avatar-size,32px ) * 8 );--os-ui-avatar-tilt-x:0deg;--os-ui-avatar-tilt-y:0deg;--os-ui-avatar-hover:0;--os-ui-avatar-glare-x:50%;--os-ui-avatar-glare-y:50%}:host( [ hidden ] ){display:none}.os-avatar__tile{position:relative;width:100%;height:100%;border-radius:50%;overflow:hidden;background:var( --os-window-bg,#f0f0f1 );color:var( --os-ui-fg-on-accent,#fff );display:flex;align-items:center;justify-content:center;font-weight:700;font-size:calc( var( --os-ui-avatar-size,32px ) * 0.48 );line-height:1;letter-spacing:0;font-feature-settings:'tnum' 1;user-select:none;transform-style:preserve-3d;transform:rotateX( var( --os-ui-avatar-tilt-x ) ) rotateY( var( --os-ui-avatar-tilt-y ) ) scale( calc( 1 + var( --os-ui-avatar-hover ) * 0.07 ) );transition:transform 220ms cubic-bezier( 0.2,0.8,0.2,1 ),box-shadow 220ms cubic-bezier( 0.2,0.8,0.2,1 );box-shadow:inset 0 0 0 1px rgba( 255,255,255,calc( 0.18 + 0.22 * var( --os-ui-avatar-hover ) ) ),inset 0 0 0 calc( 1px + var( --os-ui-avatar-hover ) * 1px ) rgba( 0,0,0,calc( 0.08 + 0.04 * var( --os-ui-avatar-hover ) ) ),0 calc( 1px + var( --os-ui-avatar-hover ) * 8px ) calc( 6px + var( --os-ui-avatar-hover ) * 18px ) rgba( 0,0,0,calc( 0.08 + 0.18 * var( --os-ui-avatar-hover ) ) )}.os-avatar__tile::after{content:'';position:absolute;inset:0;border-radius:50%;background:radial-gradient( circle at var( --os-ui-avatar-glare-x ) var( --os-ui-avatar-glare-y ),var( --os-ui-scrim,rgba( 255,255,255,0.55 ) ) 0%,var( --os-ui-hover,rgba( 255,255,255,0 ) ) 55% );opacity:var( --os-ui-avatar-hover );mix-blend-mode:overlay;pointer-events:none;transition:opacity 220ms cubic-bezier( 0.2,0.8,0.2,1 )}.os-avatar__tile::before{content:'';position:absolute;inset:calc( var( --os-ui-avatar-hover ) * -3px );border-radius:50%;background:radial-gradient( circle at var( --os-ui-avatar-glare-x ) var( --os-ui-avatar-glare-y ),color-mix( in srgb,var( --os-ui-avatar-halo,rgb( 99,102,241 ) ) calc( 35% * var( --os-ui-avatar-hover ) ),transparent ) 0%,transparent 70% );filter:blur( 4px );pointer-events:none;z-index:-1;transition:inset 220ms cubic-bezier( 0.2,0.8,0.2,1 ),background 220ms}.os-avatar__tile img{width:calc( 100% + 2px );height:calc( 100% + 2px );margin:-1px;object-fit:cover;display:block;transform:translateZ( 1px )}.os-avatar__dot{position:absolute;bottom:0;inset-inline-end:0;width:calc( var( --os-ui-avatar-size,32px ) * 0.32 );height:calc( var( --os-ui-avatar-size,32px ) * 0.32 );min-width:8px;min-height:8px;border-radius:50%;box-sizing:border-box;border:2px solid var( --os-ui-avatar-dot-ring,var( --os-window-bg,#fff ) );background:var( --os-ui-avatar-dot-color,transparent );z-index:2}.os-avatar__dot--online{background:var( --os-ui-success-fg,#00a32a )}.os-avatar__dot--online::after{content:'';position:absolute;inset:-2px;border-radius:50%;border:1px solid var( --os-ui-success-fg,#00a32a );animation:os-avatar-presence 6s var( --os-ui-ease-out,cubic-bezier( 0.22,0.9,0.28,1 ) ) infinite;pointer-events:none}@keyframes os-avatar-presence{0%{opacity:0.6;transform:scale( 1 )}20%{opacity:0;transform:scale( 2.2 )}100%{opacity:0;transform:scale( 2.2 )}}.os-avatar__dot--inactive{background:var( --os-ui-warning-fg,#dba617 )}.os-avatar__dot--offline{background:var( --os-ui-fg-muted,#8c8f94 )}@media ( prefers-reduced-motion:reduce ){.os-avatar__dot--online::after{animation:none;opacity:0.6}.os-avatar__tile{transform:none;transition:box-shadow 200ms}.os-avatar__tile::after,.os-avatar__tile::before{display:none}}`,Oe={xs:20,sm:24,md:40,lg:64,xl:96},Be=new Set(["online","inactive","offline"]),oe=class oe extends q{constructor(){super(...arguments),this._presenceHandler=null,this._imgFailed=!1,this._onPointerMove=null,this._onPointerEnter=null,this._onPointerLeave=null,this._tiltRaf=0,this._pendingTiltX="0deg",this._pendingTiltY="0deg",this._pendingGlareX="50%",this._pendingGlareY="50%"}connectedCallback(){super.connectedCallback(),this._maybeAttachPresenceListener(),this._attachHoverEffect()}disconnectedCallback(){this._presenceHandler&&(document.removeEventListener("os-presence-changed",this._presenceHandler),this._presenceHandler=null),this._detachHoverEffect()}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),e==="src"&&(this._imgFailed=!1),(e==="user-id"||e==="presence")&&this._maybeAttachPresenceListener()}render(){const e=this._attr("src"),t=this._attr("name")||"",n=this._attr("alt"),s=n!==null?n:t,r=this._attr("size"),i=this._resolveSize(r),l=this._presenceForRender(),c=this._attr("clickable")!==null;this.style.setProperty("--os-ui-avatar-size",`${i}px`);const a=e&&!this._imgFailed?"":this._initialsBg(t),u=e&&!this._imgFailed?y`<img | |
| 2 | 2 | src=${e} |
| 3 | 3 | alt=${s} |
| 4 | 4 | @error=${()=>this._onImgError()} |
| 5 | 5 | loading="lazy" |
| 6 | - />`:this._initials(t),p=l?k`<span | |
| 6 | + />`:this._initials(t),p=l?y`<span | |
| 7 | 7 | class=${`os-avatar__dot os-avatar__dot--${l}`} |
| 8 | 8 | aria-label=${this._presenceLabel(l)} |
| 9 | - ></span>`:k``;return a?k` | |
| 9 | + ></span>`:y``;return c?y` | |
| 10 | 10 | <button |
| 11 | 11 | type="button" |
| 12 | 12 | class="os-avatar__tile" |
| 13 | 13 | aria-label=${s||"User"} |
| 14 | - style=${d?`background:${d};`:""} | |
| 15 | - @click=${v=>this._onClick(v)} | |
| 14 | + style=${a?`background:${a};`:""} | |
| 15 | + @click=${f=>this._onClick(f)} | |
| 16 | 16 | >${u}</button> |
| 17 | 17 | ${p} |
| 18 | - `:k` | |
| 18 | + `:y` | |
| 19 | 19 | <div |
| 20 | 20 | class="os-avatar__tile" |
| 21 | 21 | role="img" |
| 22 | 22 | aria-label=${s||"User"} |
| 23 | - style=${d?`background:${d};`:""} | |
| 23 | + style=${a?`background:${a};`:""} | |
| 24 | 24 | >${u}</div> |
| 25 | 25 | ${p} |
| 26 | - `}_attr(e){return this.getAttribute(e)}_resolveSize(e){if(!e)return 32;if(e in Se)return Se[e];const t=Number(e);return Number.isFinite(t)&&t>0?t:32}_initials(e){const t=e.trim();return t?Array.from(t)[0]?.toUpperCase()??"?":"?"}_initialsBg(e){const t=At(e);return`linear-gradient(135deg, hsl(${t} 62% 55%), hsl(${(t+24)%360} 58% 42%))`}_presenceForRender(){const e=this._attr("presence");return e&&Ie.has(e)?e:null}_presenceLabel(e){switch(e){case"online":return"Online";case"inactive":return"Inactive";case"offline":return"Offline"}}_onImgError(){this._imgFailed=!0,this.requestUpdate()}_onClick(e){const t=this._attr("user-id"),n={userId:t!==null&&Number(t)||null,originalEvent:e};this.emit("os-avatar-click",n)}_attachHoverEffect(){typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||(this._onPointerEnter=()=>{this.style.setProperty("--os-ui-avatar-hover","1")},this._onPointerLeave=()=>{this.style.setProperty("--os-ui-avatar-hover","0"),this._pendingTiltX="0deg",this._pendingTiltY="0deg",this._pendingGlareX="50%",this._pendingGlareY="50%",this._flushTilt()},this._onPointerMove=t=>{const n=this.getBoundingClientRect();if(n.width===0||n.height===0)return;const s=(t.clientX-n.left)/n.width-.5,i=(t.clientY-n.top)/n.height-.5,r=14;this._pendingTiltY=`${(s*r).toFixed(2)}deg`,this._pendingTiltX=`${(-i*r).toFixed(2)}deg`;const l=Math.max(0,Math.min(100,(s+.5)*100)),a=Math.max(0,Math.min(100,(i+.5)*100));this._pendingGlareX=`${l.toFixed(1)}%`,this._pendingGlareY=`${a.toFixed(1)}%`,this._tiltRaf||(this._tiltRaf=requestAnimationFrame(()=>this._flushTilt()))},this.addEventListener("pointerenter",this._onPointerEnter),this.addEventListener("pointerleave",this._onPointerLeave),this.addEventListener("pointermove",this._onPointerMove))}_flushTilt(){this._tiltRaf=0,this.style.setProperty("--os-ui-avatar-tilt-x",this._pendingTiltX),this.style.setProperty("--os-ui-avatar-tilt-y",this._pendingTiltY),this.style.setProperty("--os-ui-avatar-glare-x",this._pendingGlareX),this.style.setProperty("--os-ui-avatar-glare-y",this._pendingGlareY)}_detachHoverEffect(){this._onPointerMove&&(this.removeEventListener("pointermove",this._onPointerMove),this._onPointerMove=null),this._onPointerEnter&&(this.removeEventListener("pointerenter",this._onPointerEnter),this._onPointerEnter=null),this._onPointerLeave&&(this.removeEventListener("pointerleave",this._onPointerLeave),this._onPointerLeave=null),this._tiltRaf&&(cancelAnimationFrame(this._tiltRaf),this._tiltRaf=0)}_maybeAttachPresenceListener(){const e=this._attr("user-id"),t=this._attr("presence"),n=!!e&&!t;n&&!this._presenceHandler?(this._presenceHandler=s=>{const i=s.detail;i&&String(i.userId)===String(e)&&i.newStatus&&Ie.has(i.newStatus)&&this.setAttribute("presence",i.newStatus)},document.addEventListener("os-presence-changed",this._presenceHandler)):!n&&this._presenceHandler&&(document.removeEventListener("os-presence-changed",this._presenceHandler),this._presenceHandler=null)}};V.props=["src","alt","name","size","presence","userId","clickable"],V.styles=[Et],V.help=void 0;let pe=V;H("os-avatar",pe);const re=A`:host{--_holo-fill:var( --os-ui-holo-fill,${"linear-gradient( 124deg, #afa2e8 0%, #f5a8ea 46%, #8ee9f7 100% )"} );--_holo-ink:var( --os-ui-holo-ink,#0c0b0f );--_holo-sheen:var( --os-ui-holo-sheen,linear-gradient( 124deg,rgba( 159,214,255,0.1 ) 0%,rgba( 236,155,255,0.12 ) 34%,rgba( 242,82,252,0.1 ) 58%,rgba( 147,240,198,0.09 ) 100% ) );--_holo-edge:var( --os-ui-holo-edge,linear-gradient( 124deg,rgba( 154,242,255,0.7 ) 0%,rgba( 236,155,255,0.85 ) 38%,rgba( 242,82,252,0.7 ) 62%,rgba( 159,152,255,0.6 ) 100% ) );--_holo-edge-quiet:var( --os-ui-holo-edge-quiet,linear-gradient( 124deg,rgba( 154,242,255,0.22 ) 0%,rgba( 236,155,255,0.28 ) 38%,rgba( 242,82,252,0.22 ) 62%,rgba( 159,152,255,0.2 ) 100% ) );--_holo-glow:var( --os-ui-holo-glow,0 0 0 1px rgba( 242,82,252,0.28 ),0 2px 10px rgba( 242,82,252,0.22 ) );--_holo-glow-strong:var( --os-ui-holo-glow-strong,0 0 0 1px rgba( 242,82,252,0.42 ),0 4px 18px rgba( 242,82,252,0.38 ),0 1px 3px rgba( 12,11,15,0.6 ) );--_holo-track:var( --os-ui-holo-track,rgba( 255,251,255,0.16 ) );--_holo-track-edge:var( --os-ui-holo-track-edge,#8c8f94 );--_holo-ring-color:var( --os-ui-accent-dim,#2271b1 );--_holo-focus:var( --os-ui-focus-ring,0 0 0 2px rgba( 12,11,15,0.9 ),0 0 0 4px #f252fc,0 0 12px 2px rgba( 242,82,252,0.45 ) );--_holo-focus-field:var( --os-ui-focus-ring-field,0 0 0 1px #f252fc,0 0 0 4px rgba( 242,82,252,0.18 ) );--_holo-t:var( --os-ui-holo-transition,220ms );--_holo-t-fast:var( --os-ui-motion-fast,140ms );--_holo-t-slow:var( --os-ui-motion-slow,340ms );--_holo-t-ambient:var( --os-ui-motion-ambient,12s );--_holo-spring:var( --os-ui-ease-spring,cubic-bezier( 0.32,1.5,0.55,1 ) );--_holo-ease:var( --os-ui-ease-out,cubic-bezier( 0.22,0.9,0.28,1 ) );--_holo-loop:var( --os-ui-ease-loop,cubic-bezier( 0.45,0,0.55,1 ) )}`,Nt=A` .os-holo-fill{background-color:transparent;background-image:var( --_holo-fill );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;color:var( --_holo-ink );transition:background-position var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,filter var( --_holo-t ) ease}.os-holo-fill:hover{background-position:74% 66%}.os-holo-fill:active{background-position:88% 82%;filter:brightness( 0.94 )}@media ( prefers-reduced-motion:reduce ){.os-holo-fill{transition-duration:1ms}.os-holo-fill:hover,.os-holo-fill:active{background-position:22% 28%}}`,Le=A` .os-holo-sheen{position:relative;isolation:isolate}.os-holo-sheen::before{content:'';position:absolute;inset:0;z-index:-1;border-radius:inherit;background-image:var( --_holo-sheen );background-size:200% 200%;background-position:20% 30%;opacity:0;pointer-events:none;transition:opacity var( --_holo-t ) ease,background-position var( --_holo-t ) ease}.os-holo-sheen:hover::before,.os-holo-sheen:focus-visible::before{opacity:1;background-position:76% 68%}@media ( prefers-reduced-motion:reduce ){.os-holo-sheen::before{transition-duration:1ms}.os-holo-sheen:hover::before,.os-holo-sheen:focus-visible::before{background-position:20% 30%}}`,Te=A` .os-holo-edge{position:relative}.os-holo-edge::after{content:'';position:absolute;inset:0;border-radius:inherit;padding:1px;background-image:var( --_holo-edge-quiet );opacity:0;pointer-events:none;-webkit-mask:linear-gradient( #000 0 0 ) content-box,linear-gradient( #000 0 0 );-webkit-mask-composite:xor;mask:linear-gradient( #000 0 0 ) content-box,linear-gradient( #000 0 0 );mask-composite:exclude;transition:opacity var( --_holo-t ) ease}.os-holo-edge:hover::after,.os-holo-edge:focus-visible::after{background-image:var( --_holo-edge );opacity:1}.os-holo-edge.is-lit::after{background-image:var( --_holo-edge );opacity:1}@media ( prefers-reduced-motion:reduce ){.os-holo-edge::after{transition-duration:1ms}}`,Re=A` .os-holo-glint{position:absolute;inset:0;border-radius:inherit;overflow:hidden;pointer-events:none}.os-holo-glint::before{content:'';position:absolute;top:-60%;bottom:-60%;width:45%;inset-inline-start:-60%;background:linear-gradient( 90deg,transparent 0%,rgba( 255,251,255,0.14 ) 45%,rgba( 255,251,255,0.22 ) 50%,rgba( 255,251,255,0.14 ) 55%,transparent 100% );transform:rotate( 18deg ) translateX( 0 );opacity:0}:hover>.os-holo-glint::before,:focus-visible>.os-holo-glint::before,:host(:hover )>.os-holo-glint::before,:host(:focus-visible )>.os-holo-glint::before{animation:os-holo-glint var( --_holo-t-slow ) var( --_holo-ease )}@keyframes os-holo-glint{0%{opacity:0;transform:rotate( 18deg ) translateX( 0 )}15%{opacity:1}85%{opacity:1}100%{opacity:0;transform:rotate( 18deg ) translateX( 240vw )}}@media ( prefers-reduced-motion:reduce ){:hover>.os-holo-glint::before,:focus-visible>.os-holo-glint::before,:host(:hover )>.os-holo-glint::before,:host(:focus-visible )>.os-holo-glint::before{animation:none}}`,ze=A` .os-holo-ring{position:absolute;inset:0;border-radius:inherit;box-shadow:0 0 0 0 var( --_holo-ring-color );opacity:0;pointer-events:none}:active:not(:disabled )>.os-holo-ring,:host(:active:not( [ disabled ] ) )>.os-holo-ring{animation:os-holo-ring var( --_holo-t-slow ) var( --_holo-ease )}@keyframes os-holo-ring{0%{opacity:0.45;box-shadow:0 0 0 0 var( --_holo-ring-color )}100%{opacity:0;box-shadow:0 0 0 10px transparent}}@media ( prefers-reduced-motion:reduce ){:active:not(:disabled )>.os-holo-ring,:host(:active:not( [ disabled ] ) )>.os-holo-ring{animation:none}}`,St=A` .os-holo-shimmer{background-image:var( --_holo-fill );background-size:300% 300%;background-repeat:no-repeat;animation:os-holo-shimmer 2.4s var( --_holo-loop ) infinite}@keyframes os-holo-shimmer{0%{background-position:0% 50%}100%{background-position:100% 50%}}@media ( prefers-reduced-motion:reduce ){.os-holo-shimmer{animation:none;background-position:30% 50%}}`,It=A` .os-holo-enter{animation:os-holo-enter var( --_holo-t ) var( --_holo-spring )}@keyframes os-holo-enter{from{opacity:0;transform:scale( 0.96 )}}@media ( prefers-reduced-motion:reduce ){.os-holo-enter{animation:none}}`,Pe=A` input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ),select,textarea{transition:background-color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):hover:not(:disabled ),select:hover:not(:disabled ),textarea:hover:not(:disabled ){border-color:var( --os-ui-border-strong,#8c8f94 )}input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):focus,input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):focus-visible,select:focus,select:focus-visible,textarea:focus,textarea:focus-visible{outline:none;border-color:var( --os-ui-accent,#2271b1 );box-shadow:var( --_holo-focus-field )}input::placeholder,textarea::placeholder{color:var( --os-ui-fg-faint,#8c8f94 );opacity:1}input::selection,textarea::selection{background:var( --os-ui-selection-bg,rgba( 159,152,255,0.6 ) );color:var( --os-ui-selection-fg,#fffbff )}@media ( prefers-reduced-motion:reduce ){input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ),select,textarea{transition-duration:1ms}}`,Lt=A` input[ type='checkbox' ],input[ type='radio' ]{appearance:none;-webkit-appearance:none;position:relative;flex:0 0 auto;box-sizing:border-box;width:16px;height:16px;margin:0;padding:0;border:1px solid var( --_holo-track-edge );border-radius:4px;background-color:var( --_holo-track );background-image:none;background-repeat:no-repeat;cursor:inherit;transition:background-color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input[ type='radio' ]{border-radius:50%}input[ type='checkbox' ]:hover:not(:disabled ),input[ type='radio' ]:hover:not(:disabled ){border-color:var( --os-ui-accent,#2271b1 )}input[ type='checkbox' ]:focus-visible,input[ type='radio' ]:focus-visible{outline:none;box-shadow:var( --_holo-focus )}input[ type='checkbox' ]:checked,input[ type='checkbox' ]:indeterminate,input[ type='radio' ]:checked{border-color:transparent;background-color:var( --os-ui-accent,#2271b1 )}input[ type='checkbox' ]:checked:focus-visible,input[ type='radio' ]:checked:focus-visible{box-shadow:var( --_holo-focus )}input[ type='checkbox' ]:checked::after{content:'';position:absolute;inset-inline-start:50%;top:46%;width:3.5px;height:7.5px;border:solid var( --os-ui-fg-on-accent,#fff );border-width:0 2px 2px 0;transform:translate( -50%,-50% ) rotate( 45deg );animation:os-holo-tick 180ms cubic-bezier( 0.3,1.4,0.6,1 )}input[ type='checkbox' ]:indeterminate::after{content:'';position:absolute;inset-inline-start:50%;top:50%;width:8px;height:2px;border:0;border-radius:1px;background:var( --os-ui-fg-on-accent,#fff );transform:translate( -50%,-50% )}input[ type='radio' ]:checked::after{content:'';position:absolute;inset-inline-start:50%;top:50%;width:6px;height:6px;border-radius:50%;background:var( --os-ui-fg-on-accent,#fff );transform:translate( -50%,-50% );animation:os-holo-tick 180ms cubic-bezier( 0.3,1.4,0.6,1 )}input[ type='checkbox' ]:disabled,input[ type='radio' ]:disabled{cursor:not-allowed}@keyframes os-holo-tick{from{opacity:0;transform:translate( -50%,-50% ) rotate( 45deg ) scale( 0.4 )}}@media ( prefers-reduced-motion:reduce ){input[ type='checkbox' ]:checked::after,input[ type='radio' ]:checked::after{animation:none}}`,Me=A` @keyframes os-holo-drift{0%{background-position:16% 26%}50%{background-position:84% 74%}100%{background-position:16% 26%}}.os-holo-alive{animation:os-holo-drift var( --_holo-t-ambient ) var( --_holo-loop ) infinite}@media ( prefers-reduced-motion:reduce ){.os-holo-alive{animation:none}}`;A` ${re} ${Nt} ${Le} ${Te} ${Re} ${ze} ${St} ${It} ${Pe} ${Lt} ${Me} `;const Tt=A` ${re} ${Le} ${Te} ${Re} ${ze} ${Me}:host{display:inline-flex}:host( [ fill-cell ] ){display:flex;width:100%}button{appearance:none;display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:var( --os-ui-button-padding,6px 12px );border-radius:var( --os-ui-button-border-radius,6px );font:inherit;font-weight:500;cursor:pointer;transition:background-color var( --_holo-t ) ease,color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,transform 80ms ease;background:var( --os-ui-button-bg,transparent );background-image:var( --os-ui-button-bg-image,none );background-repeat:var( --os-ui-button-bg-image-repeat,repeat );background-size:var( --os-ui-button-bg-image-size,auto );background-position:var( --os-ui-button-bg-image-position,center );color:var( --os-ui-button-fg,var( --os-ui-fg,#1d2327 ) );border:var( --os-ui-button-border,1px solid var( --os-ui-border,#c3c4c7 ) )}:host( [ fill-cell ] ) button{width:100%;min-height:var( --os-ui-button-min-height,44px )}button:disabled{opacity:0.5;cursor:not-allowed}button:active:not(:disabled ){transform:translateY( 1px )}button:hover:not(:disabled ){background-color:var( --os-ui-button-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.04 ) ) )}button:focus-visible{outline:none;box-shadow:var( --_holo-focus )}button:disabled::before,button:disabled::after,button:disabled .os-holo-glint{opacity:0 !important}:host( [ variant='primary' ] ) button{background-color:var( --os-ui-button-bg,var( --wp-admin-theme-color,#2271b1 ) );color:var( --os-ui-button-fg,var( --os-ui-fg-on-accent,#fff ) );border:var( --os-ui-button-border,1px solid transparent )}:host( [ variant='primary' ] ) button:hover:not(:disabled ){filter:brightness( 1.06 );background-color:var( --os-ui-button-bg,var( --wp-admin-theme-color,#2271b1 ) );box-shadow:var( --_holo-glow )}:host( [ variant='holo' ] ) button{background-color:transparent;background-image:var( --_holo-fill );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;color:var( --os-ui-button-fg,var( --_holo-ink ) );border:var( --os-ui-button-border,1px solid transparent );box-shadow:var( --_holo-glow );font-weight:600;transition:background-position var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,filter var( --_holo-t ) ease,transform 80ms ease}:host( [ variant='holo' ] ) button:hover:not(:disabled ){background-color:transparent;background-position:74% 66%;box-shadow:var( --_holo-glow-strong )}:host( [ variant='holo' ] ) button:active:not(:disabled ){background-position:88% 82%;filter:brightness( 0.94 )}:host( [ variant='holo' ] ) button::before{display:none}@media ( prefers-reduced-motion:reduce ){:host( [ variant='holo' ] ) button:hover:not(:disabled ),:host( [ variant='holo' ] ) button:active:not(:disabled ){background-position:22% 28%}}:host( [ variant='secondary' ] ) button{background-color:var( --os-ui-button-bg,var( --os-ui-hover,rgba( 0,0,0,0.06 ) ) );color:var( --os-ui-button-fg,var( --os-ui-fg,#1d2327 ) );border:var( --os-ui-button-border,1px solid transparent )}:host( [ variant='secondary' ] ) button:hover:not(:disabled ){background-color:var( --os-ui-button-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.1 ) ) )}:host( [ variant='danger' ] ) button{background-color:var( --os-ui-button-bg,transparent );color:var( --os-ui-button-fg,var( --os-ui-danger,#d63638 ) );border:var( --os-ui-button-border,1px solid currentColor )}:host( [ variant='danger' ] ) button:hover:not(:disabled ){background-color:var( --os-ui-danger,#d63638 );color:var( --os-ui-fg-on-accent,#fff )}:host( [ variant='danger' ] ) button::after{display:none}:host( [ variant='link' ] ) button{background-color:transparent;background-image:none;color:var( --os-ui-button-fg,var( --wp-admin-theme-color,#2271b1 ) );border:0;padding:0;text-decoration:underline}:host( [ variant='link' ] ) button::before,:host( [ variant='link' ] ) button::after,:host( [ variant='link' ] ) .os-holo-glint,:host( [ variant='link' ] ) .os-holo-ring{display:none}:host( [ variant='link' ] ) button:active:not(:disabled ){transform:none}:host( [ busy ] ) button{pointer-events:none;opacity:0.75}:host( [ variant='holo' ][ busy ] ) button{animation:os-holo-drift 12s ease-in-out infinite}@media ( prefers-reduced-motion:reduce ){:host( [ variant='holo' ][ busy ] ) button{animation:none}}.os-button__spinner{box-sizing:border-box;display:inline-block;width:12px;height:12px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:os-button-spin 0.6s linear infinite;flex-shrink:0}@keyframes os-button-spin{to{transform:rotate( 360deg )}}`,Z=class Z extends M{render(){const e=this.disabled!==null,t=this.busy!==null,n=this.type||"button";return k` | |
| 26 | + `}_attr(e){return this.getAttribute(e)}_resolveSize(e){if(!e)return 32;if(e in Oe)return Oe[e];const t=Number(e);return Number.isFinite(t)&&t>0?t:32}_initials(e){const t=e.trim();return t?Array.from(t)[0]?.toUpperCase()??"?":"?"}_initialsBg(e){const t=Vt(e);return`linear-gradient(135deg, hsl(${t} 62% 55%), hsl(${(t+24)%360} 58% 42%))`}_presenceForRender(){const e=this._attr("presence");return e&&Be.has(e)?e:null}_presenceLabel(e){switch(e){case"online":return"Online";case"inactive":return"Inactive";case"offline":return"Offline"}}_onImgError(){this._imgFailed=!0,this.requestUpdate()}_onClick(e){const t=this._attr("user-id"),n={userId:t!==null&&Number(t)||null,originalEvent:e};this.emit("os-avatar-click",n)}_attachHoverEffect(){typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||(this._onPointerEnter=()=>{this.style.setProperty("--os-ui-avatar-hover","1")},this._onPointerLeave=()=>{this.style.setProperty("--os-ui-avatar-hover","0"),this._pendingTiltX="0deg",this._pendingTiltY="0deg",this._pendingGlareX="50%",this._pendingGlareY="50%",this._flushTilt()},this._onPointerMove=t=>{const n=this.getBoundingClientRect();if(n.width===0||n.height===0)return;const s=(t.clientX-n.left)/n.width-.5,r=(t.clientY-n.top)/n.height-.5,i=14;this._pendingTiltY=`${(s*i).toFixed(2)}deg`,this._pendingTiltX=`${(-r*i).toFixed(2)}deg`;const l=Math.max(0,Math.min(100,(s+.5)*100)),c=Math.max(0,Math.min(100,(r+.5)*100));this._pendingGlareX=`${l.toFixed(1)}%`,this._pendingGlareY=`${c.toFixed(1)}%`,this._tiltRaf||(this._tiltRaf=requestAnimationFrame(()=>this._flushTilt()))},this.addEventListener("pointerenter",this._onPointerEnter),this.addEventListener("pointerleave",this._onPointerLeave),this.addEventListener("pointermove",this._onPointerMove))}_flushTilt(){this._tiltRaf=0,this.style.setProperty("--os-ui-avatar-tilt-x",this._pendingTiltX),this.style.setProperty("--os-ui-avatar-tilt-y",this._pendingTiltY),this.style.setProperty("--os-ui-avatar-glare-x",this._pendingGlareX),this.style.setProperty("--os-ui-avatar-glare-y",this._pendingGlareY)}_detachHoverEffect(){this._onPointerMove&&(this.removeEventListener("pointermove",this._onPointerMove),this._onPointerMove=null),this._onPointerEnter&&(this.removeEventListener("pointerenter",this._onPointerEnter),this._onPointerEnter=null),this._onPointerLeave&&(this.removeEventListener("pointerleave",this._onPointerLeave),this._onPointerLeave=null),this._tiltRaf&&(cancelAnimationFrame(this._tiltRaf),this._tiltRaf=0)}_maybeAttachPresenceListener(){const e=this._attr("user-id"),t=this._attr("presence"),n=!!e&&!t;n&&!this._presenceHandler?(this._presenceHandler=s=>{const r=s.detail;r&&String(r.userId)===String(e)&&r.newStatus&&Be.has(r.newStatus)&&this.setAttribute("presence",r.newStatus)},document.addEventListener("os-presence-changed",this._presenceHandler)):!n&&this._presenceHandler&&(document.removeEventListener("os-presence-changed",this._presenceHandler),this._presenceHandler=null)}};oe.props=["src","alt","name","size","presence","userId","clickable"],oe.styles=[Jt],oe.help=void 0;let we=oe;K("os-avatar",we);const me=E`:host{--_holo-fill:var( --os-ui-holo-fill,${"linear-gradient( 124deg, #afa2e8 0%, #f5a8ea 46%, #8ee9f7 100% )"} );--_holo-ink:var( --os-ui-holo-ink,#0c0b0f );--_holo-sheen:var( --os-ui-holo-sheen,linear-gradient( 124deg,rgba( 159,214,255,0.1 ) 0%,rgba( 236,155,255,0.12 ) 34%,rgba( 242,82,252,0.1 ) 58%,rgba( 147,240,198,0.09 ) 100% ) );--_holo-edge:var( --os-ui-holo-edge,linear-gradient( 124deg,rgba( 154,242,255,0.7 ) 0%,rgba( 236,155,255,0.85 ) 38%,rgba( 242,82,252,0.7 ) 62%,rgba( 159,152,255,0.6 ) 100% ) );--_holo-edge-quiet:var( --os-ui-holo-edge-quiet,linear-gradient( 124deg,rgba( 154,242,255,0.22 ) 0%,rgba( 236,155,255,0.28 ) 38%,rgba( 242,82,252,0.22 ) 62%,rgba( 159,152,255,0.2 ) 100% ) );--_holo-glow:var( --os-ui-holo-glow,0 0 0 1px rgba( 242,82,252,0.28 ),0 2px 10px rgba( 242,82,252,0.22 ) );--_holo-glow-strong:var( --os-ui-holo-glow-strong,0 0 0 1px rgba( 242,82,252,0.42 ),0 4px 18px rgba( 242,82,252,0.38 ),0 1px 3px rgba( 12,11,15,0.6 ) );--_holo-track:var( --os-ui-holo-track,rgba( 255,251,255,0.16 ) );--_holo-track-edge:var( --os-ui-holo-track-edge,#8c8f94 );--_holo-ring-color:var( --os-ui-accent-dim,#2271b1 );--_holo-focus:var( --os-ui-focus-ring,0 0 0 2px rgba( 12,11,15,0.9 ),0 0 0 4px #f252fc,0 0 12px 2px rgba( 242,82,252,0.45 ) );--_holo-focus-field:var( --os-ui-focus-ring-field,0 0 0 1px #f252fc,0 0 0 4px rgba( 242,82,252,0.18 ) );--_holo-t:var( --os-ui-holo-transition,220ms );--_holo-t-fast:var( --os-ui-motion-fast,140ms );--_holo-t-slow:var( --os-ui-motion-slow,340ms );--_holo-t-ambient:var( --os-ui-motion-ambient,12s );--_holo-spring:var( --os-ui-ease-spring,cubic-bezier( 0.32,1.5,0.55,1 ) );--_holo-ease:var( --os-ui-ease-out,cubic-bezier( 0.22,0.9,0.28,1 ) );--_holo-loop:var( --os-ui-ease-loop,cubic-bezier( 0.45,0,0.55,1 ) )}`,Zt=E` .os-holo-fill{background-color:transparent;background-image:var( --_holo-fill );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;color:var( --_holo-ink );transition:background-position var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,filter var( --_holo-t ) ease}.os-holo-fill:hover{background-position:74% 66%}.os-holo-fill:active{background-position:88% 82%;filter:brightness( 0.94 )}@media ( prefers-reduced-motion:reduce ){.os-holo-fill{transition-duration:1ms}.os-holo-fill:hover,.os-holo-fill:active{background-position:22% 28%}}`,Ke=E` .os-holo-sheen{position:relative;isolation:isolate}.os-holo-sheen::before{content:'';position:absolute;inset:0;z-index:-1;border-radius:inherit;background-image:var( --_holo-sheen );background-size:200% 200%;background-position:20% 30%;opacity:0;pointer-events:none;transition:opacity var( --_holo-t ) ease,background-position var( --_holo-t ) ease}.os-holo-sheen:hover::before,.os-holo-sheen:focus-visible::before{opacity:1;background-position:76% 68%}@media ( prefers-reduced-motion:reduce ){.os-holo-sheen::before{transition-duration:1ms}.os-holo-sheen:hover::before,.os-holo-sheen:focus-visible::before{background-position:20% 30%}}`,Xe=E` .os-holo-edge{position:relative}.os-holo-edge::after{content:'';position:absolute;inset:0;border-radius:inherit;padding:1px;background-image:var( --_holo-edge-quiet );opacity:0;pointer-events:none;-webkit-mask:linear-gradient( #000 0 0 ) content-box,linear-gradient( #000 0 0 );-webkit-mask-composite:xor;mask:linear-gradient( #000 0 0 ) content-box,linear-gradient( #000 0 0 );mask-composite:exclude;transition:opacity var( --_holo-t ) ease}.os-holo-edge:hover::after,.os-holo-edge:focus-visible::after{background-image:var( --_holo-edge );opacity:1}.os-holo-edge.is-lit::after{background-image:var( --_holo-edge );opacity:1}@media ( prefers-reduced-motion:reduce ){.os-holo-edge::after{transition-duration:1ms}}`,Ye=E` .os-holo-glint{position:absolute;inset:0;border-radius:inherit;overflow:hidden;pointer-events:none}.os-holo-glint::before{content:'';position:absolute;top:-60%;bottom:-60%;width:45%;inset-inline-start:-60%;background:linear-gradient( 90deg,transparent 0%,rgba( 255,251,255,0.14 ) 45%,rgba( 255,251,255,0.22 ) 50%,rgba( 255,251,255,0.14 ) 55%,transparent 100% );transform:rotate( 18deg ) translateX( 0 );opacity:0}:hover>.os-holo-glint::before,:focus-visible>.os-holo-glint::before,:host(:hover )>.os-holo-glint::before,:host(:focus-visible )>.os-holo-glint::before{animation:os-holo-glint var( --_holo-t-slow ) var( --_holo-ease )}@keyframes os-holo-glint{0%{opacity:0;transform:rotate( 18deg ) translateX( 0 )}15%{opacity:1}85%{opacity:1}100%{opacity:0;transform:rotate( 18deg ) translateX( 240vw )}}@media ( prefers-reduced-motion:reduce ){:hover>.os-holo-glint::before,:focus-visible>.os-holo-glint::before,:host(:hover )>.os-holo-glint::before,:host(:focus-visible )>.os-holo-glint::before{animation:none}}`,Ge=E` .os-holo-ring{position:absolute;inset:0;border-radius:inherit;box-shadow:0 0 0 0 var( --_holo-ring-color );opacity:0;pointer-events:none}:active:not(:disabled )>.os-holo-ring,:host(:active:not( [ disabled ] ) )>.os-holo-ring{animation:os-holo-ring var( --_holo-t-slow ) var( --_holo-ease )}@keyframes os-holo-ring{0%{opacity:0.45;box-shadow:0 0 0 0 var( --_holo-ring-color )}100%{opacity:0;box-shadow:0 0 0 10px transparent}}@media ( prefers-reduced-motion:reduce ){:active:not(:disabled )>.os-holo-ring,:host(:active:not( [ disabled ] ) )>.os-holo-ring{animation:none}}`,Qt=E` .os-holo-shimmer{background-image:var( --_holo-fill );background-size:300% 300%;background-repeat:no-repeat;animation:os-holo-shimmer 2.4s var( --_holo-loop ) infinite}@keyframes os-holo-shimmer{0%{background-position:0% 50%}100%{background-position:100% 50%}}@media ( prefers-reduced-motion:reduce ){.os-holo-shimmer{animation:none;background-position:30% 50%}}`,eo=E` .os-holo-enter{animation:os-holo-enter var( --_holo-t ) var( --_holo-spring )}@keyframes os-holo-enter{from{opacity:0;transform:scale( 0.96 )}}@media ( prefers-reduced-motion:reduce ){.os-holo-enter{animation:none}}`,Ve=E` input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ),select,textarea{transition:background-color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):hover:not(:disabled ),select:hover:not(:disabled ),textarea:hover:not(:disabled ){border-color:var( --os-ui-border-strong,#8c8f94 )}input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):focus,input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):focus-visible,select:focus,select:focus-visible,textarea:focus,textarea:focus-visible{outline:none;border-color:var( --os-ui-accent,#2271b1 );box-shadow:var( --_holo-focus-field )}input::placeholder,textarea::placeholder{color:var( --os-ui-fg-faint,#8c8f94 );opacity:1}input::selection,textarea::selection{background:var( --os-ui-selection-bg,rgba( 159,152,255,0.6 ) );color:var( --os-ui-selection-fg,#fffbff )}@media ( prefers-reduced-motion:reduce ){input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ),select,textarea{transition-duration:1ms}}`,to=E` input[ type='checkbox' ],input[ type='radio' ]{appearance:none;-webkit-appearance:none;position:relative;flex:0 0 auto;box-sizing:border-box;width:16px;height:16px;margin:0;padding:0;border:1px solid var( --_holo-track-edge );border-radius:4px;background-color:var( --_holo-track );background-image:none;background-repeat:no-repeat;cursor:inherit;transition:background-color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input[ type='radio' ]{border-radius:50%}input[ type='checkbox' ]:hover:not(:disabled ),input[ type='radio' ]:hover:not(:disabled ){border-color:var( --os-ui-accent,#2271b1 )}input[ type='checkbox' ]:focus-visible,input[ type='radio' ]:focus-visible{outline:none;box-shadow:var( --_holo-focus )}input[ type='checkbox' ]:checked,input[ type='checkbox' ]:indeterminate,input[ type='radio' ]:checked{border-color:transparent;background-color:var( --os-ui-accent,#2271b1 )}input[ type='checkbox' ]:checked:focus-visible,input[ type='radio' ]:checked:focus-visible{box-shadow:var( --_holo-focus )}input[ type='checkbox' ]:checked::after{content:'';position:absolute;inset-inline-start:50%;top:46%;width:3.5px;height:7.5px;border:solid var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) );border-width:0 2px 2px 0;transform:translate( -50%,-50% ) rotate( 45deg );animation:os-holo-tick 180ms cubic-bezier( 0.3,1.4,0.6,1 )}input[ type='checkbox' ]:indeterminate::after{content:'';position:absolute;inset-inline-start:50%;top:50%;width:8px;height:2px;border:0;border-radius:1px;background:var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) );transform:translate( -50%,-50% )}input[ type='radio' ]:checked::after{content:'';position:absolute;inset-inline-start:50%;top:50%;width:6px;height:6px;border-radius:50%;background:var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) );transform:translate( -50%,-50% );animation:os-holo-tick 180ms cubic-bezier( 0.3,1.4,0.6,1 )}input[ type='checkbox' ]:disabled,input[ type='radio' ]:disabled{cursor:not-allowed}@keyframes os-holo-tick{from{opacity:0;transform:translate( -50%,-50% ) rotate( 45deg ) scale( 0.4 )}}@media ( prefers-reduced-motion:reduce ){input[ type='checkbox' ]:checked::after,input[ type='radio' ]:checked::after{animation:none}}`,Je=E` @keyframes os-holo-drift{0%{background-position:16% 26%}50%{background-position:84% 74%}100%{background-position:16% 26%}}.os-holo-alive{animation:os-holo-drift var( --_holo-t-ambient ) var( --_holo-loop ) infinite}@media ( prefers-reduced-motion:reduce ){.os-holo-alive{animation:none}}`;E` ${me} ${Zt} ${Ke} ${Xe} ${Ye} ${Ge} ${Qt} ${eo} ${Ve} ${to} ${Je} `;const oo=E` ${me} ${Ke} ${Xe} ${Ye} ${Ge} ${Je}:host{display:inline-flex}:host( [ fill-cell ] ){display:flex;width:100%}button{appearance:none;display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:var( --os-ui-button-padding,6px 12px );border-radius:var( --os-ui-button-border-radius,6px );font:inherit;font-weight:500;cursor:pointer;transition:background-color var( --_holo-t ) ease,color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,transform 80ms ease;background:var( --os-ui-button-bg,transparent );background-image:var( --os-ui-button-bg-image,none );background-repeat:var( --os-ui-button-bg-image-repeat,repeat );background-size:var( --os-ui-button-bg-image-size,auto );background-position:var( --os-ui-button-bg-image-position,center );color:var( --os-ui-button-fg,var( --os-ui-fg,#1d2327 ) );border:var( --os-ui-button-border,1px solid var( --os-ui-border,#c3c4c7 ) )}:host( [ fill-cell ] ) button{width:100%;min-height:var( --os-ui-button-min-height,44px )}button:disabled{opacity:0.5;cursor:not-allowed}button:active:not(:disabled ){transform:translateY( 1px )}button:hover:not(:disabled ){background-color:var( --os-ui-button-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.04 ) ) )}button:focus-visible{outline:none;box-shadow:var( --_holo-focus )}button:disabled::before,button:disabled::after,button:disabled .os-holo-glint{opacity:0 !important}:host( [ variant='primary' ] ) button{background-color:var( --os-ui-button-bg,var( --wp-admin-theme-color,#2271b1 ) );color:var( --os-ui-button-fg,var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) ) );border:var( --os-ui-button-border,1px solid transparent )}:host( [ variant='primary' ] ) button:hover:not(:disabled ){filter:brightness( 1.06 );background-color:var( --os-ui-button-bg,var( --wp-admin-theme-color,#2271b1 ) );box-shadow:var( --_holo-glow )}:host( [ variant='holo' ] ) button{background-color:transparent;background-image:var( --_holo-fill );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;color:var( --os-ui-button-fg,var( --_holo-ink ) );border:var( --os-ui-button-border,1px solid transparent );box-shadow:var( --_holo-glow );font-weight:600;transition:background-position var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,filter var( --_holo-t ) ease,transform 80ms ease}:host( [ variant='holo' ] ) button:hover:not(:disabled ){background-color:transparent;background-position:74% 66%;box-shadow:var( --_holo-glow-strong )}:host( [ variant='holo' ] ) button:active:not(:disabled ){background-position:88% 82%;filter:brightness( 0.94 )}:host( [ variant='holo' ] ) button::before{display:none}@media ( prefers-reduced-motion:reduce ){:host( [ variant='holo' ] ) button:hover:not(:disabled ),:host( [ variant='holo' ] ) button:active:not(:disabled ){background-position:22% 28%}}:host( [ variant='secondary' ] ) button{background-color:var( --os-ui-button-bg,var( --os-ui-hover,rgba( 0,0,0,0.06 ) ) );color:var( --os-ui-button-fg,var( --os-ui-fg,#1d2327 ) );border:var( --os-ui-button-border,1px solid transparent )}:host( [ variant='secondary' ] ) button:hover:not(:disabled ){background-color:var( --os-ui-button-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.1 ) ) )}:host( [ variant='danger' ] ) button{background-color:var( --os-ui-button-bg,transparent );color:var( --os-ui-button-fg,var( --os-ui-danger,#d63638 ) );border:var( --os-ui-button-border,1px solid currentColor )}:host( [ variant='danger' ] ) button:hover:not(:disabled ){background-color:var( --os-ui-danger,#d63638 );color:var( --os-ui-fg-on-accent,#fff )}:host( [ variant='danger' ] ) button::after{display:none}:host( [ variant='link' ] ) button{background-color:transparent;background-image:none;color:var( --os-ui-button-fg,var( --wp-admin-theme-color,#2271b1 ) );border:0;padding:0;text-decoration:underline}:host( [ variant='link' ] ) button::before,:host( [ variant='link' ] ) button::after,:host( [ variant='link' ] ) .os-holo-glint,:host( [ variant='link' ] ) .os-holo-ring{display:none}:host( [ variant='link' ] ) button:active:not(:disabled ){transform:none}:host( [ busy ] ) button{pointer-events:none;opacity:0.75}:host( [ variant='holo' ][ busy ] ) button{animation:os-holo-drift 12s ease-in-out infinite}@media ( prefers-reduced-motion:reduce ){:host( [ variant='holo' ][ busy ] ) button{animation:none}}.os-button__spinner{box-sizing:border-box;display:inline-block;width:12px;height:12px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:os-button-spin 0.6s linear infinite;flex-shrink:0}@keyframes os-button-spin{to{transform:rotate( 360deg )}}`,ne=class ne extends q{static get observedAttributes(){return[...super.observedAttributes,"aria-label"]}render(){const e=this.disabled!==null,t=this.busy!==null,n=this.type||"button",s=this.getAttribute("aria-label")||"";return y` | |
| 27 | 27 | <button |
| 28 | 28 | part="button" |
| 29 | 29 | class="os-holo-edge os-holo-sheen" |
| 30 | 30 | type=${n} |
| @@ -29,10 +29,11 @@ | ||
| 29 | 29 | class="os-holo-edge os-holo-sheen" |
| 30 | 30 | type=${n} |
| 31 | 31 | ?disabled=${e||t} |
| 32 | 32 | aria-busy=${t?"true":"false"} |
| 33 | + aria-label=${s} | |
| 33 | 34 | > |
| 34 | - ${t?k`<span class="os-button__spinner" aria-hidden="true"></span>`:""} | |
| 35 | + ${t?y`<span class="os-button__spinner" aria-hidden="true"></span>`:""} | |
| 35 | 36 | <slot></slot> |
| 36 | 37 | <!-- |
| 37 | 38 | The two motion layers. Elements rather than |
| 38 | 39 | pseudo-elements because the sheen and the hairline |
| @@ -42,16 +43,16 @@ | ||
| 42 | 43 | --> |
| 43 | 44 | <span class="os-holo-glint" aria-hidden="true"></span> |
| 44 | 45 | <span class="os-holo-ring" aria-hidden="true"></span> |
| 45 | 46 | </button> |
| 46 | - `}};Z.props=["variant","disabled","type","busy","fill-cell"],Z.styles=[Tt],Z.help=void 0;let fe=Z;H("os-button",fe);const Rt=A`:host{display:inline-flex;align-items:center;justify-content:center;width:var( --os-ui-icon-size,16px );height:var( --os-ui-icon-size,16px );color:inherit;line-height:1}:host( [ hidden ] ){display:none}.os-icon__glyph{font-size:var( --os-ui-icon-size,16px );width:var( --os-ui-icon-size,16px );height:var( --os-ui-icon-size,16px );line-height:1;color:inherit;display:inline-flex;align-items:center;justify-content:center}.os-icon__glyph--char{font-family:dashicons;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none}.os-icon__glyph.dashicons{font-family:dashicons}`;let ae=null;function zt(o){let e=o.trim();if(e==="")return null;(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1));const t=e.match(/^\\([0-9a-f]{1,6})\s?$/i);return t?String.fromCodePoint(parseInt(t[1],16)):e||null}function Fe(){const o=new Map;if(typeof document>"u")return o;const e=Array.from(document.styleSheets??[]);for(const t of e){let n=null;try{n=t.cssRules}catch{continue}if(n)for(const s of Array.from(n)){const i=s;if(!i||!i.selectorText)continue;const r=i.selectorText.match(/\.dashicons-([a-z0-9-]+)::?before/i);if(!r)continue;const l=i.style?.content;if(!l)continue;const a=zt(l);a&&o.set(r[1],a)}}return o}function Pt(o){ae||(ae=Fe());const e=o.startsWith("dashicons-")?o.slice(10):o;return ae.get(e)??null}function Mt(){ae=Fe()}let De=!1;function Ft(){if(De||typeof window>"u")return;De=!0;const o=()=>{Mt()};document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",o,{once:!0}),window.addEventListener("load",o,{once:!0})}Ft();const J=class J extends M{render(){const e=this.name||"",t=e.startsWith("dashicons-")?e.slice(10):e,n=this.size;n&&/^\d+$/.test(n)&&this.style.setProperty("--os-ui-icon-size",`${n}px`);const s=Pt(t);return s?k`<span | |
| 47 | + `}};ne.props=["variant","disabled","type","busy","fill-cell"],ne.styles=[oo],ne.help=void 0;let $e=ne;K("os-button",$e);const no=E`:host{display:inline-flex;align-items:center;justify-content:center;width:var( --os-ui-icon-size,16px );height:var( --os-ui-icon-size,16px );color:inherit;line-height:1}:host( [ hidden ] ){display:none}.os-icon__glyph{font-size:var( --os-ui-icon-size,16px );width:var( --os-ui-icon-size,16px );height:var( --os-ui-icon-size,16px );line-height:1;color:inherit;display:inline-flex;align-items:center;justify-content:center}.os-icon__glyph--char{font-family:dashicons;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none}.os-icon__glyph.dashicons{font-family:dashicons}`;let ge=null;function so(o){let e=o.trim();if(e==="")return null;(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1));const t=e.match(/^\\([0-9a-f]{1,6})\s?$/i);return t?String.fromCodePoint(parseInt(t[1],16)):e||null}function Ze(){const o=new Map;if(typeof document>"u")return o;const e=Array.from(document.styleSheets??[]);for(const t of e){let n=null;try{n=t.cssRules}catch{continue}if(n)for(const s of Array.from(n)){const r=s;if(!r||!r.selectorText)continue;const i=r.selectorText.match(/\.dashicons-([a-z0-9-]+)::?before/i);if(!i)continue;const l=r.style?.content;if(!l)continue;const c=so(l);c&&o.set(i[1],c)}}return o}function ro(o){ge||(ge=Ze());const e=o.startsWith("dashicons-")?o.slice(10):o;return ge.get(e)??null}function io(){ge=Ze()}let Qe=!1;function ao(){if(Qe||typeof window>"u")return;Qe=!0;const o=()=>{io()};document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",o,{once:!0}),window.addEventListener("load",o,{once:!0})}ao();const se=class se extends q{render(){const e=this.name||"",t=e.startsWith("dashicons-")?e.slice(10):e,n=this.size;n&&/^\d+$/.test(n)&&this.style.setProperty("--os-ui-icon-size",`${n}px`);const s=ro(t);return s?y`<span | |
| 47 | 48 | class="os-icon__glyph os-icon__glyph--char dashicons dashicons-${t}" |
| 48 | 49 | aria-hidden="true" |
| 49 | - >${s}</span>`:k`<span | |
| 50 | + >${s}</span>`:y`<span | |
| 50 | 51 | class="os-icon__glyph dashicons dashicons-${t}" |
| 51 | 52 | aria-hidden="true" |
| 52 | - ></span>`}};J.props=["name","size"],J.styles=[Rt],J.help=void 0;let me=J;H("os-icon",me);const Dt=A`:host{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:32px 24px;text-align:center;color:var( --os-ui-empty-state-fg,var( --os-ui-fg-muted,#646970 ) )}:host( [ hidden ] ){display:none}.os-empty-state__icon{margin-bottom:4px;color:var( --os-ui-empty-state-icon-color,currentColor );opacity:0.75}.os-empty-state__heading{margin:0;font-size:14px;font-weight:600;color:var( --os-ui-fg,#1d2327 )}.os-empty-state__description{margin:0;font-size:12px;line-height:1.4;max-width:48ch}.os-empty-state__description:empty{display:none}.os-empty-state__cta{margin-top:8px}.os-empty-state__cta:empty{display:none}`,Q=class Q extends M{render(){const e=this.icon||"",t=this.heading||"",n=this.description||"";return k` | |
| 53 | - ${e?k`<os-icon | |
| 53 | + ></span>`}};se.props=["name","size"],se.styles=[no],se.help=void 0;let Ae=se;K("os-icon",Ae);const co=E`:host{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:32px 24px;text-align:center;color:var( --os-ui-empty-state-fg,var( --os-ui-fg-muted,#646970 ) )}:host( [ hidden ] ){display:none}.os-empty-state__icon{margin-bottom:4px;color:var( --os-ui-empty-state-icon-color,currentColor );opacity:0.75}.os-empty-state__heading{margin:0;font-size:14px;font-weight:600;color:var( --os-ui-fg,#1d2327 )}.os-empty-state__description{margin:0;font-size:12px;line-height:1.4;max-width:48ch}.os-empty-state__description:empty{display:none}.os-empty-state__cta{margin-top:8px}.os-empty-state__cta:empty{display:none}`,re=class re extends q{render(){const e=this.icon||"",t=this.heading||"",n=this.description||"";return y` | |
| 54 | + ${e?y`<os-icon | |
| 54 | 55 | class="os-empty-state__icon" |
| 55 | 56 | name=${e} |
| 56 | 57 | size="28" |
| 57 | 58 | ></os-icon>`:null} |
| @@ -60,43 +61,43 @@ | ||
| 60 | 61 | <div class="os-empty-state__cta"> |
| 61 | 62 | <slot name="cta"></slot> |
| 62 | 63 | </div> |
| 63 | 64 | <slot></slot> |
| 64 | - `}};Q.props=["icon","heading","description"],Q.styles=[Dt],Q.help=void 0;let ge=Q;H("os-empty-state",ge);const Ut=A`:host{display:inline-block;--_color:var( --os-ui-spinner-color,var( --wp-admin-theme-color,#21759b ) );--_accent:var( --os-ui-spinner-accent,var( --os-ui-fg-on-accent,#fff ) );--_size:var( --os-ui-spinner-size,48px );width:var( --_size );height:var( --_size );color:var( --_color );vertical-align:middle;line-height:0}:host( [ hidden ] ){display:none}:host( [ preset='inline' ] ){--os-ui-spinner-color:currentColor;--os-ui-spinner-size:16px}.root,.root svg{display:block;width:100%;height:100%}.root svg .mark{fill:var( --_accent )}@keyframes os-spinner-spin{to{transform:rotate( 360deg )}}@keyframes os-spinner-scale{0%,100%{transform:scale( 1 )}50%{transform:scale( 1.045 )}}@keyframes os-spinner-opacity{0%,100%{opacity:1}50%{opacity:0.7}}@media ( prefers-reduced-motion:reduce ){.root svg [ style*='animation' ]{animation:none !important}}`,Ue=Object.freeze({classic:{sp1:12,sp2:24,sp3:40,a1:28,a2:15,a3:8,gap:4,dir2:1,dir3:-1,pulse:"none",dots:0},comet:{sp1:8,sp2:14,sp3:26,a1:50,a2:28,a3:12,gap:3,dir2:1,dir3:1,pulse:"none",dots:5},orbit:{sp1:10,sp2:10,sp3:32,a1:50,a2:50,a3:8,gap:5,dir2:-1,dir3:-1,pulse:"opacity",dots:3},pulse:{sp1:6,sp2:18,sp3:30,a1:20,a2:12,a3:6,gap:4,dir2:1,dir3:-1,pulse:"both",dots:8},inline:{sp1:8,sp2:8,sp3:8,a1:25,a2:25,a3:25,gap:0,dir2:1,dir3:1,pulse:"none",dots:0}}),R=61.26,z=61.26,He=58.453,Ht='<path d="m8.708 61.26c0 20.802 12.089 38.779 29.619 47.298l-25.069-68.686c-2.916 6.536-4.55 13.769-4.55 21.388z"/><path d="m96.74 58.608c0-6.495-2.333-10.993-4.334-14.494-2.664-4.329-5.161-7.995-5.161-12.324 0-4.831 3.664-9.328 8.825-9.328.233 0 .454.029.681.042-9.35-8.566-21.807-13.796-35.489-13.796-18.36 0-34.513 9.42-43.91 23.688 1.233.037 2.395.063 3.382.063 5.497 0 14.006-.667 14.006-.667 2.833-.167 3.167 3.994.337 4.329 0 0-2.847.335-6.015.501l19.138 56.925 11.501-34.493-8.188-22.434c-2.83-.166-5.511-.501-5.511-.501-2.832-.166-2.5-4.496.332-4.329 0 0 8.679.667 13.843.667 5.496 0 14.006-.667 14.006-.667 2.835-.167 3.168 3.994.337 4.329 0 0-2.853.335-6.015.501l18.992 56.494 5.242-17.517c2.272-7.269 4.001-12.49 4.001-16.989z"/><path d="m62.184 65.857-15.768 45.819c4.708 1.384 9.687 2.141 14.846 2.141 6.12 0 11.989-1.058 17.452-2.979-.141-.225-.269-.464-.374-.724z"/><path d="m107.376 36.046c.226 1.674.354 3.471.354 5.404 0 5.333-.996 11.328-3.996 18.824l-16.053 46.413c15.624-9.111 26.133-26.038 26.133-45.426.001-9.137-2.333-17.729-6.438-25.215z"/>',ee=class ee extends M{constructor(){super(...arguments),this._paintScheduled=!1}connectedCallback(){super.connectedCallback(),this._schedulePaint()}render(){return k`<div class="root" part="root"></div>`}requestUpdate(){super.requestUpdate(),this._schedulePaint()}_schedulePaint(){this._paintScheduled||!this.isConnected||(this._paintScheduled=!0,queueMicrotask(()=>{this._paintScheduled=!1,this.isConnected&&this._paint()}))}_paint(){this._syncCssVars();const e=this.shadowRoot?.querySelector(".root");e&&(e.innerHTML=this._buildSvg())}_syncCssVars(){const e=(t,n,s)=>{const i=this.getAttribute(t);i===null?this.style.removeProperty(n):this.style.setProperty(n,s?s(i):i)};e("color","--os-ui-spinner-color"),e("accent","--os-ui-spinner-accent"),e("size","--os-ui-spinner-size",t=>/^-?\d+(\.\d+)?$/.test(t.trim())?`${t}px`:t)}_effectiveConfig(){const e=this.getAttribute("preset")??"classic",t=Ue[e]??Ue.classic,n=(r,l)=>{const a=this.getAttribute(r);if(a===null)return l;const d=parseFloat(a);return Number.isFinite(d)?d:l},s=(r,l)=>{const a=this.getAttribute(r);if(a===null)return l;const d=a.toLowerCase();return d==="-1"||d==="ccw"||d==="reverse"?-1:1},i=()=>{const r=this.getAttribute("pulse");return r==="scale"||r==="opacity"||r==="both"||r==="none"?r:t.pulse};return{sp1:n("sp1",t.sp1),sp2:n("sp2",t.sp2),sp3:n("sp3",t.sp3),a1:n("a1",t.a1),a2:n("a2",t.a2),a3:n("a3",t.a3),gap:n("gap",t.gap),dir2:s("dir2",t.dir2),dir3:s("dir3",t.dir3),pulse:i(),dots:Math.max(0,Math.floor(n("dots",t.dots)))}}_buildInlineSvg(e){const t=We(this.getAttribute("label")??"Loading"),n=9,s=(e.sp1/10).toFixed(2);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-label="${t}"><circle cx="12" cy="12" r="${n}" fill="none" stroke="currentColor" stroke-width="2.4" stroke-opacity="0.22"/><circle cx="12" cy="12" r="${n}" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-dasharray="${ce(n,e.a1)}" style="transform-origin:12px 12px;animation: os-spinner-spin ${s}s linear infinite"/></svg>`}_buildSvg(){const e=this._effectiveConfig();if(this.getAttribute("preset")==="inline")return this._buildInlineSvg(e);const t=We(this.getAttribute("label")??"Loading"),n=e.gap*3+14,s=-n,i=122.52+n*2,r=He+e.gap+2,l=r+e.gap+2,a=l+e.gap+1.5,d=`animation: os-spinner-spin ${(e.sp1/10).toFixed(2)}s linear infinite`,u=`animation: os-spinner-spin ${(e.sp2/10).toFixed(2)}s linear infinite${e.dir2<0?" reverse":""}`,p=`animation: os-spinner-spin ${(e.sp3/10).toFixed(2)}s linear infinite${e.dir3<0?" reverse":""}`,v=(e.sp1*1.8/10).toFixed(1),$=(e.sp1*2.3/10).toFixed(1);let b="";e.pulse==="scale"?b=`animation: os-spinner-scale ${v}s ease-in-out infinite`:e.pulse==="opacity"?b=`animation: os-spinner-opacity ${$}s ease-in-out infinite`:e.pulse==="both"&&(b=`animation: os-spinner-scale ${v}s ease-in-out infinite, os-spinner-opacity ${$}s ease-in-out infinite`);let I="";if(e.dots>0){const C=a+e.gap+1,c=2*Math.PI*C,h=1.6,f=(e.sp1*.65/10).toFixed(2);for(let _=0;_<e.dots;_++){const E=-(_/e.dots)*c;I+=`<circle cx="${R}" cy="${z}" r="${C.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="${h}" stroke-dasharray="${h.toFixed(2)} ${(c-h).toFixed(2)}" stroke-dashoffset="${E.toFixed(2)}" stroke-linecap="round" stroke-opacity="0.65" style="transform-origin:${R}px ${z}px;animation: os-spinner-spin ${f}s linear infinite"/>`}}return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${s} ${s} ${i} ${i}" role="img" aria-label="${t}"><g style="transform-origin:${R}px ${z}px${b?";"+b:""}"><circle cx="${R}" cy="${z}" r="${He}" fill="currentColor"/><g class="mark">${Ht}</g></g><circle cx="${R}" cy="${z}" r="${r.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="0.6" stroke-opacity="0.2"/><circle cx="${R}" cy="${z}" r="${r.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="2.2" stroke-dasharray="${ce(r,e.a1)}" stroke-linecap="round" style="transform-origin:${R}px ${z}px;${d}"/><circle cx="${R}" cy="${z}" r="${l.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="0.5" stroke-opacity="0.15"/><circle cx="${R}" cy="${z}" r="${l.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="1.6" stroke-opacity="0.8" stroke-dasharray="${ce(l,e.a2)}" stroke-linecap="round" style="transform-origin:${R}px ${z}px;${u}"/><circle cx="${R}" cy="${z}" r="${a.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="0.4" stroke-opacity="0.12"/><circle cx="${R}" cy="${z}" r="${a.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="1.0" stroke-opacity="0.6" stroke-dasharray="${ce(a,e.a3)}" stroke-linecap="round" style="transform-origin:${R}px ${z}px;${p}"/>`+I+"</svg>"}};ee.props=["preset","size","color","accent","sp1","sp2","sp3","a1","a2","a3","gap","dir2","dir3","pulse","dots","label"],ee.styles=[Ut],ee.help=void 0;let be=ee;function ce(o,e){const t=2*Math.PI*o,n=e/100*t,s=t-n;return`${n.toFixed(2)} ${s.toFixed(2)}`}function We(o){return String(o).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}H("os-spinner",be);const Wt=A` ${re} ${Pe}:host{--_field-size:var( --os-ui-field-font-size,13px );--_field-radius:var( --os-ui-field-radius,6px );display:flex;flex-direction:column;gap:4px;font-size:var( --_field-size );color:var( --os-ui-fg,#1d2327 );min-width:0}:host( [ hidden ] ){display:none}.os-textarea__label{font-size:12px;color:var( --os-ui-fg-muted,#646970 )}textarea{appearance:none;-webkit-appearance:none;display:block;width:100%;min-width:0;box-sizing:border-box;padding:8px 10px;background:var( --os-window-bg,#fff );border:1px solid var( --os-ui-border,#dcdcde );border-radius:var( --_field-radius );font:inherit;font-size:var( --_field-size );line-height:1.45;color:var( --os-ui-fg,#1d2327 );resize:vertical}textarea:disabled{opacity:0.55;cursor:not-allowed;background:var( --os-ui-hover,rgba( 0,0,0,0.03 ) )}textarea[ aria-invalid='true' ],textarea[ aria-invalid='true' ]:hover:not(:disabled ){border-color:var( --os-ui-danger,#d63638 )}textarea[ aria-invalid='true' ]:focus,textarea[ aria-invalid='true' ]:focus-visible{border-color:var( --os-ui-danger,#d63638 );box-shadow:0 0 0 1px var( --os-ui-danger,#d63638 ),0 0 0 4px rgba( 214,54,56,0.18 )}:host( [ auto-grow ] ) textarea{resize:none;overflow:hidden}`,te=class te extends M{constructor(){super(...arguments),this._textareaEl=null}connectedCallback(){super.connectedCallback(),Ct(this)}render(){const e=this._attr("label")||"",t=this._attr("value")??"",n=this._attr("placeholder")||"",s=this._boolAttr("disabled"),i=this._boolAttr("readonly"),r=this._attr("aria-label")||e,l=this._attr("name")||"",a=Number(this._attr("rows"))||3,d=this._attr("maxlength"),u=this._attr("minlength"),p=this._boolAttr("invalid"),$=`${this.id||"os-unnamed"}__field`;return k` | |
| 65 | - ${e?k`<label class="os-textarea__label" for=${$}>${e}</label>`:k``} | |
| 65 | + `}};re.props=["icon","heading","description"],re.styles=[co],re.help=void 0;let Ce=re;K("os-empty-state",Ce);const lo=E`:host{display:inline-block;--_color:var( --os-ui-spinner-color,var( --wp-admin-theme-color,#21759b ) );--_accent:var( --os-ui-spinner-accent,var( --os-ui-fg-on-accent,#fff ) );--_size:var( --os-ui-spinner-size,48px );width:var( --_size );height:var( --_size );color:var( --_color );vertical-align:middle;line-height:0}:host( [ hidden ] ){display:none}:host( [ preset='inline' ] ){--os-ui-spinner-color:currentColor;--os-ui-spinner-size:16px}.root,.root svg{display:block;width:100%;height:100%}.root svg .mark{fill:var( --_accent )}@keyframes os-spinner-spin{to{transform:rotate( 360deg )}}@keyframes os-spinner-scale{0%,100%{transform:scale( 1 )}50%{transform:scale( 1.045 )}}@keyframes os-spinner-opacity{0%,100%{opacity:1}50%{opacity:0.7}}@media ( prefers-reduced-motion:reduce ){.root svg [ style*='animation' ]{animation:none !important}}`,et=Object.freeze({classic:{sp1:12,sp2:24,sp3:40,a1:28,a2:15,a3:8,gap:4,dir2:1,dir3:-1,pulse:"none",dots:0},comet:{sp1:8,sp2:14,sp3:26,a1:50,a2:28,a3:12,gap:3,dir2:1,dir3:1,pulse:"none",dots:5},orbit:{sp1:10,sp2:10,sp3:32,a1:50,a2:50,a3:8,gap:5,dir2:-1,dir3:-1,pulse:"opacity",dots:3},pulse:{sp1:6,sp2:18,sp3:30,a1:20,a2:12,a3:6,gap:4,dir2:1,dir3:-1,pulse:"both",dots:8},inline:{sp1:8,sp2:8,sp3:8,a1:25,a2:25,a3:25,gap:0,dir2:1,dir3:1,pulse:"none",dots:0}}),P=61.26,M=61.26,tt=58.453,uo='<path d="m8.708 61.26c0 20.802 12.089 38.779 29.619 47.298l-25.069-68.686c-2.916 6.536-4.55 13.769-4.55 21.388z"/><path d="m96.74 58.608c0-6.495-2.333-10.993-4.334-14.494-2.664-4.329-5.161-7.995-5.161-12.324 0-4.831 3.664-9.328 8.825-9.328.233 0 .454.029.681.042-9.35-8.566-21.807-13.796-35.489-13.796-18.36 0-34.513 9.42-43.91 23.688 1.233.037 2.395.063 3.382.063 5.497 0 14.006-.667 14.006-.667 2.833-.167 3.167 3.994.337 4.329 0 0-2.847.335-6.015.501l19.138 56.925 11.501-34.493-8.188-22.434c-2.83-.166-5.511-.501-5.511-.501-2.832-.166-2.5-4.496.332-4.329 0 0 8.679.667 13.843.667 5.496 0 14.006-.667 14.006-.667 2.835-.167 3.168 3.994.337 4.329 0 0-2.853.335-6.015.501l18.992 56.494 5.242-17.517c2.272-7.269 4.001-12.49 4.001-16.989z"/><path d="m62.184 65.857-15.768 45.819c4.708 1.384 9.687 2.141 14.846 2.141 6.12 0 11.989-1.058 17.452-2.979-.141-.225-.269-.464-.374-.724z"/><path d="m107.376 36.046c.226 1.674.354 3.471.354 5.404 0 5.333-.996 11.328-3.996 18.824l-16.053 46.413c15.624-9.111 26.133-26.038 26.133-45.426.001-9.137-2.333-17.729-6.438-25.215z"/>',ie=class ie extends q{constructor(){super(...arguments),this._paintScheduled=!1}connectedCallback(){super.connectedCallback(),this._schedulePaint()}render(){return y`<div class="root" part="root"></div>`}requestUpdate(){super.requestUpdate(),this._schedulePaint()}_schedulePaint(){this._paintScheduled||!this.isConnected||(this._paintScheduled=!0,queueMicrotask(()=>{this._paintScheduled=!1,this.isConnected&&this._paint()}))}_paint(){this._syncCssVars();const e=this.shadowRoot?.querySelector(".root");e&&(e.innerHTML=this._buildSvg())}_syncCssVars(){const e=(t,n,s)=>{const r=this.getAttribute(t);r===null?this.style.removeProperty(n):this.style.setProperty(n,s?s(r):r)};e("color","--os-ui-spinner-color"),e("accent","--os-ui-spinner-accent"),e("size","--os-ui-spinner-size",t=>/^-?\d+(\.\d+)?$/.test(t.trim())?`${t}px`:t)}_effectiveConfig(){const e=this.getAttribute("preset")??"classic",t=et[e]??et.classic,n=(i,l)=>{const c=this.getAttribute(i);if(c===null)return l;const a=parseFloat(c);return Number.isFinite(a)?a:l},s=(i,l)=>{const c=this.getAttribute(i);if(c===null)return l;const a=c.toLowerCase();return a==="-1"||a==="ccw"||a==="reverse"?-1:1},r=()=>{const i=this.getAttribute("pulse");return i==="scale"||i==="opacity"||i==="both"||i==="none"?i:t.pulse};return{sp1:n("sp1",t.sp1),sp2:n("sp2",t.sp2),sp3:n("sp3",t.sp3),a1:n("a1",t.a1),a2:n("a2",t.a2),a3:n("a3",t.a3),gap:n("gap",t.gap),dir2:s("dir2",t.dir2),dir3:s("dir3",t.dir3),pulse:r(),dots:Math.max(0,Math.floor(n("dots",t.dots)))}}_buildInlineSvg(e){const t=ot(this.getAttribute("label")??"Loading"),n=9,s=(e.sp1/10).toFixed(2);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-label="${t}"><circle cx="12" cy="12" r="${n}" fill="none" stroke="currentColor" stroke-width="2.4" stroke-opacity="0.22"/><circle cx="12" cy="12" r="${n}" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-dasharray="${be(n,e.a1)}" style="transform-origin:12px 12px;animation: os-spinner-spin ${s}s linear infinite"/></svg>`}_buildSvg(){const e=this._effectiveConfig();if(this.getAttribute("preset")==="inline")return this._buildInlineSvg(e);const t=ot(this.getAttribute("label")??"Loading"),n=e.gap*3+14,s=-n,r=122.52+n*2,i=tt+e.gap+2,l=i+e.gap+2,c=l+e.gap+1.5,a=`animation: os-spinner-spin ${(e.sp1/10).toFixed(2)}s linear infinite`,u=`animation: os-spinner-spin ${(e.sp2/10).toFixed(2)}s linear infinite${e.dir2<0?" reverse":""}`,p=`animation: os-spinner-spin ${(e.sp3/10).toFixed(2)}s linear infinite${e.dir3<0?" reverse":""}`,f=(e.sp1*1.8/10).toFixed(1),x=(e.sp1*2.3/10).toFixed(1);let b="";e.pulse==="scale"?b=`animation: os-spinner-scale ${f}s ease-in-out infinite`:e.pulse==="opacity"?b=`animation: os-spinner-opacity ${x}s ease-in-out infinite`:e.pulse==="both"&&(b=`animation: os-spinner-scale ${f}s ease-in-out infinite, os-spinner-opacity ${x}s ease-in-out infinite`);let S="";if(e.dots>0){const w=c+e.gap+1,N=2*Math.PI*w,T=1.6,F=(e.sp1*.65/10).toFixed(2);for(let H=0;H<e.dots;H++){const le=-(H/e.dots)*N;S+=`<circle cx="${P}" cy="${M}" r="${w.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="${T}" stroke-dasharray="${T.toFixed(2)} ${(N-T).toFixed(2)}" stroke-dashoffset="${le.toFixed(2)}" stroke-linecap="round" stroke-opacity="0.65" style="transform-origin:${P}px ${M}px;animation: os-spinner-spin ${F}s linear infinite"/>`}}return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${s} ${s} ${r} ${r}" role="img" aria-label="${t}"><g style="transform-origin:${P}px ${M}px${b?";"+b:""}"><circle cx="${P}" cy="${M}" r="${tt}" fill="currentColor"/><g class="mark">${uo}</g></g><circle cx="${P}" cy="${M}" r="${i.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="0.6" stroke-opacity="0.2"/><circle cx="${P}" cy="${M}" r="${i.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="2.2" stroke-dasharray="${be(i,e.a1)}" stroke-linecap="round" style="transform-origin:${P}px ${M}px;${a}"/><circle cx="${P}" cy="${M}" r="${l.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="0.5" stroke-opacity="0.15"/><circle cx="${P}" cy="${M}" r="${l.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="1.6" stroke-opacity="0.8" stroke-dasharray="${be(l,e.a2)}" stroke-linecap="round" style="transform-origin:${P}px ${M}px;${u}"/><circle cx="${P}" cy="${M}" r="${c.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="0.4" stroke-opacity="0.12"/><circle cx="${P}" cy="${M}" r="${c.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="1.0" stroke-opacity="0.6" stroke-dasharray="${be(c,e.a3)}" stroke-linecap="round" style="transform-origin:${P}px ${M}px;${p}"/>`+S+"</svg>"}};ie.props=["preset","size","color","accent","sp1","sp2","sp3","a1","a2","a3","gap","dir2","dir3","pulse","dots","label"],ie.styles=[lo],ie.help=void 0;let Ee=ie;function be(o,e){const t=2*Math.PI*o,n=e/100*t,s=t-n;return`${n.toFixed(2)} ${s.toFixed(2)}`}function ot(o){return String(o).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}K("os-spinner",Ee);const ho=E` ${me} ${Ve}:host{--_field-size:var( --os-ui-field-font-size,13px );--_field-radius:var( --os-ui-field-radius,6px );display:flex;flex-direction:column;gap:4px;font-size:var( --_field-size );color:var( --os-ui-fg,#1d2327 );min-width:0}:host( [ hidden ] ){display:none}.os-textarea__label{font-size:12px;color:var( --os-ui-fg-muted,#646970 )}textarea{appearance:none;-webkit-appearance:none;display:block;width:100%;min-width:0;box-sizing:border-box;padding:8px 10px;background:var( --os-window-bg,#fff );border:1px solid var( --os-ui-border,#dcdcde );border-radius:var( --_field-radius );font:inherit;font-size:var( --_field-size );line-height:1.45;color:var( --os-ui-fg,#1d2327 );resize:vertical}textarea:disabled{opacity:0.55;cursor:not-allowed;background:var( --os-ui-hover,rgba( 0,0,0,0.03 ) )}textarea[ aria-invalid='true' ],textarea[ aria-invalid='true' ]:hover:not(:disabled ){border-color:var( --os-ui-danger,#d63638 )}textarea[ aria-invalid='true' ]:focus,textarea[ aria-invalid='true' ]:focus-visible{border-color:var( --os-ui-danger,#d63638 );box-shadow:0 0 0 1px var( --os-ui-danger,#d63638 ),0 0 0 4px rgba( 214,54,56,0.18 )}:host( [ auto-grow ] ) textarea{resize:none;overflow:hidden}`,ae=class ae extends q{constructor(){super(...arguments),this._textareaEl=null}connectedCallback(){super.connectedCallback(),Gt(this)}render(){const e=this._attr("label")||"",t=this._attr("value")??"",n=this._attr("placeholder")||"",s=this._boolAttr("disabled"),r=this._boolAttr("readonly"),i=this._attr("aria-label")||e,l=this._attr("name")||"",c=Number(this._attr("rows"))||3,a=this._attr("maxlength"),u=this._attr("minlength"),p=this._boolAttr("invalid"),x=`${this.id||"os-unnamed"}__field`;return y` | |
| 66 | + ${e?y`<label class="os-textarea__label" for=${x}>${e}</label>`:y``} | |
| 66 | 67 | <textarea |
| 67 | - id=${$} | |
| 68 | + id=${x} | |
| 68 | 69 | part="textarea" |
| 69 | 70 | .value=${t} |
| 70 | 71 | placeholder=${n} |
| 71 | 72 | ?disabled=${s} |
| 72 | - ?readonly=${i} | |
| 73 | - rows=${a} | |
| 74 | - maxlength=${d??""} | |
| 73 | + ?readonly=${r} | |
| 74 | + rows=${c} | |
| 75 | + maxlength=${a??""} | |
| 75 | 76 | minlength=${u??""} |
| 76 | 77 | name=${l} |
| 77 | 78 | aria-invalid=${p?"true":"false"} |
| 78 | - aria-label=${r||""} | |
| 79 | + aria-label=${i||""} | |
| 79 | 80 | @input=${b=>this._onInput(b)} |
| 80 | 81 | @change=${b=>this._onChange(b)} |
| 81 | 82 | @keydown=${b=>this._onKeyDown(b)} |
| 82 | 83 | ></textarea> |
| 83 | - `}_attr(e){return this.getAttribute(e)}_boolAttr(e){return this.getAttribute(e)!==null}_onInput(e){const t=e.target;this._textareaEl=t,this.setAttribute("value",t.value),this.emit("os-input-change",{value:t.value}),this._boolAttr("auto-grow")&&this._autosize(t)}_onChange(e){const t=e.target;this.emit("os-input-commit",{value:t.value})}_onKeyDown(e){if(this._boolAttr("submit-on-enter")&&e.key==="Enter"&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey){e.preventDefault();const t=e.target;this.emit("os-submit",{value:t.value})}}_autosize(e){const t=Number(this._attr("max-rows"))||8,n=window.getComputedStyle(e),s=parseFloat(n.fontSize)||13,i=n.lineHeight,r=i==="normal"?s*1.45:parseFloat(i)||s*1.45,l=parseFloat(n.paddingTop)||0,a=parseFloat(n.paddingBottom)||0,d=r*t+l+a;e.style.height="auto";const u=Math.min(e.scrollHeight,d);e.style.height=`${u}px`}refreshAutosize(){this._textareaEl&&this._boolAttr("auto-grow")&&this._autosize(this._textareaEl)}focusInput(){(this.shadowRoot??this).querySelector("textarea")?.focus()}clear(){this.setAttribute("value","");const t=(this.shadowRoot??this).querySelector("textarea");t&&(t.value="",this._boolAttr("auto-grow")&&this._autosize(t))}};te.props=["label","value","placeholder","disabled","readonly","ariaLabel","name","rows","maxlength","minlength","invalid","autoGrow","maxRows","submitOnEnter"],te.styles=[Wt],te.help=void 0;let ve=te;H("os-textarea",ve);const _e=new Map;async function qt(o){if(!o)return null;let e;try{e=new URL(o,window.location.href)}catch{return o}if(!/gravatar\.com$/i.test(e.hostname))return o;e.searchParams.delete("d"),e.searchParams.delete("s");const t=e.toString(),n=_e.get(t);if(n!==void 0)return n instanceof Promise,n;const s=new URL(o,window.location.href);s.searchParams.set("d","blank");const i=new Promise(r=>{const l=new Image;l.crossOrigin="anonymous",l.onload=()=>{try{const a=document.createElement("canvas");a.width=1,a.height=1;const d=a.getContext("2d",{willReadFrequently:!0});if(!d){r(o);return}d.drawImage(l,0,0,1,1);const u=d.getImageData(0,0,1,1).data;r(u[3]===0?null:o)}catch{r(o)}},l.onerror=()=>r(null),l.src=s.toString()}).then(r=>(_e.set(t,r),r));return _e.set(t,i),i}function jt(o,e){e&&qt(e).then(t=>{o.isConnected&&(t?o.setAttribute("src",t):o.removeAttribute("src"))})}const qe="__openStationSharedStores";function Xt(){const o=window;let e=o[qe];return e||(e=new Map,o[qe]=e),e}function je(o,e){const t=Xt();let n=t.get(o);n||(n={state:e(),listeners:new Set,rebuild:e},t.set(o,n));const s={get state(){return n.state},set state(i){n.state=i},getState(){return n.state},notify(){for(const i of Array.from(n.listeners))try{i(n.state)}catch(r){console.error(`[desktop-mode/shared-store:${o}] subscriber threw:`,r)}},subscribe(i){return n.listeners.add(i),()=>{n.listeners.delete(i)}},setState(i){const r=n.state;if(typeof r!="object"||r===null){console.warn(`[desktop-mode/shared-store:${o}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(r,i),s.notify()},reset(){const i=n.rebuild(),r=n.state;if(typeof r=="object"&&r!==null&&typeof i=="object"&&i!==null){const l=r;for(const a of Object.keys(l))delete l[a];Object.assign(l,i)}else n.state=i;n.listeners.clear()}};return s}const g=je("desktop-mode/agents-chat",()=>({activeAgent:null,transcripts:{},conversationIds:{},conversationsRev:0}));function Xe(o){g.state.activeAgent=o,g.state.transcripts[o.id]||(g.state.transcripts[o.id]=[]),g.state.conversationIds||(g.state.conversationIds={},g.state.conversationsRev=0),g.notify()}const Bt="my-wordpress",ye=je("desktop-mode/agents/editor-target",()=>({agentId:null,requestedAt:0}));function Kt(o){if(!Number.isFinite(o)||o<=0)return;ye.state.agentId=o,ye.state.requestedAt=Date.now(),ye.notify();const e=window.wp?.os?.openWindow;typeof e=="function"&&e(Bt,{source:"agents/editor"})}function Be(){return window.wp?.os}function le(){const o=Be()?.config?.adminUrl??"/wp-admin/";return o.endsWith("/")?o:`${o}/`}function Ke(o){switch(o){case"page":return"dashicons-admin-page";case"media":return"dashicons-admin-media";case"user":return"dashicons-admin-users";case"comment":return"dashicons-admin-comments";default:return"dashicons-admin-post"}}function Oe(o){switch(o){case"page":return y("Page","desktop-mode");case"media":return y("Media","desktop-mode");case"user":return y("User","desktop-mode");case"comment":return y("Comment","desktop-mode");default:return y("Post","desktop-mode")}}function Ot(o){const e=encodeURIComponent(String(o.id));switch(o.kind){case"user":return`${le()}user-edit.php?user_id=${e}`;case"comment":return`${le()}comment.php?action=editcomment&c=${e}`;default:return`${le()}post.php?post=${e}&action=edit`}}function Yt(o){const e=Be();if(!e?.windowManager?.open||!e.deriveWindowId)return!1;const t=Ot(o),n=e.deriveWindowId(t,le());return e.windowManager.open({id:n,baseId:n,url:t,title:o.title,icon:Ke(o.kind)}),!0}const Ye="X-WP-Nonce";function Gt(o,e){const t=Vt();if(!t)return e;const n=Zt(o);if(!n||!Jt(n))return e;const s=e?.headers??(typeof Request<"u"&&o instanceof Request?o.headers:void 0),i=new Headers(s??{});return i.has(Ye)?e:(i.set(Ye,t),{...e??{},headers:i})}function Vt(){if(typeof window>"u")return;const e=window.openStationConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function Zt(o){try{const e=typeof window<"u"&&window.location?window.location.href:void 0;return typeof o=="string"?new URL(o,e):o instanceof URL?o:typeof Request<"u"&&o instanceof Request?new URL(o.url,e):null}catch{return null}}function Jt(o){return typeof window>"u"||!window.location||o.origin!==window.location.origin?!1:!!(o.pathname.includes("/wp-json/")||o.searchParams.has("rest_route"))}function Ge(o,e,t={}){const n=window.wp?.os?.fetch;if(typeof n=="function")return n(o,e,t);const s=Gt(o,e);return fetch(o,s)}const Qt="http://localhost/";function Ve(o,e){const t=typeof window<"u"&&window.location?window.location.href:Qt,n=new URL(o,t),s=e.replace(/^\/+/,""),i=s.indexOf("?"),r=i===-1?s:s.slice(0,i),l=i===-1?"":s.slice(i+1);if(n.searchParams.has("rest_route")){const a=n.searchParams.get("rest_route")??"/",d=a.endsWith("/")?a:a+"/";n.searchParams.set("rest_route",d+r)}else{const a=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";n.pathname=a+r}return l&&new URLSearchParams(l).forEach((d,u)=>{n.searchParams.append(u,d)}),n.toString()}const O="desktop-mode/v1/agents/conversations";async function Y(o,e,t={}){const n=await Ge(Ve(o.restRoot,e),{...t,headers:{"Content-Type":"application/json","X-WP-Nonce":o.restNonce,...t.headers??{}}},{source:"desktop-mode/agents",silent:!0}),s=await n.json().catch(()=>null);if(!n.ok){const i=s&&typeof s=="object"&&typeof s.message=="string"?s.message:`HTTP ${n.status}`;throw new Error(i)}return s}async function eo(o){const e=await Y(o,O);return Array.isArray(e)?e:[]}function to(o,e){return Y(o,`${O}/${e}`)}function oo(o,e){return Y(o,`${O}/${e}`,{method:"DELETE"})}function no(o){return o.filter(e=>!e.pending)}async function so(o,e){const t=g.state,n=no(t.transcripts[o.id]??[]);if(n.length!==0){t.conversationIds||(t.conversationIds={});try{const s=t.conversationIds[o.id];if(s)await Y(e,`${O}/${s}`,{method:"PUT",body:JSON.stringify({messages:n})});else{const i=await Y(e,O,{method:"POST",body:JSON.stringify({agentId:o.id,messages:n})});t.conversationIds[o.id]=i.id}t.conversationsRev=(t.conversationsRev??0)+1,g.notify()}catch(s){console.warn("[desktop-mode/agents] conversation save failed:",s)}}}async function io(o,e){const t=await to(o,e),n=g.state;n.activeAgent={id:t.agentId,name:t.agentName,description:t.agentDescription,avatarUrl:t.agentAvatarUrl},n.transcripts[t.agentId]=Array.isArray(t.messages)?t.messages:[],n.conversationIds||(n.conversationIds={}),n.conversationIds[t.agentId]=t.id,g.notify()}const Ze={post:"post",page:"page",attachment:"media",media:"media",user:"user",comment:"comment"};function Je(o){const e=Number.parseInt(String(o??""),10);return Number.isFinite(e)&&e>0?e:0}function Qe(o){if(o.type==="shortcut"){const e=o.data;let t=Ze[String(e.kind??"")];t==="post"&&e.bridgePayload?.postType==="page"&&(t="page");const n=Je(e.ref);return!t||!n?null:{kind:t,id:n,title:String(e.title??"")||`#${n}`}}if(o.type==="desktop-file"){const t=o.data.placement?.file;if(!t)return null;const n=Ze[String(t.type??"")],s=Je(t.ref);return!n||!s?null:{kind:n,id:s,title:String(t.title??"")||`#${s}`}}return null}function ro(o){return we(y('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"),o.kind,o.title,String(o.id))}function ao(o){return{kind:o.kind,id:o.id,title:o.title}}function co(o,e="agents"){Xe(o);const t=window.wp?.os?.openWindow;typeof t=="function"&&t("desktop-mode-agent-run",{source:e})}async function et(o,e,t,n,s){Xe(o);const i=g.state.transcripts[o.id],r=i.filter(a=>!a.pending&&a.role!=="error").map(a=>({role:a.role,text:a.text}));i.push({role:"user",text:e,at:Date.now(),attachment:s});const l={role:"agent",text:y("Working…","desktop-mode"),at:Date.now(),pending:!0};i.push(l),g.notify();try{const a=await Ge(Ve(t.restRoot,`desktop-mode/v1/agents/${o.id}/invoke`),{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":t.restNonce},body:JSON.stringify({message:e,source:n,history:r})},{source:"desktop-mode/agents"}),d=await a.json().catch(()=>null);if(!a.ok){if(a.status===504)throw new Error(y("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 p=d&&typeof d=="object"&&typeof d.message=="string"?d.message:`HTTP ${a.status}`;throw new Error(p)}const u=d;l.text=u.text||y("The agent finished without a text answer.","desktop-mode"),l.toolCalls=u.toolCalls,Array.isArray(u.callToActions)&&u.callToActions.length>0&&(l.callToActions=u.callToActions)}catch(a){l.role="error",l.text=a instanceof Error?a.message:String(a)}l.pending=!1,g.notify(),so(o,t)}function lo(o,e,t){return co(o,"agents-drop"),et(o,ro(e),t,"drag",ao(e))}const uo=A` ${re}:host{display:none;position:fixed;inset:0;align-items:center;justify-content:center;background:var( --os-ui-scrim,rgba( 0,0,0,0.45 ) );background-image:var( --os-ui-scrim-image,none );background-repeat:var( --os-ui-scrim-image-repeat,repeat );background-size:var( --os-ui-scrim-image-size,auto );background-position:var( --os-ui-scrim-image-position,center );backdrop-filter:blur( 2px );z-index:10000}:host( [ open ] ){display:flex;animation:os-confirm-scrim var( --_holo-t ) var( --_holo-ease )}:host( [ open ] ) .dialog{animation:os-confirm-dialog var( --_holo-t ) var( --_holo-spring )}@keyframes os-confirm-scrim{from{opacity:0}}@keyframes os-confirm-dialog{from{opacity:0;transform:scale( 0.96 ) translateY( 8px )}}@media ( prefers-reduced-motion:reduce ){:host( [ open ] ),:host( [ open ] ) .dialog{animation:none}}.dialog{width:min( 420px,92vw );background-color:var( --os-ui-confirm-dialog-bg,#1d2327 );background-image:var( --os-ui-dialog-bg-image,none );background-repeat:var( --os-ui-dialog-bg-image-repeat,repeat );background-size:var( --os-ui-dialog-bg-image-size,auto );background-position:var( --os-ui-dialog-bg-image-position,center );color:var( --os-ui-confirm-dialog-fg,var( --os-fg,#fff ) );border:1px solid var( --os-ui-border,rgba( 255,255,255,0.08 ) );border-radius:10px;box-shadow:0 20px 50px rgba( 0,0,0,0.6 );padding:20px 22px 18px;display:flex;flex-direction:column;gap:10px;position:relative}.close{position:absolute;top:8px;right:10px;width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;background:transparent;border:0;border-radius:6px;color:var( --os-ui-confirm-dialog-fg-muted,var( --os-ui-fg-muted,rgba( 255,255,255,0.7 ) ) );cursor:pointer;font-size:22px;line-height:1;padding:0}.close:hover{background:var( --os-ui-hover,rgba( 255,255,255,0.08 ) );color:inherit}.btn:focus,.close:focus{outline:none;box-shadow:var( --_holo-focus )}.dialog:focus,.dialog:focus-visible{outline:none}.title{margin:0 0 4px;font-size:16px;font-weight:600}.message{margin:0;color:var( --os-ui-confirm-dialog-fg-muted,var( --os-ui-fg-muted,rgba( 255,255,255,0.7 ) ) );line-height:1.45;white-space:pre-line}.remember{display:flex;align-items:center;gap:8px;margin-top:4px;font-size:12px;color:var( --os-ui-confirm-dialog-fg-muted,var( --os-ui-fg-muted,rgba( 255,255,255,0.7 ) ) );cursor:pointer;user-select:none}.remember__box{margin:0;accent-color:var( --os-ui-accent,#2271b1 );cursor:pointer}.remember__box:focus,.remember__box:focus-visible{outline:none;box-shadow:var( --_holo-focus )}.actions{display:flex;justify-content:flex-end;gap:8px;margin-top:6px}.btn{border:0;border-radius:6px;padding:8px 14px;font-size:13px;cursor:pointer;font-weight:500}.btn--secondary{background:var( --os-ui-hover,rgba( 255,255,255,0.08 ) );color:inherit}.btn--secondary:hover{background:var( --os-ui-hover,rgba( 255,255,255,0.14 ) )}.btn--primary{background:var( --wp-admin-theme-color,#2271b1 );color:var( --os-ui-fg-on-accent,#fff )}.btn--primary:hover{filter:brightness( 1.08 )}.btn--danger{background:var( --os-ui-danger,#d63638 );color:var( --os-ui-fg-on-accent,#fff )}.btn--danger:hover{filter:brightness( 1.08 )}`,tt='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function ho(o){let e=o?.activeElement??null;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e&&e!==o?.body?e:null}function ot(o){const e=o.composedPath(),t=e.length>0?e[0]:o.target;return t instanceof HTMLElement?t:null}function nt(o){return o!==null&&o.matches(tt)}const oe=class oe extends M{constructor(){super(...arguments),this._prevFocus=null,this._focusTries=0,this._onKey=e=>{if(e.key==="Escape"){e.preventDefault(),this._cancel();return}if(e.key==="Tab"){this._trapTab(e);return}if(e.key==="Enter"&&!e.isComposing){if(nt(ot(e))||this.hasAttribute("danger"))return;e.preventDefault(),this._confirm()}},this._focusInitial=()=>{if(!this.hasAttribute("open"))return;const e=this.isConnected?this._initialFocusTarget():null;if(e){e.focus();return}if(this._focusTries++<5){queueMicrotask(this._focusInitial);return}this.isConnected&&this.focus()},this._onBackdrop=e=>{const t=e.composedPath();(t.length>0?t[0]:e.target)===this&&this._cancel()},this._confirm=()=>{this.emit("os-confirm",{confirmed:!0,remember:this._remembered()}),this.removeAttribute("open")},this._cancel=()=>{this.emit("os-cancel",{confirmed:!1}),this.removeAttribute("open")}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),this.addEventListener("keydown",this._onKey),this.addEventListener("click",this._onBackdrop)}disconnectedCallback(){this.removeEventListener("keydown",this._onKey),this.removeEventListener("click",this._onBackdrop),this._restoreFocus()}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),e==="open"&&(n!==null?(this._prevFocus=ho(this.ownerDocument),this._focusTries=0,queueMicrotask(this._focusInitial)):this._restoreFocus())}_focusables(){const e=this.shadowRoot;return e?Array.from(e.querySelectorAll(tt)):[]}_trapTab(e){const t=this._focusables();if(t.length===0)return;const n=t[0],s=t[t.length-1],i=ot(e),r=!nt(i);e.shiftKey&&(r||i===n)?(e.preventDefault(),s.focus()):!e.shiftKey&&(r||i===s)&&(e.preventDefault(),n.focus())}_initialFocusTarget(){const e=this.shadowRoot;if(!e)return null;const t=e.querySelector(".btn--secondary"),n=e.querySelector(".dialog");return this.hasAttribute("danger")?t??e.querySelector(".close")??n:e.querySelector(".btn--primary, .btn--danger")??t??n}_restoreFocus(){const e=this._prevFocus;this._prevFocus=null,!(!e||!e.isConnected)&&e.focus()}_remembered(){return this.shadowRoot?.querySelector(".remember__box")?.checked===!0}render(){const e=this.title??"",t=this.message??"",n=this["confirm-label"]||"Confirm",s=this["cancel-label"]||"Cancel",i=this.hasAttribute("danger"),r=this.hasAttribute("hide-cancel"),l=this.hasAttribute("dismissable"),a=this["remember-label"]??"";return k` | |
| 84 | + `}_attr(e){return this.getAttribute(e)}_boolAttr(e){return this.getAttribute(e)!==null}_onInput(e){const t=e.target;this._textareaEl=t,this.setAttribute("value",t.value),this.emit("os-input-change",{value:t.value}),this._boolAttr("auto-grow")&&this._autosize(t)}_onChange(e){const t=e.target;this.emit("os-input-commit",{value:t.value})}_onKeyDown(e){if(!(!this._boolAttr("submit-on-enter")||e.isComposing||e.keyCode===229)&&e.key==="Enter"&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey){e.preventDefault();const t=e.target;this.emit("os-submit",{value:t.value})}}_autosize(e){const t=Number(this._attr("max-rows"))||8,n=window.getComputedStyle(e),s=parseFloat(n.fontSize)||13,r=n.lineHeight,i=r==="normal"?s*1.45:parseFloat(r)||s*1.45,l=parseFloat(n.paddingTop)||0,c=parseFloat(n.paddingBottom)||0,a=(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0),u=i*t+l+c+a;e.style.height="auto",e.style.overflowY="hidden";const p=e.value?e.scrollHeight+a:i*(Number(this._attr("rows"))||3)+l+c+a,f=Math.min(p,u);e.style.height=`${Math.ceil(f)}px`,e.style.overflowY=p>Math.ceil(u)?"auto":"hidden"}refreshAutosize(){this._textareaEl&&this._boolAttr("auto-grow")&&this._autosize(this._textareaEl)}focusInput(){(this.shadowRoot??this).querySelector("textarea")?.focus()}clear(){this.setAttribute("value","");const t=(this.shadowRoot??this).querySelector("textarea");t&&(t.value="",this._boolAttr("auto-grow")&&this._autosize(t))}};ae.props=["label","value","placeholder","disabled","readonly","ariaLabel","name","rows","maxlength","minlength","invalid","autoGrow","maxRows","submitOnEnter"],ae.styles=[ho],ae.help=void 0;let Se=ae;K("os-textarea",Se);const Ne=new Map;async function po(o){if(!o)return null;let e;try{e=new URL(o,window.location.href)}catch{return o}if(!/gravatar\.com$/i.test(e.hostname))return o;e.searchParams.delete("d"),e.searchParams.delete("s");const t=e.toString(),n=Ne.get(t);if(n!==void 0)return n instanceof Promise,n;const s=new URL(o,window.location.href);s.searchParams.set("d","blank");const r=new Promise(i=>{const l=new Image;l.crossOrigin="anonymous",l.onload=()=>{try{const c=document.createElement("canvas");c.width=1,c.height=1;const a=c.getContext("2d",{willReadFrequently:!0});if(!a){i(o);return}a.drawImage(l,0,0,1,1);const u=a.getImageData(0,0,1,1).data;i(u[3]===0?null:o)}catch{i(o)}},l.onerror=()=>i(null),l.src=s.toString()}).then(i=>(Ne.set(t,i),i));return Ne.set(t,r),r}function fo(o,e){e&&po(e).then(t=>{o.isConnected&&(t?o.setAttribute("src",t):o.removeAttribute("src"))})}const nt="__openStationSharedStores";function mo(){const o=window;let e=o[nt];return e||(e=new Map,o[nt]=e),e}function st(o,e){const t=mo();let n=t.get(o);n||(n={state:e(),listeners:new Set,rebuild:e},t.set(o,n));const s={get state(){return n.state},set state(r){n.state=r},getState(){return n.state},notify(){for(const r of Array.from(n.listeners))try{r(n.state)}catch(i){console.error(`[desktop-mode/shared-store:${o}] subscriber threw:`,i)}},subscribe(r){return n.listeners.add(r),()=>{n.listeners.delete(r)}},setState(r){const i=n.state;if(typeof i!="object"||i===null){console.warn(`[desktop-mode/shared-store:${o}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(i,r),s.notify()},reset(){const r=n.rebuild(),i=n.state;if(typeof i=="object"&&i!==null&&typeof r=="object"&&r!==null){const l=i;for(const c of Object.keys(l))delete l[c];Object.assign(l,r)}else n.state=r;n.listeners.clear()}};return s}const g=st("desktop-mode/agents-chat",()=>({activeAgent:null,transcripts:{},conversationIds:{},conversationsRev:0}));function rt(o){g.state.activeAgent=o,g.state.transcripts[o.id]||(g.state.transcripts[o.id]=[]),g.state.conversationIds||(g.state.conversationIds={},g.state.conversationsRev=0),g.notify()}const go="my-wordpress",Te=st("desktop-mode/agents/editor-target",()=>({agentId:null,requestedAt:0}));function bo(o){if(!Number.isFinite(o)||o<=0)return;Te.state.agentId=o,Te.state.requestedAt=Date.now(),Te.notify();const e=window.wp?.os?.openWindow;typeof e=="function"&&e(go,{source:"agents/editor"})}function it(){return window.wp?.os}function ve(){const o=it()?.config?.adminUrl??"/wp-admin/";return o.endsWith("/")?o:`${o}/`}function at(o){switch(o){case"page":return"dashicons-admin-page";case"media":return"dashicons-admin-media";case"user":return"dashicons-admin-users";case"comment":return"dashicons-admin-comments";default:return"dashicons-admin-post"}}function ct(o){switch(o){case"page":return h("Page","desktop-mode");case"media":return h("Media","desktop-mode");case"user":return h("User","desktop-mode");case"comment":return h("Comment","desktop-mode");default:return h("Post","desktop-mode")}}function vo(o){const e=encodeURIComponent(String(o.id));switch(o.kind){case"user":return`${ve()}user-edit.php?user_id=${e}`;case"comment":return`${ve()}comment.php?action=editcomment&c=${e}`;default:return`${ve()}post.php?post=${e}&action=edit`}}function _o(o){const e=it();if(!e?.windowManager?.open||!e.deriveWindowId)return!1;const t=vo(o),n=e.deriveWindowId(t,ve());return e.windowManager.open({id:n,baseId:n,url:t,title:o.title,icon:at(o.kind)}),!0}const yo="http://localhost/";function lt(o,e){const t=typeof window<"u"&&window.location?window.location.href:yo,n=new URL(o,t),s=e.replace(/^\/+/,""),r=s.indexOf("?"),i=r===-1?s:s.slice(0,r),l=r===-1?"":s.slice(r+1);if(n.searchParams.has("rest_route")){const c=n.searchParams.get("rest_route")??"/",a=c.endsWith("/")?c:c+"/";n.searchParams.set("rest_route",a+i)}else{const c=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";n.pathname=c+i}return l&&new URLSearchParams(l).forEach((a,u)=>{n.searchParams.append(u,a)}),n.toString()}function xo(){const o=crypto.getRandomValues(new Uint8Array(16));o[6]=o[6]%16+64,o[8]=o[8]%64+128;const e=Array.from(o,t=>t.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}class Y extends he{constructor(e,t,n=new he("",{status:0})){super(e,{status:n.status,code:n.code,data:n.data,serverMessage:n.serverMessage}),this.name="JobRequestError",this.retryable=t}}async function ko(o,e,t){const n=new AbortController,s=window.setTimeout(()=>n.abort(),15e3);try{const r=await Pe(lt(o.restRoot,e),{method:t?"POST":"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":o.restNonce},body:t?JSON.stringify(t):void 0,signal:n.signal,cache:"no-store"},{source:"desktop-mode/agents",silent:!t}),i=await r.json().catch(()=>null);if(!r.ok)throw new Y(i?.message||`HTTP ${r.status}`,r.status>=500&&!i?.code||r.status===408,ye(r.status,i));if(!i||!i.jobId&&typeof i.text!="string")throw new Y(h("The job status could not be read.","desktop-mode"),!0,ye(r.status,null));return i}finally{window.clearTimeout(s)}}function wo(o){return new Promise(e=>window.setTimeout(e,o))}async function $o(o,e,t,n,s=()=>{}){const r=`desktop-mode/v1/agents/${o}`,i=Date.now()+2*60*60*1e3;let l=!1,c=2e3;for(;Date.now()<i;){try{const a=await ko(t,l?`${r}/jobs/${n}`:`${r}/invoke`,l?void 0:{...e,async:!0,requestId:n});if(!("jobId"in a))return a;if(a.jobId!==n)throw new Y(h("The server returned a different job.","desktop-mode"),!1);if(l=!0,a.status==="completed"&&a.result)return a.result;if(a.status==="failed")throw new Y(a.error?.message||h("The agent job failed.","desktop-mode"),!1);if(a.status!=="queued"&&a.status!=="running")throw new Y(h("The server returned an invalid job state.","desktop-mode"),!1);s(a.status),c=Math.min(1e4,Math.max(c*1.25,(a.pollAfter||3)*1e3))}catch(a){if(a instanceof Y&&!a.retryable)throw a;s("reconnecting"),c=Math.min(c*2,3e4)}await wo(document.hidden?Math.max(c,15e3):c)}throw new Error(h("The background job has not returned a result. Some work may already have been applied. Check the site before submitting again.","desktop-mode"))}const Q="desktop-mode/v1/agents/conversations";async function ee(o,e,t={}){const n=await Pe(lt(o.restRoot,e),{...t,headers:{"Content-Type":"application/json","X-WP-Nonce":o.restNonce,...t.headers??{}}},{source:"desktop-mode/agents",silent:!0}),s=await n.json().catch(()=>null);if(!n.ok)throw ye(n.status,s);return s}async function Ao(o){const e=await ee(o,Q);return Array.isArray(e)?e:[]}function Co(o,e){return ee(o,`${Q}/${e}`)}function Eo(o,e){return ee(o,`${Q}/${e}`,{method:"DELETE"})}function So(o){return o.filter(e=>!e.pending)}async function No(o,e){const t=g.state,n=So(t.transcripts[o.id]??[]);if(n.length!==0){t.conversationIds||(t.conversationIds={});try{const s=t.conversationIds[o.id];if(s)await ee(e,`${Q}/${s}`,{method:"PUT",body:JSON.stringify({messages:n})});else{const r=await ee(e,Q,{method:"POST",body:JSON.stringify({agentId:o.id,messages:n})});t.conversationIds[o.id]=r.id}t.conversationsRev=(t.conversationsRev??0)+1,g.notify()}catch(s){console.warn("[desktop-mode/agents] conversation save failed:",s)}}}async function To(o,e){const t=await Co(o,e),n=g.state;n.activeAgent={id:t.agentId,name:t.agentName,description:t.agentDescription,avatarUrl:t.agentAvatarUrl},n.transcripts[t.agentId]=Array.isArray(t.messages)?t.messages:[],n.conversationIds||(n.conversationIds={}),n.conversationIds[t.agentId]=t.id,g.notify()}const dt={post:"post",page:"page",attachment:"media",media:"media",user:"user",comment:"comment"};function ut(o){const e=Number.parseInt(String(o??""),10);return Number.isFinite(e)&&e>0?e:0}function ht(o){if(o.type==="shortcut"){const e=o.data;let t=dt[String(e.kind??"")];t==="post"&&e.bridgePayload?.postType==="page"&&(t="page");const n=ut(e.ref);return!t||!n?null:{kind:t,id:n,title:String(e.title??"")||`#${n}`}}if(o.type==="desktop-file"){const t=o.data.placement?.file;if(!t)return null;const n=dt[String(t.type??"")],s=ut(t.ref);return!n||!s?null:{kind:n,id:s,title:String(t.title??"")||`#${s}`}}return null}function Ro(o){return ue(h('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"),o.kind,o.title,String(o.id))}function Lo(o){return{kind:o.kind,id:o.id,title:o.title}}function Io(o,e="agents"){rt(o);const t=window.wp?.os?.openWindow;typeof t=="function"&&t("desktop-mode-agent-run",{source:e})}async function pt(o,e,t,n,s){rt(o);const r=g.state.transcripts[o.id],i=h("The agent finished without a text answer.","desktop-mode"),l=r.filter(a=>!a.pending&&a.role!=="error"&&!(a.role==="agent"&&a.text===i)).map(a=>({role:a.role,text:a.text}));r.push({role:"user",text:e,at:Date.now(),attachment:s});const c={role:"agent",text:h("Working…","desktop-mode"),at:Date.now(),pending:!0};r.push(c),g.notify();try{const a=await $o(o.id,{message:e,source:n,history:l},t,xo(),u=>{const p={queued:h("Queued — waiting for a WordPress worker…","desktop-mode"),reconnecting:h("Reconnecting to the background job…","desktop-mode"),running:h("Working in the background…","desktop-mode")};c.text=p[u],g.notify()});a.text?.trim()?c.text=a.text:(c.role="error",c.text=i),c.toolCalls=a.toolCalls,Array.isArray(a.callToActions)&&a.callToActions.length>0&&(c.callToActions=a.callToActions)}catch(a){c.role="error",c.text=a instanceof Error?a.message:String(a)}c.pending=!1,g.notify(),No(o,t)}function zo(o,e,t){return Io(o,"agents-drop"),pt(o,Ro(e),t,"drag",Lo(e))}const Po=E` ${me}:host{display:none;position:fixed;inset:0;align-items:center;justify-content:center;background:var( --os-ui-scrim,rgba( 0,0,0,0.45 ) );background-image:var( --os-ui-scrim-image,none );background-repeat:var( --os-ui-scrim-image-repeat,repeat );background-size:var( --os-ui-scrim-image-size,auto );background-position:var( --os-ui-scrim-image-position,center );backdrop-filter:blur( 2px );z-index:10000}:host( [ open ] ){display:flex;animation:os-confirm-scrim var( --_holo-t ) var( --_holo-ease )}:host( [ open ] ) .dialog{animation:os-confirm-dialog var( --_holo-t ) var( --_holo-spring )}@keyframes os-confirm-scrim{from{opacity:0}}@keyframes os-confirm-dialog{from{opacity:0;transform:scale( 0.96 ) translateY( 8px )}}@media ( prefers-reduced-motion:reduce ){:host( [ open ] ),:host( [ open ] ) .dialog{animation:none}}.dialog{width:min( 420px,92vw );background-color:var( --os-ui-confirm-dialog-bg,#1d2327 );background-image:var( --os-ui-dialog-bg-image,none );background-repeat:var( --os-ui-dialog-bg-image-repeat,repeat );background-size:var( --os-ui-dialog-bg-image-size,auto );background-position:var( --os-ui-dialog-bg-image-position,center );color:var( --os-ui-confirm-dialog-fg,var( --os-fg,#fff ) );border:1px solid var( --os-ui-border,rgba( 255,255,255,0.08 ) );border-radius:10px;box-shadow:0 20px 50px rgba( 0,0,0,0.6 );padding:20px 22px 18px;display:flex;flex-direction:column;gap:10px;position:relative}.close{position:absolute;top:8px;right:10px;width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;background:transparent;border:0;border-radius:6px;color:var( --os-ui-confirm-dialog-fg-muted,var( --os-ui-fg-muted,rgba( 255,255,255,0.7 ) ) );cursor:pointer;font-size:22px;line-height:1;padding:0}.close:hover{background:var( --os-ui-hover,rgba( 255,255,255,0.08 ) );color:inherit}.btn:focus,.close:focus{outline:none;box-shadow:var( --_holo-focus )}.dialog:focus,.dialog:focus-visible{outline:none}.title{margin:0 0 4px;font-size:16px;font-weight:600}.message{margin:0;color:var( --os-ui-confirm-dialog-fg-muted,var( --os-ui-fg-muted,rgba( 255,255,255,0.7 ) ) );line-height:1.45;white-space:pre-line}.remember{display:flex;align-items:center;gap:8px;margin-top:4px;font-size:12px;color:var( --os-ui-confirm-dialog-fg-muted,var( --os-ui-fg-muted,rgba( 255,255,255,0.7 ) ) );cursor:pointer;user-select:none}.remember__box{margin:0;accent-color:var( --os-ui-accent,#2271b1 );cursor:pointer}.remember__box:focus,.remember__box:focus-visible{outline:none;box-shadow:var( --_holo-focus )}.actions{display:flex;justify-content:flex-end;gap:8px;margin-top:6px}.btn{border:0;border-radius:6px;padding:8px 14px;font-size:13px;cursor:pointer;font-weight:500}.btn--secondary{background:var( --os-ui-hover,rgba( 255,255,255,0.08 ) );color:inherit}.btn--secondary:hover{background:var( --os-ui-hover,rgba( 255,255,255,0.14 ) )}.btn--primary{background:var( --wp-admin-theme-color,#2271b1 );color:var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) )}.btn--primary:hover{filter:brightness( 1.08 )}.btn--danger{background:var( --os-ui-danger,#d63638 );color:var( --os-ui-fg-on-accent,#fff )}.btn--danger:hover{filter:brightness( 1.08 )}`,ft='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Mo(o){let e=o?.activeElement??null;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e&&e!==o?.body?e:null}function mt(o){const e=o.composedPath(),t=e.length>0?e[0]:o.target;return t instanceof HTMLElement?t:null}function gt(o){return o!==null&&o.matches(ft)}const ce=class ce extends q{constructor(){super(...arguments),this._prevFocus=null,this._focusTries=0,this._onKey=e=>{if(e.key==="Escape"){e.preventDefault(),this._cancel();return}if(e.key==="Tab"){this._trapTab(e);return}if(e.key==="Enter"&&!e.isComposing){if(gt(mt(e))||this.hasAttribute("danger"))return;e.preventDefault(),this._confirm()}},this._focusInitial=()=>{if(!this.hasAttribute("open"))return;const e=this.isConnected?this._initialFocusTarget():null;if(e){e.focus();return}if(this._focusTries++<5){queueMicrotask(this._focusInitial);return}this.isConnected&&this.focus()},this._onBackdrop=e=>{const t=e.composedPath();(t.length>0?t[0]:e.target)===this&&this._cancel()},this._confirm=()=>{this.emit("os-confirm",{confirmed:!0,remember:this._remembered()}),this.removeAttribute("open")},this._cancel=()=>{this.emit("os-cancel",{confirmed:!1}),this.removeAttribute("open")}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),this.addEventListener("keydown",this._onKey),this.addEventListener("click",this._onBackdrop)}disconnectedCallback(){this.removeEventListener("keydown",this._onKey),this.removeEventListener("click",this._onBackdrop),this._restoreFocus()}attributeChangedCallback(e,t,n){super.attributeChangedCallback(e,t,n),e==="open"&&(n!==null?(this._prevFocus=Mo(this.ownerDocument),this._focusTries=0,queueMicrotask(this._focusInitial)):this._restoreFocus())}_focusables(){const e=this.shadowRoot;return e?Array.from(e.querySelectorAll(ft)):[]}_trapTab(e){const t=this._focusables();if(t.length===0)return;const n=t[0],s=t[t.length-1],r=mt(e),i=!gt(r);e.shiftKey&&(i||r===n)?(e.preventDefault(),s.focus()):!e.shiftKey&&(i||r===s)&&(e.preventDefault(),n.focus())}_initialFocusTarget(){const e=this.shadowRoot;if(!e)return null;const t=e.querySelector(".btn--secondary"),n=e.querySelector(".dialog");return this.hasAttribute("danger")?t??e.querySelector(".close")??n:e.querySelector(".btn--primary, .btn--danger")??t??n}_restoreFocus(){const e=this._prevFocus;this._prevFocus=null,!(!e||!e.isConnected)&&e.focus()}_remembered(){return this.shadowRoot?.querySelector(".remember__box")?.checked===!0}render(){const e=this.title??"",t=this.message??"",n=this["confirm-label"]||"Confirm",s=this["cancel-label"]||"Cancel",r=this.hasAttribute("danger"),i=this.hasAttribute("hide-cancel"),l=this.hasAttribute("dismissable"),c=this["remember-label"]??"";return y` | |
| 84 | 85 | <div class="dialog" tabindex="-1"> |
| 85 | - ${l?k`<button | |
| 86 | + ${l?y`<button | |
| 86 | 87 | type="button" |
| 87 | 88 | class="close" |
| 88 | 89 | aria-label="Close" |
| 89 | 90 | @click=${()=>this._cancel()} |
| 90 | - >×</button>`:k``} | |
| 91 | - ${e?k`<h2 class="title">${e}</h2>`:k``} | |
| 92 | - ${t?k`<p class="message">${t}</p>`:k``} | |
| 93 | - ${a?k`<label class="remember"> | |
| 91 | + >×</button>`:y``} | |
| 92 | + ${e?y`<h2 class="title">${e}</h2>`:y``} | |
| 93 | + ${t?y`<p class="message">${t}</p>`:y``} | |
| 94 | + ${c?y`<label class="remember"> | |
| 94 | 95 | <input type="checkbox" class="remember__box" /> |
| 95 | - <span class="remember__label">${a}</span> | |
| 96 | - </label>`:k``} | |
| 96 | + <span class="remember__label">${c}</span> | |
| 97 | + </label>`:y``} | |
| 97 | 98 | <div class="actions"> |
| 98 | - ${r?k``:k`<button | |
| 99 | + ${i?y``:y`<button | |
| 99 | 100 | type="button" |
| 100 | 101 | class="btn btn--secondary" |
| 101 | 102 | @click=${()=>this._cancel()} |
| 102 | 103 | > |
| @@ -103,9 +104,9 @@ | ||
| 103 | 104 | ${s} |
| 104 | 105 | </button>`} |
| 105 | 106 | <button |
| 106 | 107 | type="button" |
| 107 | - class="btn ${i?"btn--danger":"btn--primary"}" | |
| 108 | + class="btn ${r?"btn--danger":"btn--primary"}" | |
| 108 | 109 | @click=${()=>this._confirm()} |
| 109 | 110 | > |
| 110 | 111 | ${n} |
| 111 | 112 | </button> |
| @@ -110,5 +111,5 @@ | ||
| 110 | 111 | ${n} |
| 111 | 112 | </button> |
| 112 | 113 | </div> |
| 113 | 114 | </div> |
| 114 | - `}};oe.props=["open","title","message","confirm-label","cancel-label","danger","hide-cancel","dismissable","remember-label"],oe.styles=[uo],oe.help=void 0;let xe=oe;H("os-confirm-dialog",xe);function po(o){return new Promise(e=>{const t=document.createElement("os-confirm-dialog");t.setAttribute("open",""),o.title&&t.setAttribute("title",o.title),t.setAttribute("message",o.message),o.confirmLabel&&t.setAttribute("confirm-label",o.confirmLabel),o.cancelLabel&&t.setAttribute("cancel-label",o.cancelLabel),o.danger&&t.setAttribute("danger",""),o.hideCancel&&t.setAttribute("hide-cancel",""),o.dismissable&&t.setAttribute("dismissable",""),o.rememberLabel&&t.setAttribute("remember-label",o.rememberLabel);const n=s=>{t.remove(),e(s)};t.addEventListener("os-confirm",s=>{o.onRemember?.(s.detail?.remember===!0),n(!0)}),t.addEventListener("os-cancel",()=>n(!1)),document.body.appendChild(t)})}const st="desktop-mode-agent-run",G=window;let fo=0;function X(){const o=G.openStationWindowConfig?.[st];return o&&typeof o.restRoot=="string"?o:null}function mo(o){const e=new Date(o);if(Number.isNaN(e.getTime()))return"";const t=new Date,n=i=>new Date(i.getFullYear(),i.getMonth(),i.getDate()).getTime(),s=Math.round((n(t)-n(e))/864e5);return s<=0?e.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}):s===1?y("Yesterday","desktop-mode"):s<7?e.toLocaleDateString(void 0,{weekday:"short"}):e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}const go='<svg class="dm-agent-chat__send-icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d="M8 13.5V2.5M8 2.5 3.5 7M8 2.5 12.5 7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>';function de(o,e,t,n){const s=document.createElement("os-avatar");return s.className=o,s.setAttribute("size",String(e)),s.setAttribute("name",n),s.setAttribute("alt",n),t&&jt(s,t),s}function it(o,e){o.setAttribute("clickable",""),o.setAttribute("title",y("Open the agent in WP Explorer","desktop-mode")),o.addEventListener("click",t=>{t.stopPropagation(),Kt(e)}),o.addEventListener("keydown",t=>{(t.key==="Enter"||t.key===" ")&&t.stopPropagation()})}function bo(o){const e=document.createElement("button");e.type="button",e.className="dm-agent-chat__attachment",e.title=we(y('Open the %1$s "%2$s"',"desktop-mode"),Oe(o.kind),o.title);const t=document.createElement("span");t.className=`dm-agent-chat__attachment-icon dashicons ${Ke(o.kind)}`,t.setAttribute("aria-hidden","true");const n=document.createElement("span");n.className="dm-agent-chat__attachment-text";const s=document.createElement("span");s.className="dm-agent-chat__attachment-title",s.textContent=o.title;const i=document.createElement("span");i.className="dm-agent-chat__attachment-meta",i.textContent=`${Oe(o.kind)} · #${o.id}`,n.append(s,i);const r=document.createElement("span");return r.className="dm-agent-chat__attachment-open dashicons dashicons-external",r.setAttribute("aria-hidden","true"),e.append(t,n,r),e.addEventListener("click",()=>{Yt(o)}),e}function rt(o){const{transcripts:e}=g.state;return e[o.id]||(e[o.id]=[]),e[o.id]}function vo(o){const e=o.querySelector("[data-os-agent-run-root]")??o;let t=!1,n=[],s=!1,i=-1;const r=()=>{const c=X();if(!c){s=!0;return}eo({restRoot:c.restRoot,restNonce:c.restNonce}).then(h=>{n=h}).catch(()=>{n=[]}).finally(()=>{s=!0,u()})},l=c=>{g.state.transcripts[c.id]=[],g.state.conversationIds||(g.state.conversationIds={}),g.state.conversationIds[c.id]=null,g.notify()},a=async c=>{const h=X();if(!h||!await po({title:y("Delete conversation?","desktop-mode"),message:y("Cannot be undone.","desktop-mode"),confirmLabel:y("Delete","desktop-mode"),danger:!0}))return;try{await oo({restRoot:h.restRoot,restNonce:h.restNonce},c.id)}catch{return}const _=g.state;_.conversationIds?.[c.agentId]===c.id&&(_.transcripts[c.agentId]=[],_.conversationIds[c.agentId]=null),_.conversationsRev=(_.conversationsRev??0)+1,g.notify()},d=c=>{const h=X(),f=document.createElement("div");f.className="dm-agent-chat__sidebar";const _=document.createElement("os-button");_.className="dm-agent-chat__new",_.textContent=y("+ New chat","desktop-mode"),(!c||t)&&_.setAttribute("disabled",""),_.addEventListener("click",()=>{c&&!t&&l(c)}),f.appendChild(_);const E=document.createElement("div");E.className="dm-agent-chat__convs";const x=c?g.state.conversationIds?.[c.id]??null:null,L=c?n.filter(m=>m.agentId===c.id):n;if(s&&L.length===0){const m=document.createElement("div");m.className="dm-agent-chat__convs-empty",m.textContent=y("No conversations yet.","desktop-mode"),E.appendChild(m)}for(const m of L){const w=document.createElement("div");w.className="dm-agent-chat__conv",m.id===x&&w.classList.add("dm-agent-chat__conv--active"),w.setAttribute("role","button"),w.tabIndex=0,w.title=`${m.agentName} — ${m.title}`;const ne=de("dm-agent-chat__conv-avatar",28,m.agentAvatarUrl,m.agentName);m.agentId>0&&it(ne,m.agentId);const W=document.createElement("span");W.className="dm-agent-chat__conv-text";const N=document.createElement("span");N.className="dm-agent-chat__conv-top";const P=document.createElement("span");P.className="dm-agent-chat__conv-name",P.textContent=m.agentName;const q=document.createElement("time");q.className="dm-agent-chat__conv-time",q.dateTime=m.updatedAt,q.textContent=mo(m.updatedAt),N.append(P,q);const B=document.createElement("span");B.className="dm-agent-chat__conv-preview",B.textContent=m.preview||m.title,W.append(N,B);const T=()=>{t||!h||io({restRoot:h.restRoot,restNonce:h.restNonce},m.id).catch(j=>{console.warn("[desktop-mode/agents] conversation load failed:",j)})};w.addEventListener("click",T),w.addEventListener("keydown",j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),T())});const U=document.createElement("button");U.type="button",U.className="dm-agent-chat__conv-delete",U.textContent="×",U.setAttribute("aria-label",y("Delete conversation","desktop-mode")),U.addEventListener("click",j=>{j.stopPropagation(),a(m)}),w.append(ne,W,U),E.appendChild(w)}return f.appendChild(E),f},u=()=>{const c=g.state.activeAgent;e.replaceChildren();const h=document.createElement("div");h.className="dm-agent-chat",h.appendChild(d(c));const f=document.createElement("div");if(f.className="dm-agent-chat__main",h.appendChild(f),!c){const T=document.createElement("os-empty-state");T.setAttribute("icon","superhero"),T.setAttribute("heading",y("No agent selected","desktop-mode")),T.setAttribute("description",y("Open an agent from the Agents section of WP Explorer, or pick a past conversation.","desktop-mode")),f.appendChild(T),e.appendChild(h);return}const _=document.createElement("div");_.className="dm-agent-chat__head";const E=de("dm-agent-chat__avatar",40,c.avatarUrl,c.name);it(E,c.id);const x=document.createElement("div");x.className="dm-agent-chat__title";const L=document.createElement("strong");L.textContent=c.name;const m=document.createElement("span");m.className="dm-agent-chat__desc",m.textContent=c.description,x.append(L,m),_.append(E,x),f.appendChild(_);const w=document.createElement("div");w.className="dm-agent-chat__scroll";const ne=rt(c);for(const[T,U]of ne.entries())w.appendChild(p(U,c,T===ne.length-1));f.appendChild(w);const W=document.createElement("div");W.className="dm-agent-chat__composer";const N=document.createElement("os-textarea");N.setAttribute("aria-label",y("Message the agent","desktop-mode")),N.setAttribute("placeholder",y("Ask the agent to do something…","desktop-mode")),N.setAttribute("rows","1"),N.setAttribute("auto-grow",""),N.setAttribute("max-rows","6"),N.setAttribute("submit-on-enter",""),t&&N.setAttribute("disabled","");const P=document.createElement("os-button");P.className="dm-agent-chat__send",P.setAttribute("variant","primary"),P.setAttribute("title",y("Send","desktop-mode")),P.innerHTML=`${go}<span class="dm-agent-chat__send-label">${y("Send","desktop-mode")}</span>`;const q=()=>{const T=(N.value??"").trim()==="";t||T?P.setAttribute("disabled",""):P.removeAttribute("disabled")};q();const B=()=>{const T=(N.value??"").trim();T===""||t||v(c,T)};N.addEventListener("os-input-change",q),N.addEventListener("os-submit",B),P.addEventListener("click",B),W.append(N,P),f.appendChild(W),e.appendChild(h),w.scrollTop=w.scrollHeight},p=(c,h,f=!1)=>{const _=document.createElement("div");if(_.className=`dm-agent-chat__line dm-agent-chat__line--${c.role}`,c.pending&&_.classList.add("dm-agent-chat__line--pending"),c.role==="agent")_.appendChild(de("dm-agent-chat__msg-avatar",28,h.avatarUrl,h.name));else if(c.role==="user"){const x=X()?.currentUser;(x?.avatarUrl||x?.name)&&_.appendChild(de("dm-agent-chat__msg-avatar",28,x.avatarUrl??"",x.name??""))}const E=document.createElement("div");if(E.className=`dm-agent-chat__msg dm-agent-chat__msg--${c.role}`,c.pending&&E.classList.add("dm-agent-chat__msg--pending"),_.appendChild(E),c.attachment){E.appendChild(bo(c.attachment));const x=document.createElement("div");x.className="dm-agent-chat__msg-caption",x.textContent=y("Shared with the agent","desktop-mode"),E.appendChild(x)}else{if(c.pending){const L=document.createElement("os-spinner");L.setAttribute("preset","inline"),E.appendChild(L)}const x=document.createElement("div");x.className="dm-agent-chat__msg-text",c.role==="agent"&&!c.pending?x.innerHTML=lt(c.text):x.textContent=c.text,E.appendChild(x)}if(c.toolCalls&&c.toolCalls.length>0){const x=document.createElement("details");x.className="dm-agent-chat__tools";const L=document.createElement("summary");L.textContent=`${y("Tool calls","desktop-mode")} (${c.toolCalls.length})`,x.appendChild(L);for(const m of c.toolCalls){const w=document.createElement("div");w.className="dm-agent-chat__tool",w.textContent=m.error?`${m.name} — ${m.error}`:`${m.name}(${JSON.stringify(m.args)})`,x.appendChild(w)}E.appendChild(x)}if(c.callToActions&&c.callToActions.length>0&&!c.pending){const x=document.createElement("div");x.className="dm-agent-chat__ctas";const L=f&&!c.ctaUsed&&!t;for(const m of c.callToActions){const w=document.createElement("os-button");w.setAttribute("variant",m.style??"secondary"),w.textContent=m.label,L||w.setAttribute("disabled",""),w.addEventListener("click",()=>{!L||!m.reply||(c.ctaUsed=!0,v(h,m.reply))}),x.appendChild(w)}E.appendChild(x)}return _},v=async(c,h)=>{const f=X();if(!f){rt(c).push({role:"error",text:y("Chat window config is missing.","desktop-mode"),at:Date.now()}),g.notify();return}t=!0,g.notify(),await et(c,h,{restRoot:f.restRoot,restNonce:f.restNonce},"chat"),t=!1,g.notify()};let $;const b=X(),I=G.wp?.os?.dragManager;I&&b&&($=I.registerDropTarget({id:`dm-agent-chat-${++fo}`,element:e,accept:c=>{const h=g.state.activeAgent;if(!h)return!1;const f=Qe(c);return f!==null&&!(f.kind==="user"&&f.id===h.id)},acceptLabel:y("Send to agent","desktop-mode"),onDrop:c=>{const h=g.state.activeAgent,f=Qe(c.payload);!h||!f||lo(h,f,{restRoot:b.restRoot,restNonce:b.restNonce})}}));const C=g.subscribe(()=>{const c=g.state.conversationsRev??0;c!==i&&(i=c,r()),u()});return i=g.state.conversationsRev??0,r(),u(),()=>{$?.(),C()}}G.openStationNativeWindows=G.openStationNativeWindows||{},G.openStationNativeWindows[st]=vo})(); | |
| 115 | + `}};ce.props=["open","title","message","confirm-label","cancel-label","danger","hide-cancel","dismissable","remember-label"],ce.styles=[Po],ce.help=void 0;let Re=ce;K("os-confirm-dialog",Re);function Fo(o){return new Promise(e=>{const t=document.createElement("os-confirm-dialog");t.setAttribute("open",""),o.title&&t.setAttribute("title",o.title),t.setAttribute("message",o.message),o.confirmLabel&&t.setAttribute("confirm-label",o.confirmLabel),o.cancelLabel&&t.setAttribute("cancel-label",o.cancelLabel),o.danger&&t.setAttribute("danger",""),o.hideCancel&&t.setAttribute("hide-cancel",""),o.dismissable&&t.setAttribute("dismissable",""),o.rememberLabel&&t.setAttribute("remember-label",o.rememberLabel);const n=s=>{t.remove(),e(s)};t.addEventListener("os-confirm",s=>{o.onRemember?.(s.detail?.remember===!0),n(!0)}),t.addEventListener("os-cancel",()=>n(!1)),document.body.appendChild(t)})}const bt="desktop-mode-agent-run",te=window;let Do=0;function G(){const o=te.openStationWindowConfig?.[bt];return o&&typeof o.restRoot=="string"?o:null}function jo(o){const e=new Date(o);if(Number.isNaN(e.getTime()))return"";const t=new Date,n=r=>new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),s=Math.round((n(t)-n(e))/864e5);return s<=0?e.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"}):s===1?h("Yesterday","desktop-mode"):s<7?e.toLocaleDateString(void 0,{weekday:"short"}):e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}const Ho='<svg class="dm-agent-chat__send-icon" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d="M8 13.5V2.5M8 2.5 3.5 7M8 2.5 12.5 7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>';function _e(o,e,t,n){const s=document.createElement("os-avatar");return s.className=o,s.setAttribute("size",String(e)),s.setAttribute("name",n),s.setAttribute("alt",n),t&&fo(s,t),s}function vt(o,e){o.setAttribute("clickable",""),o.setAttribute("title",h("Open the agent in WP Explorer","desktop-mode")),o.addEventListener("click",t=>{t.stopPropagation(),bo(e)}),o.addEventListener("keydown",t=>{(t.key==="Enter"||t.key===" ")&&t.stopPropagation()})}function Wo(o){const e=document.createElement("button");e.type="button",e.className="dm-agent-chat__attachment",e.title=ue(h('Open the %1$s "%2$s"',"desktop-mode"),ct(o.kind),o.title);const t=document.createElement("span");t.className=`dm-agent-chat__attachment-icon dashicons ${at(o.kind)}`,t.setAttribute("aria-hidden","true");const n=document.createElement("span");n.className="dm-agent-chat__attachment-text";const s=document.createElement("span");s.className="dm-agent-chat__attachment-title",s.textContent=o.title;const r=document.createElement("span");r.className="dm-agent-chat__attachment-meta",r.textContent=`${ct(o.kind)} · #${o.id}`,n.append(s,r);const i=document.createElement("span");return i.className="dm-agent-chat__attachment-open dashicons dashicons-external",i.setAttribute("aria-hidden","true"),e.append(t,n,i),e.addEventListener("click",()=>{_o(o)}),e}function Le(o){const{transcripts:e}=g.state;return e[o.id]||(e[o.id]=[]),e[o.id]}function qo(o){const e=o.querySelector("[data-os-agent-run-root]")??o,t=()=>{const d=g.state.activeAgent;return!!d&&Le(d).some(v=>v.pending)};let n=[],s=!1,r=!1,i=-1;const l=()=>{const d=G();if(!d){s=!0;return}Ao({restRoot:d.restRoot,restNonce:d.restNonce}).then(v=>{n=v,r=!1}).catch(v=>{n=[],r=!0,console.error("[openstation] agents: conversations failed to load:",v)}).finally(()=>{s=!0,N()})},c=d=>{g.state.transcripts[d.id]=[],g.state.conversationIds||(g.state.conversationIds={}),g.state.conversationIds[d.id]=null,g.notify()},a=async d=>{const v=G();if(!v||!await Fo({title:h("Delete conversation?","desktop-mode"),message:h("Cannot be undone.","desktop-mode"),confirmLabel:h("Delete","desktop-mode"),danger:!0}))return;try{await Eo({restRoot:v.restRoot,restNonce:v.restNonce},d.id)}catch(C){console.error("[openstation] agents: conversation delete failed:",C),Tt(Rt,C,{fallback:h("Could not delete the conversation.","desktop-mode")});return}const k=g.state;k.conversationIds?.[d.agentId]===d.id&&(k.transcripts[d.agentId]=[],k.conversationIds[d.agentId]=null),k.conversationsRev=(k.conversationsRev??0)+1,g.notify()},u=d=>{const v=G(),$=document.createElement("div");$.className="dm-agent-chat__sidebar";const k=document.createElement("os-button");k.className="dm-agent-chat__new",k.textContent=h("+ New chat","desktop-mode"),(!d||t())&&k.setAttribute("disabled",""),k.addEventListener("click",()=>{d&&!t()&&c(d)}),$.appendChild(k);const C=document.createElement("div");C.className="dm-agent-chat__convs";const _=d?g.state.conversationIds?.[d.id]??null:null,I=d?n.filter(m=>m.agentId===d.id):n;if(s&&I.length===0){const m=document.createElement("div");m.className="dm-agent-chat__convs-empty",m.textContent=h(r?"Could not load conversations.":"No conversations yet.","desktop-mode"),C.appendChild(m)}for(const m of I){const A=document.createElement("div");A.className="dm-agent-chat__conv",m.id===_&&A.classList.add("dm-agent-chat__conv--active"),A.setAttribute("role","button"),A.tabIndex=0,A.title=`${m.agentName} — ${m.title}`;const z=_e("dm-agent-chat__conv-avatar",28,m.agentAvatarUrl,m.agentName);m.agentId>0&&vt(z,m.agentId);const V=document.createElement("span");V.className="dm-agent-chat__conv-text";const X=document.createElement("span");X.className="dm-agent-chat__conv-top";const R=document.createElement("span");R.className="dm-agent-chat__conv-name",R.textContent=m.agentName;const D=document.createElement("time");D.className="dm-agent-chat__conv-time",D.dateTime=m.updatedAt,D.textContent=jo(m.updatedAt),X.append(R,D);const J=document.createElement("span");J.className="dm-agent-chat__conv-preview",J.textContent=m.preview||m.title,V.append(X,J);const de=()=>{t()||!v||(x=!0,To({restRoot:v.restRoot,restNonce:v.restNonce},m.id).catch(W=>{console.warn("[desktop-mode/agents] conversation load failed:",W)}))};A.addEventListener("click",de),A.addEventListener("keydown",W=>{(W.key==="Enter"||W.key===" ")&&(W.preventDefault(),de())});const U=document.createElement("button");U.type="button",U.className="dm-agent-chat__conv-delete",U.textContent="×",U.setAttribute("aria-label",h("Delete conversation","desktop-mode")),U.addEventListener("click",W=>{W.stopPropagation(),a(m)}),A.append(z,V,U),C.appendChild(A)}return $.appendChild(C),$},p=8;let f=!0,x=!1,b=0,S;const w=d=>d.scrollHeight-d.scrollTop-d.clientHeight<=p,N=()=>{const d=g.state.activeAgent,v=e.querySelector(".dm-agent-chat__scroll");v&&(b=v.scrollTop,f=x||w(v)),x=!1,S?.disconnect(),S=void 0,e.replaceChildren();const $=document.createElement("div");$.className="dm-agent-chat",$.appendChild(u(d));const k=document.createElement("div");if(k.className="dm-agent-chat__main",$.appendChild(k),!d){const j=document.createElement("os-empty-state");j.setAttribute("icon","superhero"),j.setAttribute("heading",h("No agent selected","desktop-mode")),j.setAttribute("description",h("Open an agent from the Agents section of WP Explorer, or pick a past conversation.","desktop-mode")),k.appendChild(j),e.appendChild($);return}const C=document.createElement("div");C.className="dm-agent-chat__head";const _=_e("dm-agent-chat__avatar",40,d.avatarUrl,d.name);vt(_,d.id);const I=document.createElement("div");I.className="dm-agent-chat__title";const m=document.createElement("strong");m.textContent=d.name;const A=document.createElement("span");A.className="dm-agent-chat__desc",A.textContent=d.description,I.append(m,A),C.append(_,I),k.appendChild(C);const z=document.createElement("div");z.className="dm-agent-chat__scroll";const V=Le(d);for(const[j,Oo]of V.entries())z.appendChild(T(Oo,d,j===V.length-1));k.appendChild(z);const X=document.createElement("div");X.className="dm-agent-chat__composer";const R=document.createElement("os-textarea");R.setAttribute("aria-label",h("Message the agent","desktop-mode")),R.setAttribute("placeholder",h("Ask the agent to do something…","desktop-mode")),R.setAttribute("rows","1"),R.setAttribute("auto-grow",""),R.setAttribute("max-rows","6"),R.setAttribute("submit-on-enter",""),t()&&R.setAttribute("disabled","");const D=document.createElement("os-button");D.className="dm-agent-chat__send",D.setAttribute("variant","primary"),D.setAttribute("title",h("Send","desktop-mode")),D.innerHTML=`${Ho}<span class="dm-agent-chat__send-label">${h("Send","desktop-mode")}</span>`;const J=()=>{const j=(R.value??"").trim()==="";t()||j?D.setAttribute("disabled",""):D.removeAttribute("disabled")};J();const de=()=>{const j=(R.value??"").trim();j===""||t()||F(d,j)};R.addEventListener("os-input-change",J),R.addEventListener("os-submit",de),D.addEventListener("click",de),X.append(R,D),k.appendChild(X),e.appendChild($);let U=-1;const W=()=>{f&&(z.scrollTop=z.scrollHeight,U=z.scrollTop)};if(f||(z.scrollTop=b),W(),z.addEventListener("scroll",()=>{f&&z.scrollTop===U||(f=w(z))}),typeof ResizeObserver=="function"){S=new ResizeObserver(W),S.observe(z);for(const j of z.children)S.observe(j)}},T=(d,v,$=!1)=>{const k=document.createElement("div");if(k.className=`dm-agent-chat__line dm-agent-chat__line--${d.role}`,d.pending&&k.classList.add("dm-agent-chat__line--pending"),d.role==="agent")k.appendChild(_e("dm-agent-chat__msg-avatar",28,v.avatarUrl,v.name));else if(d.role==="user"){const _=G()?.currentUser;(_?.avatarUrl||_?.name)&&k.appendChild(_e("dm-agent-chat__msg-avatar",28,_.avatarUrl??"",_.name??""))}const C=document.createElement("div");if(C.className=`dm-agent-chat__msg dm-agent-chat__msg--${d.role}`,d.pending&&C.classList.add("dm-agent-chat__msg--pending"),k.appendChild(C),d.attachment){C.appendChild(Wo(d.attachment));const _=document.createElement("div");_.className="dm-agent-chat__msg-caption",_.textContent=h("Shared with the agent","desktop-mode"),C.appendChild(_)}else{if(d.pending){const I=document.createElement("os-spinner");I.setAttribute("preset","inline"),C.appendChild(I)}const _=document.createElement("div");_.className="dm-agent-chat__msg-text",d.role==="agent"&&!d.pending?_.innerHTML=It(d.text):_.textContent=d.text,C.appendChild(_)}if(d.toolCalls&&d.toolCalls.length>0){const _=document.createElement("details");_.className="dm-agent-chat__tools";const I=document.createElement("summary");I.textContent=`${h("Tool calls","desktop-mode")} (${d.toolCalls.length})`,_.appendChild(I);for(const m of d.toolCalls){const A=document.createElement("div");A.className="dm-agent-chat__tool",A.textContent=m.error?`${m.name} — ${m.error}`:`${m.name}(${JSON.stringify(m.args)})`,_.appendChild(A)}C.appendChild(_)}if(d.callToActions&&d.callToActions.length>0&&!d.pending){const _=document.createElement("div");_.className="dm-agent-chat__ctas";const I=$&&!d.ctaUsed&&!t();for(const m of d.callToActions){const A=document.createElement("os-button");A.setAttribute("variant",m.style??"secondary"),A.textContent=m.label,I||A.setAttribute("disabled",""),A.addEventListener("click",()=>{!I||!m.reply||(d.ctaUsed=!0,F(v,m.reply))}),_.appendChild(A)}C.appendChild(_)}return k},F=async(d,v)=>{const $=G();if(x=!0,!$){Le(d).push({role:"error",text:h("Chat window config is missing.","desktop-mode"),at:Date.now()}),g.notify();return}await pt(d,v,{restRoot:$.restRoot,restNonce:$.restNonce},"chat")};let H;const le=G(),_t=te.wp?.os?.dragManager;_t&&le&&(H=_t.registerDropTarget({id:`dm-agent-chat-${++Do}`,element:e,accept:d=>{const v=g.state.activeAgent;if(!v)return!1;const $=ht(d);return $!==null&&!($.kind==="user"&&$.id===v.id)},acceptLabel:h("Send to agent","desktop-mode"),onDrop:d=>{const v=g.state.activeAgent,$=ht(d.payload);!v||!$||(x=!0,zo(v,$,{restRoot:le.restRoot,restNonce:le.restNonce}))}}));const Uo=g.subscribe(()=>{const d=g.state.conversationsRev??0;d!==i&&(i=d,l()),N()});return i=g.state.conversationsRev??0,l(),N(),()=>{H?.(),S?.disconnect(),Uo()}}te.openStationNativeWindows=te.openStationNativeWindows||{},te.openStationNativeWindows[bt]=qo})(); | |