@apolitical/component-library 4.1.12-beta.0 → 4.1.12-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/index.mjs +2 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -156,4 +156,4 @@ Valid keys: `+JSON.stringify(Object.keys(D),null," "));var H=he(V,ie,S,q,I+"."+
|
|
|
156
156
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
157
157
|
*/function Xl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function ec(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Xl(Object(n),!0).forEach(function(r){gx(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xl(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function gx(e,t,n){return t=bx(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vx(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function bx(e){var t=vx(e,"string");return typeof t=="symbol"?t:String(t)}var tc={activateTrap:function(t,n){if(t.length>0){var r=t[t.length-1];r!==n&&r.pause()}var a=t.indexOf(n);a===-1||t.splice(a,1),t.push(n)},deactivateTrap:function(t,n){var r=t.indexOf(n);r!==-1&&t.splice(r,1),t.length>0&&t[t.length-1].unpause()}},yx=function(t){return t.tagName&&t.tagName.toLowerCase()==="input"&&typeof t.select=="function"},Dx=function(t){return(t==null?void 0:t.key)==="Escape"||(t==null?void 0:t.key)==="Esc"||(t==null?void 0:t.keyCode)===27},Cr=function(t){return(t==null?void 0:t.key)==="Tab"||(t==null?void 0:t.keyCode)===9},Cx=function(t){return Cr(t)&&!t.shiftKey},xx=function(t){return Cr(t)&&t.shiftKey},nc=function(t){return setTimeout(t,0)},rc=function(t,n){var r=-1;return t.every(function(a,i){return n(a)?(r=i,!1):!0}),r},lr=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return typeof t=="function"?t.apply(void 0,r):t},Jr=function(t){return t.target.shadowRoot&&typeof t.composedPath=="function"?t.composedPath()[0]:t.target},wx=[],Ex=function(t,n){var r=(n==null?void 0:n.document)||document,a=(n==null?void 0:n.trapStack)||wx,i=ec({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:Cx,isKeyBackward:xx},n),s={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},o,l=function(C,B,F){return C&&C[B]!==void 0?C[B]:i[F||B]},u=function(C,B){var F=typeof(B==null?void 0:B.composedPath)=="function"?B.composedPath():void 0;return s.containerGroups.findIndex(function(N){var L=N.container,W=N.tabbableNodes;return L.contains(C)||(F==null?void 0:F.includes(L))||W.find(function(ae){return ae===C})})},c=function(C){var B=i[C];if(typeof B=="function"){for(var F=arguments.length,N=new Array(F>1?F-1:0),L=1;L<F;L++)N[L-1]=arguments[L];B=B.apply(void 0,N)}if(B===!0&&(B=void 0),!B){if(B===void 0||B===!1)return B;throw new Error("`".concat(C,"` was specified but was not a node, or did not return a node"))}var W=B;if(typeof B=="string"&&(W=r.querySelector(B),!W))throw new Error("`".concat(C,"` as selector refers to no known node"));return W},m=function(){var C=c("initialFocus");if(C===!1)return!1;if(C===void 0||!pa(C,i.tabbableOptions))if(u(r.activeElement)>=0)C=r.activeElement;else{var B=s.tabbableGroups[0],F=B&&B.firstTabbableNode;C=F||c("fallbackFocus")}if(!C)throw new Error("Your focus-trap needs to have at least one focusable element");return C},f=function(){if(s.containerGroups=s.containers.map(function(C){var B=Sf(C,i.tabbableOptions),F=jf(C,i.tabbableOptions),N=B.length>0?B[0]:void 0,L=B.length>0?B[B.length-1]:void 0,W=F.find(function(D){return dn(D)}),ae=F.slice().reverse().find(function(D){return dn(D)}),ne=!!B.find(function(D){return Jt(D)>0});return{container:C,tabbableNodes:B,focusableNodes:F,posTabIndexesFound:ne,firstTabbableNode:N,lastTabbableNode:L,firstDomTabbableNode:W,lastDomTabbableNode:ae,nextTabbableNode:function(U){var X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,_=B.indexOf(U);return _<0?X?F.slice(F.indexOf(U)+1).find(function(S){return dn(S)}):F.slice(0,F.indexOf(U)).reverse().find(function(S){return dn(S)}):B[_+(X?1:-1)]}}}),s.tabbableGroups=s.containerGroups.filter(function(C){return C.tabbableNodes.length>0}),s.tabbableGroups.length<=0&&!c("fallbackFocus"))throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");if(s.containerGroups.find(function(C){return C.posTabIndexesFound})&&s.containerGroups.length>1)throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.")},p=function M(C){var B=C.activeElement;if(B)return B.shadowRoot&&B.shadowRoot.activeElement!==null?M(B.shadowRoot):B},g=function M(C){if(C!==!1&&C!==p(document)){if(!C||!C.focus){M(m());return}C.focus({preventScroll:!!i.preventScroll}),s.mostRecentlyFocusedNode=C,yx(C)&&C.select()}},h=function(C){var B=c("setReturnFocus",C);return B||(B===!1?!1:C)},y=function(C){var B=C.target,F=C.event,N=C.isBackward,L=N===void 0?!1:N;B=B||Jr(F),f();var W=null;if(s.tabbableGroups.length>0){var ae=u(B,F),ne=ae>=0?s.containerGroups[ae]:void 0;if(ae<0)L?W=s.tabbableGroups[s.tabbableGroups.length-1].lastTabbableNode:W=s.tabbableGroups[0].firstTabbableNode;else if(L){var D=rc(s.tabbableGroups,function(I){var V=I.firstTabbableNode;return B===V});if(D<0&&(ne.container===B||pa(B,i.tabbableOptions)&&!dn(B,i.tabbableOptions)&&!ne.nextTabbableNode(B,!1))&&(D=ae),D>=0){var U=D===0?s.tabbableGroups.length-1:D-1,X=s.tabbableGroups[U];W=Jt(B)>=0?X.lastTabbableNode:X.lastDomTabbableNode}else Cr(F)||(W=ne.nextTabbableNode(B,!1))}else{var _=rc(s.tabbableGroups,function(I){var V=I.lastTabbableNode;return B===V});if(_<0&&(ne.container===B||pa(B,i.tabbableOptions)&&!dn(B,i.tabbableOptions)&&!ne.nextTabbableNode(B))&&(_=ae),_>=0){var S=_===s.tabbableGroups.length-1?0:_+1,q=s.tabbableGroups[S];W=Jt(B)>=0?q.firstTabbableNode:q.firstDomTabbableNode}else Cr(F)||(W=ne.nextTabbableNode(B))}}else W=c("fallbackFocus");return W},b=function(C){var B=Jr(C);if(!(u(B,C)>=0)){if(lr(i.clickOutsideDeactivates,C)){o.deactivate({returnFocus:i.returnFocusOnDeactivate});return}lr(i.allowOutsideClick,C)||C.preventDefault()}},w=function(C){var B=Jr(C),F=u(B,C)>=0;if(F||B instanceof Document)F&&(s.mostRecentlyFocusedNode=B);else{C.stopImmediatePropagation();var N,L=!0;if(s.mostRecentlyFocusedNode)if(Jt(s.mostRecentlyFocusedNode)>0){var W=u(s.mostRecentlyFocusedNode),ae=s.containerGroups[W].tabbableNodes;if(ae.length>0){var ne=ae.findIndex(function(D){return D===s.mostRecentlyFocusedNode});ne>=0&&(i.isKeyForward(s.recentNavEvent)?ne+1<ae.length&&(N=ae[ne+1],L=!1):ne-1>=0&&(N=ae[ne-1],L=!1))}}else s.containerGroups.some(function(D){return D.tabbableNodes.some(function(U){return Jt(U)>0})})||(L=!1);else L=!1;L&&(N=y({target:s.mostRecentlyFocusedNode,isBackward:i.isKeyBackward(s.recentNavEvent)})),g(N||s.mostRecentlyFocusedNode||m())}s.recentNavEvent=void 0},A=function(C){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;s.recentNavEvent=C;var F=y({event:C,isBackward:B});F&&(Cr(C)&&C.preventDefault(),g(F))},k=function(C){if(Dx(C)&&lr(i.escapeDeactivates,C)!==!1){C.preventDefault(),o.deactivate();return}(i.isKeyForward(C)||i.isKeyBackward(C))&&A(C,i.isKeyBackward(C))},E=function(C){var B=Jr(C);u(B,C)>=0||lr(i.clickOutsideDeactivates,C)||lr(i.allowOutsideClick,C)||(C.preventDefault(),C.stopImmediatePropagation())},T=function(){if(s.active)return tc.activateTrap(a,o),s.delayInitialFocusTimer=i.delayInitialFocus?nc(function(){g(m())}):g(m()),r.addEventListener("focusin",w,!0),r.addEventListener("mousedown",b,{capture:!0,passive:!1}),r.addEventListener("touchstart",b,{capture:!0,passive:!1}),r.addEventListener("click",E,{capture:!0,passive:!1}),r.addEventListener("keydown",k,{capture:!0,passive:!1}),o},j=function(){if(s.active)return r.removeEventListener("focusin",w,!0),r.removeEventListener("mousedown",b,!0),r.removeEventListener("touchstart",b,!0),r.removeEventListener("click",E,!0),r.removeEventListener("keydown",k,!0),o},z=function(C){var B=C.some(function(F){var N=Array.from(F.removedNodes);return N.some(function(L){return L===s.mostRecentlyFocusedNode})});B&&g(m())},R=typeof window<"u"&&"MutationObserver"in window?new MutationObserver(z):void 0,$=function(){R&&(R.disconnect(),s.active&&!s.paused&&s.containers.map(function(C){R.observe(C,{subtree:!0,childList:!0})}))};return o={get active(){return s.active},get paused(){return s.paused},activate:function(C){if(s.active)return this;var B=l(C,"onActivate"),F=l(C,"onPostActivate"),N=l(C,"checkCanFocusTrap");N||f(),s.active=!0,s.paused=!1,s.nodeFocusedBeforeActivation=r.activeElement,B==null||B();var L=function(){N&&f(),T(),$(),F==null||F()};return N?(N(s.containers.concat()).then(L,L),this):(L(),this)},deactivate:function(C){if(!s.active)return this;var B=ec({onDeactivate:i.onDeactivate,onPostDeactivate:i.onPostDeactivate,checkCanReturnFocus:i.checkCanReturnFocus},C);clearTimeout(s.delayInitialFocusTimer),s.delayInitialFocusTimer=void 0,j(),s.active=!1,s.paused=!1,$(),tc.deactivateTrap(a,o);var F=l(B,"onDeactivate"),N=l(B,"onPostDeactivate"),L=l(B,"checkCanReturnFocus"),W=l(B,"returnFocus","returnFocusOnDeactivate");F==null||F();var ae=function(){nc(function(){W&&g(h(s.nodeFocusedBeforeActivation)),N==null||N()})};return W&&L?(L(h(s.nodeFocusedBeforeActivation)).then(ae,ae),this):(ae(),this)},pause:function(C){if(s.paused||!s.active)return this;var B=l(C,"onPause"),F=l(C,"onPostPause");return s.paused=!0,B==null||B(),j(),$(),F==null||F(),this},unpause:function(C){if(!s.paused||!s.active)return this;var B=l(C,"onUnpause"),F=l(C,"onPostUnpause");return s.paused=!1,B==null||B(),f(),T(),$(),F==null||F(),this},updateContainerElements:function(C){var B=[].concat(C).filter(Boolean);return s.containers=B.map(function(F){return typeof F=="string"?r.querySelector(F):F}),s.active&&f(),$(),this}},o.updateContainerElements(t),o};const kx=Object.freeze(Object.defineProperty({__proto__:null,createFocusTrap:Ex},Symbol.toStringTag,{value:"Module"})),_x=bc(kx),Bx=bc(px);function Yn(e){"@babel/helpers - typeof";return Yn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yn(e)}function Ax(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ac(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,Of(r.key),r)}}function Fx(e,t,n){return t&&ac(e.prototype,t),n&&ac(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Tx(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ts(e,t)}function Ts(e,t){return Ts=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,a){return r.__proto__=a,r},Ts(e,t)}function Sx(e){var t=Ox();return function(){var r=Sa(e),a;if(t){var i=Sa(this).constructor;a=Reflect.construct(r,arguments,i)}else a=r.apply(this,arguments);return jx(this,a)}}function jx(e,t){if(t&&(Yn(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return mr(e)}function mr(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ox(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Sa(e){return Sa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Sa(e)}function Px(e,t,n){return t=Of(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Of(e){var t=Nx(e,"string");return Yn(t)==="symbol"?t:String(t)}function Nx(e,t){if(Yn(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Yn(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Xr=x,ge=XC,Rx=_x,Mx=Rx.createFocusTrap,Ix=Bx,$x=Ix.isFocusable,go=function(e){Tx(n,e);var t=Sx(n);function n(r){var a;Ax(this,n),a=t.call(this,r),Px(mr(a),"getNodeForOption",function(o){var l,u=(l=this.internalOptions[o])!==null&&l!==void 0?l:this.originalOptions[o];if(typeof u=="function"){for(var c=arguments.length,m=new Array(c>1?c-1:0),f=1;f<c;f++)m[f-1]=arguments[f];u=u.apply(void 0,m)}if(u===!0&&(u=void 0),!u){if(u===void 0||u===!1)return u;throw new Error("`".concat(o,"` was specified but was not a node, or did not return a node"))}var p=u;if(typeof u=="string"){var g;if(p=(g=this.getDocument())===null||g===void 0?void 0:g.querySelector(u),!p)throw new Error("`".concat(o,"` as selector refers to no known node"))}return p}),a.handleDeactivate=a.handleDeactivate.bind(mr(a)),a.handlePostDeactivate=a.handlePostDeactivate.bind(mr(a)),a.handleClickOutsideDeactivates=a.handleClickOutsideDeactivates.bind(mr(a)),a.internalOptions={returnFocusOnDeactivate:!1,checkCanReturnFocus:null,onDeactivate:a.handleDeactivate,onPostDeactivate:a.handlePostDeactivate,clickOutsideDeactivates:a.handleClickOutsideDeactivates},a.originalOptions={returnFocusOnDeactivate:!0,onDeactivate:null,onPostDeactivate:null,checkCanReturnFocus:null,clickOutsideDeactivates:!1};var i=r.focusTrapOptions;for(var s in i)if(Object.prototype.hasOwnProperty.call(i,s)){if(s==="returnFocusOnDeactivate"||s==="onDeactivate"||s==="onPostDeactivate"||s==="checkCanReturnFocus"||s==="clickOutsideDeactivates"){a.originalOptions[s]=i[s];continue}a.internalOptions[s]=i[s]}return a.outsideClick=null,a.focusTrapElements=r.containerElements||[],a.updatePreviousElement(),a}return Fx(n,[{key:"getDocument",value:function(){return this.props.focusTrapOptions.document||(typeof document<"u"?document:void 0)}},{key:"getReturnFocusNode",value:function(){var a=this.getNodeForOption("setReturnFocus",this.previouslyFocusedElement);return a||(a===!1?!1:this.previouslyFocusedElement)}},{key:"updatePreviousElement",value:function(){var a=this.getDocument();a&&(this.previouslyFocusedElement=a.activeElement)}},{key:"deactivateTrap",value:function(){!this.focusTrap||!this.focusTrap.active||this.focusTrap.deactivate({returnFocus:!1,checkCanReturnFocus:null,onDeactivate:this.originalOptions.onDeactivate})}},{key:"handleClickOutsideDeactivates",value:function(a){var i=typeof this.originalOptions.clickOutsideDeactivates=="function"?this.originalOptions.clickOutsideDeactivates.call(null,a):this.originalOptions.clickOutsideDeactivates;return i&&(this.outsideClick={target:a.target,allowDeactivation:i}),i}},{key:"handleDeactivate",value:function(){this.originalOptions.onDeactivate&&this.originalOptions.onDeactivate.call(null),this.deactivateTrap()}},{key:"handlePostDeactivate",value:function(){var a=this,i=function(){var o=a.getReturnFocusNode(),l=!!(a.originalOptions.returnFocusOnDeactivate&&o!==null&&o!==void 0&&o.focus&&(!a.outsideClick||a.outsideClick.allowDeactivation&&!$x(a.outsideClick.target,a.internalOptions.tabbableOptions))),u=a.internalOptions.preventScroll,c=u===void 0?!1:u;l&&o.focus({preventScroll:c}),a.originalOptions.onPostDeactivate&&a.originalOptions.onPostDeactivate.call(null),a.outsideClick=null};this.originalOptions.checkCanReturnFocus?this.originalOptions.checkCanReturnFocus.call(null,this.getReturnFocusNode()).then(i,i):i()}},{key:"setupFocusTrap",value:function(){if(this.focusTrap)this.props.active&&!this.focusTrap.active&&(this.focusTrap.activate(),this.props.paused&&this.focusTrap.pause());else{var a=this.focusTrapElements.some(Boolean);a&&(this.focusTrap=this.props._createFocusTrap(this.focusTrapElements,this.internalOptions),this.props.active&&this.focusTrap.activate(),this.props.paused&&this.focusTrap.pause())}}},{key:"componentDidMount",value:function(){this.props.active&&this.setupFocusTrap()}},{key:"componentDidUpdate",value:function(a){if(this.focusTrap){a.containerElements!==this.props.containerElements&&this.focusTrap.updateContainerElements(this.props.containerElements);var i=!a.active&&this.props.active,s=a.active&&!this.props.active,o=!a.paused&&this.props.paused,l=a.paused&&!this.props.paused;if(i&&(this.updatePreviousElement(),this.focusTrap.activate()),s){this.deactivateTrap();return}o&&this.focusTrap.pause(),l&&this.focusTrap.unpause()}else a.containerElements!==this.props.containerElements&&(this.focusTrapElements=this.props.containerElements),this.props.active&&(this.updatePreviousElement(),this.setupFocusTrap())}},{key:"componentWillUnmount",value:function(){this.deactivateTrap()}},{key:"render",value:function(){var a=this,i=this.props.children?Xr.Children.only(this.props.children):void 0;if(i){if(i.type&&i.type===Xr.Fragment)throw new Error("A focus-trap cannot use a Fragment as its child container. Try replacing it with a <div> element.");var s=function(u){var c=a.props.containerElements;i&&(typeof i.ref=="function"?i.ref(u):i.ref&&(i.ref.current=u)),a.focusTrapElements=c||[u]},o=Xr.cloneElement(i,{ref:s});return o}return null}}]),n}(Xr.Component),cr=typeof Element>"u"?Function:Element;go.propTypes={active:ge.bool,paused:ge.bool,focusTrapOptions:ge.shape({document:ge.object,onActivate:ge.func,onPostActivate:ge.func,checkCanFocusTrap:ge.func,onPause:ge.func,onPostPause:ge.func,onUnpause:ge.func,onPostUnpause:ge.func,onDeactivate:ge.func,onPostDeactivate:ge.func,checkCanReturnFocus:ge.func,initialFocus:ge.oneOfType([ge.instanceOf(cr),ge.string,ge.bool,ge.func]),fallbackFocus:ge.oneOfType([ge.instanceOf(cr),ge.string,ge.func]),escapeDeactivates:ge.oneOfType([ge.bool,ge.func]),clickOutsideDeactivates:ge.oneOfType([ge.bool,ge.func]),returnFocusOnDeactivate:ge.bool,setReturnFocus:ge.oneOfType([ge.instanceOf(cr),ge.string,ge.bool,ge.func]),allowOutsideClick:ge.oneOfType([ge.bool,ge.func]),preventScroll:ge.bool,tabbableOptions:ge.shape({displayCheck:ge.oneOf(["full","legacy-full","non-zero-area","none"]),getShadowRoot:ge.oneOfType([ge.bool,ge.func])}),trapStack:ge.array,isKeyForward:ge.func,isKeyBackward:ge.func}),containerElements:ge.arrayOf(ge.instanceOf(cr)),children:ge.oneOfType([ge.element,ge.instanceOf(cr)])};go.defaultProps={active:!0,paused:!1,focusTrapOptions:{},_createFocusTrap:Mx};var Lx=go;const zx=wn(Lx),Pf=({showDevTools:e=!0,children:t})=>{const n=new We.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,staleTime:6e4}}});return d.jsxs(We.QueryClientProvider,{client:n,children:[t,e&&d.jsx(vh.ReactQueryDevtools,{initialIsOpen:!1})]})};var qx=x.createContext({client:sa});function Wx(e){var t=e.children,n=e.client,r=e.apiKey,a=e.options,i=x.useMemo(function(){return n&&r&&console.warn("[PostHog.js] You have provided both a client and an apiKey to PostHogProvider. The apiKey will be ignored in favour of the client."),n&&a&&console.warn("[PostHog.js] You have provided both a client and options to PostHogProvider. The options will be ignored in favour of the client."),n||(r&&(sa.__loaded&&console.warn("[PostHog.js] was already loaded elsewhere. This may cause issues."),sa.init(r,a)),sa)},[n,r]);return x.createElement(qx.Provider,{value:{client:i}},t)}const Nf=({children:e,user:t})=>t.isLoading?null:process.env.REACT_APP_PUBLIC_POSTHOG_KEY?d.jsx(Wx,{apiKey:atob(process.env.REACT_APP_PUBLIC_POSTHOG_KEY),options:{api_host:"/ph",autocapture:!1,disable_session_recording:!0,persistence_name:"flags",secure_cookie:!0,ui_host:"eu.posthog.com",bootstrap:{distinctID:t.id||"00000000-0000-0000-0000-000000000000",isIdentifiedID:!!t.id}},children:e}):d.jsx(d.Fragment,{children:e}),Rf=({children:e,locale:t,messages:n})=>{const r=t||"en",a={...Nh[r],...n||{}};return d.jsx(ue.IntlProvider,{locale:r,messages:a,children:e})},vo=x.createContext({}),ga={en:"English",es:"Español",fr:"Français",pt:"Português"},Mt=x.createContext({isLoading:!0});function Ya(){return x.useContext(Mt)}const Mf=({children:e,user:t})=>d.jsx(Mt.Provider,{value:t,children:e}),bo=x.createContext({registerOverlay:()=>{},unregisterOverlay:()=>{}}),If=()=>x.useContext(bo),$f=({children:e})=>{const[t,n]=x.useState([]);x.useEffect(()=>{t.length>0?document.body.classList.add("has-overlay"):document.body.classList.remove("has-overlay")},[t]);const r=x.useCallback(i=>{n(s=>[...s,i])},[]),a=x.useCallback(i=>{n(s=>s.filter(o=>o!==i))},[]);return d.jsx(bo.Provider,{value:{registerOverlay:r,unregisterOverlay:a},children:e})},Hx=({bootstrap:e,children:t,intl:n,showDevTools:r})=>{const[a,i]=x.useState({isLoading:!0}),s=(n==null?void 0:n.locale)||localStorage.getItem("language")||"en",[o,l]=x.useState(s),u=c=>{localStorage.setItem("language",c),l(c)};return x.useEffect(()=>{e().then(c=>{i({...c,isLoading:!1}),jc(5e3)}).catch(c=>{c.message===Fc&&window.location.pathname!=="/user-onboarding/logout"&&(window.location.href="/user-onboarding/logout"),i({isLoading:!1})})},[]),d.jsx(vo.Provider,{value:{language:o,updateLanguage:u},children:d.jsx(Rf,{locale:o,messages:n==null?void 0:n.messages,children:d.jsx(js.CookiesProvider,{children:d.jsx(Mf,{user:a,children:d.jsx($f,{children:d.jsx(Pf,{showDevTools:r,children:d.jsx(Nf,{user:a,children:t})})})})})})})};const yo=({element:e="section",children:t,className:n,...r})=>x.createElement(e,{className:G("modal",n),children:typeof t=="string"?d.jsx("p",{children:t}):t,...r});const Pr=({id:e="content-overlay",isOpen:t=!1,showDivider:n=!0,maxWidth:r,functions:{onOpen:a=()=>{},onClose:i=()=>{}}={},forceShow:{error:s=!1}={},title:o,children:l,buttons:u,className:c="",gtmContext:m="Modal"})=>{const f=ue.useIntl(),{registerOverlay:p,unregisterOverlay:g}=If(),[h,y]=x.useState(t),b=k=>{k.key==="Escape"&&w(!1)};x.useEffect(()=>(window.addEventListener("keyup",b),()=>{window.removeEventListener("keyup",b)}));const w=k=>{y(k),k?(a(),p(e)):(i(),g(e))};x.useEffect(()=>(w(t),()=>{h&&g(e)}),[t]);const A=r?{"--max-width":`${r/16}rem`}:{};return d.jsx("div",{className:G("overlay",{open:h}),role:"dialog",children:d.jsx(yo,{id:e,className:G("overlay-modal",c,{"has-max-width":r}),hidden:!h,style:A,children:t&&d.jsx(zx,{children:d.jsxs("div",{className:"overlay-content",children:[d.jsxs("div",{className:"top",children:[o&&d.jsx("h2",{className:"modal-title",children:o}),d.jsx(Ee,{variant:"tertiary",size:"medium",icon:{icon:"close"},onClick:()=>w(!1),className:"gtm-trackable","data-gtm-event-type":"close-modal-click","data-gtm-event-context":m,screenreaderText:f.formatMessage({id:"overlay_close"})})]}),n&&d.jsx(tn,{}),l,u&&d.jsxs("div",{className:"bottom",children:[d.jsx(tn,{}),d.jsx(En,{buttons:u})]}),s&&d.jsx(wr,{className:"error",children:s})]})})})})},Lf=(e,t)=>({"aria-haspopup":!0,"aria-expanded":t,"aria-controls":e});const Ux=({className:e,showModal:t=!0,title:n,formTitle:r,formLabel:a,ctaMessage:i,showIcon:s,onClose:o,reportError:l=()=>{},sendInvites:u})=>{const c=ue.useIntl();return r||(r=c.formatMessage({id:"inviteModal_formTitle"})),a||(a=c.formatMessage({id:"inviteModal_formLabel"})),i||(i=c.formatMessage({id:"inviteModal_cta"})),d.jsx(Pr,{title:n,isOpen:t,showDivider:!1,showIcon:s,functions:{onClose:o},className:G("invite-modal",e,{success:!!n}),children:d.jsx(Cf,{title:r,label:a,ctaMessage:i,onClose:o,sendInvites:u,reportError:l})})};const Vx=({members:e})=>{const[t,n]=x.useState(!1),r=a=>{const{fullName:i,jobTitle:s,organisation:o,photo:l}=a||{};return d.jsxs(d.Fragment,{children:[d.jsx(sn,{name:i,src:l}),d.jsx("p",{children:i}),d.jsx("small",{className:"text-medium",children:o?`${s}, ${o}`:s})]})};return d.jsxs("div",{className:"directory-wrapper",children:[d.jsx("ul",{className:"directory",children:e.map(a=>d.jsx("li",{children:d.jsx("button",{onClick:i=>{i.preventDefault(),i.stopPropagation(),n(a)},children:r(a)})},a.fullName))}),d.jsx(Pr,{isOpen:t!==!1,children:t===!1?"":d.jsxs(d.Fragment,{children:[r(t),d.jsx(Un,{children:t.text})]}),buttons:[{size:"small",variant:"tertiary",onClick:()=>n(!1),children:"Close"}],functions:{onClose:()=>n(!1)}})]})};const Kx=({author:e,authorCite:t,content:n,member:r,className:a=""})=>d.jsxs("blockquote",{className:G("testimonial-block",a),children:[d.jsx(Pt,{className:"testimonial",children:n}),r?d.jsx(tr,{member:r,styling:{size:"large"}}):d.jsxs(d.Fragment,{children:[e&&d.jsx("p",{className:G("author",{"text-small":!a.includes("new")}),children:e}),t&&d.jsx("p",{className:G("author-cite",{"text-small":!a.includes("new")}),children:d.jsx("cite",{children:t})})]})]}),Zx=x.memo(Kx);const Yx=({items:e=[],selector:t="",className:n=""})=>{const r=ue.useIntl(),[a,i]=x.useState(e);return x.useEffect(()=>{if(e.length)return;let s="";Array(6).fill(0).forEach((u,c)=>{s+=`${c>0?", ":""}${t} h${c+1}`});const l=Array.from(document.querySelectorAll(s)).filter(u=>u.id).map(u=>({id:u.id,text:u.textContent||""}));i(l)},[]),a&&a.length>0&&d.jsxs(Nt,{variant:"subtle",className:G("table-of-contents",n),children:[d.jsx("h2",{children:r.formatMessage({id:"tableOfContents"})}),d.jsx("nav",{children:d.jsx("ul",{children:a.map(({id:s,text:o})=>d.jsx("li",{children:d.jsx("a",{href:`#${s}`,children:o})},s))})})]})};const Ga=({time:e,rangeTime:t,prependedText:n,appendedText:r,className:a=""})=>{const i=ue.useIntl(),s="timeToComplete_";if(!e||typeof e!="number")return null;const o=c=>{const m=c/60,f=Math.floor(m),p=(m-f)*60,g=Math.round(p),h=`${i.formatMessage({id:`${s}hours`},{time:f})}${f>0&&g>0?", ":""}${i.formatMessage({id:`${s}minutes`},{time:g})}`;return{text:`${f>0?`${i.formatMessage({id:`${s}hours_short`},{time:f})} `:""}${g>0?i.formatMessage({id:`${s}minutes_short`},{time:g}):""}`,ariaText:h}};let{text:l,ariaText:u}=o(e);if(t){const{text:c,ariaText:m}=o(e+t);l=i.formatMessage({id:`${s}range`},{early:l,late:c}),u=i.formatMessage({id:`${s}range_aria`},{early:u,late:m})}return n&&(u=`${n} ${u}`,l=`${n} ${l}`),r&&(u=`${u} ${r}`,l=`${l} ${r}`),d.jsx("span",{className:G("time-to-complete",a),"aria-label":u,children:l})};const Gx=({className:e="",image:t,...n})=>t?(typeof t=="string"&&(t={width:1080,height:200,type:"image/png",url:t}),t.range=[{height:124,width:425},{height:200,width:768},{height:200,width:1368}],t.query="fit=thumb&f=center",d.jsx(er,{...n,className:G("banner",e),image:{...t,aspect:"banner"}})):null;const ln=({children:e,className:t="",styling:n={},...r})=>{const{background:a="default"}=n;return d.jsx("section",{className:G("full-width-section",t,{[a]:a!=="default"}),...r,children:e})};const Qx=({text:e,buttons:t,className:n=""})=>{const r=[];return t.forEach(a=>{r.push({href:a.link,variant:"secondary",size:{mobile:"medium",1024:"large"},className:"gtm-trackable","data-gtm-event-type":"download-click","data-gtm-event-context":a.eventContext||"Download",target:"_blank",children:a.text})}),d.jsx(ln,{className:G("download-section",n),children:d.jsxs("div",{className:"content-default",children:[x.createElement(typeof e=="string"?"h2":e.element,{className:"text"},typeof e=="string"?e:e.text),d.jsx(En,{buttons:r})]})})};function zf({href:e,setShowModal:t}){typeof e!="string"&&t(!0)}const Jx=({icon:e,description:t,ctaMessage:n,href:r,showEditButton:a,setShowModal:i})=>{const{formatMessage:s}=ue.useIntl();return d.jsxs("div",{className:G("edit-section-placeholder",{"has-icon":!!e}),style:Tc(e),children:[d.jsx("p",{children:t||s({id:"edit_section_placeholder_description"})}),a&&d.jsx(Ee,{href:r,variant:"secondary",size:"small",onClick:()=>zf({href:r,setShowModal:i}),children:n||s({id:"edit_section_placeholder_cta"})})]})},Xx=({children:e,className:t="",formProps:n,href:r,title:a,modalTitle:i,placeholder:s,showDivider:o=!0})=>{const[l,u]=x.useState(!1),c=typeof r=="string"||!!n,m=()=>u(!1);return d.jsxs("section",{className:G("edit-section",t),children:[n&&d.jsx(Pr,{title:i||`Edit ${a}`,isOpen:l,showDivider:!1,showIcon:!1,functions:{onClose:m},className:G("edit-section-modal"),children:d.jsx(nr,{...n,fields:n.fields,meta:{...n==null?void 0:n.meta,shouldShowCancelButton:!0,shouldReset:!1,showSuccessMessage:!0},functions:{...n==null?void 0:n.functions,onSuccess:async f=>{var p,g;(p=n==null?void 0:n.functions)!=null&&p.onSuccess&&await((g=n==null?void 0:n.functions)==null?void 0:g.onSuccess(f)),u(!1)},onCancel:m}})}),d.jsxs("div",{className:"edit-section-header",children:[d.jsx("h2",{className:"edit-section-header-title",children:a}),c&&d.jsx(Ee,{href:r,variant:"tertiary",size:"small",icon:"pencil",onClick:()=>zf({href:r,setShowModal:u}),children:"Edit"})]}),e||d.jsx(Jx,{...s,href:r,setShowModal:u,showEditButton:c}),o&&d.jsx(tn,{})]})};const ew=({title:e=!1,text:t,logos:n=[],styling:r={},className:a=""})=>{const i=n.length;if(i===0)return null;const s={element:typeof e=="object"?e.element:"h2",text:typeof e=="string"?e:typeof e=="object"?e.text:"",className:typeof e=="object"?e.className:""},{wrapLogos:o=!1,align:l="center",display:u="block"}=r;return d.jsxs("div",{className:G("logos",a,`align-${l}`,{[u]:u!=="block","wrap-logos":o}),children:[e&&x.createElement(s.element,{className:G("title",s.className)},s.text),t&&d.jsx("p",{children:t}),d.jsx("ul",{className:G({"two-col":i===2||i===4,"three-col":i===5||i<=10&&i%3===0}),children:n.map(({logo:c,nameOfBusiness:m,link:f=!1,description:p=!1},g)=>{if(!c||!c.url)return null;const h=d.jsx("img",{src:c.url,width:c.width||"auto",height:c.height||"auto",alt:m});return d.jsxs("li",{children:[d.jsx("p",{className:"img-wrapper",children:f?d.jsx("a",{href:f,target:"_blank",rel:"nofollow noreferrer noopener",children:h}):h}),p&&d.jsx("small",{children:p})]},window.btoa(`${c.url}_${g}`))})})]})};const tw=["small","span","strong","em","p","h1","h2","h3","h4","h5","h6","blockquote","q"],nw=({className:e="",content:t,image:n,variant:r,spacing:a="normal",styling:i,hideElements:s={eyebrow:!1,title:!1,text:!1},cta:o,children:l})=>{var g,h;const u={imageFullWidth:!0,...i};r||(r=u.imageFullWidth?"default":"light");const c=["eyebrow","title","text"],m={eyebrow:"small",title:"h1",text:"p"},f={};c.forEach(y=>{if(!t[y]){f[y]=!1;return}if(!s[y]){if(typeof t[y]=="object"){f[y]=t[y];const{text:b,element:w}=t[y];if(w&&tw.includes(w.toLowerCase()))return;f[y]={text:b,element:m[y]};return}f[y]={text:t[y],element:m[y]}}});const p=o&&o.text&&o.link;return p&&o.link[0]==="#"&&(o.props||(o.props={}),o.props.onClick=y=>{y.preventDefault(),y.stopPropagation();const b=document.getElementById(o.link.substring(1));b&&b.scrollIntoView({behavior:"smooth"})}),d.jsx(ln,{className:G("banner-section",r,a,e,{"has-image":n,"image-full-width":n&&u.imageFullWidth,"image-inline":n&&!u.imageFullWidth,"has-cta":p,"has-extra-spacing":r!=="subtle"&&a==="normal"&&f.eyebrow&&f.title}),children:d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"content-wrapper",children:[c.map(y=>{if(f[y]&&typeof f[y]=="object"){const{text:b,element:w=""}=f[y];return y==="text"?d.jsx(Un,{overrideType:"text-only",className:"text",children:b},y):x.createElement(w,{key:y,className:y},b)}return null}),l,p&&d.jsx(Ee,{variant:n||["light","subtle"].includes(r)?"primary":"secondary",size:{mobile:"medium",768:"large"},href:o.link,...o.props,className:G({new:r==="subtle",[(g=o.props)==null?void 0:g.className]:(h=o.props)==null?void 0:h.className}),children:o.text})]}),n&&d.jsx(er,{image:{...n,aspect:u.imageFullWidth?"banner":n.aspect||void 0}})]})})},rw=x.memo(nw);const aw=({image:e,variant:t="default",children:n,className:r=""})=>{const a={};return e&&(a["--image"]=`url(${e})`),d.jsx(ln,{className:G("custom-content-banner",t,r,{"has-image":e}),style:a,children:d.jsx("div",{className:"content-slim",children:n})})};const iw=({alignImage:e="left",className:t,content:n,image:r})=>{const a=typeof n=="string"?d.jsx(Un,{children:n}):n;return d.jsxs(ln,{className:G("highlight-section",t),children:[r&&d.jsx("div",{className:G("highlight-container highlight-image",{[`highlight-image-${e}`]:e==="right"}),children:d.jsx(er,{image:r})}),d.jsx("div",{className:G("highlight-container highlight-content-wrapper",{"no-image":!r}),children:d.jsx("div",{className:G("highlight-content",{"highlight-content-right":e==="left"}),children:r?a:d.jsx("div",{className:"content-default",children:a})})})]})},sw=x.memo(iw);const ow=({variant:e="primary",button:t=null,title:n,text:r,gtmContext:a})=>!n&&!r?null:d.jsxs("aside",{className:G("marketing-block",e),children:[n&&d.jsx("p",{className:"title",children:n}),r&&d.jsx("p",{children:r}),t&&d.jsx(Ee,{variant:"secondary",size:"medium",href:t.link,className:"gtm-trackable","data-gtm-event-context":a,"data-gtm-event-type":"learn-more-click",children:t.text})]}),uw=({type:e,data:t})=>{const n=ue.useIntl(),{answers:r,createdAt:a,dateHasPassed:i,isOngoingEvent:s,pill:o,readingTime:l,publishedDate:u,startDate:c}=t;if(e==="question"){const m=a&&ts(a);return d.jsxs("p",{className:"details answers","data-testid":"question-answers",children:[n.formatMessage({id:"card_answers"},{number:r}),a&&d.jsxs("span",{"data-testid":"question-created-at",children:[" ","·"," ",n.formatMessage({id:"card_time_ago"},{time:m?n.formatMessage({id:`dates_${m.path}`},{number:m.number}):0})]})]})}if(c&&!i||s)return d.jsx("p",{className:"details",children:s?n.formatMessage({id:"card_bootcamp"}):Rs(c)});if(o)return d.jsx(hn,{variant:o==="free"?"subtle":"highlighted",className:o,"data-testid":"course-type",children:o});if(l||u){const m=u&&ts(u);return d.jsxs("ul",{className:"details",children:[l&&d.jsx("li",{"data-testid":"reading-time",children:n.formatMessage({id:"card_time_read"},{time:l})}),u&&d.jsx("li",{"data-testid":"published-date",children:n.formatMessage({id:"card_time_ago"},{time:m?n.formatMessage({id:`dates_${m.path}`},{number:m.number}):0})})]})}return null},ja={communityPage:{basePath:"/communities/",className:"communityPage",gtmEvent:"community"},customCard:{className:"custom",gtmEvent:"custom",length:{text:335,secondaryText:150}},event:{basePath:"/events/",className:"event",gtmEvent:"event"},microcourse:{basePath:"/microcourses/en/",className:"course",gtmEvent:"microcourse-overview"},solutionArticle:{basePath:"/solution-articles/en/",className:"article",length:{title:60},gtmEvent:"article"},qaQuestion:{basePath:"/questions-answers/",className:"question",length:{title:190},gtmEvent:"q-and-a-question"},listPage:{basePath:"/list/en/",className:"list",gtmEvent:"list"},people:{basePath:"/profiles/",className:"people",length:{people:1e3},gtmEvent:"person"},learningHub:{basePath:"/learning-hub/",className:"learning-hub",length:{title:190},gtmEvent:"learning-hub"}},lw=({data:e,cta:t,link:n,gtmContext:r})=>{var h,y;const a=ue.useIntl(),[i,s]=x.useState({loading:!1,registered:e.registered||!1});x.useEffect(()=>{e.registered&&s(b=>({...b,registered:!0}))},[e.registered]);const{customLinkText:o,startDate:l,dateHasPassed:u,pill:c,slug:m}=e,f=e.contentType;let p="";if((h=ja[f])!=null&&h.gtmEvent&&(p=ja[f].gtmEvent),l&&u)return n?d.jsx("a",{href:n,className:"details additional-link gtm-trackable","data-gtm-event-context":`${r}-CarouselCard`,"data-gtm-event-type":`${p}-click`,children:o||a.formatMessage({id:"card_watch"})}):null;if(f==="people")return n?d.jsx(Ee,{variant:"tertiary",size:"small",href:n,className:"gtm-trackable","data-gtm-event-context":`${r}-Card-Button`,"data-gtm-event-type":`${p}-click`,children:o||a.formatMessage({id:"card_cta_people"})}):null;const g=["communityPage","microcourse","event"];if(t&&t.onClick&&g.includes(f)&&c!=="premium"){const b=i.loading||i.registered||((y=e==null?void 0:e.members)==null?void 0:y.isMember),w=async A=>{if(A.preventDefault(),A.stopPropagation(),!(b||!t||!t.onClick)){s(k=>({...k,loading:!0}));try{const k=await t.onClick(e);s(k==="success"?()=>({registered:!0,loading:!1}):E=>({...E,loading:!1}))}catch{s(E=>({...E,loading:!1}))}}};return d.jsx("p",{className:G("cta-wrapper",{"has-member-section":e==null?void 0:e.members}),children:d.jsx(Ee,{onClick:w,className:"gtm-trackable",size:"small",styling:{fullWidth:!0},disabled:b,"data-gtm-event-context":`${r}Page-${f}: ${m}`,"data-gtm-event-type":`${r}-${f}-register-click`,"data-testid":"in-card-button",children:o||a.formatMessage({id:`card_cta_${f}${b?`_${i.loading?"loading":"done"}`:""}`})})})}return null};const cw={title:66,text:3e3,secondaryText:1e3,partner:25},Do=({id:e="",card:t,buildCardData:n,cta:r,gtmContext:a="Carousel",className:i="",handleCardClick:s})=>{var R,$,M;const o=ue.useIntl(),l=x.useContext(Mt),u=l&&typeof l.id=="string",[c,m]=x.useState({data:null,isLoading:!0}),{data:f,isLoading:p}=c,g=x.useCallback(()=>{n(t,u).then(C=>{m(()=>({data:C,isLoading:!1}))}).catch(()=>m(C=>({...C,isLoading:!1})))},[e]);if(x.useEffect(()=>{g()},[]),p||!f)return d.jsx(wt,{element:"li",className:"card-wrapper","data-testid":"card-placeholder"});s&&!r&&(r={text:o.formatMessage({id:`card_cta_${t.contentType}`}),onClick:s});const{contentType:h}=f;if(!h||!ja[h])return d.jsx(wt,{element:"li",className:"card-wrapper"});const{basePath:y="",className:b,length:w,gtmEvent:A}=ja[h];let k=f.slug?`${y}${f.slug}`:!1;f.slug&&(f.slug.slice(0,4)==="http"||f.slug.slice(0,2)==="//"||f.slug.slice(0,6)==="mailto"||f.slug.slice(0,3)==="tel")&&(k=f.slug);const E=C=>{k&&(C.preventDefault(),C.stopPropagation(),window.location.href=k)},T={...cw,...w};let j={className:"card"},z={};return k&&(z={href:k,className:"gtm-trackable","data-gtm-event-context":`${a}-CarouselCard`,"data-gtm-event-type":`${A}-click`,"data-testid":"link"},f.openInNewTab&&(z.target="_blank"),j={onClick:E,className:"card gtm-trackable","data-gtm-event-context":`${a}-CarouselCard`,"data-gtm-event-type":`${A}-click`}),d.jsx("li",{className:G("card-wrapper text-medium",b,i,{"has-link":k,"no-link":!k,"has-image":f.banner}),"data-testid":`${h}-card`,children:d.jsxs("div",{...j,children:[d.jsx(Nc,{className:"card-label",contentType:h,customIcon:f.isPrivate?"lock-locked":f.customIcon,customLabel:f.customLabel}),h==="communityPage"&&(f==null?void 0:f.createdAt)&&Fh(f==null?void 0:f.createdAt,60)&&d.jsx(hn,{size:"small",variant:"information","data-testid":"new-community",children:o.formatMessage({id:"card_new"})}),f.startDate&&!f.isOngoingEvent&&d.jsx(hn,{size:"small",variant:f.dateHasPassed?"default":"information","data-testid":"date",children:f.dateHasPassed?o.formatMessage({id:"card_ended"}):Sc(f.startDate)}),f.banner?d.jsxs("p",{className:"img",children:[f.registered&&d.jsx(hn,{size:"small",variant:"registered",children:o.formatMessage({id:"card_registered"})}),d.jsx(er,{image:{...f.banner,description:""}})]}):b==="people"?d.jsx(sn,{name:f.title||"",src:f.profile,"data-testid":"people-profile-picture"}):null,f.contributors&&d.jsx(zs,{contributors:{data:f.contributors},styling:{size:"small",showGap:b!=="question",showText:!0},multipleText:["event","solutionArticle"].includes(h)?o.formatMessage({id:`card_contributors_${h}`}):void 0,"data-testid":"contributors"}),f.partner&&d.jsx("p",{className:"partners","data-testid":"partners",children:f.partner.length>1?o.formatMessage({id:"card_partner"},{partner:f.partner[0],number:f.partner.length-1}):Wn(f.partner[0],T.partner)}),["title","text","secondaryText"].map(C=>{const B=f[C];if(!B)return null;const F=_c(C),N={key:C,className:F,"data-testid":F},L={wrapper:"p",forceWrapper:!0,forceInline:!0},W=Wn(B,T[C]);return["title","text"].includes(C)&&k?(L.wrapper="a",d.jsx("p",{...N,children:d.jsx(Pt,{options:L,...z,children:W})})):d.jsx(Pt,{options:L,...N,children:W})}),(l==null?void 0:l.id)&&(f==null?void 0:f.members)&&d.jsxs("span",{className:"member-information",children:[((R=f==null?void 0:f.members)==null?void 0:R.isMember)&&d.jsx(hn,{size:"small",variant:"registered",icon:(($=f==null?void 0:f.members)==null?void 0:$.memberType)==="owner"?"user":"tick",children:o.formatMessage({id:`card_member_type_${(M=f==null?void 0:f.members)==null?void 0:M.memberType}`})}),d.jsx("br",{}),d.jsx("span",{className:"label member-count",children:o.formatMessage({id:"card_member_count"},{count:f==null?void 0:f.members.count})})]}),d.jsx(uw,{type:b||"",data:f}),d.jsx(lw,{data:f,cta:r,link:k||"",gtmContext:a})]})})};const qf=({cards:e,cardTypes:t,className:n="",...r})=>d.jsx("ul",{className:G("card-block",n),children:e.map((a,i)=>{const s=a.slug?`${a.slug}-${t[i]}`:`${t[i]}-${i}`;return d.jsx(Do,{id:s,card:{...a,contentType:t[i]},...r},s)})}),dw=(e,t,n,r)=>{const a=t*n<=e,i=e<t*(n+1),s=r.includes(Math.floor(e/t));return a&&i||s},fw=({id:e,title:t})=>{const n=ue.useIntl();if(!t||!t.text)return null;const{text:r,element:a="h2",variant:i="default",size:s="medium",link:o}=t;return x.createElement(a,{className:G("title",i,s,{"highlighted-title":i==="highlighted"}),children:d.jsxs(d.Fragment,{children:[r,o&&d.jsx("a",{href:o,className:"text-medium gtm-trackable","data-gtm-event-context":"CarouselViewAll","data-gtm-event-type":`${e||window.btoa(r)}-view-all-click`,children:n.formatMessage({id:"card_carousel_viewAll"})})]})})};const $i={fourCards:1024,threeCards:769,twoCards:480};let ea=null;const hw=({id:e,cards:t,cardTypes:n,buildCardData:r,title:a,className:i,gtmContext:s,...o})=>{const l=ue.useIntl(),[u,c]=x.useState({cardsPerPage:4,isLoading:!0}),{cardsPerPage:m,isLoading:f}=u,[p,g]=x.useState({currentPage:0,loadedPages:[0]}),{currentPage:h,loadedPages:y}=p,[b,w]=x.useState(""),A=t.length,k=Math.ceil(A/m),E=x.useRef(null),T=Qn(!0,!0,E==null?void 0:E.current);x.useEffect(()=>{let C=1;T&&(T>=$i.fourCards?C=4:T>=$i.threeCards?C=3:T>=$i.twoCards&&(C=2),C>A&&(C=A)),c(B=>({...B,cardsPerPage:C,isLoading:!1}))},[T,A]);const j=(C="next")=>{let B=h;if(typeof C=="string")if(C==="next")if(h<k-1)B=h+1;else return;else if(h>0)B=h-1;else return;else B=C;g(N=>({...N,currentPage:B,loadedPages:[...new Set([...y,B])]}));const F=()=>{const N=B*u.cardsPerPage,L=N+u.cardsPerPage;return t.slice(N,L).length};w(l.formatMessage({id:"carousel_pagination_aria_live"},{direction:C,count:F()}))},z=C=>{ea=C.touches[0].clientX},R=C=>{if(ea===null)return;const B=C.touches[0].clientX,F=ea-B;F>5?j("next"):F<-5&&j("previous"),ea=null},$={"--width":`${T||0}px`,"--total-cards":A,"--cards-per-page":m,"--page":h};if(f)return d.jsx($s,{layout:`carousel${a?"-with-title":""}`});const M=(C,B)=>{var N;let F=null;return(N=C==null?void 0:C.sys)!=null&&N.id?F=`card-${C.sys.id}`:C!=null&&C.slug?F=`card-${C.slug}`:[n[B],C.contentType].includes("customCard")&&(F=`card-${window.btoa(`${C.title} ${C.createdAt}`)}-${B}`),F};return d.jsxs("section",{ref:E,className:G("carousel-wrapper",i),"data-testid":"carousel",children:[d.jsx(fw,{id:e,title:a}),d.jsx("ul",{className:"carousel",onTouchStart:z,onTouchMove:R,style:$,"data-testid":"carousel-list",children:t.map((C,B)=>{let F=M(C,B);return F&&dw(B,m,h,y)?d.jsx(Do,{id:F,card:{...C,contentType:n[B]},buildCardData:r,gtmContext:s,...o},F):(F=F||`${e}-card-${B}`,d.jsx(wt,{element:"li",className:"card-wrapper","data-testid":"card-placeholder"},F))})}),k<=1?null:d.jsxs(d.Fragment,{children:[d.jsxs("ul",{className:"controls","data-testid":"carousel-controls",children:[d.jsx("li",{className:"arrow previous",children:d.jsx(Ee,{variant:"secondary",size:"large",icon:{icon:"chevron_left"},onClick:C=>{C.preventDefault(),C.stopPropagation(),j("previous")},screenreaderText:l.formatMessage({id:"carousel_pagination_previous"}),disabled:h<=0})}),[...Array(k)].map((C,B)=>d.jsx("li",{"data-testid":"carousel-controls-button",children:d.jsx("button",{className:G("page-indicator",{selected:B===h}),onClick:F=>{F.preventDefault(),F.stopPropagation(),j(B)},children:d.jsx(Me,{showOnFocus:!1,children:l.formatMessage({id:"carousel_pagination_page"},{number:B+1,total:k})})})},`page-indicator-${B}`)),d.jsx("li",{className:"arrow next",children:d.jsx(Ee,{variant:"secondary",size:"large",icon:{icon:"chevron_right"},onClick:C=>{C.preventDefault(),C.stopPropagation(),j("next")},screenreaderText:l.formatMessage({id:"carousel_pagination_next"}),disabled:h>=k-1})})]}),d.jsx(Me,{"aria-live":"polite",showOnFocus:!1,children:b})]})]})},mw=({carousels:e=[],isLoading:t,title:n,className:r="",...a})=>!e||!e.length?null:e.map(({title:i,viewAllUrl:s,cards:o,cardsTypes:l},u)=>{const c=i?window.btoa(i):`carousel-${u}`,m=u===e.length-1;return t?d.jsxs(x.Fragment,{children:[d.jsx($s,{layout:`carousel${i?"-with-title":""}`,"data-testid":"carousel-placeholder"}),m?null:d.jsx(tn,{})]},`placeholder-${c}`):d.jsxs(x.Fragment,{children:[d.jsx(hw,{cards:o,cardTypes:l,title:n!=null&&n.hidden?{}:{...n,text:i,link:s},...a}),m?null:d.jsx(tn,{})]},`carousel-${c}`)});const ta="joinCommunityButton",Co=({isMember:e=!1,isOpen:t=!1,isShort:n=!1,disabled:r=!1,functions:{join:a,leave:i}={join:()=>{},leave:()=>{}}})=>{const s=ue.useIntl(),o=x.useContext(Mt),l=o&&typeof o.id=="string",u=r||!l,[c,m]=x.useState(e),[f,p]=x.useState(e?"joined":"notJoined");x.useEffect(()=>{f==="joining"?p("joined"):f==="leaving"&&p("notJoined")},[c]);const g={},h={};return c&&f!=="leaving"&&(g["data-hover-text"]=s.formatMessage({id:`${ta}_leave`}),g["aria-label"]=s.formatMessage({id:`${ta}_member_aria`}),h["aria-hidden"]="true"),d.jsx(Ee,{variant:c?"secondary":"primary",size:"medium",styling:{fullWidth:!0},icon:c&&f!=="leaving"?{icon:"tick",position:"left"}:!1,tooltip:!t&&!c?s.formatMessage({id:`${ta}_closed_tooltip`}):"",onClick:async y=>{u||(y.currentTarget.blur(),c?(p("leaving"),typeof i=="function"&&await i()):(p("joining"),typeof a=="function"&&await a()),m(!c))},className:G("join-community-button",f,{active:f==="joining"}),disabled:u,...g,children:d.jsx("span",{className:"text",...h,children:s.formatMessage({id:`${ta}${["joining","leaving"].includes(f)?`_${f}`:c?"_member":n?"_short":""}`})})})};const Li="communityDetails_",pw=({className:e="",isMember:t=!1,isOpen:n=!1,slug:r,members:{number:a=0,data:i=[]}={number:0,data:[]},functions:{invite:s,...o}})=>{const l=ue.useIntl(),u=5,c=a||i.length,m=i.length?i:Array(u).fill({}),f=`/communities/${r}/members`===window.location.pathname,p=t||n,g=!n&&!t;return d.jsxs("div",{className:G("community-details",e),children:[p&&d.jsxs("div",{className:"member-details",children:[d.jsxs("div",{className:"top",children:[d.jsxs("h4",{children:[l.formatMessage({id:`${Li}members`}),d.jsx("span",{className:"count",children:c})]}),!f&&d.jsx("p",{className:"text-small",children:d.jsx("a",{href:`/communities/${r}/members`,children:l.formatMessage({id:`${Li}viewAll`})})})]}),d.jsx(zs,{contributors:{total:a,data:m},styling:{size:"medium",showGap:!0,showPlaceholders:c===0},cutoff:u})]}),d.jsx(Co,{isMember:t,isOpen:n,disabled:g,functions:{...o}}),t&&d.jsx(Ee,{variant:"primary",onClick:s,icon:{icon:"plus"},styling:{fullWidth:!0},children:l.formatMessage({id:`${Li}invite`})})]})};const gw=({breadcrumbs:e,cutoff:t=20,className:n=""})=>{const r=ue.useIntl();return d.jsxs(d.Fragment,{children:[d.jsx(Me,{element:"p",children:r.formatMessage({id:"breadcrumbs_label"})}),d.jsx("ul",{className:G("breadcrumbs text-small",n),children:e.map(({text:a,href:i,current:s=!1},o)=>{const l={};return s&&(l["aria-current"]="location"),d.jsxs("li",{children:[s&&d.jsx(Me,{element:"span",children:r.formatMessage({id:"breadcrumbs_currentPage"})}),d.jsx(kn,{href:s?void 0:i,...l,children:Wn(a,t)})]},`${window.btoa(a)}_${o}`)})})]})};const vw=({options:e,allOption:t=!1,allowMultiple:n=!0,onChange:r=()=>{},className:a=""})=>{const i=ue.useIntl(),s=t?[{id:"all",text:typeof t!="boolean"&&t.text||i.formatMessage({id:"filters_all"})},...e]:e,[o,l]=x.useState(t?["all"]:[]),u=(c,m)=>{let f=[];o.includes(c)?f=o.filter(p=>p!==c):c==="all"?f=["all"]:n?f=[...o.filter(p=>p!=="all"),c]:f=[c],l(p=>(r&&typeof r=="function"&&r({current:f,previous:p}),f)),m&&typeof m=="function"&&m()};return d.jsx("ul",{className:G("filters",a),children:s.map(({id:c,text:m,disabled:f=!1,callback:p=()=>{}})=>{let g={};return f&&(g={disabled:!0,"aria-label":i.formatMessage({id:"filters_disabled"},{name:m})}),d.jsx("li",{children:d.jsx("button",{className:G(c,{selected:o.includes(c)}),onClick:h=>{h.preventDefault(),h.stopPropagation(),u(c,p)},...g,children:m})},c)})})},bw=(e,t,n)=>{const r=String(e);if(!n||!n.length)return t?`/${r}/${t}`:`/${r}`;let a="",i=!1;return n.forEach(({url:s,position:o})=>{o==="before-lang"?(a+=`/${s}`,i=!0):(a.includes(`/${r}/`)||(a+=`/${r}`),a+=`/${s}`)}),a.includes(`/${r}/`)||(a+=`/${r}`),t&&(a+=`/${t}`),i?{url:a,urlForRouter:`/${a.split("/").slice(2).join("/")}`}:a};const na="languageSwitcher_",yw=({currentLanguage:e,isOriginalLanguage:t=!1,isHumanTranslation:n=!1,translations:r,onChange:a,urlParts:i,variant:s="default",label:o,className:l=""})=>{const u=ue.useIntl(),{updateLanguage:c=()=>{}}=x.useContext(vo),[m,f]=x.useState(e);if(x.useEffect(()=>{e!==m&&f(e)},[e]),!r||!Object.values(r).some(y=>y&&y.post_name))return null;const g=Object.keys(r),h=m!==e;return d.jsxs("div",{className:G("language-switcher text-small",s,l),children:[d.jsxs("nav",{children:[s!=="short"&&d.jsx("p",{children:o||u.formatMessage({id:`${na}label`})}),d.jsx("ul",{children:g.map(y=>{var A;if(!ga[y])return null;const b=(A=r[y])==null?void 0:A.post_name;let w={className:y};if(m===y)w["aria-label"]=u.formatMessage({id:`${na}selected`},{language:ga[y]});else{const k=bw(y,b,i);w={...w,href:typeof k=="string"?k:k.url,onClick:E=>{f(y),c(y),typeof a<"u"&&(E.preventDefault(),E.stopPropagation(),a(y,typeof k=="string"?k:k.urlForRouter))}}}return d.jsx("li",{children:d.jsx(kn,{...w,fallbackElement:"span",children:ga[y]})},y)})}),s!=="short"&&!h&&d.jsx("p",{children:u.formatMessage({id:`${na}translation_${t?"original":n?"human":"machine"}`})})]}),s!=="short"&&!h&&!t&&!n&&d.jsx("small",{children:u.formatMessage({id:`${na}disclaimer`},{email:Pn.support,link:y=>{const b=`mailto:${y}`;return d.jsx("a",{href:b,children:y})}})})]})};const zi=ue.createIntl({locale:"en",messages:Xn}),Nr=({hasNextPage:e=!0,loadNextPage:t=()=>{},isLoading:n=!1,variant:r="secondary",size:a="medium",styling:i={muted:!1,fullWidth:!1},icon:s=!1,messages:o={button:zi.formatMessage({id:"loadMore_button"}),endOfFeed:zi.formatMessage({id:"loadMore_endOfFeed"}),error:zi.formatMessage({id:"loadMore_error"})},className:l="",gtmContext:u="LoadMore"})=>{const[c,m]=x.useState(""),f=async p=>{if(!n)try{await t(p)}catch(g){g instanceof Error?m(g.message):m("Unknown error")}};return!c&&!e&&!o.endOfFeed?null:d.jsx("footer",{className:G("load-more",l),children:!c&&e?d.jsx(Ee,{variant:r,size:a,styling:i,icon:s,onClick:f,"data-gtm-event-context":u,"data-gtm-event-type":"load-more-click",disabled:n,className:"gtm-trackable","data-testid":"load-more-button",children:o.button}):o.endOfFeed&&(!c||c!=null&&c.includes("Cannot read items"))?d.jsx("p",{children:o.endOfFeed}):c&&d.jsx("p",{className:"error",children:o.error})})};const xo=({variant:e="default",version:t="default",className:n="",...r})=>d.jsx("p",{className:"logo-wrapper",children:d.jsx("a",{href:"/home/",className:G("logo",e,t,n),...r,children:d.jsx(Me,{children:d.jsx(ue.FormattedMessage,{id:"apolitical"})})})});let ra=!1;const Wf=({element:e="div",id:t="more-menu",options:n,className:r=""})=>{const a=ue.useIntl(),i=x.useRef(null),[s,o]=x.useState(!1),l=u=>{i.current&&u.target instanceof HTMLElement&&!i.current.contains(u.target)&&o(!1)};return x.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)})),x.createElement(e,{ref:i,className:G("more-menu text-medium",r),children:d.jsxs(d.Fragment,{children:[d.jsx(Ee,{variant:"tertiary",size:"medium",icon:{icon:"ellipsis"},onClick:()=>o(!s),"aria-haspopup":"true","aria-expanded":s,"aria-controls":t,screenreaderText:a.formatMessage({id:"moreMenu"}),className:"more-menu-button"}),d.jsx("ul",{id:t,hidden:!s,children:n.map(({href:u,onClick:c,text:m,icon:f,...p},g)=>{const h={...p,onClick:y=>{o(!1),typeof c=="function"&&c(y)},onFocus:()=>{ra&&(clearTimeout(ra),ra=!1)},onBlur:()=>{ra=setTimeout(()=>{o(!1)},100)}};return u&&(h.href=u),d.jsx("li",{className:"more-menu-list-item",children:d.jsx(Ee,{variant:"tertiary",size:"medium",icon:f?{icon:f,position:"left"}:!1,...h,children:m})},`${window.btoa(m)}_${g}`)})})]})})},Dw=(e,t=!1)=>t?e.replaceAll("/","")===t:typeof window<"u"&&window.location&&window.location.pathname===e;const Cw=[{key:"homepage",href:"/home/"},{key:"events",href:"/events/"},{key:"microcourses",href:"/microcourses/"},{key:"articles",href:"/solution-articles/"},{key:"communities",href:"/communities/"}],Hf=({activeLink:e})=>{const t=ue.useIntl(),n=x.useContext(Mt),r=n&&typeof n.id=="string";return d.jsxs("ul",{id:"navigation-menu",className:"text-medium",children:[Cw.map(({key:a,href:i})=>{const s=Dw(i,e),o={};return s&&(o["aria-current"]="page"),d.jsx("li",{className:G(a,{active:s}),children:d.jsx("a",{href:i,"data-gtm-event-type":`${a}-click`,"data-gtm-event-context":"NavigationMenu",className:"gtm-trackable",...o,children:t.formatMessage({id:`navigationMenu_links_${a}`})})},a)}),r&&d.jsx("li",{className:"profile","data-testid":"profile-link",children:d.jsxs("a",{href:"/profiles/me","data-gtm-event-type":"profile-click","data-gtm-event-context":"NavigationMenu",className:"gtm-trackable",children:[d.jsx(sn,{name:(n==null?void 0:n.name)||"",src:n!=null&&n.image?n.image.thumbnail:""}),d.jsx("span",{children:t.formatMessage({id:"navigationMenu_profile"})})]})})]})},dr=(e,t,n)=>`${e}?share=${t}${n?`&uuid=${n}`:""}`,xw=({title:e,link:t,referrer:n})=>[{key:"linkedin",icon:"social_linkedin",url:`https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(`${dr(t,"linkedin",n)}&src=linkedin`)}&title=${encodeURIComponent(e)}&source=Apolitical`},{key:"twitter",icon:"social_twitter",url:`https://twitter.com/share?ref_src=twsrc%5Etfw&url=${encodeURIComponent(`${dr(t,"twitter",n)}&src=twitter`)}&text=${encodeURIComponent(e)}&via=${encodeURIComponent("apoliticalco")}`},{key:"facebook",icon:"social_facebook",url:`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(`${dr(t,"facebook",n)}`)}&t=${e}`},{key:"email",icon:"share_email",url:`mailto:?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`${e}
|
|
158
158
|
|
|
159
|
-
${dr(t,"mailto",n)}&src=email`)}`},{key:"clipboard-copy",icon:"share_copy-link",url:dr(t,"copy",n),shouldRender:()=>navigator&&navigator.clipboard&&navigator.clipboard.writeText,onClick:(r,a)=>(r.preventDefault(),r.stopPropagation(),navigator.clipboard.writeText(a))}];const ww="shareLinks_",Ew=({title:e,link:t,referrer:n,gtmContext:r="ShareLinks",size:a="large",variant:i="default",className:s=""})=>{const o=ue.useIntl(),l=xw({title:e,link:t,referrer:n});return d.jsxs("aside",{className:G("share-links",a,i,s),children:[d.jsx("p",{className:"text-small",children:o.formatMessage({id:"shareLinks_label"})}),d.jsx("ul",{children:l.map(({key:u,icon:c,url:m,shouldRender:f=!0,onClick:p})=>{if(typeof f=="function"&&!f())return null;const g={};return p&&(g.onClick=h=>p(h,m)),d.jsx("li",{children:d.jsx(Ee,{size:a,variant:"tertiary",icon:{icon:c||u},href:m,target:"_blank",rel:"noopener noreferrer",className:"gtm-trackable","data-gtm-event-context":`${r}-SocialButtons`,"data-gtm-event-type":`${u}-click`,"data-testid":"link",screenreaderText:o.formatMessage({id:`${ww}link_${u}`}),...g})},u)})})]})};const kw=({tabs:e,className:t="",preventLocationChange:n})=>{var u;const r=(c,m,f)=>(c||(c=`panel-${window.btoa(m)}-${f}`),c);let a=e.findIndex(c=>c.current===!0);if(a<0&&(a=0),window.location.hash){const c=window.location.hash.replace("#","");if(e.find(f=>f.id===c)){for(let f=0;f<e.length;f++)if(r(e[f].id,e[f].text,f)===c){a=f;break}}}const[i,s]=x.useState((u=e[a])!=null&&u.id?e[a].id:r(e[a].id,e[a].text,a));x.useEffect(()=>{if(e[a].hasCarousel){const c=new CustomEvent("hiddenSectionVisible",{detail:{id:i}});window.dispatchEvent(c)}},[i]);const o=[],l=[];return e.forEach(({id:c,text:m,content:f,href:p,hasCarousel:g},h)=>{c=r(c,m,h);const y=i===c,b={};p||(b["aria-controls"]=c,b.onClick=w=>{w.preventDefault(),w.stopPropagation(),s(c),!n&&(window.location.hash=`#${c}`)},l.push(d.jsx("section",{id:c,hidden:!y,role:"tabpanel","aria-labelledby":`tab-${c}`,"aria-live":y?"assertive":"off",children:typeof f=="string"?d.jsx("p",{children:f}):f},`section-${c}`))),o.push(d.jsx("li",{"data-testid":"navigation-tab",children:d.jsx("a",{href:p||`#${c}`,id:`tab-${c}`,className:G({selected:y}),role:"tab","aria-selected":y,...b,children:m})},`tab-${c}`))}),d.jsxs("div",{className:G("tabs-wrapper",t),children:[d.jsx("ul",{className:"tabs",role:"tablist",children:o}),d.jsx("div",{className:"tab-content",children:l})]})};const _w={"2-1":901,"1-3":769,"1-1":769},Uf=({layout:e="2-1",hideOnMobile:t=!1,hasCSSContainers:n=!1,className:r="",children:a})=>{const i=Qn(!0);let s=a;return x.Children.count(a)===1&&(s=x.Children.toArray(a)[0],s.props&&(s=s.props.children)),d.jsx("section",{className:G("columns",`layout-${e}`,r,{"has-containers":n}),children:x.Children.map(s,(o,l)=>t!==!1&&l===t&&i&&i<_w[e]?null:o)})};let qi;const Wi="contactFooter_",Bw=({onSuccess:e=async()=>{},onFailure:t=()=>{}})=>{const n=x.useRef(null),[r,a]=x.useState(0),[i,s]=x.useState(!1),o=()=>{n.current&&a(n.current.clientHeight)},l=()=>{i||(s(!0),clearTimeout(qi),qi=setTimeout(()=>{o(),s(!1)},500))};return x.useEffect(()=>(o(),window.addEventListener("resize",l),()=>{clearTimeout(qi),window.removeEventListener("resize",l)}),[]),d.jsx(ln,{id:"contactForm",className:"contact-footer",children:d.jsxs("div",{className:"inner-wrapper",children:[d.jsx("h2",{children:d.jsx(ue.FormattedMessage,{id:`${Wi}title`})}),d.jsxs("div",{className:"content-wrapper",ref:n,"data-testid":"content-wrapper",style:i?{}:{minHeight:r},children:[d.jsxs("aside",{children:[d.jsx("p",{children:d.jsx(ue.FormattedMessage,{id:`${Wi}text`})}),d.jsx(kn,{className:"mailto-link",href:"mailto:hello@apolitical.co",children:d.jsx(ue.FormattedMessage,{id:`${Wi}email`})})]}),d.jsx(Df,{functions:{onSuccess:e,onFailure:t},gtm:{context:"FooterContactUsForm",event:"contact-form-submit-click"}})]})]})})},Aw=({activeLink:e,...t})=>d.jsx(ln,{children:d.jsx(Uf,{layout:"1-3",children:d.jsxs(d.Fragment,{children:[d.jsx(Hf,{activeLink:e}),d.jsx($c,{...t})]})})});const Hi="cookieBanner_",Ui=["apol-cookie-banner","apolitical-performance-cookie-consent","functional-cookie-consent"],Vi=new Date(Date.now()+12*30*24*60*60*1e3),Vf=()=>{const e=ue.useIntl(),[t,n,r]=js.useCookies(Ui),[a,i]=x.useState(!t["apol-cookie-banner"]),s=()=>{Ui.forEach(c=>{n(c,!0,{path:"/",expires:Vi,domain:c==="apolitical-performance-cookie-consent"?".apolitical.co":void 0})}),i(!1),window.location.reload()},o=()=>{n("apol-cookie-banner",!0,{path:"/",expires:Vi}),Ui.forEach(c=>{if(c==="apol-cookie-banner"){n(c,!0,{path:"/",expires:Vi});return}r(c)}),i(!1)};if(!a)return null;const l=[{id:"settings",href:"/pages/cookie-policy",gtmType:"policy-page"},{id:"reject",onClick:o,gtmType:"reject-all"},{id:"accept",onClick:s,gtmType:"accepted-all"}],u=[];return l.forEach(c=>{u.push({variant:c.href?"tertiary":"primary",href:c.href,onClick:c.onClick,className:"gtm-trackable","data-gtm-event-context":"cookie-banner","data-gtm-event-type":`cookie-${c.gtmType}-click`,children:e.formatMessage({id:`${Hi}buttons_${c.id}`})})}),d.jsxs("aside",{id:"cookie-banner",className:"text-medium",children:[d.jsx("h6",{children:e.formatMessage({id:`${Hi}title`})}),d.jsx("p",{children:e.formatMessage({id:`${Hi}text`})}),d.jsx(En,{buttons:u})]})},qt={platform:{order:["events","courses","articles","communities"],events:{href:"/events/",gtmType:"events-click"},courses:{href:"/microcourses/",gtmType:"microcourses-click"},articles:{href:"/solution-articles/",gtmType:"articles-click"},communities:{href:"/communities/",gtmType:"communities-click"}},community:{order:["support","post","join","guidelines"],support:{name:"Support FAQ",href:"/pages/support-faq",gtmType:"support-faq-click"},post:{href:"/pages/post-an-article",gtmType:"post-an-article-click"},join:{href:"/pages/who-can-join-the-community",gtmType:"who-can-join-click"},guidelines:{href:"/pages/values-and-guidelines",gtmType:"guidelines-and-values-click"}},company:{order:["news","story","team","careers","partner","contact"],news:{href:"/learning-hub/updates/",gtmType:"news-click"},story:{href:"/pages/our-story",gtmType:"our-story-click"},team:{href:"/pages/meet-our-team",gtmType:"team-click"},careers:{href:"/pages/careers",gtmType:"careers-click"},partner:{href:"/partnerships/",gtmType:"partner-with-us-click"},contact:{href:"/pages/get-in-touch",gtmType:"contact-click"},child:"legal"},legal:{order:["privacy","terms","cookie","accessibility","ai"],privacy:{href:"https://about.apolitical.co/privacy-policy",gtmType:"privacy-policy-link"},terms:{href:"https://about.apolitical.co/terms-and-conditions",gtmType:"terms-conditions-link"},cookie:{href:"/pages/cookie-policy",gtmType:"cookie-policy-link"},ai:{href:"/pages/ai-principles",gtmType:"ai-principles-link"},accessibility:{href:"/pages/accessibility-statement",gtmType:"accessibility-link"},text:{order:["dataProtection","euDataProtection"],dataProtection:{email:Pn["data-protection"].default,gtmType:"email-dpo-link"},euDataProtection:{email:Pn["data-protection"].eu,gtmType:"email-eu-dpo-link"}}},contact:{text:{order:["correspondence","registered","berlin","support","business"],correspondence:{address:!0},registered:{address:!0},berlin:{address:!0},support:{email:Pn.support,gtmType:"concierge-email-click"},business:{email:Pn.general,gtmType:"hello-email-click"}}},social:{order:["linkedin","twitter","facebook"],linkedin:{href:"https://www.linkedin.com/company/apolitical"},twitter:{href:"https://twitter.com/apoliticalco"},facebook:{href:"https://www.facebook.com/apoliticalco"}}};const Ln="footer_",Oa="SiteFooter",ic=({group:e})=>{const t=qt[e].order||[];let n=!1;return"text"in qt[e]&&(n=qt[e].text),d.jsxs(x.Fragment,{children:[d.jsx("p",{className:"pre-title",children:d.jsx(ue.FormattedMessage,{id:`${Ln}${e}`})}),Array.isArray(t)&&t.length>0&&d.jsx("ul",{className:"text-medium",children:t.map(r=>{if(["order","child","text"].includes(r))return null;const{href:a,gtmType:i}=qt[e][r],s={};return["legal"].includes(e)&&(s.target="_blank",s.rel="noopener"),d.jsx("li",{children:d.jsx("a",{href:a,className:"gtm-trackable","data-gtm-event-context":Oa,"data-gtm-event-type":i,...s,children:d.jsx(ue.FormattedMessage,{id:`${Ln}${e}_${r}`})})},`${e}_${r}`)})}),typeof n!="boolean"&&"order"in n&&Array.isArray(n.order)&&d.jsx("dl",{className:"text-medium",children:n.order.map(r=>d.jsxs(x.Fragment,{children:[d.jsx("dt",{children:d.jsx(ue.FormattedMessage,{id:`${Ln}${e}_${r}`})}),d.jsxs("dd",{children:[typeof n!="boolean"&&n[r].address&&d.jsx("address",{children:d.jsx(ue.FormattedMessage,{id:`${Ln}${e}_${r}_address`,values:{br:d.jsx("br",{})}})}),typeof n!="boolean"&&n[r].email&&d.jsx("a",{href:`mailto:${n[r].email}`,className:"gtm-trackable","data-gtm-event-context":Oa,"data-gtm-event-type":n[r].gtmType,children:n[r].email})]})]},`dl-${e}-${r}`))})]},e)},wo=()=>d.jsx("div",{id:"footer",children:d.jsxs("div",{className:"wrapper",children:[d.jsx(Ia,{element:"hr"}),d.jsx(xo,{variant:"inverted",version:"full",className:"gtm-trackable","data-gtm-event-context":Oa,"data-gtm-event-type":"logo-homepage-link"}),d.jsx("footer",{children:["platform","community","company","contact"].map(e=>d.jsxs("div",{className:"group",children:[d.jsx(ic,{group:e}),Object.keys(qt[e]).includes("child")&&d.jsx(ic,{group:qt[e].child})]},e))}),d.jsx("hr",{}),d.jsxs("div",{className:"sub-footer",children:[d.jsx("ul",{children:Array.isArray(qt.social.order)&&qt.social.order.map(e=>{const t=qt.social[e];return d.jsx("li",{className:e,children:d.jsx("a",{href:t.href,target:"_blank",rel:"noopener noreferrer",className:"gtm-trackable","data-gtm-event-context":Oa,"data-gtm-event-type":"social-click",children:d.jsx("span",{className:"hidden",children:d.jsx(ue.FormattedMessage,{id:`${Ln}social_${e}`})})})},e)})}),d.jsx("small",{children:d.jsx(ue.FormattedMessage,{id:`${Ln}copyright`,values:{currentYear:new Date().getFullYear()}})})]})]})}),Pe={timeouts:{},handlerCalled:{},getIsDesktopVersion:(e,t)=>{const n={navigation:{loggedIn:769,loggedOut:881},search:{loggedIn:961,loggedOut:1121}},r=i=>{const s=`logged${e?"In":"Out"}`;return t>=n[i][s]};let a={};return["navigation","search"].forEach(i=>{a[i]=r(i)}),a},shouldChangeHeaderIsVisible:(e,t,n)=>{Object.values(t).filter(a=>a===!0).length||n([{type:"headerIsVisible",value:e}])},handleMenus:({id:e,value:t,menus:n,dispatch:r,forceHandle:a=!1})=>{if(!a&&n[e]===t||!a&&e==="account"&&t===!1&&n.navigation===!0)return;const i=Date.now();if(!a&&!t&&Pe.handlerCalled[e]&&i-Pe.handlerCalled[e]<500)return;Pe.handlerCalled[e]=i;let s=[{type:`menus.${e}`,value:t}];if(t===!0)Object.keys(n).forEach(o=>{o===e||n[o]===!1||s.push({type:`menus.${o}`,value:!1})});else{let o=null;switch(e){case"navigation":o=document.querySelector("#header .menu-button"),o||(o=document.querySelector("#navigation > li.parent"));break;case"search":o=document.querySelector("#header .toggle-search-button");break;case"account":o=document.querySelector("#header .account-button");break;default:return}o&&o.focus()}r(s)},findFirstChild:(e,t,n=!1)=>{if(!e||!e[0])return!1;for(let r=0;r<=e.length;r++){if(!e[r])continue;if(e[r][t]&&(!n||e[r][t].includes(n)))return e[r];if(!t.includes("."))continue;const a=vc(e[r],t);if(!(typeof a>"u")&&(!n||a[t]&&a[t].includes(n)||a.value&&a.value.includes(n)||a.toString().includes(n)))return e[r]}return e[0].children?Pe.findFirstChild(e[0].children,t,n):!1},autoFocus:({menu:e,navigationRef:t,isDesktopVersion:n,focusElements:r,dispatch:a})=>{var l;if(!t.current||!t.current.children)return;const i=n?"desktop":"default";if(r[e][i]){(l=document.querySelector(`#header ul a[href="${r[e][i]}"]:last-child`))==null||l.focus();return}let s,o;switch(e){case"navigation":if(n){const u=Pe.findFirstChild(t.current.children,"attributes.aria-controls","navigation");s=Pe.findFirstChild(u.children,"href")}else s=Pe.findFirstChild(t.current.children,"href");break;case"account":if(o=Pe.findFirstChild(t.current.children,"className","account"),!o||!o.children)return;s=Pe.findFirstChild(o.children,"href");break;default:return}s&&(a([{type:`focusElements.${e}.${i}`,value:s.attributes.href.value}]),s.focus())},events:{onClick:(e,{id:t,callback:n,isOpen:r})=>{e.target&&e.target.attributes&&e.target.attributes.href||(e.preventDefault(),e.stopPropagation(),clearTimeout(Pe.timeouts[t]),n(t,!r))},onFocus:({id:e})=>{clearTimeout(Pe.timeouts[e])},onMouseEnter:({id:e,callback:t})=>{clearTimeout(Pe.timeouts[e]),t(e,!0)},onBlur:({id:e,callback:t})=>{Pe.timeouts[e]=setTimeout(()=>{t(e,!1)},250)}}},Sr={order:["home","topics","partners","account"],home:{href:"/home/",hasVariantText:!0,gtmType:"homepage-click"},topics:{order:["explore","topics"],menuId:"navigation",explore:{order:["events","courses","articles","communities"],events:{href:"/events/",className:"icon events"},courses:{href:"/microcourses/",gtmType:"microcourses-click",className:"icon courses"},articles:{href:"/solution-articles/",gtmType:"articles-click",className:"icon articles"},communities:{href:"/communities/",gtmType:"communities-click",className:"icon communities"}},topics:{order:["climate","cities-and-local-government","digital-and-data","education","equity-justice-and-inclusion","health-and-social-care","innovation","leadership-and-skills","life-in-government","policymaking","transport-and-infrastructure","work-and-the-economy"],className:"columns",climate:{href:"/topics/climate/"},"cities-and-local-government":{href:"/topics/cities-and-local-government/"},"digital-and-data":{href:"/topics/digital-and-data/"},education:{href:"/topics/education/"},"equity-justice-and-inclusion":{href:"/topics/equity-justice-and-inclusion/"},"health-and-social-care":{href:"/topics/health-and-social-care/"},innovation:{href:"/topics/innovation/"},"leadership-and-skills":{href:"/topics/leadership-and-skills/"},"life-in-government":{href:"/topics/life-in-government/"},policymaking:{href:"/topics/policymaking/"},"transport-and-infrastructure":{href:"/topics/transport-and-infrastructure/"},"work-and-the-economy":{href:"/topics/work-and-the-economy/"}}},partners:{href:"/partnerships/",onlyShow:"logged-out"},account:{order:["profile","settings","log-out"],className:"account",onlyShow:"logged-in",doTrack:!1,profile:{href:"/profiles/me"},settings:{href:"/profiles/me/manage-account"},"log-out":{href:"/user-onboarding/logout",className:"divider"}},buttons:{order:["login","signup"],login:{href:"/user-onboarding/login"},signup:{href:"/signup/?ref=header-banner",props:{variant:"primary"}}}},Pa=({id:e,isLoggedIn:t=!1,isDesktopVersion:n=!1,menus:r={},callback:a=()=>{},doTrack:i=null})=>{const s=ue.useIntl(),o=vc(Sr,e);if(!o||o.onlyShow&&(o.onlyShow==="logged-in"&&!t||o.onlyShow==="logged-out"&&t))return null;const l="doTrack"in o,u=i===null?l?o.doTrack:!0:i,c=e.includes("buttons.");let m=`header_${e.replaceAll(".","_")}`;o.hasVariantText&&(m+=`_logged${t?"In":"Out"}`);let f=!1;if(o.href){let w=o.gtmType||`${e}-click`;if(w.includes(".")){const A=w.split("."),k=A[A.length-2];w=`${k==="topics"?`${k}-`:""}${A[A.length-1]}`}f={href:o.href},u&&(f={...f,className:"gtm-trackable","data-gtm-event-type":w,"data-gtm-event-context":"HeaderButtons"}),c&&(f={...f,variant:"secondary",size:{mobile:"small",881:"large"},...o.props||{}})}const p=o.order&&o.order[0]&&o[o.order[0]],g=p&&o[o.order[0]].order,h=f&&window.location.pathname===o.href;let y={},b={};if(h&&(y={...y,"aria-current":"page"}),p){const w=o.menuId||e,A={onClick:k=>Pe.events.onClick(k,{id:w,callback:a,isOpen:r[w]}),onFocus:()=>Pe.events.onFocus({id:w}),onBlur:()=>Pe.events.onBlur({id:w,callback:a}),onMouseLeave:()=>Pe.events.onBlur({id:w,callback:a}),onMouseEnter:()=>Pe.events.onMouseEnter({id:w,callback:a})};n&&(g&&(y={...A,onKeyPress:k=>{k.key==="Enter"&&Pe.events.onClick(k,{id:w,callback:a,isOpen:r[w]})},tabIndex:"0","aria-haspopup":!0,"aria-expanded":r[w],"aria-controls":w}),b={hidden:w in r?!r[w]:!0}),g||(b={...b,...A})}return d.jsxs("li",{className:G({[o.className]:o.className,"has-submenu":p,parent:g,active:h}),...y,children:[f?x.createElement(c?Ee:"a",f,s.formatMessage({id:m})):s.formatMessage({id:m}),o.order&&d.jsx("ul",{...b,children:o.order.map(w=>{if(!o[w])return null;const A={isLoggedIn:t,isDesktopVersion:n,menus:r,callback:a,doTrack:l?u:null};return o[w].order?d.jsxs("li",{className:G({[o[w].className]:o[w].className}),children:[s.formatMessage({id:`${m}_${w}`}),d.jsx("ul",{children:o[w].order.map(k=>d.jsx(Pa,{id:`${e}.${w}.${k}`,...A},k))})]},w):d.jsx(Pa,{id:`${e}.${w}`,...A},w)})})]},e)};const Fw={height:67,height_desktop:83},Eo=({showNavigation:e=!0})=>{const t=ue.useIntl(),n=x.useContext(Mt),r=Qn(!0,!0),a=n&&typeof n.id=="string",i=x.useMemo(()=>Pe.getIsDesktopVersion(a,r),[a,r]),[s,o]=x.useReducer(jr,{headerIsVisible:!0,menus:{navigation:!1,search:!1,account:!1},focusElements:{navigation:{desktop:!1,default:!1},account:{desktop:!1,default:!1}}}),{headerIsVisible:l,menus:u,focusElements:c}=s,m=x.useRef(s);x.useEffect(()=>{m.current=s},[s]),wc({scrollPosition:Fw[`height${i.navigation?"_desktop":""}`],callbacks:{scrollUp:()=>{const h=m.current.menus;!i&&h.navigation||Pe.shouldChangeHeaderIsVisible(!0,h,o)},scrollDown:()=>{const h=m.current.menus;!i&&h.navigation||Pe.shouldChangeHeaderIsVisible(!1,h,o)}}});const f=(h,y,b=!1)=>{Pe.handleMenus({id:h,value:y,menus:m.current.menus,dispatch:o,forceHandle:b})},p=x.useRef(null),g=h=>{h.key==="Escape"&&["navigation","search","account"].forEach(y=>{m.current.menus[y]&&f(y,!1,!0)})};return x.useEffect(()=>{var h;return(h=document.getElementById("header"))==null||h.addEventListener("keydown",g),()=>{var y;(y=document.getElementById("header"))==null||y.removeEventListener("keydown",g)}},[]),Hn(()=>{u.navigation&&Pe.autoFocus({menu:"navigation",navigationRef:p,isDesktopVersion:i.navigation,focusElements:c,dispatch:o})},[u.navigation]),Hn(()=>{u.account&&Pe.autoFocus({menu:"account",navigationRef:p,isDesktopVersion:i.navigation,focusElements:c,dispatch:o})},[u.account]),n&&n.isLoading?null:d.jsxs(d.Fragment,{children:[d.jsxs("nav",{id:"header",className:G({"logged-in":a,"logged-out":!a,visible:l}),children:[d.jsx(Me,{element:"a",href:"#content-of-page",children:t.formatMessage({id:"header_skip"})}),d.jsx(xo,{variant:"monochrome"}),e&&d.jsxs(d.Fragment,{children:[!i.navigation&&d.jsx("button",{className:"menu-button gtm-trackable",onClick:h=>{h.preventDefault(),h.stopPropagation(),f("navigation",!u.navigation)},"data-gtm-event-type":"open-tab-menu-click","data-gtm-event-context":"HeaderLeft-Chevron","aria-haspopup":"true","aria-expanded":u.navigation,"aria-controls":"navigation",children:d.jsx(Me,{children:t.formatMessage({id:`header_menu_${u.navigation?"hide":"show"}`})})}),d.jsx("ul",{ref:p,id:"navigation",hidden:i.navigation||u.account?!1:!u.navigation,"data-showing":!i.navigation&&u.account?"account":"default",children:Sr.order.map(h=>d.jsx(Pa,{id:h,isLoggedIn:a,isDesktopVersion:i.navigation,menus:{navigation:u.navigation,account:u.account},callback:f},h))}),!i.search&&d.jsx("button",{className:"search toggle-search-button",onClick:h=>{h.preventDefault(),h.stopPropagation(),f("search",!u.search)},"aria-haspopup":"true","aria-expanded":u.search,"aria-controls":"search-form",children:d.jsx(Me,{children:t.formatMessage({id:`header_search_${u.search?"hide":"show"}`})})}),d.jsx(xf,{id:"global-search",handleToggle:{searchIsOpen:u.search,isDesktopVersion:i.search},gtmContext:"search-bar-header",gtmEvent:"form-submission"}),a?d.jsxs("button",{className:"account-button",onClick:h=>Pe.events.onClick(h,{id:"account",callback:f,isOpen:u.account}),onMouseEnter:()=>Pe.events.onMouseEnter({id:"account",callback:f}),onMouseLeave:()=>Pe.events.onBlur({id:"account",callback:f}),"aria-haspopup":"true","aria-expanded":u.account,"aria-controls":"navigation",children:[d.jsx(Me,{children:t.formatMessage({id:`header_account_${u.account?"hide":"show"}`})}),d.jsx(sn,{name:n&&n.name||"",src:n&&n.image&&n.image.thumbnail||""})]}):d.jsx("ul",{className:"sign-in-buttons",children:Sr.buttons.order.map(h=>d.jsx(Pa,{id:`buttons.${h}`},h))})]})]}),d.jsx("hr",{id:"content-of-page"}),d.jsx("div",{className:G("overlay",{open:u.navigation||u.account||!i.search&&u.search})})]})};const Tw=()=>{const e=ue.useIntl();return d.jsxs(d.Fragment,{children:[d.jsx(Eo,{}),d.jsx("div",{id:"content",children:d.jsx(an,{variant:"error",text:e.formatMessage({id:"pageLayout_error"})})}),d.jsx(wo,{})]})},Kf=({children:e,additionalContent:{prepended:t,appended:n}={},reportError:r,forceShow:a={},styling:i={},className:s="",locale:o="en"})=>{const{navigation:l=!0,footer:u=!0}=a,{background:c="default",variant:m="default",circle:f="default",modal:p="default"}=i,g=Dc();x.useEffect(()=>{window.scrollTo(0,0)},[g]);const h=oa(e,{locale:o}),y=oa(t,{locale:o}),b=oa(n,{locale:o}),w={};return c!=="default"&&(w[c]=!0),m!=="default"&&(w[m]=!0),f!=="default"&&(w[f]=!0),d.jsx(yh.ErrorBoundary,{onError:r,fallback:d.jsx(Tw,{}),children:d.jsx(x.Suspense,{fallback:null,children:d.jsxs("div",{id:"wrapper",className:G(s,w,{"has-footer":u}),children:[d.jsx(Eo,{showNavigation:l}),d.jsxs("main",{id:"content-wrapper",children:[y&&d.jsx("div",{className:G("additional-content prepended",{"large-modal":p==="large"}),children:y}),x.createElement(c==="bold"?yo:"div",{id:"content",children:h,className:G({"large-modal":p==="large"})})]}),b&&d.jsx("div",{className:"additional-content appended",children:b}),u&&d.jsx(wo,{}),d.jsx(Vf,{})]})})})},sc={default:"tags_",headerTopics:"header_topics_topics_"},Ki={topic:{Climate:"climate",CitiesAndLocalGovernment:"cities-and-local-government",DigitalAndData:"digital-and-data",Education:"education",EquityJusticeAndInclusion:"equity-justice-and-inclusion",HealthAndSocialCare:"health-and-social-care",Innovation:"innovation",LeadershipAndSkills:"leadership-and-skills",LifeInGovernment:"life-in-government",Policymaking:"policymaking",TransportAndInfrastructure:"transport-and-infrastructure",WorkAndTheEconomy:"work-and-the-economy"},"from the community":"community"},Sw={getTagDetails:e=>{if(e.includes("topic_")){if(e=Ki.topic[e.replace("topic_","")],e){const t=Sr.topics.topics[e].href;return t?{id:e,href:t,text:`${sc.headerTopics}${e}`}:null}return null}return Ki[e]?(e=Ki[e],{id:e,text:`${sc.default}${e}`}):null}};const jw=({tags:e=[],color:t="default",forceOneLine:n=!1,canHaveLinks:r=!0,className:a="",gtmType:i="tag-click",gtmContext:s="tags"})=>{const o=ue.useIntl();if(!e||e.length<1)return null;const l=[];return e.forEach(u=>{if(!u)return;const c=Sw.getTagDetails(u);c&&l.push(c)}),l.length<1?null:d.jsx("ul",{className:G("tags text-small",t,a,{"one-line":n}),children:l.map(u=>{const c=o.formatMessage({id:u.text});return d.jsx("li",{children:u.href&&r?d.jsx("a",{href:u.href,className:"gtm-trackable","data-gtm-event-type":i,"data-gtm-event-context":s,children:c}):c},u.id)})})};const Ow=({members:{data:e=[],total:t=e.length},hasNextPage:n=!1,loadNextPage:r=()=>{},gtmContext:a="member",gtmType:i="member-click",className:s=""})=>{const o=ue.useIntl();return e.length===0?null:d.jsxs("div",{className:G("members-list",s),children:[d.jsxs("h1",{children:[o.formatMessage({id:"membersList"}),d.jsx("span",{className:"count",children:t})]}),d.jsx("ul",{children:e.map((l,u)=>d.jsxs("li",{children:[d.jsx(tr,{member:l,gtmContext:a,gtmType:i}),l.isAdmin&&d.jsx(hn,{children:o.formatMessage({id:"membersList_admin"})})]},u))}),n&&d.jsx(Nr,{hasNextPage:n,loadNextPage:r,icon:{icon:"arrow-down",position:"right"},gtmContext:a})]})};const Pw=({element:e="p",data:{timeLeftToFinish:t,percentageCompleted:{inTime:n=0,inLessons:r=0},shouldShowTimes:a=!0},graph:i,styling:s={},className:o=""})=>{const l=ue.useIntl();let u=a?n:r;u>99?u=100:u<1&&(u=0);const{highlightPercentage:c=!1}=s;return x.createElement(e,{className:G("course-progression",o,{"highlight-percentage":c,"has-circle-graph":i==="circle"}),children:d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"percentage",children:l.formatMessage({id:"courseProgression_done"},{percent:m=>d.jsx("strong",{children:m}),number:u})}),u<100&&a&&d.jsx(Ga,{time:t,appendedText:l.formatMessage({id:"courseProgression_timeLeft"})}),d.jsx(Is,{progress:u,styling:{layout:i||"bar",size:i&&i==="circle"?"small":"default"}})]})})};const Zf=({element:e="span",sectionId:t,subsectionId:n,title:r,className:a=""})=>x.createElement(e,{className:G("lesson-name",a),"data-number":`${t}.${n}`,children:r});const Yf=({size:e="default",completionTime:t,icon:n,optional:r,type:a,children:i})=>{const s=ue.useIntl(),o=$a(`lessonType_${a}`)?s.formatMessage({id:`lessonType_${a}`}):Ac(a||"");return d.jsxs("small",{className:G("content-type",{[e]:e!=="default"}),children:[d.jsx("span",{className:G("type",n),children:o})," ",t>0&&!r&&d.jsx(Ga,{time:t})," ",i?d.jsx("span",{className:"additional",children:i}):null]})};const Nw=({course:{articles:e,canAccessCourse:t,description:n,hideTimes:r,isEnrolled:a,sectionId:i,sectionTime:s,slug:o,timeLeft:l,title:u},quizScores:c})=>{const m=ue.useIntl(),f="courseStructure_",p=u.toLowerCase().includes("course conclusion");return d.jsxs(La,{className:"course-structure",label:d.jsxs(d.Fragment,{children:[d.jsxs("small",{children:[m.formatMessage({id:`${f}section${p?"_end":""}`},{number:i})," ",!r&&s>=0&&d.jsx("span",{className:"time",children:a&&l===0?m.formatMessage({id:`${f}time_completed`}):d.jsx(Ga,{time:s,appendedText:a?m.formatMessage({id:`${f}time_left`}):""})})]}),d.jsx("h3",{children:u})]}),shouldAnimate:!0,children:[d.jsx("p",{children:n}),d.jsx("ol",{children:e&&e.length>0&&e.map(({completed:g,completionTime:h,contentType:y,icon:b,image:w,isIntroduction:A,optional:k,slug:E,subsectionId:T,title:j,type:z})=>{const R=a&&t||A,$={};return w&&($.style={"--image":`url(${w})`}),d.jsx("li",{className:G({article:y===fr.ARTICLE,discussion:y===fr.DISCUSSION,quiz:y===fr.QUIZ,completed:g&&y===fr.ARTICLE,locked:!R}),...$,children:d.jsx(kn,{href:R?`/microcourses/en/${o}/${E}`:void 0,fallbackElement:"span",className:"inner",gtmContext:`MicrocourseOutline${Bc(j)}`,gtmType:"article-click",children:d.jsxs(d.Fragment,{children:[d.jsx(Zf,{sectionId:i,subsectionId:T,title:j,className:"course-title"})," ",d.jsx(Yf,{completionTime:h,icon:b,optional:k,type:z,children:c&&c[E]&&d.jsx("span",{className:"quiz-score",children:`${c[E]}%`})})]})})},E)})})]})};const Rw=({isComplete:e=!1,onClick:t,...n})=>{const r=ue.useIntl();return n["data-gtm-event-context"]||(n["data-gtm-event-context"]="LessonIntroduction"),d.jsx(Ee,{...n,variant:"tertiary",icon:e?{icon:"check-inside-circle_no-overlap_inverted"}:{icon:"check-inside-circle_no-overlap",hover:"check-inside-circle_no-overlap_inverted"},onClick:t,className:G("mark-complete-button center gtm-trackable",{completed:e}),"data-gtm-event-type":"mark-as-complete",disabled:e,children:r.formatMessage({id:`markCompleteButton${e?"_completed":""}`})})};let aa=null;const ut="discussion_form_",Qa=({id:e,content:t={type:"response",slugs:{}},userHasPermissions:n=!0,meta:r={isLoading:!1,isInWrapper:!1,isEditing:!1,showTitle:!1,showSuccessMessage:!0},placeholder:a,maxLength:i=0,forceShow:s={cancel:!1,error:!1},functions:o={create:()=>{},handleSaveEdit:()=>{},handleCancel:()=>{},callback:()=>{},getUsers:()=>Promise.resolve([]),props:{create:{projectNames:["questions-answers"]}}},data:l={},gtmContext:u="DiscussionForm"})=>{var R,$,M;const c=ue.useIntl(),m=x.useContext(Mt),[f,p]=x.useState(r.isEditing&&r.isEditing.text||""),[g,h]=x.useState(s.error||!1),[y,b]=x.useState(!1);if(r.isLoading)return d.jsx(wt,{className:"discussion-card discussion-form","data-testid":"loading-placeholder"});const w=C=>{p(C);let B;!m||!m.id?B=Ft(c.formatMessage,`${ut}error_loggedOut`,t.type,"action"):n?i>0&&C.length>=i&&(B=`${ut}error_tooLong`):B=Ft(c.formatMessage,`${ut}error_noPermission`,t.type,"action"),B?h(B):g&&h(!1)};let A=`${t.type}-form`;if(t.type==="response"||t.type==="reply"){const C=((R=t.slugs)==null?void 0:R.reply)||(($=t.slugs)==null?void 0:$.answer)||((M=t.slugs)==null?void 0:M.question)||"";C&&(A=`${A}-${C.slice(-15)}`)}e&&(A=`${e}-${A}`);const k=async C=>{var F;if(C.preventDefault(),C.stopPropagation(),!m||!m.id||!n||T)return;aa&&clearTimeout(aa),b("submitting");const B=window.location.pathname;try{let N;switch(t.type){case"post":N=await o.create({content:f});break;case"question":N=await o.create({title:f,authorId:m&&m.id,...(F=o.props)==null?void 0:F.create});break;case"response":N=await o.create({questionSlug:t.slugs.question},{body:f,authorId:m&&m.id,contentPath:B});break;case"reply":N=await o.create({questionSlug:t.slugs.question,answerSlug:t.slugs.answer},{body:f,authorId:m&&m.id,contentPath:B});break;default:break}await Th(1e3),o.callback&&await o.callback(N),aa=setTimeout(()=>{p(""),b("submitted");const L=new Event("discussionFormSubmitted");document.dispatchEvent(L),E()},500)}catch(N){const L=N;let W=`${ut}error`;L!=null&&L.message.includes("entry already exists")&&(W=Ft(c.formatMessage,`${ut}error_alreadyExists`,t.type,"action")),L!=null&&L.message.includes("429")?W=Ft(c.formatMessage,`${ut}error_tooMany`,t.type,"action"):L!=null&&L.message.includes("400")&&(W=`${ut}error`),h(W),E()}},E=()=>{aa=setTimeout(()=>{h(!1),b(!1)},5e3)},T=!f||!Mh(f),j=y==="submitting",z=[];return(r.isEditing&&!j||s.cancel)&&z.push({variant:"secondary",size:{mobile:"small",600:"medium"},onClick:o.handleCancel,className:"gtm-trackable","data-gtm-event-context":u,"data-gtm-event-type":`cancel-${t.type}-click`,disabled:!s.cancel&&(!m||!m.id||!f),children:c.formatMessage({id:`${ut}cancel`})}),z.push({variant:"primary",size:{mobile:"small",600:"medium"},onClick:C=>{if(r.isEditing){b("submitting"),o.handleSaveEdit&&o.handleSaveEdit(f);return}k(C)},className:"gtm-trackable","data-gtm-event-context":u,"data-gtm-event-type":`${r.isEditing?"save":"submit"}-${t.type}-click`,"data-testid":"save-button",disabled:!m||!m.id||!n||T||j||r.isEditing&&f===r.isEditing.text,children:c.formatMessage({id:`${ut}${j?r.isEditing?"saving":"posting":r.isEditing?"save":"post"}`})}),d.jsxs("form",{id:A,className:G("discussion-card discussion-form",{"no-styling":r.isInWrapper&&r.isEditing}),"data-testid":`discussion-${t.type}-form`,children:[(r==null?void 0:r.showTitle)&&!r.isEditing&&["question"].includes(t.type)&&d.jsx("h2",{children:Ft(c.formatMessage,`${ut}title`,t.type,"action")}),d.jsx(tr,{member:m||"community",gtmContext:u,gtmType:"profile-click"}),d.jsx(Me,{element:"label",showOnFocus:!1,htmlFor:`${A}-input`,children:Ft(c.formatMessage,`${ut}label`,t.type,"action")}),d.jsx(yf,{id:`${A}-input`,value:y==="submitting"&&!g?"":f,placeholder:a||Ft(c.formatMessage,`${ut}placeholder`,t.type,"action"),maxLength:i,functions:{onChange:w,getUsers:o.getUsers},data:l,autoFocus:!!r.isEditing,"aria-invalid":!!g,"aria-errormessage":"error-message"}),d.jsx("small",{children:Ft(c.formatMessage,`${ut}explainer`,t.type,"action",{a:C=>d.jsx("a",{href:"https://about.apolitical.co/q-and-a-community-guidelines",target:"_blank",className:"gtm-trackable","data-gtm-event-context":u,"data-gtm-event-type":"community-guidelines-link",rel:"noreferrer",children:C})})}),d.jsx(En,{buttons:z}),y==="submitted"&&r.showSuccessMessage&&d.jsx(wr,{className:"success","data-testid":"success",children:Ft(c.formatMessage,`${ut}success`,t.type,"action")}),g&&d.jsx(wr,{id:"error-message",className:"error","data-testid":"error",children:s.error?s.error:typeof g=="string"?g.includes(" ")?g:c.formatMessage({id:g},{action:c.formatMessage({id:`discussion_action_${t.type}`}),maxLength:i}):g})]})},ko=({form:e,membershipRequiredToPost:{isMember:t,required:n,join:r,leave:a,notMemberStateText:i}})=>{if(n&&!t)return d.jsx(an,{text:i,button:{breakpoints:{mobile:!0,901:!1},component:d.jsx(Co,{isShort:!0,functions:{join:r,leave:a}})}});const{content:s,functions:o,meta:l,...u}=e;return d.jsx(Qa,{content:{type:(s==null?void 0:s.type)||"reply",slugs:(s==null?void 0:s.slugs)||{}},functions:{...o,create:(o==null?void 0:o.create)||(()=>{})},meta:{...l,isEditing:(l==null?void 0:l.isEditing)||!1,showSuccessMessage:!1},...u,id:`add-post-${u.id||""}`})},Mw={showForm:!1},Ja=x.createContext(Mw),Gf=({children:e})=>{const[t,n]=x.useState({showForm:!1});return d.jsx(Ja.Provider,{value:{...t,updateConversation:n},children:e})},Iw=({question:e,answer:t,reply:n})=>({...e&&{questionSlug:e},...t&&{answerSlug:t},...n&&{replySlug:n}}),$w=(e,t=10)=>!e||e.length===0?[]:e.slice(0,t);const Ss=({icon:e,...t})=>d.jsx(Ee,{className:"discussion-button",variant:"tertiary",icon:e,...t});let xr=!1;const Zi=()=>{xr!==!1&&(clearTimeout(xr),xr=!1)},Yi=5;let Gi=null;const Qf=({element:e="div",likes:t=0,peopleWhoLiked:n=!1,isShort:r=!0,userLiked:a=!1,content:i={type:"reply",slugs:{}},canLike:s=!0,functions:{createLike:o=()=>{},deleteLike:l=()=>{}}={}})=>{const u=ue.useIntl(),c={numberOfLikes:t,userLikedContent:a,ignoreInteractions:!1,showLikers:!1,tabbableLink:0},[m,f]=x.useReducer(jr,c),{numberOfLikes:p,userLikedContent:g,ignoreInteractions:h,showLikers:y,tabbableLink:b}=m;x.useEffect(()=>{f([{type:"userLikedContent",value:a}])},[a]);const w=x.useMemo(()=>$w(n,Yi),[n]),A=j=>{if(j.preventDefault(),j.stopPropagation(),f([{type:"showLikers",value:!1}]),xr)return Zi(),!1;if(Zi(),h||!s)return!1;xr=setTimeout(k,350)},k=async()=>{if(Zi(),h||!s)return!1;let j=g?p-1:p+1;j<0&&(j=0),f([{type:"ignoreInteractions",value:!0},{type:"numberOfLikes",value:j},{type:"userLikedContent",value:!g}]);try{if(i&&i.slugs){const z=Iw(i.slugs);g?await l(z):await o({...z,payload:{contentPath:window.location.pathname}})}}catch{f([{type:"numberOfLikes",value:t},{type:"userLikedContent",value:a}])}finally{f([{type:"ignoreInteractions",value:!1}])}},E=()=>{Gi=setTimeout(()=>{f([{type:"showLikers",value:!1}])},500)},T=()=>{Gi&&clearTimeout(Gi)};return x.createElement(e,{className:"likes-wrapper",onKeyDown:j=>{j.key==="Escape"&&f([{type:"showLikers",value:!1}])},onMouseEnter:()=>{T(),f([{type:"showLikers",value:!0}])},onMouseLeave:()=>{E()}},d.jsxs(d.Fragment,{children:[d.jsx(Ss,{className:G("discussion-button text-medium action-button",{"show-spinner":h,"is-liked":g,disabled:!s}),icon:{icon:g?"heart":"heart_empty",animate:"bounce"},disabled:!s,"data-testid":"like-button","data-gtm-event-context":"Likes","data-gtm-event-type":`like-${i.type}-click`,onClick:A,screenreaderText:s?u.formatMessage({id:`discussion_likes_${g?"unlike":"like"}`},{action:u.formatMessage({id:`discussion_action_${i.type}`})}):!1,"aria-pressed":g,children:d.jsx("span",{"data-testid":"number-of-likes",className:"number-of-likes",children:u.formatMessage({id:`discussion_likes${r?"_short":""}`},{number:p})})}),n&&d.jsxs(d.Fragment,{children:[d.jsx(Me,{element:"button",className:"tertiary small icon navigation_arrow",onFocus:()=>{T()},onBlur:()=>E,onClick:j=>{var R;j.preventDefault(),j.stopPropagation(),T(),f([{type:"showLikers",value:!0}]);const z=(R=j.currentTarget.nextSibling)==null?void 0:R.childNodes[0];if(z){const $=z.querySelector("li:first-child a");$&&(f([{type:"tabbableLink",value:0}]),setTimeout(()=>{$.focus()},100))}},onKeyDown:j=>{j.key==="Escape"&&(j.preventDefault(),j.stopPropagation(),E())},"aria-expanded":y,"aria-controls":`likes-tooltip-${i.slug}`,children:d.jsx(Me,{showOnFocus:!1,children:u.formatMessage({id:"discussion_likes_show"},{action:i.type})})}),d.jsx(Jn,{id:`likes-tooltip-${i.slug}`,isOpen:y,isLoading:n.length===0,children:n.length&&d.jsxs("ul",{children:[w.map((j,z)=>{if(typeof j=="string"||!j.name)return null;const R={};return b!==z&&(R.tabIndex=-1),d.jsx("li",{"data-index":z,children:d.jsx(kn,{href:j.id?`/profiles/${j.id}`:void 0,gtmContext:"Likes",gtmType:"liked-name-click",onClick:$=>$==null?void 0:$.stopPropagation(),onFocus:()=>T(),onKeyDown:$=>{var N,L,W,ae;if(!$||!["ArrowUp","ArrowDown"].includes($.key||""))return;$.stopPropagation(),$.preventDefault();const M=$.key==="ArrowUp"?"up":"down",C=(N=$.currentTarget)==null?void 0:N.parentElement;let B=C==null?void 0:C.nextElementSibling;if(M==="up"){const ne=C==null?void 0:C.previousElementSibling;ne?B=ne:(B=(L=C==null?void 0:C.parentElement)==null?void 0:L.lastElementChild,(B==null?void 0:B.getAttribute("data-index"))==="-1"&&(B=B==null?void 0:B.previousElementSibling))}else(!B||(B==null?void 0:B.getAttribute("data-index"))==="-1")&&(B=(W=C==null?void 0:C.parentElement)==null?void 0:W.firstElementChild);if(!B)return;const F=(B==null?void 0:B.getAttribute("data-index"))||"0";f([{type:"tabbableLink",value:F}]),(ae=B==null?void 0:B.querySelector("a"))==null||ae.focus()},...R,children:j.name})},j.id||window.btoa(j.name))}),t>Yi&&d.jsx("li",{"data-index":"-1",children:u.formatMessage({id:"discussion_likes_more"},{number:t-Yi})})]})})]})]}))},oc=e=>{const t={};return Object.keys(e).forEach(n=>n.includes("Id")?t[n]=e[n]:t[`${n}Slug`]=e[n]),t},Xa=(e,t)=>e&&!t,Qi=({children:e,class:t,...n})=>{const r={...n,class:G("subtle",t)};return d.jsx("blockquote",{...r,children:e})},Lw=280,zw=(e,t,n)=>{let r=t?Wn(e,Lw):e;return r=r.trim(),n&&(r=r.replace(Ns,(a,i)=>{const s=n[i];return s?`<a href="/profiles/${s.id}" class="mentioned-user">@${s.data.name}</a>`:a})),r};const zt="discussion_",qw=195,Rr=({element:e="div",content:t,userHasPermissions:n=!0,isLoading:r=!1,originalAuthorId:a,forceHide:i={actionBar:!1,comments:!1,likes:!1},functions:{content:{createContent:s,deleteContent:o,updateContent:l}={createContent:async()=>{},deleteContent:async()=>{},updateContent:async()=>{}},likes:{createLike:u,deleteLike:c}={createLike:()=>{},deleteLike:()=>{}},comments:{openComments:m}={openComments:()=>{}},mentions:{getUsers:f}={getUsers:()=>Promise.resolve([])}},links:p={},className:g,gtmContext:h="DiscussionAnswer",children:y,isTruncated:b=!1})=>{const w=ue.useIntl(),A=x.useContext(Mt),k=x.useContext(Ja),{author:E,canLike:T,createdAt:j,id:z,likes:R=0,userLiked:$,comments:M=0,mentions:C}=t,B=A&&A.id&&typeof E!="string"&&E.id&&E.id===A.id||!1,F=typeof T=="boolean"?T:n?!B:!1,N=B&&(!t.createdAt||Ah(t.createdAt,10,"seconds")),L=x.useRef(null),[W,ae]=x.useState({body:t&&t.body||"",isEditing:!1,didEdit:t&&t.isEdited||!1}),[ne,D]=x.useState(!1),[U,X]=x.useState(N?"highlighted":"default"),[_,S]=x.useState("");x.useEffect(()=>{const H=L.current;if(!(!H||U==="default"))return document.addEventListener("discussionFormSubmitted",q),H.addEventListener("transitionend",I),()=>{document.removeEventListener("discussionFormSubmitted",q),H.removeEventListener("transitionend",I)}},[]),x.useEffect(()=>{ae({...W,body:t&&t.body||"",didEdit:t&&t.isEdited||!1})},[t.isEdited]);const q=()=>{setTimeout(()=>{X("fading")},1e3)},I=({propertyName:H})=>{H==="background-color"&&X(de=>(de==="default"&&(document.removeEventListener("discussionFormSubmitted",q),L.current&&L.current.removeEventListener("transitionend",I)),de==="fading"?"default":de))};if(r||!t||t.type==="answer"&&(!t.slugs||!t.slugs.question))return d.jsx(wt,{className:"discussion-card discussion-post"});const V=zw(W.body,b,C),te=async H=>{H||(H=""),S("");try{if(!gc(H,W.body)){const de=t.type==="question"?{title:H}:{body:H};await l(oc(t.slugs),de)}ae({body:H,isEditing:!1,didEdit:!0})}catch{S(`${zt}form_error`)}},ee=()=>{k&&k.updateConversation&&k.updateConversation({showForm:!0}),setTimeout(()=>{var je,Oe,He;const de=`reply-form-${(t.type==="answer"?t.slug:((je=t.slugs)==null?void 0:je.reply)||((Oe=t.slugs)==null?void 0:Oe.answer)||((He=t.slugs)==null?void 0:He.question)||"").toLowerCase().slice(-15)}`,pe=document.getElementById(de),we=document.getElementById(`${de}-input`);we&&we.focus(),pe&&pe.scrollIntoView({behavior:"smooth"})},0)},ie=async()=>{D(!1);try{await o(oc(t.slugs))}catch{S("delete-error")}},he=[{text:w.formatMessage({id:`${zt}moreMenu_report`}),onClick:H=>{H.stopPropagation()},href:`mailto:community@apolitical.co?subject=${encodeURI(w.formatMessage({id:`${zt}report_subject`}))}&body=${encodeURI(w.formatMessage({id:`${zt}report_body`},{contentType:t.type||"",contentSlug:t.slug||"",contentUrl:`${window.origin}${typeof process<"u"&&process.env.PUBLIC_URL||""}/${t.slugs.question||""}`}))}`,icon:"flag"}];return n&&B&&he.push({text:w.formatMessage({id:`${zt}moreMenu_edit`}),onClick:()=>ae({...W,isEditing:!0}),icon:"pencil-paper",className:"gtm-trackable","data-gtm-event-context":h,"data-gtm-event-type":`edit-${t.type}-click`},{text:w.formatMessage({id:`${zt}moreMenu_delete`}),onClick:H=>{H.preventDefault(),H.stopPropagation(),D(!0)},icon:"trash",className:"gtm-trackable","data-gtm-event-context":h,"data-gtm-event-type":`delete-${t.type}-click`,...Lf(`delete-${t.slug}-modal`,ne)}),x.createElement(e,{className:G("discussion-post",g,{[U]:!g||!g.includes("highlighted-text-box"),"has-link":p.post&&!W.isEditing}),ref:L,"data-testid":`discussion-${t.type}-thread`,"data-gtm-event-context":`${h}-post-click`,onClick:H=>{!p.post||W.isEditing||(H.preventDefault(),H.stopPropagation(),window.location.href=p.post)},children:d.jsxs(d.Fragment,{children:[d.jsxs("div",{id:z||t.slug,className:G("discussion-card",t.type,{editing:W.isEditing,"has-link":p.post&&!W.isEditing}),children:[!W.isEditing&&d.jsx(tr,{member:E,additionalContent:{createdAt:j,didEdit:W.didEdit},className:typeof E!="string"&&E.id===a?"highlighted":"",gtmContext:h,gtmType:"profile-click"}),W.isEditing?d.jsx(Qa,{id:`editing-${t.slug}`,content:{type:t.type,slugs:t.slugs},userHasPermissions:n,meta:{isLoading:r,isInWrapper:!0,isEditing:{text:W.body}},maxLength:t.type==="question"?250:5e4,forceShow:{error:_!==""&&_!=="delete-error"?w.formatMessage({id:_},{action:w.formatMessage({id:`discussion_action_${t.type}`})}):!1},functions:{create:s,handleSaveEdit:te,handleCancel:()=>{S(""),ae({...W,isEditing:!1})},getUsers:f},gtmContext:`${h}Form`,data:{mentions:t.mentions}}):p.post?d.jsxs("a",{href:p.post,children:[(t==null?void 0:t.title)&&d.jsx("p",{className:"content-title",children:t==null?void 0:t.title}),V.length>qw?d.jsx(Ic,{text:V,markdownOptions:{overrides:{a:as,blockquote:{component:Qi}}}}):d.jsx(Un,{options:{overrides:{a:as,blockquote:{component:Qi}}},children:V})]}):d.jsx(Un,{options:{wrapper:t.type==="question"?"h1":x.Fragment,forceWrapper:t.type==="question",forceInline:t.type==="question",forceBlock:t.type!=="question",overrides:{blockquote:{component:Qi}}},children:V}),!W.isEditing&&!(i!=null&&i.actionBar)&&d.jsxs("ul",{className:G("actions text-medium",t.type),"data-testid":`${t.type}-actions`,children:[!i.likes&&d.jsx(Qf,{element:"li",likes:R,isShort:!1,userLiked:$,content:{type:t.type,slugs:t.slugs,slug:t.slug},canLike:F,peopleWhoLiked:t.peopleWhoLiked,functions:{createLike:u,deleteLike:c}}),!i.comments&&(["question","post"].includes(t.type)||p.comments||typeof m=="function")&&d.jsx("li",{children:d.jsx(Ss,{onClick:H=>{H.preventDefault(),H.stopPropagation(),p.comments&&(window.location.href=p.comments),typeof m=="function"&&m()},icon:{icon:"speech-bubble_square_thick"},"data-gtm-event-context":h,"data-gtm-event-type":`answer-${t.type}-click`,screenreaderText:w.formatMessage({id:`${zt}comments_screenReader`},{count:M}),children:w.formatMessage({id:`${zt}comments`},{count:M})})}),(t.type==="answer"||t.type==="reply")&&d.jsx("li",{children:d.jsx(Ss,{styling:{muted:!0},onClick:ee,icon:{icon:"speech-bubble_square_thick"},children:w.formatMessage({id:`${zt}reply`})})}),d.jsx(Wf,{element:"li",id:`more-${t.slug}`,options:he})]})]}),y,d.jsx(Pr,{id:`delete-${t.slug}-modal`,isOpen:ne,functions:{onOpen:()=>{},onClose:()=>D(!1)},forceShow:{error:_==="delete-error"?w.formatMessage({id:"discussion_delete_error"},{action:w.formatMessage({id:`discussion_action_${t.type}`})}):!1},title:w.formatMessage({id:"discussion_delete_title"},{action:w.formatMessage({id:`discussion_action_${t.type}`})}),buttons:[{variant:"secondary",onClick:()=>D(!1),children:w.formatMessage({id:"discussion_delete_cancel"})},{variant:"primary",className:"destructive",onClick:ie,children:w.formatMessage({id:"discussion_delete_delete"})}],gtmContext:`${t.type.charAt(0).toUpperCase()}${t.type.slice(1)}:${t.slug}`,children:d.jsx(ue.FormattedMessage,{id:"discussion_delete_text",values:{p:H=>d.jsx("p",{children:H}),action:w.formatMessage({id:`discussion_action_${t.type}`})}})})]})})};const Ji="discussion_responses_",Jf=({type:e="answer",responses:t=0})=>{const n=ue.useIntl();return t=parseInt(t),d.jsxs("div",{className:"responses-heading",children:[d.jsx("h4",{children:n.formatMessage({id:`${Ji}title`},{action:n.formatMessage({id:`${Ji}${e}`}),count:t})}),t===0&&d.jsx("p",{children:Ft(n.formatMessage,`${Ji}empty`,e,e)})]})};const Xf=({loadMore:{isLoading:e,hasNextPage:t,loadNextPage:n}={isLoading:!1,hasNextPage:!1,loadNextPage:()=>{}},form:r,children:a})=>{const i=ue.useIntl(),s=x.useContext(Ja),o=oa(a,{element:"li"});return d.jsxs("div",{className:G("thread-wrapper",{"empty-thread":!o}),children:[!Object.is(o,null)&&d.jsx("ul",{className:"thread",children:o}),!e&&d.jsx(Nr,{hasNextPage:t,loadNextPage:n,size:"small",styling:{muted:!0},icon:{icon:"arrow_corner-down_right",position:"left"},messages:{button:i.formatMessage({id:"discussion_thread_loadMore"}),error:i.formatMessage({id:"loadMore_error"})}}),r&&s.showForm&&d.jsx(Qa,{...r})]})},Ww="post",Hw="reply",eh="00000000-0000-0000-0000-000000000000";function _o({queryClient:e,queryKey:t}){function n(r,a,i){e.setQueryData(t,i)}return n}function Bo({queryClient:e,queryKey:t}){async function n(r){await e.cancelQueries({queryKey:t});const a=e.getQueryData(t);return e.setQueryData(t,r),a}return n}function Uw(){return{latest_reactions:{like:[],reply:[]},reaction_counts:{like:0,reply:0},own_reactions:{like:[],reply:[]}}}function Vw(){return{latest_children:{like:[],reply:[]},children_counts:{like:0,reply:0},own_children:{like:[],reply:[]}}}function th(e){const{id:t="",name:n="",organization:r="",jobTitle:a="",image:i={}}=e,{thumbnail:s=""}=i;return{id:t,data:{name:n,organization:r,jobTitle:a,thumbnail:s}}}function Kw({content:e}){return{content:e,id:eh,time:new Date().toISOString(),verb:Ww}}function uc({activity:e,user:t}){return{...e,actor:th(t),...Uw()}}function Na({activity:e,reaction:t}){var n,r,a;t?(e.latest_reactions={...e.latest_reactions||{},like:[...((r=e.latest_reactions)==null?void 0:r.like)||[],t]},e.own_reactions={...e.own_reactions||{},like:[...((a=e.own_reactions)==null?void 0:a.like)||[],t]}):e.reaction_counts={...e.reaction_counts||{},like:(n=e.reaction_counts)!=null&&n.like?e.reaction_counts.like+1:1}}function nh({activity:e,user:t}){var n,r,a;e.reaction_counts={...e.reaction_counts||{},like:(n=e.reaction_counts)!=null&&n.like?e.reaction_counts.like-1:0},t!=null&&t.id&&(e.latest_reactions={...e.latest_reactions||{},like:(((r=e.latest_reactions)==null?void 0:r.like)||[]).filter(({user_id:i})=>i!==t.id)},e.own_reactions={...e.own_reactions||{},like:(((a=e.own_reactions)==null?void 0:a.like)||[]).filter(({user_id:i})=>i!==t.id)})}function Zw({activityId:e,replyId:t,content:n}){return{activity_id:e,data:{content:n},id:eh,kind:Hw,parent:t||""}}function lc({reply:e,user:t}){const n=th(t);return{...e,user_id:n.id,user:n,...Vw()}}function cc({reply:e,reaction:t}){var n,r,a;t?(e.latest_children={...e.latest_children||{},like:[...((r=e.latest_children)==null?void 0:r.like)||[],t]},e.own_children={...e.own_children||{},like:[...((a=e.own_children)==null?void 0:a.like)||[],t]}):e.children_counts={...e.children_counts||{},like:(n=e.children_counts)!=null&&n.like?e.children_counts.like+1:1}}function Yw({reply:e,user:t}){var n,r,a;e.children_counts={...e.children_counts||{},like:(n=e.children_counts)!=null&&n.like?e.children_counts.like-1:0},t!=null&&t.id&&(e.latest_children={...e.latest_children||{},like:(((r=e.latest_children)==null?void 0:r.like)||[]).filter(({user_id:i})=>i!==t.id)},e.own_children={...e.own_children||{},like:(((a=e.own_children)==null?void 0:a.like)||[]).filter(({user_id:i})=>i!==t.id)})}const rh=e=>{const t=new CustomEvent("discussionPostAdded",{detail:e});document.dispatchEvent(t)};let dc,Xi=0;const ah=()=>{x.useEffect(()=>(document.addEventListener("discussionPostAdded",e),()=>{document.removeEventListener("discussionPostAdded",e)}),[]);const e=t=>{const n=t.detail;if(!n)return;clearTimeout(dc);const r=document.getElementById(n);if(r){r.scrollIntoView({behavior:"smooth",block:"start"}),Xi=0;return}Xi++,!(Xi>10)&&(dc=setTimeout(()=>{e(t)},50))}},Gn=Object.freeze({id:"some-user-id-1",name:"some user name 1",organization:"some user organization 1",jobTitle:"some user job title 1",image:{thumbnail:"https://some-user-thumbnail.com/avatar1.png"},isLoading:!1}),rn=Object.freeze({id:"some-user-id-2",name:"some user name 2",organization:"some user organization 2",jobTitle:"some user job title 2",image:{thumbnail:"https://some-user-thumbnail.com/avatar2.png"},isLoading:!1}),ih=Object.freeze({actor:`SU:${Gn.id}`,content:"some content 1",duration:"5.53ms",feed_id:"some-feed-id-1",foreign_id:"post:some-foriegn-id-1",id:"some-activity-id-1",object:"comment",time:"2023-11-24T17:52:36.162000",verb:"post"}),Gw=Object.freeze({actor:`SU:${rn.id}`,content:"some content 2",duration:"5.53ms",feed_id:"some-feed-id-2",foreign_id:"post:some-foriegn-id-2",id:"some-activity-id-2",object:"comment",time:"2023-11-24T17:54:36.162000",verb:"post"}),Qw=Object.freeze({actor:`SU:${Gn.id}`,content:"some content 3",duration:"5.53ms",feed_id:"some-feed-id-3",foreign_id:"post:some-foriegn-id-3",id:"some-activity-id-3",object:"comment",time:"2023-11-24T17:56:36.162000",verb:"post"}),Jw=Object.freeze({actor:`SU:${rn.id}`,content:"some content 4",duration:"5.53ms",feed_id:"some-feed-id-4",foreign_id:"post:some-foriegn-id-4",id:"some-activity-id-4",object:"comment",time:"2023-11-24T17:54:36.162000",verb:"post"});Object.freeze({id:"some-reaction-id-1",activity_id:ih.id,kind:"like",created_at:"2023-11-24T17:58:36.162000",data:{},parent:"",updated_at:"2023-11-24T17:58:36.162000",user_id:rn.id,children_counts:{},latest_children:{},latest_children_extra:{},own_children:{},user:{id:rn.id,data:{},created_at:"2023-11-24T17:58:36.162000",updated_at:"2023-11-24T17:58:36.162000"}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-1",user_id:rn.id,user:{id:rn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:ih.id,data:{content:"Some content 1..."},parent:"",latest_children:{},children_counts:{}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-2",user_id:Gn.id,user:{id:Gn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Gw.id,data:{content:"Some content 2..."},parent:"",latest_children:{},children_counts:{}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-3",user_id:rn.id,user:{id:rn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Qw.id,data:{content:"Some content 3..."},parent:"",latest_children:{},children_counts:{}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-3",user_id:Gn.id,user:{id:Gn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Jw.id,data:{content:"Some content 4..."},parent:"",latest_children:{},children_counts:{}});function Xw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a,user:i}){const{mutate:s}=We.useMutation({mutationFn:e,onMutate:o=>t(l=>{const u=uc({activity:Kw(o),user:i});return fc(u,l)}),onError:n,onSuccess:(o,l,u)=>{const c=uc({activity:o,user:i});r.setQueryData(a,fc(c,u,!0)),setTimeout(()=>{rh(c.id)},0)}});return s}function eE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({activityId:a,content:i})=>t(s=>{const o=Ra(a,s);return o&&(o.content=i),s}),onError:n});return r}function tE({queryFns:{create:e,edit:t,like:n,list:r,remove:a,unlike:i},queryKey:s}){const o=We.useQueryClient(),l=Ya(),u={queryClient:o,queryKey:s},c={mutationHandlers:{error:_o(u),mutate:Bo(u)},user:l,...u},m=Xw({...c,mutationFn:e}),f=eE({...c,mutationFn:t}),p=nE({...c,mutationFn:n}),g=aE({...c,mutationFn:a}),h=iE({...c,mutationFn:i}),{activities:y,...b}=rE({queryKey:s,queryFn:r});return{activities:y,mutations:{create:m,edit:f,remove:g,like:p,unlike:h},user:l,...b}}function nE({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=We.useMutation({mutationFn:e,onMutate:({activityId:s})=>t(o=>{const l=Ra(s,o);return l&&Na({activity:l}),o}),onError:n,onSuccess:(s,{activityId:o},l)=>{const u=Ra(o,l);u&&Na({activity:u,reaction:s}),r.setQueryData(a,l)}});return i}function rE({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}=We.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:{next:null},getNextPageParam:o=>(o==null?void 0:o.next)||null});return{activities:oE(n),error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}}function aE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({activityId:a})=>t(i=>sE(a,i)),onError:n});return r}function iE({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=We.useMutation({mutationFn:e,onMutate:({activityId:i})=>t(s=>{const o=Ra(i,s);return o&&nh({activity:o,user:r}),s}),onError:n});return a}function fc(e,t,n=!1){return t?(n?t.pages[0].results[0]=e:t.pages[0].results=[e,...t.pages[0].results],t):{pages:[{next:"",results:[e]}],pageParams:[""]}}function Ra(e,t){if(t)for(const{results:n}of t.pages){const r=n.find(({id:a})=>a===e);if(r)return r}}function sE(e,t){for(const{results:n}of t.pages){const r=n.findIndex(({id:a})=>a===e);if(r!==-1){n.splice(r,1);break}}return t}function oE(e){var t;return((t=e==null?void 0:e.pages)==null?void 0:t.reduce((n,{results:r})=>[...n,...r],[]))||[]}const uE=({basePath:e,parentId:t,isMember:n,functions:{activities:r,mentions:a,join:i,leave:s}})=>{const o=ue.useIntl(),{activities:l,error:u,fetchNextPage:c,hasNextPage:m,isLoading:f,mutations:{create:p,edit:g,remove:h,like:y,unlike:b},user:w}=tE({queryKey:[e,t,"activities"],queryFns:r});return ah(),u?d.jsx(an,{variant:"error",text:u.message}):d.jsxs("section",{children:[d.jsx(ko,{form:{content:{type:"post",slugs:{}},functions:{create:p,getUsers:a.getUsers},meta:{isEditing:!1,showSuccessMessage:!1}},membershipRequiredToPost:{isMember:n,required:!0,join:i,leave:s,notMemberStateText:o.formatMessage({id:"community_joinToPost"})}}),l==null?void 0:l.map((A,k)=>{var L,W,ae,ne,D,U,X,_;const{id:E,own_reactions:T,latest_reactions:j,reaction_counts:z,mentioned_users:R}=A,$=(((L=j==null?void 0:j.like)==null?void 0:L.length)||0)>0,M=(((W=T==null?void 0:T.like)==null?void 0:W.length)||0)>0,C=M?T==null?void 0:T.like[0].id:"",B=$?(ae=j==null?void 0:j.like)==null?void 0:ae.map(S=>{var q,I,V;return{id:(q=S==null?void 0:S.user)==null?void 0:q.id,name:(V=(I=S==null?void 0:S.user)==null?void 0:I.data)==null?void 0:V.name}}):!1,F=A==null?void 0:A.actor,N=(F==null?void 0:F.id)===(w==null?void 0:w.id);return d.jsx(x.Fragment,{children:d.jsx(Rr,{content:{type:"post",title:A==null?void 0:A.title,body:A==null?void 0:A.content,canLike:Xa(n,N),createdAt:(A==null?void 0:A.time)||"",slugs:{question:`${e}/${t}`,answer:E},slug:E,author:{id:F==null?void 0:F.id,name:(ne=F==null?void 0:F.data)==null?void 0:ne.name,organization:(D=F==null?void 0:F.data)==null?void 0:D.organization,jobTitle:(U=F==null?void 0:F.data)==null?void 0:U.jobTitle,location:(X=F==null?void 0:F.data)==null?void 0:X.location,image:{thumbnail:((_=F==null?void 0:F.data)==null?void 0:_.thumbnail)||void 0}},userLiked:M,likes:(z==null?void 0:z.like)||0,comments:(z==null?void 0:z.reply)||0,peopleWhoLiked:B,mentions:R},links:{post:`${e}/${t}/${E}`,comments:`${e}/${t}/${E}`},gtmContext:"community",functions:{content:{createContent:()=>null,deleteContent:()=>h({activityId:E}),updateContent:(S,{body:q})=>g({activityId:E,content:q})},likes:{createLike:()=>y({activityId:E}),deleteLike:()=>b({activityId:E,reactionId:C})},comments:{openComments:()=>null},mentions:a},isTruncated:!0})},E)}),!f&&d.jsx(Nr,{hasNextPage:m,loadNextPage:()=>c(),icon:{icon:"arrow-down",position:"right"},messages:{button:o.formatMessage({id:"loadMore_button"}),error:o.formatMessage({id:"loadMore_error"})}})]})},lE={next:"id_lt=67ef0342-6f6e-4807-beea-5a9184ec140c&limit=5",results:[{created_at:"2023-12-03T18:47:44.081716Z",updated_at:"2023-12-03T18:47:44.081716Z",id:"256b921e-ffe6-410d-b754-ac1aaee989ce",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 17..."},parent:"",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:02.517688Z",updated_at:"2023-12-03T18:47:24.852582Z",id:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 16 (edited)..."},parent:"",latest_children:{reply:[{created_at:"2023-12-03T19:28:09.799652Z",updated_at:"2023-12-03T19:28:09.799652Z",id:"bf1ec451-e7c3-4ebe-a60e-248b0ec2a671",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 3..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:59.756761Z",updated_at:"2023-12-03T19:27:59.756761Z",id:"7887d921-e2ba-48ef-8089-db24536dbf70",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 2..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:46.534650Z",updated_at:"2023-12-03T19:27:46.534650Z",id:"73f5bdf3-7080-48ac-a8dc-185f71b38b42",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 1..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}}]},own_children:{reply:[{created_at:"2023-12-03T19:28:09.799652Z",updated_at:"2023-12-03T19:28:09.799652Z",id:"bf1ec451-e7c3-4ebe-a60e-248b0ec2a671",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 3..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:59.756761Z",updated_at:"2023-12-03T19:27:59.756761Z",id:"7887d921-e2ba-48ef-8089-db24536dbf70",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 2..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:46.534650Z",updated_at:"2023-12-03T19:27:46.534650Z",id:"73f5bdf3-7080-48ac-a8dc-185f71b38b42",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 1..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}}]},children_counts:{reply:3}},{created_at:"2023-12-03T17:47:45.107092Z",updated_at:"2023-12-03T17:47:45.107092Z",id:"27a59e8f-f094-442f-88ec-1d5ec2f72790",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 14..."},parent:"",latest_children:{reply:[{created_at:"2023-12-03T18:47:10.603929Z",updated_at:"2023-12-03T18:47:10.603929Z",id:"c32b83d5-c5fc-4253-8531-eb99dcb01f28",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 8..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:47:04.856649Z",updated_at:"2023-12-03T18:47:04.856649Z",id:"5efd80e3-cb11-4748-8c64-f46b71df69c4",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 7..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:22.687552Z",updated_at:"2023-12-03T18:36:22.687552Z",id:"a3a2ebae-6df2-4dc0-beee-2296188b67aa",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 6..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:16.129336Z",updated_at:"2023-12-03T18:36:16.129336Z",id:"72948da5-bf3c-4bd5-9a21-2cee36e0ce8a",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 5..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:40.850756Z",updated_at:"2023-12-03T17:56:40.850756Z",id:"81ebc855-d1f6-4a2c-a788-a251bae406b6",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 4..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:34.103420Z",updated_at:"2023-12-03T17:56:34.103420Z",id:"ddc28de7-4e89-4572-8122-c95dceacc2fd",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 3..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:26.410145Z",updated_at:"2023-12-03T17:56:26.410145Z",id:"916ed4b6-ad87-47bc-9e00-7b0c46180276",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 2..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:19.921740Z",updated_at:"2023-12-03T17:56:19.921740Z",id:"92cddcb2-cbdc-4e69-9c8e-5afe3a607411",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 1..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}}]},own_children:{reply:[{created_at:"2023-12-03T18:47:10.603929Z",updated_at:"2023-12-03T18:47:10.603929Z",id:"c32b83d5-c5fc-4253-8531-eb99dcb01f28",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 8..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:47:04.856649Z",updated_at:"2023-12-03T18:47:04.856649Z",id:"5efd80e3-cb11-4748-8c64-f46b71df69c4",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 7..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:22.687552Z",updated_at:"2023-12-03T18:36:22.687552Z",id:"a3a2ebae-6df2-4dc0-beee-2296188b67aa",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 6..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:16.129336Z",updated_at:"2023-12-03T18:36:16.129336Z",id:"72948da5-bf3c-4bd5-9a21-2cee36e0ce8a",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 5..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:40.850756Z",updated_at:"2023-12-03T17:56:40.850756Z",id:"81ebc855-d1f6-4a2c-a788-a251bae406b6",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 4..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}}]},children_counts:{reply:8}},{created_at:"2023-12-03T17:47:40.066170Z",updated_at:"2023-12-03T17:47:40.066170Z",id:"9ed6a1d0-00b5-4a03-94d7-ac01e188e2e2",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 13..."},parent:"",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:47:33.107894Z",updated_at:"2023-12-03T17:47:33.107894Z",id:"67ef0342-6f6e-4807-beea-5a9184ec140c",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 12..."},parent:"",latest_children:{},children_counts:{}}],duration:"6.48ms"};function cE({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a,user:i}){const{mutate:s}=We.useMutation({mutationFn:e,onMutate:o=>t(l=>{const u=lc({reply:Zw(o),user:i});return hc(u,l,{replace:!1,append:(o==null?void 0:o.replyId)!==void 0})}),onError:n,onSuccess:(o,l,u)=>{const c=lc({reply:o,user:i});r.setQueryData(a,hc(c,u,{replace:!0,append:(l==null?void 0:l.replyId)!==void 0})),setTimeout(()=>{rh(c.id)},0)}});return s}function dE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({replyId:a,content:i})=>t(s=>{const o=Ma(a,s);return o&&(o.data.content=i),s}),onError:n});return r}function sh({queryFns:{create:e,edit:t,like:n,list:r,remove:a,unlike:i},queryKey:s}){const o=We.useQueryClient(),l=Ya(),u={queryClient:o,queryKey:s},c={mutationHandlers:{error:_o(u),mutate:Bo(u)},user:l,...u},m=cE({...c,mutationFn:e}),f=dE({...c,mutationFn:t}),p=fE({...c,mutationFn:n}),g=mE({...c,mutationFn:a}),h=pE({...c,mutationFn:i}),{replies:y,...b}=hE({queryKey:s,queryFn:r});return{replies:y,mutations:{create:m,edit:f,remove:g,like:p,unlike:h},user:l,...b}}function fE({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=We.useMutation({mutationFn:e,onMutate:({replyId:s})=>t(o=>{const l=Ma(s,o);return l&&cc({reply:l}),o}),onError:n,onSuccess:(s,{replyId:o},l)=>{const u=Ma(o,l);u&&cc({reply:u,reaction:s}),r.setQueryData(a,l)}});return i}function hE({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}=We.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:{next:""},getNextPageParam:u=>(u==null?void 0:u.next)||null}),o=DE(n),l=`${o.length||0}${i?"+":""}`;return{replies:o,repliesCount:l,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}}function mE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({replyId:a})=>t(i=>yE(a,i)),onError:n});return r}function pE({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=We.useMutation({mutationFn:e,onMutate:({replyId:i})=>t(s=>{const o=Ma(i,s);return o&&Yw({reply:o,user:r}),s}),onError:n});return a}function gE(e){return{pages:[{next:"",results:[e]}],pageParams:[""]}}function vE(e,t,n){const r=t.pages.length-1,a=t.pages[r].results.length-1;return n!=null&&n.replace?t.pages[r].results[a]=e:t.pages[r].results.push(e),t}function bE(e,t,n){return n!=null&&n.replace?t.pages[0].results[0]=e:t.pages[0].results=[e,...t.pages[0].results],t}function hc(e,t,n){return t?n!=null&&n.append?vE(e,t,n):bE(e,t,n):gE(e)}function Ma(e,t){if(t)for(const{results:n}of t.pages){const r=n.find(({id:a})=>a===e);if(r)return r}}function yE(e,t){for(const{results:n}of t.pages){const r=n.findIndex(({id:a})=>a===e);if(r!==-1){n.splice(r,1);break}}return t}function DE(e){var t;return((t=e==null?void 0:e.pages)==null?void 0:t.reduce((n,r)=>[...n,...r==null?void 0:r.results],[]))||[]}const CE=({basePath:e,parentId:t,activityId:n,replyId:r,isMember:a,functions:i})=>{const s=ue.useIntl(),o=3,{replies:l,fetchNextPage:u,hasNextPage:c,isLoading:m,mutations:{create:f,edit:p,like:g,remove:h,unlike:y},user:b}=sh({queryKey:[e,t,n,r,"replies"],queryFns:{...i,list:k=>i.list({...k,reactionId:r})}});Os([m]);const[w,A]=x.useState(!0);return d.jsxs(d.Fragment,{children:[(l==null?void 0:l.length)>=o&&d.jsx(Ee,{className:"nested-replies-show-toggle",variant:"secondary",size:"small",icon:{icon:`arrow_corner-${w?"up_left":"down_right"}`,position:"left"},onClick:()=>A(!w),children:s.formatMessage({id:`discussion_thread_${w?"hide":"show"}`},{count:l==null?void 0:l.length})}),w&&d.jsx(Xf,{loadMore:{isLoading:m,hasNextPage:c,loadNextPage:()=>u()},form:{content:{type:"reply",slugs:{question:`${e}/${t}`,answer:n,reply:r}},functions:{create:(k,{body:E})=>f({activityId:n,replyId:r,content:E})},meta:{isEditing:!1,showSuccessMessage:!1}},children:l&&l.length>0?l==null?void 0:l.map(k=>{var D,U,X,_,S,q,I,V,te,ee,ie,he;const{id:E,own_children:T,latest_children:j,children_counts:z,mentioned_users:R}=k,M=(((D=T==null?void 0:T.like)==null?void 0:D.length)||0)>0?(U=T==null?void 0:T.like)==null?void 0:U.find(H=>{var de;return((de=H==null?void 0:H.user)==null?void 0:de.id)===(b==null?void 0:b.id)}):!1,C=M?M==null?void 0:M.id:"",B=!!M,N=(((X=j==null?void 0:j.like)==null?void 0:X.length)||0)>0?(_=j==null?void 0:j.like)==null?void 0:_.map(H=>{var de,pe,we;return{id:(de=H==null?void 0:H.user)==null?void 0:de.id,name:(we=(pe=H==null?void 0:H.user)==null?void 0:pe.data)==null?void 0:we.name}}):!1,L=k==null?void 0:k.user,W=(L==null?void 0:L.id)===(b==null?void 0:b.id),ae=Xa(a,W),ne=typeof k.data.content=="string"?(S=k==null?void 0:k.data)==null?void 0:S.content:((I=(q=k==null?void 0:k.data)==null?void 0:q.content)==null?void 0:I.text)||"";return d.jsx(Rr,{content:{id:E,type:"reply",body:ne,canLike:ae,createdAt:k==null?void 0:k.created_at,slugs:{question:`${e}/${t}`,answer:n,reply:k==null?void 0:k.parent},slug:"",author:{id:L==null?void 0:L.id,name:(V=L.data)==null?void 0:V.name,organization:(te=L.data)==null?void 0:te.organization,jobTitle:(ee=L.data)==null?void 0:ee.jobTitle,location:(ie=L.data)==null?void 0:ie.location,image:{thumbnail:((he=L.data)==null?void 0:he.thumbnail)||void 0}},userLiked:B,likes:(z==null?void 0:z.like)||0,peopleWhoLiked:N,mentions:R},functions:{content:{createContent:()=>null,deleteContent:()=>h({replyId:E}),updateContent:(H,{body:de})=>p({replyId:E,content:de})},likes:{createLike:()=>g({replyId:E}),deleteLike:()=>y({replyId:E,reactionId:C})},comments:{},mentions:{getUsers:i.getUsers}}},E)}):null})]})};const oh=({basePath:e,parentId:t,activityId:n,isMember:r,functions:{reactions:a,mentions:i,join:s,leave:o}})=>{const l=ue.useIntl(),{replies:u,repliesCount:c,fetchNextPage:m,hasNextPage:f,isLoading:p,mutations:{create:g,edit:h,like:y,remove:b,unlike:w},user:A}=sh({queryKey:[e,t,n,"replies"],queryFns:a});return Os([p]),ah(),d.jsxs("section",{className:"replies-feed",children:[d.jsx(Jf,{type:"comment",responses:c}),d.jsx(ko,{form:{content:{type:"reply",slugs:{}},functions:{create:(k,{body:E})=>g({activityId:n,content:E}),...i},meta:{isEditing:!1,showSuccessMessage:!1},placeholder:l.formatMessage({id:"discussion_responses_placeholder"})},membershipRequiredToPost:{isMember:r,required:!0,join:s,leave:o,notMemberStateText:l.formatMessage({id:"community_joinToPost"})}}),u==null?void 0:u.map(k=>{var D,U,X,_,S,q,I,V,te,ee,ie,he;const{id:E,own_children:T,latest_children:j,children_counts:z,data:{mentioned_users:R}}=k,M=(((D=T==null?void 0:T.like)==null?void 0:D.length)||0)>0?(U=T==null?void 0:T.like)==null?void 0:U.find(H=>{var de;return((de=H==null?void 0:H.user)==null?void 0:de.id)===(A==null?void 0:A.id)}):!1,C=M?M==null?void 0:M.id:"",B=!!M,N=(((X=j==null?void 0:j.like)==null?void 0:X.length)||0)>0?(_=j==null?void 0:j.like)==null?void 0:_.map(H=>{var de,pe,we;return{id:(de=H==null?void 0:H.user)==null?void 0:de.id,name:(we=(pe=H==null?void 0:H.user)==null?void 0:pe.data)==null?void 0:we.name}}):!1,L=k==null?void 0:k.user,W=(L==null?void 0:L.id)===(A==null?void 0:A.id),ae=Xa(r,W),ne=typeof k.data.content=="string"?(S=k==null?void 0:k.data)==null?void 0:S.content:((I=(q=k==null?void 0:k.data)==null?void 0:q.content)==null?void 0:I.text)||"";return d.jsx(Gf,{children:d.jsx(Rr,{content:{id:E,type:"reply",body:ne,canLike:ae,createdAt:k==null?void 0:k.created_at,slugs:{question:`${e}/${t}`,answer:n,reply:E},slug:E,author:{id:L==null?void 0:L.id,name:(V=L.data)==null?void 0:V.name,organization:(te=L.data)==null?void 0:te.organization,jobTitle:(ee=L.data)==null?void 0:ee.jobTitle,location:(ie=L.data)==null?void 0:ie.location,image:{thumbnail:((he=L.data)==null?void 0:he.thumbnail)||void 0}},userLiked:B,likes:(z==null?void 0:z.like)||0,peopleWhoLiked:N,mentions:R},functions:{content:{createContent:()=>null,deleteContent:()=>b({replyId:E}),updateContent:(H,{body:de})=>h({replyId:E,content:de})},likes:{createLike:()=>y({replyId:E}),deleteLike:()=>w({replyId:E,reactionId:C})},comments:{},mentions:i},children:d.jsx(CE,{basePath:e,parentId:t,activityId:n,replyId:E,isMember:r,functions:{...a,...i}})},E)},E)}),!p&&d.jsx(Nr,{hasNextPage:f,loadNextPage:()=>m(),icon:{icon:"arrow-down",position:"right"},messages:{button:l.formatMessage({id:"loadMore_button"}),error:l.formatMessage({id:"loadMore_error"})}})]})};function xE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({content:a})=>t(i=>(i&&(i.content=a),i)),onError:n});return r}function wE({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,isFetching:i}=We.useQuery({queryFn:e,queryKey:t});return{activity:n,error:r,isLoading:a,isFetching:i}}function EE({queryFns:{read:e,edit:t,like:n,unlike:r},queryKey:a}){const i=We.useQueryClient(),s=Ya(),o={queryClient:i,queryKey:a},l={mutationHandlers:{error:_o(o),mutate:Bo(o)},user:s,...o},u=xE({...l,mutationFn:t}),c=kE({...l,mutationFn:n}),m=_E({...l,mutationFn:r}),{activity:f,...p}=wE({queryKey:a,queryFn:e});return{activity:f,mutations:{edit:u,like:c,unlike:m},user:s,...p}}function kE({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=We.useMutation({mutationFn:e,onMutate:s=>t(o=>(o&&Na({activity:o}),o)),onError:n,onSuccess:(s,o,l)=>{l&&Na({activity:l,reaction:s}),r.setQueryData(a,l)}});return i}function _E({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=We.useMutation({mutationFn:e,onMutate:i=>t(s=>(s&&nh({activity:s,user:r}),s)),onError:n});return a}const BE=({basePath:e,parentId:t,activityId:n,isMember:r,functions:{activities:{remove:a,...i},reactions:s,mentions:o,join:l,leave:u}})=>{var M,C,B,F,N,L,W,ae,ne,D;const c=ue.useIntl(),m=x.useContext(Mt),{activity:f,error:p,isLoading:g,mutations:{edit:h,like:y,unlike:b}}=EE({queryFns:i,queryKey:[e,t,n]});if(g)return d.jsx(wt,{style:{height:"400px"}});if(p||!f)return d.jsx(an,{variant:"error",text:c.formatMessage({id:"activitySection_notFoundError"})});const{own_reactions:w,latest_reactions:A,mentioned_users:k}=f,E=(((M=A==null?void 0:A.like)==null?void 0:M.length)||0)>0,T=(((C=w==null?void 0:w.like)==null?void 0:C.length)||0)>0,j=T?w==null?void 0:w.like[0].id:"",z=E?(B=A==null?void 0:A.like)==null?void 0:B.map(U=>{var X,_,S;return{id:(X=U==null?void 0:U.user)==null?void 0:X.id,name:(S=(_=U==null?void 0:U.user)==null?void 0:_.data)==null?void 0:S.name}}):!1,R=f==null?void 0:f.actor,$=(R==null?void 0:R.id)===(m==null?void 0:m.id);return d.jsxs("section",{className:"activity-section",children:[d.jsx(Rr,{className:"highlighted-text-box subtle",content:{id:n,type:"post",body:f==null?void 0:f.content,canLike:Xa(r,$),createdAt:(f==null?void 0:f.time)||"",slugs:{question:`${e}/${t}`,answer:f==null?void 0:f.id},slug:n,author:{id:R.id,name:(F=R.data)==null?void 0:F.name,organization:(N=R.data)==null?void 0:N.organization,jobTitle:(L=R.data)==null?void 0:L.jobTitle,location:(W=R.data)==null?void 0:W.location,image:{thumbnail:((ae=R.data)==null?void 0:ae.thumbnail)||void 0}},userLiked:T,likes:((ne=f==null?void 0:f.reaction_counts)==null?void 0:ne.like)||0,comments:((D=f==null?void 0:f.reaction_counts)==null?void 0:D.reply)||0,peopleWhoLiked:z,mentions:k},originalAuthorId:R==null?void 0:R.id,forceHide:{comments:!0},functions:{content:{createContent:()=>null,deleteContent:a,updateContent:(U,{body:X})=>h({content:X})},likes:{createLike:()=>y({activityId:n}),deleteLike:()=>b({activityId:n,reactionId:j})},comments:{openComments:()=>{}},mentions:o}},n),d.jsx(oh,{basePath:e,parentId:t,activityId:n,isMember:r,functions:{reactions:s,mentions:o,join:l,leave:u}})]})},AE=({id:e,data:{jobTitle:t,name:n,organization:r,thumbnail:a}})=>({id:e,name:n,jobTitle:t,organization:r,image:{thumbnail:a}}),mc=[{contentType:"solutionArticle",banner:{description:"",url:"//images.ctfassets.net/txbhe1wabmyx/kCcBdXurt3uOKu6NdTPm0/1b6d19179b21f98dbdadf2477c03d267/devin-avery-7gwqj0yyrhm-unsplash.jpg",width:295,height:180,type:"image/jpeg",aspect:"responsiveCard",query:"w=295&h=180&fit=thumb&f=center"},slug:"why-public-servants-must-learn-to-fail",contributors:["community"]},{contentType:"solutionArticle",banner:{description:"",url:"//images.ctfassets.net/txbhe1wabmyx/12Y0W1K0zVcDKzgLZlbfyC/6eb0757a02cbeea19b1b42d7da04d553/ashkan-forouzani-m0l9nbcivuk-unsplash.jpg",width:295,height:180,type:"image/jpeg",aspect:"responsiveCard",query:"w=295&h=180&fit=thumb&f=center"},slug:"organisational-culture-change-and-failure",contributors:[{name:"Mari-Liis",id:"bdb7509c-89ed-4633-8bc0-dbf11f5d9be1"}]},{contentType:"solutionArticle",banner:{description:"",url:"//images.ctfassets.net/txbhe1wabmyx/26TEwu0xVkbQDguuW89fY6/d54ce406cdd652d68979770d526398ab/nik-shuliahin-bunwp1bl0nc-unsplash.jpg",width:295,height:180,type:"image/jpeg",aspect:"responsiveCard",query:"w=295&h=180&fit=thumb&f=center"},slug:"how-to-learn-from-failure-without-causing-a-scandal",contributors:["community"]}];const ia="notFoundError_",FE=()=>{const e=ue.useIntl(),t=[];return mc.forEach((n,r)=>{n.title=e.formatMessage({id:`${ia}post_${r+1}`}),t.push("solutionArticle")}),d.jsxs(Kf,{styling:{background:"bold",circle:"small",variant:"alt-2"},additionalContent:{appended:d.jsxs(ln,{children:[d.jsx(qf,{cards:mc,cardTypes:t,buildCardData:n=>new Promise((r,a)=>{r(n)})}),d.jsx(Ee,{href:"/solution-articles/",children:e.formatMessage({id:`${ia}cta`})})]})},reportError:()=>{},className:"not-found-error",children:[d.jsx("h1",{children:e.formatMessage({id:`${ia}title`})}),d.jsx("p",{children:e.formatMessage({id:`${ia}text`})})]})};exports.ASSETS_BUCKET=Ht;exports.ActivitiesFeed=uE;exports.ActivitySection=BE;exports.AddPost=ko;exports.Banner=Gx;exports.BannerSection=rw;exports.Breadcrumbs=gw;exports.Buckets=Wh;exports.Button=Ee;exports.ButtonWrapper=En;exports.COURSE_CONTENT_TYPES=fr;exports.CacheProvider=Pf;exports.Card=Do;exports.CardBlock=qf;exports.Carousel=mw;exports.CharacterLimit=qs;exports.CollapsibleSection=La;exports.Columns=Uf;exports.CommunityDetails=pw;exports.ContactFooter=Bw;exports.ContactForm=Df;exports.ContentTypeLabel=Nc;exports.Contributors=zs;exports.ConversationContext=Ja;exports.CookieBanner=Vf;exports.CourseProgression=Pw;exports.CourseStructure=Nw;exports.CustomContentBanner=aw;exports.Directory=Vx;exports.DiscussionConversation=Gf;exports.DiscussionForm=Qa;exports.DiscussionLikes=Qf;exports.DiscussionPost=Rr;exports.DiscussionThread=Xf;exports.Divider=tn;exports.DownloadSection=Qx;exports.EMAILS=Pn;exports.EditSection=Xx;exports.EmailHelperTextBox=Wc;exports.EmptyStateBox=an;exports.Filters=vw;exports.FlagsProvider=Nf;exports.Footer=wo;exports.Form=nr;exports.Formatting=Z;exports.FullWidthSection=ln;exports.GlobalProviders=Hx;exports.Header=Eo;exports.HelperTextBox=Mc;exports.HiddenFromScreenReaders=Ia;exports.HideShowTextBox=Ic;exports.HighlightSection=sw;exports.HighlightedTextBox=Nt;exports.INVALID_TOKEN=Fc;exports.IconBulletedList=Vh;exports.ImageContainer=Lh;exports.IntlProvider=Rf;exports.InviteForm=Cf;exports.InviteModal=Ux;exports.JoinButton=Co;exports.LanguageContext=vo;exports.LanguageSwitcher=yw;exports.LessonName=Zf;exports.LessonType=Yf;exports.Link=kn;exports.LoadMore=Nr;exports.LoadingBlock=rm;exports.LoadingPlaceholder=wt;exports.LoadingState=$s;exports.Logo=xo;exports.LogoSection=ew;exports.MarkCompleteButton=Rw;exports.MarkdownText=Un;exports.MarketingBlock=ow;exports.Marks=Ot;exports.Member=tr;exports.MembersList=Ow;exports.Modal=yo;exports.MoreMenu=Wf;exports.NUMBER_OF_COUNTRIES=Bh;exports.NUMBER_OF_USERS=_h;exports.NavigationMenu=Hf;exports.NotFoundError=FE;exports.Overlay=Pr;exports.OverlayContext=bo;exports.OverlayProvider=$f;exports.PageHeading=$c;exports.PageLayout=Kf;exports.PasswordForm=IC;exports.PasswordRules=Zc;exports.Pill=hn;exports.Popover=Pc;exports.Portal=Ms;exports.ProfileImageChange=MC;exports.ProfilePicture=sn;exports.ProgressBar=Is;exports.ProgressTracker=zh;exports.Rating=gm;exports.RepliesFeed=oh;exports.ResponsesHeading=Jf;exports.ResponsiveImage=er;exports.ReturnToNavButton=qh;exports.RichTextEditor=yf;exports.SearchForm=xf;exports.ShareLinks=Ew;exports.SignupForm=HC;exports.Span=as;exports.StatusBanner=wr;exports.TableOfContents=Yx;exports.Tabs=kw;exports.Tags=jw;exports.TestimonialBlock=Zx;exports.TimeToComplete=Ga;exports.Toggle=RC;exports.Tooltip=Jn;exports.TopLevelPage=Aw;exports.UUID_V4_REGEX=Ns;exports.UserContext=Mt;exports.UserProvider=Mf;exports.VisuallyHidden=Me;exports.addAriaProps=Lf;exports.basicReducer=jr;exports.camelCaseToDashCase=_c;exports.checkIntlPathExists=$a;exports.generateConditions=ma;exports.generateCssIcon=Tc;exports.getCharacterLimitProps=qc;exports.getLongDate=Rs;exports.getMember=Ls;exports.getShortDate=Sc;exports.getValueLength=za;exports.headerData=Sr;exports.mapGetStreamData=AE;exports.pageReady=jc;exports.passwordValidator=ns;exports.repliesFeedMock=lE;exports.supportedLanguages=ga;exports.toCamelCase=Bc;exports.toCapitalisedCase=kh;exports.toSentenceCase=Ac;exports.useCurrentPath=Dc;exports.useEffectAfterMount=Hn;exports.useElementWidth=Qn;exports.useOverlay=If;exports.useScrollListener=wc;exports.useScrollToHash=Os;exports.useTooltips=Ps;exports.useUser=Ya;
|
|
159
|
+
${dr(t,"mailto",n)}&src=email`)}`},{key:"clipboard-copy",icon:"share_copy-link",url:dr(t,"copy",n),shouldRender:()=>navigator&&navigator.clipboard&&navigator.clipboard.writeText,onClick:(r,a)=>(r.preventDefault(),r.stopPropagation(),navigator.clipboard.writeText(a))}];const ww="shareLinks_",Ew=({title:e,link:t,referrer:n,gtmContext:r="ShareLinks",size:a="large",variant:i="default",className:s=""})=>{const o=ue.useIntl(),l=xw({title:e,link:t,referrer:n});return d.jsxs("aside",{className:G("share-links",a,i,s),children:[d.jsx("p",{className:"text-small",children:o.formatMessage({id:"shareLinks_label"})}),d.jsx("ul",{children:l.map(({key:u,icon:c,url:m,shouldRender:f=!0,onClick:p})=>{if(typeof f=="function"&&!f())return null;const g={};return p&&(g.onClick=h=>p(h,m)),d.jsx("li",{children:d.jsx(Ee,{size:a,variant:"tertiary",icon:{icon:c||u},href:m,target:"_blank",rel:"noopener noreferrer",className:"gtm-trackable","data-gtm-event-context":`${r}-SocialButtons`,"data-gtm-event-type":`${u}-click`,"data-testid":"link",screenreaderText:o.formatMessage({id:`${ww}link_${u}`}),...g})},u)})})]})};const kw=({tabs:e,className:t="",preventLocationChange:n})=>{var u;const r=(c,m,f)=>(c||(c=`panel-${window.btoa(m)}-${f}`),c);let a=e.findIndex(c=>c.current===!0);if(a<0&&(a=0),window.location.hash){const c=window.location.hash.replace("#","");if(e.find(f=>f.id===c)){for(let f=0;f<e.length;f++)if(r(e[f].id,e[f].text,f)===c){a=f;break}}}const[i,s]=x.useState((u=e[a])!=null&&u.id?e[a].id:r(e[a].id,e[a].text,a));x.useEffect(()=>{if(e[a].hasCarousel){const c=new CustomEvent("hiddenSectionVisible",{detail:{id:i}});window.dispatchEvent(c)}},[i]);const o=[],l=[];return e.forEach(({id:c,text:m,content:f,href:p,hasCarousel:g},h)=>{c=r(c,m,h);const y=i===c,b={};p||(b["aria-controls"]=c,b.onClick=w=>{w.preventDefault(),w.stopPropagation(),s(c),!n&&(window.location.hash=`#${c}`)},l.push(d.jsx("section",{id:c,hidden:!y,role:"tabpanel","aria-labelledby":`tab-${c}`,"aria-live":y?"assertive":"off",children:typeof f=="string"?d.jsx("p",{children:f}):f},`section-${c}`))),o.push(d.jsx("li",{"data-testid":"navigation-tab",children:d.jsx("a",{href:p||`#${c}`,id:`tab-${c}`,className:G({selected:y}),role:"tab","aria-selected":y,...b,children:m})},`tab-${c}`))}),d.jsxs("div",{className:G("tabs-wrapper",t),children:[d.jsx("ul",{className:"tabs",role:"tablist",children:o}),d.jsx("div",{className:"tab-content",children:l})]})};const _w={"2-1":901,"1-3":769,"1-1":769},Uf=({layout:e="2-1",hideOnMobile:t=!1,hasCSSContainers:n=!1,className:r="",children:a})=>{const i=Qn(!0);let s=a;return x.Children.count(a)===1&&(s=x.Children.toArray(a)[0],s.props&&(s=s.props.children)),d.jsx("section",{className:G("columns",`layout-${e}`,r,{"has-containers":n}),children:x.Children.map(s,(o,l)=>t!==!1&&l===t&&i&&i<_w[e]?null:o)})};let qi;const Wi="contactFooter_",Bw=({onSuccess:e=async()=>{},onFailure:t=()=>{}})=>{const n=x.useRef(null),[r,a]=x.useState(0),[i,s]=x.useState(!1),o=()=>{n.current&&a(n.current.clientHeight)},l=()=>{i||(s(!0),clearTimeout(qi),qi=setTimeout(()=>{o(),s(!1)},500))};return x.useEffect(()=>(o(),window.addEventListener("resize",l),()=>{clearTimeout(qi),window.removeEventListener("resize",l)}),[]),d.jsx(ln,{id:"contactForm",className:"contact-footer",children:d.jsxs("div",{className:"inner-wrapper",children:[d.jsx("h2",{children:d.jsx(ue.FormattedMessage,{id:`${Wi}title`})}),d.jsxs("div",{className:"content-wrapper",ref:n,"data-testid":"content-wrapper",style:i?{}:{minHeight:r},children:[d.jsxs("aside",{children:[d.jsx("p",{children:d.jsx(ue.FormattedMessage,{id:`${Wi}text`})}),d.jsx(kn,{className:"mailto-link",href:"mailto:hello@apolitical.co",children:d.jsx(ue.FormattedMessage,{id:`${Wi}email`})})]}),d.jsx(Df,{functions:{onSuccess:e,onFailure:t},gtm:{context:"FooterContactUsForm",event:"contact-form-submit-click"}})]})]})})},Aw=({activeLink:e,...t})=>d.jsx(ln,{children:d.jsx(Uf,{layout:"1-3",children:d.jsxs(d.Fragment,{children:[d.jsx(Hf,{activeLink:e}),d.jsx($c,{...t})]})})});const Hi="cookieBanner_",Ui=["apol-cookie-banner","apolitical-performance-cookie-consent","functional-cookie-consent"],Vi=new Date(Date.now()+12*30*24*60*60*1e3),Vf=()=>{const e=ue.useIntl(),[t,n,r]=js.useCookies(Ui),[a,i]=x.useState(!t["apol-cookie-banner"]),s=()=>{Ui.forEach(c=>{n(c,!0,{path:"/",expires:Vi,domain:c==="apolitical-performance-cookie-consent"?".apolitical.co":void 0})}),i(!1),window.location.reload()},o=()=>{n("apol-cookie-banner",!0,{path:"/",expires:Vi}),Ui.forEach(c=>{if(c==="apol-cookie-banner"){n(c,!0,{path:"/",expires:Vi});return}r(c)}),i(!1)};if(!a)return null;const l=[{id:"settings",href:"/pages/cookie-policy",gtmType:"policy-page"},{id:"reject",onClick:o,gtmType:"reject-all"},{id:"accept",onClick:s,gtmType:"accepted-all"}],u=[];return l.forEach(c=>{u.push({variant:c.href?"tertiary":"primary",href:c.href,onClick:c.onClick,className:"gtm-trackable","data-gtm-event-context":"cookie-banner","data-gtm-event-type":`cookie-${c.gtmType}-click`,children:e.formatMessage({id:`${Hi}buttons_${c.id}`})})}),d.jsxs("aside",{id:"cookie-banner",className:"text-medium",children:[d.jsx("h6",{children:e.formatMessage({id:`${Hi}title`})}),d.jsx("p",{children:e.formatMessage({id:`${Hi}text`})}),d.jsx(En,{buttons:u})]})},qt={platform:{order:["events","courses","articles","communities"],events:{href:"/events/",gtmType:"events-click"},courses:{href:"/microcourses/",gtmType:"microcourses-click"},articles:{href:"/solution-articles/",gtmType:"articles-click"},communities:{href:"/communities/",gtmType:"communities-click"}},community:{order:["support","post","join","guidelines"],support:{name:"Support FAQ",href:"/pages/support-faq",gtmType:"support-faq-click"},post:{href:"/pages/post-an-article",gtmType:"post-an-article-click"},join:{href:"/pages/who-can-join-the-community",gtmType:"who-can-join-click"},guidelines:{href:"/pages/values-and-guidelines",gtmType:"guidelines-and-values-click"}},company:{order:["news","story","team","careers","partner","contact"],news:{href:"/learning-hub/updates/",gtmType:"news-click"},story:{href:"/pages/our-story",gtmType:"our-story-click"},team:{href:"/pages/meet-our-team",gtmType:"team-click"},careers:{href:"/pages/careers",gtmType:"careers-click"},partner:{href:"/partnerships/",gtmType:"partner-with-us-click"},contact:{href:"/pages/get-in-touch",gtmType:"contact-click"},child:"legal"},legal:{order:["privacy","terms","cookie","accessibility","ai"],privacy:{href:"https://about.apolitical.co/privacy-policy",gtmType:"privacy-policy-link"},terms:{href:"https://about.apolitical.co/terms-and-conditions",gtmType:"terms-conditions-link"},cookie:{href:"/pages/cookie-policy",gtmType:"cookie-policy-link"},ai:{href:"/pages/ai-principles",gtmType:"ai-principles-link"},accessibility:{href:"/pages/accessibility-statement",gtmType:"accessibility-link"},text:{order:["dataProtection","euDataProtection"],dataProtection:{email:Pn["data-protection"].default,gtmType:"email-dpo-link"},euDataProtection:{email:Pn["data-protection"].eu,gtmType:"email-eu-dpo-link"}}},contact:{text:{order:["correspondence","registered","berlin","support","business"],correspondence:{address:!0},registered:{address:!0},berlin:{address:!0},support:{email:Pn.support,gtmType:"concierge-email-click"},business:{email:Pn.general,gtmType:"hello-email-click"}}},social:{order:["linkedin","twitter","facebook"],linkedin:{href:"https://www.linkedin.com/company/apolitical"},twitter:{href:"https://twitter.com/apoliticalco"},facebook:{href:"https://www.facebook.com/apoliticalco"}}};const Ln="footer_",Oa="SiteFooter",ic=({group:e})=>{const t=qt[e].order||[];let n=!1;return"text"in qt[e]&&(n=qt[e].text),d.jsxs(x.Fragment,{children:[d.jsx("p",{className:"pre-title",children:d.jsx(ue.FormattedMessage,{id:`${Ln}${e}`})}),Array.isArray(t)&&t.length>0&&d.jsx("ul",{className:"text-medium",children:t.map(r=>{if(["order","child","text"].includes(r))return null;const{href:a,gtmType:i}=qt[e][r],s={};return["legal"].includes(e)&&(s.target="_blank",s.rel="noopener"),d.jsx("li",{children:d.jsx("a",{href:a,className:"gtm-trackable","data-gtm-event-context":Oa,"data-gtm-event-type":i,...s,children:d.jsx(ue.FormattedMessage,{id:`${Ln}${e}_${r}`})})},`${e}_${r}`)})}),typeof n!="boolean"&&"order"in n&&Array.isArray(n.order)&&d.jsx("dl",{className:"text-medium",children:n.order.map(r=>d.jsxs(x.Fragment,{children:[d.jsx("dt",{children:d.jsx(ue.FormattedMessage,{id:`${Ln}${e}_${r}`})}),d.jsxs("dd",{children:[typeof n!="boolean"&&n[r].address&&d.jsx("address",{children:d.jsx(ue.FormattedMessage,{id:`${Ln}${e}_${r}_address`,values:{br:d.jsx("br",{})}})}),typeof n!="boolean"&&n[r].email&&d.jsx("a",{href:`mailto:${n[r].email}`,className:"gtm-trackable","data-gtm-event-context":Oa,"data-gtm-event-type":n[r].gtmType,children:n[r].email})]})]},`dl-${e}-${r}`))})]},e)},wo=()=>d.jsx("div",{id:"footer",children:d.jsxs("div",{className:"wrapper",children:[d.jsx(Ia,{element:"hr"}),d.jsx(xo,{variant:"inverted",version:"full",className:"gtm-trackable","data-gtm-event-context":Oa,"data-gtm-event-type":"logo-homepage-link"}),d.jsx("footer",{children:["platform","community","company","contact"].map(e=>d.jsxs("div",{className:"group",children:[d.jsx(ic,{group:e}),Object.keys(qt[e]).includes("child")&&d.jsx(ic,{group:qt[e].child})]},e))}),d.jsx("hr",{}),d.jsxs("div",{className:"sub-footer",children:[d.jsx("ul",{children:Array.isArray(qt.social.order)&&qt.social.order.map(e=>{const t=qt.social[e];return d.jsx("li",{className:e,children:d.jsx("a",{href:t.href,target:"_blank",rel:"noopener noreferrer",className:"gtm-trackable","data-gtm-event-context":Oa,"data-gtm-event-type":"social-click",children:d.jsx("span",{className:"hidden",children:d.jsx(ue.FormattedMessage,{id:`${Ln}social_${e}`})})})},e)})}),d.jsx("small",{children:d.jsx(ue.FormattedMessage,{id:`${Ln}copyright`,values:{currentYear:new Date().getFullYear()}})})]})]})}),Pe={timeouts:{},handlerCalled:{},getIsDesktopVersion:(e,t)=>{const n={navigation:{loggedIn:769,loggedOut:881},search:{loggedIn:961,loggedOut:1121}},r=i=>{const s=`logged${e?"In":"Out"}`;return t>=n[i][s]};let a={};return["navigation","search"].forEach(i=>{a[i]=r(i)}),a},shouldChangeHeaderIsVisible:(e,t,n)=>{Object.values(t).filter(a=>a===!0).length||n([{type:"headerIsVisible",value:e}])},handleMenus:({id:e,value:t,menus:n,dispatch:r,forceHandle:a=!1})=>{if(!a&&n[e]===t||!a&&e==="account"&&t===!1&&n.navigation===!0)return;const i=Date.now();if(!a&&!t&&Pe.handlerCalled[e]&&i-Pe.handlerCalled[e]<500)return;Pe.handlerCalled[e]=i;let s=[{type:`menus.${e}`,value:t}];if(t===!0)Object.keys(n).forEach(o=>{o===e||n[o]===!1||s.push({type:`menus.${o}`,value:!1})});else{let o=null;switch(e){case"navigation":o=document.querySelector("#header .menu-button"),o||(o=document.querySelector("#navigation > li.parent"));break;case"search":o=document.querySelector("#header .toggle-search-button");break;case"account":o=document.querySelector("#header .account-button");break;default:return}o&&o.focus()}r(s)},findFirstChild:(e,t,n=!1)=>{if(!e||!e[0])return!1;for(let r=0;r<=e.length;r++){if(!e[r])continue;if(e[r][t]&&(!n||e[r][t].includes(n)))return e[r];if(!t.includes("."))continue;const a=vc(e[r],t);if(!(typeof a>"u")&&(!n||a[t]&&a[t].includes(n)||a.value&&a.value.includes(n)||a.toString().includes(n)))return e[r]}return e[0].children?Pe.findFirstChild(e[0].children,t,n):!1},autoFocus:({menu:e,navigationRef:t,isDesktopVersion:n,focusElements:r,dispatch:a})=>{var l;if(!t.current||!t.current.children)return;const i=n?"desktop":"default";if(r[e][i]){(l=document.querySelector(`#header ul a[href="${r[e][i]}"]:last-child`))==null||l.focus();return}let s,o;switch(e){case"navigation":if(n){const u=Pe.findFirstChild(t.current.children,"attributes.aria-controls","navigation");s=Pe.findFirstChild(u.children,"href")}else s=Pe.findFirstChild(t.current.children,"href");break;case"account":if(o=Pe.findFirstChild(t.current.children,"className","account"),!o||!o.children)return;s=Pe.findFirstChild(o.children,"href");break;default:return}s&&(a([{type:`focusElements.${e}.${i}`,value:s.attributes.href.value}]),s.focus())},events:{onClick:(e,{id:t,callback:n,isOpen:r})=>{e.target&&e.target.attributes&&e.target.attributes.href||(e.preventDefault(),e.stopPropagation(),clearTimeout(Pe.timeouts[t]),n(t,!r))},onFocus:({id:e})=>{clearTimeout(Pe.timeouts[e])},onMouseEnter:({id:e,callback:t})=>{clearTimeout(Pe.timeouts[e]),t(e,!0)},onBlur:({id:e,callback:t})=>{Pe.timeouts[e]=setTimeout(()=>{t(e,!1)},250)}}},Sr={order:["home","topics","partners","account"],home:{href:"/home/",hasVariantText:!0,gtmType:"homepage-click"},topics:{order:["explore","topics"],menuId:"navigation",explore:{order:["events","courses","articles","communities"],events:{href:"/events/",className:"icon events"},courses:{href:"/microcourses/",gtmType:"microcourses-click",className:"icon courses"},articles:{href:"/solution-articles/",gtmType:"articles-click",className:"icon articles"},communities:{href:"/communities/",gtmType:"communities-click",className:"icon communities"}},topics:{order:["climate","cities-and-local-government","digital-and-data","education","equity-justice-and-inclusion","health-and-social-care","innovation","leadership-and-skills","life-in-government","policymaking","transport-and-infrastructure","work-and-the-economy"],className:"columns",climate:{href:"/topics/climate/"},"cities-and-local-government":{href:"/topics/cities-and-local-government/"},"digital-and-data":{href:"/topics/digital-and-data/"},education:{href:"/topics/education/"},"equity-justice-and-inclusion":{href:"/topics/equity-justice-and-inclusion/"},"health-and-social-care":{href:"/topics/health-and-social-care/"},innovation:{href:"/topics/innovation/"},"leadership-and-skills":{href:"/topics/leadership-and-skills/"},"life-in-government":{href:"/topics/life-in-government/"},policymaking:{href:"/topics/policymaking/"},"transport-and-infrastructure":{href:"/topics/transport-and-infrastructure/"},"work-and-the-economy":{href:"/topics/work-and-the-economy/"}}},partners:{href:"/partnerships/",onlyShow:"logged-out"},account:{order:["profile","settings","log-out"],className:"account",onlyShow:"logged-in",doTrack:!1,profile:{href:"/profiles/me"},settings:{href:"/profiles/me/manage-account"},"log-out":{href:"/user-onboarding/logout",className:"divider"}},buttons:{order:["login","signup"],login:{href:"/user-onboarding/login"},signup:{href:"/signup/?ref=header-banner",props:{variant:"primary"}}}},Pa=({id:e,isLoggedIn:t=!1,isDesktopVersion:n=!1,menus:r={},callback:a=()=>{},doTrack:i=null})=>{const s=ue.useIntl(),o=vc(Sr,e);if(!o||o.onlyShow&&(o.onlyShow==="logged-in"&&!t||o.onlyShow==="logged-out"&&t))return null;const l="doTrack"in o,u=i===null?l?o.doTrack:!0:i,c=e.includes("buttons.");let m=`header_${e.replaceAll(".","_")}`;o.hasVariantText&&(m+=`_logged${t?"In":"Out"}`);let f=!1;if(o.href){let w=o.gtmType||`${e}-click`;if(w.includes(".")){const A=w.split("."),k=A[A.length-2];w=`${k==="topics"?`${k}-`:""}${A[A.length-1]}`}f={href:o.href},u&&(f={...f,className:"gtm-trackable","data-gtm-event-type":w,"data-gtm-event-context":"HeaderButtons"}),c&&(f={...f,variant:"secondary",size:{mobile:"small",881:"large"},...o.props||{}})}const p=o.order&&o.order[0]&&o[o.order[0]],g=p&&o[o.order[0]].order,h=f&&window.location.pathname===o.href;let y={},b={};if(h&&(y={...y,"aria-current":"page"}),p){const w=o.menuId||e,A={onClick:k=>Pe.events.onClick(k,{id:w,callback:a,isOpen:r[w]}),onFocus:()=>Pe.events.onFocus({id:w}),onBlur:()=>Pe.events.onBlur({id:w,callback:a}),onMouseLeave:()=>Pe.events.onBlur({id:w,callback:a}),onMouseEnter:()=>Pe.events.onMouseEnter({id:w,callback:a})};n&&(g&&(y={...A,onKeyPress:k=>{k.key==="Enter"&&Pe.events.onClick(k,{id:w,callback:a,isOpen:r[w]})},tabIndex:"0","aria-haspopup":!0,"aria-expanded":r[w],"aria-controls":w}),b={hidden:w in r?!r[w]:!0}),g||(b={...b,...A})}return d.jsxs("li",{className:G({[o.className]:o.className,"has-submenu":p,parent:g,active:h}),...y,children:[f?x.createElement(c?Ee:"a",f,s.formatMessage({id:m})):s.formatMessage({id:m}),o.order&&d.jsx("ul",{...b,children:o.order.map(w=>{if(!o[w])return null;const A={isLoggedIn:t,isDesktopVersion:n,menus:r,callback:a,doTrack:l?u:null};return o[w].order?d.jsxs("li",{className:G({[o[w].className]:o[w].className}),children:[s.formatMessage({id:`${m}_${w}`}),d.jsx("ul",{children:o[w].order.map(k=>d.jsx(Pa,{id:`${e}.${w}.${k}`,...A},k))})]},w):d.jsx(Pa,{id:`${e}.${w}`,...A},w)})})]},e)};const Fw={height:67,height_desktop:83},Eo=({showNavigation:e=!0})=>{const t=ue.useIntl(),n=x.useContext(Mt),r=Qn(!0,!0),a=n&&typeof n.id=="string",i=x.useMemo(()=>Pe.getIsDesktopVersion(a,r),[a,r]),[s,o]=x.useReducer(jr,{headerIsVisible:!0,menus:{navigation:!1,search:!1,account:!1},focusElements:{navigation:{desktop:!1,default:!1},account:{desktop:!1,default:!1}}}),{headerIsVisible:l,menus:u,focusElements:c}=s,m=x.useRef(s);x.useEffect(()=>{m.current=s},[s]),wc({scrollPosition:Fw[`height${i.navigation?"_desktop":""}`],callbacks:{scrollUp:()=>{const h=m.current.menus;!i&&h.navigation||Pe.shouldChangeHeaderIsVisible(!0,h,o)},scrollDown:()=>{const h=m.current.menus;!i&&h.navigation||Pe.shouldChangeHeaderIsVisible(!1,h,o)}}});const f=(h,y,b=!1)=>{Pe.handleMenus({id:h,value:y,menus:m.current.menus,dispatch:o,forceHandle:b})},p=x.useRef(null),g=h=>{h.key==="Escape"&&["navigation","search","account"].forEach(y=>{m.current.menus[y]&&f(y,!1,!0)})};return x.useEffect(()=>{var h;return(h=document.getElementById("header"))==null||h.addEventListener("keydown",g),()=>{var y;(y=document.getElementById("header"))==null||y.removeEventListener("keydown",g)}},[]),Hn(()=>{u.navigation&&Pe.autoFocus({menu:"navigation",navigationRef:p,isDesktopVersion:i.navigation,focusElements:c,dispatch:o})},[u.navigation]),Hn(()=>{u.account&&Pe.autoFocus({menu:"account",navigationRef:p,isDesktopVersion:i.navigation,focusElements:c,dispatch:o})},[u.account]),n&&n.isLoading?null:d.jsxs(d.Fragment,{children:[d.jsxs("nav",{id:"header",className:G({"logged-in":a,"logged-out":!a,visible:l}),children:[d.jsx(Me,{element:"a",href:"#content-of-page",children:t.formatMessage({id:"header_skip"})}),d.jsx(xo,{variant:"monochrome"}),e&&d.jsxs(d.Fragment,{children:[!i.navigation&&d.jsx("button",{className:"menu-button gtm-trackable",onClick:h=>{h.preventDefault(),h.stopPropagation(),f("navigation",!u.navigation)},"data-gtm-event-type":"open-tab-menu-click","data-gtm-event-context":"HeaderLeft-Chevron","aria-haspopup":"true","aria-expanded":u.navigation,"aria-controls":"navigation",children:d.jsx(Me,{children:t.formatMessage({id:`header_menu_${u.navigation?"hide":"show"}`})})}),d.jsx("ul",{ref:p,id:"navigation",hidden:i.navigation||u.account?!1:!u.navigation,"data-showing":!i.navigation&&u.account?"account":"default",children:Sr.order.map(h=>d.jsx(Pa,{id:h,isLoggedIn:a,isDesktopVersion:i.navigation,menus:{navigation:u.navigation,account:u.account},callback:f},h))}),!i.search&&d.jsx("button",{className:"search toggle-search-button",onClick:h=>{h.preventDefault(),h.stopPropagation(),f("search",!u.search)},"aria-haspopup":"true","aria-expanded":u.search,"aria-controls":"search-form",children:d.jsx(Me,{children:t.formatMessage({id:`header_search_${u.search?"hide":"show"}`})})}),d.jsx(xf,{id:"global-search",handleToggle:{searchIsOpen:u.search,isDesktopVersion:i.search},gtmContext:"search-bar-header",gtmEvent:"form-submission"}),a?d.jsxs("button",{className:"account-button",onClick:h=>Pe.events.onClick(h,{id:"account",callback:f,isOpen:u.account}),onMouseEnter:()=>Pe.events.onMouseEnter({id:"account",callback:f}),onMouseLeave:()=>Pe.events.onBlur({id:"account",callback:f}),"aria-haspopup":"true","aria-expanded":u.account,"aria-controls":"navigation",children:[d.jsx(Me,{children:t.formatMessage({id:`header_account_${u.account?"hide":"show"}`})}),d.jsx(sn,{name:n&&n.name||"",src:n&&n.image&&n.image.thumbnail||""})]}):d.jsx("ul",{className:"sign-in-buttons",children:Sr.buttons.order.map(h=>d.jsx(Pa,{id:`buttons.${h}`},h))})]})]}),d.jsx("hr",{id:"content-of-page"}),d.jsx("div",{className:G("overlay",{open:u.navigation||u.account||!i.search&&u.search})})]})};const Tw=()=>{const e=ue.useIntl();return d.jsxs(d.Fragment,{children:[d.jsx(Eo,{}),d.jsx("div",{id:"content",children:d.jsx(an,{variant:"error",text:e.formatMessage({id:"pageLayout_error"})})}),d.jsx(wo,{})]})},Kf=({children:e,additionalContent:{prepended:t,appended:n}={},reportError:r,forceShow:a={},styling:i={},className:s="",locale:o="en"})=>{const{navigation:l=!0,footer:u=!0}=a,{background:c="default",variant:m="default",circle:f="default",modal:p="default"}=i,g=Dc();x.useEffect(()=>{window.scrollTo(0,0)},[g]);const h=oa(e,{locale:o}),y=oa(t,{locale:o}),b=oa(n,{locale:o}),w={};return c!=="default"&&(w[c]=!0),m!=="default"&&(w[m]=!0),f!=="default"&&(w[f]=!0),d.jsx(yh.ErrorBoundary,{onError:r,fallback:d.jsx(Tw,{}),children:d.jsx(x.Suspense,{fallback:null,children:d.jsxs("div",{id:"wrapper",className:G(s,w,{"has-footer":u}),children:[d.jsx(Eo,{showNavigation:l}),d.jsxs("main",{id:"content-wrapper",children:[y&&d.jsx("div",{className:G("additional-content prepended",{"large-modal":p==="large"}),children:y}),x.createElement(c==="bold"?yo:"div",{id:"content",children:h,className:G({"large-modal":p==="large"})})]}),b&&d.jsx("div",{className:"additional-content appended",children:b}),u&&d.jsx(wo,{}),d.jsx(Vf,{})]})})})},sc={default:"tags_",headerTopics:"header_topics_topics_"},Ki={topic:{Climate:"climate",CitiesAndLocalGovernment:"cities-and-local-government",DigitalAndData:"digital-and-data",Education:"education",EquityJusticeAndInclusion:"equity-justice-and-inclusion",HealthAndSocialCare:"health-and-social-care",Innovation:"innovation",LeadershipAndSkills:"leadership-and-skills",LifeInGovernment:"life-in-government",Policymaking:"policymaking",TransportAndInfrastructure:"transport-and-infrastructure",WorkAndTheEconomy:"work-and-the-economy"},"from the community":"community"},Sw={getTagDetails:e=>{if(e.includes("topic_")){if(e=Ki.topic[e.replace("topic_","")],e){const t=Sr.topics.topics[e].href;return t?{id:e,href:t,text:`${sc.headerTopics}${e}`}:null}return null}return Ki[e]?(e=Ki[e],{id:e,text:`${sc.default}${e}`}):null}};const jw=({tags:e=[],color:t="default",forceOneLine:n=!1,canHaveLinks:r=!0,className:a="",gtmType:i="tag-click",gtmContext:s="tags"})=>{const o=ue.useIntl();if(!e||e.length<1)return null;const l=[];return e.forEach(u=>{if(!u)return;const c=Sw.getTagDetails(u);c&&l.push(c)}),l.length<1?null:d.jsx("ul",{className:G("tags text-small",t,a,{"one-line":n}),children:l.map(u=>{const c=o.formatMessage({id:u.text});return d.jsx("li",{children:u.href&&r?d.jsx("a",{href:u.href,className:"gtm-trackable","data-gtm-event-type":i,"data-gtm-event-context":s,children:c}):c},u.id)})})};const Ow=({members:{data:e=[],total:t=e.length},hasNextPage:n=!1,loadNextPage:r=()=>{},gtmContext:a="member",gtmType:i="member-click",className:s=""})=>{const o=ue.useIntl();return e.length===0?null:d.jsxs("div",{className:G("members-list",s),children:[d.jsxs("h1",{children:[o.formatMessage({id:"membersList"}),d.jsx("span",{className:"count",children:t})]}),d.jsx("ul",{children:e.map((l,u)=>d.jsxs("li",{children:[d.jsx(tr,{member:l,gtmContext:a,gtmType:i}),l.isAdmin&&d.jsx(hn,{children:o.formatMessage({id:"membersList_admin"})})]},u))}),n&&d.jsx(Nr,{hasNextPage:n,loadNextPage:r,icon:{icon:"arrow-down",position:"right"},gtmContext:a})]})};const Pw=({element:e="p",data:{timeLeftToFinish:t,percentageCompleted:{inTime:n=0,inLessons:r=0},shouldShowTimes:a=!0},graph:i,styling:s={},className:o=""})=>{const l=ue.useIntl();let u=a?n:r;u>99?u=100:u<1&&(u=0);const{highlightPercentage:c=!1}=s;return x.createElement(e,{className:G("course-progression",o,{"highlight-percentage":c,"has-circle-graph":i==="circle"}),children:d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"percentage",children:l.formatMessage({id:"courseProgression_done"},{percent:m=>d.jsx("strong",{children:m}),number:u})}),u<100&&a&&d.jsx(Ga,{time:t,appendedText:l.formatMessage({id:"courseProgression_timeLeft"})}),d.jsx(Is,{progress:u,styling:{layout:i||"bar",size:i&&i==="circle"?"small":"default"}})]})})};const Zf=({element:e="span",sectionId:t,subsectionId:n,title:r,className:a=""})=>x.createElement(e,{className:G("lesson-name",a),"data-number":`${t}.${n}`,children:r});const Yf=({size:e="default",completionTime:t,icon:n,optional:r,type:a,children:i})=>{const s=ue.useIntl(),o=$a(`lessonType_${a}`)?s.formatMessage({id:`lessonType_${a}`}):Ac(a||"");return d.jsxs("small",{className:G("content-type",{[e]:e!=="default"}),children:[d.jsx("span",{className:G("type",n),children:o})," ",t>0&&!r&&d.jsx(Ga,{time:t})," ",i?d.jsx("span",{className:"additional",children:i}):null]})};const Nw=({course:{articles:e,canAccessCourse:t,description:n,hideTimes:r,isEnrolled:a,sectionId:i,sectionTime:s,slug:o,timeLeft:l,title:u},quizScores:c})=>{const m=ue.useIntl(),f="courseStructure_",p=u.toLowerCase().includes("course conclusion");return d.jsxs(La,{className:"course-structure",label:d.jsxs(d.Fragment,{children:[d.jsxs("small",{children:[m.formatMessage({id:`${f}section${p?"_end":""}`},{number:i})," ",!r&&s>=0&&d.jsx("span",{className:"time",children:a&&l===0?m.formatMessage({id:`${f}time_completed`}):d.jsx(Ga,{time:s,appendedText:a?m.formatMessage({id:`${f}time_left`}):""})})]}),d.jsx("h3",{children:u})]}),shouldAnimate:!0,children:[d.jsx("p",{children:n}),d.jsx("ol",{children:e&&e.length>0&&e.map(({completed:g,completionTime:h,contentType:y,icon:b,image:w,isIntroduction:A,optional:k,slug:E,subsectionId:T,title:j,type:z})=>{const R=a&&t||A,$={};return w&&($.style={"--image":`url(${w})`}),d.jsx("li",{className:G({article:y===fr.ARTICLE,discussion:y===fr.DISCUSSION,quiz:y===fr.QUIZ,completed:g&&y===fr.ARTICLE,locked:!R}),...$,children:d.jsx(kn,{href:R?`/microcourses/en/${o}/${E}`:void 0,fallbackElement:"span",className:"inner",gtmContext:`MicrocourseOutline${Bc(j)}`,gtmType:"article-click",children:d.jsxs(d.Fragment,{children:[d.jsx(Zf,{sectionId:i,subsectionId:T,title:j,className:"course-title"})," ",d.jsx(Yf,{completionTime:h,icon:b,optional:k,type:z,children:c&&c[E]&&d.jsx("span",{className:"quiz-score",children:`${c[E]}%`})})]})})},E)})})]})};const Rw=({isComplete:e=!1,onClick:t,...n})=>{const r=ue.useIntl();return n["data-gtm-event-context"]||(n["data-gtm-event-context"]="LessonIntroduction"),d.jsx(Ee,{...n,variant:"tertiary",icon:e?{icon:"check-inside-circle_no-overlap_inverted"}:{icon:"check-inside-circle_no-overlap",hover:"check-inside-circle_no-overlap_inverted"},onClick:t,className:G("mark-complete-button center gtm-trackable",{completed:e}),"data-gtm-event-type":"mark-as-complete",disabled:e,children:r.formatMessage({id:`markCompleteButton${e?"_completed":""}`})})};let aa=null;const ut="discussion_form_",Qa=({id:e,content:t={type:"response",slugs:{}},userHasPermissions:n=!0,meta:r={isLoading:!1,isInWrapper:!1,isEditing:!1,showTitle:!1,showSuccessMessage:!0},placeholder:a,maxLength:i=0,forceShow:s={cancel:!1,error:!1},functions:o={create:()=>{},handleSaveEdit:()=>{},handleCancel:()=>{},callback:()=>{},getUsers:()=>Promise.resolve([]),props:{create:{projectNames:["questions-answers"]}}},data:l={},gtmContext:u="DiscussionForm"})=>{var R,$,M;const c=ue.useIntl(),m=x.useContext(Mt),[f,p]=x.useState(r.isEditing&&r.isEditing.text||""),[g,h]=x.useState(s.error||!1),[y,b]=x.useState(!1);if(r.isLoading)return d.jsx(wt,{className:"discussion-card discussion-form","data-testid":"loading-placeholder"});const w=C=>{p(C);let B;!m||!m.id?B=Ft(c.formatMessage,`${ut}error_loggedOut`,t.type,"action"):n?i>0&&C.length>=i&&(B=`${ut}error_tooLong`):B=Ft(c.formatMessage,`${ut}error_noPermission`,t.type,"action"),B?h(B):g&&h(!1)};let A=`${t.type}-form`;if(t.type==="response"||t.type==="reply"){const C=((R=t.slugs)==null?void 0:R.reply)||(($=t.slugs)==null?void 0:$.answer)||((M=t.slugs)==null?void 0:M.question)||"";C&&(A=`${A}-${C.slice(-15)}`)}e&&(A=`${e}-${A}`);const k=async C=>{var F;if(C.preventDefault(),C.stopPropagation(),!m||!m.id||!n||T)return;aa&&clearTimeout(aa),b("submitting");const B=window.location.pathname;try{let N;switch(t.type){case"post":N=await o.create({content:f});break;case"question":N=await o.create({title:f,authorId:m&&m.id,...(F=o.props)==null?void 0:F.create});break;case"response":N=await o.create({questionSlug:t.slugs.question},{body:f,authorId:m&&m.id,contentPath:B});break;case"reply":N=await o.create({questionSlug:t.slugs.question,answerSlug:t.slugs.answer},{body:f,authorId:m&&m.id,contentPath:B});break;default:break}await Th(1e3),o.callback&&await o.callback(N),aa=setTimeout(()=>{p(""),b("submitted");const L=new Event("discussionFormSubmitted");document.dispatchEvent(L),E()},500)}catch(N){const L=N;let W=`${ut}error`;L!=null&&L.message.includes("entry already exists")&&(W=Ft(c.formatMessage,`${ut}error_alreadyExists`,t.type,"action")),L!=null&&L.message.includes("429")?W=Ft(c.formatMessage,`${ut}error_tooMany`,t.type,"action"):L!=null&&L.message.includes("400")&&(W=`${ut}error`),h(W),E()}},E=()=>{aa=setTimeout(()=>{h(!1),b(!1)},5e3)},T=!f||!Mh(f),j=y==="submitting",z=[];return(r.isEditing&&!j||s.cancel)&&z.push({variant:"secondary",size:{mobile:"small",600:"medium"},onClick:o.handleCancel,className:"gtm-trackable","data-gtm-event-context":u,"data-gtm-event-type":`cancel-${t.type}-click`,disabled:!s.cancel&&(!m||!m.id||!f),children:c.formatMessage({id:`${ut}cancel`})}),z.push({variant:"primary",size:{mobile:"small",600:"medium"},onClick:C=>{if(r.isEditing){b("submitting"),o.handleSaveEdit&&o.handleSaveEdit(f);return}k(C)},className:"gtm-trackable","data-gtm-event-context":u,"data-gtm-event-type":`${r.isEditing?"save":"submit"}-${t.type}-click`,"data-testid":"save-button",disabled:!m||!m.id||!n||T||j||r.isEditing&&f===r.isEditing.text,children:c.formatMessage({id:`${ut}${j?r.isEditing?"saving":"posting":r.isEditing?"save":"post"}`})}),d.jsxs("form",{id:A,className:G("discussion-card discussion-form",{"no-styling":r.isInWrapper&&r.isEditing}),"data-testid":`discussion-${t.type}-form`,children:[(r==null?void 0:r.showTitle)&&!r.isEditing&&["question"].includes(t.type)&&d.jsx("h2",{children:Ft(c.formatMessage,`${ut}title`,t.type,"action")}),d.jsx(tr,{member:m||"community",gtmContext:u,gtmType:"profile-click"}),d.jsx(Me,{element:"label",showOnFocus:!1,htmlFor:`${A}-input`,children:Ft(c.formatMessage,`${ut}label`,t.type,"action")}),d.jsx(yf,{id:`${A}-input`,value:y==="submitting"&&!g?"":f,placeholder:a||Ft(c.formatMessage,`${ut}placeholder`,t.type,"action"),maxLength:i,functions:{onChange:w,getUsers:o.getUsers},data:l,autoFocus:!!r.isEditing,"aria-invalid":!!g,"aria-errormessage":"error-message"}),d.jsx("small",{children:Ft(c.formatMessage,`${ut}explainer`,t.type,"action",{a:C=>d.jsx("a",{href:"https://about.apolitical.co/q-and-a-community-guidelines",target:"_blank",className:"gtm-trackable","data-gtm-event-context":u,"data-gtm-event-type":"community-guidelines-link",rel:"noreferrer",children:C})})}),d.jsx(En,{buttons:z}),y==="submitted"&&r.showSuccessMessage&&d.jsx(wr,{className:"success","data-testid":"success",children:Ft(c.formatMessage,`${ut}success`,t.type,"action")}),g&&d.jsx(wr,{id:"error-message",className:"error","data-testid":"error",children:s.error?s.error:typeof g=="string"?g.includes(" ")?g:c.formatMessage({id:g},{action:c.formatMessage({id:`discussion_action_${t.type}`}),maxLength:i}):g})]})},ko=({form:e,membershipRequiredToPost:{isMember:t,required:n,join:r,leave:a,notMemberStateText:i}})=>{if(n&&!t)return d.jsx(an,{text:i,button:{breakpoints:{mobile:!0,901:!1},component:d.jsx(Co,{isShort:!0,functions:{join:r,leave:a}})}});const{content:s,functions:o,meta:l,...u}=e;return d.jsx(Qa,{content:{type:(s==null?void 0:s.type)||"reply",slugs:(s==null?void 0:s.slugs)||{}},functions:{...o,create:(o==null?void 0:o.create)||(()=>{})},meta:{...l,isEditing:(l==null?void 0:l.isEditing)||!1,showSuccessMessage:!1},...u,id:`add-post-${u.id||""}`})},Mw={showForm:!1},Ja=x.createContext(Mw),Gf=({children:e})=>{const[t,n]=x.useState({showForm:!1});return d.jsx(Ja.Provider,{value:{...t,updateConversation:n},children:e})},Iw=({question:e,answer:t,reply:n})=>({...e&&{questionSlug:e},...t&&{answerSlug:t},...n&&{replySlug:n}}),$w=(e,t=10)=>!e||e.length===0?[]:e.slice(0,t);const Ss=({icon:e,...t})=>d.jsx(Ee,{className:"discussion-button",variant:"tertiary",icon:e,...t});let xr=!1;const Zi=()=>{xr!==!1&&(clearTimeout(xr),xr=!1)},Yi=5;let Gi=null;const Qf=({element:e="div",likes:t=0,peopleWhoLiked:n=!1,isShort:r=!0,userLiked:a=!1,content:i={type:"reply",slugs:{}},canLike:s=!0,functions:{createLike:o=()=>{},deleteLike:l=()=>{}}={}})=>{const u=ue.useIntl(),c={numberOfLikes:t,userLikedContent:a,ignoreInteractions:!1,showLikers:!1,tabbableLink:0},[m,f]=x.useReducer(jr,c),{numberOfLikes:p,userLikedContent:g,ignoreInteractions:h,showLikers:y,tabbableLink:b}=m;x.useEffect(()=>{f([{type:"userLikedContent",value:a}])},[a]);const w=x.useMemo(()=>$w(n,Yi),[n]),A=j=>{if(j.preventDefault(),j.stopPropagation(),f([{type:"showLikers",value:!1}]),xr)return Zi(),!1;if(Zi(),h||!s)return!1;xr=setTimeout(k,350)},k=async()=>{if(Zi(),h||!s)return!1;let j=g?p-1:p+1;j<0&&(j=0),f([{type:"ignoreInteractions",value:!0},{type:"numberOfLikes",value:j},{type:"userLikedContent",value:!g}]);try{if(i&&i.slugs){const z=Iw(i.slugs);g?await l(z):await o({...z,payload:{contentPath:window.location.pathname}})}}catch{f([{type:"numberOfLikes",value:t},{type:"userLikedContent",value:a}])}finally{f([{type:"ignoreInteractions",value:!1}])}},E=()=>{Gi=setTimeout(()=>{f([{type:"showLikers",value:!1}])},500)},T=()=>{Gi&&clearTimeout(Gi)};return x.createElement(e,{className:"likes-wrapper",onKeyDown:j=>{j.key==="Escape"&&f([{type:"showLikers",value:!1}])},onMouseEnter:()=>{T(),f([{type:"showLikers",value:!0}])},onMouseLeave:()=>{E()}},d.jsxs(d.Fragment,{children:[d.jsx(Ss,{className:G("discussion-button text-medium action-button",{"show-spinner":h,"is-liked":g,disabled:!s}),icon:{icon:g?"heart":"heart_empty",animate:"bounce"},disabled:!s,"data-testid":"like-button","data-gtm-event-context":"Likes","data-gtm-event-type":`like-${i.type}-click`,onClick:A,screenreaderText:s?u.formatMessage({id:`discussion_likes_${g?"unlike":"like"}`},{action:u.formatMessage({id:`discussion_action_${i.type}`})}):!1,"aria-pressed":g,children:d.jsx("span",{"data-testid":"number-of-likes",className:"number-of-likes",children:u.formatMessage({id:`discussion_likes${r?"_short":""}`},{number:p})})}),n&&d.jsxs(d.Fragment,{children:[d.jsx(Me,{element:"button",className:"tertiary small icon navigation_arrow",onFocus:()=>{T()},onBlur:()=>E,onClick:j=>{var R;j.preventDefault(),j.stopPropagation(),T(),f([{type:"showLikers",value:!0}]);const z=(R=j.currentTarget.nextSibling)==null?void 0:R.childNodes[0];if(z){const $=z.querySelector("li:first-child a");$&&(f([{type:"tabbableLink",value:0}]),setTimeout(()=>{$.focus()},100))}},onKeyDown:j=>{j.key==="Escape"&&(j.preventDefault(),j.stopPropagation(),E())},"aria-expanded":y,"aria-controls":`likes-tooltip-${i.slug}`,children:d.jsx(Me,{showOnFocus:!1,children:u.formatMessage({id:"discussion_likes_show"},{action:i.type})})}),d.jsx(Jn,{id:`likes-tooltip-${i.slug}`,isOpen:y,isLoading:n.length===0,children:n.length&&d.jsxs("ul",{children:[w.map((j,z)=>{if(typeof j=="string"||!j.name)return null;const R={};return b!==z&&(R.tabIndex=-1),d.jsx("li",{"data-index":z,children:d.jsx(kn,{href:j.id?`/profiles/${j.id}`:void 0,gtmContext:"Likes",gtmType:"liked-name-click",onClick:$=>$==null?void 0:$.stopPropagation(),onFocus:()=>T(),onKeyDown:$=>{var N,L,W,ae;if(!$||!["ArrowUp","ArrowDown"].includes($.key||""))return;$.stopPropagation(),$.preventDefault();const M=$.key==="ArrowUp"?"up":"down",C=(N=$.currentTarget)==null?void 0:N.parentElement;let B=C==null?void 0:C.nextElementSibling;if(M==="up"){const ne=C==null?void 0:C.previousElementSibling;ne?B=ne:(B=(L=C==null?void 0:C.parentElement)==null?void 0:L.lastElementChild,(B==null?void 0:B.getAttribute("data-index"))==="-1"&&(B=B==null?void 0:B.previousElementSibling))}else(!B||(B==null?void 0:B.getAttribute("data-index"))==="-1")&&(B=(W=C==null?void 0:C.parentElement)==null?void 0:W.firstElementChild);if(!B)return;const F=(B==null?void 0:B.getAttribute("data-index"))||"0";f([{type:"tabbableLink",value:F}]),(ae=B==null?void 0:B.querySelector("a"))==null||ae.focus()},...R,children:j.name})},j.id||window.btoa(j.name))}),t>Yi&&d.jsx("li",{"data-index":"-1",children:u.formatMessage({id:"discussion_likes_more"},{number:t-Yi})})]})})]})]}))},oc=e=>{const t={};return Object.keys(e).forEach(n=>n.includes("Id")?t[n]=e[n]:t[`${n}Slug`]=e[n]),t},Xa=(e,t)=>e&&!t,Qi=({children:e,class:t,...n})=>{const r={...n,class:G("subtle",t)};return d.jsx("blockquote",{...r,children:e})},Lw=280,zw=(e,t,n)=>{let r=t?Wn(e,Lw):e;return r=r.trim(),n&&(r=r.replace(Ns,(a,i)=>{var o;const s=n[i];return!s||!s.id||!s.data||!s.data.name?a:s?`<a href="/profiles/${s==null?void 0:s.id}" class="mentioned-user">@${(o=s==null?void 0:s.data)==null?void 0:o.name}</a>`:a})),r};const zt="discussion_",qw=195,Rr=({element:e="div",content:t,userHasPermissions:n=!0,isLoading:r=!1,originalAuthorId:a,forceHide:i={actionBar:!1,comments:!1,likes:!1},functions:{content:{createContent:s,deleteContent:o,updateContent:l}={createContent:async()=>{},deleteContent:async()=>{},updateContent:async()=>{}},likes:{createLike:u,deleteLike:c}={createLike:()=>{},deleteLike:()=>{}},comments:{openComments:m}={openComments:()=>{}},mentions:{getUsers:f}={getUsers:()=>Promise.resolve([])}},links:p={},className:g,gtmContext:h="DiscussionAnswer",children:y,isTruncated:b=!1})=>{const w=ue.useIntl(),A=x.useContext(Mt),k=x.useContext(Ja),{author:E,canLike:T,createdAt:j,id:z,likes:R=0,userLiked:$,comments:M=0,mentions:C}=t,B=A&&A.id&&typeof E!="string"&&E.id&&E.id===A.id||!1,F=typeof T=="boolean"?T:n?!B:!1,N=B&&(!t.createdAt||Ah(t.createdAt,10,"seconds")),L=x.useRef(null),[W,ae]=x.useState({body:t&&t.body||"",isEditing:!1,didEdit:t&&t.isEdited||!1}),[ne,D]=x.useState(!1),[U,X]=x.useState(N?"highlighted":"default"),[_,S]=x.useState("");x.useEffect(()=>{const H=L.current;if(!(!H||U==="default"))return document.addEventListener("discussionFormSubmitted",q),H.addEventListener("transitionend",I),()=>{document.removeEventListener("discussionFormSubmitted",q),H.removeEventListener("transitionend",I)}},[]),x.useEffect(()=>{ae({...W,body:t&&t.body||"",didEdit:t&&t.isEdited||!1})},[t.isEdited]);const q=()=>{setTimeout(()=>{X("fading")},1e3)},I=({propertyName:H})=>{H==="background-color"&&X(de=>(de==="default"&&(document.removeEventListener("discussionFormSubmitted",q),L.current&&L.current.removeEventListener("transitionend",I)),de==="fading"?"default":de))};if(r||!t||t.type==="answer"&&(!t.slugs||!t.slugs.question))return d.jsx(wt,{className:"discussion-card discussion-post"});const V=zw(W.body,b,C),te=async H=>{H||(H=""),S("");try{if(!gc(H,W.body)){const de=t.type==="question"?{title:H}:{body:H};await l(oc(t.slugs),de)}ae({body:H,isEditing:!1,didEdit:!0})}catch{S(`${zt}form_error`)}},ee=()=>{k&&k.updateConversation&&k.updateConversation({showForm:!0}),setTimeout(()=>{var je,Oe,He;const de=`reply-form-${(t.type==="answer"?t.slug:((je=t.slugs)==null?void 0:je.reply)||((Oe=t.slugs)==null?void 0:Oe.answer)||((He=t.slugs)==null?void 0:He.question)||"").toLowerCase().slice(-15)}`,pe=document.getElementById(de),we=document.getElementById(`${de}-input`);we&&we.focus(),pe&&pe.scrollIntoView({behavior:"smooth"})},0)},ie=async()=>{D(!1);try{await o(oc(t.slugs))}catch{S("delete-error")}},he=[{text:w.formatMessage({id:`${zt}moreMenu_report`}),onClick:H=>{H.stopPropagation()},href:`mailto:community@apolitical.co?subject=${encodeURI(w.formatMessage({id:`${zt}report_subject`}))}&body=${encodeURI(w.formatMessage({id:`${zt}report_body`},{contentType:t.type||"",contentSlug:t.slug||"",contentUrl:`${window.origin}${typeof process<"u"&&process.env.PUBLIC_URL||""}/${t.slugs.question||""}`}))}`,icon:"flag"}];return n&&B&&he.push({text:w.formatMessage({id:`${zt}moreMenu_edit`}),onClick:()=>ae({...W,isEditing:!0}),icon:"pencil-paper",className:"gtm-trackable","data-gtm-event-context":h,"data-gtm-event-type":`edit-${t.type}-click`},{text:w.formatMessage({id:`${zt}moreMenu_delete`}),onClick:H=>{H.preventDefault(),H.stopPropagation(),D(!0)},icon:"trash",className:"gtm-trackable","data-gtm-event-context":h,"data-gtm-event-type":`delete-${t.type}-click`,...Lf(`delete-${t.slug}-modal`,ne)}),x.createElement(e,{className:G("discussion-post",g,{[U]:!g||!g.includes("highlighted-text-box"),"has-link":p.post&&!W.isEditing}),ref:L,"data-testid":`discussion-${t.type}-thread`,"data-gtm-event-context":`${h}-post-click`,onClick:H=>{!p.post||W.isEditing||(H.preventDefault(),H.stopPropagation(),window.location.href=p.post)},children:d.jsxs(d.Fragment,{children:[d.jsxs("div",{id:z||t.slug,className:G("discussion-card",t.type,{editing:W.isEditing,"has-link":p.post&&!W.isEditing}),children:[!W.isEditing&&d.jsx(tr,{member:E,additionalContent:{createdAt:j,didEdit:W.didEdit},className:typeof E!="string"&&E.id===a?"highlighted":"",gtmContext:h,gtmType:"profile-click"}),W.isEditing?d.jsx(Qa,{id:`editing-${t.slug}`,content:{type:t.type,slugs:t.slugs},userHasPermissions:n,meta:{isLoading:r,isInWrapper:!0,isEditing:{text:W.body}},maxLength:t.type==="question"?250:5e4,forceShow:{error:_!==""&&_!=="delete-error"?w.formatMessage({id:_},{action:w.formatMessage({id:`discussion_action_${t.type}`})}):!1},functions:{create:s,handleSaveEdit:te,handleCancel:()=>{S(""),ae({...W,isEditing:!1})},getUsers:f},gtmContext:`${h}Form`,data:{mentions:t.mentions}}):p.post?d.jsxs("a",{href:p.post,children:[(t==null?void 0:t.title)&&d.jsx("p",{className:"content-title",children:t==null?void 0:t.title}),V.length>qw?d.jsx(Ic,{text:V,markdownOptions:{overrides:{a:as,blockquote:{component:Qi}}}}):d.jsx(Un,{options:{overrides:{a:as,blockquote:{component:Qi}}},children:V})]}):d.jsx(Un,{options:{wrapper:t.type==="question"?"h1":x.Fragment,forceWrapper:t.type==="question",forceInline:t.type==="question",forceBlock:t.type!=="question",overrides:{blockquote:{component:Qi}}},children:V}),!W.isEditing&&!(i!=null&&i.actionBar)&&d.jsxs("ul",{className:G("actions text-medium",t.type),"data-testid":`${t.type}-actions`,children:[!i.likes&&d.jsx(Qf,{element:"li",likes:R,isShort:!1,userLiked:$,content:{type:t.type,slugs:t.slugs,slug:t.slug},canLike:F,peopleWhoLiked:t.peopleWhoLiked,functions:{createLike:u,deleteLike:c}}),!i.comments&&(["question","post"].includes(t.type)||p.comments||typeof m=="function")&&d.jsx("li",{children:d.jsx(Ss,{onClick:H=>{H.preventDefault(),H.stopPropagation(),p.comments&&(window.location.href=p.comments),typeof m=="function"&&m()},icon:{icon:"speech-bubble_square_thick"},"data-gtm-event-context":h,"data-gtm-event-type":`answer-${t.type}-click`,screenreaderText:w.formatMessage({id:`${zt}comments_screenReader`},{count:M}),children:w.formatMessage({id:`${zt}comments`},{count:M})})}),(t.type==="answer"||t.type==="reply")&&d.jsx("li",{children:d.jsx(Ss,{styling:{muted:!0},onClick:ee,icon:{icon:"speech-bubble_square_thick"},children:w.formatMessage({id:`${zt}reply`})})}),d.jsx(Wf,{element:"li",id:`more-${t.slug}`,options:he})]})]}),y,d.jsx(Pr,{id:`delete-${t.slug}-modal`,isOpen:ne,functions:{onOpen:()=>{},onClose:()=>D(!1)},forceShow:{error:_==="delete-error"?w.formatMessage({id:"discussion_delete_error"},{action:w.formatMessage({id:`discussion_action_${t.type}`})}):!1},title:w.formatMessage({id:"discussion_delete_title"},{action:w.formatMessage({id:`discussion_action_${t.type}`})}),buttons:[{variant:"secondary",onClick:()=>D(!1),children:w.formatMessage({id:"discussion_delete_cancel"})},{variant:"primary",className:"destructive",onClick:ie,children:w.formatMessage({id:"discussion_delete_delete"})}],gtmContext:`${t.type.charAt(0).toUpperCase()}${t.type.slice(1)}:${t.slug}`,children:d.jsx(ue.FormattedMessage,{id:"discussion_delete_text",values:{p:H=>d.jsx("p",{children:H}),action:w.formatMessage({id:`discussion_action_${t.type}`})}})})]})})};const Ji="discussion_responses_",Jf=({type:e="answer",responses:t=0})=>{const n=ue.useIntl();return t=parseInt(t),d.jsxs("div",{className:"responses-heading",children:[d.jsx("h4",{children:n.formatMessage({id:`${Ji}title`},{action:n.formatMessage({id:`${Ji}${e}`}),count:t})}),t===0&&d.jsx("p",{children:Ft(n.formatMessage,`${Ji}empty`,e,e)})]})};const Xf=({loadMore:{isLoading:e,hasNextPage:t,loadNextPage:n}={isLoading:!1,hasNextPage:!1,loadNextPage:()=>{}},form:r,children:a})=>{const i=ue.useIntl(),s=x.useContext(Ja),o=oa(a,{element:"li"});return d.jsxs("div",{className:G("thread-wrapper",{"empty-thread":!o}),children:[!Object.is(o,null)&&d.jsx("ul",{className:"thread",children:o}),!e&&d.jsx(Nr,{hasNextPage:t,loadNextPage:n,size:"small",styling:{muted:!0},icon:{icon:"arrow_corner-down_right",position:"left"},messages:{button:i.formatMessage({id:"discussion_thread_loadMore"}),error:i.formatMessage({id:"loadMore_error"})}}),r&&s.showForm&&d.jsx(Qa,{...r})]})},Ww="post",Hw="reply",eh="00000000-0000-0000-0000-000000000000";function _o({queryClient:e,queryKey:t}){function n(r,a,i){e.setQueryData(t,i)}return n}function Bo({queryClient:e,queryKey:t}){async function n(r){await e.cancelQueries({queryKey:t});const a=e.getQueryData(t);return e.setQueryData(t,r),a}return n}function Uw(){return{latest_reactions:{like:[],reply:[]},reaction_counts:{like:0,reply:0},own_reactions:{like:[],reply:[]}}}function Vw(){return{latest_children:{like:[],reply:[]},children_counts:{like:0,reply:0},own_children:{like:[],reply:[]}}}function th(e){const{id:t="",name:n="",organization:r="",jobTitle:a="",image:i={}}=e,{thumbnail:s=""}=i;return{id:t,data:{name:n,organization:r,jobTitle:a,thumbnail:s}}}function Kw({content:e}){return{content:e,id:eh,time:new Date().toISOString(),verb:Ww}}function uc({activity:e,user:t}){return{...e,actor:th(t),...Uw()}}function Na({activity:e,reaction:t}){var n,r,a;t?(e.latest_reactions={...e.latest_reactions||{},like:[...((r=e.latest_reactions)==null?void 0:r.like)||[],t]},e.own_reactions={...e.own_reactions||{},like:[...((a=e.own_reactions)==null?void 0:a.like)||[],t]}):e.reaction_counts={...e.reaction_counts||{},like:(n=e.reaction_counts)!=null&&n.like?e.reaction_counts.like+1:1}}function nh({activity:e,user:t}){var n,r,a;e.reaction_counts={...e.reaction_counts||{},like:(n=e.reaction_counts)!=null&&n.like?e.reaction_counts.like-1:0},t!=null&&t.id&&(e.latest_reactions={...e.latest_reactions||{},like:(((r=e.latest_reactions)==null?void 0:r.like)||[]).filter(({user_id:i})=>i!==t.id)},e.own_reactions={...e.own_reactions||{},like:(((a=e.own_reactions)==null?void 0:a.like)||[]).filter(({user_id:i})=>i!==t.id)})}function Zw({activityId:e,replyId:t,content:n}){return{activity_id:e,data:{content:n},id:eh,kind:Hw,parent:t||""}}function lc({reply:e,user:t}){const n=th(t);return{...e,user_id:n.id,user:n,...Vw()}}function cc({reply:e,reaction:t}){var n,r,a;t?(e.latest_children={...e.latest_children||{},like:[...((r=e.latest_children)==null?void 0:r.like)||[],t]},e.own_children={...e.own_children||{},like:[...((a=e.own_children)==null?void 0:a.like)||[],t]}):e.children_counts={...e.children_counts||{},like:(n=e.children_counts)!=null&&n.like?e.children_counts.like+1:1}}function Yw({reply:e,user:t}){var n,r,a;e.children_counts={...e.children_counts||{},like:(n=e.children_counts)!=null&&n.like?e.children_counts.like-1:0},t!=null&&t.id&&(e.latest_children={...e.latest_children||{},like:(((r=e.latest_children)==null?void 0:r.like)||[]).filter(({user_id:i})=>i!==t.id)},e.own_children={...e.own_children||{},like:(((a=e.own_children)==null?void 0:a.like)||[]).filter(({user_id:i})=>i!==t.id)})}const rh=e=>{const t=new CustomEvent("discussionPostAdded",{detail:e});document.dispatchEvent(t)};let dc,Xi=0;const ah=()=>{x.useEffect(()=>(document.addEventListener("discussionPostAdded",e),()=>{document.removeEventListener("discussionPostAdded",e)}),[]);const e=t=>{const n=t.detail;if(!n)return;clearTimeout(dc);const r=document.getElementById(n);if(r){r.scrollIntoView({behavior:"smooth",block:"start"}),Xi=0;return}Xi++,!(Xi>10)&&(dc=setTimeout(()=>{e(t)},50))}},Gn=Object.freeze({id:"some-user-id-1",name:"some user name 1",organization:"some user organization 1",jobTitle:"some user job title 1",image:{thumbnail:"https://some-user-thumbnail.com/avatar1.png"},isLoading:!1}),rn=Object.freeze({id:"some-user-id-2",name:"some user name 2",organization:"some user organization 2",jobTitle:"some user job title 2",image:{thumbnail:"https://some-user-thumbnail.com/avatar2.png"},isLoading:!1}),ih=Object.freeze({actor:`SU:${Gn.id}`,content:"some content 1",duration:"5.53ms",feed_id:"some-feed-id-1",foreign_id:"post:some-foriegn-id-1",id:"some-activity-id-1",object:"comment",time:"2023-11-24T17:52:36.162000",verb:"post"}),Gw=Object.freeze({actor:`SU:${rn.id}`,content:"some content 2",duration:"5.53ms",feed_id:"some-feed-id-2",foreign_id:"post:some-foriegn-id-2",id:"some-activity-id-2",object:"comment",time:"2023-11-24T17:54:36.162000",verb:"post"}),Qw=Object.freeze({actor:`SU:${Gn.id}`,content:"some content 3",duration:"5.53ms",feed_id:"some-feed-id-3",foreign_id:"post:some-foriegn-id-3",id:"some-activity-id-3",object:"comment",time:"2023-11-24T17:56:36.162000",verb:"post"}),Jw=Object.freeze({actor:`SU:${rn.id}`,content:"some content 4",duration:"5.53ms",feed_id:"some-feed-id-4",foreign_id:"post:some-foriegn-id-4",id:"some-activity-id-4",object:"comment",time:"2023-11-24T17:54:36.162000",verb:"post"});Object.freeze({id:"some-reaction-id-1",activity_id:ih.id,kind:"like",created_at:"2023-11-24T17:58:36.162000",data:{},parent:"",updated_at:"2023-11-24T17:58:36.162000",user_id:rn.id,children_counts:{},latest_children:{},latest_children_extra:{},own_children:{},user:{id:rn.id,data:{},created_at:"2023-11-24T17:58:36.162000",updated_at:"2023-11-24T17:58:36.162000"}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-1",user_id:rn.id,user:{id:rn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:ih.id,data:{content:"Some content 1..."},parent:"",latest_children:{},children_counts:{}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-2",user_id:Gn.id,user:{id:Gn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Gw.id,data:{content:"Some content 2..."},parent:"",latest_children:{},children_counts:{}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-3",user_id:rn.id,user:{id:rn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Qw.id,data:{content:"Some content 3..."},parent:"",latest_children:{},children_counts:{}});Object.freeze({created_at:"2023-12-03T21:53:45.999851Z",updated_at:"2023-12-03T21:53:45.999851Z",id:"some-reply-id-3",user_id:Gn.id,user:{id:Gn.id,data:{},created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z"},kind:"reply",activity_id:Jw.id,data:{content:"Some content 4..."},parent:"",latest_children:{},children_counts:{}});function Xw({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a,user:i}){const{mutate:s}=We.useMutation({mutationFn:e,onMutate:o=>t(l=>{const u=uc({activity:Kw(o),user:i});return fc(u,l)}),onError:n,onSuccess:(o,l,u)=>{const c=uc({activity:o,user:i});r.setQueryData(a,fc(c,u,!0)),setTimeout(()=>{rh(c.id)},0)}});return s}function eE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({activityId:a,content:i})=>t(s=>{const o=Ra(a,s);return o&&(o.content=i),s}),onError:n});return r}function tE({queryFns:{create:e,edit:t,like:n,list:r,remove:a,unlike:i},queryKey:s}){const o=We.useQueryClient(),l=Ya(),u={queryClient:o,queryKey:s},c={mutationHandlers:{error:_o(u),mutate:Bo(u)},user:l,...u},m=Xw({...c,mutationFn:e}),f=eE({...c,mutationFn:t}),p=nE({...c,mutationFn:n}),g=aE({...c,mutationFn:a}),h=iE({...c,mutationFn:i}),{activities:y,...b}=rE({queryKey:s,queryFn:r});return{activities:y,mutations:{create:m,edit:f,remove:g,like:p,unlike:h},user:l,...b}}function nE({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=We.useMutation({mutationFn:e,onMutate:({activityId:s})=>t(o=>{const l=Ra(s,o);return l&&Na({activity:l}),o}),onError:n,onSuccess:(s,{activityId:o},l)=>{const u=Ra(o,l);u&&Na({activity:u,reaction:s}),r.setQueryData(a,l)}});return i}function rE({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}=We.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:{next:null},getNextPageParam:o=>(o==null?void 0:o.next)||null});return{activities:oE(n),error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}}function aE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({activityId:a})=>t(i=>sE(a,i)),onError:n});return r}function iE({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=We.useMutation({mutationFn:e,onMutate:({activityId:i})=>t(s=>{const o=Ra(i,s);return o&&nh({activity:o,user:r}),s}),onError:n});return a}function fc(e,t,n=!1){return t?(n?t.pages[0].results[0]=e:t.pages[0].results=[e,...t.pages[0].results],t):{pages:[{next:"",results:[e]}],pageParams:[""]}}function Ra(e,t){if(t)for(const{results:n}of t.pages){const r=n.find(({id:a})=>a===e);if(r)return r}}function sE(e,t){for(const{results:n}of t.pages){const r=n.findIndex(({id:a})=>a===e);if(r!==-1){n.splice(r,1);break}}return t}function oE(e){var t;return((t=e==null?void 0:e.pages)==null?void 0:t.reduce((n,{results:r})=>[...n,...r],[]))||[]}const uE=({basePath:e,parentId:t,isMember:n,functions:{activities:r,mentions:a,join:i,leave:s}})=>{const o=ue.useIntl(),{activities:l,error:u,fetchNextPage:c,hasNextPage:m,isLoading:f,mutations:{create:p,edit:g,remove:h,like:y,unlike:b},user:w}=tE({queryKey:[e,t,"activities"],queryFns:r});return ah(),u?d.jsx(an,{variant:"error",text:u.message}):d.jsxs("section",{children:[d.jsx(ko,{form:{content:{type:"post",slugs:{}},functions:{create:p,getUsers:a.getUsers},meta:{isEditing:!1,showSuccessMessage:!1}},membershipRequiredToPost:{isMember:n,required:!0,join:i,leave:s,notMemberStateText:o.formatMessage({id:"community_joinToPost"})}}),l==null?void 0:l.map((A,k)=>{var L,W,ae,ne,D,U,X,_;const{id:E,own_reactions:T,latest_reactions:j,reaction_counts:z,mentioned_users:R}=A,$=(((L=j==null?void 0:j.like)==null?void 0:L.length)||0)>0,M=(((W=T==null?void 0:T.like)==null?void 0:W.length)||0)>0,C=M?T==null?void 0:T.like[0].id:"",B=$?(ae=j==null?void 0:j.like)==null?void 0:ae.map(S=>{var q,I,V;return{id:(q=S==null?void 0:S.user)==null?void 0:q.id,name:(V=(I=S==null?void 0:S.user)==null?void 0:I.data)==null?void 0:V.name}}):!1,F=A==null?void 0:A.actor,N=(F==null?void 0:F.id)===(w==null?void 0:w.id);return d.jsx(x.Fragment,{children:d.jsx(Rr,{content:{type:"post",title:A==null?void 0:A.title,body:A==null?void 0:A.content,canLike:Xa(n,N),createdAt:(A==null?void 0:A.time)||"",slugs:{question:`${e}/${t}`,answer:E},slug:E,author:{id:F==null?void 0:F.id,name:(ne=F==null?void 0:F.data)==null?void 0:ne.name,organization:(D=F==null?void 0:F.data)==null?void 0:D.organization,jobTitle:(U=F==null?void 0:F.data)==null?void 0:U.jobTitle,location:(X=F==null?void 0:F.data)==null?void 0:X.location,image:{thumbnail:((_=F==null?void 0:F.data)==null?void 0:_.thumbnail)||void 0}},userLiked:M,likes:(z==null?void 0:z.like)||0,comments:(z==null?void 0:z.reply)||0,peopleWhoLiked:B,mentions:R},links:{post:`${e}/${t}/${E}`,comments:`${e}/${t}/${E}`},gtmContext:"community",functions:{content:{createContent:()=>null,deleteContent:()=>h({activityId:E}),updateContent:(S,{body:q})=>g({activityId:E,content:q})},likes:{createLike:()=>y({activityId:E}),deleteLike:()=>b({activityId:E,reactionId:C})},comments:{openComments:()=>null},mentions:a},isTruncated:!0})},E)}),!f&&d.jsx(Nr,{hasNextPage:m,loadNextPage:()=>c(),icon:{icon:"arrow-down",position:"right"},messages:{button:o.formatMessage({id:"loadMore_button"}),error:o.formatMessage({id:"loadMore_error"})}})]})},lE={next:"id_lt=67ef0342-6f6e-4807-beea-5a9184ec140c&limit=5",results:[{created_at:"2023-12-03T18:47:44.081716Z",updated_at:"2023-12-03T18:47:44.081716Z",id:"256b921e-ffe6-410d-b754-ac1aaee989ce",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 17..."},parent:"",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:02.517688Z",updated_at:"2023-12-03T18:47:24.852582Z",id:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 16 (edited)..."},parent:"",latest_children:{reply:[{created_at:"2023-12-03T19:28:09.799652Z",updated_at:"2023-12-03T19:28:09.799652Z",id:"bf1ec451-e7c3-4ebe-a60e-248b0ec2a671",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 3..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:59.756761Z",updated_at:"2023-12-03T19:27:59.756761Z",id:"7887d921-e2ba-48ef-8089-db24536dbf70",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 2..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:46.534650Z",updated_at:"2023-12-03T19:27:46.534650Z",id:"73f5bdf3-7080-48ac-a8dc-185f71b38b42",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 1..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}}]},own_children:{reply:[{created_at:"2023-12-03T19:28:09.799652Z",updated_at:"2023-12-03T19:28:09.799652Z",id:"bf1ec451-e7c3-4ebe-a60e-248b0ec2a671",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 3..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:59.756761Z",updated_at:"2023-12-03T19:27:59.756761Z",id:"7887d921-e2ba-48ef-8089-db24536dbf70",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 2..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}},{created_at:"2023-12-03T19:27:46.534650Z",updated_at:"2023-12-03T19:27:46.534650Z",id:"73f5bdf3-7080-48ac-a8dc-185f71b38b42",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 1..."},parent:"ecb077fe-9f3d-4066-aca2-1ddbc9ac6de7",latest_children:{},children_counts:{}}]},children_counts:{reply:3}},{created_at:"2023-12-03T17:47:45.107092Z",updated_at:"2023-12-03T17:47:45.107092Z",id:"27a59e8f-f094-442f-88ec-1d5ec2f72790",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 14..."},parent:"",latest_children:{reply:[{created_at:"2023-12-03T18:47:10.603929Z",updated_at:"2023-12-03T18:47:10.603929Z",id:"c32b83d5-c5fc-4253-8531-eb99dcb01f28",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 8..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:47:04.856649Z",updated_at:"2023-12-03T18:47:04.856649Z",id:"5efd80e3-cb11-4748-8c64-f46b71df69c4",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 7..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:22.687552Z",updated_at:"2023-12-03T18:36:22.687552Z",id:"a3a2ebae-6df2-4dc0-beee-2296188b67aa",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 6..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:16.129336Z",updated_at:"2023-12-03T18:36:16.129336Z",id:"72948da5-bf3c-4bd5-9a21-2cee36e0ce8a",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 5..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:40.850756Z",updated_at:"2023-12-03T17:56:40.850756Z",id:"81ebc855-d1f6-4a2c-a788-a251bae406b6",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 4..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:34.103420Z",updated_at:"2023-12-03T17:56:34.103420Z",id:"ddc28de7-4e89-4572-8122-c95dceacc2fd",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 3..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:26.410145Z",updated_at:"2023-12-03T17:56:26.410145Z",id:"916ed4b6-ad87-47bc-9e00-7b0c46180276",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 2..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:19.921740Z",updated_at:"2023-12-03T17:56:19.921740Z",id:"92cddcb2-cbdc-4e69-9c8e-5afe3a607411",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 1..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}}]},own_children:{reply:[{created_at:"2023-12-03T18:47:10.603929Z",updated_at:"2023-12-03T18:47:10.603929Z",id:"c32b83d5-c5fc-4253-8531-eb99dcb01f28",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 8..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:47:04.856649Z",updated_at:"2023-12-03T18:47:04.856649Z",id:"5efd80e3-cb11-4748-8c64-f46b71df69c4",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 7..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:22.687552Z",updated_at:"2023-12-03T18:36:22.687552Z",id:"a3a2ebae-6df2-4dc0-beee-2296188b67aa",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 6..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T18:36:16.129336Z",updated_at:"2023-12-03T18:36:16.129336Z",id:"72948da5-bf3c-4bd5-9a21-2cee36e0ce8a",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 5..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:56:40.850756Z",updated_at:"2023-12-03T17:56:40.850756Z",id:"81ebc855-d1f6-4a2c-a788-a251bae406b6",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Reply 4..."},parent:"27a59e8f-f094-442f-88ec-1d5ec2f72790",latest_children:{},children_counts:{}}]},children_counts:{reply:8}},{created_at:"2023-12-03T17:47:40.066170Z",updated_at:"2023-12-03T17:47:40.066170Z",id:"9ed6a1d0-00b5-4a03-94d7-ac01e188e2e2",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 13..."},parent:"",latest_children:{},children_counts:{}},{created_at:"2023-12-03T17:47:33.107894Z",updated_at:"2023-12-03T17:47:33.107894Z",id:"67ef0342-6f6e-4807-beea-5a9184ec140c",user_id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",user:{created_at:"2023-08-31T07:11:38.677184Z",updated_at:"2023-08-31T07:11:38.677184Z",id:"3a1a02cf-b4d2-4425-b677-2818ec5d775c",data:{name:"Danu Tester"}},kind:"reply",activity_id:"c0ed39d0-8e0f-11ee-8080-8001137b7e08",data:{content:"Testing 12..."},parent:"",latest_children:{},children_counts:{}}],duration:"6.48ms"};function cE({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a,user:i}){const{mutate:s}=We.useMutation({mutationFn:e,onMutate:o=>t(l=>{const u=lc({reply:Zw(o),user:i});return hc(u,l,{replace:!1,append:(o==null?void 0:o.replyId)!==void 0})}),onError:n,onSuccess:(o,l,u)=>{const c=lc({reply:o,user:i});r.setQueryData(a,hc(c,u,{replace:!0,append:(l==null?void 0:l.replyId)!==void 0})),setTimeout(()=>{rh(c.id)},0)}});return s}function dE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({replyId:a,content:i})=>t(s=>{const o=Ma(a,s);return o&&(o.data.content=i),s}),onError:n});return r}function sh({queryFns:{create:e,edit:t,like:n,list:r,remove:a,unlike:i},queryKey:s}){const o=We.useQueryClient(),l=Ya(),u={queryClient:o,queryKey:s},c={mutationHandlers:{error:_o(u),mutate:Bo(u)},user:l,...u},m=cE({...c,mutationFn:e}),f=dE({...c,mutationFn:t}),p=fE({...c,mutationFn:n}),g=mE({...c,mutationFn:a}),h=pE({...c,mutationFn:i}),{replies:y,...b}=hE({queryKey:s,queryFn:r});return{replies:y,mutations:{create:m,edit:f,remove:g,like:p,unlike:h},user:l,...b}}function fE({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=We.useMutation({mutationFn:e,onMutate:({replyId:s})=>t(o=>{const l=Ma(s,o);return l&&cc({reply:l}),o}),onError:n,onSuccess:(s,{replyId:o},l)=>{const u=Ma(o,l);u&&cc({reply:u,reaction:s}),r.setQueryData(a,l)}});return i}function hE({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}=We.useInfiniteQuery({queryKey:t,queryFn:e,initialPageParam:{next:""},getNextPageParam:u=>(u==null?void 0:u.next)||null}),o=DE(n),l=`${o.length||0}${i?"+":""}`;return{replies:o,repliesCount:l,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}}function mE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({replyId:a})=>t(i=>yE(a,i)),onError:n});return r}function pE({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=We.useMutation({mutationFn:e,onMutate:({replyId:i})=>t(s=>{const o=Ma(i,s);return o&&Yw({reply:o,user:r}),s}),onError:n});return a}function gE(e){return{pages:[{next:"",results:[e]}],pageParams:[""]}}function vE(e,t,n){const r=t.pages.length-1,a=t.pages[r].results.length-1;return n!=null&&n.replace?t.pages[r].results[a]=e:t.pages[r].results.push(e),t}function bE(e,t,n){return n!=null&&n.replace?t.pages[0].results[0]=e:t.pages[0].results=[e,...t.pages[0].results],t}function hc(e,t,n){return t?n!=null&&n.append?vE(e,t,n):bE(e,t,n):gE(e)}function Ma(e,t){if(t)for(const{results:n}of t.pages){const r=n.find(({id:a})=>a===e);if(r)return r}}function yE(e,t){for(const{results:n}of t.pages){const r=n.findIndex(({id:a})=>a===e);if(r!==-1){n.splice(r,1);break}}return t}function DE(e){var t;return((t=e==null?void 0:e.pages)==null?void 0:t.reduce((n,r)=>[...n,...r==null?void 0:r.results],[]))||[]}const CE=({basePath:e,parentId:t,activityId:n,replyId:r,isMember:a,functions:i})=>{const s=ue.useIntl(),o=3,{replies:l,fetchNextPage:u,hasNextPage:c,isLoading:m,mutations:{create:f,edit:p,like:g,remove:h,unlike:y},user:b}=sh({queryKey:[e,t,n,r,"replies"],queryFns:{...i,list:k=>i.list({...k,reactionId:r})}});Os([m]);const[w,A]=x.useState(!0);return d.jsxs(d.Fragment,{children:[(l==null?void 0:l.length)>=o&&d.jsx(Ee,{className:"nested-replies-show-toggle",variant:"secondary",size:"small",icon:{icon:`arrow_corner-${w?"up_left":"down_right"}`,position:"left"},onClick:()=>A(!w),children:s.formatMessage({id:`discussion_thread_${w?"hide":"show"}`},{count:l==null?void 0:l.length})}),w&&d.jsx(Xf,{loadMore:{isLoading:m,hasNextPage:c,loadNextPage:()=>u()},form:{content:{type:"reply",slugs:{question:`${e}/${t}`,answer:n,reply:r}},functions:{create:(k,{body:E})=>f({activityId:n,replyId:r,content:E})},meta:{isEditing:!1,showSuccessMessage:!1}},children:l&&l.length>0?l==null?void 0:l.map(k=>{var D,U,X,_,S,q,I,V,te,ee,ie,he;const{id:E,own_children:T,latest_children:j,children_counts:z,mentioned_users:R}=k,M=(((D=T==null?void 0:T.like)==null?void 0:D.length)||0)>0?(U=T==null?void 0:T.like)==null?void 0:U.find(H=>{var de;return((de=H==null?void 0:H.user)==null?void 0:de.id)===(b==null?void 0:b.id)}):!1,C=M?M==null?void 0:M.id:"",B=!!M,N=(((X=j==null?void 0:j.like)==null?void 0:X.length)||0)>0?(_=j==null?void 0:j.like)==null?void 0:_.map(H=>{var de,pe,we;return{id:(de=H==null?void 0:H.user)==null?void 0:de.id,name:(we=(pe=H==null?void 0:H.user)==null?void 0:pe.data)==null?void 0:we.name}}):!1,L=k==null?void 0:k.user,W=(L==null?void 0:L.id)===(b==null?void 0:b.id),ae=Xa(a,W),ne=typeof k.data.content=="string"?(S=k==null?void 0:k.data)==null?void 0:S.content:((I=(q=k==null?void 0:k.data)==null?void 0:q.content)==null?void 0:I.text)||"";return d.jsx(Rr,{content:{id:E,type:"reply",body:ne,canLike:ae,createdAt:k==null?void 0:k.created_at,slugs:{question:`${e}/${t}`,answer:n,reply:k==null?void 0:k.parent},slug:"",author:{id:L==null?void 0:L.id,name:(V=L.data)==null?void 0:V.name,organization:(te=L.data)==null?void 0:te.organization,jobTitle:(ee=L.data)==null?void 0:ee.jobTitle,location:(ie=L.data)==null?void 0:ie.location,image:{thumbnail:((he=L.data)==null?void 0:he.thumbnail)||void 0}},userLiked:B,likes:(z==null?void 0:z.like)||0,peopleWhoLiked:N,mentions:R},functions:{content:{createContent:()=>null,deleteContent:()=>h({replyId:E}),updateContent:(H,{body:de})=>p({replyId:E,content:de})},likes:{createLike:()=>g({replyId:E}),deleteLike:()=>y({replyId:E,reactionId:C})},comments:{},mentions:{getUsers:i.getUsers}}},E)}):null})]})};const oh=({basePath:e,parentId:t,activityId:n,isMember:r,functions:{reactions:a,mentions:i,join:s,leave:o}})=>{const l=ue.useIntl(),{replies:u,repliesCount:c,fetchNextPage:m,hasNextPage:f,isLoading:p,mutations:{create:g,edit:h,like:y,remove:b,unlike:w},user:A}=sh({queryKey:[e,t,n,"replies"],queryFns:a});return Os([p]),ah(),d.jsxs("section",{className:"replies-feed",children:[d.jsx(Jf,{type:"comment",responses:c}),d.jsx(ko,{form:{content:{type:"reply",slugs:{}},functions:{create:(k,{body:E})=>g({activityId:n,content:E}),...i},meta:{isEditing:!1,showSuccessMessage:!1},placeholder:l.formatMessage({id:"discussion_responses_placeholder"})},membershipRequiredToPost:{isMember:r,required:!0,join:s,leave:o,notMemberStateText:l.formatMessage({id:"community_joinToPost"})}}),u==null?void 0:u.map(k=>{var D,U,X,_,S,q,I,V,te,ee,ie,he;const{id:E,own_children:T,latest_children:j,children_counts:z,data:{mentioned_users:R}}=k,M=(((D=T==null?void 0:T.like)==null?void 0:D.length)||0)>0?(U=T==null?void 0:T.like)==null?void 0:U.find(H=>{var de;return((de=H==null?void 0:H.user)==null?void 0:de.id)===(A==null?void 0:A.id)}):!1,C=M?M==null?void 0:M.id:"",B=!!M,N=(((X=j==null?void 0:j.like)==null?void 0:X.length)||0)>0?(_=j==null?void 0:j.like)==null?void 0:_.map(H=>{var de,pe,we;return{id:(de=H==null?void 0:H.user)==null?void 0:de.id,name:(we=(pe=H==null?void 0:H.user)==null?void 0:pe.data)==null?void 0:we.name}}):!1,L=k==null?void 0:k.user,W=(L==null?void 0:L.id)===(A==null?void 0:A.id),ae=Xa(r,W),ne=typeof k.data.content=="string"?(S=k==null?void 0:k.data)==null?void 0:S.content:((I=(q=k==null?void 0:k.data)==null?void 0:q.content)==null?void 0:I.text)||"";return d.jsx(Gf,{children:d.jsx(Rr,{content:{id:E,type:"reply",body:ne,canLike:ae,createdAt:k==null?void 0:k.created_at,slugs:{question:`${e}/${t}`,answer:n,reply:E},slug:E,author:{id:L==null?void 0:L.id,name:(V=L.data)==null?void 0:V.name,organization:(te=L.data)==null?void 0:te.organization,jobTitle:(ee=L.data)==null?void 0:ee.jobTitle,location:(ie=L.data)==null?void 0:ie.location,image:{thumbnail:((he=L.data)==null?void 0:he.thumbnail)||void 0}},userLiked:B,likes:(z==null?void 0:z.like)||0,peopleWhoLiked:N,mentions:R},functions:{content:{createContent:()=>null,deleteContent:()=>b({replyId:E}),updateContent:(H,{body:de})=>h({replyId:E,content:de})},likes:{createLike:()=>y({replyId:E}),deleteLike:()=>w({replyId:E,reactionId:C})},comments:{},mentions:i},children:d.jsx(CE,{basePath:e,parentId:t,activityId:n,replyId:E,isMember:r,functions:{...a,...i}})},E)},E)}),!p&&d.jsx(Nr,{hasNextPage:f,loadNextPage:()=>m(),icon:{icon:"arrow-down",position:"right"},messages:{button:l.formatMessage({id:"loadMore_button"}),error:l.formatMessage({id:"loadMore_error"})}})]})};function xE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({content:a})=>t(i=>(i&&(i.content=a),i)),onError:n});return r}function wE({queryFn:e,queryKey:t}){const{data:n,error:r,isLoading:a,isFetching:i}=We.useQuery({queryFn:e,queryKey:t});return{activity:n,error:r,isLoading:a,isFetching:i}}function EE({queryFns:{read:e,edit:t,like:n,unlike:r},queryKey:a}){const i=We.useQueryClient(),s=Ya(),o={queryClient:i,queryKey:a},l={mutationHandlers:{error:_o(o),mutate:Bo(o)},user:s,...o},u=xE({...l,mutationFn:t}),c=kE({...l,mutationFn:n}),m=_E({...l,mutationFn:r}),{activity:f,...p}=wE({queryKey:a,queryFn:e});return{activity:f,mutations:{edit:u,like:c,unlike:m},user:s,...p}}function kE({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=We.useMutation({mutationFn:e,onMutate:s=>t(o=>(o&&Na({activity:o}),o)),onError:n,onSuccess:(s,o,l)=>{l&&Na({activity:l,reaction:s}),r.setQueryData(a,l)}});return i}function _E({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=We.useMutation({mutationFn:e,onMutate:i=>t(s=>(s&&nh({activity:s,user:r}),s)),onError:n});return a}const BE=({basePath:e,parentId:t,activityId:n,isMember:r,functions:{activities:{remove:a,...i},reactions:s,mentions:o,join:l,leave:u}})=>{var M,C,B,F,N,L,W,ae,ne,D;const c=ue.useIntl(),m=x.useContext(Mt),{activity:f,error:p,isLoading:g,mutations:{edit:h,like:y,unlike:b}}=EE({queryFns:i,queryKey:[e,t,n]});if(g)return d.jsx(wt,{style:{height:"400px"}});if(p||!f)return d.jsx(an,{variant:"error",text:c.formatMessage({id:"activitySection_notFoundError"})});const{own_reactions:w,latest_reactions:A,mentioned_users:k}=f,E=(((M=A==null?void 0:A.like)==null?void 0:M.length)||0)>0,T=(((C=w==null?void 0:w.like)==null?void 0:C.length)||0)>0,j=T?w==null?void 0:w.like[0].id:"",z=E?(B=A==null?void 0:A.like)==null?void 0:B.map(U=>{var X,_,S;return{id:(X=U==null?void 0:U.user)==null?void 0:X.id,name:(S=(_=U==null?void 0:U.user)==null?void 0:_.data)==null?void 0:S.name}}):!1,R=f==null?void 0:f.actor,$=(R==null?void 0:R.id)===(m==null?void 0:m.id);return d.jsxs("section",{className:"activity-section",children:[d.jsx(Rr,{className:"highlighted-text-box subtle",content:{id:n,type:"post",body:f==null?void 0:f.content,canLike:Xa(r,$),createdAt:(f==null?void 0:f.time)||"",slugs:{question:`${e}/${t}`,answer:f==null?void 0:f.id},slug:n,author:{id:R.id,name:(F=R.data)==null?void 0:F.name,organization:(N=R.data)==null?void 0:N.organization,jobTitle:(L=R.data)==null?void 0:L.jobTitle,location:(W=R.data)==null?void 0:W.location,image:{thumbnail:((ae=R.data)==null?void 0:ae.thumbnail)||void 0}},userLiked:T,likes:((ne=f==null?void 0:f.reaction_counts)==null?void 0:ne.like)||0,comments:((D=f==null?void 0:f.reaction_counts)==null?void 0:D.reply)||0,peopleWhoLiked:z,mentions:k},originalAuthorId:R==null?void 0:R.id,forceHide:{comments:!0},functions:{content:{createContent:()=>null,deleteContent:a,updateContent:(U,{body:X})=>h({content:X})},likes:{createLike:()=>y({activityId:n}),deleteLike:()=>b({activityId:n,reactionId:j})},comments:{openComments:()=>{}},mentions:o}},n),d.jsx(oh,{basePath:e,parentId:t,activityId:n,isMember:r,functions:{reactions:s,mentions:o,join:l,leave:u}})]})},AE=({id:e,data:{jobTitle:t,name:n,organization:r,thumbnail:a}})=>({id:e,name:n,jobTitle:t,organization:r,image:{thumbnail:a}}),mc=[{contentType:"solutionArticle",banner:{description:"",url:"//images.ctfassets.net/txbhe1wabmyx/kCcBdXurt3uOKu6NdTPm0/1b6d19179b21f98dbdadf2477c03d267/devin-avery-7gwqj0yyrhm-unsplash.jpg",width:295,height:180,type:"image/jpeg",aspect:"responsiveCard",query:"w=295&h=180&fit=thumb&f=center"},slug:"why-public-servants-must-learn-to-fail",contributors:["community"]},{contentType:"solutionArticle",banner:{description:"",url:"//images.ctfassets.net/txbhe1wabmyx/12Y0W1K0zVcDKzgLZlbfyC/6eb0757a02cbeea19b1b42d7da04d553/ashkan-forouzani-m0l9nbcivuk-unsplash.jpg",width:295,height:180,type:"image/jpeg",aspect:"responsiveCard",query:"w=295&h=180&fit=thumb&f=center"},slug:"organisational-culture-change-and-failure",contributors:[{name:"Mari-Liis",id:"bdb7509c-89ed-4633-8bc0-dbf11f5d9be1"}]},{contentType:"solutionArticle",banner:{description:"",url:"//images.ctfassets.net/txbhe1wabmyx/26TEwu0xVkbQDguuW89fY6/d54ce406cdd652d68979770d526398ab/nik-shuliahin-bunwp1bl0nc-unsplash.jpg",width:295,height:180,type:"image/jpeg",aspect:"responsiveCard",query:"w=295&h=180&fit=thumb&f=center"},slug:"how-to-learn-from-failure-without-causing-a-scandal",contributors:["community"]}];const ia="notFoundError_",FE=()=>{const e=ue.useIntl(),t=[];return mc.forEach((n,r)=>{n.title=e.formatMessage({id:`${ia}post_${r+1}`}),t.push("solutionArticle")}),d.jsxs(Kf,{styling:{background:"bold",circle:"small",variant:"alt-2"},additionalContent:{appended:d.jsxs(ln,{children:[d.jsx(qf,{cards:mc,cardTypes:t,buildCardData:n=>new Promise((r,a)=>{r(n)})}),d.jsx(Ee,{href:"/solution-articles/",children:e.formatMessage({id:`${ia}cta`})})]})},reportError:()=>{},className:"not-found-error",children:[d.jsx("h1",{children:e.formatMessage({id:`${ia}title`})}),d.jsx("p",{children:e.formatMessage({id:`${ia}text`})})]})};exports.ASSETS_BUCKET=Ht;exports.ActivitiesFeed=uE;exports.ActivitySection=BE;exports.AddPost=ko;exports.Banner=Gx;exports.BannerSection=rw;exports.Breadcrumbs=gw;exports.Buckets=Wh;exports.Button=Ee;exports.ButtonWrapper=En;exports.COURSE_CONTENT_TYPES=fr;exports.CacheProvider=Pf;exports.Card=Do;exports.CardBlock=qf;exports.Carousel=mw;exports.CharacterLimit=qs;exports.CollapsibleSection=La;exports.Columns=Uf;exports.CommunityDetails=pw;exports.ContactFooter=Bw;exports.ContactForm=Df;exports.ContentTypeLabel=Nc;exports.Contributors=zs;exports.ConversationContext=Ja;exports.CookieBanner=Vf;exports.CourseProgression=Pw;exports.CourseStructure=Nw;exports.CustomContentBanner=aw;exports.Directory=Vx;exports.DiscussionConversation=Gf;exports.DiscussionForm=Qa;exports.DiscussionLikes=Qf;exports.DiscussionPost=Rr;exports.DiscussionThread=Xf;exports.Divider=tn;exports.DownloadSection=Qx;exports.EMAILS=Pn;exports.EditSection=Xx;exports.EmailHelperTextBox=Wc;exports.EmptyStateBox=an;exports.Filters=vw;exports.FlagsProvider=Nf;exports.Footer=wo;exports.Form=nr;exports.Formatting=Z;exports.FullWidthSection=ln;exports.GlobalProviders=Hx;exports.Header=Eo;exports.HelperTextBox=Mc;exports.HiddenFromScreenReaders=Ia;exports.HideShowTextBox=Ic;exports.HighlightSection=sw;exports.HighlightedTextBox=Nt;exports.INVALID_TOKEN=Fc;exports.IconBulletedList=Vh;exports.ImageContainer=Lh;exports.IntlProvider=Rf;exports.InviteForm=Cf;exports.InviteModal=Ux;exports.JoinButton=Co;exports.LanguageContext=vo;exports.LanguageSwitcher=yw;exports.LessonName=Zf;exports.LessonType=Yf;exports.Link=kn;exports.LoadMore=Nr;exports.LoadingBlock=rm;exports.LoadingPlaceholder=wt;exports.LoadingState=$s;exports.Logo=xo;exports.LogoSection=ew;exports.MarkCompleteButton=Rw;exports.MarkdownText=Un;exports.MarketingBlock=ow;exports.Marks=Ot;exports.Member=tr;exports.MembersList=Ow;exports.Modal=yo;exports.MoreMenu=Wf;exports.NUMBER_OF_COUNTRIES=Bh;exports.NUMBER_OF_USERS=_h;exports.NavigationMenu=Hf;exports.NotFoundError=FE;exports.Overlay=Pr;exports.OverlayContext=bo;exports.OverlayProvider=$f;exports.PageHeading=$c;exports.PageLayout=Kf;exports.PasswordForm=IC;exports.PasswordRules=Zc;exports.Pill=hn;exports.Popover=Pc;exports.Portal=Ms;exports.ProfileImageChange=MC;exports.ProfilePicture=sn;exports.ProgressBar=Is;exports.ProgressTracker=zh;exports.Rating=gm;exports.RepliesFeed=oh;exports.ResponsesHeading=Jf;exports.ResponsiveImage=er;exports.ReturnToNavButton=qh;exports.RichTextEditor=yf;exports.SearchForm=xf;exports.ShareLinks=Ew;exports.SignupForm=HC;exports.Span=as;exports.StatusBanner=wr;exports.TableOfContents=Yx;exports.Tabs=kw;exports.Tags=jw;exports.TestimonialBlock=Zx;exports.TimeToComplete=Ga;exports.Toggle=RC;exports.Tooltip=Jn;exports.TopLevelPage=Aw;exports.UUID_V4_REGEX=Ns;exports.UserContext=Mt;exports.UserProvider=Mf;exports.VisuallyHidden=Me;exports.addAriaProps=Lf;exports.basicReducer=jr;exports.camelCaseToDashCase=_c;exports.checkIntlPathExists=$a;exports.generateConditions=ma;exports.generateCssIcon=Tc;exports.getCharacterLimitProps=qc;exports.getLongDate=Rs;exports.getMember=Ls;exports.getShortDate=Sc;exports.getValueLength=za;exports.headerData=Sr;exports.mapGetStreamData=AE;exports.pageReady=jc;exports.passwordValidator=ns;exports.repliesFeedMock=lE;exports.supportedLanguages=ga;exports.toCamelCase=Bc;exports.toCapitalisedCase=kh;exports.toSentenceCase=Ac;exports.useCurrentPath=Dc;exports.useEffectAfterMount=Hn;exports.useElementWidth=Qn;exports.useOverlay=If;exports.useScrollListener=wc;exports.useScrollToHash=Os;exports.useTooltips=Ps;exports.useUser=Ya;
|
package/index.mjs
CHANGED
|
@@ -23600,8 +23600,9 @@ const yC = ({
|
|
|
23600
23600
|
}, DC = 280, xC = (e, t, n) => {
|
|
23601
23601
|
let r = t ? Yn(e, DC) : e;
|
|
23602
23602
|
return r = r.trim(), n && (r = r.replace(wc, (a, i) => {
|
|
23603
|
+
var o;
|
|
23603
23604
|
const s = n[i];
|
|
23604
|
-
return s ? `<a href="/profiles/${s.id}" class="mentioned-user">@${s.data.name}</a>` : a;
|
|
23605
|
+
return !s || !s.id || !s.data || !s.data.name ? a : s ? `<a href="/profiles/${s == null ? void 0 : s.id}" class="mentioned-user">@${(o = s == null ? void 0 : s.data) == null ? void 0 : o.name}</a>` : a;
|
|
23605
23606
|
})), r;
|
|
23606
23607
|
};
|
|
23607
23608
|
const Kt = "discussion_", wC = 195, ei = ({
|