(()=>{"use strict";const e=window.wp.blocks,t=window.wp.element,l=window.wp.primitives,o=(0,t.createElement)(l.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,t.createElement)(l.Path,{d:"M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z"})),r=JSON.parse('{"$schema":"https://json.schemastore.org/block.json","apiVersion":2,"name":"small-plugins/category-labels","title":"Category Labels","category":"text","description":"Display a subset of relevant post categories/taxonomies.","keywords":["category","labels"],"attributes":{"scopeToCurrentPost":{"type":"boolean","default":true},"displayPrimary":{"type":"boolean","default":false},"fallbackPrimary":{"type":"boolean","default":true},"limitCategories":{"type":"string","default":""}},"providesContext":{"category-labels-block/scope-to-current-post":"scopeToCurrentPost","category-labels-block/display-primary":"displayPrimary","category-labels-block/fallback-primary":"fallbackPrimary","category-labels-block/limit":"limitCategories"},"version":"1.0.0","textdomain":"category-labels-block","editorScript":"category-labels-block-script","editorStyle":"category-labels-block-editor-style","style":"category-labels-block-frontend-style","supports":{"spacing":{"margin":true,"padding":true,"blockGap":true},"align":["full","wide"],"color":{"background":true,"link":true,"text":false},"layout":{"allowSwitching":false,"allowInheriting":false,"allowVerticalAlignment":false,"allowSizingOnChildren":true,"default":{"type":"flex","flexWrap":"nowrap"}},"typography":{"fontSize":true,"lineHeight":true,"__experimentalFontStyle":true,"__experimentalFontWeight":true,"__experimentalTextTransform":true,"__experimentalFontFamily":true,"__experimentalLetterSpacing":true,"__experimentalTextDecoration":true,"__experimentalSkipSerialization":["textDecoration"],"__experimentalDefaultControls":{"fontSize":true}}}}'),a=window.wp.data;function n(){const{getEntityRecords:e}=(0,a.select)("core");return e("taxonomy","category",{per_page:-1,post:(0,a.select)("core/editor").getEditedPostAttribute("id"),context:"view"})}const s={from:[{type:"block",blocks:["core/post-terms"],isMatch:()=>{const e=n();return Array.isArray(e)&&e?.length>0},transform:t=>{const l=[];return n().forEach((t=>{const o=(0,e.createBlock)("small-plugins/post-term",{term:{id:t?.id,url:t?.link,title:t?.name,kind:"taxonomy",openInNewTab:!1}},[(0,e.createBlock)("small-plugins/term-name")]);l.push(o)})),(0,e.createBlock)("small-plugins/category-labels",{layout:{type:"flex",orientation:"horizontal",justifyContent:t.textAlign}},l)}}]},i=window.wp.i18n,c=window.wp.blockEditor,m=window.lodash,p=window.wp.components,u=function(){return(0,t.createElement)("div",{className:"clb-category-labels-placeholder__preview"},(0,t.createElement)("div",{className:"clb-category-labels-placeholder__actions__indicator"},(0,t.createElement)(p.Icon,{icon:o}),(0,i.__)("Category Labels")))};(0,e.registerBlockType)(r,{icon:o,edit:function(e){const{scopeToCurrentPost:l,displayPrimary:o,limitCategories:r,fallbackPrimary:n}=e.attributes,s=(0,a.useSelect)((t=>t("core/block-editor").getBlock(e.clientId).innerBlocks.length>0)),g=(0,m.get)(e,"__unstableLayoutClassNames",""),y=(0,c.useBlockProps)({className:["category-labels-block-root",g].join(" ")}),b=!e.isSelected&&!s,d=s?c.InnerBlocks.DefaultBlockAppender:c.InnerBlocks.ButtonBlockAppender,k="true"===(0,m.get)(smallPluginsCategoryLabelsBlockData,"hasSeoPlugin",!1),w="true"===(0,m.get)(smallPluginsCategoryLabelsBlockData,"isPremium");return(0,t.createElement)(t.Fragment,null,(0,t.createElement)("div",y,(0,t.createElement)(c.InnerBlocks,{orientation:"horizontal",allowedBlocks:k?["small-plugins/post-term","small-plugins/primary-term"]:["small-plugins/post-term"],renderAppender:!b&&d,placeholder:b?(0,t.createElement)(u,null):null})),(0,t.createElement)(c.InspectorControls,null,(0,t.createElement)(p.PanelBody,null,(0,t.createElement)(p.ToggleControl,{checked:l,onChange:()=>e.setAttributes({scopeToCurrentPost:!l}),label:(0,i.__)("Scope to current post","category-labels-block"),help:(0,i.__)("Do you want to only allow category links assigned to the current post?","category-labels-block")}),l&&w&&(0,t.createElement)(p.__experimentalNumberControl,{allowReset:!0,label:(0,i.__)("Limit Categories","category-labels-block"),min:1,help:(0,i.__)("Show a maximum number of labels whose order matches the block.","category-labels-block"),value:r,onChange:t=>e.setAttributes({limitCategories:t})})),(0,t.createElement)(p.PanelBody,null,(0,t.createElement)(p.Tip,null,(0,i.__)("Primary category settings have been moved into their own block.","category-labels-block")))))},save:function(){return(0,t.createElement)("div",c.useBlockProps.save({className:"category-labels-block-root"}),(0,t.createElement)(c.InnerBlocks.Content,null))},transforms:s})})();