OwlCyberSecurity - MANAGER
Edit File: campaignCommentsBlockApp.js
(()=>{"use strict";var e={1063:(e,t,n)=>{var r=n(51609),a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=r.useState,i=r.useEffect,c=r.useLayoutEffect,s=r.useDebugValue;function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!a(e,n)}catch(e){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=o({inst:{value:n,getSnapshot:t}}),a=r[0].inst,l=r[1];return c((function(){a.value=n,a.getSnapshot=t,u(a)&&l({inst:a})}),[e,n,t]),i((function(){return u(a)&&l({inst:a}),e((function(){u(a)&&l({inst:a})}))}),[e]),s(n),n};t.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:l},19888:(e,t,n)=>{e.exports=n(1063)},51609:e=>{e.exports=window.React}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r=n(51609);const a=window.wp.element,o=window.wp.apiFetch;var i=n.n(o);const c=window.wp.url,s=window.wp.i18n;var u=n(19888);const l=()=>{},d=l(),m=Object,f=e=>e===d,g=e=>"function"==typeof e,p=(e,t)=>({...e,...t}),v=new WeakMap;let w=0;const h=e=>{const t=typeof e,n=e&&e.constructor,r=n==Date;let a,o;if(m(e)!==e||r||n==RegExp)a=r?e.toJSON():"symbol"==t?e.toString():"string"==t?JSON.stringify(e):""+e;else{if(a=v.get(e),a)return a;if(a=++w+"~",v.set(e,a),n==Array){for(a="@",o=0;o<e.length;o++)a+=h(e[o])+",";v.set(e,a)}if(n==m){a="#";const t=m.keys(e).sort();for(;!f(o=t.pop());)f(e[o])||(a+=o+":"+h(e[o])+",");v.set(e,a)}}return a},y=new WeakMap,_={},b={},E="undefined",k=typeof window!=E,S=typeof document!=E,O=(e,t)=>{const n=y.get(e);return[()=>!f(t)&&e.get(t)||_,r=>{if(!f(t)){const a=e.get(t);t in b||(b[t]=a),n[5](t,p(a,r),a||_)}},n[6],()=>!f(t)&&t in b?b[t]:!f(t)&&e.get(t)||_]};let R=!0;const[L,N]=k&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[l,l],x={isOnline:()=>R,isVisible:()=>{const e=S&&document.visibilityState;return f(e)||"hidden"!==e}},T={initFocus:e=>(S&&document.addEventListener("visibilitychange",e),L("focus",e),()=>{S&&document.removeEventListener("visibilitychange",e),N("focus",e)}),initReconnect:e=>{const t=()=>{R=!0,e()},n=()=>{R=!1};return L("online",t),L("offline",n),()=>{N("online",t),N("offline",n)}}},V=!r.useId,C=!k||"Deno"in window,D=C?r.useEffect:r.useLayoutEffect,P="undefined"!=typeof navigator&&navigator.connection,M=!C&&P&&(["slow-2g","2g"].includes(P.effectiveType)||P.saveData),A=e=>{if(g(e))try{e=e()}catch(t){e=""}const t=e;return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?h(e):"",t]};let I=0;const j=()=>++I;async function F(...e){const[t,n,r,a]=e,o=p({populateCache:!0,throwOnError:!0},"boolean"==typeof a?{revalidate:a}:a||{});let i=o.populateCache;const c=o.rollbackOnError;let s=o.optimisticData;const u=!1!==o.revalidate,l=o.throwOnError;if(g(n)){const e=n,r=[],a=t.keys();for(const n of a)!/^\$(inf|sub)\$/.test(n)&&e(t.get(n)._k)&&r.push(n);return Promise.all(r.map(m))}return m(n);async function m(n){const[a]=A(n);if(!a)return;const[o,m]=O(t,a),[p,v,w,h]=y.get(t),_=()=>{const e=p[a];return u&&(delete w[a],delete h[a],e&&e[0])?e[0](2).then((()=>o().data)):o().data};if(e.length<3)return _();let b,E=r;const k=j();v[a]=[k,0];const S=!f(s),R=o(),L=R.data,N=R._c,x=f(N)?L:N;if(S&&(s=g(s)?s(x,L):s,m({data:s,_c:x})),g(E))try{E=E(x)}catch(e){b=e}if(E&&g(E.then)){if(E=await E.catch((e=>{b=e})),k!==v[a][0]){if(b)throw b;return E}b&&S&&(e=>"function"==typeof c?c(e):!1!==c)(b)&&(i=!0,m({data:x,_c:d}))}if(i&&!b)if(g(i)){const e=i(E,x);m({data:e,error:d,_c:d})}else m({data:E,error:d,_c:d});if(v[a][1]=j(),Promise.resolve(_()).then((()=>{m({_c:d})})),!b)return E;if(l)throw b}}const W=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},$=(e,t)=>{if(!y.has(e)){const n=p(T,t),r={},a=F.bind(d,e);let o=l;const i={},c=(e,t)=>{const n=i[e]||[];return i[e]=n,n.push(t),()=>n.splice(n.indexOf(t),1)},s=(t,n,r)=>{e.set(t,n);const a=i[t];if(a)for(const e of a)e(n,r)},u=()=>{if(!y.has(e)&&(y.set(e,[r,{},{},{},a,s,c]),!C)){const t=n.initFocus(setTimeout.bind(d,W.bind(d,r,0))),a=n.initReconnect(setTimeout.bind(d,W.bind(d,r,1)));o=()=>{t&&t(),a&&a(),y.delete(e)}}};return u(),[e,a,u,o]}return[e,y.get(e)[4]]},[q,J]=$(new Map),z=p({onLoadingSlow:l,onSuccess:l,onError:l,onErrorRetry:(e,__,t,n,r)=>{const a=t.errorRetryCount,o=r.retryCount,i=~~((Math.random()+.5)*(1<<(o<8?o:8)))*t.errorRetryInterval;!f(a)&&o>a||setTimeout(n,i,r)},onDiscarded:l,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:M?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:M?5e3:3e3,compare:(e,t)=>h(e)==h(t),isPaused:()=>!1,cache:q,mutate:J,fallback:{}},x),H=(e,t)=>{const n=p(e,t);if(t){const{use:r,fallback:a}=e,{use:o,fallback:i}=t;r&&o&&(n.use=r.concat(o)),a&&i&&(n.fallback=p(a,i))}return n},U=(0,r.createContext)({}),B=k&&window.__SWR_DEVTOOLS_USE__,Q=B?window.__SWR_DEVTOOLS_USE__:[],G=Q.concat((e=>(t,n,r)=>e(t,n&&((...e)=>{const[r]=A(t),[,,,a]=y.get(q);if(r.startsWith("$inf$"))return n(...e);const o=a[r];return f(o)?n(...e):(delete a[r],o)}),r)));B&&(window.__SWR_DEVTOOLS_REACT__=r);const K=r.use||(e=>{if("pending"===e.status)throw e;if("fulfilled"===e.status)return e.value;throw"rejected"===e.status?e.reason:(e.status="pending",e.then((t=>{e.status="fulfilled",e.value=t}),(t=>{e.status="rejected",e.reason=t})),e)}),X={dedupe:!0},Y=(m.defineProperty((e=>{const{value:t}=e,n=(0,r.useContext)(U),a=g(t),o=(0,r.useMemo)((()=>a?t(n):t),[a,n,t]),i=(0,r.useMemo)((()=>a?o:H(n,o)),[a,n,o]),c=o&&o.provider,s=(0,r.useRef)(d);c&&!s.current&&(s.current=$(c(i.cache||q),o));const u=s.current;return u&&(i.cache=u[0],i.mutate=u[1]),D((()=>{if(u)return u[2]&&u[2](),u[3]}),[]),(0,r.createElement)(U.Provider,p(e,{value:i}))}),"defaultValue",{value:z}),Z=(e,t,n)=>{const{cache:a,compare:o,suspense:i,fallbackData:c,revalidateOnMount:s,revalidateIfStale:l,refreshInterval:m,refreshWhenHidden:v,refreshWhenOffline:w,keepPreviousData:h}=n,[_,b,S,R]=y.get(a),[L,N]=A(e),x=(0,r.useRef)(!1),T=(0,r.useRef)(!1),P=(0,r.useRef)(L),M=(0,r.useRef)(t),I=(0,r.useRef)(n),W=()=>I.current,$=()=>W().isVisible()&&W().isOnline(),[q,J,z,H]=O(a,L),U=(0,r.useRef)({}).current,B=f(c)?n.fallback[L]:c,Q=(e,t)=>{for(const n in U){const r=n;if("data"===r){if(!o(e[r],t[r])){if(!f(e[r]))return!1;if(!o(oe,t[r]))return!1}}else if(t[r]!==e[r])return!1}return!0},G=(0,r.useMemo)((()=>{const e=!!L&&!!t&&(f(s)?!W().isPaused()&&!i&&(!!f(l)||l):s),n=t=>{const n=p(t);return delete n._k,e?{isValidating:!0,isLoading:!0,...n}:n},r=q(),a=H(),o=n(r),c=r===a?o:n(a);let u=o;return[()=>{const e=n(q());return Q(e,u)?(u.data=e.data,u.isLoading=e.isLoading,u.isValidating=e.isValidating,u.error=e.error,u):(u=e,e)},()=>c]}),[a,L]),Y=(0,u.useSyncExternalStore)((0,r.useCallback)((e=>z(L,((t,n)=>{Q(n,t)||e()}))),[a,L]),G[0],G[1]),Z=!x.current,ee=_[L]&&_[L].length>0,te=Y.data,ne=f(te)?B:te,re=Y.error,ae=(0,r.useRef)(ne),oe=h?f(te)?ae.current:te:ne,ie=!(ee&&!f(re))&&(Z&&!f(s)?s:!W().isPaused()&&(i?!f(ne)&&l:f(ne)||l)),ce=!!(L&&t&&Z&&ie),se=f(Y.isValidating)?ce:Y.isValidating,ue=f(Y.isLoading)?ce:Y.isLoading,le=(0,r.useCallback)((async e=>{const t=M.current;if(!L||!t||T.current||W().isPaused())return!1;let r,a,i=!0;const c=e||{},s=!S[L]||!c.dedupe,u=()=>V?!T.current&&L===P.current&&x.current:L===P.current,l={isValidating:!1,isLoading:!1},m=()=>{J(l)},p=()=>{const e=S[L];e&&e[1]===a&&delete S[L]},v={isValidating:!0};f(q().data)&&(v.isLoading=!0);try{if(s&&(J(v),n.loadingTimeout&&f(q().data)&&setTimeout((()=>{i&&u()&&W().onLoadingSlow(L,n)}),n.loadingTimeout),S[L]=[t(N),j()]),[r,a]=S[L],r=await r,s&&setTimeout(p,n.dedupingInterval),!S[L]||S[L][1]!==a)return s&&u()&&W().onDiscarded(L),!1;l.error=d;const e=b[L];if(!f(e)&&(a<=e[0]||a<=e[1]||0===e[1]))return m(),s&&u()&&W().onDiscarded(L),!1;const c=q().data;l.data=o(c,r)?c:r,s&&u()&&W().onSuccess(r,L,n)}catch(e){p();const t=W(),{shouldRetryOnError:n}=t;t.isPaused()||(l.error=e,s&&u()&&(t.onError(e,L,t),(!0===n||g(n)&&n(e))&&$()&&t.onErrorRetry(e,L,t,(e=>{const t=_[L];t&&t[0]&&t[0](3,e)}),{retryCount:(c.retryCount||0)+1,dedupe:!0})))}return i=!1,m(),!0}),[L,a]),de=(0,r.useCallback)(((...e)=>F(a,P.current,...e)),[]);if(D((()=>{M.current=t,I.current=n,f(te)||(ae.current=te)})),D((()=>{if(!L)return;const e=le.bind(d,X);let t=0;const n=((e,t,n)=>{const r=t[e]||(t[e]=[]);return r.push(n),()=>{const e=r.indexOf(n);e>=0&&(r[e]=r[r.length-1],r.pop())}})(L,_,((n,r={})=>{if(0==n){const n=Date.now();W().revalidateOnFocus&&n>t&&$()&&(t=n+W().focusThrottleInterval,e())}else if(1==n)W().revalidateOnReconnect&&$()&&e();else{if(2==n)return le();if(3==n)return le(r)}}));return T.current=!1,P.current=L,x.current=!0,J({_k:N}),ie&&(f(ne)||C?e():(r=e,k&&typeof window.requestAnimationFrame!=E?window.requestAnimationFrame(r):setTimeout(r,1))),()=>{T.current=!0,n()};var r}),[L]),D((()=>{let e;function t(){const t=g(m)?m(q().data):m;t&&-1!==e&&(e=setTimeout(n,t))}function n(){q().error||!v&&!W().isVisible()||!w&&!W().isOnline()?t():le(X).then(t)}return t(),()=>{e&&(clearTimeout(e),e=-1)}}),[m,v,w,L]),(0,r.useDebugValue)(oe),i&&f(ne)&&L){if(!V&&C)throw new Error("Fallback data is required when using suspense in SSR.");M.current=t,I.current=n,T.current=!1;const e=R[L];if(!f(e)){const t=de(e);K(t)}if(!f(re))throw re;{const e=le(X);f(oe)||(e.status="fulfilled",e.value=!0),K(e)}}return{mutate:de,get data(){return U.data=!0,oe},get error(){return U.error=!0,re},get isValidating(){return U.isValidating=!0,se},get isLoading(){return U.isLoading=!0,ue}}},function(...e){const t=p(z,(0,r.useContext)(U)),[n,a,o]=(e=>g(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}])(e),i=H(t,o);let c=Z;const{use:s}=i,u=(s||[]).concat(G);for(let e=u.length;e--;)c=u[e](c);return c(n,a||i.fetcher||null,i)});var Z;function ee({attributes:e,data:t}){const[n,a]=(0,r.useState)(!1),{comment:o,date:i,donorName:c,avatar:u}=t,{commentLength:l,showAvatar:d,showDate:m,showName:f,readMoreText:g=(0,s.__)("Read More","give")}=e,p=o.slice(0,l)+(o.length>l?"...":"");return(0,r.createElement)("div",{className:"givewp-campaign-comment-block-card"},d&&(0,r.createElement)("div",{className:"givewp-campaign-comment-block-card__avatar"},(0,r.createElement)("img",{src:u,alt:(0,s.__)("Donor avatar")})),(0,r.createElement)("div",{className:"givewp-campaign-comment-block__content"},f&&(0,r.createElement)("p",{className:"givewp-campaign-comment-block-card__donor-name"},c),m&&(0,r.createElement)("p",{className:"givewp-campaign-comment-block-card__details"},i),(0,r.createElement)("p",{className:"givewp-campaign-comment-block-card__comment"},n?o:p),o?.length>l&&!n&&(0,r.createElement)("button",{className:"givewp-campaign-comment-block-card__read-more",onClick:()=>a(!n)},g)))}function te({secondaryColor:e}){return(0,r.createElement)("div",{className:"givewp-campaign-comments-block-empty-state"},(0,r.createElement)("div",{className:"givewp-campaign-donations-block-empty-state__icon"},(0,r.createElement)("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,r.createElement)("path",{d:"M10 33.48h4.351c.567 0 1.131.068 1.681.203l4.597 1.117a7.126 7.126 0 0 0 3.044.07l5.083-.988a7.007 7.007 0 0 0 3.545-1.846l3.596-3.498a2.505 2.505 0 0 0 0-3.615c-.924-.9-2.389-1-3.434-.238l-4.191 3.058c-.6.439-1.33.675-2.082.675h-4.047 2.576c1.452 0 2.628-1.144 2.628-2.557v-.511c0-1.173-.82-2.195-1.99-2.479l-3.975-.967a8.374 8.374 0 0 0-1.976-.236c-1.608 0-4.519 1.332-4.519 1.332l-4.886 2.043m-6.667-.708V34c0 .934 0 1.4.182 1.757.16.314.414.569.728.728.357.182.823.182 1.757.182h1.333c.933 0 1.4 0 1.757-.181.313-.16.568-.415.728-.729.182-.356.182-.823.182-1.757v-9.666c0-.934 0-1.4-.182-1.757a1.667 1.667 0 0 0-.728-.728c-.357-.182-.824-.182-1.757-.182H6.001c-.934 0-1.4 0-1.757.182-.314.16-.569.415-.728.728-.182.357-.182.823-.182 1.757zM28.653 5.989c-.995-2.082-3.288-3.185-5.518-2.12-2.23 1.064-3.18 3.588-2.247 5.804.577 1.37 2.23 4.028 3.41 5.86.435.677.653 1.015.971 1.213.273.17.614.262.936.251.374-.012.732-.197 1.448-.565 1.936-.997 4.698-2.473 5.882-3.37 1.917-1.452 2.392-4.121.957-6.15s-3.937-2.229-5.84-.923z",stroke:e,"stroke-width":"3.333","stroke-linecap":"round","stroke-linejoin":"round"}))),(0,r.createElement)("div",{className:"givewp-campaign-comments-block-empty-state__details"},(0,r.createElement)("strong",{className:"givewp-campaign-comments-block-empty-state__title"},(0,s.__)("Leave a supportive message by","give")),(0,r.createElement)("p",{className:"givewp-campaign-comments-block-empty-state__description"},(0,s.__)("donating to the campaign.","give"))))}function ne({attributes:e,secondaryColor:t}){const{title:n=(0,s.__)("Share your support","give")}=e,{data:a,isLoading:o}=Y((0,c.addQueryArgs)(`/givewp/v3/campaigns/${e?.campaignId}/comments`,{id:e?.campaignId,perPage:e?.commentsPerPage,anonymous:e?.showAnonymous}),(e=>i()({path:e})));return o?null:a&&0===a?.length?(0,r.createElement)(te,{secondaryColor:t}):(0,r.createElement)("div",{className:"givewp-campaign-comment-block"},(0,r.createElement)("h4",{className:"givewp-campaign-comment-block__title"},n),(0,r.createElement)("p",{className:"givewp-campaign-comment-block__cta"},(0,s.__)("Leave a supportive message by donating to the campaign.","give")),a?.map(((t,n)=>(0,r.createElement)(ee,{key:`givewp-campaign-comment-${n}`,attributes:e,data:t}))))}const re=document.querySelectorAll("[data-givewp-campaign-comments]");re&&re.forEach((e=>{const t=e.getAttribute("data-attributes"),n=e.getAttribute("data-secondary-color");return(0,a.createRoot)(e).render((0,r.createElement)(ne,{attributes:JSON.parse(t),secondaryColor:n}))}))})();