1import{j as n,d as r,a as T,t as M,r as R,g as $,ac as D,ad as N,ae as w,af as U,ag as W,q as H}from"./index-D6EGPuBX.js";import{a as q}from"./admin_layout_base-OFjLav4n.js";import{_ as V,T as G,s as J}from"./form-Abg_wvLY.js";import{M as K,u as C,m as Q,a as Y,b as X,T as Z}from"./pagebuilder_section-BgMWFyoH.js";import{c as v}from"./index-D6eu1Y6_.js";import{O as ee,k as te}from"./kebabCase-D4fxDeAS.js";import{c as ie}from"./capitalize-CBVuOp2I.js";import{i as _}from"./isEmpty-V_e8evrK.js";import{u as ae,g as oe}from"./gql-pDldDZKs.js";import{p as ne}from"./path_from_slugs-BkrKpry9.js";import{s as re}from"./safely_parse_json-6PRpHd_K.js";import{u as se}from"./useRailsContext-BSdAZvnZ.js";import"./inspect-D9zWrUpL.js";import"./Helmet-CGPsIqcc.js";import"./index-CzKlQJMC.js";import"./ApolloContext-C4RA8h06.js";function P(e,i,t){const{onChange:a,storeKeys:o}=e;a({type:"update",storeKeys:o.pop(),scopes:["internal"],updater:({internal:s=K()})=>({internal:s.set(i,t)})})}function le(e,i){const{storeKeys:t}=e,{store:a}=C();return a==null?void 0:a.getInternals().getIn(t.pop().push(i))}const pe={animate:{height:"auto",opacity:1,overflow:"hidden",y:0,transition:{height:{duration:.4},y:{duration:.25},opacity:{duration:.25}}},exit:{overflow:"hidden",boxSizing:"content-box",height:0,opacity:0,y:-50,transition:{height:{duration:.4},opacity:{duration:.25}}},initial:{height:0,opacity:0,y:-50,overflow:"hidden"}};function ce({storeKeys:e,onChange:i,schema:t,parentSchema:a,...o}){var d,g;const s=((g=(d=a.getIn(["properties"]))==null?void 0:d.keySeq())==null?void 0:g.get(0))===e.last(),l=le({storeKeys:e},"openKey"),p=l===void 0?s:l===e.last(),c=()=>{p?P({storeKeys:e,onChange:i},"openKey",null):P({storeKeys:e,onChange:i},"openKey",e.last())};return n.jsxs("div",{children:[n.jsx(r.Pane,{borderBottom:!0,css:{cursor:"pointer",position:"sticky",top:"$$adminNavHeight",scrollMarginTop:"$$adminNavHeight","&:first-child":{borderTopLeftRadius:"$2",borderTopRightRadius:"$2"},"&:last-of-type":{borderBottomLeftRadius:"$2",borderBottomRightRadius:"$2",borderColor:"transparent"},marginLeft:2,backgroundColor:"hsl($hsl_background / 0.75)",backdropFilter:"blur(10px) saturate(180%)",zIndex:"$focused"},children:n.jsxs(r.HStack,{align:"center",css:{cursor:"pointer",userSelect:"none",padding:"$6 $5"},onClick:c,children:[n.jsxs(r.VStack,{children:[n.jsx(r.Heading,{children:t.get("title",X(e.last()))}),t.has("description")&&n.jsx(r.Text,{size:"caption2",children:t.get("description","")})]}),n.jsx(r.Button,{appearance:"outline",round:!0,color:"tertiary",size:"small",icon:p?r.CloseIcon:r.ChevronDownIcon,css:{marginLeft:"auto",flexShrink:0},onPress:c})]})}),n.jsx(v.AnimatePresence,{initial:!1,children:p&&n.jsxs(r.Pane,{as:v.motion.div,css:{padding:"0 $5"},variants:pe,initial:"initial",animate:"animate",exit:"exit",borderBottom:!0,children:[n.jsx(r.Spacer,{size:"$4"}),n.jsx(ee,{schema:t,storeKeys:e,...o,noGrid:!1}),n.jsx(r.Spacer,{size:"$4"})]})})]})}const de=Q(Y(ce));function ge({storeKeys:e,onChange:i,schema:t,errors:a,valid:o,required:s,value:l,t:p}){var S;const{store:c}=C(),d=c.values.getIn(["page","title"]),g=T(),h=Object.keys(g).filter(u=>u.startsWith("slug")&&u!=="slug").map(u=>g[u]).join("/"),{host:f}=M(),z=`${f}/${h}`,k=(S=Object.keys(a==null?void 0:a.errorsToJS()))==null?void 0:S[0],B=t.getIn(["view","size"],"regular");return n.jsxs(r.InputGroup,{description:p(e.last(),{relative:"description",fallback:!1},t),helpText:p(e.last(),{relative:"helpText",fallback:!1},t),errorMessage:k?n.jsx(Z,{text:k,schema:t}):null,size:t.getIn(["view","size"],"regular"),label:p(e.last(),null,t),labelProps:{appearance:"default"},children:[n.jsx(r.Card,{border:!0,css:{$$borderTopColor:"$colors$gray3",$$borderBottomColor:"$colors$gray3",$$borderLeftColor:"$colors$gray3",height:`$controlHeight${ie(B)}`,display:"flex",alignItems:"center",padding:"$2",backgroundColor:"$gray4",borderTopRightRadius:0,borderBottomRightRadius:0},children:z}),n.jsx(r.TextInput,{css:{width:"100%"},value:l,inputMode:"url",placeholder:te(d),"aria-label":t.get("label","Text Widget"),maxLength:t.get("maxLength"),name:t.get("name"),invalid:!o,onChange:u=>{i({storeKeys:e,scopes:["value"],type:"set",data:{value:u},schema:t,required:s})}})]})}const ue=r.globalCss({":root":{backgroundColor:"$groupedBackgroun
1d"},html:{minHeight:"100%",height:"100%",backgroundColor:"$groupedBackground"},body:{backgroundColor:"$groupedBackground",minHeight:"100%"},a:{appearance:"none",textDecoration:"none"}}),he=r.styled("div",r.VStack,{maxWidth:"800px",marginInline:"auto",padding:"$10"});function fe(e,i){var t;return ue(),n.jsx(he,{space:"large",children:n.jsx(r.Card,{elevation:1,css:{backgroundColor:"$background"},children:n.jsx(V,{ref:i,...e,widgets:{...e.widgets,custom:{text_area:G,settings_section:de,slug:ge,...(t=e.widgets)==null?void 0:t.custom}}})})})}const I=R.forwardRef(fe);I.displayName="SettingsForm";function me(e){return e==null}var ye=me;const be=$(ye),j=e=>function i(t,a=t){const o=t.replace(/\.([A-z0-9]*)(\.|$)/,"[$1]$2");return a!==o?i(o,t):o}(e);function L(e={},i=new FormData,t=""){return e||(e={}),!e&&typeof e!="object"||Object.entries(e).forEach(([a,o])=>{typeof o=="string"||typeof o=="number"||typeof o=="boolean"?i.append(j(`${t}${a}`),o.toString()):be(o)?i.append(j(`${t}${a}`),""):typeof o=="object"&&!Array.isArray(o)&&!_(o)&&L(o,i,`${t}${a}.`)}),i}var we=D;function _e(e,i,t){return e==null?e:we(e,i,t)}var xe=_e;const A=$(xe);var $e=N;function ke(e,i){return e==null?!0:$e(e,i)}var Se=ke;const b=$(Se);function m(e){return U(e)&&"type"in e&&(e==null?void 0:e.type)==="object"}function E(e){if(W(e))return e;if(!e.startsWith("/"))throw new Error(`Invalid key path: ${e}`);return e.startsWith("/")&&(e=e.slice(1)),e.split("/")}function F(e,i,{result:t={},valuesKeys:a=[]}={result:{},valuesKeys:[]}){if(_(t)&&(t=e),m(i)&&i.properties){for(const o in i.properties){const s=i.properties[o];if(m(s)){F(e,s,{result:t,valuesKeys:[...a,o]});continue}const l=s.keyPath,p=w(e,[...a,o]);if(l===null){b(t,[...a,o]);continue}if(l){const c=E(l);b(t,[...a,o]),A(t,c,p)}}_(w(t,a))&&b(t,a)}return t}function O(e,i,{result:t={},valuesKeys:a=[]}={result:{},valuesKeys:[]}){if(m(i)&&i.properties)for(const o in i.properties){const s=i.properties[o];if(m(s)){O(e,s,{result:t,valuesKeys:[...a,o]});continue}const l=s.keyPath||[...a,o],p=E(l);A(t,[...a,o],w(e,p))}return t}const x={$schema:"http://json-schema.org/schema",type:"object",view:{space:"none"},title:"#/properties/page/properties/title",properties:{page:{title:"Page Settings",description:"These settings determine how this page is displayed.",type:"object",widget:"settings_section",view:{label:!1,default_active:!0,separator:!1,space:"extraLarge"},required:["title"],properties:{title:{type:"string",view:{placeholder:"Title"}},featured_image_id:{$ref:"#/$defs/image",type:["number","null"],mode:"id",t:{label:"Featured Image"},view:{size:!1,aspectRatio:"16 / 9"}},custom_slug:{type:"string",format:"uri-reference",widget:"slug",base:"/admin/pages",t:{label:"Custom Page URL",description:"Edit the slug for this specific page."},view:{placeholder:"Custom Slug"}},delegate_id:{type:"number",keyPath:"/page/delegate_attributes/id",hidden:!0}}},seo:{title:"SEO / Social Settings",description:"These show up in the back of the website and help people find this page when searching through keywords or google.",widget:"settings_section",type:"object",view:{label:!1,separator:!1,space:"extraLarge"},properties:{browser_title:{type:"string",keyPath:"/page/browser_title",view:{label:"Browser Title",placeholder:"Browser Title"}},canonical_url:{type:"string",format:"uri",keyPath:"/page/canonical_url",view:{label:"Canonical URL",placeholder:"Canonical URL"}},search_keywords:{type:"string",keyPath:"/page/delegate_attributes/search_keywords",t:{label:"Search Keywords",placeholder:"Search Keywords",description:"Write the key words someone would include in a search when looking for your page or content. Separate each one with a comma and space. (Eg. Homily, Easter, spring)"}},social_description:{type:"string",keyPath:"/page/social_description",widget:"text_area",t:{label:"Social Media Description (Optional)",description:"This copy shows up when someone shares a link to this page on social media. This should give context to this page and invite others to look at the content."},view:{rows:4,placeholder:"Social Media Description (Optional)"}},social_image_id:{$ref:"#/$defs/image",mode:"id",type:["number","null"],label:"Social Media Image (Optional)",keyPath:"/page/social_image_id",t:{label:"Social Media Image (Optional)",description:"If you want a different picture than the main photo to show up on social media, you can upload that here."},view:{size:!1,aspectRatio:"16 / 9"}}}},navigation:{title:"Navigation Settings",description:"These settings determine how someone finds this page while on your website.",widget:"settings_section",type:"object",view:{label:!1,separator:!1,space:"extraLarge"},properties:{link_url:{type:"string",keyPath:"/page/link_url",t:{label:"Redirect URL",description:"If you would like to redirect this page to an already existing page on your site, write in the url path here (eg. /about-contact)",placeholder:"Redirect URL"}},options_for_parent_page:{type:"string",default:"",keyPath:null,widget:"segmented_control",oneOf:[{title:"Standard",const:"",description:'A regular parent page that is included in its child page URLs. e.g "About" "/about/contact"'},{title:"Redirect to first child",const:"skip_to_first_child",description:"I want this page to be skipped and to go directly to its first child."},{title:"Set as Folder",const:"collapse_slug",description:`Remove this page's slug from its child page URLs. e.g "About" "/contact"`}]},parent_id:{keyPath:"/page/parent_id",type:["string","number","null"],widget:"select","@context":{graphql:"query { pages { pages { id title } } }",accessor:"pages.pages",map:{key:"id",label:"title"}},view:{placeholder:"Parent Page"}
1,t:{label:"Choose a Parent Page",description:"Assign this page as a child to a parent page that already exists."}},menu_title:{type:"string",keyPath:"/page/menu_title",t:{label:"Menu Title",description:"Write how you want this page to be displayed in the menu navigation.",placeholder:"Menu Title"}},show_in_menu:{type:"boolean",keyPath:"/page/show_in_menu",default:!0,t:{label:"Display this page in the site menu",description:"Uncheck this box if you want to remove a page from your site menu. This can be handy if you have a page you want to link people to directly but don't want to show the page in the menu."}},hide_from_index:{type:"boolean",keyPath:"/page/delegate_attributes/hide_from_index",default:!1,t:{label:"Private Page",description:"Accessible only by direct link: save & refresh to get page link."}}},if:{properties:{options_for_parent_page:{const:"collapse_slug"}}},then:{properties:{parent_id:{hidden:!0}}}},advanced:{title:"Advanced Settings",widget:"settings_section",type:"object",view:{label:!1,separator:!1,space:"extraLarge"},properties:{set_as_homepage:{keyPath:"/set_as_homepage",type:"boolean",t:{label:"Set this as the new homepage"}},is_global:{keyPath:"/page/is_global",type:"boolean",t:{label:"Display on all descendant sites"}}}}},$defs:{image:J}},ve=oe(` 2 query GetPageSettings($path: String!) { 3 page(path: $path) { 4 id 5 settings 6 title 7 draft 8 } 9 } 10`);function Pe(){const e=r.useToaster(),{pathname:i}=H(),{csrf:t}=se(),a=R.useRef(null);async function o(){var y,h,f;if((y=a.current)==null?void 0:y.isInvalid)throw new Error("Form is invalid",(h=a.current)==null?void 0:h.values);const p=F((f=a.current)==null?void 0:f.values,x),c=L(p);c.append("_method","patch"),c.append("authenticity_token",t),c.append("page[draft]","false");const d=i.replace(/\/(settings|edit)$/,"");if(!(await fetch(d,{method:"POST",body:c})).ok)throw new Error("Failed to save form data")}function s(l){console.error(l),e.add({title:"Error",description:"There was an error saving your changes.",intent:"danger"})}return q("save",async()=>{try{await o(),e.add({title:"Saved",description:"Your changes have been saved.",intent:"success"})}catch(l){s(l)}}),{formRef:a}}function We(){var s;const e=T(),i=ne(e),{data:t,loading:a}=ae(ve,{variables:{path:i}}),{formRef:o}=Pe();return a?null:n.jsx(I,{ref:o,schema:x,initialValues:O(re((s=t==null?void 0:t.page)==null?void 0:s.settings),x)})}export{We as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.