(()=>{"use strict";var e,t={3508(e,t,i){const a=window.wp.blocks,s=window.wp.primitives,n=window.ReactJSXRuntime;var r=(0,n.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,n.jsx)(s.Path,{fillRule:"evenodd",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"})});const o=[{attributes:{title:{type:"string",default:"Fediverse Following"},selectedUser:{type:"string",default:"blog"},per_page:{type:"number",default:10},order:{type:"string",default:"desc",enum:["asc","desc"]}},supports:{html:!1},isEligible:({title:e})=>!!e,migrate:({title:e,...t})=>[t,[(0,a.createBlock)("core/heading",{content:e,level:3})]]}],l=window.wp.components,c=window.wp.blockEditor,p=window.wp.coreData,u=window.wp.data,d=window.wp.element,h=window.wp.i18n,v=window.wp.apiFetch;var g=i.n(v);function b(){return window._activityPubOptions||{}}function y({name:e}){const{enabled:t}=b(),i=t?.blog?"":(0,h.__)("It will be empty in other non-author contexts.","activitypub"),a=(0,h.sprintf)(/* translators: %1$s: block name, %2$s: extra information for non-author context */ /* translators: %1$s: block name, %2$s: extra information for non-author context */
(0,h.__)("This %1$s block will adapt to the page it is on, displaying the user profile associated with a post author (in a loop) or a user archive. %2$s","activitypub"),e,i).trim();return(0,n.jsx)(l.Card,{children:(0,n.jsx)(l.CardBody,{children:(0,d.createInterpolateElement)(a,{strong:(0,n.jsx)("strong",{})})})})}const f=window.wp.url;function w({name:e,icon:t,url:i,webfinger:a}){const s=`@${a}`,{defaultAvatarUrl:r,showAvatars:o}=b(),l=t?.url||r;return(0,n.jsxs)("a",{className:"activitypub-actor-link",href:i,title:s,onClick:e=>e.preventDefault(),children:[o&&(0,n.jsx)("img",{width:"48",height:"48",src:l,className:"activitypub-actor-avatar",alt:e,onError:e=>{e.target.src=r}}),(0,n.jsxs)("div",{className:"activitypub-actor-info",children:[(0,n.jsx)("span",{className:"activitypub-actor-name",children:e}),(0,n.jsx)("span",{className:"activitypub-actor-handle",children:s})]}),(0,n.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",className:"external-link-icon","aria-hidden":"true",focusable:"false",fill:"currentColor",children:(0,n.jsx)("path",{d:"M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"})})]})}function m({page:e,pages:t,setPage:i,navLabel:a=(0,h.__)("Navigation","activitypub")}){if(t<=1)return null;const s=e<=1,r=e>=t;return(0,n.jsxs)("nav",{className:"activitypub-actor-list-pagination",role:"navigation",children:[(0,n.jsx)("h1",{className:"screen-reader-text",children:a}),(0,n.jsx)("a",{role:"button",tabIndex:0,className:"pagination-previous","aria-disabled":s,"aria-label":(0,h.__)("Previous page","activitypub"),onClick:()=>{s||i(e-1)},onKeyDown:t=>{s||"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i(e-1))},children:(0,h.__)("Previous","activitypub")}),(0,n.jsx)("div",{className:"pagination-info",children:`${e} / ${t}`}),(0,n.jsx)("a",{role:"button",tabIndex:0,className:"pagination-next","aria-disabled":r,"aria-label":(0,h.__)("Next page","activitypub"),onClick:()=>{r||i(e+1)},onKeyDown:t=>{r||"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i(e+1))},children:(0,h.__)("Next","activitypub")})]})}function _({selectedUser:e,perPage:t,order:i,endpoint:a="followers",page:s,setPage:r,initialData:o=!1,emptyMessage:l=(0,h.__)("No results found.","activitypub"),navLabel:c=(0,h.__)("Navigation","activitypub")}){const{namespace:p}=b(),u="blog"===e?0:e,[v,y]=(0,d.useState)([]),[_,x]=(0,d.useState)(0),[j,k]=(0,d.useState)(1),N=s||j,S=r||k,U=(0,d.useCallback)((e,i)=>{y(e),x(Math.ceil(i/t))},[t]);return(0,d.useEffect)(()=>{if(o&&1===N)return U(o.items,o.total);const e=(0,f.addQueryArgs)(`/${p}/actors/${u}/${a}`,{per_page:t,order:i,page:N,context:"full"});g()({path:e}).then(({orderedItems:e=[],totalItems:t=0})=>U(e,t)).catch(()=>U([],0))},[p,u,t,i,N,a,o,U]),(0,n.jsxs)("div",{className:"activitypub-actor-list-container",children:[v.length?(0,n.jsx)("ul",{className:"activitypub-actor-list",children:v.map(e=>(0,n.jsx)("li",{className:"activitypub-actor-item",children:(0,n.jsx)(w,{...e})},e.url))}):(0,n.jsx)("p",{className:"activitypub-actor-list-placeholder",children:l}),(0,n.jsx)(m,{page:N,pages:_,setPage:S,navLabel:c})]})}function x(e){return!!e&&Object.entries(e).some(([e,t])=>e.endsWith("activitypub_hide_social_graph")&&t)}const j=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","name":"activitypub/following","apiVersion":3,"version":"8.2.1","title":"Fediverse Following","category":"widgets","description":"Display the accounts you follow in the Fediverse on your website.","textdomain":"activitypub","icon":"groups","keywords":["fediverse","activitypub","following","mastodon"],"supports":{"html":false,"interactivity":true},"attributes":{"selectedUser":{"type":"string","default":"blog"},"per_page":{"type":"number","default":10},"order":{"type":"string","default":"desc","enum":["asc","desc"]}},"usesContext":["postType","postId"],"styles":[{"name":"default","label":"Default","isDefault":true},{"name":"card","label":"Card"},{"name":"compact","label":"Compact"}],"editorScript":"file:./index.js","editorStyle":"file:./index.css","viewScriptModule":"file:./view.js","viewScript":"wp-api-fetch","style":["file:./style-index.css"],"render":"file:./render.php"}');(0,a.registerBlockType)(j,{deprecated:o,edit:function({attributes:e,setAttributes:t,context:{postType:i,postId:a}}){const{className:s="",order:r,per_page:o,selectedUser:v}=e,f=(0,c.useBlockProps)(),[w,m]=(0,d.useState)(1),j=[{label:(0,h.__)("New to old","activitypub"),value:"desc"},{label:(0,h.__)("Old to new","activitypub"),value:"asc"}],k=function({withInherit:e=!1}){const{enabled:t,namespace:i}=b(),[a,s]=(0,d.useState)(!1),{fetchedUsers:n,isLoadingUsers:r}=(0,u.useSelect)(e=>{const{getUsers:i,getIsResolving:a}=e("core");return{fetchedUsers:t?.users?i({capabilities:"activitypub"}):null,isLoadingUsers:!!t?.users&&a("getUsers",[{capabilities:"activitypub"}])}},[t?.users]),o=(0,u.useSelect)(e=>n||r?null:e("core").getCurrentUser(),[n,r]);(0,d.useEffect)(()=>{!n&&!r&&o&&i&&g()({path:`/${i}/actors/${o.id}`,method:"HEAD",headers:{Accept:"application/activity+json"},parse:!1}).then(()=>s(!0)).catch(()=>s(!1))},[n,r,o,i]);const l=(0,d.useMemo)(()=>n||(o&&a?[{id:o.id,name:o.name}]:[]),[n,o,a]);return(0,d.useMemo)(()=>{if(!l.length)return[];const i=[];return t?.blog&&n&&i.push({label:(0,h.__)("Blog","activitypub"),value:"blog"}),e&&t?.users&&n&&i.push({label:(0,h.__)("Dynamic User","activitypub"),value:"inherit"}),l.reduce((e,t)=>(e.push({label:t.name,value:`${t.id}`}),e),i)},[l,t?.blog,t?.users,n,e])}({withInherit:!0}),N=e=>i=>{m(1),t({[e]:i})},{blogSocialGraphHidden:S,currentUser:U,usersWithMeta:C,siteUrl:M,canManageOptions:O}=(0,u.useSelect)(e=>{const{getCurrentUser:t,getUsers:i,getEntityRecord:a,canUser:s}=e(p.store),n=a("root","site"),r=a("root","__unstableBase");return{blogSocialGraphHidden:!!n?.activitypub_hide_social_graph,currentUser:t(),usersWithMeta:i({capabilities:"activitypub",context:"edit"}),siteUrl:r?.home,canManageOptions:s("update",{kind:"root",name:"site"})}},[]),P=(0,u.useSelect)(e=>{const{getEditedEntityRecord:t}=e(p.store),s=t("postType",i,a)?.author;return s??null},[i,a]),E=(0,d.useMemo)(()=>k.length&&C?k.filter(({value:e})=>{if("inherit"===e)return!0;if("blog"===e)return!S;const t=C?.find(t=>String(t.id)===e);return!x(t?.meta)}):[],[k,S,C]),D=(0,d.useMemo)(()=>{if(!C)return!1;if("blog"===v)return S;if("inherit"===v){if(!P)return!1;const e=C.find(e=>e.id===P);return!!e&&x(e.meta)}return!1},[v,P,C,S]),F=(0,d.useMemo)(()=>!(!D||!U)&&("blog"===v?O:U.id===P),[D,U,v,P,O]),I=(0,d.useMemo)(()=>F&&M?"blog"===v?M+"/wp-admin/options-general.php?page=activitypub&tab=blog-profile":M+"/wp-admin/profile.php#activitypub":null,[F,M,v]);(0,d.useEffect)(()=>{E.length&&("blog"===v||"inherit"===v||E.find(({value:e})=>e===v)||t({selectedUser:E[0].value}))},[v,E,t]);const B=[["core/heading",{level:3,placeholder:(0,h.__)("Fediverse Following","activitypub"),content:(0,h.__)("Fediverse Following","activitypub")}]];return(0,n.jsxs)("div",{...f,children:[(0,n.jsx)(c.InspectorControls,{children:(0,n.jsxs)(l.PanelBody,{title:(0,h.__)("Following Options","activitypub"),children:[E.length>1&&(0,n.jsx)(l.SelectControl,{label:(0,h.__)("Select User","activitypub"),value:v,options:E,onChange:N("selectedUser"),__next40pxDefaultSize:!0}),(0,n.jsx)(l.SelectControl,{label:(0,h.__)("Sort","activitypub"),value:r,options:j,onChange:N("order"),__next40pxDefaultSize:!0}),(0,n.jsx)(l.RangeControl,{label:(0,h.__)("Number of Following","activitypub"),value:o,onChange:N("per_page"),min:1,max:10,__next40pxDefaultSize:!0})]})},"setting"),(0,n.jsxs)("div",{className:`wp-block-activitypub-following ${s}`,children:[(0,n.jsx)(c.InnerBlocks,{template:B,allowedBlocks:["core/heading"],templateLock:"all",renderAppender:!1}),D&&(0,n.jsx)(l.Notice,{status:"warning",isDismissible:!1,children:I?(0,d.createInterpolateElement)(/* translators: is a link to the profile settings page. */ /* translators: is a link to the profile settings page. */
(0,h.__)("The selected user has their social graph hidden. This block will not display following on the frontend. Edit privacy settings","activitypub"),{a:(0,n.jsx)(l.ExternalLink,{href:I})}):(0,h.__)("The selected user has their social graph hidden. This block will not display following on the frontend.","activitypub")}),!D&&"inherit"===v&&P&&(0,n.jsx)(_,{selectedUser:P,perPage:o,order:r,endpoint:"following",page:w,setPage:m,emptyMessage:(0,h.__)("Not following anyone yet.","activitypub"),navLabel:(0,h.__)("Following navigation","activitypub")}),!D&&"inherit"===v&&!P&&(0,n.jsx)(y,{name:(0,h.__)("Following","activitypub")}),!D&&"inherit"!==v&&(0,n.jsx)(_,{selectedUser:v,perPage:o,order:r,endpoint:"following",page:w,setPage:m,emptyMessage:(0,h.__)("Not following anyone yet.","activitypub"),navLabel:(0,h.__)("Following navigation","activitypub")})]})]})},save:function(){const e=c.useBlockProps.save(),t=c.useInnerBlocksProps.save(e);return(0,n.jsx)("div",{...t})},icon:r})}},i={};function a(e){var s=i[e];if(void 0!==s)return s.exports;var n=i[e]={exports:{}};return t[e](n,n.exports,a),n.exports}a.m=t,e=[],a.O=(t,i,s,n)=>{if(!i){var r=1/0;for(p=0;p=n)&&Object.keys(a.O).every(e=>a.O[e](i[l]))?i.splice(l--,1):(o=!1,n0&&e[p-1][2]>n;p--)e[p]=e[p-1];e[p]=[i,s,n]},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var i in t)a.o(t,i)&&!a.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={801:0,509:0};a.O.j=t=>0===e[t];var t=(t,i)=>{var s,n,[r,o,l]=i,c=0;if(r.some(t=>0!==e[t])){for(s in o)a.o(o,s)&&(a.m[s]=o[s]);if(l)var p=l(a)}for(t&&t(i);ca(3508));s=a.O(s)})();