@apolitical/component-library 4.1.12-beta.2 → 4.1.12-beta.3
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
CHANGED
|
@@ -156,4 +156,4 @@ Valid keys: `+JSON.stringify(Object.keys(D),null," "));var V=le(K,ae,S,W,I+"."+
|
|
|
156
156
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
157
157
|
*/function ec(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 tc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ec(Object(n),!0).forEach(function(r){yx(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ec(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function yx(e,t,n){return t=Cx(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Dx(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 Cx(e){var t=Dx(e,"string");return typeof t=="symbol"?t:String(t)}var nc={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()}},xx=function(t){return t.tagName&&t.tagName.toLowerCase()==="input"&&typeof t.select=="function"},wx=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},Ex=function(t){return Cr(t)&&!t.shiftKey},kx=function(t){return Cr(t)&&t.shiftKey},rc=function(t){return setTimeout(t,0)},ac=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},_x=[],Bx=function(t,n){var r=(n==null?void 0:n.document)||document,a=(n==null?void 0:n.trapStack)||_x,i=tc({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:Ex,isKeyBackward:kx},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(R){var L=R.container,q=R.tabbableNodes;return L.contains(C)||(F==null?void 0:F.includes(L))||q.find(function(oe){return oe===C})})},c=function(C){var B=i[C];if(typeof B=="function"){for(var F=arguments.length,R=new Array(F>1?F-1:0),L=1;L<F;L++)R[L-1]=arguments[L];B=B.apply(void 0,R)}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 q=B;if(typeof B=="string"&&(q=r.querySelector(B),!q))throw new Error("`".concat(C,"` as selector refers to no known node"));return q},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=Of(C,i.tabbableOptions),F=Pf(C,i.tabbableOptions),R=B.length>0?B[0]:void 0,L=B.length>0?B[B.length-1]:void 0,q=F.find(function(D){return dn(D)}),oe=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:R,lastTabbableNode:L,firstDomTabbableNode:q,lastDomTabbableNode:oe,nextTabbableNode:function(H){var X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,_=B.indexOf(H);return _<0?X?F.slice(F.indexOf(H)+1).find(function(S){return dn(S)}):F.slice(0,F.indexOf(H)).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,xx(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,R=C.isBackward,L=R===void 0?!1:R;B=B||Jr(F),f();var q=null;if(s.tabbableGroups.length>0){var oe=u(B,F),ne=oe>=0?s.containerGroups[oe]:void 0;if(oe<0)L?q=s.tabbableGroups[s.tabbableGroups.length-1].lastTabbableNode:q=s.tabbableGroups[0].firstTabbableNode;else if(L){var D=ac(s.tabbableGroups,function(I){var K=I.firstTabbableNode;return B===K});if(D<0&&(ne.container===B||pa(B,i.tabbableOptions)&&!dn(B,i.tabbableOptions)&&!ne.nextTabbableNode(B,!1))&&(D=oe),D>=0){var H=D===0?s.tabbableGroups.length-1:D-1,X=s.tabbableGroups[H];q=Jt(B)>=0?X.lastTabbableNode:X.lastDomTabbableNode}else Cr(F)||(q=ne.nextTabbableNode(B,!1))}else{var _=ac(s.tabbableGroups,function(I){var K=I.lastTabbableNode;return B===K});if(_<0&&(ne.container===B||pa(B,i.tabbableOptions)&&!dn(B,i.tabbableOptions)&&!ne.nextTabbableNode(B))&&(_=oe),_>=0){var S=_===s.tabbableGroups.length-1?0:_+1,W=s.tabbableGroups[S];q=Jt(B)>=0?W.firstTabbableNode:W.firstDomTabbableNode}else Cr(F)||(q=ne.nextTabbableNode(B))}}else q=c("fallbackFocus");return q},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 R,L=!0;if(s.mostRecentlyFocusedNode)if(Jt(s.mostRecentlyFocusedNode)>0){var q=u(s.mostRecentlyFocusedNode),oe=s.containerGroups[q].tabbableNodes;if(oe.length>0){var ne=oe.findIndex(function(D){return D===s.mostRecentlyFocusedNode});ne>=0&&(i.isKeyForward(s.recentNavEvent)?ne+1<oe.length&&(R=oe[ne+1],L=!1):ne-1>=0&&(R=oe[ne-1],L=!1))}}else s.containerGroups.some(function(D){return D.tabbableNodes.some(function(H){return Jt(H)>0})})||(L=!1);else L=!1;L&&(R=y({target:s.mostRecentlyFocusedNode,isBackward:i.isKeyBackward(s.recentNavEvent)})),g(R||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(wx(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 nc.activateTrap(a,o),s.delayInitialFocusTimer=i.delayInitialFocus?rc(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 R=Array.from(F.removedNodes);return R.some(function(L){return L===s.mostRecentlyFocusedNode})});B&&g(m())},N=typeof window<"u"&&"MutationObserver"in window?new MutationObserver(z):void 0,$=function(){N&&(N.disconnect(),s.active&&!s.paused&&s.containers.map(function(C){N.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"),R=l(C,"checkCanFocusTrap");R||f(),s.active=!0,s.paused=!1,s.nodeFocusedBeforeActivation=r.activeElement,B==null||B();var L=function(){R&&f(),T(),$(),F==null||F()};return R?(R(s.containers.concat()).then(L,L),this):(L(),this)},deactivate:function(C){if(!s.active)return this;var B=tc({onDeactivate:i.onDeactivate,onPostDeactivate:i.onPostDeactivate,checkCanReturnFocus:i.checkCanReturnFocus},C);clearTimeout(s.delayInitialFocusTimer),s.delayInitialFocusTimer=void 0,j(),s.active=!1,s.paused=!1,$(),nc.deactivateTrap(a,o);var F=l(B,"onDeactivate"),R=l(B,"onPostDeactivate"),L=l(B,"checkCanReturnFocus"),q=l(B,"returnFocus","returnFocusOnDeactivate");F==null||F();var oe=function(){rc(function(){q&&g(h(s.nodeFocusedBeforeActivation)),R==null||R()})};return q&&L?(L(h(s.nodeFocusedBeforeActivation)).then(oe,oe),this):(oe(),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 Ax=Object.freeze(Object.defineProperty({__proto__:null,createFocusTrap:Bx},Symbol.toStringTag,{value:"Module"})),Fx=yc(Ax),Tx=yc(bx);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 Sx(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ic(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,Rf(r.key),r)}}function jx(e,t,n){return t&&ic(e.prototype,t),n&&ic(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ox(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&&js(e,t)}function js(e,t){return js=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,a){return r.__proto__=a,r},js(e,t)}function Px(e){var t=Nx();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 Rx(this,a)}}function Rx(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 Nx(){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 Mx(e,t,n){return t=Rf(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Rf(e){var t=Ix(e,"string");return Yn(t)==="symbol"?t:String(t)}function Ix(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=nx,$x=Fx,Lx=$x.createFocusTrap,zx=Tx,qx=zx.isFocusable,vo=function(e){Ox(n,e);var t=Px(n);function n(r){var a;Sx(this,n),a=t.call(this,r),Mx(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 jx(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&&!qx(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;vo.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)])};vo.defaultProps={active:!0,paused:!1,focusTrapOptions:{},_createFocusTrap:Lx};var Wx=vo;const Hx=wn(Wx),Nf=({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(yh.ReactQueryDevtools,{initialIsOpen:!1})]})};var Ux=x.createContext({client:sa});function Vx(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(Ux.Provider,{value:{client:i}},t)}const Mf=({children:e,user:t})=>t.isLoading?null:process.env.REACT_APP_PUBLIC_POSTHOG_KEY?d.jsx(Vx,{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}),If=({children:e,locale:t,messages:n})=>{const r=t||"en",a={...Ih[r],...n||{}};return d.jsx(ue.IntlProvider,{locale:r,messages:a,children:e})},bo=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 $f=({children:e,user:t})=>d.jsx(Mt.Provider,{value:t,children:e}),yo=x.createContext({registerOverlay:()=>{},unregisterOverlay:()=>{}}),Lf=()=>x.useContext(yo),zf=({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(yo.Provider,{value:{registerOverlay:r,unregisterOverlay:a},children:e})},Kx=({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}),Pc(5e3)}).catch(c=>{c.message===Tc&&window.location.pathname!=="/user-onboarding/logout"&&(window.location.href="/user-onboarding/logout"),i({isLoading:!1})})},[]),d.jsx(bo.Provider,{value:{language:o,updateLanguage:u},children:d.jsx(If,{locale:o,messages:n==null?void 0:n.messages,children:d.jsx(Ps.CookiesProvider,{children:d.jsx($f,{user:a,children:d.jsx(zf,{children:d.jsx(Nf,{showDevTools:r,children:d.jsx(Mf,{user:a,children:t})})})})})})})};const Do=({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}=Lf(),[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(Do,{id:e,className:G("overlay-modal",c,{"has-max-width":r}),hidden:!h,style:A,children:t&&d.jsx(Hx,{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})]})})})})},qf=(e,t)=>({"aria-haspopup":!0,"aria-expanded":t,"aria-controls":e});const Zx=({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(wf,{title:r,label:a,ctaMessage:i,onClose:o,sendInvites:u,reportError:l})})};const Yx=({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 Gx=({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})})]})]}),Qx=x.memo(Gx);const Jx=({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(Rt,{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 Xx=({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 ew=({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 Wf({href:e,setShowModal:t}){typeof e!="string"&&t(!0)}const tw=({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:Sc(e),children:[d.jsx("p",{children:t||s({id:"edit_section_placeholder_description"})}),a&&d.jsx(Ee,{href:r,variant:"secondary",size:"small",onClick:()=>Wf({href:r,setShowModal:i}),children:n||s({id:"edit_section_placeholder_cta"})})]})},nw=({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:()=>Wf({href:r,setShowModal:u}),children:"Edit"})]}),e||d.jsx(tw,{...s,href:r,setShowModal:u,showEditButton:c}),o&&d.jsx(tn,{})]})};const rw=({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 aw=["small","span","strong","em","p","h1","h2","h3","h4","h5","h6","blockquote","q"],iw=({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&&aw.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}})]})})},sw=x.memo(iw);const ow=({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 uw=({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})})})]})},lw=x.memo(uw);const cw=({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})]}),dw=({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&&rs(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"}):Ms(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&&rs(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"}},fw=({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 hw={title:66,text:3e3,secondaryText:1e3,partner:25},Co=({id:e="",card:t,buildCardData:n,cta:r,gtmContext:a="Carousel",className:i="",handleCardClick:s})=>{var N,$,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={...hw,...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(Mc,{className:"card-label",contentType:h,customIcon:f.isPrivate?"lock-locked":f.customIcon,customLabel:f.customLabel}),h==="communityPage"&&(f==null?void 0:f.createdAt)&&Sh(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"}):jc(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(qs,{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=Bc(C),R={key:C,className:F,"data-testid":F},L={wrapper:"p",forceWrapper:!0,forceInline:!0},q=Wn(B,T[C]);return["title","text"].includes(C)&&k?(L.wrapper="a",d.jsx("p",{...R,children:d.jsx(Pt,{options:L,...z,children:q})})):d.jsx(Pt,{options:L,...R,children:q})}),(l==null?void 0:l.id)&&(f==null?void 0:f.members)&&d.jsxs("span",{className:"member-information",children:[((N=f==null?void 0:f.members)==null?void 0:N.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(dw,{type:b||"",data:f}),d.jsx(fw,{data:f,cta:r,link:k||"",gtmContext:a})]})})};const Hf=({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(Co,{id:s,card:{...a,contentType:t[i]},...r},s)})}),mw=(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},pw=({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 gw=({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(R=>({...R,currentPage:B,loadedPages:[...new Set([...y,B])]}));const F=()=>{const R=B*u.cardsPerPage,L=R+u.cardsPerPage;return t.slice(R,L).length};w(l.formatMessage({id:"carousel_pagination_aria_live"},{direction:C,count:F()}))},z=C=>{ea=C.touches[0].clientX},N=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(Ls,{layout:`carousel${a?"-with-title":""}`});const M=(C,B)=>{var R;let F=null;return(R=C==null?void 0:C.sys)!=null&&R.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(pw,{id:e,title:a}),d.jsx("ul",{className:"carousel",onTouchStart:z,onTouchMove:N,style:$,"data-testid":"carousel-list",children:t.map((C,B)=>{let F=M(C,B);return F&&mw(B,m,h,y)?d.jsx(Co,{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})]})]})},vw=({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(Ls,{layout:`carousel${i?"-with-title":""}`,"data-testid":"carousel-placeholder"}),m?null:d.jsx(tn,{})]},`placeholder-${c}`):d.jsxs(x.Fragment,{children:[d.jsx(gw,{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",xo=({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_",bw=({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(qs,{contributors:{total:a,data:m},styling:{size:"medium",showGap:!0,showPlaceholders:c===0},cutoff:u})]}),d.jsx(xo,{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 yw=({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 Dw=({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)})})},Cw=(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_",xw=({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(bo),[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=Cw(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}),Rr=({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 wo=({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 Uf=({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}`)})})]})})},ww=(e,t=!1)=>t?e.replaceAll("/","")===t:typeof window<"u"&&window.location&&window.location.pathname===e;const Ew=[{key:"homepage",href:"/home/"},{key:"events",href:"/events/"},{key:"microcourses",href:"/microcourses/"},{key:"articles",href:"/solution-articles/"},{key:"communities",href:"/communities/"}],Vf=({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:[Ew.map(({key:a,href:i})=>{const s=ww(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}`:""}`,kw=({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 _w="shareLinks_",Bw=({title:e,link:t,referrer:n,gtmContext:r="ShareLinks",size:a="large",variant:i="default",className:s=""})=>{const o=ue.useIntl(),l=kw({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:`${_w}link_${u}`}),...g})},u)})})]})};const Aw=({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 Fw={"2-1":901,"1-3":769,"1-1":769},Kf=({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<Fw[e]?null:o)})};let qi;const Wi="contactFooter_",Tw=({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(xf,{functions:{onSuccess:e,onFailure:t},gtm:{context:"FooterContactUsForm",event:"contact-form-submit-click"}})]})]})})},Sw=({activeLink:e,...t})=>d.jsx(ln,{children:d.jsx(Kf,{layout:"1-3",children:d.jsxs(d.Fragment,{children:[d.jsx(Vf,{activeLink:e}),d.jsx(zc,{...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),Zf=()=>{const e=ue.useIntl(),[t,n,r]=Ps.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",sc=({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)},Eo=()=>d.jsx("div",{id:"footer",children:d.jsxs("div",{className:"wrapper",children:[d.jsx(Ia,{element:"hr"}),d.jsx(wo,{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(sc,{group:e}),Object.keys(qt[e]).includes("child")&&d.jsx(sc,{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=bc(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=bc(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 jw={height:67,height_desktop:83},ko=({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]),Ec({scrollPosition:jw[`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(wo,{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(Ef,{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 Ow=()=>{const e=ue.useIntl();return d.jsxs(d.Fragment,{children:[d.jsx(ko,{}),d.jsx("div",{id:"content",children:d.jsx(an,{variant:"error",text:e.formatMessage({id:"pageLayout_error"})})}),d.jsx(Eo,{})]})},Yf=({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=Cc();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(Ch.ErrorBoundary,{onError:r,fallback:d.jsx(Ow,{}),children:d.jsx(x.Suspense,{fallback:null,children:d.jsxs("div",{id:"wrapper",className:G(s,w,{"has-footer":u}),children:[d.jsx(ko,{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"?Do:"div",{id:"content",children:h,className:G({"large-modal":p==="large"})})]}),b&&d.jsx("div",{className:"additional-content appended",children:b}),u&&d.jsx(Eo,{}),d.jsx(Zf,{})]})})})},oc={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"},Pw={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:`${oc.headerTopics}${e}`}:null}return null}return Ki[e]?(e=Ki[e],{id:e,text:`${oc.default}${e}`}):null}};const Rw=({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=Pw.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 Nw=({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(Rr,{hasNextPage:n,loadNextPage:r,icon:{icon:"arrow-down",position:"right"},gtmContext:a})]})};const Mw=({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($s,{progress:u,styling:{layout:i||"bar",size:i&&i==="circle"?"small":"default"}})]})})};const Gf=({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 Qf=({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}`}):Fc(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 Iw=({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 N=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:!N}),...$,children:d.jsx(kn,{href:N?`/microcourses/en/${o}/${E}`:void 0,fallbackElement:"span",className:"inner",gtmContext:`MicrocourseOutline${Ac(j)}`,gtmType:"article-click",children:d.jsxs(d.Fragment,{children:[d.jsx(Gf,{sectionId:i,subsectionId:T,title:j,className:"course-title"})," ",d.jsx(Qf,{completionTime:h,icon:b,optional:k,type:z,children:c&&c[E]&&d.jsx("span",{className:"quiz-score",children:`${c[E]}%`})})]})})},E)})})]})};const $w=({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 N,$,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=((N=t.slugs)==null?void 0:N.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 R;switch(t.type){case"post":R=await o.create({content:f});break;case"question":R=await o.create({title:f,authorId:m&&m.id,...(F=o.props)==null?void 0:F.create});break;case"response":R=await o.create({questionSlug:t.slugs.question},{body:f,authorId:m&&m.id,contentPath:B});break;case"reply":R=await o.create({questionSlug:t.slugs.question,answerSlug:t.slugs.answer},{body:f,authorId:m&&m.id,contentPath:B});break;default:break}await jh(1e3),o.callback&&await o.callback(R),aa=setTimeout(()=>{p(""),b("submitted");const L=new Event("discussionFormSubmitted");document.dispatchEvent(L),E()},500)}catch(R){const L=R;let q=`${ut}error`;L!=null&&L.message.includes("entry already exists")&&(q=Ft(c.formatMessage,`${ut}error_alreadyExists`,t.type,"action")),L!=null&&L.message.includes("429")?q=Ft(c.formatMessage,`${ut}error_tooMany`,t.type,"action"):L!=null&&L.message.includes("400")&&(q=`${ut}error`),h(q),E()}},E=()=>{aa=setTimeout(()=>{h(!1),b(!1)},5e3)},T=!f||!Lh(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(Cf,{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})]})},_o=({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(xo,{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||""}`})},Lw={showForm:!1},Ja=x.createContext(Lw),Jf=({children:e})=>{const[t,n]=x.useState({showForm:!1});return d.jsx(Ja.Provider,{value:{...t,updateConversation:n},children:e})},zw=({question:e,answer:t,reply:n})=>({...e&&{questionSlug:e},...t&&{answerSlug:t},...n&&{replySlug:n}}),qw=(e,t=10)=>!e||e.length===0?[]:e.slice(0,t);const Os=({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 Xf=({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(()=>qw(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=zw(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(Os,{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 N;j.preventDefault(),j.stopPropagation(),T(),f([{type:"showLikers",value:!0}]);const z=(N=j.currentTarget.nextSibling)==null?void 0:N.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 N={};return b!==z&&(N.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 R,L,q,oe;if(!$||!["ArrowUp","ArrowDown"].includes($.key||""))return;$.stopPropagation(),$.preventDefault();const M=$.key==="ArrowUp"?"up":"down",C=(R=$.currentTarget)==null?void 0:R.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=(q=C==null?void 0:C.parentElement)==null?void 0:q.firstElementChild);if(!B)return;const F=(B==null?void 0:B.getAttribute("data-index"))||"0";f([{type:"tabbableLink",value:F}]),(oe=B==null?void 0:B.querySelector("a"))==null||oe.focus()},...N,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})})]})})]})]}))},uc=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})},Ww=280,Hw=async(e,t,n,r=()=>Promise.resolve([]))=>{let a=t?Wn(e,Ww):e;return a=a.trim(),n?await Oc({text:a,template:'<a href="/profiles/{{id}}" class="mentioned-user">@{{name}}</a>',mentions:n,getUsers:r}):a};const zt="discussion_",Uw=195,Nr=({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:N=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,R=B&&(!t.createdAt||Th(t.createdAt,10,"seconds")),L=x.useRef(null),[q,oe]=x.useState({body:t&&t.body||"",isEditing:!1,didEdit:t&&t.isEdited||!1,postBody:""}),[ne,D]=x.useState(!1),[H,X]=x.useState(R?"highlighted":"default"),[_,S]=x.useState("");x.useEffect(()=>{const le=L.current;if(!(!le||H==="default"))return document.addEventListener("discussionFormSubmitted",W),le.addEventListener("transitionend",I),()=>{document.removeEventListener("discussionFormSubmitted",W),le.removeEventListener("transitionend",I)}},[]),x.useEffect(()=>{oe({...q,body:t&&t.body||"",didEdit:t&&t.isEdited||!1})},[t.isEdited]),x.useEffect(()=>{(async()=>{const V=await Hw(q.body,b,C,f);oe({...q,postBody:V})})()},[q.body,C]);const W=()=>{setTimeout(()=>{X("fading")},1e3)},I=({propertyName:le})=>{le==="background-color"&&X(V=>(V==="default"&&(document.removeEventListener("discussionFormSubmitted",W),L.current&&L.current.removeEventListener("transitionend",I)),V==="fading"?"default":V))};if(r||!t||t.type==="answer"&&(!t.slugs||!t.slugs.question)||q.postBody==="")return d.jsx(wt,{className:"discussion-card discussion-post"});const K=async le=>{le||(le=""),S("");try{if(!vc(le,q.body)){const V=t.type==="question"?{title:le}:{body:le};await l(uc(t.slugs),V)}oe({...q,body:le,isEditing:!1,didEdit:!0})}catch{S(`${zt}form_error`)}},te=()=>{k&&k.updateConversation&&k.updateConversation({showForm:!0}),setTimeout(()=>{var we,je,Oe;const V=`reply-form-${(t.type==="answer"?t.slug:((we=t.slugs)==null?void 0:we.reply)||((je=t.slugs)==null?void 0:je.answer)||((Oe=t.slugs)==null?void 0:Oe.question)||"").toLowerCase().slice(-15)}`,he=document.getElementById(V),pe=document.getElementById(`${V}-input`);pe&&pe.focus(),he&&he.scrollIntoView({behavior:"smooth"})},0)},ee=async()=>{D(!1);try{await o(uc(t.slugs))}catch{S("delete-error")}},ae=[{text:w.formatMessage({id:`${zt}moreMenu_report`}),onClick:le=>{le.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&&ae.push({text:w.formatMessage({id:`${zt}moreMenu_edit`}),onClick:()=>oe({...q,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:le=>{le.preventDefault(),le.stopPropagation(),D(!0)},icon:"trash",className:"gtm-trackable","data-gtm-event-context":h,"data-gtm-event-type":`delete-${t.type}-click`,...qf(`delete-${t.slug}-modal`,ne)}),x.createElement(e,{className:G("discussion-post",g,{[H]:!g||!g.includes("highlighted-text-box"),"has-link":p.post&&!q.isEditing}),ref:L,"data-testid":`discussion-${t.type}-thread`,"data-gtm-event-context":`${h}-post-click`,onClick:le=>{!p.post||q.isEditing||(le.preventDefault(),le.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:q.isEditing,"has-link":p.post&&!q.isEditing}),children:[!q.isEditing&&d.jsx(tr,{member:E,additionalContent:{createdAt:j,didEdit:q.didEdit},className:typeof E!="string"&&E.id===a?"highlighted":"",gtmContext:h,gtmType:"profile-click"}),q.isEditing?d.jsx(Qa,{id:`editing-${t.slug}`,content:{type:t.type,slugs:t.slugs},userHasPermissions:n,meta:{isLoading:r,isInWrapper:!0,isEditing:{text:q.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:K,handleCancel:()=>{S(""),oe({...q,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}),q.postBody.length>Uw?d.jsx(Lc,{text:q.postBody,markdownOptions:{overrides:{a:ss,blockquote:{component:Qi}}}}):d.jsx(Un,{options:{overrides:{a:ss,blockquote:{component:Qi}}},children:q.postBody})]}):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:q.postBody}),!q.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(Xf,{element:"li",likes:N,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(Os,{onClick:le=>{le.preventDefault(),le.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(Os,{styling:{muted:!0},onClick:te,icon:{icon:"speech-bubble_square_thick"},children:w.formatMessage({id:`${zt}reply`})})}),d.jsx(Uf,{element:"li",id:`more-${t.slug}`,options:ae})]})]}),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:ee,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:le=>d.jsx("p",{children:le}),action:w.formatMessage({id:`discussion_action_${t.type}`})}})})]})})};const Ji="discussion_responses_",eh=({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 th=({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(Rr,{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})]})},Vw="post",Kw="reply",nh="00000000-0000-0000-0000-000000000000";function Bo({queryClient:e,queryKey:t}){function n(r,a,i){e.setQueryData(t,i)}return n}function Ao({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 Zw(){return{latest_reactions:{like:[],reply:[]},reaction_counts:{like:0,reply:0},own_reactions:{like:[],reply:[]}}}function Yw(){return{latest_children:{like:[],reply:[]},children_counts:{like:0,reply:0},own_children:{like:[],reply:[]}}}function rh(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 Gw({content:e}){return{content:e,id:nh,time:new Date().toISOString(),verb:Vw}}function lc({activity:e,user:t}){return{...e,actor:rh(t),...Zw()}}function Ra({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 ah({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 Qw({activityId:e,replyId:t,content:n}){return{activity_id:e,data:{content:n},id:nh,kind:Kw,parent:t||""}}function cc({reply:e,user:t}){const n=rh(t);return{...e,user_id:n.id,user:n,...Yw()}}function dc({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 Jw({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 ih=e=>{const t=new CustomEvent("discussionPostAdded",{detail:e});document.dispatchEvent(t)};let fc,Xi=0;const sh=()=>{x.useEffect(()=>(document.addEventListener("discussionPostAdded",e),()=>{document.removeEventListener("discussionPostAdded",e)}),[]);const e=t=>{const n=t.detail;if(!n)return;clearTimeout(fc);const r=document.getElementById(n);if(r){r.scrollIntoView({behavior:"smooth",block:"start"}),Xi=0;return}Xi++,!(Xi>10)&&(fc=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}),oh=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"}),Xw=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"}),eE=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"}),tE=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:oh.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:oh.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:Xw.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:eE.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:tE.id,data:{content:"Some content 4..."},parent:"",latest_children:{},children_counts:{}});function nE({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({activity:Gw(o),user:i});return hc(u,l)}),onError:n,onSuccess:(o,l,u)=>{const c=lc({activity:o,user:i});r.setQueryData(a,hc(c,u,!0)),setTimeout(()=>{ih(c.id)},0)}});return s}function rE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({activityId:a,content:i})=>t(s=>{const o=Na(a,s);return o&&(o.content=i),s}),onError:n});return r}function aE({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:Bo(u),mutate:Ao(u)},user:l,...u},m=nE({...c,mutationFn:e}),f=rE({...c,mutationFn:t}),p=iE({...c,mutationFn:n}),g=oE({...c,mutationFn:a}),h=uE({...c,mutationFn:i}),{activities:y,...b}=sE({queryKey:s,queryFn:r});return{activities:y,mutations:{create:m,edit:f,remove:g,like:p,unlike:h},user:l,...b}}function iE({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=Na(s,o);return l&&Ra({activity:l}),o}),onError:n,onSuccess:(s,{activityId:o},l)=>{const u=Na(o,l);u&&Ra({activity:u,reaction:s}),r.setQueryData(a,l)}});return i}function sE({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:cE(n),error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}}function oE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({activityId:a})=>t(i=>lE(a,i)),onError:n});return r}function uE({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=We.useMutation({mutationFn:e,onMutate:({activityId:i})=>t(s=>{const o=Na(i,s);return o&&ah({activity:o,user:r}),s}),onError:n});return a}function hc(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 Na(e,t){if(t)for(const{results:n}of t.pages){const r=n.find(({id:a})=>a===e);if(r)return r}}function lE(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 cE(e){var t;return((t=e==null?void 0:e.pages)==null?void 0:t.reduce((n,{results:r})=>[...n,...r],[]))||[]}const dE=({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}=aE({queryKey:[e,t,"activities"],queryFns:r});return sh(),u?d.jsx(an,{variant:"error",text:u.message}):d.jsxs("section",{children:[d.jsx(_o,{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,q,oe,ne,D,H,X,_;const{id:E,own_reactions:T,latest_reactions:j,reaction_counts:z,mentioned_users:N}=A,$=(((L=j==null?void 0:j.like)==null?void 0:L.length)||0)>0,M=(((q=T==null?void 0:T.like)==null?void 0:q.length)||0)>0,C=M?T==null?void 0:T.like[0].id:"",B=$?(oe=j==null?void 0:j.like)==null?void 0:oe.map(S=>{var W,I,K;return{id:(W=S==null?void 0:S.user)==null?void 0:W.id,name:(K=(I=S==null?void 0:S.user)==null?void 0:I.data)==null?void 0:K.name}}):!1,F=A==null?void 0:A.actor,R=(F==null?void 0:F.id)===(w==null?void 0:w.id);return d.jsx(x.Fragment,{children:d.jsx(Nr,{content:{type:"post",title:A==null?void 0:A.title,body:A==null?void 0:A.content,canLike:Xa(n,R),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:(H=F==null?void 0:F.data)==null?void 0:H.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:N},links:{post:`${e}/${t}/${E}`,comments:`${e}/${t}/${E}`},gtmContext:"community",functions:{content:{createContent:()=>null,deleteContent:()=>h({activityId:E}),updateContent:(S,{body:W})=>g({activityId:E,content:W})},likes:{createLike:()=>y({activityId:E}),deleteLike:()=>b({activityId:E,reactionId:C})},comments:{openComments:()=>null},mentions:a},isTruncated:!0})},E)}),!f&&d.jsx(Rr,{hasNextPage:m,loadNextPage:()=>c(),icon:{icon:"arrow-down",position:"right"},messages:{button:o.formatMessage({id:"loadMore_button"}),error:o.formatMessage({id:"loadMore_error"})}})]})},fE={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 hE({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=cc({reply:Qw(o),user:i});return mc(u,l,{replace:!1,append:(o==null?void 0:o.replyId)!==void 0})}),onError:n,onSuccess:(o,l,u)=>{const c=cc({reply:o,user:i});r.setQueryData(a,mc(c,u,{replace:!0,append:(l==null?void 0:l.replyId)!==void 0})),setTimeout(()=>{ih(c.id)},0)}});return s}function mE({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 uh({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:Bo(u),mutate:Ao(u)},user:l,...u},m=hE({...c,mutationFn:e}),f=mE({...c,mutationFn:t}),p=pE({...c,mutationFn:n}),g=vE({...c,mutationFn:a}),h=bE({...c,mutationFn:i}),{replies:y,...b}=gE({queryKey:s,queryFn:r});return{replies:y,mutations:{create:m,edit:f,remove:g,like:p,unlike:h},user:l,...b}}function pE({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&&dc({reply:l}),o}),onError:n,onSuccess:(s,{replyId:o},l)=>{const u=Ma(o,l);u&&dc({reply:u,reaction:s}),r.setQueryData(a,l)}});return i}function gE({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=wE(n),l=`${o.length||0}${i?"+":""}`;return{replies:o,repliesCount:l,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}}function vE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({replyId:a})=>t(i=>xE(a,i)),onError:n});return r}function bE({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&&Jw({reply:o,user:r}),s}),onError:n});return a}function yE(e){return{pages:[{next:"",results:[e]}],pageParams:[""]}}function DE(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 CE(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 mc(e,t,n){return t?n!=null&&n.append?DE(e,t,n):CE(e,t,n):yE(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 xE(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 wE(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 EE=({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}=uh({queryKey:[e,t,n,r,"replies"],queryFns:{...i,list:k=>i.list({...k,reactionId:r})}});Rs([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(th,{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,H,X,_,S,W,I,K,te,ee,ae,le;const{id:E,own_children:T,latest_children:j,children_counts:z,mentioned_users:N}=k,M=(((D=T==null?void 0:T.like)==null?void 0:D.length)||0)>0?(H=T==null?void 0:T.like)==null?void 0:H.find(V=>{var he;return((he=V==null?void 0:V.user)==null?void 0:he.id)===(b==null?void 0:b.id)}):!1,C=M?M==null?void 0:M.id:"",B=!!M,R=(((X=j==null?void 0:j.like)==null?void 0:X.length)||0)>0?(_=j==null?void 0:j.like)==null?void 0:_.map(V=>{var he,pe,we;return{id:(he=V==null?void 0:V.user)==null?void 0:he.id,name:(we=(pe=V==null?void 0:V.user)==null?void 0:pe.data)==null?void 0:we.name}}):!1,L=k==null?void 0:k.user,q=(L==null?void 0:L.id)===(b==null?void 0:b.id),oe=Xa(a,q),ne=typeof k.data.content=="string"?(S=k==null?void 0:k.data)==null?void 0:S.content:((I=(W=k==null?void 0:k.data)==null?void 0:W.content)==null?void 0:I.text)||"";return d.jsx(Nr,{content:{id:E,type:"reply",body:ne,canLike:oe,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:(K=L.data)==null?void 0:K.name,organization:(te=L.data)==null?void 0:te.organization,jobTitle:(ee=L.data)==null?void 0:ee.jobTitle,location:(ae=L.data)==null?void 0:ae.location,image:{thumbnail:((le=L.data)==null?void 0:le.thumbnail)||void 0}},userLiked:B,likes:(z==null?void 0:z.like)||0,peopleWhoLiked:R,mentions:N},functions:{content:{createContent:()=>null,deleteContent:()=>h({replyId:E}),updateContent:(V,{body:he})=>p({replyId:E,content:he})},likes:{createLike:()=>g({replyId:E}),deleteLike:()=>y({replyId:E,reactionId:C})},comments:{},mentions:{getUsers:i.getUsers}}},E)}):null})]})};const lh=({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}=uh({queryKey:[e,t,n,"replies"],queryFns:a});return Rs([p]),sh(),d.jsxs("section",{className:"replies-feed",children:[d.jsx(eh,{type:"comment",responses:c}),d.jsx(_o,{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,H,X,_,S,W,I,K,te,ee,ae,le;const{id:E,own_children:T,latest_children:j,children_counts:z,data:{mentioned_users:N}}=k,M=(((D=T==null?void 0:T.like)==null?void 0:D.length)||0)>0?(H=T==null?void 0:T.like)==null?void 0:H.find(V=>{var he;return((he=V==null?void 0:V.user)==null?void 0:he.id)===(A==null?void 0:A.id)}):!1,C=M?M==null?void 0:M.id:"",B=!!M,R=(((X=j==null?void 0:j.like)==null?void 0:X.length)||0)>0?(_=j==null?void 0:j.like)==null?void 0:_.map(V=>{var he,pe,we;return{id:(he=V==null?void 0:V.user)==null?void 0:he.id,name:(we=(pe=V==null?void 0:V.user)==null?void 0:pe.data)==null?void 0:we.name}}):!1,L=k==null?void 0:k.user,q=(L==null?void 0:L.id)===(A==null?void 0:A.id),oe=Xa(r,q),ne=typeof k.data.content=="string"?(S=k==null?void 0:k.data)==null?void 0:S.content:((I=(W=k==null?void 0:k.data)==null?void 0:W.content)==null?void 0:I.text)||"";return d.jsx(Jf,{children:d.jsx(Nr,{content:{id:E,type:"reply",body:ne,canLike:oe,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:(K=L.data)==null?void 0:K.name,organization:(te=L.data)==null?void 0:te.organization,jobTitle:(ee=L.data)==null?void 0:ee.jobTitle,location:(ae=L.data)==null?void 0:ae.location,image:{thumbnail:((le=L.data)==null?void 0:le.thumbnail)||void 0}},userLiked:B,likes:(z==null?void 0:z.like)||0,peopleWhoLiked:R,mentions:N},functions:{content:{createContent:()=>null,deleteContent:()=>b({replyId:E}),updateContent:(V,{body:he})=>h({replyId:E,content:he})},likes:{createLike:()=>y({replyId:E}),deleteLike:()=>w({replyId:E,reactionId:C})},comments:{},mentions:i},children:d.jsx(EE,{basePath:e,parentId:t,activityId:n,replyId:E,isMember:r,functions:{...a,...i}})},E)},E)}),!p&&d.jsx(Rr,{hasNextPage:f,loadNextPage:()=>m(),icon:{icon:"arrow-down",position:"right"},messages:{button:l.formatMessage({id:"loadMore_button"}),error:l.formatMessage({id:"loadMore_error"})}})]})};function kE({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 _E({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 BE({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:Bo(o),mutate:Ao(o)},user:s,...o},u=kE({...l,mutationFn:t}),c=AE({...l,mutationFn:n}),m=FE({...l,mutationFn:r}),{activity:f,...p}=_E({queryKey:a,queryFn:e});return{activity:f,mutations:{edit:u,like:c,unlike:m},user:s,...p}}function AE({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=We.useMutation({mutationFn:e,onMutate:s=>t(o=>(o&&Ra({activity:o}),o)),onError:n,onSuccess:(s,o,l)=>{l&&Ra({activity:l,reaction:s}),r.setQueryData(a,l)}});return i}function FE({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=We.useMutation({mutationFn:e,onMutate:i=>t(s=>(s&&ah({activity:s,user:r}),s)),onError:n});return a}const TE=({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,R,L,q,oe,ne,D;const c=ue.useIntl(),m=x.useContext(Mt),{activity:f,error:p,isLoading:g,mutations:{edit:h,like:y,unlike:b}}=BE({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(H=>{var X,_,S;return{id:(X=H==null?void 0:H.user)==null?void 0:X.id,name:(S=(_=H==null?void 0:H.user)==null?void 0:_.data)==null?void 0:S.name}}):!1,N=f==null?void 0:f.actor,$=(N==null?void 0:N.id)===(m==null?void 0:m.id);return d.jsxs("section",{className:"activity-section",children:[d.jsx(Nr,{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:N.id,name:(F=N.data)==null?void 0:F.name,organization:(R=N.data)==null?void 0:R.organization,jobTitle:(L=N.data)==null?void 0:L.jobTitle,location:(q=N.data)==null?void 0:q.location,image:{thumbnail:((oe=N.data)==null?void 0:oe.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:N==null?void 0:N.id,forceHide:{comments:!0},functions:{content:{createContent:()=>null,deleteContent:a,updateContent:(H,{body:X})=>h({content:X})},likes:{createLike:()=>y({activityId:n}),deleteLike:()=>b({activityId:n,reactionId:j})},comments:{openComments:()=>{}},mentions:o}},n),d.jsx(lh,{basePath:e,parentId:t,activityId:n,isMember:r,functions:{reactions:s,mentions:o,join:l,leave:u}})]})},SE=({id:e,data:{jobTitle:t,name:n,organization:r,thumbnail:a}})=>({id:e,name:n,jobTitle:t,organization:r,image:{thumbnail:a}}),pc=[{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_",jE=()=>{const e=ue.useIntl(),t=[];return pc.forEach((n,r)=>{n.title=e.formatMessage({id:`${ia}post_${r+1}`}),t.push("solutionArticle")}),d.jsxs(Yf,{styling:{background:"bold",circle:"small",variant:"alt-2"},additionalContent:{appended:d.jsxs(ln,{children:[d.jsx(Hf,{cards:pc,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=dE;exports.ActivitySection=TE;exports.AddPost=_o;exports.Banner=Xx;exports.BannerSection=sw;exports.Breadcrumbs=yw;exports.Buckets=Vh;exports.Button=Ee;exports.ButtonWrapper=En;exports.COURSE_CONTENT_TYPES=fr;exports.CacheProvider=Nf;exports.Card=Co;exports.CardBlock=Hf;exports.Carousel=vw;exports.CharacterLimit=Ws;exports.CollapsibleSection=La;exports.Columns=Kf;exports.CommunityDetails=bw;exports.ContactFooter=Tw;exports.ContactForm=xf;exports.ContentTypeLabel=Mc;exports.Contributors=qs;exports.ConversationContext=Ja;exports.CookieBanner=Zf;exports.CourseProgression=Mw;exports.CourseStructure=Iw;exports.CustomContentBanner=ow;exports.Directory=Yx;exports.DiscussionConversation=Jf;exports.DiscussionForm=Qa;exports.DiscussionLikes=Xf;exports.DiscussionPost=Nr;exports.DiscussionThread=th;exports.Divider=tn;exports.DownloadSection=ew;exports.EMAILS=Pn;exports.EditSection=nw;exports.EmailHelperTextBox=Uc;exports.EmptyStateBox=an;exports.Filters=Dw;exports.FlagsProvider=Mf;exports.Footer=Eo;exports.Form=nr;exports.Formatting=Z;exports.FullWidthSection=ln;exports.GET_STREAM_PRESTRING=ts;exports.GlobalProviders=Kx;exports.Header=ko;exports.HelperTextBox=$c;exports.HiddenFromScreenReaders=Ia;exports.HideShowTextBox=Lc;exports.HighlightSection=lw;exports.HighlightedTextBox=Rt;exports.INVALID_TOKEN=Tc;exports.IconBulletedList=Yh;exports.ImageContainer=Wh;exports.IntlProvider=If;exports.InviteForm=wf;exports.InviteModal=Zx;exports.JoinButton=xo;exports.LanguageContext=bo;exports.LanguageSwitcher=xw;exports.LessonName=Gf;exports.LessonType=Qf;exports.Link=kn;exports.LoadMore=Rr;exports.LoadingBlock=sm;exports.LoadingPlaceholder=wt;exports.LoadingState=Ls;exports.Logo=wo;exports.LogoSection=rw;exports.MarkCompleteButton=$w;exports.MarkdownText=Un;exports.MarketingBlock=cw;exports.Marks=Ot;exports.Member=tr;exports.MembersList=Nw;exports.Modal=Do;exports.MoreMenu=Uf;exports.NUMBER_OF_COUNTRIES=Fh;exports.NUMBER_OF_USERS=Ah;exports.NavigationMenu=Vf;exports.NotFoundError=jE;exports.Overlay=Pr;exports.OverlayContext=yo;exports.OverlayProvider=zf;exports.PageHeading=zc;exports.PageLayout=Yf;exports.PasswordForm=zC;exports.PasswordRules=Gc;exports.Pill=hn;exports.Popover=Nc;exports.Portal=Is;exports.ProfileImageChange=LC;exports.ProfilePicture=sn;exports.ProgressBar=$s;exports.ProgressTracker=Hh;exports.Rating=ym;exports.RepliesFeed=lh;exports.ResponsesHeading=eh;exports.ResponsiveImage=er;exports.ReturnToNavButton=Uh;exports.RichTextEditor=Cf;exports.SearchForm=Ef;exports.ShareLinks=Bw;exports.SignupForm=KC;exports.Span=ss;exports.StatusBanner=wr;exports.TableOfContents=Jx;exports.Tabs=Aw;exports.Tags=Rw;exports.TestimonialBlock=Qx;exports.TimeToComplete=Ga;exports.Toggle=$C;exports.Tooltip=Jn;exports.TopLevelPage=Sw;exports.UUID_V4_REGEX=ns;exports.UserContext=Mt;exports.UserProvider=$f;exports.VisuallyHidden=Me;exports.addAriaProps=qf;exports.basicReducer=jr;exports.camelCaseToDashCase=Bc;exports.checkIntlPathExists=$a;exports.generateConditions=ma;exports.generateCssIcon=Sc;exports.getCharacterLimitProps=Hc;exports.getLongDate=Ms;exports.getMember=zs;exports.getShortDate=jc;exports.getValueLength=za;exports.headerData=Sr;exports.mapGetStreamData=SE;exports.pageReady=Pc;exports.passwordValidator=as;exports.repliesFeedMock=fE;exports.supportedLanguages=ga;exports.toCamelCase=Ac;exports.toCapitalisedCase=Bh;exports.toSentenceCase=Fc;exports.useCurrentPath=Cc;exports.useEffectAfterMount=Hn;exports.useElementWidth=Qn;exports.useOverlay=Lf;exports.useScrollListener=Ec;exports.useScrollToHash=Rs;exports.useTooltips=Ns;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 _w="shareLinks_",Bw=({title:e,link:t,referrer:n,gtmContext:r="ShareLinks",size:a="large",variant:i="default",className:s=""})=>{const o=ue.useIntl(),l=kw({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:`${_w}link_${u}`}),...g})},u)})})]})};const Aw=({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 Fw={"2-1":901,"1-3":769,"1-1":769},Kf=({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<Fw[e]?null:o)})};let qi;const Wi="contactFooter_",Tw=({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(xf,{functions:{onSuccess:e,onFailure:t},gtm:{context:"FooterContactUsForm",event:"contact-form-submit-click"}})]})]})})},Sw=({activeLink:e,...t})=>d.jsx(ln,{children:d.jsx(Kf,{layout:"1-3",children:d.jsxs(d.Fragment,{children:[d.jsx(Vf,{activeLink:e}),d.jsx(zc,{...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),Zf=()=>{const e=ue.useIntl(),[t,n,r]=Ps.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",sc=({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)},Eo=()=>d.jsx("div",{id:"footer",children:d.jsxs("div",{className:"wrapper",children:[d.jsx(Ia,{element:"hr"}),d.jsx(wo,{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(sc,{group:e}),Object.keys(qt[e]).includes("child")&&d.jsx(sc,{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=bc(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=bc(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 jw={height:67,height_desktop:83},ko=({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]),Ec({scrollPosition:jw[`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(wo,{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(Ef,{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 Ow=()=>{const e=ue.useIntl();return d.jsxs(d.Fragment,{children:[d.jsx(ko,{}),d.jsx("div",{id:"content",children:d.jsx(an,{variant:"error",text:e.formatMessage({id:"pageLayout_error"})})}),d.jsx(Eo,{})]})},Yf=({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=Cc();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(Ch.ErrorBoundary,{onError:r,fallback:d.jsx(Ow,{}),children:d.jsx(x.Suspense,{fallback:null,children:d.jsxs("div",{id:"wrapper",className:G(s,w,{"has-footer":u}),children:[d.jsx(ko,{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"?Do:"div",{id:"content",children:h,className:G({"large-modal":p==="large"})})]}),b&&d.jsx("div",{className:"additional-content appended",children:b}),u&&d.jsx(Eo,{}),d.jsx(Zf,{})]})})})},oc={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"},Pw={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:`${oc.headerTopics}${e}`}:null}return null}return Ki[e]?(e=Ki[e],{id:e,text:`${oc.default}${e}`}):null}};const Rw=({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=Pw.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 Nw=({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(Rr,{hasNextPage:n,loadNextPage:r,icon:{icon:"arrow-down",position:"right"},gtmContext:a})]})};const Mw=({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($s,{progress:u,styling:{layout:i||"bar",size:i&&i==="circle"?"small":"default"}})]})})};const Gf=({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 Qf=({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}`}):Fc(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 Iw=({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 N=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:!N}),...$,children:d.jsx(kn,{href:N?`/microcourses/en/${o}/${E}`:void 0,fallbackElement:"span",className:"inner",gtmContext:`MicrocourseOutline${Ac(j)}`,gtmType:"article-click",children:d.jsxs(d.Fragment,{children:[d.jsx(Gf,{sectionId:i,subsectionId:T,title:j,className:"course-title"})," ",d.jsx(Qf,{completionTime:h,icon:b,optional:k,type:z,children:c&&c[E]&&d.jsx("span",{className:"quiz-score",children:`${c[E]}%`})})]})})},E)})})]})};const $w=({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 N,$,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=((N=t.slugs)==null?void 0:N.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 R;switch(t.type){case"post":R=await o.create({content:f});break;case"question":R=await o.create({title:f,authorId:m&&m.id,...(F=o.props)==null?void 0:F.create});break;case"response":R=await o.create({questionSlug:t.slugs.question},{body:f,authorId:m&&m.id,contentPath:B});break;case"reply":R=await o.create({questionSlug:t.slugs.question,answerSlug:t.slugs.answer},{body:f,authorId:m&&m.id,contentPath:B});break;default:break}await jh(1e3),o.callback&&await o.callback(R),aa=setTimeout(()=>{p(""),b("submitted");const L=new Event("discussionFormSubmitted");document.dispatchEvent(L),E()},500)}catch(R){const L=R;let q=`${ut}error`;L!=null&&L.message.includes("entry already exists")&&(q=Ft(c.formatMessage,`${ut}error_alreadyExists`,t.type,"action")),L!=null&&L.message.includes("429")?q=Ft(c.formatMessage,`${ut}error_tooMany`,t.type,"action"):L!=null&&L.message.includes("400")&&(q=`${ut}error`),h(q),E()}},E=()=>{aa=setTimeout(()=>{h(!1),b(!1)},5e3)},T=!f||!Lh(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(Cf,{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})]})},_o=({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(xo,{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||""}`})},Lw={showForm:!1},Ja=x.createContext(Lw),Jf=({children:e})=>{const[t,n]=x.useState({showForm:!1});return d.jsx(Ja.Provider,{value:{...t,updateConversation:n},children:e})},zw=({question:e,answer:t,reply:n})=>({...e&&{questionSlug:e},...t&&{answerSlug:t},...n&&{replySlug:n}}),qw=(e,t=10)=>!e||e.length===0?[]:e.slice(0,t);const Os=({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 Xf=({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(()=>qw(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=zw(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(Os,{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 N;j.preventDefault(),j.stopPropagation(),T(),f([{type:"showLikers",value:!0}]);const z=(N=j.currentTarget.nextSibling)==null?void 0:N.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 N={};return b!==z&&(N.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 R,L,q,oe;if(!$||!["ArrowUp","ArrowDown"].includes($.key||""))return;$.stopPropagation(),$.preventDefault();const M=$.key==="ArrowUp"?"up":"down",C=(R=$.currentTarget)==null?void 0:R.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=(q=C==null?void 0:C.parentElement)==null?void 0:q.firstElementChild);if(!B)return;const F=(B==null?void 0:B.getAttribute("data-index"))||"0";f([{type:"tabbableLink",value:F}]),(oe=B==null?void 0:B.querySelector("a"))==null||oe.focus()},...N,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})})]})})]})]}))},uc=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})},Ww=280,Hw=async(e,t,n,r=()=>Promise.resolve([]))=>{let a=t?Wn(e,Ww):e;return a=a.trim(),n?await Oc({text:a,template:'<a href="/profiles/{{id}}" class="mentioned-user">@{{name}}</a>',mentions:n,getUsers:r}):a};const zt="discussion_",Uw=195,Nr=({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:N=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,R=B&&(!t.createdAt||Th(t.createdAt,10,"seconds")),L=x.useRef(null),[q,oe]=x.useState({body:t&&t.body||"",isEditing:!1,didEdit:t&&t.isEdited||!1,postBody:""}),[ne,D]=x.useState(!1),[H,X]=x.useState(R?"highlighted":"default"),[_,S]=x.useState("");x.useEffect(()=>{const le=L.current;if(!(!le||H==="default"))return document.addEventListener("discussionFormSubmitted",W),le.addEventListener("transitionend",I),()=>{document.removeEventListener("discussionFormSubmitted",W),le.removeEventListener("transitionend",I)}},[]),x.useEffect(()=>{oe({...q,body:t&&t.body||"",didEdit:t&&t.isEdited||!1})},[t.isEdited]),x.useEffect(()=>{(async()=>{const V=await Hw(q.body,b,C,f);oe({...q,postBody:V})})()},[q.body,C]);const W=()=>{setTimeout(()=>{X("fading")},1e3)},I=({propertyName:le})=>{le==="background-color"&&X(V=>(V==="default"&&(document.removeEventListener("discussionFormSubmitted",W),L.current&&L.current.removeEventListener("transitionend",I)),V==="fading"?"default":V))};if(r||!t||t.type==="answer"&&(!t.slugs||!t.slugs.question)||q.postBody==="")return d.jsx(wt,{className:"discussion-card discussion-post"});const K=async le=>{le||(le=""),S("");try{if(!vc(le,q.body)){const V=t.type==="question"?{title:le}:{body:le};await l(uc(t.slugs),V)}oe({...q,body:le,isEditing:!1,didEdit:!0})}catch{S(`${zt}form_error`)}},te=()=>{k&&k.updateConversation&&k.updateConversation({showForm:!0}),setTimeout(()=>{var we,je,Oe;const V=`reply-form-${(t.type==="answer"?t.slug:((we=t.slugs)==null?void 0:we.reply)||((je=t.slugs)==null?void 0:je.answer)||((Oe=t.slugs)==null?void 0:Oe.question)||"").toLowerCase().slice(-15)}`,he=document.getElementById(V),pe=document.getElementById(`${V}-input`);pe&&pe.focus(),he&&he.scrollIntoView({behavior:"smooth"})},0)},ee=async()=>{D(!1);try{await o(uc(t.slugs))}catch{S("delete-error")}},ae=[{text:w.formatMessage({id:`${zt}moreMenu_report`}),onClick:le=>{le.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&&ae.push({text:w.formatMessage({id:`${zt}moreMenu_edit`}),onClick:()=>oe({...q,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:le=>{le.preventDefault(),le.stopPropagation(),D(!0)},icon:"trash",className:"gtm-trackable","data-gtm-event-context":h,"data-gtm-event-type":`delete-${t.type}-click`,...qf(`delete-${t.slug}-modal`,ne)}),x.createElement(e,{className:G("discussion-post",g,{[H]:!g||!g.includes("highlighted-text-box"),"has-link":p.post&&!q.isEditing}),ref:L,"data-testid":`discussion-${t.type}-thread`,"data-gtm-event-context":`${h}-post-click`,onClick:le=>{!p.post||q.isEditing||(le.preventDefault(),le.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:q.isEditing,"has-link":p.post&&!q.isEditing}),children:[!q.isEditing&&d.jsx(tr,{member:E,additionalContent:{createdAt:j,didEdit:q.didEdit},className:typeof E!="string"&&E.id===a?"highlighted":"",gtmContext:h,gtmType:"profile-click"}),q.isEditing?d.jsx(Qa,{id:`editing-${t.slug}`,content:{type:t.type,slugs:t.slugs},userHasPermissions:n,meta:{isLoading:r,isInWrapper:!0,isEditing:{text:q.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:K,handleCancel:()=>{S(""),oe({...q,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}),q.postBody.length>Uw?d.jsx(Lc,{text:q.postBody,markdownOptions:{overrides:{a:ss,blockquote:{component:Qi}}}}):d.jsx(Un,{options:{overrides:{a:ss,blockquote:{component:Qi}}},children:q.postBody})]}):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:q.postBody}),!q.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(Xf,{element:"li",likes:N,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(Os,{onClick:le=>{le.preventDefault(),le.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(Os,{styling:{muted:!0},onClick:te,icon:{icon:"speech-bubble_square_thick"},children:w.formatMessage({id:`${zt}reply`})})}),d.jsx(Uf,{element:"li",id:`more-${t.slug}`,options:ae})]})]}),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:ee,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:le=>d.jsx("p",{children:le}),action:w.formatMessage({id:`discussion_action_${t.type}`})}})})]})})};const Ji="discussion_responses_",eh=({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 th=({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(Rr,{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})]})},Vw="post",Kw="reply",nh="00000000-0000-0000-0000-000000000000";function Bo({queryClient:e,queryKey:t}){function n(r,a,i){e.setQueryData(t,i)}return n}function Ao({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 Zw(){return{latest_reactions:{like:[],reply:[]},reaction_counts:{like:0,reply:0},own_reactions:{like:[],reply:[]}}}function Yw(){return{latest_children:{like:[],reply:[]},children_counts:{like:0,reply:0},own_children:{like:[],reply:[]}}}function rh(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 Gw({content:e}){return{content:e,id:nh,time:new Date().toISOString(),verb:Vw}}function lc({activity:e,user:t}){return{...e,actor:rh(t),...Zw()}}function Ra({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 ah({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 Qw({activityId:e,replyId:t,content:n}){return{activity_id:e,data:{content:n},id:nh,kind:Kw,parent:t||""}}function cc({reply:e,user:t}){const n=rh(t);return{...e,user_id:n.id,user:n,...Yw()}}function dc({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 Jw({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 ih=e=>{const t=new CustomEvent("discussionPostAdded",{detail:e});document.dispatchEvent(t)};let fc,Xi=0;const sh=()=>{x.useEffect(()=>(document.addEventListener("discussionPostAdded",e),()=>{document.removeEventListener("discussionPostAdded",e)}),[]);const e=t=>{const n=t.detail;if(!n)return;clearTimeout(fc);const r=document.getElementById(n);if(r){r.scrollIntoView({behavior:"smooth",block:"start"}),Xi=0;return}Xi++,!(Xi>10)&&(fc=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}),oh=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"}),Xw=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"}),eE=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"}),tE=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:oh.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:oh.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:Xw.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:eE.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:tE.id,data:{content:"Some content 4..."},parent:"",latest_children:{},children_counts:{}});function nE({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({activity:Gw(o),user:i});return hc(u,l)}),onError:n,onSuccess:(o,l,u)=>{const c=lc({activity:o,user:i});r.setQueryData(a,hc(c,u,!0)),setTimeout(()=>{ih(c.id)},0)}});return s}function rE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({activityId:a,content:i})=>t(s=>{const o=Na(a,s);return o&&(o.content=i),s}),onError:n});return r}function aE({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:Bo(u),mutate:Ao(u)},user:l,...u},m=nE({...c,mutationFn:e}),f=rE({...c,mutationFn:t}),p=iE({...c,mutationFn:n}),g=oE({...c,mutationFn:a}),h=uE({...c,mutationFn:i}),{activities:y,...b}=sE({queryKey:s,queryFn:r});return{activities:y,mutations:{create:m,edit:f,remove:g,like:p,unlike:h},user:l,...b}}function iE({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=Na(s,o);return l&&Ra({activity:l}),o}),onError:n,onSuccess:(s,{activityId:o},l)=>{const u=Na(o,l);u&&Ra({activity:u,reaction:s}),r.setQueryData(a,l)}});return i}function sE({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:cE(n),error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}}function oE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({activityId:a})=>t(i=>lE(a,i)),onError:n});return r}function uE({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=We.useMutation({mutationFn:e,onMutate:({activityId:i})=>t(s=>{const o=Na(i,s);return o&&ah({activity:o,user:r}),s}),onError:n});return a}function hc(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 Na(e,t){if(t)for(const{results:n}of t.pages){const r=n.find(({id:a})=>a===e);if(r)return r}}function lE(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 cE(e){var t;return((t=e==null?void 0:e.pages)==null?void 0:t.reduce((n,{results:r})=>[...n,...r],[]))||[]}const dE=({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}=aE({queryKey:[e,t,"activities"],queryFns:r});return sh(),u?d.jsx(an,{variant:"error",text:u.message}):d.jsxs("section",{children:[d.jsx(_o,{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,q,oe,ne,D,H,X,_;const{id:E,own_reactions:T,latest_reactions:j,reaction_counts:z,mentioned_users:N}=A,$=(((L=j==null?void 0:j.like)==null?void 0:L.length)||0)>0,M=(((q=T==null?void 0:T.like)==null?void 0:q.length)||0)>0,C=M?T==null?void 0:T.like[0].id:"",B=$?(oe=j==null?void 0:j.like)==null?void 0:oe.map(S=>{var W,I,K;return{id:(W=S==null?void 0:S.user)==null?void 0:W.id,name:(K=(I=S==null?void 0:S.user)==null?void 0:I.data)==null?void 0:K.name}}):!1,F=A==null?void 0:A.actor,R=(F==null?void 0:F.id)===(w==null?void 0:w.id);return d.jsx(x.Fragment,{children:d.jsx(Nr,{content:{type:"post",title:A==null?void 0:A.title,body:A==null?void 0:A.content,canLike:Xa(n,R),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:(H=F==null?void 0:F.data)==null?void 0:H.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:N},links:{post:`${e}/${t}/${E}`,comments:`${e}/${t}/${E}`},gtmContext:"community",functions:{content:{createContent:()=>null,deleteContent:()=>h({activityId:E}),updateContent:(S,{body:W})=>g({activityId:E,content:W})},likes:{createLike:()=>y({activityId:E}),deleteLike:()=>b({activityId:E,reactionId:C})},comments:{openComments:()=>null},mentions:a},isTruncated:!0})},E)}),!f&&d.jsx(Rr,{hasNextPage:m,loadNextPage:()=>c(),icon:{icon:"arrow-down",position:"right"},messages:{button:o.formatMessage({id:"loadMore_button"}),error:o.formatMessage({id:"loadMore_error"})}})]})},fE={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 hE({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=cc({reply:Qw(o),user:i});return mc(u,l,{replace:!1,append:(o==null?void 0:o.replyId)!==void 0})}),onError:n,onSuccess:(o,l,u)=>{const c=cc({reply:o,user:i});r.setQueryData(a,mc(c,u,{replace:!0,append:(l==null?void 0:l.replyId)!==void 0})),setTimeout(()=>{ih(c.id)},0)}});return s}function mE({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 uh({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:Bo(u),mutate:Ao(u)},user:l,...u},m=hE({...c,mutationFn:e}),f=mE({...c,mutationFn:t}),p=pE({...c,mutationFn:n}),g=vE({...c,mutationFn:a}),h=bE({...c,mutationFn:i}),{replies:y,...b}=gE({queryKey:s,queryFn:r});return{replies:y,mutations:{create:m,edit:f,remove:g,like:p,unlike:h},user:l,...b}}function pE({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&&dc({reply:l}),o}),onError:n,onSuccess:(s,{replyId:o},l)=>{const u=Ma(o,l);u&&dc({reply:u,reaction:s}),r.setQueryData(a,l)}});return i}function gE({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=wE(n),l=`${o.length||0}${i?"+":""}`;return{replies:o,repliesCount:l,error:r,isLoading:a,hasNextPage:i,fetchNextPage:s}}function vE({mutationFn:e,mutationHandlers:{mutate:t,error:n}}){const{mutate:r}=We.useMutation({mutationFn:e,onMutate:({replyId:a})=>t(i=>xE(a,i)),onError:n});return r}function bE({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&&Jw({reply:o,user:r}),s}),onError:n});return a}function yE(e){return{pages:[{next:"",results:[e]}],pageParams:[""]}}function DE(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 CE(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 mc(e,t,n){return t?n!=null&&n.append?DE(e,t,n):CE(e,t,n):yE(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 xE(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 wE(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 EE=({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}=uh({queryKey:[e,t,n,r,"replies"],queryFns:{...i,list:k=>i.list({...k,reactionId:r})}});Rs([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(th,{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}),getUsers:i.getUsers},meta:{isEditing:!1,showSuccessMessage:!1}},children:l&&l.length>0?l==null?void 0:l.map(k=>{var D,H,X,_,S,W,I,K,te,ee,ae,le;const{id:E,own_children:T,latest_children:j,children_counts:z,data:{mentioned_users:N}}=k,M=(((D=T==null?void 0:T.like)==null?void 0:D.length)||0)>0?(H=T==null?void 0:T.like)==null?void 0:H.find(V=>{var he;return((he=V==null?void 0:V.user)==null?void 0:he.id)===(b==null?void 0:b.id)}):!1,C=M?M==null?void 0:M.id:"",B=!!M,R=(((X=j==null?void 0:j.like)==null?void 0:X.length)||0)>0?(_=j==null?void 0:j.like)==null?void 0:_.map(V=>{var he,pe,we;return{id:(he=V==null?void 0:V.user)==null?void 0:he.id,name:(we=(pe=V==null?void 0:V.user)==null?void 0:pe.data)==null?void 0:we.name}}):!1,L=k==null?void 0:k.user,q=(L==null?void 0:L.id)===(b==null?void 0:b.id),oe=Xa(a,q),ne=typeof k.data.content=="string"?(S=k==null?void 0:k.data)==null?void 0:S.content:((I=(W=k==null?void 0:k.data)==null?void 0:W.content)==null?void 0:I.text)||"";return d.jsx(Nr,{content:{id:E,type:"reply",body:ne,canLike:oe,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:(K=L.data)==null?void 0:K.name,organization:(te=L.data)==null?void 0:te.organization,jobTitle:(ee=L.data)==null?void 0:ee.jobTitle,location:(ae=L.data)==null?void 0:ae.location,image:{thumbnail:((le=L.data)==null?void 0:le.thumbnail)||void 0}},userLiked:B,likes:(z==null?void 0:z.like)||0,peopleWhoLiked:R,mentions:N},functions:{content:{createContent:()=>null,deleteContent:()=>h({replyId:E}),updateContent:(V,{body:he})=>p({replyId:E,content:he})},likes:{createLike:()=>g({replyId:E}),deleteLike:()=>y({replyId:E,reactionId:C})},comments:{},mentions:{getUsers:i.getUsers}}},E)}):null})]})};const lh=({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}=uh({queryKey:[e,t,n,"replies"],queryFns:a});return Rs([p]),sh(),d.jsxs("section",{className:"replies-feed",children:[d.jsx(eh,{type:"comment",responses:c}),d.jsx(_o,{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,H,X,_,S,W,I,K,te,ee,ae,le;const{id:E,own_children:T,latest_children:j,children_counts:z,data:{mentioned_users:N}}=k,M=(((D=T==null?void 0:T.like)==null?void 0:D.length)||0)>0?(H=T==null?void 0:T.like)==null?void 0:H.find(V=>{var he;return((he=V==null?void 0:V.user)==null?void 0:he.id)===(A==null?void 0:A.id)}):!1,C=M?M==null?void 0:M.id:"",B=!!M,R=(((X=j==null?void 0:j.like)==null?void 0:X.length)||0)>0?(_=j==null?void 0:j.like)==null?void 0:_.map(V=>{var he,pe,we;return{id:(he=V==null?void 0:V.user)==null?void 0:he.id,name:(we=(pe=V==null?void 0:V.user)==null?void 0:pe.data)==null?void 0:we.name}}):!1,L=k==null?void 0:k.user,q=(L==null?void 0:L.id)===(A==null?void 0:A.id),oe=Xa(r,q),ne=typeof k.data.content=="string"?(S=k==null?void 0:k.data)==null?void 0:S.content:((I=(W=k==null?void 0:k.data)==null?void 0:W.content)==null?void 0:I.text)||"";return d.jsx(Jf,{children:d.jsx(Nr,{content:{id:E,type:"reply",body:ne,canLike:oe,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:(K=L.data)==null?void 0:K.name,organization:(te=L.data)==null?void 0:te.organization,jobTitle:(ee=L.data)==null?void 0:ee.jobTitle,location:(ae=L.data)==null?void 0:ae.location,image:{thumbnail:((le=L.data)==null?void 0:le.thumbnail)||void 0}},userLiked:B,likes:(z==null?void 0:z.like)||0,peopleWhoLiked:R,mentions:N},functions:{content:{createContent:()=>null,deleteContent:()=>b({replyId:E}),updateContent:(V,{body:he})=>h({replyId:E,content:he})},likes:{createLike:()=>y({replyId:E}),deleteLike:()=>w({replyId:E,reactionId:C})},comments:{},mentions:i},children:d.jsx(EE,{basePath:e,parentId:t,activityId:n,replyId:E,isMember:r,functions:{...a,...i}})},E)},E)}),!p&&d.jsx(Rr,{hasNextPage:f,loadNextPage:()=>m(),icon:{icon:"arrow-down",position:"right"},messages:{button:l.formatMessage({id:"loadMore_button"}),error:l.formatMessage({id:"loadMore_error"})}})]})};function kE({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 _E({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 BE({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:Bo(o),mutate:Ao(o)},user:s,...o},u=kE({...l,mutationFn:t}),c=AE({...l,mutationFn:n}),m=FE({...l,mutationFn:r}),{activity:f,...p}=_E({queryKey:a,queryFn:e});return{activity:f,mutations:{edit:u,like:c,unlike:m},user:s,...p}}function AE({mutationFn:e,mutationHandlers:{mutate:t,error:n},queryClient:r,queryKey:a}){const{mutate:i}=We.useMutation({mutationFn:e,onMutate:s=>t(o=>(o&&Ra({activity:o}),o)),onError:n,onSuccess:(s,o,l)=>{l&&Ra({activity:l,reaction:s}),r.setQueryData(a,l)}});return i}function FE({mutationFn:e,mutationHandlers:{mutate:t,error:n},user:r}){const{mutate:a}=We.useMutation({mutationFn:e,onMutate:i=>t(s=>(s&&ah({activity:s,user:r}),s)),onError:n});return a}const TE=({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,R,L,q,oe,ne,D;const c=ue.useIntl(),m=x.useContext(Mt),{activity:f,error:p,isLoading:g,mutations:{edit:h,like:y,unlike:b}}=BE({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(H=>{var X,_,S;return{id:(X=H==null?void 0:H.user)==null?void 0:X.id,name:(S=(_=H==null?void 0:H.user)==null?void 0:_.data)==null?void 0:S.name}}):!1,N=f==null?void 0:f.actor,$=(N==null?void 0:N.id)===(m==null?void 0:m.id);return d.jsxs("section",{className:"activity-section",children:[d.jsx(Nr,{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:N.id,name:(F=N.data)==null?void 0:F.name,organization:(R=N.data)==null?void 0:R.organization,jobTitle:(L=N.data)==null?void 0:L.jobTitle,location:(q=N.data)==null?void 0:q.location,image:{thumbnail:((oe=N.data)==null?void 0:oe.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:N==null?void 0:N.id,forceHide:{comments:!0},functions:{content:{createContent:()=>null,deleteContent:a,updateContent:(H,{body:X})=>h({content:X})},likes:{createLike:()=>y({activityId:n}),deleteLike:()=>b({activityId:n,reactionId:j})},comments:{openComments:()=>{}},mentions:o}},n),d.jsx(lh,{basePath:e,parentId:t,activityId:n,isMember:r,functions:{reactions:s,mentions:o,join:l,leave:u}})]})},SE=({id:e,data:{jobTitle:t,name:n,organization:r,thumbnail:a}})=>({id:e,name:n,jobTitle:t,organization:r,image:{thumbnail:a}}),pc=[{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_",jE=()=>{const e=ue.useIntl(),t=[];return pc.forEach((n,r)=>{n.title=e.formatMessage({id:`${ia}post_${r+1}`}),t.push("solutionArticle")}),d.jsxs(Yf,{styling:{background:"bold",circle:"small",variant:"alt-2"},additionalContent:{appended:d.jsxs(ln,{children:[d.jsx(Hf,{cards:pc,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=dE;exports.ActivitySection=TE;exports.AddPost=_o;exports.Banner=Xx;exports.BannerSection=sw;exports.Breadcrumbs=yw;exports.Buckets=Vh;exports.Button=Ee;exports.ButtonWrapper=En;exports.COURSE_CONTENT_TYPES=fr;exports.CacheProvider=Nf;exports.Card=Co;exports.CardBlock=Hf;exports.Carousel=vw;exports.CharacterLimit=Ws;exports.CollapsibleSection=La;exports.Columns=Kf;exports.CommunityDetails=bw;exports.ContactFooter=Tw;exports.ContactForm=xf;exports.ContentTypeLabel=Mc;exports.Contributors=qs;exports.ConversationContext=Ja;exports.CookieBanner=Zf;exports.CourseProgression=Mw;exports.CourseStructure=Iw;exports.CustomContentBanner=ow;exports.Directory=Yx;exports.DiscussionConversation=Jf;exports.DiscussionForm=Qa;exports.DiscussionLikes=Xf;exports.DiscussionPost=Nr;exports.DiscussionThread=th;exports.Divider=tn;exports.DownloadSection=ew;exports.EMAILS=Pn;exports.EditSection=nw;exports.EmailHelperTextBox=Uc;exports.EmptyStateBox=an;exports.Filters=Dw;exports.FlagsProvider=Mf;exports.Footer=Eo;exports.Form=nr;exports.Formatting=Z;exports.FullWidthSection=ln;exports.GET_STREAM_PRESTRING=ts;exports.GlobalProviders=Kx;exports.Header=ko;exports.HelperTextBox=$c;exports.HiddenFromScreenReaders=Ia;exports.HideShowTextBox=Lc;exports.HighlightSection=lw;exports.HighlightedTextBox=Rt;exports.INVALID_TOKEN=Tc;exports.IconBulletedList=Yh;exports.ImageContainer=Wh;exports.IntlProvider=If;exports.InviteForm=wf;exports.InviteModal=Zx;exports.JoinButton=xo;exports.LanguageContext=bo;exports.LanguageSwitcher=xw;exports.LessonName=Gf;exports.LessonType=Qf;exports.Link=kn;exports.LoadMore=Rr;exports.LoadingBlock=sm;exports.LoadingPlaceholder=wt;exports.LoadingState=Ls;exports.Logo=wo;exports.LogoSection=rw;exports.MarkCompleteButton=$w;exports.MarkdownText=Un;exports.MarketingBlock=cw;exports.Marks=Ot;exports.Member=tr;exports.MembersList=Nw;exports.Modal=Do;exports.MoreMenu=Uf;exports.NUMBER_OF_COUNTRIES=Fh;exports.NUMBER_OF_USERS=Ah;exports.NavigationMenu=Vf;exports.NotFoundError=jE;exports.Overlay=Pr;exports.OverlayContext=yo;exports.OverlayProvider=zf;exports.PageHeading=zc;exports.PageLayout=Yf;exports.PasswordForm=zC;exports.PasswordRules=Gc;exports.Pill=hn;exports.Popover=Nc;exports.Portal=Is;exports.ProfileImageChange=LC;exports.ProfilePicture=sn;exports.ProgressBar=$s;exports.ProgressTracker=Hh;exports.Rating=ym;exports.RepliesFeed=lh;exports.ResponsesHeading=eh;exports.ResponsiveImage=er;exports.ReturnToNavButton=Uh;exports.RichTextEditor=Cf;exports.SearchForm=Ef;exports.ShareLinks=Bw;exports.SignupForm=KC;exports.Span=ss;exports.StatusBanner=wr;exports.TableOfContents=Jx;exports.Tabs=Aw;exports.Tags=Rw;exports.TestimonialBlock=Qx;exports.TimeToComplete=Ga;exports.Toggle=$C;exports.Tooltip=Jn;exports.TopLevelPage=Sw;exports.UUID_V4_REGEX=ns;exports.UserContext=Mt;exports.UserProvider=$f;exports.VisuallyHidden=Me;exports.addAriaProps=qf;exports.basicReducer=jr;exports.camelCaseToDashCase=Bc;exports.checkIntlPathExists=$a;exports.generateConditions=ma;exports.generateCssIcon=Sc;exports.getCharacterLimitProps=Hc;exports.getLongDate=Ms;exports.getMember=zs;exports.getShortDate=jc;exports.getValueLength=za;exports.headerData=Sr;exports.mapGetStreamData=SE;exports.pageReady=Pc;exports.passwordValidator=as;exports.repliesFeedMock=fE;exports.supportedLanguages=ga;exports.toCamelCase=Ac;exports.toCapitalisedCase=Bh;exports.toSentenceCase=Fc;exports.useCurrentPath=Cc;exports.useEffectAfterMount=Hn;exports.useElementWidth=Qn;exports.useOverlay=Lf;exports.useScrollListener=Ec;exports.useScrollToHash=Rs;exports.useTooltips=Ns;exports.useUser=Ya;
|
package/index.mjs
CHANGED
|
@@ -25498,7 +25498,8 @@ const aE = ({
|
|
|
25498
25498
|
},
|
|
25499
25499
|
functions: {
|
|
25500
25500
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25501
|
-
create: (E, { body: C }) => f({ activityId: n, replyId: r, content: C })
|
|
25501
|
+
create: (E, { body: C }) => f({ activityId: n, replyId: r, content: C }),
|
|
25502
|
+
getUsers: i.getUsers
|
|
25502
25503
|
},
|
|
25503
25504
|
meta: { isEditing: !1, showSuccessMessage: !1 }
|
|
25504
25505
|
},
|
|
@@ -25509,7 +25510,7 @@ const aE = ({
|
|
|
25509
25510
|
own_children: F,
|
|
25510
25511
|
latest_children: S,
|
|
25511
25512
|
children_counts: L,
|
|
25512
|
-
mentioned_users: N
|
|
25513
|
+
data: { mentioned_users: N }
|
|
25513
25514
|
} = E, R = (((D = F == null ? void 0 : F.like) == null ? void 0 : D.length) || 0) > 0 ? (W = F == null ? void 0 : F.like) == null ? void 0 : W.find((U) => {
|
|
25514
25515
|
var pe;
|
|
25515
25516
|
return ((pe = U == null ? void 0 : U.user) == null ? void 0 : pe.id) === (b == null ? void 0 : b.id);
|
package/package.json
CHANGED