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

1 line
7.1 KiB
JavaScript

(()=>{"use strict";var e,t={792:(e,t,o)=>{const r=window.wp.element,n=window.wp.domReady;var a=o.n(n);const c=window.wp.apiFetch;var i=o.n(c);const l=window.wp.components,u=window.wp.i18n;function s(e){return`var(--wp--preset--color--${e})`}function p(e){if("string"!=typeof e)return null;if(e.match(/^#/))return e.substring(0,7);const[,,t]=e.split("|");return s(t)}function m(e,t,o=null,r=""){return o?`${e}${r} { ${t}: ${o}; }\n`:""}function d(e,t,o,r){return m(e,"background-color",t)+m(e,"color",o)+m(e,"background-color",r,":hover")+m(e,"background-color",r,":focus")}function v({selector:e,style:t,backgroundColor:o}){const n=function(e,t,o){const r=`${e} .components-button`,n=("string"==typeof(a=o)?s(a):a?.color?.background||null)||t?.color?.background;var a;return d(r,p(t?.elements?.link?.color?.text),n,p(t?.elements?.link?.[":hover"]?.color?.text))}(e,t,o);return(0,r.createElement)("style",null,n)}const f=window.wp.primitives,y=(0,r.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(f.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"})),b=(0,r.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,r.createElement)(f.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),w=function({icon:e,size:t=24,...o}){return(0,r.cloneElement)(e,{width:t,height:t,...o})},_=window.wp.compose;function h(e){try{return new URL(e),!0}catch(e){return!1}}function g({actionText:e,copyDescription:t,handle:o,resourceUrl:n}){const a=(0,u.__)("Loading...","activitypub"),c=(0,u.__)("Opening...","activitypub"),s=(0,u.__)("Error","activitypub"),p=(0,u.__)("Invalid","activitypub"),[m,d]=(0,r.useState)(e),[v,f]=(0,r.useState)(y),g=(0,_.useCopyToClipboard)(o,(()=>{f(b),setTimeout((()=>f(y)),1e3)})),[E,k]=(0,r.useState)(""),x=(0,r.useCallback)((()=>{let t;if(!h(E)&&!function(e){const t=e.replace(/^@/,"").split("@");return 2===t.length&&h(`https://${t[1]}`)}(E))return d(p),t=setTimeout((()=>d(e)),2e3),()=>clearTimeout(t);const o=n+E;d(a),i()({path:o}).then((({url:t})=>{d(c),setTimeout((()=>{window.open(t,"_blank"),d(e)}),200)})).catch((()=>{d(s),setTimeout((()=>d(e)),2e3)}))}),[E]);return(0,r.createElement)("div",{className:"activitypub__dialog"},(0,r.createElement)("div",{className:"activitypub-dialog__section"},(0,r.createElement)("h4",null,(0,u.__)("My Profile","activitypub")),(0,r.createElement)("div",{className:"activitypub-dialog-description"},t),(0,r.createElement)("div",{className:"activitypub-dialog__button-group"},(0,r.createElement)("input",{type:"text",value:o,readOnly:!0}),(0,r.createElement)(l.Button,{ref:g},(0,r.createElement)(w,{icon:v}),(0,u.__)("Copy","activitypub")))),(0,r.createElement)("div",{className:"activitypub-dialog__section"},(0,r.createElement)("h4",null,(0,u.__)("Your Profile","activitypub")),(0,r.createElement)("div",{className:"activitypub-dialog__description"},(0,r.createInterpolateElement)((0,u.__)("Or, if you know your own profile, we can start things that way! (eg <code>https://example.com/yourusername</code> or <code>yourusername@example.com</code>)","activitypub"),{code:(0,r.createElement)("code",null)})),(0,r.createElement)("div",{className:"activitypub-dialog__button-group"},(0,r.createElement)("input",{type:"text",value:E,onKeyDown:e=>{"Enter"===e?.code&&x()},onChange:e=>k(e.target.value)}),(0,r.createElement)(l.Button,{onClick:x},m))))}const{namespace:E}=window._activityPubOptions,k={avatar:"",webfinger:"@well@hello.dolly",name:(0,u.__)("Hello Dolly Fan Account","activitypub"),url:"#"};function x(e){if(!e)return k;const t={...k,...e};return t.avatar=t?.icon?.url,t}function O({profile:e,popupStyles:t,userId:o}){const{avatar:n,name:a,webfinger:c}=e;return(0,r.createElement)("div",{className:"activitypub-profile"},(0,r.createElement)("img",{className:"activitypub-profile__avatar",src:n,alt:a}),(0,r.createElement)("div",{className:"activitypub-profile__content"},(0,r.createElement)("div",{className:"activitypub-profile__name"},a),(0,r.createElement)("div",{className:"activitypub-profile__handle",title:c},c)),(0,r.createElement)(C,{profile:e,popupStyles:t,userId:o}))}function C({profile:e,popupStyles:t,userId:o}){const[n,a]=(0,r.useState)(!1),c=(0,u.sprintf)((0,u.__)("Follow %s","activitypub"),e?.name);return(0,r.createElement)(r.Fragment,null,(0,r.createElement)(l.Button,{className:"activitypub-profile__follow",onClick:()=>a(!0)},(0,u.__)("Follow","activitypub")),n&&(0,r.createElement)(l.Modal,{className:"activitypub-profile__confirm activitypub__modal",onRequestClose:()=>a(!1),title:c},(0,r.createElement)(N,{profile:e,userId:o}),(0,r.createElement)("style",null,t)))}function N({profile:e,userId:t}){const{webfinger:o}=e,n=(0,u.__)("Follow","activitypub"),a=`/${E}/actors/${t}/remote-follow?resource=`,c=(0,u.__)("Copy and paste my profile into the search field of your favorite fediverse app or server.","activitypub");return(0,r.createElement)(g,{actionText:n,copyDescription:c,handle:o,resourceUrl:a})}function S({selectedUser:e,style:t,backgroundColor:o,id:n,useId:a=!1,profileData:c=!1}){const[l,u]=(0,r.useState)(x()),s="site"===e?0:e,m=function(e){return d(".apfmd__button-group .components-button",p(e?.elements?.link?.color?.text)||"#111","#fff",p(e?.elements?.link?.[":hover"]?.color?.text)||"#333")}(t),f=a?{id:n}:{};function y(e){u(x(e))}return(0,r.useEffect)((()=>{if(c)return y(c);(function(e){const t={headers:{Accept:"application/activity+json"},path:`/${E}/actors/${e}`};return i()(t)})(s).then(y)}),[s,c]),(0,r.createElement)("div",{...f},(0,r.createElement)(v,{selector:`#${n}`,style:t,backgroundColor:o}),(0,r.createElement)(O,{profile:l,userId:s,popupStyles:m}))}let $=1;a()((()=>{[].forEach.call(document.querySelectorAll(".activitypub-follow-me-block-wrapper"),(e=>{const t=JSON.parse(e.dataset.attrs);(0,r.render)((0,r.createElement)(S,{...t,id:"activitypub-follow-me-block-"+$++,useId:!0}),e)}))}))}},o={};function r(e){var n=o[e];if(void 0!==n)return n.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.m=t,e=[],r.O=(t,o,n,a)=>{if(!o){var c=1/0;for(s=0;s<e.length;s++){o=e[s][0],n=e[s][1],a=e[s][2];for(var i=!0,l=0;l<o.length;l++)(!1&a||c>=a)&&Object.keys(r.O).every((e=>r.O[e](o[l])))?o.splice(l--,1):(i=!1,a<c&&(c=a));if(i){e.splice(s--,1);var u=n();void 0!==u&&(t=u)}}return t}a=a||0;for(var s=e.length;s>0&&e[s-1][2]>a;s--)e[s]=e[s-1];e[s]=[o,n,a]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={529:0,740:0};r.O.j=t=>0===e[t];var t=(t,o)=>{var n,a,c=o[0],i=o[1],l=o[2],u=0;if(c.some((t=>0!==e[t]))){for(n in i)r.o(i,n)&&(r.m[n]=i[n]);if(l)var s=l(r)}for(t&&t(o);u<c.length;u++)a=c[u],r.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return r.O(s)},o=self.webpackChunkwordpress_activitypub=self.webpackChunkwordpress_activitypub||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var n=r.O(void 0,[740],(()=>r(792)));n=r.O(n)})();