!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"substack@538433c"};var t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3a65df26-c451-42d4-9f5a-38c904680d87",e._sentryDebugIdIdentifier="sentry-dbid-3a65df26-c451-42d4-9f5a-38c904680d87")}catch(e){}}();"use strict";(self.webpackChunksubstack=self.webpackChunksubstack||[]).push([["80655"],{62550:function(e,t,l){l.d(t,{s:()=>d});var n=l(69277),o=l(17402),r=l(15734),i=l.n(r),a=l(84605),s=l(68349);let d=e=>{let{iString:t}=(0,a.GO)(),[l,r]=(0,o.useState)(!1),[d,p]=(0,o.useState)(null),h=(0,o.useRef)(null),g=(e,l)=>{let n=(0,s.uX)(e,t(l));p(n),r(!1),console.error("".concat(l,":"),n)},m=async function(t,l,o){var a,s,d;let c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};r(!0),p(null);let m=null==(a=t.target)?void 0:a.files[0];if(!m)return void r(!1);try{if(e.submitWithAjax){let t=await u(l,m,(0,n._)({noRedirect:!0},c));r(!1),p(null),null==(s=e.onChangeLogo)||s.call(e,t.body.url)}else{let e=new FormData(null!=(d=h.current)?d:void 0);e.set("logo",m),await i().post(l).query(c).send(e),window.location.reload()}}catch(e){g(e,o)}},v=async function(l,n,o){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},{skipConfirm:a=!1}=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(a||window.confirm(t(n))){r(!0),p(null);try{if(e.submitWithAjax){var s;await c(l,i),r(!1),p(null),null==(s=e.onChangeLogo)||s.call(e,null)}else await c(l,i),window.location.reload()}catch(e){g(e,o)}}};return{loading:l,error:d,setLoading:r,setError:p,assignForm:e=>{h.current=e},handleApiError:g,handleImageUpload:m,handleImageDelete:v}},u=async function(e,t){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return i().post(e).attach("logo",t).query(l)},c=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return i().delete(e).query(t)}},67459:function(e,t,l){l.d(t,{m:()=>I});var n=l(4006),o=l(17402),r=l(84605),i=l(35369),a=l(16074),s=l(76977),d=l(20500),u=l(37598),c=l(61084),p=l(65842),h=l(82286),g=l(60561),m=l(20347),v=l(3849),b=l(69277),_=l(89490);function f(e){var t=(0,m._)({},(0,v._)(e));return(0,n.Y)(_.az,(0,b._)({width:20,height:20,radius:"xs",sizing:"border-box",border:"detail"},t))}function Y(e){let{color:t,isSelected:l,onClick:o}=e;return(0,n.Y)(i.Nm,{resetCss:!0,width:32,height:32,radius:"sm",border:"detail",sizing:"border-box",pressable:"sm",animate:!0,className:l?"selected-jjlvQ6":void 0,style:{background:t},onClick:o})}function y(e){return e.startsWith("#")?e.slice(1):e}var k=l(82776);function C(e){let{value:t,onCanSaveChange:l}=e,{iString:i}=(0,r.GO)(),[a,s]=(0,o.useState)(y(t));(0,o.useEffect)(()=>{s(y(t))},[t]);let d=e=>{var t;let l=e.startsWith("#")?e:"#".concat(e),n=l.slice(1);return"#".concat((t=n,/^[0-9A-F]{1}$/i.test(t)?t.repeat(6):/^[0-9A-F]{2}$/i.test(t)?t.repeat(3):/^[0-9A-F]{3,5}$/i.test(t)?t.split("").map(e=>e+e).join("").slice(0,6):t))},u=e=>{let l;return l=d(e),(0,k.validateHex)(l)&&d(e)!==t},c=d(a),h=(0,k.validateHex)(c)?c:"transparent";return(0,n.Y)(p.ks,{value:a,placeholder:i("Enter a hex color"),autoFocus:!0,onChange:e=>{let t=e.currentTarget.value;s(t);let n=d(t);l(u(t),n)},onBlur:e=>{let n=e.currentTarget.value.trim();if(""===n){s(y(t)),l(u(t),t);return}let o=d(n);(0,k.validateHex)(o)&&(s(y(o)),l(u(o),o))},onPaste:e=>{var t;let n=null==(t=e.clipboardData)?void 0:t.getData("text");if(null==n?void 0:n.startsWith("#")){e.preventDefault();let t=y(n).slice(0,6);s(t);let o=d(t);l(u(t),o)}},leading:(0,n.Y)(f,{style:{background:h}}),flex:"grow",maxLength:6,style:{textTransform:a.length>0?"uppercase":"none"}})}let w={accent:[["FF6719","e11d48","ec4899","c026d3","9333ea","7c3aed"],["4f46e5","2563eb","0284c7","0891b2","0d9488","059669"],["16a34a","65a30d","a16207","d97706","ea580c","292524"],["4c0519","1e1b4b","042f2e","1a2e05","431407","020617"]],background:[["ffffff","fafafa","fff1f2","fdf2f8","faf5ff","fdf4ff"],["f3e8ff","eef2ff","eff6ff","f0f9ff","ecfeff","f0fdfa"],["ecfdf5","f0fdf4","f7fee7","fffbeb","fff7ed","fef2f2"],["292524","171717","111827","020617","1e1b4b","042f2e"]]},I=e=>{let{color:t,colorTypes:l,hasError:o=!1,onPreviewChange:i,presets:a,info:s,onBeforeSelect:d,onSelect:p}=e,{iString:h}=(0,r.GO)(),{previewColorChange:m,clearPreview:v,pauseAndClearPreview:b}=(0,g.v9)(),_=e=>{(null==l?void 0:l.length)&&(e?(m({color:e,colorTypes:l}),null==i||i()):v())},Y=()=>{b(),null==d||d()};return(0,n.Y)(u.A,{trigger:(0,n.Y)(c.UC,{error:o,label:t?y(t):void 0,leading:(0,n.Y)(f,{style:{background:t}}),placeholder:h("Select a color"),style:{textTransform:"uppercase"}}),onClose:()=>_(null),children:e=>{let{close:l}=e;return(0,n.Y)(S,{close:l,color:t,info:s,presets:w[a],onBeforeSelect:Y,onPreview:_,onSelect:p})}})};function S(e){let{close:t,color:l,presets:u,info:c,onBeforeSelect:g,onSelect:m,onPreview:v}=e,{iString:b}=(0,r.GO)(),[_,f]=(0,o.useState)(!1),[Y,y]=(0,o.useState)(l);return(0,n.FD)(s.VP,{className:"picker-fFsg2n",onClick:e=>e.stopPropagation(),children:[(0,n.Y)(D,{presets:u,selectedColor:l,onMouseLeave:()=>v(null),onPreview:v,onSelect:e=>{null==g||g(),m(e),t()}}),(0,n.Y)(a.v,{}),(0,n.FD)(p.A0,{children:[(0,n.FD)(h.Xn,{children:[(0,n.Y)(C,{value:l,onCanSaveChange:(e,t)=>{f(e),y(t),v(t)}}),_&&(0,n.Y)(i.$n,{priority:"primary-mono",onClick:()=>{_&&(null==g||g(),m(Y),t())},children:b("Save")})]}),c&&(0,n.Y)(d.EE,{children:c})]})]})}function D(e){let{presets:t,selectedColor:l,onMouseLeave:o,onSelect:r,onPreview:i}=e;return(0,n.Y)("div",{className:"grid-_aCbEZ",onMouseLeave:o,children:t.map((e,t)=>(0,n.Y)(s.fI,{className:"row-HPeXLD",children:e.map(e=>{let t="#".concat(e),o=y(l)===e;return(0,n.Y)("div",{onMouseEnter:()=>i(t),children:(0,n.Y)(Y,{color:t,isSelected:o,onClick:()=>r(t)})},e)})},t))})}},8205:function(e,t,l){l.d(t,{e:()=>a,n:()=>i});var n=l(4006),o=l(17402);let r=(0,o.createContext)(null),i=e=>{let{children:t,value:l}=e;return(0,n.Y)(r.Provider,{value:l,children:t})},a=()=>{let e=(0,o.useContext)(r);if(!e)throw Error("useContentBlocksContext must be used within a ContentBlocksProvider");return e}},96025:function(e,t,l){l.d(t,{O:()=>i,W:()=>a});var n=l(4006),o=l(17402);let r=(0,o.createContext)(null),i=e=>{let{children:t}=e,[l,i]=(0,o.useState)(null),[a,s]=(0,o.useState)(!1),d=(0,o.useCallback)(e=>{i(e)},[]),u=(0,o.useCallback)(e=>{s(e)},[]);return(0,n.Y)(r.Provider,{value:{simulatePostCount:l,setSimulatePostCount:d,hideImages:a,setHideImages:u},children:t})};function a(){let e=(0,o.useContext)(r);if(!e)throw Error("useDevTools must be used within a DevToolsProvider");return e}},41322:function(e,t,l){l.d(t,{T:()=>F});var n=l(4006),o=l(84605),r=l(20500),i=l(88762),a=l(62550),s=l(80887),d=l(88296),u=l(94796),c=l(42391),p=l(1839),h=l(17402),g=l(7842),m=l(33764),v=l(35369),b=l(17028),_=l(76977),f=l(45859),Y=l(19832),y=l(57820),k=l(63136),C=l(25112),w=l(49807);let I={logoImageWrapper:"logoImageWrapper-q6tofM",fullWidthImageWrapper:"fullWidthImageWrapper-adkFQ9",placeholder:"placeholder-YLueDo",logoWrapper:"logoWrapper-w0evGH",logo:"logo-U9Fiyi",fullWidthWrapper:"fullWidthWrapper-RnNlYs",wordmark:"wordmark-PxcHNx",welcome:"welcome-SLPHte",loadingOverlay:"loadingOverlay-Apkz_U"},S=(0,w.dJ9)("/icon/SubstackIcon?height=128&fill=%23DDDDDD&stroke=%23DDDDDD",256),D=e=>{let{variant:t,url:l,loading:r,onChange:i,onDelete:a}=e,{iString:s}=(0,o.GO)(),w=(0,h.useRef)(null),[D,F]=(0,h.useState)(!1),[O,A]=(0,h.useState)(!1),[B,T]=(0,h.useState)(!1),P="wordmark"===t,x="welcome"===t,R="logo"===t,E=()=>{var e;return null==(e=w.current)?void 0:e.click()},W=()=>F(!0),N=async e=>{i({target:{files:[new File([e],"generated.png",{type:"image/png"})]}})},M=async()=>{T(!0),await a(),A(!1),T(!1)},G="logo"===t?I.logoImageWrapper:I.fullWidthImageWrapper,L=(0,n.Y)(v.Nm,{animate:!0,bg:"primary",border:"detail",borderStyle:"dashed",className:I.placeholder,cursor:"pointer",hover:!0,radius:"sm",resetCss:!0,children:(0,n.Y)(_.ov,{direction:"column",gap:4,children:r?(0,n.Y)(y.y$,{}):(0,n.FD)(n.FK,{children:[(0,n.Y)(d.A,{size:16}),(0,n.Y)(k.EY.B5,{color:"primary",weight:"medium",children:s("Add image")})]})})}),z=(0,n.FD)(b.az,{border:"detail",className:"logo"===t?I.logoWrapper:I.fullWidthWrapper,overflow:"hidden",position:"relative",radius:"sm",children:[(0,n.Y)(m.o,{alt:s(P?"Publication wordmark":x?"Welcome image":"Publication logo"),className:P?I.wordmark:x?I.welcome:I.logo,imageIsFixedWidth:"logo"===t,maxWidth:"logo"===t?56:C.u2,src:l||S,useRetinaSizing:!0}),r&&(0,n.Y)(b.VP,{alignItems:"center",className:I.loadingOverlay,justifyContent:"center",position:"absolute",children:(0,n.Y)(y.y$,{size:24,theme:"media"})})]});return(0,n.FD)(b.VP,{className:I.container,children:[l?(0,n.Y)(b.VP,{className:G,position:"relative",children:(0,n.FD)(f.W1,{trigger:z,children:[(0,n.Y)(f.Dr,{leading:(0,n.Y)(u.A,{}),onClick:E,children:s("Upload new image")}),R&&(0,n.Y)(f.Dr,{leading:(0,n.Y)(c.A,{}),onClick:W,children:s("Generate new image")}),(0,n.Y)(f.H9,{children:(0,n.Y)(f.Dr,{leading:(0,n.Y)(p.A,{}),priority:"destructive",onClick:()=>A(!0),children:s("Remove image")})})]})}):(0,n.FD)(f.W1,{trigger:L,children:[(0,n.Y)(f.Dr,{leading:(0,n.Y)(u.A,{}),onClick:E,children:s("Upload image")}),R&&(0,n.Y)(f.Dr,{leading:(0,n.Y)(c.A,{}),onClick:W,children:s("Generate image")})]}),(0,n.Y)("input",{ref:w,name:"logo",style:{display:"none"},type:"file",onChange:e=>{e.currentTarget.files&&i({target:{files:Array.from(e.currentTarget.files)}})}}),R&&(0,n.Y)(g.u,{isOpen:D,onClose:()=>F(!1),onImageSelected:N}),(0,n.Y)(Y.m,{description:s(P?"Are you sure you want to remove your wordmark?":x?"Are you sure you want to remove your welcome image?":"Are you sure you want to remove your logo?"),isOpen:O,primaryButton:(0,n.Y)(v.$n,{loading:B,priority:"destructive",onClick:M,children:s("Remove")}),secondaryButton:(0,n.Y)(v.$n,{disabled:B,priority:"secondary-outline",onClick:()=>A(!1),children:s("Cancel")}),title:s(P?"Remove wordmark":x?"Remove welcome photo":"Remove logo"),onClose:()=>A(!1)})]})},F=e=>{let{variant:t,url:l,onChange:d}=e,{iString:u}=(0,o.GO)(),c=(0,a.s)({url:l,submitWithAjax:!0,onChangeLogo:d}),p="wordmark"===t,h="welcome"===t,g="/api/v1/publication/logo",m=p?{wide:!0}:h?{cover:!0}:{},v=u(p?"Wordmark":h?"Image":"Logo"),b=u(p?"Horizontal image at least 1344\xd7256 pixels":h?"Image at least 600\xd7600 pixels shown on your welcome page":"Square image at least 256\xd7256 pixels"),_=p?"wordmark":h?"welcome photo":"logo";return(0,n.Y)("form",{ref:c.assignForm,action:"".concat(g).concat(p?"?wide=true":h?"?cover=true":""),encType:"multipart/form-data",method:"post",children:(0,n.FD)(s.u,{label:(0,n.Y)(i.oP,{tooltip:b,children:v}),children:[(0,n.Y)(D,{loading:c.loading,url:l,variant:t,onChange:e=>{c.handleImageUpload(e,g,"error uploading ".concat(_),m)},onDelete:()=>c.handleImageDelete(g,"","error deleting ".concat(_),m,{skipConfirm:!0})}),c.error&&(0,n.Y)(r.yn,{children:c.error})]})})}},74716:function(e,t,l){l.d(t,{J:()=>s});var n=l(4006),o=l(84605),r=l(67459),i=l(80887),a=l(16499);let s=e=>{let{colorType:t,label:l,theme:s,value:d,onChange:u}=e,{iString:c}=(0,o.GO)(),p=s.web_bg_color||"#ffffff",h=null!==d;return(0,n.FD)(n.FK,{children:[(0,n.Y)(a.e,{label:c("Use custom colors"),value:h,onChange:e=>u(e?p:null)}),h&&(0,n.Y)(i.u,{label:l,children:(0,n.Y)(r.m,{color:null!=d?d:p,colorTypes:[t],presets:"background",onSelect:u})})]})}},46454:function(e,t,l){l.d(t,{u:()=>tW});var n=l(4006),o=l(85478),r=l(69277),i=l(84605),a=l(8205),s=l(60561),d=l(32485),u=l.n(d),c=l(35369),p=l(76977),h=l(63136);let g=e=>{let{description:t,disabled:l,isSelected:o,title:r,onClick:i,onMouseEnter:a}=e;return(0,n.FD)(c.Nm,{className:u()("option-SKqMtI",{[String("selected-hkGw8f")]:o,[String("disabled-HtWQiV")]:l}),disabled:l,resetCss:!0,onClick:l?void 0:i,onMouseEnter:l?void 0:a,children:[(0,n.Y)(h.EY.B4,{color:l?"tertiary":"primary",ellipsis:!0,weight:"medium",children:r}),(0,n.Y)(h.EY.B5,{color:l?"tertiary":"secondary",ellipsis:!0,children:t})]})},m=e=>{let{children:t,onMouseLeave:l}=e;return(0,n.Y)(p.I1,{alignItems:"stretch",gap:4,paddingX:8,onMouseLeave:l,children:t})};var v=l(27449),b=l(57459);let _=e=>{let{insertAfterIndex:t,onBlockInsert:l}=e,{iString:o}=(0,i.GO)(),{pub:d}=(0,a.e)(),{previewContentBlockInsert:u,clearPreview:c}=(0,s.v9)(),p=(0,b.be)({pub:d}).availableBlockTypes.map(e=>(0,r._)({type:e},(0,b.WI)(e,o)));return(0,n.FD)(v.O.Wrapper,{children:[(0,n.Y)(v.O.Header,{title:o("Add block")}),(0,n.Y)(v.O.ScrollArea,{children:(0,n.Y)(m,{onMouseLeave:c,children:p.map(e=>{let{type:o,title:r,description:i}=e;return(0,n.Y)(g,{description:i,title:r,onClick:()=>{c(),l(o)},onMouseEnter:()=>{u({blockType:o,insertAfterIndex:t})}},o)})})})]})};var f=l(90883),Y=l(17402),y=l(54217),k=l(54718),C=l(32708),w=l(6632),I=l(43241),S=l(80697),D=l(45859),F=l(66511),O=l(47787),A=l(65670);let B=e=>{let{contentBlockId:t,canDelete:l,hasUnsavedChanges:o}=e,{iString:r}=(0,i.GO)(),{contentBlocks:s,deleteContentBlock:d,reorderContentBlocks:u,restoreContentBlocks:p}=(0,a.e)(),{openPicker:h}=(0,A.er)(),{scrollToBlock:g}=(0,O.i)(),{showDeleteSuccess:m}=(0,y.U)(),v=s.findIndex(e=>e.id===t),b=v>0,_=v{let e=[...s];await d(t),m(()=>p(e))},Y=(0,n.Y)(c.K0,{priority:"tertiary",size:"sm",children:(0,n.Y)(k.A,{size:20})}),B=l?(0,n.Y)(D.Dr,{leading:(0,n.Y)(C.A,{}),priority:"destructive",onClick:f,children:r("Remove block")}):(0,n.Y)(F.m_,{text:r("You must have at least one content block"),children:(0,n.Y)(D.Dr,{disabled:!0,leading:(0,n.Y)(C.A,{}),priority:"destructive",children:r("Remove block")})});return(0,n.FD)(D.W1,{align:"start",trigger:Y,children:[(0,n.Y)(D.Dr,{disabled:!b,leading:(0,n.Y)(w.A,{}),onClick:()=>{b&&(u(v,v-1),setTimeout(()=>{g({type:"content-block",id:t})},100))},children:r("Move block up")}),(0,n.Y)(D.Dr,{disabled:!_,leading:(0,n.Y)(I.A,{}),onClick:()=>{_&&(u(v,v+1),setTimeout(()=>{g({type:"content-block",id:t})},100))},children:r("Move block down")}),o?(0,n.Y)(F.m_,{text:r("Please save or cancel your changes first."),children:(0,n.Y)(D.Dr,{disabled:!0,leading:(0,n.Y)(S.A,{}),children:r("Insert block above")})}):(0,n.Y)(D.Dr,{leading:(0,n.Y)(S.A,{}),onClick:()=>{h({type:"block-picker",insertAfterIndex:v-1})},children:r("Insert block above")}),o?(0,n.Y)(F.m_,{text:r("Please save or cancel your changes first."),children:(0,n.Y)(D.Dr,{disabled:!0,leading:(0,n.Y)(S.A,{}),children:r("Insert block below")})}):(0,n.Y)(D.Dr,{leading:(0,n.Y)(S.A,{}),onClick:()=>{h({type:"block-picker",insertAfterIndex:v})},children:r("Insert block below")}),B]})};var T=l(17028),P=l(86465),x=l(78403),R=l(80887),E=l(79284),W=l(67211),N=l(60141);let M=e=>{let{value:t,onChange:l}=e,{iString:o}=(0,i.GO)(),[r,a]=(0,Y.useState)(!!t),s=(0,Y.useRef)(null),d=(0,Y.useRef)(!0);return(0,Y.useEffect)(()=>{if(d.current){d.current=!1;return}r&&s.current&&s.current.focus()},[r]),(0,n.FD)(R.u,{label:o("Title"),children:[(0,n.Y)(W.Y,{label:o("Use override"),value:r,onChange:e=>{a(e),e||l("")}}),r&&(0,n.Y)(N.A,{inputRef:s,label:"",value:null!=t?t:"",onChange:l})]})};var G=l(79785),L=l(33031),z=l.n(L),H=l(60250),X=l(87677),U=l(61084);function J(){let e=(0,G._)(["Tag: ",""]);return J=function(){return e},e}function K(){let e=(0,G._)(["Tag: Unknown"]);return K=function(){return e},e}function V(){let e=(0,G._)(["Section: ",""]);return V=function(){return e},e}function j(){let e=(0,G._)(["Section: Unknown"]);return j=function(){return e},e}let $=e=>{let{disabled:t,error:l,value:o,postTags:r,sections:a,onChange:s}=e,{iString:d,iTemplate:u}=(0,i.GO)(),[c,p]=(0,Y.useState)(null),h="";if("tag"===o.post_source){let e=r.find(e=>e.id===o.post_tag_id);h=(null==e?void 0:e.name)?u(J(),null==e?void 0:e.name):u(K())}else if("section"===o.post_source){let e=a.find(e=>e.id===o.section_id);h=(null==e?void 0:e.name)?u(V(),null==e?void 0:e.name):u(j())}else h=d("latest"===o.post_source?"Recent posts":"multiple"===o.post_source?"Recent posts":"Unknown");return(0,n.FD)(U.eB,{disabled:t,error:l,label:h,children:[!c&&(0,n.Y)(U.Jm,{onClick:()=>{s({post_source:"latest",section_id:null,post_tag_id:null})},selected:"latest"===o.post_source,children:d("Recent posts")}),!c&&(0,n.Y)(ee,{value:"tags",setActiveMenu:p,label:d("Tags")}),!c&&(0,n.Y)(ee,{value:"sections",setActiveMenu:p,label:d("Sections")}),"tags"===c&&(0,n.Y)(Z,{setActiveMenu:p,label:d("Tags")}),"tags"===c&&0===r.length&&(0,n.Y)(et,{text:d("Your publication has no tags")}),"tags"===c&&r.length>0&&(0,n.Y)(q,{postTags:r,onChange:s,setActiveMenu:p,value:o}),"sections"===c&&(0,n.Y)(Z,{setActiveMenu:p,label:d("Sections")}),"sections"===c&&0===a.length&&(0,n.Y)(et,{text:d("Your publication has no sections")}),"sections"===c&&a.length>0&&(0,n.Y)(Q,{sections:a,onChange:s,setActiveMenu:p,value:o})]})};function q(e){let{postTags:t,onChange:l,setActiveMenu:o,value:r}=e;return(0,n.Y)(D.H9,{children:z()(t,[e=>e.name.toLowerCase()]).map(e=>(0,n.Y)(U.Jm,{onClick:()=>{l({post_source:"tag",post_tag_id:e.id,section_id:null}),o(null)},selected:"tag"===r.post_source&&r.post_tag_id===e.id,children:e.name},e.id))})}function Q(e){let{sections:t,onChange:l,setActiveMenu:o,value:r}=e;return(0,n.Y)(D.H9,{children:z()(t,[e=>e.name.toLowerCase()]).map(e=>(0,n.Y)(U.Jm,{onClick:()=>{l({post_source:"section",section_id:e.id,post_tag_id:null}),o(null)},selected:"section"===r.post_source&&r.section_id===e.id,children:e.name},e.id))})}function Z(e){let{setActiveMenu:t,label:l}=e;return(0,n.Y)(U.Jm,{onClick:e=>{e.preventDefault(),t(null)},leading:(0,n.Y)(H.A,{}),children:l})}function ee(e){let{value:t,setActiveMenu:l,label:o}=e;return(0,n.Y)(U.Jm,{onClick:e=>{e.preventDefault(),l(t)},trailing:(0,n.Y)(X.A,{}),children:o})}function et(e){let{text:t}=e;return(0,n.Y)(D.H9,{children:(0,n.Y)(p.ov,{padding:6,children:(0,n.Y)(h.EY.B4,{color:"secondary",textAlign:"center",children:t})})})}var el=l(70408),en=l(83673),eo=l.n(en),er=l(38970),ei=l.n(er),ea=l(49207),es=l(57820),ed=l(21436),eu=l(45773),ec=l(33727),ep=l(65842);let eh=e=>{var t;let{item:l,allowTitleOverride:o,error:a,listeners:s,onRemove:d,onTitleOverrideChange:g}=e,{iString:m}=(0,i.GO)(),[v,b]=(0,Y.useState)(!!l.titleOverride),_=(0,Y.useRef)(null),f=(0,Y.useRef)(!0);return(0,Y.useEffect)(()=>{if(f.current){f.current=!1;return}v&&_.current&&_.current.focus()},[v]),(0,n.Y)(ec.Z,{className:u()("card-dV61x9",{[String("error-WvtNUg")]:a}),elevated:!1,outline:"detail",padding:0,radius:"sm",children:(0,n.FD)(p.I1,{gap:0,children:[(0,n.FD)(p.Ye,{alignItems:"center",gap:4,padding:8,children:[(0,n.Y)(p.fI,(0,el._)((0,r._)({alignItems:"center",className:"dragHandle-V_9iYr",cursor:"grab",height:24,justifyContent:"center",width:24},s),{children:(0,n.Y)(ed.A,{size:16})})),(0,n.Y)(h.EY.B4,{ellipsis:!0,flex:"grow",children:l.label}),(0,n.FD)(p.Ye,{gap:0,children:[o&&(0,n.Y)(D.W1,{trigger:(0,n.Y)(c.K0,{priority:"quaternary",size:"sm",children:(0,n.Y)(k.A,{size:16})}),children:(0,n.Y)(D.Dr,{trailing:v?(0,n.Y)(eu.A,{size:16}):void 0,onClick:()=>void(v?b(!1):b(!0),g("")),children:m("Add title override")})}),(0,n.Y)(c.K0,{priority:"quaternary",size:"sm",onClick:d,children:(0,n.Y)(C.A,{size:16})})]})]}),v&&(0,n.Y)(p.pT,{paddingBottom:12,paddingLeft:36,paddingRight:8,children:(0,n.Y)(ep.ks,{ref:_,placeholder:m("Title override"),style:{width:200},value:null!=(t=l.titleOverride)?t:"",onChange:e=>{g(e.currentTarget.value)}})})]})})},eg=e=>{let{allowTitleOverride:t,disabledSourceIds:l,label:o,postTags:a,sections:s,value:d,errorSourceStrings:u,onChange:c}=e,{iString:g}=(0,i.GO)(),m=ei()(a,"id"),v=ei()(s,"id"),b=new Set(d.map(e=>"section"===e.type?e.sectionId:e.tagId)),_=new Set((null!=u?u:[]).map(e=>{let[t,l]=e.split(":");return l?"section"===t?Number(l):l:null}).filter(e=>null!==e)),f=eo()(d.map(e=>{var t,l,n,o;let i="section"===e.type?e.sectionId:e.tagId;return null===i?null:(0,el._)((0,r._)({},e),{label:null!=(o=null==(t="section"===e.type?v[null!=(l=e.sectionId)?l:"undefined"]:m[null!=(n=e.tagId)?n:"undefined"])?void 0:t.name)?o:"Unknown",id:i})})),Y=!a||!s;return(0,n.FD)(p.I1,{gap:16,children:[o&&(0,n.Y)(h.EY.B4,{color:"secondary",weight:"medium",children:o}),Y?(0,n.Y)(p.Ye,{justifyContent:"center",children:(0,n.Y)(es.y$,{})}):(0,n.FD)(p.I1,{gap:8,children:[(0,n.Y)(ea.w,{items:f.map(e=>e.id),onReorder:e=>{let t=ei()(f,"id");c(e.map(e=>t[e]).filter(Boolean))},children:(0,n.Y)(p.I1,{gap:4,children:f.map(e=>(0,n.Y)(ea.W,{item:e.id,useDragHandle:!0,children:l=>{var o;let{listeners:i}=l;return(0,n.Y)(eh,{allowTitleOverride:t,error:_.has(e.id),item:{id:e.id,label:e.label,titleOverride:null!=(o=e.titleOverride)?o:null},listeners:i,onRemove:()=>{var t;return t=e.id,void c(f.filter(e=>e.id!==t))},onTitleOverrideChange:t=>{var l;return l=e.id,void c(d.map(e=>("section"===e.type?e.sectionId:e.tagId)===l?(0,el._)((0,r._)({},e),{titleOverride:t}):e))}})}},e.id))})}),(0,n.Y)(em,{disabledSourceIds:l,postTags:a,sections:s,selectedIds:b,onSelect:e=>{var t,l,n,o,i,a,s,d;c([...f,"tag"===e.type?(0,el._)((0,r._)({},e),{label:null!=(o=null==(t=m[null!=(n=e.tagId)?n:""])?void 0:t.name)?o:"",id:null!=(i=e.tagId)?i:""}):(0,el._)((0,r._)({},e),{label:null!=(s=null==(l=v[null!=(a=e.sectionId)?a:""])?void 0:l.name)?s:"",id:null!=(d=e.sectionId)?d:0})])}}),0===a.length&&0===s.length&&(0,n.FD)(p.I1,{gap:4,children:[(0,n.Y)(h.EY.B4,{color:"error",weight:"semibold",children:g("Add tags or sections to publish changes")}),(0,n.Y)(h.EY.B4,{color:"error",children:g("Add tags or sections to your posts or choose a different post layout")})]})]})]})},em=e=>{let{disabledSourceIds:t,postTags:l,sections:o,selectedIds:r,onSelect:a}=e,{iString:s}=(0,i.GO)(),[d,u]=(0,Y.useState)(null);return(0,n.FD)(D.W1,{trigger:(0,n.Y)(c.$n,{leading:(0,n.Y)(S.A,{size:16}),priority:"secondary-outline",size:"md",children:s("Add source")}),onClose:()=>u(null),children:[!d&&(0,n.Y)(U.Jm,{trailing:(0,n.Y)(X.A,{}),onClick:e=>{e.preventDefault(),u("tags")},children:s("Tags")}),!d&&(0,n.Y)(U.Jm,{trailing:(0,n.Y)(X.A,{}),onClick:e=>{e.preventDefault(),u("sections")},children:s("Sections")}),"tags"===d&&(0,n.Y)(U.Jm,{leading:(0,n.Y)(H.A,{}),onClick:e=>{e.preventDefault(),u(null)},children:s("Tags")}),"tags"===d&&0===l.length&&(0,n.Y)(D.H9,{children:(0,n.Y)(p.ov,{padding:6,children:(0,n.Y)(h.EY.B4,{color:"secondary",textAlign:"center",children:s("Your publication has no tags")})})}),"tags"===d&&l.length>0&&(0,n.Y)(D.H9,{children:(0,n.Y)(p.I1,{maxHeight:300,children:z()(l,[e=>e.name.toLowerCase()]).map(e=>(0,n.Y)(U.Jm,{disabled:r.has(e.id)||(null==t?void 0:t.has(e.id)),onClick:()=>{a({type:"tag",tagId:e.id,sectionId:null}),u(null)},children:e.name},e.id))})}),"sections"===d&&(0,n.Y)(U.Jm,{leading:(0,n.Y)(H.A,{}),onClick:e=>{e.preventDefault(),u(null)},children:s("Sections")}),"sections"===d&&0===o.length&&(0,n.Y)(D.H9,{children:(0,n.Y)(p.ov,{padding:6,children:(0,n.Y)(h.EY.B4,{color:"secondary",textAlign:"center",children:s("Your publication has no sections")})})}),"sections"===d&&o.length>0&&(0,n.Y)(D.H9,{children:(0,n.Y)(p.I1,{maxHeight:300,children:z()(o,[e=>e.name.toLowerCase()]).map(e=>(0,n.Y)(U.Jm,{disabled:r.has(e.id)||(null==t?void 0:t.has(e.id)),onClick:()=>{a({type:"section",sectionId:e.id,tagId:null}),u(null)},children:e.name},e.id))})})]})},ev=e=>{var t,l,o,r,d,u,c,p,h;let{contentBlock:g,errors:m}=e,{iString:v}=(0,i.GO)(),{changeContentBlock:_,pub:f,postTags:Y}=(0,a.e)(),{previewContentBlockChange:y}=(0,s.v9)(),k=(0,b.be)({pub:f}),C=null!=(d=null==(t=k.featureVariantOptions[0])?void 0:t.value)?d:"focus-left-list",w=null!=(u=null==(l=g.attrs.feature)?void 0:l.variant)?u:C,I=null!=(c=null==(o=k.featureVariantOptions.find(e=>e.value===w))?void 0:o.label)?c:w;return(0,n.Y)(T.I1,{children:(0,n.FD)(E.X,{scrollToBlockOnFocus:{type:"content-block",id:g.id},children:[(0,n.Y)(R.u,{label:v("Layout"),children:(0,n.Y)(x.y,{label:I,children:k.featureVariantOptions.map(e=>(0,n.Y)(x.y.Item,{selected:w===e.value,onClick:()=>{_({contentBlockId:g.id,updates:{attrs:{feature:{variant:e.value}}}})},onMouseEnter:()=>{y({contentBlockId:g.id,updates:{attrs:{feature:{variant:e.value}}}})},children:e.label},e.value))})}),(0,n.FD)(R.u,{label:v("Posts"),children:[(0,n.Y)($,{error:!!(null==m?void 0:m.post_source),postTags:Y||[],sections:f.sections,value:{post_source:g.post_source,post_tag_id:g.post_tag_id,section_id:g.section_id},onChange:e=>{_({contentBlockId:g.id,updates:e})}}),(0,n.Y)(P.I,{errors:null==m?void 0:m.post_source})]}),"multiple"===g.post_source&&(0,n.Y)(R.u,{label:v("Sources"),children:(0,n.Y)(eg,{label:"",postTags:Y,sections:f.sections,value:(null!=(p=g.postSources)?p:[]).map(e=>{var t,l;return{type:e.section_id?"section":"tag",sectionId:null!=(t=e.section_id)?t:null,tagId:null!=(l=e.tag_id)?l:null}}),onChange:e=>{_({contentBlockId:g.id,updates:{postSources:e.slice(0,10).map((e,t)=>({content_block_id:g.id,source_order:t+1,tag_id:e.tagId,section_id:e.sectionId,title_override:null}))}})}})}),(0,n.Y)(M,{value:null!=(h=g.attrs.titleOverride)?h:null==(r=g.attrs.feature)?void 0:r.title,onChange:e=>{_({contentBlockId:g.id,updates:{attrs:{titleOverride:e}}})}})]})})};var eb=l(16499),e_=l(86898);let ef=[{value:"list",label:"List"},{value:"grid",label:"Grid"}],eY=Array.from({length:e_.AD.rows.max-e_.AD.rows.min+1},(e,t)=>e_.AD.rows.min+t),ey=Array.from({length:e_.AD.posts.max-e_.AD.posts.min+1},(e,t)=>e_.AD.posts.min+t),ek=e=>{var t,l,o,r;let{contentBlock:d,errors:u}=e,{changeContentBlock:c,contentBlocks:p,pub:h,postTags:g}=(0,a.e)(),{previewContentBlockChange:m}=(0,s.v9)(),{iString:v}=(0,i.GO)(),b="grid"===d.block_type,_=b?"grid":"list",f=b&&"multiple"===d.post_source,Y=d.attrs.titleOverride,y=new Set;for(let e of p)if(e.id!==d.id){if("section"===e.post_source&&e.section_id)y.add(e.section_id);else if("tag"===e.post_source&&e.post_tag_id)y.add(e.post_tag_id);else if("multiple"===e.post_source&&e.postSources)for(let t of e.postSources)t.section_id&&y.add(t.section_id),t.tag_id&&y.add(t.tag_id)}let k=b?null!=(l=d.num_rows)?l:e_.AD.rows.default:null!=(o=d.num_posts)?o:e_.AD.posts.default,C=b?eY:ey,w=v(b?"Rows":"Posts");return(0,n.Y)(T.I1,{children:(0,n.FD)(E.X,{scrollToBlockOnFocus:{type:"content-block",id:d.id},children:[(0,n.Y)(R.u,{label:v("Layout"),children:(0,n.Y)(x.y,{label:null==(t=ef.find(e=>e.value===_))?void 0:t.label,children:ef.map(e=>(0,n.Y)(x.y.Item,{selected:_===e.value,onClick:()=>{if(e.value!==d.block_type){let t={block_type:e.value};"list"===e.value&&"multiple"===d.post_source&&(t.post_source="latest",t.postSources=[]),c({contentBlockId:d.id,updates:t})}},onMouseEnter:()=>m({contentBlockId:d.id,updates:{block_type:e.value}}),children:e.label},e.value))})}),(0,n.FD)(R.u,{label:v("Source"),children:[(0,n.Y)($,{disabled:f,error:!f&&!!(null==u?void 0:u.post_source),postTags:g||[],sections:h.sections,value:{post_source:d.post_source,post_tag_id:d.post_tag_id,section_id:d.section_id},onChange:e=>{c({contentBlockId:d.id,updates:e})}}),!f&&(0,n.Y)(P.I,{errors:null==u?void 0:u.post_source})]}),b&&(0,n.Y)(eb.e,{label:v("Use multiple sources"),value:f,onChange:e=>{e?c({contentBlockId:d.id,updates:{post_source:"multiple",section_id:null,post_tag_id:null}}):c({contentBlockId:d.id,updates:{post_source:"latest",postSources:[]}})}}),b&&f&&(0,n.FD)(T.I1,{gap:8,children:[(0,n.Y)(eg,{allowTitleOverride:!0,disabledSourceIds:y,errorSourceStrings:null==u?void 0:u.duplicate_post_sources,label:"",postTags:g,sections:h.sections,value:(null!=(r=d.postSources)?r:[]).map(e=>{var t,l,n;return{type:e.section_id?"section":"tag",sectionId:null!=(t=e.section_id)?t:null,tagId:null!=(l=e.tag_id)?l:null,titleOverride:null!=(n=e.title_override)?n:null}}),onChange:e=>{c({contentBlockId:d.id,updates:{postSources:e.slice(0,10).map((e,t)=>({content_block_id:d.id,source_order:t+1,tag_id:e.tagId,section_id:e.sectionId,title_override:e.titleOverride||null}))}})}}),(0,n.Y)(P.I,{errors:null==u?void 0:u.post_source})]}),!f&&(0,n.Y)(R.u,{label:w,children:(0,n.Y)(x.y,{label:String(k),children:C.map(e=>(0,n.Y)(x.y.Item,{selected:k===e,onClick:()=>c({contentBlockId:d.id,updates:b?{num_rows:e}:{num_posts:e}}),onMouseEnter:()=>m({contentBlockId:d.id,updates:b?{num_rows:e}:{num_posts:e}}),children:e},e))})}),!f&&(0,n.Y)(M,{value:Y,onChange:e=>{c({contentBlockId:d.id,updates:{attrs:{titleOverride:e}}})}})]})})},eC=[{value:"podcasts",label:"Podcasts"},{value:"videos",label:"Videos"}],ew=e=>{var t,l,o,r,d;let{contentBlock:u}=e,{iString:c}=(0,i.GO)(),{changeContentBlock:p}=(0,a.e)(),{previewContentBlockChange:h}=(0,s.v9)(),g=null!=(r=null==(l=u.attrs)||null==(t=l.media_carousel)?void 0:t.variant)?r:"podcasts",m=null!=(d=null==(o=eC.find(e=>e.value===g))?void 0:o.label)?d:g;return(0,n.Y)(T.I1,{children:(0,n.Y)(E.X,{scrollToBlockOnFocus:{type:"content-block",id:u.id},children:(0,n.Y)(R.u,{label:c("Media type"),children:(0,n.Y)(x.y,{label:m,children:eC.map(e=>(0,n.Y)(x.y.Item,{selected:g===e.value,onClick:()=>{p({contentBlockId:u.id,updates:{attrs:{media_carousel:{variant:e.value}}}})},onMouseEnter:()=>{h({contentBlockId:u.id,updates:{attrs:{media_carousel:{variant:e.value}}}})},children:e.label},e.value))})})})})},eI=e=>{let{contentBlock:t,errors:l,showTitleOverride:o=!1}=e,{iString:r}=(0,i.GO)(),{changeContentBlock:s,pub:d,postTags:u}=(0,a.e)();return(0,n.Y)(T.I1,{children:(0,n.FD)(E.X,{scrollToBlockOnFocus:{type:"content-block",id:t.id},children:[(0,n.FD)(R.u,{label:r("Source"),children:[(0,n.Y)($,{error:!!(null==l?void 0:l.post_source),postTags:u||[],sections:d.sections,value:{post_source:t.post_source,post_tag_id:t.post_tag_id,section_id:t.section_id},onChange:e=>{s({contentBlockId:t.id,updates:e})}}),(0,n.Y)(P.I,{errors:null==l?void 0:l.post_source})]}),o&&(0,n.Y)(M,{value:t.attrs.titleOverride,onChange:e=>{s({contentBlockId:t.id,updates:{attrs:{titleOverride:e}}})}})]})})};var eS=l(56458);let eD=e=>{var t,l,o,r,s,d,u,c;let{contentBlock:p,onUserRoleChange:h}=e,{changeContentBlock:g,pub:m}=(0,a.e)(),{iString:v}=(0,i.GO)(),b="enabled"===m.payments_state,_=(0,eS.QN)(m);return(0,Y.useEffect)(()=>()=>{h("unsubscribed")},[h]),(0,n.Y)(T.I1,{children:(0,n.Y)(E.X,{title:v("Messages"),children:(0,n.FD)(T.I1,{gap:16,children:[(0,n.Y)(N.A,{label:v("Message for non-subscribers"),value:null!=(s=null==(t=p.attrs)?void 0:t.non_subscriber_message)?s:"",onChange:e=>{g({contentBlockId:p.id,updates:{attrs:{non_subscriber_message:e}}})},onFocus:()=>{h("unsubscribed")}}),(0,n.Y)(N.A,{label:v("Message for free subscribers"),value:null!=(d=null==(l=p.attrs)?void 0:l.free_subscriber_message)?d:"",onChange:e=>{g({contentBlockId:p.id,updates:{attrs:{free_subscriber_message:e}}})},onFocus:()=>{h("free")}}),b&&(0,n.Y)(N.A,{label:v("Message for paid subscribers"),value:null!=(u=null==(o=p.attrs)?void 0:o.paid_subscriber_message)?u:"",onChange:e=>{g({contentBlockId:p.id,updates:{attrs:{paid_subscriber_message:e}}})},onFocus:()=>{h("paid")}}),b&&_&&(0,n.Y)(N.A,{label:v("Message for founding members"),value:null!=(c=null==(r=p.attrs)?void 0:r.founding_member_message)?c:"",onChange:e=>{g({contentBlockId:p.id,updates:{attrs:{founding_member_message:e}}})},onFocus:()=>{h("founding")}})]})})})};var eF=l(71783);let eO=e=>{let{contentBlockId:t,onReset:l,onSave:o,onUserRoleChange:r}=e,{iString:s}=(0,i.GO)(),{contentBlocks:d,contentBlockErrors:u}=(0,a.e)(),{hasUnsavedChanges:c}=(0,y.U)(),p=(0,f.md)(eF.pD),h=d.find(e=>e.id===t),g=(0,Y.useMemo)(()=>{let e=[];return u.global&&e.push(...u.global),Object.values(u.contentBlocks).forEach(t=>{(null==t?void 0:t.primary_sidebar_modules)&&t.primary_sidebar_modules.forEach(t=>{e.includes(t)||e.push(t)}),(null==t?void 0:t.secondary_sidebar_modules)&&t.secondary_sidebar_modules.forEach(t=>{e.includes(t)||e.push(t)})}),e.length>0?e:null},[u]);if(!h)return null;let m=(0,b.WI)(h.block_type,s).title,_=u.contentBlocks[h.id],k=d.length>1;return(0,n.FD)(v.O.Wrapper,{children:[(0,n.Y)(v.O.Header,{renderActions:p?void 0:()=>(0,n.Y)(B,{canDelete:k,contentBlockId:t,hasUnsavedChanges:c}),title:m,onReset:l,onSave:o}),(0,n.FD)(v.O.ScrollArea,{children:[(()=>{switch(h.block_type){case"feature":return(0,n.Y)(ev,{contentBlock:h,errors:_});case"grid":case"list":return(0,n.Y)(ek,{contentBlock:h,errors:_});case"subscribe":return(0,n.Y)(eD,{contentBlock:h,onUserRoleChange:r});case"half_feature":return(0,n.Y)(eI,{contentBlock:h,errors:_,showTitleOverride:!0});case"podcast_plus_three":case"single_post":return(0,n.Y)(eI,{contentBlock:h,errors:_});case"media_carousel":return(0,n.Y)(ew,{contentBlock:h});default:return null}})(),(0,n.Y)(v.O.Footer,{errors:g,onReset:l,onSave:o})]})]})};var eA=l(83126),eB=l(49031),eT=l(84713),eP=l(34581),ex=l(65217),eR=l(65590),eE=l(74716),eW=l(72535),eN=l(19945);let eM=e=>{var t,l,o,a,d,u,c,p,h,g,m;let{pub:v,theme:b,onThemeChange:_}=e,{iString:f}=(0,i.GO)(),{previewFooterChange:Y}=(0,s.v9)(),{scrollToBlock:y}=(0,O.i)(),k=(0,r._)({},eN.F7,b.custom_footer),C="default"===k.layout,w=(e=>{let{isCustomLayout:t,iString:l}=e;return[{value:"default",label:l(t?"None":"Default")},{value:"centered",label:l("Centered")},{value:"two-column",label:l("Two Column")},{value:"three-column",label:l("Three Column")}]})({isCustomLayout:"custom"===b.home_posts,iString:f}),I=(e=>{let{iString:t}=e;return[{value:"hidden",label:t("Hidden"),showPublicationName:!1},{value:"top",label:t("Top"),showPublicationName:!0,publicationNamePosition:"top"},{value:"bottom",label:t("Bottom"),showPublicationName:!0,publicationNamePosition:"bottom"}]})({iString:f}),S=null!=(t=b.social_media_links)?t:{},D=!!v.logo_url_wide,F=e=>{_((0,eW.T)({theme:b,updates:e}))},A=e=>{_({social_media_links:(0,r._)({},S,e)})},B=w.find(e=>e.value===k.layout),P=(g=k.showPublicationName,m=k.publicationNamePosition,g?m:"hidden"),W=I.find(e=>e.value===P);return(0,n.FD)(T.I1,{children:[(0,n.FD)(E.X,{children:[(0,n.Y)(R.u,{label:f("Layout"),children:(0,n.Y)(x.y,{label:null==B?void 0:B.label,children:w.map(e=>(0,n.Y)(x.y.Item,{selected:k.layout===e.value,onClick:()=>{_((0,eW.T)({theme:b,updates:{layout:e.value}})),y({type:"footer"})},onMouseEnter:()=>{Y({layout:e.value}),y({type:"footer"})},children:e.label},e.value))})}),!C&&(0,n.Y)(eE.J,{colorType:"custom_footer_bg",label:f("Background"),theme:b,value:null!=(l=k.backgroundColor)?l:null,onChange:e=>F({backgroundColor:e})})]}),!C&&(0,n.FD)(E.X,{title:f("Publication banner"),children:[(0,n.Y)(R.u,{label:f("Position"),children:(0,n.Y)(x.y,{label:null==W?void 0:W.label,children:I.map(e=>(0,n.Y)(x.y.Item,{selected:P===e.value,onClick:()=>{F((0,r._)({showPublicationName:e.showPublicationName},e.publicationNamePosition&&{publicationNamePosition:e.publicationNamePosition})),y({type:"footer"})},onMouseEnter:()=>{Y({showPublicationName:e.showPublicationName,publicationNamePosition:e.publicationNamePosition}),y({type:"footer"})},children:e.label},e.value))})}),k.showPublicationName&&(0,n.FD)(T.I1,{gap:12,children:[D&&(0,n.Y)(eb.e,{label:f("Show wordmark"),value:"wordmark"===k.publicationNameStyle,onChange:e=>F({publicationNameStyle:e?"wordmark":"text"})}),(0,n.Y)(eE.J,{colorType:"custom_footer_secondary_bg",label:f("Background"),theme:b,value:null!=(o=k.publicationNameBackgroundColor)?o:null,onChange:e=>F({publicationNameBackgroundColor:e})})]})]}),!C&&(0,n.FD)(E.X,{title:f("Social Media Links"),children:[(0,n.Y)(R.u,{label:f("Instagram"),children:(0,n.Y)(ep.ks,{leading:(0,n.Y)(eT.A,{size:20}),placeholder:"@username",value:null!=(a=S.instagram)?a:"",onChange:e=>A({instagram:e.currentTarget.value||null})})}),(0,n.Y)(R.u,{label:f("TikTok"),children:(0,n.Y)(ep.ks,{leading:(0,n.Y)(ex.A,{size:20}),placeholder:"@username",value:null!=(d=S.tiktok)?d:"",onChange:e=>A({tiktok:e.currentTarget.value||null})})}),(0,n.Y)(R.u,{label:f("YouTube"),children:(0,n.Y)(ep.ks,{leading:(0,n.Y)(eR.A,{size:20}),placeholder:"@username",value:null!=(u=S.youtube)?u:"",onChange:e=>A({youtube:e.currentTarget.value||null})})}),(0,n.Y)(R.u,{label:f("Facebook"),children:(0,n.Y)(ep.ks,{leading:(0,n.Y)(eB.A,{size:20}),placeholder:"username",value:null!=(c=S.facebook)?c:"",onChange:e=>A({facebook:e.currentTarget.value||null})})}),(0,n.Y)(R.u,{label:f("LinkedIn"),children:(0,n.Y)(ep.ks,{leading:(0,n.Y)(eP.A,{size:20}),placeholder:"linkedin.com/in/username",value:null!=(p=S.linkedin)?p:"",onChange:e=>A({linkedin:e.currentTarget.value||null})})}),(0,n.Y)(R.u,{label:f("Bluesky"),children:(0,n.Y)(ep.ks,{leading:(0,n.Y)(eA.A,{size:20}),placeholder:"@username.bsky.social",value:null!=(h=S.bluesky)?h:"",onChange:e=>A({bluesky:e.currentTarget.value||null})})})]})]})},eG=e=>{let{errors:t,pub:l,theme:o,onReset:r,onSave:a,onThemeChange:s}=e,{iString:d}=(0,i.GO)();return(0,n.FD)(v.O.Wrapper,{children:[(0,n.Y)(v.O.Header,{title:d("Footer"),onReset:r,onSave:a}),(0,n.FD)(v.O.ScrollArea,{children:[(0,n.Y)(eM,{pub:l,theme:o,onThemeChange:s}),(0,n.Y)(v.O.Footer,{errors:t,onReset:r,onSave:a})]})]})};var eL=l(41322),ez=l(23781);let eH=e=>{let{defaultFontKey:t,label:l,value:o,onChange:r,onPreview:a}=e,{iString:d}=(0,i.GO)(),{clearPreview:u}=(0,s.v9)(),c=null!=o;return(0,n.FD)(n.FK,{children:[(0,n.Y)(eb.e,{label:d("Use custom fonts"),value:c,onChange:e=>r(e&&null!=t?t:null)}),c&&(0,n.Y)(R.u,{label:l,children:(0,n.Y)(ez.S,{fontKey:null!=o?o:t,onPreview:e=>{a?a(e):e||u()},onSelect:r})})]})},eX=[{value:"stacked-nav-bottom",label:"Standard",layout:"stacked",navPosition:"bottom"},{value:"wide-wordmark",label:"Wide",layout:"stacked",navPosition:"top"},{value:"hamburger",label:"Hamburger",layout:"logo_center",navStyle:"stacked"},{value:"logo_left",label:"Inline",layout:"logo_left"}],eU=[{value:"text",label:"Text"},{value:"buttons",label:"Button"},{value:"stacked",label:"Hamburger"}],eJ=e=>{var t,l,a,d,u,c,p,h;let{pub:g,theme:m,onPubLogosChange:v,onThemeChange:b}=e,{iString:_}=(0,i.GO)(),{getConfigFor:f}=(0,o.mJ)(),{previewHeaderChange:Y,previewFontChange:y,clearPreview:k}=(0,s.v9)(),C=!!f("use_advanced_fonts"),w=(0,r._)({},eN.Tb,m.custom_header),I=w.navStyle,S=(c=w.layout,p=w.navPosition,"stacked"===(h=I)&&"logo_center"===c?"hamburger":"stacked"===c?"top"===p&&"stacked"!==h?"wide-wordmark":"stacked-nav-bottom":"logo_center"===c?"stacked-nav-bottom":"logo_left"),D=eX.find(e=>e.value===S),F=eU.find(e=>e.value===I),O=null!=(a=null==(t=m.font_options)?void 0:t.heading)?a:m.font_preset_heading,A="hamburger"===S,B="logo_left"===w.layout||"stacked"===w.layout?eU.filter(e=>"stacked"!==e.value):eU;return(0,n.FD)(T.I1,{children:[(0,n.FD)(E.X,{title:_("Images"),children:[(0,n.Y)(eL.T,{url:g.logo_url,variant:"logo",onChange:e=>v({logo_url:e})}),(0,n.Y)(eL.T,{url:g.logo_url_wide,variant:"wordmark",onChange:e=>v({logo_url_wide:e})})]}),(0,n.FD)(E.X,{title:_("Display"),children:[(0,n.Y)(R.u,{label:_("Layout"),children:(0,n.Y)(x.y,{label:null==D?void 0:D.label,children:eX.map(e=>(0,n.Y)(x.y.Item,{selected:S===e.value,onClick:()=>{let t={layout:e.layout,navPosition:e.navPosition};e.navStyle?t.navStyle=e.navStyle:"stacked"===I&&(t.navStyle="text"),"logo_left"===e.value&&"stacked"===I&&(t.navStyle="text"),b((0,eW.z)({theme:m,updates:t}))},onMouseEnter:()=>Y({layout:e.layout,navPosition:e.navPosition,navStyle:e.navStyle}),children:e.label},e.value))})}),A&&(0,n.Y)(eb.e,{label:_("Show logo"),value:!1!==w.showLogo,onChange:e=>b((0,eW.z)({theme:m,updates:{showLogo:e}}))}),!A&&(0,n.Y)(R.u,{label:_("Navigation"),children:(0,n.Y)(x.y,{label:null!=(d=null==F?void 0:F.label)?d:"Text",children:B.map(e=>(0,n.Y)(x.y.Item,{selected:I===e.value,onClick:()=>b((0,eW.z)({theme:m,updates:{navStyle:e.value}})),onMouseEnter:()=>Y({navStyle:e.value}),children:e.label},e.value))})})]}),C&&!g.logo_url_wide&&(0,n.Y)(E.X,{title:_("Typography"),children:(0,n.Y)(eH,{defaultFontKey:O,label:_("Wordmark"),value:null==(l=m.font_options)?void 0:l.wordmark,onChange:e=>b({font_options:(0,el._)((0,r._)({},m.font_options),{wordmark:null!=e?e:void 0})}),onPreview:e=>e?y({presetType:"wordmark",font:e}):k()})}),(0,n.Y)(E.X,{title:_("Colors"),children:(0,n.Y)(eE.J,{colorType:"custom_header_bg",label:_("Background"),theme:m,value:null!=(u=w.backgroundColor)?u:null,onChange:e=>b((0,eW.z)({theme:m,updates:{backgroundColor:e}}))})})]})},eK=e=>{let{errors:t,pub:l,theme:o,onPubLogosChange:r,onReset:a,onSave:s,onThemeChange:d}=e,{iString:u}=(0,i.GO)();return(0,n.FD)(v.O.Wrapper,{children:[(0,n.Y)(v.O.Header,{title:u("Header"),onReset:a,onSave:s}),(0,n.FD)(v.O.ScrollArea,{children:[(0,n.Y)(eJ,{pub:l,theme:o,onPubLogosChange:r,onThemeChange:d}),(0,n.Y)(v.O.Footer,{errors:t,onReset:a,onSave:s})]})]})},eV=[{value:"list",label:"List"},{value:"grid",label:"Grid"},{value:"grid-groups",label:"Groups"}],ej=e=>{var t,l;let{showRecommendationsOnHomepage:o=!1,theme:r,onShowRecommendationsOnHomepageChange:d,onLayoutSelect:u,onThemeChange:c}=e,{iString:h}=(0,i.GO)(),{postTags:g,pub:m}=(0,a.e)(),{previewHomeBodyChange:v}=(0,s.v9)(),b=(null!=(l=r.body_post_groups)?l:[]).map(e=>({type:e.section_id?"section":"tag",sectionId:e.section_id,tagId:e.tag_id}));return(0,n.FD)(p.VP,{children:[(0,n.FD)(E.X,{scrollToBlockOnFocus:{type:"home-body"},children:[(0,n.Y)(R.u,{label:h("Layout"),children:(0,n.Y)(x.y,{label:(null==(t=eV.find(e=>e.value===r.home_posts))?void 0:t.label)||"List",children:eV.map(e=>(0,n.Y)(x.y.Item,{selected:r.home_posts===e.value,onClick:()=>u(e.value),onMouseEnter:()=>v(e.value),children:e.label},e.value))})}),"list"===r.home_posts&&(0,n.Y)(eb.e,{label:h("Hide images"),value:r.hide_images_from_list,onChange:e=>c({hide_images_from_list:e})}),"grid-groups"===r.home_posts&&(0,n.Y)(eg,{label:h("Groups"),postTags:g,sections:m.sections,value:b,onChange:e=>{c({body_post_groups:e.map((e,t)=>({publication_id:m.id,order:t+1,section_id:"section"===e.type?e.sectionId:null,tag_id:"tag"===e.type?e.tagId:null}))})}})]}),(0,n.Y)(E.X,{title:h("Sidebar"),children:(0,n.Y)(eb.e,{label:h("Show recommendations"),value:o,onChange:null!=d?d:()=>{}})})]})},e$=e=>{let{errors:t,showRecommendationsOnHomepage:l,theme:o,onShowRecommendationsOnHomepageChange:r,onReset:a,onSave:s,onThemeChange:d}=e,{iString:u}=(0,i.GO)();return(0,n.FD)(v.O.Wrapper,{children:[(0,n.Y)(v.O.Header,{title:u("Body"),onReset:a,onSave:s}),(0,n.FD)(v.O.ScrollArea,{children:[(0,n.Y)(ej,{showRecommendationsOnHomepage:l,theme:o,onLayoutSelect:e=>d({home_posts:e}),onShowRecommendationsOnHomepageChange:r,onThemeChange:d}),(0,n.Y)(v.O.Footer,{errors:t,onReset:a,onSave:s})]})]})};var eq=l(31887),eQ=l(68349),eZ=l(79531),e0=l(68410),e1=l(12387),e4=l(96025),e6=l(67459);let e2=e=>{let{colorTypes:t,hasError:l,label:o,onPreviewChange:r,presets:i,value:a,onChange:s}=e;return(0,n.Y)(R.u,{label:o,children:(0,n.Y)(e6.m,{color:a,colorTypes:t,hasError:l,presets:i,onPreviewChange:r,onSelect:s})})};var e7=l(32641),e8=l(78579),e9=l(89490);function e3(e){var t,l,{onValueChange:o,onValueCommit:i,className:a,value:s,defaultValue:d,flex:c,orientation:h="horizontal"}=e,g=(0,e7._)(e,["onValueChange","onValueCommit","className","value","defaultValue","flex","orientation"]);let m=null!=(l=null!=(t=null==s?void 0:s.length)?t:null==d?void 0:d.length)?l:1;return(0,n.Y)(e8.bL,(0,el._)((0,r._)({value:s,defaultValue:d,onValueChange:o,onValueCommit:i,orientation:h},g),{asChild:!0,children:(0,n.FD)(p.pT,{position:"relative",alignItems:"center",cursor:"pointer",flex:c,direction:"horizontal"===h?"row":"column",className:u()("root-WrfBT5",a),children:[(0,n.Y)(e5,{children:(0,n.Y)(te,{})}),Array.from({length:m}).map((e,t)=>(0,n.Y)(tt,{},t))]})}))}function e5(e){let{children:t}=e;return(0,n.Y)(e8.CC,{asChild:!0,children:(0,n.Y)(e9.az,{as:"span",position:"relative",flex:"grow",radius:"full",overflow:"hidden",className:"track-JENbBz",children:t})})}function te(){return(0,n.Y)(e8.Q6,{asChild:!0,children:(0,n.Y)(e9.az,{as:"span",position:"absolute",inset:0,animate:!0,className:"range-haBfbF"})})}function tt(){return(0,n.Y)(e8.zi,{asChild:!0,children:(0,n.Y)(e9.az,{radius:"full",shadow:"xs",sizing:"border-box",cursor:"grab",animate:!0,className:"thumb-CtVltx"})})}var tl=l(25112);let tn=e=>{let{label:t,value:l,min:o,max:r,onChange:i}=e;return(0,n.FD)(T.pT,{alignItems:"center",gap:4,justifyContent:"space-between",children:[(0,n.Y)(h.EY.B4,{fontWeight:"medium",children:t}),(0,n.Y)(T.I1,{style:{flexShrink:0},width:tl.u2,children:(0,n.Y)(e3,{max:r,min:o,value:[l],onValueChange:e=>{var t;return i(null!=(t=e[0])?t:0)}})})]})};var to=l(77228),tr=l(77681),ti=l(30960);function ta(e){let{homepageType:t,onChange:l}=e,o=function(){let{iString:e}=(0,i.GO)();return(0,Y.useMemo)(()=>[{value:"profile",label:e("Profile"),subtitle:e("All your content in a single feed"),leading:(0,n.Y)(tr.A,{size:16,stroke:"var(--color-fg-primary) !important"})},{value:"newspaper",label:e("Custom"),subtitle:e("Custom layout, branding, and navigation"),leading:(0,n.Y)(ti.A,{size:16,stroke:"var(--color-fg-primary) !important"})}],[])}(),r="profile"===t,a=o.find(e=>"profile"===e.value===r);return(0,n.Y)(U.eB,{label:null==a?void 0:a.label,leading:null==a?void 0:a.leading,children:o.map(e=>{let t="profile"===e.value?r:!r;return(0,n.Y)(U.Jm,{selected:t,onClick:()=>l(e.value),description:e.subtitle,leading:e.leading,children:e.label},e.value)})})}var ts=l(4016),td=l(86007);let tu=e=>{var t,l,d,u,c;let{hasAccentError:p,hasBackgroundError:h,postPreviewCropGravity:g,postPreviewRadius:m,pub:v,theme:_,onHomepageTypeChange:f,onPostPreviewCropGravityChange:y,onPostPreviewCropGravityHover:k,onPostPreviewRadiusChange:C,onPostPreviewRadiusHover:w,onThemeChange:I}=e,{iString:S}=(0,i.GO)(),{getConfigFor:D}=(0,o.mJ)(),F={none:S("None"),xs:S("Default"),sm:S("Small"),md:S("Medium"),lg:S("Large"),full:S("Absurd")},{clearPreview:A,previewFontChange:B}=(0,s.v9)(),{scrollToBlock:P}=(0,O.i)(),{simulatePostCount:W,setSimulatePostCount:N,hideImages:M,setHideImages:G}=(0,e4.W)(),{addDefaultContentBlock:L,contentBlocks:z,fetchedHomepageData:H,removeContentBlock:X}=(0,a.e)(),{breakpoint:U}=(0,e0.sM)(),J=!!D("use_advanced_fonts"),K=(0,b.be)({pub:v}),V=!!D("profile_portal_theme"),j="profile"===v.homepage_type,$=null!==W,q=null!=(u=null==H?void 0:H.newPosts)?u:[],Q=(0,eZ.z)({breakpoint:U,firstPostMissingImage:!(null==(t=q[0])?void 0:t.cover_image),heroVariant:_.home_hero,pub:v}),Z=q.length>Q,ee=(0,Y.useRef)("custom"!==_.home_posts?_.home_posts:"list"),et=(0,Y.useRef)(null),en=null!=(c=null==(l=_.font_options)?void 0:l.heading)?c:_.font_preset_heading,eo=_.web_bg_color||"#ffffff",er=(0,r._)({},eN.Tb,_.custom_header),ei=(0,r._)({},eN.F7,_.custom_footer),ea=(_.cover_bg_color||eo).toLowerCase()!==eo.toLowerCase(),es=!(0,ts.lu)({pub:v});return(0,n.FD)(T.I1,{children:[(0,n.Y)(E.X,{title:S("Theme"),children:(0,n.Y)(ta,{homepageType:v.homepage_type,onChange:f})}),(!j||V)&&(0,n.FD)(E.X,{title:S("Colors"),children:[(0,n.Y)(e2,{colorTypes:["web_bg_color",...ea?[]:["cover_bg_color"]],hasError:h,label:S("Background"),presets:"background",value:eo,onChange:e=>{I({web_bg_color:e}),ea||I({cover_bg_color:e})}}),(0,n.Y)(e2,{colorTypes:["background_pop"],hasError:p,label:S("Accent"),presets:"accent",value:_.background_pop||"#FF6719",onChange:e=>{I({background_pop:e})},onPreviewChange:()=>P({type:"header"})}),!j&&er.backgroundColor&&(0,n.Y)(e2,{colorTypes:["custom_header_bg"],label:S("Header"),presets:"background",value:er.backgroundColor,onChange:e=>{I((0,eW.z)({theme:_,updates:{backgroundColor:e}}))},onPreviewChange:()=>P({type:"header"})}),!j&&"default"!==ei.layout&&ei.backgroundColor&&(0,n.Y)(e2,{colorTypes:["custom_footer_bg"],label:S("Footer"),presets:"background",value:ei.backgroundColor,onChange:e=>{I((0,eW.T)({theme:_,updates:{backgroundColor:e}}))},onPreviewChange:()=>P({type:"footer"})}),!j&&"default"!==ei.layout&&ei.showPublicationName&&ei.publicationNameBackgroundColor&&(0,n.Y)(e2,{colorTypes:["custom_footer_secondary_bg"],label:S("Secondary footer"),presets:"background",value:ei.publicationNameBackgroundColor,onChange:e=>{I((0,eW.T)({theme:_,updates:{publicationNameBackgroundColor:e}}))},onPreviewChange:()=>P({type:"footer"})})]}),!j&&(0,n.FD)(n.FK,{children:[(0,n.FD)(E.X,{title:S("Typography"),children:[J&&!v.logo_url_wide&&(null==(d=_.font_options)?void 0:d.wordmark)&&(0,n.Y)(R.u,{label:S("Wordmark"),children:(0,n.Y)(ez.S,{fontKey:_.font_options.wordmark,onPreview:e=>e?B({presetType:"wordmark",font:e}):A(),onSelect:e=>{I({font_options:(0,el._)((0,r._)({},_.font_options),{wordmark:e})})}})}),(0,n.Y)(R.u,{label:S("Titles"),children:(0,n.Y)(to.B,{fontKey:en,useAdvancedFonts:J,onPreview:e=>e?B({presetType:"heading",font:e}):A(),onSelect:e=>{I({font_options:(0,el._)((0,r._)({},_.font_options),{heading:e})})}})})]}),(0,n.FD)(E.X,{title:S("Images"),children:[(0,n.Y)(R.u,{label:S("Cropping"),children:(0,n.FD)(x.y,{label:S("auto"===g?"Smart":"Center"),onClear:()=>k(null),children:[(0,n.Y)(x.y.Item,{description:S("Focus on the center of the image"),selected:"center"===g,onClick:()=>y("center"),onMouseEnter:()=>k("center"),children:S("Center")}),(0,n.Y)(x.y.Item,{description:S("Focus on the most interesting part of the image"),selected:"auto"===g,onClick:()=>y("auto"),onMouseEnter:()=>k("auto"),children:S("Smart")})]})}),es&&(0,n.Y)(R.u,{label:S("Rounding"),children:(0,n.Y)(x.y,{label:F[m],onClear:()=>w(null),children:td.JQ.map(e=>(0,n.Y)(x.y.Item,{selected:m===e,onClick:()=>C(e),onMouseEnter:()=>w(e),children:F[e]},e))})})]}),Z&&K.showCustomBodyLayoutToggle&&(0,n.FD)(E.X,{title:S("Layout"),children:[(0,n.Y)(eb.e,{label:S("Use custom body layout"),value:"custom"===_.home_posts,onChange:e=>{if(e){let e="custom"===_.home_posts?"list":_.home_posts;if(ee.current=e,I({home_posts:"custom"}),0===z.length){var t,l,n,o;let{contentBlockId:r}=L({hasLinks:(null!=(n=null==H||null==(t=H.homepageLinks)?void 0:t.length)?n:0)>0,hasRecommendations:(null!=(o=null==H||null==(l=H.recommendations)?void 0:l.length)?o:0)>0,previousLayout:e});et.current=r}}else I({home_posts:ee.current}),et.current&&(X(et.current),et.current=null)}}),"custom"===_.home_posts&&(0,n.Y)(e1.F,{Icon:eq.A,title:S("Click a block in the preview to edit it. Click between blocks to insert new ones.")})]})]}),(0,eQ.LQ)()&&"undefined"!=typeof window&&"1"===new URLSearchParams(window.location.search).get("dev_tools")&&(0,n.FD)(E.X,{title:"Developer Tools",children:[(0,n.Y)(eb.e,{label:"Simulate posts",value:$,onChange:e=>{N(e?5:null)}}),$&&(0,n.FD)(n.FK,{children:[(0,n.Y)(tn,{label:"Post count: ".concat(W),max:12,min:0,value:W,onChange:N}),(0,n.Y)(eb.e,{label:"Hide images",value:M,onChange:G})]})]})]})};var tc=l(97213);let tp=e=>{let{onFeedOfPostsChange:t}=e,{iString:l}=(0,i.GO)();return(0,n.FD)(E.X,{children:[(0,n.Y)(e1.F,{description:l('Your publication is using the legacy "Feed of posts" layout, which is no longer officially supported. You can continue using it, but customization options are limited.'),Icon:tc.A,title:l("Legacy layout")}),(0,n.Y)(c.$n,{priority:"secondary",size:"md",onClick:()=>t(!1),children:l("Switch to standard layout")})]})},th=e=>{let{errors:t,feedOfPostsSelected:l,hasAccentError:o,hasBackgroundError:r,postPreviewCropGravity:a,postPreviewRadius:s,pub:d,theme:u,onFeedOfPostsChange:c,onHomepageTypeChange:p,onPostPreviewCropGravityChange:h,onPostPreviewCropGravityHover:g,onPostPreviewRadiusChange:m,onPostPreviewRadiusHover:b,onReset:_,onSave:f,onThemeChange:Y}=e,{iString:y}=(0,i.GO)();return(0,n.FD)(v.O.Wrapper,{children:[(0,n.Y)(v.O.Header,{title:y("Home page"),onReset:_,onSave:f}),(0,n.FD)(v.O.ScrollArea,{children:[(0,n.FD)(T.I1,{children:[l&&(0,n.Y)(tp,{onFeedOfPostsChange:c}),!l&&(0,n.Y)(tu,{hasAccentError:o,hasBackgroundError:r,postPreviewCropGravity:a,postPreviewRadius:s,pub:d,theme:u,onHomepageTypeChange:p,onPostPreviewCropGravityChange:h,onPostPreviewCropGravityHover:g,onPostPreviewRadiusChange:m,onPostPreviewRadiusHover:b,onThemeChange:Y})]}),(0,n.Y)(v.O.Footer,{errors:t,onReset:_,onSave:f})]})]})};var tg=l(88974),tm=l(18387);let tv=e=>{var t;let{column:l,contentBlockId:o,insertAtIndex:r,onSidebarModuleInsert:d}=e,{iString:u}=(0,i.GO)(),{contentBlocks:c}=(0,a.e)(),{previewSidebarModuleInsert:p,clearPreview:h}=(0,s.v9)(),{selectBlock:b,closePicker:_}=(0,A.er)(),f=[];c.forEach(e=>{var t,l;f.push(...null!=(t=e.primary_sidebar_modules)?t:[]),f.push(...null!=(l=e.secondary_sidebar_modules)?l:[])});let Y=new Set(f),y=[{id:"subscribe",title:(t=u)("Subscribe"),description:t("Capture new readers with subscription options")},{id:"recommendations",title:t("Recommendations"),description:t("Suggest other publications to your readers")},{id:"links",title:t("Links"),description:t("Share important links with your audience")},{id:"contributors",title:t("Contributors"),description:t("Showcase the people behind your publication")},{id:"newsletters",title:t("Newsletters"),description:t("Feature sections from your publication")},{id:"podcasts",title:t("Podcasts"),description:t("Highlight your podcast episodes")},{id:"top-posts",title:t("Top posts"),description:t("Display your most popular content")}];return(0,n.FD)(v.O.Wrapper,{children:[(0,n.Y)(v.O.Header,{title:u("Add module")}),(0,n.Y)(v.O.ScrollArea,{children:(0,n.Y)(m,{onMouseLeave:h,children:y.map(e=>{let{id:t,title:i,description:a}=e,s=Y.has(t);return(0,n.Y)(g,{description:a,disabled:s,title:i,onClick:()=>{h(),d({contentBlockId:o,column:l,insertAtIndex:r,moduleId:t}),_(),b({type:"content-block",id:o})},onMouseEnter:()=>{p({contentBlockId:o,column:l,insertAtIndex:r,moduleId:t})}},t)})})})]})};var tb=l(2404),t_=l.n(tb),tf=l(21258);let tY=e=>{let{contentBlockId:t,moduleId:l,initialOrder:n}=e,o=(0,a.e)(),{initializeSidebarModuleEdit:r}=o;return(0,Y.useEffect)(()=>{r({contentBlockId:t,moduleId:l,initialOrder:n})},[t,r,l,n]),o},ty=e=>{let{align:t="full",description:l,label:o,value:r,onChange:i}=e;return"right"===t?(0,n.Y)(T.pT,{justifyContent:"end",children:(0,n.Y)(T.az,{style:{flexShrink:0},width:tl.u2,children:(0,n.Y)(W.Y,{label:o,value:r,onChange:i})})}):(0,n.Y)(W.Y,{details:l,label:o,value:r,onChange:i})};var tk=l(69474);let tC=e=>{let{contentBlockId:t,moduleId:l}=e,{iString:o}=(0,i.GO)(),{deleteSidebarModule:r}=(0,a.e)(),{selectBlock:s}=(0,A.er)(),d=(0,n.Y)(c.K0,{priority:"tertiary",size:"sm",children:(0,n.Y)(k.A,{size:20})});return(0,n.Y)(D.W1,{align:"start",trigger:d,children:(0,n.Y)(D.Dr,{leading:(0,n.Y)(C.A,{}),priority:"destructive",onClick:()=>{r({contentBlockId:t,moduleId:l}),s({type:"content-block",id:t})},children:o("Remove module")})})},tw=e=>{var t,l,o;let{contentBlockId:r,onReset:s,onSave:d}=e,{iString:u}=(0,i.GO)(),{contributors:c}=(0,a.e)(),p=(0,Y.useMemo)(()=>c.map(e=>e.id),[c]),{changeSidebarModule:h,contentBlocksById:g}=tY({contentBlockId:r,moduleId:"contributors",initialOrder:p}),m=g[r],b=null!=(o=null==m||null==(t=m.attrs.contributors)?void 0:t.excluded_user_ids)?o:[],_=null==m||null==(l=m.attrs.contributors)?void 0:l.contributor_order,f=!_||0===_.length||t_()(_,p);return(0,n.FD)(v.O.Wrapper,{children:[(0,n.Y)(tk.f,{renderActions:()=>(0,n.Y)(tC,{contentBlockId:r,moduleId:"contributors"}),title:u("Contributors")}),(0,n.FD)(v.O.ScrollArea,{children:[(0,n.FD)(E.X,{children:[(0,n.Y)(R.u,{label:u("Hidden"),stacked:!0,children:(0,n.Y)(tf.K,{options:c.map(e=>({value:e.id,label:e.name})),placeholder:u("Select contributors to hide..."),value:b,onChange:e=>{h({contentBlockId:r,moduleId:"contributors",updates:{excluded_user_ids:e}})}})}),(0,n.Y)(ty,{description:u("When enabled, contributors are automatically sorted by their most recent post. Drag to reorder in the preview to set a custom order."),label:u("Order by latest post"),value:f,onChange:e=>{e&&h({contentBlockId:r,moduleId:"contributors",updates:{contributor_order:[]}})}})]}),(0,n.Y)(v.O.Footer,{errors:null,onReset:s,onSave:d})]})]})};var tI=l(82776);let tS=e=>{var t,l;let{contentBlockId:o,onReset:r,onSave:s}=e,{iString:d}=(0,i.GO)(),{pub:u}=(0,a.e)(),c=(0,Y.useMemo)(()=>u.sections.filter(e=>(0,tI.sectionIsSpecificallyMarkedAsNewsletter)({section:e,pub:u})||!e.is_podcast),[u]),{changeSidebarModule:p,contentBlocksById:h}=tY({contentBlockId:o,moduleId:"newsletters",initialOrder:(0,Y.useMemo)(()=>c.map(e=>e.id),[c])}),g=h[o],m=null!=(l=null==g||null==(t=g.attrs.newsletters)?void 0:t.excluded_section_ids)?l:[];return(0,n.FD)(v.O.Wrapper,{children:[(0,n.Y)(tk.f,{renderActions:()=>(0,n.Y)(tC,{contentBlockId:o,moduleId:"newsletters"}),title:d("Newsletters")}),(0,n.FD)(v.O.ScrollArea,{children:[(0,n.Y)(E.X,{children:(0,n.Y)(R.u,{label:d("Hidden"),stacked:!0,children:(0,n.Y)(tf.K,{options:c.map(e=>({value:e.id,label:e.name})),placeholder:d("Select newsletters to hide..."),value:m,onChange:e=>{p({contentBlockId:o,moduleId:"newsletters",updates:{excluded_section_ids:e}})}})})}),(0,n.Y)(v.O.Footer,{errors:null,onReset:r,onSave:s})]})]})},tD=e=>{var t,l;let{contentBlockId:o,onReset:r,onSave:s}=e,{iString:d}=(0,i.GO)(),{pub:u}=(0,a.e)(),{allPodcasts:c,initialOrder:p}=(0,Y.useMemo)(()=>{let e=[];return u.podcast_enabled&&e.push({id:-1,name:u.podcast_title||u.name,description:u.podcast_description||"",logo_url:u.podcast_art_url,isPubPodcast:!0}),e.push(...u.sections.filter(e=>e.is_podcast).map(e=>({id:e.id,name:e.name,description:e.description||"",logo_url:e.logo_url,isPubPodcast:!1}))),{allPodcasts:e,initialOrder:e.map(e=>e.id)}},[u]),{changeSidebarModule:h,contentBlocksById:g}=tY({contentBlockId:o,moduleId:"podcasts",initialOrder:p}),m=g[o],b=null!=(l=null==m||null==(t=m.attrs.podcasts)?void 0:t.excluded_section_ids)?l:[];return(0,n.FD)(v.O.Wrapper,{children:[(0,n.Y)(tk.f,{renderActions:()=>(0,n.Y)(tC,{contentBlockId:o,moduleId:"podcasts"}),title:d("Podcasts")}),(0,n.FD)(v.O.ScrollArea,{children:[(0,n.Y)(E.X,{children:(0,n.Y)(R.u,{label:d("Hidden"),stacked:!0,children:(0,n.Y)(tf.K,{options:c.map(e=>({value:e.id,label:e.name})),placeholder:d("Select podcasts to hide..."),value:b,onChange:e=>{h({contentBlockId:o,moduleId:"podcasts",updates:{excluded_section_ids:e}})}})})}),(0,n.Y)(v.O.Footer,{errors:null,onReset:r,onSave:s})]})]})};var tF=l(33167),tO=l(36372);let tA=e=>{let{href:t,children:l,onRefresh:o,refreshMessage:r}=e,{popToast:i}=(0,tO.d)(),a=(0,Y.useRef)(!1),s=(0,Y.useCallback)(async()=>{"visible"===document.visibilityState&&a.current&&(a.current=!1,o&&(await o(),r&&i(()=>(0,n.Y)(tO.y,{text:r}))))},[o,r,i]);(0,Y.useEffect)(()=>{if(o)return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[o,s]);let d=(0,Y.useCallback)(()=>{o&&(a.current=!0)},[o]);return(0,n.FD)("a",{className:u()("pencraft",(0,c.C3)({priority:"secondary",size:"md"})),href:t,rel:"noopener noreferrer",style:{width:"100%"},target:"_blank",onClick:d,children:[l,(0,n.Y)(tF.A,{size:20})]})},tB={links:"Links updated",recommendations:"Recommendations updated",subscribe:"Publication updated"},tT=e=>{let{contentBlockId:t,moduleId:l,onReset:o,settingsCta:r,settingsUrl:s,title:d}=e,{iString:u}=(0,i.GO)(),{refetchHomepageData:c,refetchPublication:p}=(0,a.e)();return(0,n.FD)(v.O.Wrapper,{children:[(0,n.Y)(tk.f,{renderActions:()=>(0,n.Y)(tC,{contentBlockId:t,moduleId:l}),title:d}),(0,n.FD)(v.O.ScrollArea,{children:[(0,n.Y)(E.X,{children:(0,n.Y)(tA,{href:s,refreshMessage:u(tB[l]),onRefresh:"subscribe"===l?p:c,children:r})}),(0,n.Y)(v.O.Footer,{doneOnly:!0,errors:null,onReset:null!=o?o:null})]})]})},tP=[4,5,6,7],tx=e=>{var t,l;let{contentBlockId:o,onReset:r,onSave:a}=e,{iString:d}=(0,i.GO)(),{changeSidebarModule:u,contentBlocksById:c}=tY({contentBlockId:o,moduleId:"top-posts"}),p=c[o],{previewContentBlockChange:h}=(0,s.v9)(),g=null!=(l=null==p||null==(t=p.attrs.top_posts)?void 0:t.num_posts)?l:5;return(0,n.FD)(v.O.Wrapper,{children:[(0,n.Y)(tk.f,{renderActions:()=>(0,n.Y)(tC,{contentBlockId:o,moduleId:"top-posts"}),title:d("Top posts")}),(0,n.FD)(v.O.ScrollArea,{children:[(0,n.Y)(E.X,{children:(0,n.Y)(R.u,{label:d("Posts"),children:(0,n.Y)(x.y,{label:String(g),children:tP.map(e=>(0,n.Y)(x.y.Item,{selected:g===e,onClick:()=>{u({contentBlockId:o,moduleId:"top-posts",updates:{num_posts:e}})},onMouseEnter:()=>{h({contentBlockId:o,updates:{attrs:{top_posts:{num_posts:e}}}})},children:e},e))})})}),(0,n.Y)(v.O.Footer,{errors:null,onReset:r,onSave:a})]})]})};var tR=l(39318);let tE=e=>{let{contentBlockId:t,moduleId:l,onReset:o,onSave:r}=e,{iString:s}=(0,i.GO)(),{contentBlocksById:d,pub:u}=(0,a.e)();if(!d[t])return null;switch(l){case"links":return(0,n.Y)(tT,{contentBlockId:t,moduleId:l,settingsCta:s("Edit links"),settingsUrl:(0,tR.P5z)(u),title:s("Links"),onReset:o});case"recommendations":return(0,n.Y)(tT,{contentBlockId:t,moduleId:l,settingsCta:s("Edit recommendations"),settingsUrl:(0,tR.OFB)(u),title:s("Recommendations"),onReset:o});case"subscribe":return(0,n.Y)(tT,{contentBlockId:t,moduleId:l,settingsCta:s("Edit publication"),settingsUrl:(0,tR.muC)(u,{section:"basics-settings"}),title:s("Subscribe"),onReset:o});case"contributors":return(0,n.Y)(tw,{contentBlockId:t,onReset:o,onSave:r});case"newsletters":return(0,n.Y)(tS,{contentBlockId:t,onReset:o,onSave:r});case"podcasts":return(0,n.Y)(tD,{contentBlockId:t,onReset:o,onSave:r});case"top-posts":return(0,n.Y)(tx,{contentBlockId:t,onReset:o,onSave:r});default:return null}},tW=e=>{var t,l;let{colorErrors:r,contentBlockErrors:i,feedOfPostsSelected:a,picker:s,postPreviewCropGravity:d,postPreviewRadius:u,pub:c,showRecommendationsOnHomepage:p,selection:h,theme:g,onContentBlockInsert:m,onFeedOfPostsChange:v,onHomepageTypeChange:b,onPostPinAdd:f,onPostPinRemove:Y,onPostPreviewCropGravityChange:y,onPostPreviewCropGravityHover:k,onPostPreviewRadiusChange:C,onPostPreviewRadiusHover:w,onShowRecommendationsOnHomepageChange:I,onPreviewUserRoleChange:S,pinnedPosts:D,onPubLogosChange:F,onReset:O,onResetContentBlocks:A,onSave:B,onSidebarModuleInsert:T,onThemeChange:P}=e,{getConfigFor:x}=(0,o.mJ)(),R=!!x("enable_content_block_pinning"),E=i.global||r.errors?[...null!=(t=i.global)?t:[],...null!=(l=r.errors)?l:[]]:null;if(s){if("block-picker"===s.type)return(0,n.Y)(_,{insertAfterIndex:s.insertAfterIndex,onBlockInsert:m});if("module-picker"===s.type)return(0,n.Y)(tv,{column:s.column,contentBlockId:s.parentBlockId,insertAtIndex:s.insertAtIndex,onSidebarModuleInsert:T})}return h?h.item?function(e,t,l,o,r,i,a,s){let{item:d}=e;if((null==d?void 0:d.type)==="sidebar-module"&&"content-block"===e.block.type)return(0,n.Y)(tE,{contentBlockId:e.block.id,moduleId:d.moduleId,onReset:t,onSave:l});if((null==d?void 0:d.type)==="post-pin"&&s){let{postId:t}=d,l=t?a[t]:void 0,s="content-block"===e.block.type?e.block.id:"";return(0,n.Y)(tm.j,{pinnedPost:l,pub:o,onPinPost:t=>r(t,d.slotIndex,e.block),onRemovePin:t?()=>i({contentBlockId:s,postId:t}):void 0})}return null}(h,A,B,c,f,Y,D,R):function(e,t){let{combinedErrors:l,pub:o,showRecommendationsOnHomepage:r,theme:i,onPreviewUserRoleChange:a,onPubLogosChange:s,onReset:d,onResetContentBlocks:u,onSave:c,onShowRecommendationsOnHomepageChange:p,onThemeChange:h}=t;switch(e.block.type){case"header":return(0,n.Y)(eK,{errors:l,pub:o,theme:i,onPubLogosChange:s,onReset:d,onSave:c,onThemeChange:h});case"home-hero":return(0,n.Y)(tg.R,{errors:l,pub:o,theme:i,onReset:d,onSave:c,onThemeChange:h});case"home-body":return(0,n.Y)(e$,{errors:l,showRecommendationsOnHomepage:r,theme:i,onReset:d,onSave:c,onShowRecommendationsOnHomepageChange:p,onThemeChange:h});case"content-block":return(0,n.Y)(eO,{contentBlockId:e.block.id,onReset:u,onSave:c,onUserRoleChange:a});case"footer":return(0,n.Y)(eG,{errors:l,pub:o,theme:i,onReset:d,onSave:c,onThemeChange:h});default:return null}}(h,{combinedErrors:E,pub:c,showRecommendationsOnHomepage:p,theme:g,onPreviewUserRoleChange:S,onPubLogosChange:F,onReset:O,onResetContentBlocks:A,onSave:B,onShowRecommendationsOnHomepageChange:I,onThemeChange:P}):(0,n.Y)(th,{errors:E,feedOfPostsSelected:a,hasAccentError:r.hasAccentError,hasBackgroundError:r.hasBackgroundError,postPreviewCropGravity:d,postPreviewRadius:u,pub:c,theme:g,onFeedOfPostsChange:v,onHomepageTypeChange:b,onPostPreviewCropGravityChange:y,onPostPreviewCropGravityHover:k,onPostPreviewRadiusChange:C,onPostPreviewRadiusHover:w,onReset:O,onSave:B,onThemeChange:P})}},72535:function(e,t,l){l.d(t,{T:()=>i,z:()=>r});var n=l(69277),o=l(19945);let r=e=>{let{theme:t,updates:l}=e;return{custom_header:(0,n._)({},o.Tb,t.custom_header,l)}},i=e=>{let{theme:t,updates:l}=e;return{custom_footer:(0,n._)({},o.F7,t.custom_footer,l)}}},9567:function(e,t,l){l.d(t,{x:()=>O,z:()=>A});var n=l(69277),o=l(70408),r=l(32641),i=l(88055),a=l.n(i),s=l(58156),d=l.n(s),u=l(2404),c=l.n(u),p=l(38970),h=l.n(p),g=l(6924),m=l.n(g),v=l(90179),b=l.n(v),_=l(44383),f=l.n(_),Y=l(17402),y=l(15734),k=l.n(y),C=l(68414),w=l(86898),I=l(37764);function S(e,t){var l,n,o,r;switch(t){case"contributors":return null!=(l=null==e?void 0:e.attrs.contributors)?l:{};case"newsletters":return null!=(n=null==e?void 0:e.attrs.newsletters)?n:{};case"podcasts":return null!=(o=null==e?void 0:e.attrs.podcasts)?o:{};case"top-posts":return null!=(r=null==e?void 0:e.attrs.top_posts)?r:{}}}function D(e,t){switch(e){case"contributors":return{contributors:t};case"newsletters":return{newsletters:t};case"podcasts":return{podcasts:t};case"top-posts":return{top_posts:t}}}let F=["content_block_id","order","tag_id","section_id","title_override"],O=e=>{let{contributors:t,contributorIdsWithPosts:l,pub:i,postTags:s,onAddBlockCallback:u,onContentBlockDelete:p,onContentBlockReorder:g,onSidebarModuleDelete:v,onSidebarModuleInsert:_,initialContentBlocks:y}=e,O=(0,Y.useRef)(!1),[A,B]=(0,Y.useState)(null!=y?y:[]),[T,P]=(0,Y.useState)(null!=y?y:[]),[x,R]=(0,Y.useState)({global:null,contentBlocks:{}}),[E,W]=(0,Y.useState)(null),N=(0,Y.useMemo)(()=>{if(!E)return T;let{contentBlockId:e,moduleId:t,attrs:l}=E;return T.map(r=>r.id!==e?r:(0,o._)((0,n._)({},r),{attrs:(0,n._)({},r.attrs,D(t,l))}))},[T,E]),M=N.length!==A.length||N.some((e,t)=>!A[t]||!((e,t)=>{let{postSources:l}=e,n=(0,r._)(e,["postSources"]),{postSources:o}=t,i=(0,r._)(t,["postSources"]);return c()(n,i)&&(!l&&!o||!!l&&!!o&&l.length===o.length&&l.every((e,t)=>{let l=o[t];return c()(f()(e,F),f()(l,F))}))})(e,A[t])),G=(0,Y.useMemo)(()=>{if(!E)return!1;let{contentBlockId:e,moduleId:t,attrs:l,initialOrder:n}=E,o=S(A.find(t=>t.id===e),t);if(n){let e="contributors"===t?"contributor_order":"section_order";if(!d()(o,e)&&c()(d()(l,e),n))return!c()(b()(l,e),b()(o,e))}return!c()(l,o)},[E,A]);(0,Y.useEffect)(()=>{if(void 0!==y&&y.length>=0){O.current||(B(y),P(y),O.current=!0);return}O.current||(async()=>{try{let{body:e}=await k().get("/api/v1/content_block");B(e),P(e),O.current=!0}catch(e){console.error(e)}})()},[y]);let L=(0,Y.useCallback)(()=>{R({global:null,contentBlocks:{}})},[]);(0,Y.useEffect)(()=>{L()},[T,L]);let z=(0,Y.useCallback)(e=>{let{layoutID:t}=e,l=(0,C.v4)();return P(e=>[...e,{attrs:{},block_type:t,id:l,order:e.length,post_source:"subscribe"===t?"none":"latest",post_tag_id:null,primary_sidebar_modules:[],publication_id:i.id,secondary_sidebar_modules:[],section_id:null}]),u&&setTimeout(()=>{u(l)},200),{contentBlockId:l}},[u,i.id]),H=(0,Y.useCallback)(e=>{var t;let l=(0,C.v4)(),n=["subscribe"];(null!=(t=null==e?void 0:e.showRecommendationsOnHomepage)?t:i.show_recs_on_homepage)&&(null==e?void 0:e.hasRecommendations)&&n.push("recommendations"),(null==e?void 0:e.hasLinks)&&n.push("links");let o=(null==e?void 0:e.previousLayout)==="grid"||(null==e?void 0:e.previousLayout)==="grid-groups";return P(e=>[...e,{attrs:{},block_type:o?"grid":"list",id:l,num_rows:3,order:e.length,post_source:"latest",post_tag_id:null,primary_sidebar_modules:n,publication_id:i.id,secondary_sidebar_modules:[],section_id:null}]),u&&setTimeout(()=>{u(l)},200),{contentBlockId:l}},[u,i.id,i.show_recs_on_homepage]),X=(0,Y.useCallback)(e=>{let{blockType:t,insertAfterIndex:l}=e,r=(0,C.v4)(),a={attrs:{},block_type:t,id:r,order:l+1,post_source:"subscribe"===t?"none":"latest",post_tag_id:null,primary_sidebar_modules:[],publication_id:i.id,secondary_sidebar_modules:[],section_id:null};return P(e=>{let t=[...e];return t.splice(l+1,0,a),t.map((e,t)=>(0,o._)((0,n._)({},e),{order:t}))}),u&&setTimeout(()=>{u(r)},200),{contentBlockId:r}},[u,i.id]),U=(0,Y.useCallback)(e=>{P(t=>t.filter(t=>t.id!==e))},[]),J=(0,Y.useCallback)((e,t)=>{P(l=>{let r=[...l],[i]=r.splice(e,1);return i?(r.splice(t,0,i),r.map((e,t)=>(0,o._)((0,n._)({},e),{order:t}))):l}),null==g||g()},[g]),K=(0,Y.useCallback)(async e=>{let t=T.filter(t=>t.id!==e);await k().put("/api/v1/content_block").send(t),P(t),B(t),null==p||p(e)},[T,p]),V=(0,Y.useCallback)(e=>{let{contentBlockId:t,updates:l}=e,n=(e,t)=>Array.isArray(t)?t:void 0;P(e=>e.map(e=>e.id===t?m()(a()(e),l,n):e))},[]),j=(0,Y.useCallback)(e=>{var t,l;let{contentBlockId:n,column:o,insertAtIndex:r,moduleId:i}=e,a=T.find(e=>e.id===n);if(!a)return;let s=[...null!=(t=a.secondary_sidebar_modules)?t:[]],d=[...null!=(l=a.primary_sidebar_modules)?l:[]];"left"===o?void 0!==r?s.splice(r,0,i):s.push(i):void 0!==r?d.splice(r,0,i):d.push(i),V({contentBlockId:n,updates:{secondary_sidebar_modules:s,primary_sidebar_modules:d}}),null==_||_(n)},[T,V,_]),$=(0,Y.useCallback)(e=>{var t,l;let{contentBlockId:n,moduleId:o}=e,r=T.find(e=>e.id===n);r&&(V({contentBlockId:n,updates:{secondary_sidebar_modules:(null!=(t=r.secondary_sidebar_modules)?t:[]).filter(e=>e!==o),primary_sidebar_modules:(null!=(l=r.primary_sidebar_modules)?l:[]).filter(e=>e!==o)}}),W(null),null==v||v(n))},[T,V,v]),q=(0,Y.useCallback)(async()=>{if(!M)return null;let e=a()(A);return await k().put("/api/v1/content_block").send(N),P(N),B(N),W(null),{previousContentBlocks:e}},[N,M,A]),Q=(0,Y.useCallback)(()=>{P(A),W(null)},[A]),Z=(0,Y.useCallback)(e=>{let{maxContentBlocks:t}=e,{hasError:l,errorObject:n}=(0,w.Qc)(T,{maxContentBlocks:t,sections:i.sections,postTags:null!=s?s:void 0});return R(n),{isValid:!l}},[T,s,i.sections]),ee=(0,Y.useCallback)(e=>{let{contentBlockId:t,moduleId:l,initialOrder:r}=e;if((null==E?void 0:E.contentBlockId)===t&&(null==E?void 0:E.moduleId)===l||!I.HG.includes(l))return;let i=T;E&&P(i=T.map(e=>e.id!==E.contentBlockId?e:(0,o._)((0,n._)({},e),{attrs:(0,n._)({},e.attrs,D(E.moduleId,E.attrs))})));let a=S(i.find(e=>e.id===t),l);if(r){if("contributors"===l){if(!(null==a?void 0:a.contributor_order))return void W({contentBlockId:t,moduleId:l,attrs:(0,o._)((0,n._)({},a),{contributor_order:r}),initialOrder:r})}else if(("newsletters"===l||"podcasts"===l)&&!(null==a?void 0:a.section_order))return void W({contentBlockId:t,moduleId:l,attrs:(0,o._)((0,n._)({},a),{section_order:r}),initialOrder:r})}W({contentBlockId:t,moduleId:l,attrs:a})},[T,E]),et=(0,Y.useCallback)(e=>{let{contentBlockId:t,moduleId:l,updates:r}=e;E&&E.contentBlockId===t&&E.moduleId===l&&W(e=>{var t,l;if(!e)return null;let i=(0,n._)({},r);if("_add_excluded_user_id"in r&&void 0!==r._add_excluded_user_id){let l=e.attrs,a=null!=(t=null==l?void 0:l.excluded_user_ids)?t:[];i=(0,o._)((0,n._)({},i),{excluded_user_ids:[...a,r._add_excluded_user_id]}),delete i._add_excluded_user_id}if("_add_excluded_section_id"in r&&void 0!==r._add_excluded_section_id){let t=e.attrs,a=null!=(l=null==t?void 0:t.excluded_section_ids)?l:[];i=(0,o._)((0,n._)({},i),{excluded_section_ids:[...a,r._add_excluded_section_id]}),delete i._add_excluded_section_id}return(0,o._)((0,n._)({},e),{attrs:(0,n._)({},e.attrs,i)})})},[E]),el=(0,Y.useCallback)(()=>{E&&W(null)},[E]),en=(0,Y.useCallback)(async e=>{e&&(await k().put("/api/v1/content_block").send(e),P(e),B(e),W(null))},[]),eo=(0,Y.useMemo)(()=>h()(i.sections,"id"),[i.sections]),er=(0,Y.useMemo)(()=>h()(s,"id"),[s]),ei=(0,Y.useMemo)(()=>N.map(e=>{if("section"===e.post_source&&e.section_id)return(0,o._)((0,n._)({},e),{section:eo[e.section_id]});if("tag"===e.post_source&&e.post_tag_id)return(0,o._)((0,n._)({},e),{postTag:er[e.post_tag_id]});if("multiple"===e.post_source&&e.postSources){let t=e.postSources.map(e=>{var t,l;return(0,o._)((0,n._)({},e),{section:e.section_id&&null!=(t=eo[e.section_id])?t:null,post_tag:e.tag_id&&null!=(l=er[e.tag_id])?l:null})});return(0,o._)((0,n._)({},e),{postSources:t})}return e}),[N,er,eo]),ea=(0,Y.useMemo)(()=>h()(ei,"id"),[ei]),es=l?t.filter(e=>l.has(e.id)):t;return{activeSidebarModuleEdit:E?{contentBlockId:E.contentBlockId,moduleId:E.moduleId}:null,contentBlockErrors:x,contributors:es,postTags:s,pub:i,addContentBlock:z,addDefaultContentBlock:H,changeContentBlock:V,changeContentBlocks:P,changeContentBlockErrors:R,clearContentBlockErrors:L,contentBlocks:ei,contentBlocksById:ea,deleteContentBlock:K,deleteSidebarModule:$,hasContentBlockChanges:M,hasSidebarModuleChanges:G,changeSidebarModule:et,insertContentBlock:X,insertSidebarModule:j,initializeSidebarModuleEdit:ee,removeContentBlock:U,reorderContentBlocks:J,resetContentBlocks:Q,resetSidebarModuleSettings:el,restoreContentBlocks:en,saveContentBlocks:q,validateForSave:Z}},A=e=>{let{shouldFetch:t}=e,[l,n]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{t&&(l||(async()=>{try{let e=await k().get("/api/v1/publication/post-tag");n(e.body)}catch(e){console.error(e)}})())},[l,t]),{postTags:l}}},23781:function(e,t,l){l.d(t,{S:()=>b});var n=l(4006),o=l(32485),r=l.n(o),i=l(45773),a=l(17402),s=l(84605),d=l(89490),u=l(35369),c=l(76977),p=l(61084),h=l(63136),g=l(8312);let m="weightButton-v_oFmf",v=g.a_.flatMap(e=>e.families),b=e=>{let{fontKey:t,onSelect:l,onPreview:o}=e,{iString:r}=(0,s.GO)(),i=(0,a.useRef)(!1),{family:d,weight:u}=function(e){let{fontKey:t}=e;if(!t)return{};let l=v.find(e=>e.weights.some(l=>(0,g.s1)({family:e,weight:l})===t));if(!l)return{};let n=l.weights.find(e=>(0,g.s1)({family:l,weight:e})===t);return{family:l,weight:n}}({fontKey:t}),c=d&&u?f({family:d,weight:u}):void 0,m=null==d?void 0:d.name,b=e=>{i.current=!0,l(e),setTimeout(()=>{i.current=!1},500)},Y=e=>{i.current||null==o||o(e)};return(0,n.Y)(p.eB,{label:m?(0,n.Y)(h.EY,{style:c,children:m}):void 0,placeholder:r("Select a font"),onClose:()=>Y(null),children:g.a_.map(e=>(0,n.Y)(_,{category:e,fontKey:t,selectedFamily:d,onSelect:b,onPreview:Y},e.label))})};function _(e){let{category:t,fontKey:l,selectedFamily:o,onSelect:a,onPreview:s}=e;return(0,n.FD)(n.FK,{children:[(0,n.Y)("div",{className:"categoryLabel-nyHzoj",children:(0,n.Y)(h.EY.B4,{color:"secondary",children:t.label})}),t.families.map(e=>{let t=e.name,v=e===o,b=e.weights.length>1,_=e.name;return(0,n.Y)(p.Jm,{onClick:t=>{t.target.closest(".".concat(m))||a((0,g.s1)({family:e,weight:e.defaultWeight}))},onMouseEnter:()=>{null==s||s((0,g.s1)({family:e,weight:e.defaultWeight}))},children:(0,n.FD)(c.Ye,{gap:8,alignItems:"center",justifyContent:"space-between",style:{width:240},children:[(0,n.FD)(c.Ye,{gap:8,alignItems:"center",flex:"grow",children:[(0,n.Y)(d.az,{width:16,display:"flex",alignItems:"center",justifyContent:"center",children:v&&(0,n.Y)(i.A,{size:16})}),(0,n.Y)(h.EY.B3,{style:f({family:e,weight:e.defaultWeight}),children:t})]}),b&&(0,n.Y)(c.Ye,{gap:2,className:"weightSelector-Aixm0T",onMouseLeave:()=>{let t=v?l:(0,g.s1)({family:e,weight:e.defaultWeight});null==s||s(null!=t?t:null)},children:e.weights.map(t=>{let o=(0,g.s1)({family:e,weight:t}),i=v?o===l:t===e.defaultWeight;return(0,n.Y)("span",{onMouseEnter:()=>null==s?void 0:s(o),children:(0,n.Y)(u.Nm,{className:r()(m,i&&"selected-UIxJlm"),style:f({family:e,weight:t}),onClick:()=>{a(o)},children:"Aa"})},t)})})]})},_)})]})}function f(e){let{family:t,weight:l}=e;return(0,g.VW)(t)?{fontFamily:g.tr,fontWeight:l}:{fontFamily:[t.name.includes(" ")?"'".concat(t.name,"'"):t.name,t.fallback].join(","),fontWeight:l}}},77228:function(e,t,l){l.d(t,{B:()=>p});var n=l(4006),o=l(84605),r=l(76977),i=l(61084),a=l(63136),s=l(23781),d=l(8312);let u={lora_600:"fancy_serif",roboto_mono_700:"mono",roboto_slab_700:"slab"},c=new Set([...d.tt.map(e=>e.key),...Object.keys(d.BE.heading),...Object.values(d.BE.heading)]),p=e=>{let{fontKey:t,onSelect:l,onPreview:o,useAdvancedFonts:r}=e;return r?(0,n.Y)(s.S,{fontKey:t,onSelect:l,onPreview:o}):(0,n.Y)(h,{fontKey:t,onSelect:l,onPreview:o})};function h(e){var t;let{fontKey:l,onSelect:s,onPreview:p}=e,{iString:h}=(0,o.GO)(),g=l&&!(!l||c.has(l)),m=function(e){if(e)return d.tt.some(t=>t.key===e)?e:u[e]}(l),v=d.tt.find(e=>e.key===m),b=null!=(t=(0,d.OK)(l))?t:void 0,_=g?l:null==v?void 0:v.label;return(0,n.FD)(r.I1,{gap:4,children:[(0,n.Y)(i.eB,{label:_?(0,n.Y)(a.EY,{style:b,children:_}):void 0,placeholder:h("Select a font"),onClose:()=>null==p?void 0:p(null),children:d.tt.map(e=>{var t;let l=null!=(t=(0,d.OK)(e.key))?t:void 0,o=e.key===m;return(0,n.Y)(i.Jm,{selected:o,onClick:()=>s(e.key),onMouseEnter:()=>null==p?void 0:p(e.key),children:(0,n.Y)(a.EY.B3,{style:l,children:e.label})},e.key)})}),g&&(0,n.Y)(a.EY.B4,{color:"secondary",children:h("This font is no longer available. If you switch, it can't be reselected.")})]})}}}]);