(()=>{"use strict";const e=window.wp.i18n,t=window.wp.data,r=window.wp.element,o=window.wp.components,s=window.wp.hooks,n="_seopress_robots_primary_cat",a=({slug:s})=>{const{allTerms:a,selectedTermIds:l,storedPrimary:i}=(0,t.useSelect)((e=>{const t=e("core/editor"),r=e("core"),o=r.getTaxonomy(s);return{allTerms:r.getEntityRecords("taxonomy",s,{per_page:-1,context:"view"}),selectedTermIds:o?t.getEditedPostAttribute(o.rest_base):void 0,storedPrimary:(t.getEditedPostAttribute("meta")||{})[n]}}),[s]),c=(0,r.useMemo)((()=>{const e=l||[];return(a||[]).filter((t=>e.includes(t.id)))}),[a,l]),d=(0,r.useMemo)((()=>i&&c.some((e=>String(e.id)===String(i)))?String(i):"none"),[i,c]),{editPost:m}=(0,t.useDispatch)("core/editor");if(!c.length)return null;const p=[{value:"none",label:(0,e.__)("None (will disable this feature)","wp-seopress")},...c.map((e=>({value:String(e.id),label:e.name})))];return React.createElement(o.SelectControl,{label:(0,e.__)("Select a primary category","wp-seopress"),value:d,options:p,onChange:e=>{m({meta:{[n]:"none"===e?"":e}})},__next40pxDefaultSize:!0})};(0,s.addFilter)("editor.PostTaxonomyType","wpseopress",(e=>t=>React.createElement(React.Fragment,null,React.createElement(e,t),t.slug&&"category"===t.slug&&React.createElement(o.PanelRow,{className:"seopress-primary-term-picker"},React.createElement(a,t)))))})();