laipower/wp-content/plugins/activitypub/build/follow-me/index.js

1 line
8.2 KiB
JavaScript
Raw Normal View History

(()=>{"use strict";var e,t={454:(e,t,n)=>{const o=window.wp.blocks,r=window.wp.element,l=window.wp.primitives,i=(0,r.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(l.Path,{d:"M15.5 9.5a1 1 0 100-2 1 1 0 000 2zm0 1.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5zm-2.25 6v-2a2.75 2.75 0 00-2.75-2.75h-4A2.75 2.75 0 003.75 15v2h1.5v-2c0-.69.56-1.25 1.25-1.25h4c.69 0 1.25.56 1.25 1.25v2h1.5zm7-2v2h-1.5v-2c0-.69-.56-1.25-1.25-1.25H15v-1.5h2.5A2.75 2.75 0 0120.25 15zM9.5 8.5a1 1 0 11-2 0 1 1 0 012 0zm1.5 0a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z",fillRule:"evenodd"})),a=window.wp.blockEditor,c=window.wp.i18n,u=window.wp.components,s=window.wp.data,p=window._activityPubOptions?.enabled,v=window.wp.apiFetch;var m=n.n(v);const d=(0,r.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(l.Path,{d:"M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"})),f=(0,r.createElement)(l.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(l.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),b=function({icon:e,size:t=24,...n}){return(0,r.cloneElement)(e,{width:t,height:t,...n})},w=window.wp.compose;function y(e){return`var(--wp--preset--color--${e})`}function _(e){if("string"!=typeof e)return null;if(e.match(/^#/))return e.substring(0,7);const[,,t]=e.split("|");return y(t)}function h(e,t,n=null,o=""){return n?`${e}${o} { ${t}: ${n}; }\n`:""}function g(e,t,n,o){return h(e,"background-color",t)+h(e,"color",n)+h(e,"background-color",o,":hover")+h(e,"background-color",o,":focus")}function E({selector:e,style:t,backgroundColor:n}){const o=function(e,t,n){const o=`${e} .components-button`,r=("string"==typeof(l=n)?y(l):l?.color?.background||null)||t?.color?.background;var l;return g(o,_(t?.elements?.link?.color?.text),r,_(t?.elements?.link?.[":hover"]?.color?.text))}(e,t,n);return(0,r.createElement)("style",null,o)}const{namespace:k}=window._activityPubOptions,x={avatar:"",webfinger:"@well@hello.dolly",name:(0,c.__)("Hello Dolly Fan Account","activitypub"),url:"#"};function C(e){if(!e)return x;const t={...x,...e};return t.avatar=t?.icon?.url,t}function O({profile:e,popupStyles:t,userId:n}){const{avatar:o,name:l,webfinger:i}=e;return(0,r.createElement)("div",{className:"activitypub-profile"},(0,r.createElement)("img",{className:"activitypub-profile__avatar",src:o,alt:l}),(0,r.createElement)("div",{className:"activitypub-profile__content"},(0,r.createElement)("div",{className:"activitypub-profile__name"},l),(0,r.createElement)("div",{className:"activitypub-profile__handle",title:i},i)),(0,r.createElement)(S,{profile:e,popupStyles:t,userId:n}))}function S({profile:e,popupStyles:t,userId:n}){const[o,l]=(0,r.useState)(!1),i=(0,c.sprintf)((0,c.__)("Follow %s","activitypub"),e?.name);return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(u.Button,{className:"activitypub-profile__follow",onClick:()=>l(!0)},(0,c.__)("Follow","activitypub")),o&&(0,r.createElement)(u.Modal,{className:"activitypub-profile__confirm activitypub__modal",onRequestClose:()=>l(!1),title:i},(0,r.createElement)($,{profile:e,userId:n}),(0,r.createElement)("style",null,t)))}function N(e){try{return new URL(e),!0}catch(e){return!1}}function $({profile:e,userId:t}){const{webfinger:n}=e,o=(0,c.__)("Follow","activitypub"),l=(0,c.__)("Loading...","activitypub"),i=(0,c.__)("Opening...","activitypub"),a=(0,c.__)("Error","activitypub"),s=(0,c.__)("Invalid","activitypub"),[p,v]=(0,r.useState)(o),[y,_]=(0,r.useState)(d),h=(0,w.useCopyToClipboard)(n,(()=>{_(f),setTimeout((()=>_(d)),1e3)})),[g,E]=(0,r.useState)(""),x=(0,r.useCallback)((()=>{let e;if(!N(g)&&!function(e){const t=e.replace(/^@/,"").split("@");return 2===t.length&&N(`https://${t[1]}`)}(g))return v(s),e=setTimeout((()=>v(o)),2e3),()=>clearTimeout(e);const n=`/${k}/users/${t}/remote-follow?resource=${g}`;v(l),m()({path:n}).the