💦 FULL SET: Changeset/ - HD Photos!

Changeset 3425712


Ignore:
Timestamp:
12/23/2025 12:09:31 AM (7 days ago)
Author:
ronalfy
Message:

Hot fix: Disabling/enabling patterns would error out on some installs.

Location:
pattern-wrangler/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pattern-wrangler/trunk/build/dlx-pw-patterns-view.asset.php

    r3425616 r3425712  
    1 <?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-a11y', 'wp-api-fetch', 'wp-blob', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-element', 'wp-escape-html', 'wp-i18n', 'wp-primitives', 'wp-private-apis', 'wp-url', 'wp-warning'), 'version' => 'dac271456d777a30224d');
     1<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-a11y', 'wp-api-fetch', 'wp-blob', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-element', 'wp-escape-html', 'wp-i18n', 'wp-primitives', 'wp-private-apis', 'wp-url', 'wp-warning'), 'version' => '4612f737350121b3ec79');
  • pattern-wrangler/trunk/build/dlx-pw-patterns-view.js

    r3425616 r3425712  
    3939(0,s.__)("Move %s down"),e.label)})]}),u&&(0,f.jsx)(l.Button,{className:"dataviews-field-control__field-visibility-button",disabled:!e.enableHiding,accessibleWhenDisabled:!0,size:"compact",onClick:()=>{u(),setTimeout((()=>{const t=document.querySelector(`.dataviews-field-control__field-${e.id} .dataviews-field-control__field-visibility-button`);t instanceof HTMLElement&&t.focus()}),50)},icon:i?ji:oo,label:i?(0,s.sprintf)(/* translators: %s: field label */ /* translators: %s: field label */
    4040(0,s._x)("Hide %s","field"),e.label):(0,s.sprintf)(/* translators: %s: field label */ /* translators: %s: field label */
    41 (0,s._x)("Show %s","field"),e.label)}),p&&(0,f.jsx)(mo,{previewOptions:p,onChangePreviewOption:m,onMenuOpenChange:v,activeOption:e.id})]})]})})}function vo({index:e,field:t,view:n,onChangeView:r}){var i;const o=null!==(i=n.fields)&&void 0!==i?i:[],a=void 0!==e&&o.includes(t.id);return(0,f.jsx)(go,{field:t,isVisible:a,isFirst:void 0!==e&&e<1,isLast:void 0!==e&&e===o.length-1,onToggleVisibility:()=>{r({...n,fields:a?o.filter((e=>e!==t.id)):[...o,t.id]})},onMoveUp:void 0!==e?()=>{var i;r({...n,fields:[...null!==(i=o.slice(0,e-1))&&void 0!==i?i:[],t.id,o[e-1],...o.slice(e+1)]})}:void 0,onMoveDown:void 0!==e?()=>{var i;r({...n,fields:[...null!==(i=o.slice(0,e))&&void 0!==i?i:[],o[e+1],t.id,...o.slice(e+2)]})}:void 0})}function yo(e){return!!e}function bo(){var e;const{view:n,fields:r,onChangeView:i}=(0,t.useContext)(q),o=[n?.titleField,n?.mediaField,n?.descriptionField].filter(Boolean),a=null!==(e=n.fields)&&void 0!==e?e:[],c=r.filter((e=>!a.includes(e.id)&&!o.includes(e.id)&&"media"!==e.type)),u=a.map((e=>r.find((t=>t.id===e)))).filter(yo);if(!u?.length&&!c?.length)return null;const d=r.find((e=>e.id===n.titleField)),h=r.find((e=>e.id===n.mediaField)),p=r.find((e=>e.id===n.descriptionField)),m=r.filter((e=>"media"===e.type));let g;if(m.length>1){var v;const e=yo(h)&&(null===(v=n.showMedia)||void 0===v||v);g=yo(h)&&(0,f.jsx)(go,{field:h,label:(0,s.__)("Preview"),description:h.label,isVisible:e,onToggleVisibility:()=>{i({...n,showMedia:!e})},canMove:!1,previewOptions:m.map((e=>({label:e.label,id:e.id}))),onChangePreviewOption:e=>i({...n,mediaField:e})},h.id)}const y=[{field:d,isVisibleFlag:"showTitle"},{field:h,isVisibleFlag:"showMedia",ui:g},{field:p,isVisibleFlag:"showDescription"}].filter((({field:e})=>yo(e))),b=y.filter((({field:e,isVisibleFlag:t})=>{var r;return yo(e)&&(null===(r=n[t])||void 0===r||r)})),w=y.filter((({field:e,isVisibleFlag:t})=>{var r;return yo(e)&&!(null===(r=n[t])||void 0===r||r)}));return(0,f.jsxs)(l.__experimentalVStack,{className:"dataviews-field-control",spacing:6,children:[(0,f.jsx)(l.__experimentalVStack,{className:"dataviews-view-config__properties",spacing:0,children:(b.length>0||!!u?.length)&&(0,f.jsxs)(l.__experimentalItemGroup,{isBordered:!0,isSeparated:!0,children:[b.map((({field:e,isVisibleFlag:t,ui:r})=>null!=r?r:(0,f.jsx)(go,{field:e,isVisible:!0,onToggleVisibility:()=>{i({...n,[t]:!1})},canMove:!1},e.id))),u.map(((e,t)=>(0,f.jsx)(vo,{field:e,view:n,onChangeView:i,index:t},e.id)))]})}),(!!c?.length||!!w.length)&&(0,f.jsxs)(l.__experimentalVStack,{spacing:4,children:[(0,f.jsx)(l.BaseControl.VisualLabel,{style:{margin:0},children:(0,s.__)("Hidden")}),(0,f.jsx)(l.__experimentalVStack,{className:"dataviews-view-config__properties",spacing:0,children:(0,f.jsxs)(l.__experimentalItemGroup,{isBordered:!0,isSeparated:!0,children:[w.length>0&&w.map((({field:e,isVisibleFlag:t,ui:r})=>null!=r?r:(0,f.jsx)(go,{field:e,isVisible:!1,onToggleVisibility:()=>{i({...n,[t]:!0})},canMove:!1},e.id))),c.map((e=>(0,f.jsx)(vo,{field:e,view:n,onChangeView:i},e.id)))]})})]})]})}function wo({title:e,description:t,children:n}){return(0,f.jsxs)(l.__experimentalGrid,{columns:12,className:"dataviews-settings-section",gap:4,children:[(0,f.jsxs)("div",{className:"dataviews-settings-section__sidebar",children:[(0,f.jsx)(l.__experimentalHeading,{level:2,className:"dataviews-settings-section__title",children:e}),t&&(0,f.jsx)(l.__experimentalText,{variant:"muted",className:"dataviews-settings-section__description",children:t})]}),(0,f.jsx)(l.__experimentalGrid,{columns:8,gap:4,className:"dataviews-settings-section__content",children:n})]})}function xo(){const{view:e}=(0,t.useContext)(q),r=(0,n.useInstanceId)(_o,"dataviews-view-config-dropdown"),i=qi.find((t=>t.type===e.type));return(0,f.jsx)(l.Dropdown,{expandOnMobile:!0,popoverProps:{...lo,id:r},renderToggle:({onToggle:e,isOpen:t})=>(0,f.jsx)(l.Button,{size:"compact",icon:ao,label:(0,s._x)("View options","View is used as a noun"),onClick:e,"aria-expanded":t?"true":"false","aria-controls":r}),renderContent:()=>(0,f.jsx)(l.__experimentalDropdownContentWrapper,{paddingSize:"medium",className:"dataviews-config__popover-content-wrapper",children:(0,f.jsxs)(l.__experimentalVStack,{className:"dataviews-view-config",spacing:6,children:[(0,f.jsxs)(wo,{title:(0,s.__)("Appearance"),children:[(0,f.jsxs)(l.__experimentalHStack,{expanded:!0,className:"is-divided-in-two",children:[(0,f.jsx)(uo,{}),(0,f.jsx)(fo,{})]}),!!i?.viewConfigOptions&&(0,f.jsx)(i.viewConfigOptions,{}),(0,f.jsx)(po,{})]}),(0,f.jsx)(wo,{title:(0,s.__)("Properties"),children:(0,f.jsx)(bo,{})})]})})})}function _o(){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(co,{}),(0,f.jsx)(xo,{})]})}const Eo=(0,t.memo)(_o),So=window.wp.url;function Co({item:e,field:t}){const n=t.getValue({item:e});return t?.elements?.find((e=>e.value===n))?.label||t.getValue({item:e})}const Oo={sort:function(e,t,n){return"asc"===n?e.localeCompare(t):t.localeCompare(e)},isValid:function(e,t){if(""===e)return!1;if(!(0,So.isEmail)(e))return!1;if(t?.elements){const n=t?.elements?.map((e=>e.value));if(!n.includes(e))return!1}return!0},Edit:"email",render:({item:e,field:t})=>t.elements?Co({item:e,field:t}):t.getValue({item:e}),enableSorting:!0,filterBy:{defaultOperators:[v,y],validOperators:[m,g,L,k,T,v,y,b,w]}},Po={sort:function(e,t,n){return"asc"===n?e-t:t-e},isValid:function(e,t){if(""===e)return!1;if(!Number.isInteger(Number(e)))return!1;if(t?.elements){const n=t?.elements.map((e=>e.value));if(!n.includes(Number(e)))return!1}return!0},Edit:"integer",render:({item:e,field:t})=>t.elements?Co({item:e,field:t}):t.getValue({item:e}),enableSorting:!0,filterBy:{defaultOperators:[m,g,x,_,E,S,I],validOperators:[m,g,x,_,E,S,I,v,y,b,w]}},jo={sort:function(e,t,n){return"asc"===n?e.localeCompare(t):t.localeCompare(e)},isValid:function(e,t){if(t?.elements){const n=t?.elements?.map((e=>e.value));if(!n.includes(e))return!1}return!0},Edit:"text",render:({item:e,field:t})=>t.elements?Co({item:e,field:t}):t.getValue({item:e}),enableSorting:!0,filterBy:{defaultOperators:[v,y],validOperators:[m,g,L,k,T,v,y,b,w]}},Lo={sort:function(e,t,n){const r=new Date(e).getTime(),i=new Date(t).getTime();return"asc"===n?r-i:i-r},isValid:function(e,t){if(t?.elements){const n=t?.elements.map((e=>e.value));if(!n.includes(e))return!1}return!0},Edit:"datetime",render:({item:e,field:t})=>t.elements?Co({item:e,field:t}):t.getValue({item:e}),enableSorting:!0,filterBy:{defaultOperators:[A,M,C,O,P,j,N,R],validOperators:[A,M,C,O,P,j,N,R]}},ko=window.wp.date,To={sort:function(e,t,n){const r=new Date(e).getTime(),i=new Date(t).getTime();return"asc"===n?r-i:i-r},isValid:function(e,t){if(t?.elements){const n=t?.elements.map((e=>e.value));if(!n.includes(e))return!1}return!0},Edit:null,render:({item:e,field:t})=>{if(t.elements)return Co({item:e,field:t});const n=t.getValue({item:e});return n?(r=n,(0,ko.dateI18n)((0,ko.getSettings)().formats.date,(0,ko.getDate)(r))):"";var r},enableSorting:!0,filterBy:!1},Io={sort:function(e,t,n){const r=Boolean(e);return r===Boolean(t)?0:"asc"===n?r?1:-1:r?-1:1},isValid:function(e){return!![!0,!1,void 0].includes(e)},Edit:"boolean",render:({item:e,field:t})=>t.elements?Co({item:e,field:t}):!0===t.getValue({item:e})?(0,s.__)("True"):!1===t.getValue({item:e})?(0,s.__)("False"):null,enableSorting:!0,filterBy:{defaultOperators:[m,g],validOperators:[m,g]}},Ao={sort:function(){return 0},isValid:function(e,t){if(t?.elements){const n=t?.elements.map((e=>e.value));if(!n.includes(e))return!1}return!0},Edit:null,render:()=>null,enableSorting:!1,filterBy:!1},Mo={sort:function(e,t,n){const r=Array.isArray(e)?e:[],i=Array.isArray(t)?t:[];if(r.length!==i.length)return"asc"===n?r.length-i.length:i.length-r.length;const o=r.join(","),a=i.join(",");return"asc"===n?o.localeCompare(a):a.localeCompare(o)},isValid:function(e,t){if(!Array.isArray(e))return!1;if(!e.every((e=>"string"==typeof e)))return!1;if(t?.elements){const n=t.elements.map((e=>e.value));if(!e.every((e=>n.includes(e))))return!1}return!0},Edit:null,render:function({item:e,field:t}){return(t.getValue({item:e})||[]).join(", ")},enableSorting:!0,filterBy:{defaultOperators:[v,y],validOperators:[v,y,b,w]}},No={[N]:[{value:"days",label:(0,s.__)("Days")},{value:"weeks",label:(0,s.__)("Weeks")},{value:"months",label:(0,s.__)("Months")},{value:"years",label:(0,s.__)("Years")}],[R]:[{value:"days",label:(0,s.__)("Days ago")},{value:"weeks",label:(0,s.__)("Weeks ago")},{value:"months",label:(0,s.__)("Months ago")},{value:"years",label:(0,s.__)("Years ago")}]};function Ro({id:e,value:n,onChange:r,label:i,hideLabelFromVision:o,options:a}){const{value:c="",unit:u=a[0].value}=n,d=(0,t.useCallback)((t=>r({[e]:{value:Number(t),unit:u}})),[e,r,u]),h=(0,t.useCallback)((t=>r({[e]:{value:c,unit:t}})),[e,r,c]);return(0,f.jsx)(l.BaseControl,{id:e,__nextHasNoMarginBottom:!0,className:"dataviews-controls__datetime",label:i,hideLabelFromVision:o,children:(0,f.jsxs)(l.__experimentalHStack,{spacing:2.5,children:[(0,f.jsx)(l.__experimentalNumberControl,{__next40pxDefaultSize:!0,className:"dataviews-controls__datetime-number",spinControls:"none",min:1,step:1,value:c,onChange:d}),(0,f.jsx)(l.SelectControl,{className:"dataviews-controls__datetime-unit",__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,s.__)("Unit"),value:u,options:a,onChange:h,hideLabelFromVision:!0})]})})}function Fo({id:e,value:n,onChange:r,hideLabelFromVision:i}){const[o="",a=""]=Array.isArray(n)?n:[],c=(0,t.useCallback)((t=>r({[e]:[Number(t),a]})),[e,r,a]),u=(0,t.useCallback)((t=>r({[e]:[o,Number(t)]})),[e,r,o]);return(0,f.jsx)(l.BaseControl,{__nextHasNoMarginBottom:!0,help:(0,s.__)("The max. value must be greater than the min. value."),children:(0,f.jsxs)(l.Flex,{direction:"row",gap:4,children:[(0,f.jsx)(l.__experimentalNumberControl,{label:(0,s.__)("Min."),value:o,max:a?Number(a)-1:void 0,onChange:c,__next40pxDefaultSize:!0,hideLabelFromVision:i}),(0,f.jsx)(l.__experimentalNumberControl,{label:(0,s.__)("Max."),value:a,min:o?Number(o)+1:void 0,onChange:u,__next40pxDefaultSize:!0,hideLabelFromVision:i})]})})}const Do={boolean:function({field:e,onChange:t,data:n,hideLabelFromVision:r}){const{id:i,getValue:o,label:a}=e;return(0,f.jsx)(l.ToggleControl,{hidden:r,__nextHasNoMarginBottom:!0,label:a,checked:o({item:n}),onChange:()=>t({[i]:!o({item:n})})})},checkbox:function({field:e,onChange:t,data:n,hideLabelFromVision:r}){const{id:i,getValue:o,label:a,description:s}=e;return(0,f.jsx)(l.CheckboxControl,{__nextHasNoMarginBottom:!0,hidden:r,label:a,help:s,checked:o({item:n}),onChange:()=>t({[i]:!o({item:n})})})},datetime:function({data:e,field:n,onChange:r,hideLabelFromVision:i,operator:o}){const{id:a,label:s}=n,c=n.getValue({item:e}),u=(0,t.useCallback)((e=>r({[a]:e})),[a,r]);return o===N||o===R?(0,f.jsx)(Ro,{id:a,value:c&&"object"==typeof c?c:{},onChange:r,label:s,hideLabelFromVision:i,options:No[o]}):(0,f.jsxs)("fieldset",{className:"dataviews-controls__datetime",children:[!i&&(0,f.jsx)(l.BaseControl.VisualLabel,{as:"legend",children:s}),i&&(0,f.jsx)(l.VisuallyHidden,{as:"legend",children:s}),(0,f.jsx)(l.TimePicker,{currentTime:"string"==typeof c?c:void 0,onChange:u,hideLabelFromVision:!0})]})},email:function({data:e,field:n,onChange:r,hideLabelFromVision:i}){const{id:o,label:a,placeholder:s,description:c}=n,u=n.getValue({item:e}),d=(0,t.useCallback)((e=>r({[o]:e})),[o,r]);return(0,f.jsx)(l.TextControl,{type:"email",label:a,placeholder:s,value:null!=u?u:"",help:c,onChange:d,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,hideLabelFromVision:i})},integer:function({data:e,field:n,onChange:r,hideLabelFromVision:i,operator:o}){var a;const{id:s,label:c,description:u}=n,d=null!==(a=n.getValue({item:e}))&&void 0!==a?a:"",h=(0,t.useCallback)((e=>r({[s]:Number(e)})),[s,r]);return o===I?(0,f.jsx)(Fo,{id:s,value:d,onChange:r,hideLabelFromVision:i}):(0,f.jsx)(l.__experimentalNumberControl,{label:c,help:u,value:d,onChange:h,__next40pxDefaultSize:!0,hideLabelFromVision:i})},radio:function({data:e,field:n,onChange:r,hideLabelFromVision:i}){const{id:o,label:a}=n,s=n.getValue({item:e}),c=(0,t.useCallback)((e=>r({[o]:e})),[o,r]);return n.elements?(0,f.jsx)(l.RadioControl,{label:a,onChange:c,options:n.elements,selected:s,hideLabelFromVision:i}):null},select:function({data:e,field:n,onChange:r,hideLabelFromVision:i}){var o,a;const{id:c,label:u}=n,d=null!==(o=n.getValue({item:e}))&&void 0!==o?o:"",h=(0,t.useCallback)((e=>r({[c]:e})),[c,r]),p=[{label:(0,s.__)("Select item"),value:""},...null!==(a=n?.elements)&&void 0!==a?a:[]];return(0,f.jsx)(l.SelectControl,{label:u,value:d,help:n.description,options:p,onChange:h,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,hideLabelFromVision:i})},text:function({data:e,field:n,onChange:r,hideLabelFromVision:i}){const{id:o,label:a,placeholder:s,description:c}=n,u=n.getValue({item:e}),d=(0,t.useCallback)((e=>r({[o]:e})),[o,r]);return(0,f.jsx)(l.TextControl,{label:a,placeholder:s,value:null!=u?u:"",help:c,onChange:d,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,hideLabelFromVision:i})},toggleGroup:function({data:e,field:n,onChange:r,hideLabelFromVision:i}){const{id:o}=n,a=n.getValue({item:e}),s=(0,t.useCallback)((e=>r({[o]:e})),[o,r]);if(n.elements){const e=n.elements.find((e=>e.value===a));return(0,f.jsx)(l.__experimentalToggleGroupControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,isBlock:!0,label:n.label,help:e?.description||n.description,onChange:s,value:a,hideLabelFromVision:i,children:n.elements.map((e=>(0,f.jsx)(l.__experimentalToggleGroupControlOption,{label:e.label,value:e.value},e.value)))})}return null}};function Vo(e){if(Object.keys(Do).includes(e))return Do[e];throw"Control "+e+" not found"}const Bo=e=>e.id,zo=()=>!0,Ho=[];function $o({header:e,search:n=!0,searchLabel:r}){const{isShowingFilter:i}=(0,t.useContext)(q);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(l.__experimentalHStack,{alignment:"top",justify:"space-between",className:"dataviews__view-actions",spacing:1,children:[(0,f.jsxs)(l.__experimentalHStack,{justify:"start",expanded:!1,className:"dataviews__search",children:[n&&(0,f.jsx)(to,{label:r}),(0,f.jsx)(Zr,{})]}),(0,f.jsxs)(l.__experimentalHStack,{spacing:1,expanded:!1,style:{flexShrink:0},children:[(0,f.jsx)(Eo,{}),e]})]}),i&&(0,f.jsx)(Jr,{className:"dataviews-filters__container"}),(0,f.jsx)(Yi,{}),(0,f.jsx)(eo,{})]})}const Go=function({view:e,onChangeView:r,fields:i,search:o=!0,searchLabel:a,actions:s=Ho,data:l,getItemId:c=Bo,getItemLevel:u,isLoading:d=!1,paginationInfo:h,defaultLayouts:p,selection:v,onChangeSelection:y,onClickItem:b,renderItemLink:w,isItemClickable:x=zo,header:_,children:E,perPageSizes:S}){const C=(0,t.useRef)(null),[O,P]=(0,t.useState)(0),j=(0,n.useResizeObserver)((e=>{P(e[0].borderBoxSize[0].inlineSize)}),{box:"border-box"}),[L,k]=(0,t.useState)([]),T=void 0===v||void 0===y,A=T?L:v,[M,N]=(0,t.useState)(null),R=(0,t.useMemo)((()=>function(e){return e.map((e=>{var t,n,r,i,o,a,s,l;const c="email"===(u=e.type)?Oo:"integer"===u?Po:"text"===u?jo:"datetime"===u?Lo:"date"===u?To:"boolean"===u?Io:"media"===u?Ao:"array"===u?Mo:{sort:(e,t,n)=>"number"==typeof e&&"number"==typeof t?"asc"===n?e-t:t-e:"asc"===n?e.localeCompare(t):t.localeCompare(e),isValid:(e,t)=>{if(t?.elements){const n=t?.elements?.map((e=>e.value));if(!n.includes(e))return!1}return!0},Edit:null,render:({item:e,field:t})=>t.elements?Co({item:e,field:t}):t.getValue({item:e}),enableSorting:!0,filterBy:{defaultOperators:[m,g],validOperators:F}};var u;const d=e.getValue||(f=e.id,({item:e})=>{const t=f.split(".");let n=e;for(const e of t)n=n.hasOwnProperty(e)?n[e]:void 0;return n});var f;const h=null!==(t=e.sort)&&void 0!==t?t:function(e,t,n){return c.sort(d({item:e}),d({item:t}),n)},p=null!==(n=e.isValid)&&void 0!==n?n:function(e,t){return c.isValid(d({item:e}),t)},v=function(e,t){return"function"==typeof e.Edit?e.Edit:"string"==typeof e.Edit?Vo(e.Edit):e.elements?Vo("select"):"string"==typeof t.Edit?Vo(t.Edit):t.Edit}(e,c),y=null!==(r=e.render)&&void 0!==r?r:function({item:e,field:t}){return c.render({item:e,field:t})},b=function(e,t){if(!1===e.filterBy)return!1;if("object"==typeof e.filterBy){let n=e.filterBy.operators;n&&Array.isArray(n)||(n=t.filterBy?t.filterBy.defaultOperators:[]);let r=F;return"object"==typeof t.filterBy&&(r=t.filterBy.validOperators),n=n.filter((e=>r.includes(e))),e.elements&&n.includes(I)&&(n=n.filter((e=>e!==I))),n.some((e=>D.includes(e)))&&(n=n.filter((e=>[...D,I].includes(e)))),0!==n.length&&{isPrimary:!!e.filterBy.isPrimary,operators:n}}if(!1===t.filterBy)return!1;let n=t.filterBy.defaultOperators;return e.elements&&n.includes(I)&&(n=n.filter((e=>e!==I))),{operators:n}}(e,c);return{...e,label:e.label||e.id,header:e.header||e.label||e.id,getValue:d,render:y,sort:h,isValid:p,Edit:v,enableHiding:null===(i=e.enableHiding)||void 0===i||i,enableSorting:null===(o=null!==(a=e.enableSorting)&&void 0!==a?a:c.enableSorting)||void 0===o||o,filterBy:b,readOnly:null!==(s=null!==(l=e.readOnly)&&void 0!==l?l:c.readOnly)&&void 0!==s&&s}}))}(i)),[i]),V=(0,t.useMemo)((()=>A.filter((e=>l.some((t=>c(t)===e))))),[A,l,c]),B=Kr(R,e),[z,H]=(0,t.useState)((()=>(B||[]).some((e=>e.isPrimary))));return(0,f.jsx)(q.Provider,{value:{view:e,onChangeView:r,fields:R,actions:s,data:l,isLoading:d,paginationInfo:h,selection:V,onChangeSelection:function(e){const t="function"==typeof e?e(A):e;T&&k(t),y&&y(t)},openedFilter:M,setOpenedFilter:N,getItemId:c,getItemLevel:u,isItemClickable:x,onClickItem:b,renderItemLink:w,containerWidth:O,containerRef:C,defaultLayouts:p,filters:B,isShowingFilter:z,setIsShowingFilter:H,perPageSizes:S},children:(0,f.jsx)("div",{className:"dataviews-wrapper",ref:(0,n.useMergeRefs)([C,j]),children:null!=E?E:(0,f.jsx)($o,{header:_,search:o,searchLabel:a})})})};Go.BulkActionToolbar=Ci,Go.Filters=Jr,Go.FiltersToggle=Zr,Go.Layout=Yi,Go.LayoutSwitcher=co,Go.Pagination=Zi,Go.Search=to,Go.ViewConfig=xo;const Uo=Go;var Wo=i(270),qo=i.n(Wo);const Yo=(...e)=>e.filter(((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t)).join(" ").trim();var Xo={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Ko=(0,Pe.forwardRef)((({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:o,iconNode:a,...s},l)=>(0,Pe.createElement)("svg",{ref:l,...Xo,width:t,height:t,stroke:e,strokeWidth:r?24*Number(n)/Number(t):n,className:Yo("lucide",i),...s},[...a.map((([e,t])=>(0,Pe.createElement)(e,t))),...Array.isArray(o)?o:[o]]))),Zo=(e,t)=>{const n=(0,Pe.forwardRef)((({className:n,...r},i)=>{return(0,Pe.createElement)(Ko,{ref:i,iconNode:t,className:Yo(`lucide-${o=e,o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,n),...r});var o}));return n.displayName=`${e}`,n},Qo=Zo("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Jo=Zo("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),ea=Zo("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);var ta=i(942),na=i.n(ta),ra=i(556),ia=i.n(ra);const oa=window.wp.a11y;function aa(e){return aa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},aa(e)}function sa(){return sa=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},sa.apply(null,arguments)}function la(e,t,n){return(t=function(e){var t=function(e){if("object"!=aa(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=aa(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==aa(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ca=function(e){var t=e.message,n=e.status,r=e.politeness,i=e.icon,o=e.className,a=e.inline,c=e.children,u=e.hasToTop,d=void 0!==u&&u;(0,Pe.useEffect)((function(){(0,oa.speak)(t,r)}),[t,n,r]);var f=function(){return null!==i},h=na()(o,"dlx-pw-admin__notice",la(la(la({"dlx-pw-admin__notice--has-icon":f()},"dlx-pw-admin__notice-type--".concat(n),!0),"dlx-pw-admin__notice-appearance--inline",a),"dlx-pw-admin__notice-appearance--block",!a)),p=[{label:(0,s.__)("Back to Top","wp-dlx-pw-comments"),url:"#dlx-pw-admin-header",variant:"link",className:"dlx-pw-admin__notice-action dlx-pw-admin__notice-action--to-top"}];return Le().createElement("div",{className:h},Le().createElement(l.Notice,sa({isDismissible:!1,spokenMessage:t,actions:d?p:[]},e),f()&&Le().createElement("div",{className:"dlx-pw-admin__notice-icon"},function(e){return Le().createElement(e,{width:16,height:16,fill:"#6c757d"})}(i)),Le().createElement("div",{className:"dlx-pw-admin__notice-message"},Le().createElement(Le().Fragment,null,t," ",c," "))))};ca.defaultProps={message:"",status:"info",politeness:"polite",icon:null,className:"",inline:!1,hasToTop:!1},ca.propTypes={message:ia().string.isRequired,status:ia().oneOf(["info","warning","success","error"]),politeness:ia().oneOf(["assertive","polite"]),icon:ia().func,className:ia().string,inline:ia().bool,hasToTop:ia().bool};const ua=ca;function da(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return fa(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fa(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function fa(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const ha=function(e){var t=e.loadingMessage,n={type:e.type,message:e.message,title:e.title,isDismissable:!1,isPersistent:!1,isSuccess:!1,loadingMessage:t,politeness:"polite"},r=da((0,Pe.useState)(n),2),i=r[0],o=(r[1],da((0,Pe.useState)(!1),2)),a=o[0],c=(o[1],da((0,Pe.useState)(!1),2)),u=c[0],d=c[1];(0,Pe.useEffect)((function(){e.isVisible&&setTimeout((function(){e.onClose()}),5e3)}),[e.isVisible]);var f=function(){switch(i.type){case"success":return Le().createElement(Qo,null);case"error":case"critical":return Le().createElement(Jo,null);default:return Le().createElement(ea,null)}};return Le().createElement(Le().Fragment,null,Le().createElement(l.Snackbar,{className:na()("dlx-pw-snackbar dlx-pw-snackbar-".concat(i.type),{"dlx-pw-snackbar-loading":a}),actions:function(){var e=[];return"success"===i.type&&e.push({label:(0,s.__)("Back to Top","pattern-wrangler"),url:"#dlx-pw-admin-header",variant:"link",className:"dlx-pw-admin__notice-action dlx-pw-admin__notice-action--to-top"}),e}(),icon:f(),onDismiss:function(){d(!1),e.onClose()},explicitDismiss:i.isDismissable},a?t:i.message)," ",u&&function(){if("critical"===i.type)return Le().createElement(l.Modal,{className:na()("dlx-pw-modal dlx-pw-modal-".concat(i.type),{"dlx-pw-modal-loading":a}),bodyOpenClassName:"dlx-pw-modal-body-open",title:i.title,onRequestClose:function(){d(!1)},isDismissible:!0,shouldCloseOnClickOutside:i.isPersistent,shouldCloseOnEsc:i.isPersistent},Le().createElement(ua,{message:i.message,status:i.type,politeness:i.politeness,icon:f,inline:!1}),Le().createElement("div",{className:"dlx-pw-modal-button-group"},Le().createElement(l.Button,{className:"button button-error",variant:"secondary",onClick:function(){d(!1)}},(0,s.__)("OK","pattern-wrangler"))))}()," ")};i(912);const pa=Zo("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var ma=e=>"checkbox"===e.type,ga=e=>e instanceof Date,va=e=>null==e;const ya=e=>"object"==typeof e;var ba=e=>!va(e)&&!Array.isArray(e)&&ya(e)&&!ga(e),wa=e=>ba(e)&&e.target?ma(e.target)?e.target.checked:e.target.value:e,xa=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),_a="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function Ea(e){let t;const n=Array.isArray(e),r="undefined"!=typeof FileList&&e instanceof FileList;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(_a&&(e instanceof Blob||r)||!n&&!ba(e))return e;if(t=n?[]:{},n||(e=>{const t=e.constructor&&e.constructor.prototype;return ba(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const n in e)e.hasOwnProperty(n)&&(t[n]=Ea(e[n]));else t=e}return t}var Sa=e=>Array.isArray(e)?e.filter(Boolean):[],Ca=e=>void 0===e,Oa=(e,t,n)=>{if(!t||!ba(e))return n;const r=Sa(t.split(/[,[\].]+?/)).reduce(((e,t)=>va(e)?e:e[t]),e);return Ca(r)||r===e?Ca(e[t])?n:e[t]:r},Pa=e=>"boolean"==typeof e,ja=e=>/^\w*$/.test(e),La=e=>Sa(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ka=(e,t,n)=>{let r=-1;const i=ja(t)?[t]:La(t),o=i.length,a=o-1;for(;++r<o;){const t=i[r];let o=n;if(r!==a){const n=e[t];o=ba(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=o,e=e[t]}return e};const Ta="blur",Ia="onChange",Aa="onSubmit",Ma="all",Na="pattern",Ra="required",Fa=Pe.createContext(null),Da=()=>Pe.useContext(Fa);var Va=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(i,o,{get:()=>{const i=o;return t._proxyFormState[i]!==Ma&&(t._proxyFormState[i]=!r||Ma),n&&(n[i]=!0),e[i]}});return i},Ba=e=>ba(e)&&!Object.keys(e).length,za=(e,t,n,r)=>{n(e);const{name:i,...o}=e;return Ba(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find((e=>t[e]===(!r||Ma)))},Ha=e=>Array.isArray(e)?e:[e],$a=(e,t,n)=>!e||!t||e===t||Ha(e).some((e=>e&&(n?e===t:e.startsWith(t)||t.startsWith(e))));function Ga(e){const t=Pe.useRef(e);t.current=e,Pe.useEffect((()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}}),[e.disabled])}function Ua(e){const t=Da(),{control:n=t.control,disabled:r,name:i,exact:o}=e||{},[a,s]=Pe.useState(n._formState),l=Pe.useRef(!0),c=Pe.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),u=Pe.useRef(i);return u.current=i,Ga({disabled:r,next:e=>l.current&&$a(u.current,e.name,o)&&za(e,c.current,n._updateFormState)&&s({...n._formState,...e}),subject:n._subjects.state}),Pe.useEffect((()=>(l.current=!0,c.current.isValid&&n._updateValid(!0),()=>{l.current=!1})),[n]),Pe.useMemo((()=>Va(a,n,c.current,!1)),[a,n])}var Wa=e=>"string"==typeof e,qa=(e,t,n,r,i)=>Wa(e)?(r&&t.watch.add(e),Oa(n,e,i)):Array.isArray(e)?e.map((e=>(r&&t.watch.add(e),Oa(n,e)))):(r&&(t.watchAll=!0),n);function Ya(e){const t=Da(),{control:n=t.control,name:r,defaultValue:i,disabled:o,exact:a}=e||{},s=Pe.useRef(r);s.current=r,Ga({disabled:o,subject:n._subjects.values,next:e=>{$a(s.current,e.name,a)&&c(Ea(qa(s.current,n._names,e.values||n._formValues,!1,i)))}});const[l,c]=Pe.useState(n._getWatch(r,i));return Pe.useEffect((()=>n._removeUnmounted())),l}const Xa=e=>e.render(function(e){const t=Da(),{name:n,disabled:r,control:i=t.control,shouldUnregister:o}=e,a=xa(i._names.array,n),s=Ya({control:i,name:n,defaultValue:Oa(i._formValues,n,Oa(i._defaultValues,n,e.defaultValue)),exact:!0}),l=Ua({control:i,name:n,exact:!0}),c=Pe.useRef(i.register(n,{...e.rules,value:s,...Pa(e.disabled)?{disabled:e.disabled}:{}})),u=Pe.useMemo((()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Oa(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!Oa(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!Oa(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!Oa(l.validatingFields,n)},error:{enumerable:!0,get:()=>Oa(l.errors,n)}})),[l,n]),d=Pe.useMemo((()=>({name:n,value:s,...Pa(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:e=>c.current.onChange({target:{value:wa(e),name:n},type:"change"}),onBlur:()=>c.current.onBlur({target:{value:Oa(i._formValues,n),name:n},type:Ta}),ref:e=>{const t=Oa(i._fields,n);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}})),[n,i._formValues,r,l.disabled,s,i._fields]);return Pe.useEffect((()=>{const e=i._options.shouldUnregister||o,t=(e,t)=>{const n=Oa(i._fields,e);n&&n._f&&(n._f.mount=t)};if(t(n,!0),e){const e=Ea(Oa(i._options.defaultValues,n));ka(i._defaultValues,n,e),Ca(Oa(i._formValues,n))&&ka(i._formValues,n,e)}return()=>{(a?e&&!i._state.action:e)?i.unregister(n):t(n,!1)}}),[n,i,a,o]),Pe.useEffect((()=>{Pa(r)&&Oa(i._fields,n)&&i._updateDisabledField({disabled:r,fields:i._fields,name:n,value:Oa(i._fields,n)._f.value})}),[r,n,i]),Pe.useMemo((()=>({field:d,formState:l,fieldState:u})),[d,l,u])}(e));var Ka=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},Za=e=>({isOnSubmit:!e||e===Aa,isOnBlur:"onBlur"===e,isOnChange:e===Ia,isOnAll:e===Ma,isOnTouch:"onTouched"===e}),Qa=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))));const Ja=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const n=Oa(e,i);if(n){const{_f:e,...o}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r)return!0;if(e.ref&&t(e.ref,e.name)&&!r)return!0;if(Ja(o,t))break}else if(ba(o)&&Ja(o,t))break}}};var es=(e,t,n)=>{const r=Ha(Oa(e,n));return ka(r,"root",t[n]),ka(e,n,r),e},ts=e=>"file"===e.type,ns=e=>"function"==typeof e,rs=e=>{if(!_a)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},is=e=>Wa(e),os=e=>"radio"===e.type,as=e=>e instanceof RegExp;const ss={value:!1,isValid:!1},ls={value:!0,isValid:!0};var cs=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Ca(e[0].attributes.value)?Ca(e[0].value)||""===e[0].value?ls:{value:e[0].value,isValid:!0}:ls:ss}return ss};const us={isValid:!1,value:null};var ds=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),us):us;function fs(e,t,n="validate"){if(is(e)||Array.isArray(e)&&e.every(is)||Pa(e)&&!e)return{type:n,message:is(e)?e:"",ref:t}}var hs=e=>ba(e)&&!as(e)?e:{value:e,message:""},ps=async(e,t,n,r,i)=>{const{ref:o,refs:a,required:s,maxLength:l,minLength:c,min:u,max:d,pattern:f,validate:h,name:p,valueAsNumber:m,mount:g,disabled:v}=e._f,y=Oa(t,p);if(!g||v)return{};const b=a?a[0]:o,w=e=>{r&&b.reportValidity&&(b.setCustomValidity(Pa(e)?"":e||""),b.reportValidity())},x={},_=os(o),E=ma(o),S=_||E,C=(m||ts(o))&&Ca(o.value)&&Ca(y)||rs(o)&&""===o.value||""===y||Array.isArray(y)&&!y.length,O=Ka.bind(null,p,n,x),P=(e,t,n,r="maxLength",i="minLength")=>{const a=e?t:n;x[p]={type:e?r:i,message:a,ref:o,...O(e?r:i,a)}};if(i?!Array.isArray(y)||!y.length:s&&(!S&&(C||va(y))||Pa(y)&&!y||E&&!cs(a).isValid||_&&!ds(a).isValid)){const{value:e,message:t}=is(s)?{value:!!s,message:s}:hs(s);if(e&&(x[p]={type:Ra,message:t,ref:b,...O(Ra,t)},!n))return w(t),x}if(!(C||va(u)&&va(d))){let e,t;const r=hs(d),i=hs(u);if(va(y)||isNaN(y)){const n=o.valueAsDate||new Date(y),a=e=>new Date((new Date).toDateString()+" "+e),s="time"==o.type,l="week"==o.type;Wa(r.value)&&y&&(e=s?a(y)>a(r.value):l?y>r.value:n>new Date(r.value)),Wa(i.value)&&y&&(t=s?a(y)<a(i.value):l?y<i.value:n<new Date(i.value))}else{const n=o.valueAsNumber||(y?+y:y);va(r.value)||(e=n>r.value),va(i.value)||(t=n<i.value)}if((e||t)&&(P(!!e,r.message,i.message,"max","min"),!n))return w(x[p].message),x}if((l||c)&&!C&&(Wa(y)||i&&Array.isArray(y))){const e=hs(l),t=hs(c),r=!va(e.value)&&y.length>+e.value,i=!va(t.value)&&y.length<+t.value;if((r||i)&&(P(r,e.message,t.message),!n))return w(x[p].message),x}if(f&&!C&&Wa(y)){const{value:e,message:t}=hs(f);if(as(e)&&!y.match(e)&&(x[p]={type:Na,message:t,ref:o,...O(Na,t)},!n))return w(t),x}if(h)if(ns(h)){const e=fs(await h(y,t),b);if(e&&(x[p]={...e,...O("validate",e.message)},!n))return w(e.message),x}else if(ba(h)){let e={};for(const r in h){if(!Ba(e)&&!n)break;const i=fs(await h[r](y,t),b,r);i&&(e={...i,...O(r,i.message)},w(i.message),n&&(x[p]=e))}if(!Ba(e)&&(x[p]={ref:b,...e},!n))return x}return w(!0),x};function ms(e,t){const n=Array.isArray(t)?t:ja(t)?[t]:La(t),r=1===n.length?e:function(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Ca(e)?r++:e[t[r++]];return e}(e,n),i=n.length-1,o=n[i];return r&&delete r[o],0!==i&&(ba(r)&&Ba(r)||Array.isArray(r)&&function(e){for(const t in e)if(e.hasOwnProperty(t)&&!Ca(e[t]))return!1;return!0}(r))&&ms(e,n.slice(0,-1)),e}var gs=()=>{let e=[];return{get observers(){return e},next:t=>{for(const n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}},vs=e=>va(e)||!ya(e);function ys(e,t){if(vs(e)||vs(t))return e===t;if(ga(e)&&ga(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const n=e[i];if(!r.includes(i))return!1;if("ref"!==i){const e=t[i];if(ga(n)&&ga(e)||ba(n)&&ba(e)||Array.isArray(n)&&Array.isArray(e)?!ys(n,e):n!==e)return!1}}return!0}var bs=e=>"select-multiple"===e.type,ws=e=>rs(e)&&e.isConnected,xs=e=>{for(const t in e)if(ns(e[t]))return!0;return!1};function _s(e,t={}){const n=Array.isArray(e);if(ba(e)||n)for(const n in e)Array.isArray(e[n])||ba(e[n])&&!xs(e[n])?(t[n]=Array.isArray(e[n])?[]:{},_s(e[n],t[n])):va(e[n])||(t[n]=!0);return t}function Es(e,t,n){const r=Array.isArray(e);if(ba(e)||r)for(const r in e)Array.isArray(e[r])||ba(e[r])&&!xs(e[r])?Ca(t)||vs(n[r])?n[r]=Array.isArray(e[r])?_s(e[r],[]):{..._s(e[r])}:Es(e[r],va(t)?{}:t[r],n[r]):n[r]=!ys(e[r],t[r]);return n}var Ss=(e,t)=>Es(e,t,_s(t)),Cs=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Ca(e)?e:t?""===e?NaN:e?+e:e:n&&Wa(e)?new Date(e):r?r(e):e;function Os(e){const t=e.ref;if(!(e.refs?e.refs.every((e=>e.disabled)):t.disabled))return ts(t)?t.files:os(t)?ds(e.refs).value:bs(t)?[...t.selectedOptions].map((({value:e})=>e)):ma(t)?cs(e.refs).value:Cs(Ca(t.value)?e.ref.value:t.value,e)}var Ps=e=>Ca(e)?e:as(e)?e.source:ba(e)?as(e.value)?e.value.source:e.value:e;const js="AsyncFunction";function Ls(e,t,n){const r=Oa(e,n);if(r||ja(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const r=i.join("."),o=Oa(t,r),a=Oa(e,r);if(o&&!Array.isArray(o)&&n!==r)return{name:n};if(a&&a.type)return{name:r,error:a};i.pop()}return{name:n}}const ks={mode:Aa,reValidateMode:Ia,shouldFocusError:!0};function Ts(e={}){let t,n={...ks,...e},r={submitCount:0,isDirty:!1,isLoading:ns(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1},i={},o=(ba(n.defaultValues)||ba(n.values))&&Ea(n.defaultValues||n.values)||{},a=n.shouldUnregister?{}:Ea(o),s={action:!1,mount:!1,watch:!1},l={mount:new Set,unMount:new Set,array:new Set,watch:new Set},c=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:gs(),array:gs(),state:gs()},f=Za(n.mode),h=Za(n.reValidateMode),p=n.criteriaMode===Ma,m=async e=>{if(!n.disabled&&(u.isValid||e)){const e=n.resolver?Ba((await b()).errors):await w(i,!0);e!==r.isValid&&d.state.next({isValid:e})}},g=(e,t)=>{n.disabled||!u.isValidating&&!u.validatingFields||((e||Array.from(l.mount)).forEach((e=>{e&&(t?ka(r.validatingFields,e,t):ms(r.validatingFields,e))})),d.state.next({validatingFields:r.validatingFields,isValidating:!Ba(r.validatingFields)}))},v=(e,t,n,r)=>{const l=Oa(i,e);if(l){const i=Oa(a,e,Ca(n)?Oa(o,e):n);Ca(i)||r&&r.defaultChecked||t?ka(a,e,t?i:Os(l._f)):E(e,i),s.mount&&m()}},y=(e,t,a,s,l)=>{let c=!1,f=!1;const h={name:e};if(!n.disabled){const n=!!(Oa(i,e)&&Oa(i,e)._f&&Oa(i,e)._f.disabled);if(!a||s){u.isDirty&&(f=r.isDirty,r.isDirty=h.isDirty=x(),c=f!==h.isDirty);const i=n||ys(Oa(o,e),t);f=!(n||!Oa(r.dirtyFields,e)),i||n?ms(r.dirtyFields,e):ka(r.dirtyFields,e,!0),h.dirtyFields=r.dirtyFields,c=c||u.dirtyFields&&f!==!i}if(a){const t=Oa(r.touchedFields,e);t||(ka(r.touchedFields,e,a),h.touchedFields=r.touchedFields,c=c||u.touchedFields&&t!==a)}c&&l&&d.state.next(h)}return c?h:{}},b=async e=>{g(e,!0);const t=await n.resolver(a,n.context,((e,t,n,r)=>{const i={};for(const n of e){const e=Oa(t,n);e&&ka(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}})(e||l.mount,i,n.criteriaMode,n.shouldUseNativeValidation));return g(e),t},w=async(e,t,i={valid:!0})=>{for(const s in e){const c=e[s];if(c){const{_f:e,...d}=c;if(e){const d=l.array.has(e.name),f=c._f&&!!(o=c._f)&&!!o.validate&&!!(ns(o.validate)&&o.validate.constructor.name===js||ba(o.validate)&&Object.values(o.validate).find((e=>e.constructor.name===js)));f&&u.validatingFields&&g([s],!0);const h=await ps(c,a,p,n.shouldUseNativeValidation&&!t,d);if(f&&u.validatingFields&&g([s]),h[e.name]&&(i.valid=!1,t))break;!t&&(Oa(h,e.name)?d?es(r.errors,h,e.name):ka(r.errors,e.name,h[e.name]):ms(r.errors,e.name))}!Ba(d)&&await w(d,t,i)}}var o;return i.valid},x=(e,t)=>!n.disabled&&(e&&t&&ka(a,e,t),!ys(L(),o)),_=(e,t,n)=>qa(e,l,{...s.mount?a:Ca(t)?o:Wa(e)?{[e]:t}:t},n,t),E=(e,t,n={})=>{const r=Oa(i,e);let o=t;if(r){const n=r._f;n&&(!n.disabled&&ka(a,e,Cs(t,n)),o=rs(n.ref)&&va(t)?"":t,bs(n.ref)?[...n.ref.options].forEach((e=>e.selected=o.includes(e.value))):n.refs?ma(n.ref)?n.refs.length>1?n.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(o)?!!o.find((t=>t===e.value)):o===e.value))):n.refs[0]&&(n.refs[0].checked=!!o):n.refs.forEach((e=>e.checked=e.value===o)):ts(n.ref)?n.ref.value="":(n.ref.value=o,n.ref.type||d.values.next({name:e,values:{...a}})))}(n.shouldDirty||n.shouldTouch)&&y(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&j(e)},S=(e,t,n)=>{for(const r in t){const o=t[r],a=`${e}.${r}`,s=Oa(i,a);(l.array.has(e)||ba(o)||s&&!s._f)&&!ga(o)?S(a,o,n):E(a,o,n)}},C=(e,t,n={})=>{const c=Oa(i,e),f=l.array.has(e),h=Ea(t);ka(a,e,h),f?(d.array.next({name:e,values:{...a}}),(u.isDirty||u.dirtyFields)&&n.shouldDirty&&d.state.next({name:e,dirtyFields:Ss(o,a),isDirty:x(e,h)})):!c||c._f||va(h)?E(e,h,n):S(e,h,n),Qa(e,l)&&d.state.next({...r}),d.values.next({name:s.mount?e:void 0,values:{...a}})},O=async e=>{s.mount=!0;const o=e.target;let v=o.name,x=!0;const _=Oa(i,v),E=e=>{x=Number.isNaN(e)||ga(e)&&isNaN(e.getTime())||ys(e,Oa(a,v,e))};if(_){let s,C;const O=o.type?Os(_._f):wa(e),P=e.type===Ta||"focusout"===e.type,L=!((S=_._f).mount&&(S.required||S.min||S.max||S.maxLength||S.minLength||S.pattern||S.validate)||n.resolver||Oa(r.errors,v)||_._f.deps)||((e,t,n,r,i)=>!i.isOnAll&&(!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:!(n?r.isOnChange:i.isOnChange)||e))(P,Oa(r.touchedFields,v),r.isSubmitted,h,f),k=Qa(v,l,P);ka(a,v,O),P?(_._f.onBlur&&_._f.onBlur(e),t&&t(0)):_._f.onChange&&_._f.onChange(e);const T=y(v,O,P,!1),I=!Ba(T)||k;if(!P&&d.values.next({name:v,type:e.type,values:{...a}}),L)return u.isValid&&("onBlur"===n.mode?P&&m():m()),I&&d.state.next({name:v,...k?{}:T});if(!P&&k&&d.state.next({...r}),n.resolver){const{errors:e}=await b([v]);if(E(O),x){const t=Ls(r.errors,i,v),n=Ls(e,i,t.name||v);s=n.error,v=n.name,C=Ba(e)}}else g([v],!0),s=(await ps(_,a,p,n.shouldUseNativeValidation))[v],g([v]),E(O),x&&(s?C=!1:u.isValid&&(C=await w(i,!0)));x&&(_._f.deps&&j(_._f.deps),((e,i,o,a)=>{const s=Oa(r.errors,e),l=u.isValid&&Pa(i)&&r.isValid!==i;var f;if(n.delayError&&o?(f=()=>((e,t)=>{ka(r.errors,e,t),d.state.next({errors:r.errors})})(e,o),t=e=>{clearTimeout(c),c=setTimeout(f,e)},t(n.delayError)):(clearTimeout(c),t=null,o?ka(r.errors,e,o):ms(r.errors,e)),(o?!ys(s,o):s)||!Ba(a)||l){const t={...a,...l&&Pa(i)?{isValid:i}:{},errors:r.errors,name:e};r={...r,...t},d.state.next(t)}})(v,C,s,T))}var S},P=(e,t)=>{if(Oa(r.errors,t)&&e.focus)return e.focus(),1},j=async(e,t={})=>{let o,a;const s=Ha(e);if(n.resolver){const t=await(async e=>{const{errors:t}=await b(e);if(e)for(const n of e){const e=Oa(t,n);e?ka(r.errors,n,e):ms(r.errors,n)}else r.errors=t;return t})(Ca(e)?e:s);o=Ba(t),a=e?!s.some((e=>Oa(t,e))):o}else e?(a=(await Promise.all(s.map((async e=>{const t=Oa(i,e);return await w(t&&t._f?{[e]:t}:t)})))).every(Boolean),(a||r.isValid)&&m()):a=o=await w(i);return d.state.next({...!Wa(e)||u.isValid&&o!==r.isValid?{}:{name:e},...n.resolver||!e?{isValid:o}:{},errors:r.errors}),t.shouldFocus&&!a&&Ja(i,P,e?s:l.mount),a},L=e=>{const t={...s.mount?a:o};return Ca(e)?t:Wa(e)?Oa(t,e):e.map((e=>Oa(t,e)))},k=(e,t)=>({invalid:!!Oa((t||r).errors,e),isDirty:!!Oa((t||r).dirtyFields,e),error:Oa((t||r).errors,e),isValidating:!!Oa(r.validatingFields,e),isTouched:!!Oa((t||r).touchedFields,e)}),T=(e,t,n)=>{const o=(Oa(i,e,{_f:{}})._f||{}).ref,a=Oa(r.errors,e)||{},{ref:s,message:l,type:c,...u}=a;ka(r.errors,e,{...u,...t,ref:o}),d.state.next({name:e,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&o&&o.focus&&o.focus()},I=(e,t={})=>{for(const s of e?Ha(e):l.mount)l.mount.delete(s),l.array.delete(s),t.keepValue||(ms(i,s),ms(a,s)),!t.keepError&&ms(r.errors,s),!t.keepDirty&&ms(r.dirtyFields,s),!t.keepTouched&&ms(r.touchedFields,s),!t.keepIsValidating&&ms(r.validatingFields,s),!n.shouldUnregister&&!t.keepDefaultValue&&ms(o,s);d.values.next({values:{...a}}),d.state.next({...r,...t.keepDirty?{isDirty:x()}:{}}),!t.keepIsValid&&m()},A=({disabled:e,name:t,field:n,fields:r,value:i})=>{if(Pa(e)&&s.mount||e){const o=e?void 0:Ca(i)?Os(n?n._f:Oa(r,t)._f):i;(e||!e&&!Ca(o))&&ka(a,t,o),y(t,o,!1,!1,!0)}},M=(e,t={})=>{let r=Oa(i,e);const a=Pa(t.disabled)||Pa(n.disabled);return ka(i,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),l.mount.add(e),r?A({field:r,disabled:Pa(t.disabled)?t.disabled:n.disabled,name:e,value:t.value}):v(e,!0,t.value),{...a?{disabled:t.disabled||n.disabled}:{},...n.progressive?{required:!!t.required,min:Ps(t.min),max:Ps(t.max),minLength:Ps(t.minLength),maxLength:Ps(t.maxLength),pattern:Ps(t.pattern)}:{},name:e,onChange:O,onBlur:O,ref:a=>{if(a){M(e,t),r=Oa(i,e);const n=Ca(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,s=(e=>os(e)||ma(e))(n),l=r._f.refs||[];if(s?l.find((e=>e===n)):n===r._f.ref)return;ka(i,e,{_f:{...r._f,...s?{refs:[...l.filter(ws),n,...Array.isArray(Oa(o,e))?[{}]:[]],ref:{type:n.type,name:e}}:{ref:n}}}),v(e,!1,void 0,n)}else r=Oa(i,e,{}),r._f&&(r._f.mount=!1),(n.shouldUnregister||t.shouldUnregister)&&(!xa(l.array,e)||!s.action)&&l.unMount.add(e)}}},N=()=>n.shouldFocusError&&Ja(i,P,l.mount),R=(e,t)=>async o=>{let s;if(o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist()),n.disabled)return void(t&&await t({...r.errors},o));let l=Ea(a);if(d.state.next({isSubmitting:!0}),n.resolver){const{errors:e,values:t}=await b();r.errors=e,l=t}else await w(i);if(ms(r.errors,"root"),Ba(r.errors)){d.state.next({errors:{}});try{await e(l,o)}catch(e){s=e}}else t&&await t({...r.errors},o),N(),setTimeout(N);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Ba(r.errors)&&!s,submitCount:r.submitCount+1,errors:r.errors}),s)throw s},F=(e,t={})=>{const c=e?Ea(e):o,f=Ea(c),h=Ba(e),p=h?o:f;if(t.keepDefaultValues||(o=c),!t.keepValues){if(t.keepDirtyValues){const e=new Set([...l.mount,...Object.keys(Ss(o,a))]);for(const t of Array.from(e))Oa(r.dirtyFields,t)?ka(p,t,Oa(a,t)):C(t,Oa(p,t))}else{if(_a&&Ca(e))for(const e of l.mount){const t=Oa(i,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(rs(e)){const t=e.closest("form");if(t){t.reset();break}}}}i={}}a=n.shouldUnregister?t.keepDefaultValues?Ea(o):{}:Ea(p),d.array.next({values:{...p}}),d.values.next({values:{...p}})}l={mount:t.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},s.mount=!u.isValid||!!t.keepIsValid||!!t.keepDirtyValues,s.watch=!!n.shouldUnregister,d.state.next({submitCount:t.keepSubmitCount?r.submitCount:0,isDirty:!h&&(t.keepDirty?r.isDirty:!(!t.keepDefaultValues||ys(e,o))),isSubmitted:!!t.keepIsSubmitted&&r.isSubmitted,dirtyFields:h?{}:t.keepDirtyValues?t.keepDefaultValues&&a?Ss(o,a):r.dirtyFields:t.keepDefaultValues&&e?Ss(o,e):t.keepDirty?r.dirtyFields:{},touchedFields:t.keepTouched?r.touchedFields:{},errors:t.keepErrors?r.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&r.isSubmitSuccessful,isSubmitting:!1})},D=(e,t)=>F(ns(e)?e(a):e,t);return{control:{register:M,unregister:I,getFieldState:k,handleSubmit:R,setError:T,_executeSchema:b,_getWatch:_,_getDirty:x,_updateValid:m,_removeUnmounted:()=>{for(const e of l.unMount){const t=Oa(i,e);t&&(t._f.refs?t._f.refs.every((e=>!ws(e))):!ws(t._f.ref))&&I(e)}l.unMount=new Set},_updateFieldArray:(e,t=[],l,c,f=!0,h=!0)=>{if(c&&l&&!n.disabled){if(s.action=!0,h&&Array.isArray(Oa(i,e))){const t=l(Oa(i,e),c.argA,c.argB);f&&ka(i,e,t)}if(h&&Array.isArray(Oa(r.errors,e))){const t=l(Oa(r.errors,e),c.argA,c.argB);f&&ka(r.errors,e,t),((e,t)=>{!Sa(Oa(e,t)).length&&ms(e,t)})(r.errors,e)}if(u.touchedFields&&h&&Array.isArray(Oa(r.touchedFields,e))){const t=l(Oa(r.touchedFields,e),c.argA,c.argB);f&&ka(r.touchedFields,e,t)}u.dirtyFields&&(r.dirtyFields=Ss(o,a)),d.state.next({name:e,isDirty:x(e,t),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ka(a,e,t)},_updateDisabledField:A,_getFieldArray:e=>Sa(Oa(s.mount?a:o,e,n.shouldUnregister?Oa(o,e,[]):[])),_reset:F,_resetDefaultValues:()=>ns(n.defaultValues)&&n.defaultValues().then((e=>{D(e,n.resetOptions),d.state.next({isLoading:!1})})),_updateFormState:e=>{r={...r,...e}},_disableForm:e=>{Pa(e)&&(d.state.next({disabled:e}),Ja(i,((t,n)=>{const r=Oa(i,n);r&&(t.disabled=r._f.disabled||e,Array.isArray(r._f.refs)&&r._f.refs.forEach((t=>{t.disabled=r._f.disabled||e})))}),0,!1))},_subjects:d,_proxyFormState:u,_setErrors:e=>{r.errors=e,d.state.next({errors:r.errors,isValid:!1})},get _fields(){return i},get _formValues(){return a},get _state(){return s},set _state(e){s=e},get _defaultValues(){return o},get _names(){return l},set _names(e){l=e},get _formState(){return r},set _formState(e){r=e},get _options(){return n},set _options(e){n={...n,...e}}},trigger:j,register:M,handleSubmit:R,watch:(e,t)=>ns(e)?d.values.subscribe({next:n=>e(_(void 0,t),n)}):_(e,t,!0),setValue:C,getValues:L,reset:D,resetField:(e,t={})=>{Oa(i,e)&&(Ca(t.defaultValue)?C(e,Ea(Oa(o,e))):(C(e,t.defaultValue),ka(o,e,Ea(t.defaultValue))),t.keepTouched||ms(r.touchedFields,e),t.keepDirty||(ms(r.dirtyFields,e),r.isDirty=t.defaultValue?x(e,Ea(Oa(o,e))):x()),t.keepError||(ms(r.errors,e),u.isValid&&m()),d.state.next({...r}))},clearErrors:e=>{e&&Ha(e).forEach((e=>ms(r.errors,e))),d.state.next({errors:e?r.errors:{}})},unregister:I,setError:T,setFocus:(e,t={})=>{const n=Oa(i,e),r=n&&n._f;if(r){const e=r.refs?r.refs[0]:r.ref;e.focus&&(e.focus(),t.shouldSelect&&ns(e.select)&&e.select())}},getFieldState:k}}function Is(e={}){const t=Pe.useRef(void 0),n=Pe.useRef(void 0),[r,i]=Pe.useState({isDirty:!1,isValidating:!1,isLoading:ns(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ns(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ts(e),formState:r});const o=t.current.control;return o._options=e,Ga({subject:o._subjects.state,next:e=>{za(e,o._proxyFormState,o._updateFormState,!0)&&i({...o._formState})}}),Pe.useEffect((()=>o._disableForm(e.disabled)),[o,e.disabled]),Pe.useEffect((()=>{if(o._proxyFormState.isDirty){const e=o._getDirty();e!==r.isDirty&&o._subjects.state.next({isDirty:e})}}),[o,r.isDirty]),Pe.useEffect((()=>{e.values&&!ys(e.values,n.current)?(o._reset(e.values,o._options.resetOptions),n.current=e.values,i((e=>({...e})))):o._resetDefaultValues()}),[e.values,o]),Pe.useEffect((()=>{e.errors&&o._setErrors(e.errors)}),[e.errors,o]),Pe.useEffect((()=>{o._state.mount||(o._updateValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()})),Pe.useEffect((()=>{e.shouldUnregister&&o._subjects.values.next({values:o._getWatch()})}),[e.shouldUnregister,o]),t.current.formState=Va(r,o),t.current}function As(e){return As="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},As(e)}function Ms(){Ms=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==As(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(As(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function Ns(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function Rs(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Fs(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Fs(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Fs(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const Ds=function(e){var t,n=e.categories||[],r=(e.categories||[]).map((function(e){return e.label||e.name})),i=(e.patternCategories||[]).map((function(e){return e.label||e.name})),o=Rs((0,Pe.useState)(e.copyPatternId||0),1)[0],a=Rs((0,Pe.useState)(e.syncedDefaultStatus||"synced"),1)[0],c=Rs((0,Pe.useState)(e.syncedDisabled||!1),1)[0],d=Rs((0,Pe.useState)(!1),2),f=d[0],h=d[1],p=Rs((0,Pe.useState)(e.isEditMode||!1),2),m=p[0],g=(p[1],Is({defaultValues:{patternId:e.patternId||0,patternNonce:e.patternNonce||"",patternTitle:e.patternTitle||"",patternCategories:i||[],patternSyncStatus:e.patternSyncStatus||a,patternCopyId:o}})),v=g.control,y=(g.getValues,g.handleSubmit),b=(g.reset,g.setError),w=(g.trigger,g.setValue,Ya({control:v}),Ua({control:v})),x=w.errors,_=(w.isDirty,w.dirtyFields,function(){var t,r=(t=Ms().mark((function t(r){var i,o,a,s,l;return Ms().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return h(!0),i=r.patternCategories.map((function(e){return{name:e,id:(t=e,r=n.find((function(e){return(e.label||e.name).toLowerCase()===t.toLowerCase()})),r?r.id:0)};var t,r})),o=m?"/dlxplugins/pattern-wrangler/v1/patterns/update/":"/dlxplugins/pattern-wrangler/v1/patterns/create/",t.next=5,u()({path:o,method:"POST",data:{patternId:r.patternId,patternNonce:r.patternNonce,nonce:dlxEnhancedPatternsView.createNonce,patternTitle:r.patternTitle,patternCategories:i,patternSyncStatus:r.patternSyncStatus,patternCopyId:r.patternCopyId}});case 5:null!=(a=t.sent)&&a.error?b("patternTitle",{message:a.error}):(s=a.patternId,m?e.onEdit(a):(l=encodeURIComponent(window.location.href),window.location.href="".concat(dlxEnhancedPatternsView.getSiteBaseUrl,"post.php?post=").concat(s,"&action=edit&redirect_to=").concat(l))),h(!1);case 8:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(e){Ns(o,r,i,a,s,"next",e)}function s(e){Ns(o,r,i,a,s,"throw",e)}a(void 0)}))});return function(_x){return r.apply(this,arguments)}}());return Le().createElement(Le().Fragment,null,Le().createElement(l.Modal,{title:e.title||(0,s.__)("Add Pattern","pattern-wrangler"),onRequestClose:e.onRequestClose,focusOnMount:"firstContentElement"},Le().createElement("div",{className:"dlx-pw-modal-content"},Le().createElement("form",{onSubmit:y(_)},Le().createElement("div",{className:"dlx-pw-modal-admin-row"},Le().createElement(Xa,{control:v,name:"patternTitle",rules:{required:(0,s.__)("Pattern title is required.","pattern-wrangler")},render:function(e){var t=e.field;return Le().createElement(l.TextControl,{label:(0,s.__)("Pattern Title","pattern-wrangler"),help:(0,s.__)("Enter the title of the pattern.","pattern-wrangler"),value:t.value,onChange:function(e){return t.onChange(e)},disabled:f})}})),Le().createElement("div",{className:"dlx-pw-modal-admin-row"},Le().createElement(Xa,{control:v,name:"patternCategories[]",render:function(e){var t=e.field;return Le().createElement(Le().Fragment,null,Le().createElement(l.FormTokenField,{label:(0,s.__)("Categories","pattern-wrangler"),help:(0,s.__)("Enter the categories of the pattern.","pattern-wrangler"),value:t.value,onChange:function(e){t.onChange(e)},tokenizeOnSpace:!1,allowMultiple:!0,placeholder:(0,s.__)("Add a category","pattern-wrangler"),suggestions:r,disabled:f,__experimentalShowHowTo:!1}),Le().createElement("p",{className:"description"},(0,s.__)("Separate with commas or press the Enter key.","pattern-wrangler")))}})),Le().createElement("div",{className:"dlx-pw-modal-admin-row"},Le().createElement(Xa,{control:v,name:"patternSyncStatus",render:function(e){var t=e.field;return Le().createElement(Le().Fragment,null,Le().createElement(l.__experimentalToggleGroupControl,{label:(0,s.__)("Sync Status","pattern-wrangler"),isAdaptiveWidth:!0,value:t.value,onChange:function(e){t.onChange(e)},disabled:f||c},Le().createElement(l.__experimentalToggleGroupControlOption,{value:"synced",label:(0,s.__)("Synced","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Synced","pattern-wrangler"),disabled:c}),Le().createElement(l.__experimentalToggleGroupControlOption,{value:"unsynced",label:(0,s.__)("Unsynced","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Unsynced","pattern-wrangler"),disabled:c})))}})),Le().createElement("div",{className:"dlx-pw-modal-admin-row dlx-pw-modal-admin-row-buttons"},Le().createElement(l.Button,{variant:"primary",type:"submit",disabled:f},(t=(0,s.__)("Add Pattern","pattern-wrangler"),m&&(t=(0,s.__)("Save Pattern","pattern-wrangler")),f&&(t=(0,s.__)("Saving Pattern…","pattern-wrangler")),t)),Le().createElement(l.Button,{variant:"secondary",onClick:e.onRequestClose,disabled:f},(0,s.__)("Cancel","pattern-wrangler"))),(null==x?void 0:x.patternTitle)&&Le().createElement(ua,{className:"dlx-pw-admin-notice",status:"error",inline:!0,icon:function(){return Le().createElement(pa,null)}},x.patternTitle.message)))))};function Vs(e){return Vs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Vs(e)}function Bs(){Bs=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==Vs(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Vs(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function zs(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function Hs(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const $s=function(e){var t,n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Hs(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hs(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,Pe.useState)(!1),2),r=n[0],i=n[1],o=Is({defaultValues:{items:e.items||[],patternNonce:e.patternNonce||"",forceDelete:!1}}),a=o.control,c=(o.getValues,o.handleSubmit),d=(o.reset,o.setError,o.trigger,o.setValue,Ya({control:a}),Ua({control:a})),f=d.errors,h=(d.isDirty,d.dirtyFields,function(){var t,n=(t=Bs().mark((function t(n){var r,o;return Bs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i(!0),r=n.items.map((function(e){return{id:e.id,nonce:e.editNonce}})),t.next=5,u()({path:"/dlxplugins/pattern-wrangler/v1/patterns/pause/",method:"POST",data:{items:r}});case 5:o=t.sent,e.onPause(o,r),i(!1);case 8:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(e){zs(o,r,i,a,s,"next",e)}function s(e){zs(o,r,i,a,s,"throw",e)}a(void 0)}))});return function(_x){return n.apply(this,arguments)}}());return Le().createElement(Le().Fragment,null,Le().createElement(l.Modal,{title:1===e.items.length?(0,s.__)("Disable Pattern","pattern-wrangler"):(0,s._n)("Disable Pattern","Disable Patterns",e.items.length,"pattern-wrangler"),onRequestClose:e.onRequestClose,focusOnMount:"firstContentElement"},Le().createElement("div",{className:"dlx-pw-modal-content"},Le().createElement("form",{onSubmit:c(h)},Le().createElement("div",{className:"dlx-pw-modal-admin-row dlx-pw-modal-admin-row-buttons"},Le().createElement(l.Button,{variant:"primary",type:"submit",disabled:r},(t=(0,s._n)("Disable Pattern","Disable Patterns",e.items.length,"pattern-wrangler"),r&&(t=(0,s._n)("Disabling Pattern…","Disabling Patterns…",e.items.length,"pattern-wrangler")),t)),Le().createElement(l.Button,{variant:"secondary",onClick:e.onRequestClose,disabled:r},(0,s.__)("Cancel","pattern-wrangler"))),(null==f?void 0:f.patternTitle)&&Le().createElement(ua,{className:"dlx-pw-admin-notice",status:"error",inline:!0,icon:function(){return Le().createElement(pa,null)}},f.patternTitle.message)))))};function Gs(e){return Gs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gs(e)}function Us(){Us=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==Gs(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Gs(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function Ws(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function qs(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const Ys=function(e){var t,n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return qs(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?qs(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,Pe.useState)(!1),2),r=n[0],i=n[1],o=Is({defaultValues:{items:e.items||[],patternNonce:e.patternNonce||"",forceDelete:!1}}),a=o.control,c=(o.getValues,o.handleSubmit),d=(o.reset,o.setError,o.trigger,o.setValue,Ya({control:a}),Ua({control:a})),f=d.errors,h=(d.isDirty,d.dirtyFields,function(){var t,n=(t=Us().mark((function t(n){var r,o;return Us().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i(!0),r=n.items.map((function(e){return{id:e.id,nonce:e.editNonce}})),t.next=5,u()({path:"/dlxplugins/pattern-wrangler/v1/patterns/publish/",method:"POST",data:{items:r}});case 5:o=t.sent,e.onPublish(o,r),i(!1);case 8:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(e){Ws(o,r,i,a,s,"next",e)}function s(e){Ws(o,r,i,a,s,"throw",e)}a(void 0)}))});return function(_x){return n.apply(this,arguments)}}());return Le().createElement(Le().Fragment,null,Le().createElement(l.Modal,{title:1===e.items.length?(0,s.__)("Publish Pattern","pattern-wrangler"):(0,s._n)("Publish Pattern","Publish Patterns",e.items.length,"pattern-wrangler"),onRequestClose:e.onRequestClose,focusOnMount:"firstContentElement"},Le().createElement("div",{className:"dlx-pw-modal-content"},Le().createElement("form",{onSubmit:c(h)},Le().createElement("div",{className:"dlx-pw-modal-admin-row dlx-pw-modal-admin-row-buttons"},Le().createElement(l.Button,{variant:"primary",type:"submit",disabled:r},(t=(0,s._n)("Publish Pattern","Publish Patterns",e.items.length,"pattern-wrangler"),r&&(t=(0,s._n)("Publishing Pattern…","Publishing Patterns…",e.items.length,"pattern-wrangler")),t)),Le().createElement(l.Button,{variant:"secondary",onClick:e.onRequestClose,disabled:r},(0,s.__)("Cancel","pattern-wrangler"))),(null==f?void 0:f.patternTitle)&&Le().createElement(ua,{className:"dlx-pw-admin-notice",status:"error",inline:!0,icon:function(){return Le().createElement(pa,null)}},f.patternTitle.message)))))};function Xs(e){return Xs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xs(e)}function Ks(){Ks=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==Xs(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Xs(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function Zs(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function Qs(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const Js=function(e){var t,n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Qs(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qs(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,Pe.useState)(!1),2),r=n[0],i=n[1],o=Is({defaultValues:{items:e.items||[],patternNonce:e.patternNonce||"",forceDelete:!1}}),a=o.control,c=(o.getValues,o.handleSubmit),d=(o.reset,o.setError,o.trigger,o.setValue,Ya({control:a}),Ua({control:a})),f=d.errors,h=(d.isDirty,d.dirtyFields,function(){var t,n=(t=Ks().mark((function t(n){var r,o;return Ks().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i(!0),r=n.items.map((function(e){return{id:e.id,nonce:e.editNonce}})),t.next=5,u()({path:"/dlxplugins/pattern-wrangler/v1/patterns/publish/",method:"POST",data:{items:r}});case 5:o=t.sent,e.onReenable(o,r),i(!1);case 8:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(e){Zs(o,r,i,a,s,"next",e)}function s(e){Zs(o,r,i,a,s,"throw",e)}a(void 0)}))});return function(_x){return n.apply(this,arguments)}}());return Le().createElement(Le().Fragment,null,Le().createElement(l.Modal,{title:1===e.items.length?(0,s.__)("Re-enable Pattern","pattern-wrangler"):(0,s._n)("Re-enable Pattern","Re-enable Patterns",e.items.length,"pattern-wrangler"),onRequestClose:e.onRequestClose,focusOnMount:"firstContentElement"},Le().createElement("div",{className:"dlx-pw-modal-content"},Le().createElement("form",{onSubmit:c(h)},Le().createElement("div",{className:"dlx-pw-modal-admin-row dlx-pw-modal-admin-row-buttons"},Le().createElement(l.Button,{variant:"primary",type:"submit",disabled:r},(t=(0,s._n)("Re-enable Pattern","Re-enable Patterns",e.items.length,"pattern-wrangler"),r&&(t=(0,s._n)("Re-enabling Pattern…","Re-enabling Patterns…",e.items.length,"pattern-wrangler")),t)),Le().createElement(l.Button,{variant:"secondary",onClick:e.onRequestClose,disabled:r},(0,s.__)("Cancel","pattern-wrangler"))),(null==f?void 0:f.patternTitle)&&Le().createElement(ua,{className:"dlx-pw-admin-notice",status:"error",inline:!0,icon:function(){return Le().createElement(pa,null)}},f.patternTitle.message)))))};function el(e){return el="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},el(e)}function tl(){tl=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==el(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(el(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function nl(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function rl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const il=function(e){var t,n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return rl(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?rl(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,Pe.useState)(!1),2),r=n[0],i=n[1],o=Is({defaultValues:{items:e.items||[],patternNonce:e.patternNonce||"",forceDelete:!1}}),a=o.control,c=(o.getValues,o.handleSubmit),d=(o.reset,o.setError,o.trigger,o.setValue,Ya({control:a}),Ua({control:a})),f=d.errors,h=(d.isDirty,d.dirtyFields,function(){var t,n=(t=tl().mark((function t(n){var r,o;return tl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i(!0),r=n.items.map((function(e){return{id:e.id,nonce:e.editNonce}})),t.next=5,u()({path:"/dlxplugins/pattern-wrangler/v1/patterns/delete/",method:"POST",data:{items:r}});case 5:o=t.sent,e.onDelete(o,r),i(!1);case 8:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(e){nl(o,r,i,a,s,"next",e)}function s(e){nl(o,r,i,a,s,"throw",e)}a(void 0)}))});return function(_x){return n.apply(this,arguments)}}());return Le().createElement(Le().Fragment,null,Le().createElement(l.Modal,{title:1===e.items.length?(0,s.__)("Delete Pattern","pattern-wrangler"):(0,s._n)("Delete Pattern","Delete Patterns",e.items.length,"pattern-wrangler"),onRequestClose:e.onRequestClose,focusOnMount:"firstContentElement"},Le().createElement("div",{className:"dlx-pw-modal-content"},Le().createElement("form",{onSubmit:c(h)},Le().createElement("div",{className:"dlx-pw-modal-admin-row dlx-pw-modal-admin-row-buttons"},Le().createElement(l.Button,{variant:"primary",type:"submit",isDestructive:!0,disabled:r},(t=(0,s._n)("Delete Pattern","Delete Patterns",e.items.length,"pattern-wrangler"),r&&(t=(0,s._n)("Deleting Pattern…","Deleting Patterns…",e.items.length,"pattern-wrangler")),t)),Le().createElement(l.Button,{variant:"secondary",onClick:e.onRequestClose,disabled:r},(0,s.__)("Cancel","pattern-wrangler"))),(null==f?void 0:f.patternTitle)&&Le().createElement(ua,{className:"dlx-pw-admin-notice",status:"error",inline:!0,icon:function(){return Le().createElement(pa,null)}},f.patternTitle.message)))))};function ol(e){return ol="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ol(e)}function al(){al=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==ol(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(ol(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function sl(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function ll(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){sl(o,r,i,a,s,"next",e)}function s(e){sl(o,r,i,a,s,"throw",e)}a(void 0)}))}}function cl(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ul(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ul(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ul(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const dl=function(e){var t=cl((0,Pe.useState)(dlxEnhancedPatternsView.isMultisite),1)[0],n=cl((0,Pe.useState)(null),2),r=n[0],i=n[1],o=cl((0,Pe.useState)(null),2),a=o[0],c=o[1],u=function(){var e=ll(al().mark((function e(t,n){var r,i;return al().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=document.createElement("button")).classList.add("dlx-pw-copy-shortcode"),r.innerHTML='<span class="dashicons dashicons-clipboard"></span>',i=function(){var e=ll(al().mark((function e(){var t,i,o;return al().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=!1,null===(t=navigator.clipboard)||void 0===t||!t.writeText){e.next=10;break}return e.prev=2,e.next=5,navigator.clipboard.writeText(n);case 5:i=!0,e.next=10;break;case 8:e.prev=8,e.t0=e.catch(2);case 10:if(!i){(o=document.createElement("textarea")).value=n,o.style.position="fixed",o.style.opacity="0",o.style.pointerEvents="none",document.body.appendChild(o),o.select();try{document.execCommand("copy"),i=!0}catch(e){}document.body.removeChild(o)}i&&(r.innerHTML='<span class="dashicons dashicons-yes"></span>',setTimeout((function(){r.innerHTML='<span class="dashicons dashicons-clipboard"></span>'}),1500));case 12:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(){return e.apply(this,arguments)}}(),r.addEventListener("click",i),t.parentElement.appendChild(r),e.abrupt("return",(function(){r.removeEventListener("click",i),r.remove()}));case 7:case"end":return e.stop()}}),e)})));return function(_x,t){return e.apply(this,arguments)}}();(0,Pe.useEffect)((function(){r&&u(r,d())}),[r]),(0,Pe.useEffect)((function(){a&&u(a,f())}),[a]);var d=function(){return t&&e.item.siteId?'[wp_block slug="'.concat(e.item.slug,'" site_id="').concat(e.item.siteId,'"]'):'[wp_block slug="'.concat(e.item.slug,'"]')},f=function(){return t&&e.item.siteId?"<?php function_exists( 'pw_wp_block' ) ? pw_wp_block( '".concat(e.item.slug,"', ").concat(e.item.siteId,", $echo = true ) : ''; ?>"):"<?php function_exists( 'pw_wp_block' ) ? pw_wp_block( '".concat(e.item.slug,"', null, $echo = true ) : ''; ?>")};return Le().createElement(Le().Fragment,null,Le().createElement(l.Modal,{title:(0,s.__)("Get Code","pattern-wrangler"),onRequestClose:e.onRequestClose,focusOnMount:"firstContentElement"},Le().createElement("div",{className:"dlx-pw-modal-content"},Le().createElement("p",{className:"description"},(0,s.__)("Use the fields below to get a shortcode or PHP function to output the pattern on your site.","pattern-wrangler")),Le().createElement("div",{className:"dlx-pw-modal-admin-row"},Le().createElement(l.TextControl,{label:(0,s.__)("Pattern Shortcode","pattern-wrangler"),value:d(),disabled:!0,ref:i,className:"dlx-pw-modal-admin-row-input"})),Le().createElement("div",{className:"dlx-pw-modal-admin-row"},Le().createElement(l.TextControl,{label:(0,s.__)("Pattern PHP Function","pattern-wrangler"),value:f(),disabled:!0,ref:c,className:"dlx-pw-modal-admin-row-input"})),Le().createElement("div",{className:"dlx-pw-modal-admin-row dlx-pw-modal-admin-row-buttons"},Le().createElement(l.Button,{variant:"secondary",onClick:e.onRequestClose},(0,s.__)("Cancel","pattern-wrangler"))))))};function fl(e){return fl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fl(e)}function hl(e){return function(e){if(Array.isArray(e))return pl(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return pl(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pl(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ml(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function gl(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ml(Object(n),!0).forEach((function(t){vl(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ml(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function vl(e,t,n){return(t=function(e){var t=function(e){if("object"!=fl(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=fl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==fl(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function yl(){yl=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==fl(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(fl(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function bl(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}var wl={patterns:[],categories:[],assets:[],data:{patterns:[],categories:[],assets:[]},loading:!1,error:null},xl={setPatterns:function(e){return{type:"SET_PATTERNS",patterns:e}},setPattern:function(e,t,n,r){return{type:"SET_PATTERN",patternId:e,patternTitle:t,patternCategories:n,patternCategorySlugs:r}},addPattern:function(e){return{type:"ADD_PATTERN",pattern:e}},disablePatterns:function(e){return{type:"DISABLE_PATTERNS",patternIdsAndNonces:e}},enablePatterns:function(e){return{type:"ENABLE_PATTERNS",patternIdsAndNonces:e}},setCategory:function(e,t){return{type:"SET_CATEGORY",categoryId:e,categoryTermData:t}},upsertCategory:function(e){return{type:"UPSERT_CATEGORY",categoryData:e}},setCategories:function(e){return{type:"SET_CATEGORIES",categories:e}},setAssets:function(e){return{type:"SET_ASSETS",assets:e}},setData:function(e){return{type:"SET_DATA",data:e}},setAllData:function(e,t,n,r){return{type:"SET_ALL_DATA",patterns:e,categories:t,assets:n,data:r}},setLoading:function(e){return{type:"SET_LOADING",loading:e}},setError:function(e){return{type:"SET_ERROR",error:e}},fetchData:function(){return function(){var e,t=(e=yl().mark((function e(t){var n,r;return yl().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.dispatch,e.prev=1,n(xl.setLoading(!0)),n(xl.setError(null)),e.next=6,u()({path:(0,So.addQueryArgs)("/dlxplugins/pattern-wrangler/v1/patterns/all/",{nonce:dlxEnhancedPatternsView.getNonce}),method:"GET"});case 6:r=e.sent,n(r?xl.setAllData(r.patterns,r.categories,r.assets,r):xl.setError("Failed to fetch data")),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(1),n(xl.setError(e.t0.message||"Network error occurred"));case 13:return e.prev=13,n(xl.setLoading(!1)),e.finish(13);case 16:case"end":return e.stop()}}),e,null,[[1,10,13,16]])})),function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){bl(o,r,i,a,s,"next",e)}function s(e){bl(o,r,i,a,s,"throw",e)}a(void 0)}))});return function(_x){return t.apply(this,arguments)}}()},deletePatterns:function(e){return{type:"DELETE_PATTERNS",patternIdsAndNonces:e}}},_l=(0,ai.createReduxStore)("dlxplugins/pattern-wrangler/patterns",{reducer:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:wl,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_ALL_DATA":return gl(gl({},e),{},{patterns:t.patterns,categories:t.categories,assets:t.assets,data:t.data,loading:!1,error:null});case"SET_PATTERNS":return gl(gl({},e),{},{patterns:t.patterns});case"SET_CATEGORIES":return gl(gl({},e),{},{categories:t.categories});case"UPSERT_CATEGORY":var n=gl(gl({},t.categoryData),e.categories);return gl(gl({},e),{},{categories:n,data:gl(gl({},e.data),{},{categories:n})});case"SET_PATTERN":var r=t.patternCategories,i=t.patternCategorySlugs,o=e.patterns.map((function(e){return e.id===t.patternId?gl(gl({},e),{title:t.patternTitle,categories:r,categorySlugs:i}):e}));return gl(gl({},e),{},{patterns:o,data:gl(gl({},e.data),{},{patterns:o})});case"ADD_PATTERN":return gl(gl({},e),{},{patterns:[].concat(hl(e.patterns),[t.pattern]),data:gl(gl({},e.data),{},{patterns:[].concat(hl(e.patterns),[t.pattern])})});case"SET_CATEGORY":var a=e.categories.map((function(e){return e.id===t.categoryId?gl(gl({},e),t.categoryTermData):e}));return gl(gl({},e),{},{categories:a,data:gl(gl({},e.data),{},{categories:a})});case"SET_DATA":return gl(gl({},e),{},{data:t.data});case"SET_ASSETS":return gl(gl({},e),{},{assets:t.assets});case"SET_LOADING":return gl(gl({},e),{},{loading:t.loading});case"SET_ERROR":return gl(gl({},e),{},{error:t.error});case"DISABLE_PATTERNS":var s=t.patternIdsAndNonces,l=[];return e.patterns.forEach((function(e){s.some((function(t){return t.id===e.id}))&&(e.isDisabled=!0),l.push(e)})),gl(gl({},e),{},{patterns:[].concat(l),data:gl(gl({},e.data),{},{patterns:[].concat(l)})});case"ENABLE_PATTERNS":var c=t.patternIdsAndNonces,u=[];return e.patterns.forEach((function(e){c.some((function(t){return t.id===e.id}))&&(e.isDisabled=!1),u.push(e)})),gl(gl({},e),{},{patterns:[].concat(u),data:gl(gl({},e.data),{},{patterns:[].concat(u)})});case"DELETE_PATTERNS":var d=t.patternIdsAndNonces,f=hl(e.patterns).filter((function(e){return!d.some((function(t){return t.id===e.id}))}));return gl(gl({},e),{},{patterns:f,data:gl(gl({},e.data),{},{patterns:f})});default:return e}},actions:xl,selectors:{getPatterns:function(e){return e.patterns},getCategories:function(e){return e.categories},getAssets:function(e){return e.assets},getData:function(e){return e.data},getLoading:function(e){return e.loading},getError:function(e){return e.error}}});(0,ai.register)(_l);const El=_l,Sl=window.wp.blocks;function Cl(e){return Cl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Cl(e)}function Ol(){Ol=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==Cl(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Cl(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function Pl(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function jl(){var e;return e=Ol().mark((function e(t){var n,r,i,o;return Ol().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.text();case 2:n=e.sent,e.prev=3,r=JSON.parse(n),e.next=10;break;case 7:throw e.prev=7,e.t0=e.catch(3),new Error("Invalid JSON file (cannot parse)");case 10:if(r.title){e.next=12;break}throw new Error("Pattern JSON missing a title");case 12:if(i="","string"!=typeof r.content){e.next=17;break}i=r.content,e.next=22;break;case 17:if(!Array.isArray(r.blocks)){e.next=21;break}i=(0,Sl.serialize)(r.blocks),e.next=22;break;case 21:throw new Error("Pattern JSON missing content or blocks array");case 22:return o="string"==typeof r.syncStatus?r.syncStatus:"unsynced",e.abrupt("return",{title:r.title,content:i,syncStatus:o});case 24:case"end":return e.stop()}}),e,null,[[3,7]])})),jl=function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Pl(o,r,i,a,s,"next",e)}function s(e){Pl(o,r,i,a,s,"throw",e)}a(void 0)}))},jl.apply(this,arguments)}const Ll=function(_x){return jl.apply(this,arguments)};function kl(e){return kl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},kl(e)}function Tl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Il(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Tl(Object(n),!0).forEach((function(t){Al(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tl(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Al(e,t,n){return(t=function(e){var t=function(e){if("object"!=kl(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=kl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==kl(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ml(e){return function(e){if(Array.isArray(e))return zl(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Bl(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Nl(){Nl=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==kl(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(kl(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function Rl(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function Fl(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Rl(o,r,i,a,s,"next",e)}function s(e){Rl(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Dl(){return Dl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Dl.apply(null,arguments)}function Vl(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||Bl(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Bl(e,t){if(e){if("string"==typeof e)return zl(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?zl(e,t):void 0}}function zl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var Hl=function(e){var r=e.src,i=e.title,o=e.item,a=(0,t.useRef)(null),s=(0,t.useRef)(null),l=Vl((0,t.useState)(!1),2),c=l[0],u=l[1],d=Vl((0,t.useState)(1),2),f=d[0],h=d[1],p=Vl((0,t.useState)(0),2),m=p[0],g=p[1],v=Vl((0,t.useState)(0),2),y=v[0],b=v[1],w=Vl((0,t.useState)(1),2),x=w[0],_=w[1];(0,t.useEffect)((function(){var e=a.current;if(e){var t=function(){u(!0),g(o.viewportWidth||e.offsetWidth)};return e.addEventListener("load",t),function(){e.removeEventListener("load",t)}}}),[r]);var E=Vl((0,n.useResizeObserver)(),2),S=E[0],C=E[1],O=C.width,P=C.height;return(0,t.useEffect)((function(){if(void 0!==O&&c&&0!==m){var e=O/(m||800),t=O/P,n=Math.max(m*t,100);b(n),h(e),_(t);var r=new CustomEvent("dlxPatternPreviewResize",{detail:{width:O}});window.dispatchEvent(r);try{window.parent.dispatchEvent(r)}catch(e){}}}),[O,c]),(0,t.useEffect)((function(){a.current&&g(a.current.offsetWidth)}),[a,y]),React.createElement("a",{href:r,className:"pattern-preview-iframe-link",target:"_blank",rel:"noopener noreferrer",onClick:function(e){e.preventDefault(),$l(o)},"aria-hidden":"true"},React.createElement("div",{className:"pattern-preview-iframe-scale-container-wrapper",ref:s,style:{transform:"scale(".concat(f,")")}},React.createElement("div",{className:"pattern-preview-iframe-scale-wrapper"},React.createElement("div",{className:"pattern-preview-iframe-scale-container"},S,React.createElement("div",{className:"pattern-preview-iframe-wrapper"},React.createElement("iframe",{ref:a,key:"preview-".concat(o.id),src:r,title:i,sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",loading:"lazy",style:{position:"absolute",top:0,left:0,width:o.viewportWidth||800,aspectRatio:x,height:y+"px",maxHeight:"1200px",overflow:"visible"}}))))))},$l=function(e){var t=e.viewportWidth||1200,n=null!=e&&e.id?"".concat(ajaxurl,"?action=dlxpw_pattern_preview&pattern_id=").concat(e.id,"&viewport_width=").concat(t):"";o.Fancybox.show([{src:n,caption:e.title,type:"iframe",closeButton:!0}])},Gl={grid:{layout:{titleField:"title",mediaField:"pattern-view-json",columns:2,columnGap:"24px",rowGap:"24px",showMedia:!0,viewConfigOptions:{}}}},Ul=function(e){var n,i,o,c,d,f,h,p,m=e.data,g=Vl((0,t.useState)([]),2),v=g[0],y=g[1],b=(0,ai.useSelect)((function(e){return{patterns:e(El).getPatterns()}})).patterns,w=Vl((0,t.useState)([]),2),x=w[0],_=w[1],E=(0,ai.useSelect)((function(){return{categories:(0,ai.select)(El).getCategories()}})).categories,S=((0,ai.useSelect)((function(){return{assets:(0,ai.select)(El).getAssets()}})).assets,Vl((0,t.useState)([]),2)),C=S[0],O=S[1],P=Vl((0,t.useState)(!0),2),j=P[0],L=P[1],k=Vl((0,t.useState)({isVisible:!1,message:"",title:"",type:""}),2),T=k[0],I=k[1],A=Vl((0,t.useState)(!1),2),M=A[0],N=A[1],R=Vl((0,t.useState)(!1),2),F=R[0],D=R[1],V=Vl((0,t.useState)(0),2),B=(V[0],V[1]),z=Vl((0,t.useState)(null),2),H=z[0],$=z[1],G=Vl((0,t.useState)(null),2),U=G[0],W=G[1],q=Vl((0,t.useState)(null),2),Y=q[0],X=q[1],K=Vl((0,t.useState)(null),2),Z=K[0],Q=K[1],J=Vl((0,t.useState)(null),2),ee=J[0],te=J[1],ne=Vl((0,t.useState)(null),2),re=ne[0],ie=ne[1],oe=function(e){var t=e.isLocal,n=e.title,i="";t?i="unsynced":"synced"===e.patternType&&(i="synced");var o=JSON.stringify({__file:"wp_block",title:n,content:e.content,syncStatus:i},null,2);(0,r.downloadBlob)("".concat(n,".json"),o,"application/json")},ae=function(){var e,t,n,r,i,o;return{type:"grid",previewSize:"large",paginationInfo:{totalItems:b.length,totalPages:0},page:parseInt((0,So.getQueryArgs)(window.location.href).paged)||1,perPage:parseInt((0,So.getQueryArgs)(window.location.href).perPage)||12,defaultPerPage:12,sort:{field:(0,a.escapeAttribute)((0,So.getQueryArgs)(window.location.href).orderby||"title"),direction:(0,a.escapeAttribute)((0,So.getQueryArgs)(window.location.href).order||"asc")},titleField:"title",mediaField:"pattern-view-json",layout:Gl.grid.layout,fields:["title","pattern-view-json"],search:(0,a.escapeAttribute)((null===(e=(0,So.getQueryArgs)(window.location.href))||void 0===e?void 0:e.search)||""),filters:[{field:"patternType",value:(null===(t=(0,So.getQueryArgs)(window.location.href))||void 0===t?void 0:t.patternType)||"all"},{field:"patternStatus",value:(null===(n=(0,So.getQueryArgs)(window.location.href))||void 0===n?void 0:n.patternStatus)||"both"},{field:"patternLocalStatus",value:(null===(r=(0,So.getQueryArgs)(window.location.href))||void 0===r?void 0:r.patternLocalStatus)||"both"},{field:"patternRegisteredStatus",value:(null===(i=(0,So.getQueryArgs)(window.location.href))||void 0===i?void 0:i.patternRegisteredStatus)||"both"},{field:"patternLocalRegisteredStatus",value:(null===(o=(0,So.getQueryArgs)(window.location.href))||void 0===o?void 0:o.patternLocalRegisteredStatus)||"enabled"}]}},se=function(e){return React.createElement(React.Fragment,null,React.createElement("div",{className:"pattern-quick-links"},e.isLocal&&React.createElement(React.Fragment,null,!e.isDisabled&&React.createElement(React.Fragment,null,React.createElement(l.Button,{variant:"link",onClick:function(t){t.preventDefault(),t.stopPropagation(),$({item:e})}},(0,s.__)("Quick Edit","pattern-wrangler"))," | ",React.createElement(l.Button,{variant:"link",onClick:function(t){t.preventDefault(),t.stopPropagation(),ie({item:e})}},(0,s.__)("Get Code","pattern-wrangler"))," | "),React.createElement(l.Button,{variant:"link",onClick:function(t){t.preventDefault(),t.stopPropagation(),oe(e)}},(0,s.__)("Export Pattern","pattern-wrangler"))),!e.isLocal&&React.createElement(React.Fragment,null,React.createElement(l.Button,{variant:"link",onClick:function(t){t.preventDefault(),t.stopPropagation(),B(e.id),D({item:e})}},(0,s.__)("Copy to New Pattern","pattern-wrangler"))," | ",React.createElement(l.Button,{variant:"link",onClick:function(t){t.preventDefault(),t.stopPropagation(),oe(e)}},(0,s.__)("Export Pattern","pattern-wrangler")))))},le=Vl((0,t.useState)(ae()),2),ce=le[0],ue=le[1],de=(0,t.useMemo)((function(){return[{id:"title",label:(0,s.__)("Title","pattern-wrangler"),render:function(e){var t=e.item;if(null==t||!t.categorySlugs||0===t.categorySlugs.length)return React.createElement("div",{className:"pattern-title-categories"},React.createElement("div",{className:"pattern-title"},t.isLocal&&React.createElement(l.Button,{variant:"link",onClick:function(e){e.preventDefault();var n=encodeURIComponent(window.location.href);window.location.href="".concat(dlxEnhancedPatternsView.getSiteBaseUrl,"post.php?post=").concat(t.id,"&action=edit&redirect_to=").concat(n)}},t.title),!t.isLocal&&React.createElement("span",{className:"pattern-title"},t.title)),React.createElement("div",{className:"pattern-categories"},(0,s.__)("No categories","pattern-wrangler")),se(t));var n=(0,ai.select)(El).getCategories();return React.createElement(React.Fragment,null,React.createElement("div",{className:"pattern-title-categories"},React.createElement("div",{className:"pattern-title"},t.isLocal&&React.createElement(l.Button,{variant:"link",onClick:function(e){e.preventDefault();var n=encodeURIComponent(window.location.href);window.location.href="".concat(dlxEnhancedPatternsView.getSiteBaseUrl,"post.php?post=").concat(t.id,"&action=edit&redirect_to=").concat(n)}},t.title),!t.isLocal&&React.createElement("span",{className:"pattern-title"},t.title)),t.categorySlugs.length>0&&Object.values(n).length>0&&React.createElement("div",{className:"pattern-categories"},(0,s.__)("Categories:","pattern-wrangler")," ",t.categorySlugs.map((function(e,r){var i,o,a=(null==e?void 0:e.slug)||e.toString();if(!n.hasOwnProperty(a))return null;var s=(null===(i=n[a])||void 0===i?void 0:i.label)||(null===(o=n[a])||void 0===o?void 0:o.name);return React.createElement("span",{key:"category-".concat(r),className:"pattern-category"},s," ",r<t.categorySlugs.length-1&&", ")}))),se(t)))},enableSorting:!0,enableHiding:!1,enableGlobalSearch:!0},{id:"pattern-view-json",label:(0,s.__)("Preview","pattern-wrangler"),getValue:function(e){var t=e.item,n=t.viewportWidth||1200,r=null!=t&&t.id?"".concat(ajaxurl,"?action=dlxpw_pattern_preview&pattern_id=").concat(t.id,"&viewport_width=").concat(n):"",i=(0,s.__)("Local","pattern-wrangler"),o="pattern-badge-local",a=(0,s.__)("Disabled","pattern-wrangler"),l=!0;t.isDisabled&&t.isLocal?a=(0,s.__)("Draft","pattern-wrangler"):!t.isDisabled&&t.isLocal?l=!1:t.isDisabled||t.isLocal||(l=!1),t.isLocal?"synced"===t.patternType?(i=(0,s.__)("Local Synced","pattern-wrangler"),o="pattern-badge-synced"):(i=(0,s.__)("Local Unsynced","pattern-wrangler"),o="pattern-badge-unsynced"):(i=(0,s.__)("Registered","pattern-wrangler"),o="pattern-badge-registered");var c=React.createElement(React.Fragment,null,React.createElement("div",{className:"pattern-badge-wrapper"},l&&React.createElement("span",{className:"pattern-badge ".concat("pattern-badge-disabled")},a),React.createElement("span",{className:"pattern-badge ".concat(o)},i)));return React.createElement(React.Fragment,null,c,React.createElement("div",{className:"pattern-preview-wrapper"},React.createElement(Hl,{src:r,title:"Preview: ".concat(t.title),item:t})))},enableSorting:!1,enableHiding:!1},{id:"categories",label:(0,s.__)("Categories","pattern-wrangler"),render:function(e){return e.item,null},enableSorting:!1,enableHiding:!1,enableGlobalSearch:!0,type:"array",filterBy:{operators:["isAny","isNone"]},elements:Object.values(E).map((function(e){return{label:e.label||e.name,value:e.slug}}))},{id:"assets",label:(0,s.__)("Filter Patterns by Source","pattern-wrangler"),render:function(e){return e.item,null},enableHiding:!1,enableGlobalSearch:!0,enableSorting:!1,filterBy:{operators:["is"]},elements:Object.values((0,ai.select)(El).getAssets()||[]).map((function(e){return{label:e.label,value:e.slug}}))},{elements:[{label:(0,s.__)("All Patterns","pattern-wrangler"),value:"all"},{label:(0,s.__)("Local Patterns","pattern-wrangler"),value:"local"},{label:(0,s.__)("Registered Patterns","pattern-wrangler"),value:"registered"}],enableHiding:!1,enableSorting:!1,enableGlobalSearch:!1,filterBy:{operators:["is"]},default:"all",type:"array",id:"patternType",label:(0,s.__)("Pattern Type","pattern-wrangler")},{elements:[{label:(0,s.__)("Unsynced Patterns","pattern-wrangler"),value:"unsynced"},{label:(0,s.__)("Synced Patterns","pattern-wrangler"),value:"synced"},{label:(0,s.__)("Both","pattern-wrangler"),value:"both"}],enableHiding:!1,enableSorting:!1,enableGlobalSearch:!1,filterBy:{operators:["is"]},type:"array",id:"patternStatus",label:(0,s.__)("Pattern Status","pattern-wrangler")},{elements:[{label:(0,s.__)("Paused Patterns","pattern-wrangler"),value:"paused"},{label:(0,s.__)("Unpaused Patterns","pattern-wrangler"),value:"unpaused"},{label:(0,s.__)("Both","pattern-wrangler"),value:"both"}],enableHiding:!1,enableSorting:!1,enableGlobalSearch:!1,filterBy:{operators:["is"]},type:"array",id:"patternRegisteredStatus",label:(0,s.__)("Pattern Registered Status","pattern-wrangler")},{elements:[{label:(0,s.__)("Draft Patterns","pattern-wrangler"),value:"draft"},{label:(0,s.__)("Published Patterns","pattern-wrangler"),value:"published"},{label:(0,s.__)("Both","pattern-wrangler"),value:"both"}],enableHiding:!1,enableSorting:!1,enableGlobalSearch:!1,filterBy:{operators:["is"]},type:"array",id:"patternLocalStatus",label:(0,s.__)("Pattern Local Status","pattern-wrangler")},{elements:[{label:(0,s.__)("Disabled Patterns","pattern-wrangler"),value:"disabled"},{label:(0,s.__)("Enabled Patterns","pattern-wrangler"),value:"enabled"},{label:(0,s.__)("Both","pattern-wrangler"),value:"both"}],enableHiding:!1,enableSorting:!1,enableGlobalSearch:!1,filterBy:{operators:["is"]},type:"array",id:"patternLocalRegisteredStatus",label:(0,s.__)("Pattern Local and Registered Status","pattern-wrangler")}]}),[]),fe=(0,t.useMemo)((function(){return[{id:"quick-edit",label:(0,s.__)("Quick Edit","pattern-wrangler"),icon:"edit",callback:function(e){$({item:e[0]})},isEligible:function(e){return e.isLocal&&!e.isDisabled},isPrimary:!0},{id:"get-code",label:(0,s.__)("Get Code","pattern-wrangler"),icon:"code",callback:function(e){ie({item:e[0]})},isEligible:function(e){return e.isLocal&&!e.isDisabled},isPrimary:!1,supportsBulk:!1},{id:"delete",label:(0,s.__)("Delete Pattern","pattern-wrangler"),icon:"trash",isEligible:function(e){return e.isLocal&&e.isDisabled},callback:function(e){te({items:e})},isPrimary:!1,isDestructive:!0,supportsBulk:!0},{id:"publish",label:(0,s.__)("Publish Pattern","pattern-wrangler"),icon:"yes-alt",isEligible:function(e){return e.isLocal&&e.isDisabled},callback:function(e){X({items:e})},isPrimary:!1,isDestructive:!1,supportsBulk:!0},{id:"unpause",label:(0,s.__)("Re-enable Pattern","pattern-wrangler"),icon:"controls-play",isEligible:function(e){return!e.isLocal&&e.isDisabled},callback:function(e){Q({items:e})},isPrimary:!1,isDestructive:!1,supportsBulk:!0},{id:"copy-to-local",label:(0,s.__)("Copy to New Pattern","pattern-wrangler"),icon:"edit",callback:function(e){var t=e[0];B(t.id),D({item:t})},isEligible:function(e){return!e.isLocal},isPrimary:!1,isDestructive:!1},{id:"disable-preview",label:(0,s.__)("Disable Pattern","pattern-wrangler"),icon:"controls-pause",callback:function(e){W({items:e})},isEligible:function(e){return!e.isDisabled},isDestructive:!0,supportsBulk:!0,isPrimary:!1},{id:"copy",label:(0,s.__)("Copy Pattern to Clipboard","pattern-wrangler"),icon:"edit",callback:(e=Fl(Nl().mark((function e(t){var n,r,i,o;return Nl().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t[0].content.trim(),r=!1,e.prev=2,null===(i=navigator.clipboard)||void 0===i||!i.writeText){e.next=12;break}return e.prev=4,e.next=7,navigator.clipboard.writeText(n);case 7:r=!0,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:if(!r){(o=document.createElement("textarea")).value=n,o.style.position="fixed",o.style.opacity="0",o.style.pointerEvents="none",document.body.appendChild(o),o.select();try{document.execCommand("copy"),r=!0}catch(e){}document.body.removeChild(o)}I({isVisible:!0,message:(0,s.__)("Pattern copied to clipboard","pattern-wrangler"),title:(0,s.__)("Pattern Copied","pattern-wrangler"),type:"success",onClose:function(){I({isVisible:!1})}}),e.next=18;break;case 16:e.prev=16,e.t1=e.catch(2);case 18:case"end":return e.stop()}}),e,null,[[2,16],[4,10]])}))),function(_x){return e.apply(this,arguments)}),isEligible:function(e){return!0},isPrimary:!1,isDestructive:!1},{id:"export",label:(0,s.__)("Export to JSON","pattern-wrangler"),icon:"edit",callback:function(e){var t=e[0].isLocal,n=e[0].title,i="";t?i="unsynced":"synced"===e[0].patternType&&(i="synced");var o=JSON.stringify({__file:"wp_block",title:n,content:e[0].content,syncStatus:i},null,2);(0,r.downloadBlob)("".concat(n,".json"),o,"application/json")},isEligible:function(){return!0},isPrimary:!1,isDestructive:!1}];var e}),[E,b]),he=function(e){var t,n,r=Ml(b);null!==r&&0!==r.length||(r=Ml(m.patterns));var i=null==e||null===(t=e.sort)||void 0===t?void 0:t.field,o=null==e||null===(n=e.sort)||void 0===n?void 0:n.direction;"title"===i&&("desc"===o?r.sort((function(e,t){return t.title.localeCompare(e.title)})):r.sort((function(e,t){return e.title.localeCompare(t.title)})));var a=(null==e?void 0:e.filters)||[];a.length>0&&a.forEach((function(e){switch(e.field){case"categories":if(e.value){var t=e.value.map((function(e){return(0,So.cleanForSlug)(e)}));"isAny"===e.operator?r=r.filter((function(e){return(e.categorySlugs||[]).some((function(e){var n=e.name||(0,So.cleanForSlug)(e);return t.includes(n)}))})):"isNone"===e.operator&&(r=r.filter((function(e){return!(e.categorySlugs||[]).some((function(e){var n=e.name||(0,So.cleanForSlug)(e);return t.includes(n)}))})))}break;case"assets":e.value&&"is"===e.operator&&(r=r.filter((function(t){return t.asset===e.value})));break;case"patternType":if(e.value)switch(e.value){case"all":break;case"local":r=r.filter((function(e){return e.isLocal}));break;case"registered":r=r.filter((function(e){return!e.isLocal}))}break;case"patternStatus":if(e.value){var n=a.find((function(e){return"patternType"===e.field}));if(n&&"local"===n.value&&e.value)switch(e.value){case"unsynced":r=r.filter((function(e){return!!e.syncStatus&&"unsynced"===e.syncStatus&&e.isLocal}));break;case"synced":r=r.filter((function(e){return!!e.syncStatus&&"synced"===e.syncStatus&&e.isLocal}))}}break;case"patternLocalStatus":if(e.value){var i=a.find((function(e){return"patternType"===e.field}));if(i&&"local"===i.value&&e.value)switch(e.value){case"draft":r=r.filter((function(e){return e.isDisabled&&e.isLocal}));break;case"published":r=r.filter((function(e){return!e.isDisabled&&e.isLocal}))}}break;case"patternRegisteredStatus":if(e.value){var o=a.find((function(e){return"patternType"===e.field}));if(o&&"registered"===o.value&&e.value)switch(e.value){case"paused":r=r.filter((function(e){return e.isDisabled&&!e.isLocal}));break;case"unpaused":r=r.filter((function(e){return!e.isDisabled&&!e.isLocal}))}}break;case"patternLocalRegisteredStatus":if(e.value){var s=a.find((function(e){return"patternType"===e.field}));if(s&&"all"===s.value&&e.value)switch(e.value){case"disabled":r=r.filter((function(e){return e.isDisabled}));break;case"enabled":r=r.filter((function(e){return!e.isDisabled}))}}}}));var s=(null==e?void 0:e.search)||"";return"undefined"!==s&&""!==s&&(r=r.filter((function(t){return(t.label||t.title).toLowerCase().includes((e.search||s).toLowerCase())}))),r.length},pe=function(e){var t,n,r=Ml(b);null!==r&&0!==r.length||(r=Ml(m.patterns));var i=null==e||null===(t=e.sort)||void 0===t?void 0:t.field,o=null==e||null===(n=e.sort)||void 0===n?void 0:n.direction;"title"===i&&("desc"===o?r.sort((function(e,t){return t.title.localeCompare(e.title)})):r.sort((function(e,t){return e.title.localeCompare(t.title)})));var a=(null==e?void 0:e.filters)||[];a.length>0&&a.forEach((function(e){switch(e.field){case"categories":if(e.value){var t=e.value.map((function(e){return(0,So.cleanForSlug)(e)}));"isAny"===e.operator?r=r.filter((function(e){return(e.categorySlugs||[]).some((function(e){var n=e.name||(0,So.cleanForSlug)(e);return t.includes(n)}))})):"isNone"===e.operator&&(r=r.filter((function(e){return!(e.categorySlugs||[]).some((function(e){var n=e.name||(0,So.cleanForSlug)(e);return t.includes(n)}))})))}break;case"assets":e.value&&(r=r.filter((function(t){return t.asset===e.value})));break;case"patternType":if(e.value)switch(e.value){case"all":break;case"local":r=r.filter((function(e){return e.isLocal}));break;case"registered":r=r.filter((function(e){return!e.isLocal}))}break;case"patternStatus":if(e.value){var n=a.find((function(e){return"patternType"===e.field}));if(n&&"local"===n.value&&e.value)switch(e.value){case"unsynced":r=r.filter((function(e){return!!e.syncStatus&&"unsynced"===e.syncStatus&&e.isLocal}));break;case"synced":r=r.filter((function(e){return!!e.syncStatus&&"synced"===e.syncStatus&&e.isLocal}))}}break;case"patternLocalStatus":if(e.value){var i=a.find((function(e){return"patternType"===e.field}));if(i&&"local"===i.value&&e.value)switch(e.value){case"draft":case"paused":r=r.filter((function(e){return e.isDisabled&&e.isLocal}));break;case"published":r=r.filter((function(e){return!e.isDisabled&&e.isLocal}))}}break;case"patternRegisteredStatus":if(e.value){var o=a.find((function(e){return"patternType"===e.field}));if(o&&"registered"===o.value&&e.value)switch(e.value){case"paused":r=r.filter((function(e){return e.isDisabled&&!e.isLocal}));break;case"unpaused":r=r.filter((function(e){return!e.isDisabled&&!e.isLocal}))}}break;case"patternLocalRegisteredStatus":if(e.value){var s=a.find((function(e){return"patternType"===e.field}));if(s&&"all"===s.value&&e.value)switch(e.value){case"disabled":r=r.filter((function(e){return e.isDisabled}));break;case"enabled":r=r.filter((function(e){return!e.isDisabled}))}}}}));var s=(null==e?void 0:e.search)||"";return"undefined"!==s&&""!==s&&(r=r.filter((function(t){return(t.label||t.title).toLowerCase().includes((e.search||s).toLowerCase())}))),r.slice((e.page-1)*e.perPage,e.page*e.perPage)},me=function(e){var t,n,r,i,o,a,s=(0,So.getQueryArgs)(window.location.href);s.paged=e.page||1,s.perPage=e.perPage,e.search?s.search=e.search:s.search="",null!==(t=e.sort)&&void 0!==t&&t.field&&(s.orderby=e.sort.field,s.order=e.sort.direction);var l=null===(n=e.filters)||void 0===n?void 0:n.find((function(e){return"patternType"===e.field})),c=null===(r=e.filters)||void 0===r?void 0:r.find((function(e){return"patternStatus"===e.field}));l&&(s.patternType=l.value),c&&(s.patternStatus=c.value);var u=null===(i=e.filters)||void 0===i?void 0:i.find((function(e){return"patternRegisteredStatus"===e.field})),d=null===(o=e.filters)||void 0===o?void 0:o.find((function(e){return"patternLocalStatus"===e.field})),f=null===(a=e.filters)||void 0===a?void 0:a.find((function(e){return"patternLocalRegisteredStatus"===e.field}));u&&!f&&(s.patternRegisteredStatus=u.value),d&&!f&&(s.patternLocalStatus=d.value),f&&(s.patternLocalRegisteredStatus=f.value);var h=(0,So.addQueryArgs)(window.location.pathname,s);(0,So.getQueryArgs)(window.location.href).search&&!e.search&&(h=(0,So.removeQueryArgs)(h,"search")),_(pe(e)),window.history.pushState({},"",h),s.page=s.paged,ue(Il(Il({},e),s))};return(0,t.useEffect)((function(){window.addEventListener("popstate",(function(){me(ae())}))}),[ce]),(0,t.useEffect)((function(){if(m&&m.hasOwnProperty("patterns")&&m.categories){var e=de.findIndex((function(e){return"categories"===e.id})),t=[],n="";de[e].elements=Object.values(m.categories).map((function(e){var r=e.label;return n===e.label&&(r="".concat(r," (").concat(e.count+1,")")),n=e.label,e.registered||t.push({id:e.id,label:e.label}),{label:r,value:e.slug}})),0===t.length&&de.splice(e,1),0===Object.values(m.assets).length&&de.splice(de.findIndex((function(e){return"assets"===e.id})),1);var r=Il(Il({},ce),{},{fields:Ml(de)});if(O(t),ue(r),m.patterns&&m.patterns!==x){var i=pe(ce);_(i)}L(!1)}}),[m]),j?React.createElement(React.Fragment,null,"Loading..."):React.createElement("div",{className:"dlx-patterns-view-container-wrapper"},React.createElement("div",{className:"dlx-patterns-view-container"},React.createElement(Uo,{data:x,fields:de,actions:fe,label:(0,s.__)("Patterns","pattern-wrangler"),view:ce,onChangeView:me,paginationInfo:{totalItems:he(ce),totalPages:Math.ceil(he(ce)/ce.perPage)},perPageSizes:[12,24,48,96],selection:v,onChangeSelection:y,defaultLayouts:Gl,searchLabel:(0,s.__)("Search Patterns","pattern-wrangler")},React.createElement("div",{className:"dlx-patterns-view-container-header"},React.createElement("h1",null,(0,s.__)("Pattern Library","pattern-wrangler"))),React.createElement("div",{className:"dlx-patterns-view-quick-buttons-wrapper"},React.createElement(l.Button,{variant:"primary",className:"dlx-patterns-view-quick-button",onClick:function(){N(!0)}},(0,s.__)("Add New Pattern","pattern-wrangler")),React.createElement(l.FormFileUpload,{accept:".json",variant:"secondary",className:"dlx-patterns-view-quick-button",onChange:function(){var e=Fl(Nl().mark((function e(t){var n,r,i,o;return Nl().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.target.files[0],e.prev=1,e.next=4,Ll(n);case 4:return r=e.sent,e.next=7,u()({path:"/wp/v2/blocks",method:"POST",data:{title:r.title,content:r.content,status:"publish",meta:{wp_pattern_sync_status:r.syncStatus}}});case 7:if(null==(i=e.sent)||!i.id){e.next=13;break}return e.next=11,u()({path:"/dlxplugins/pattern-wrangler/v1/patterns/get/".concat(i.id),method:"GET"});case 11:(o=e.sent)&&(0,ai.dispatch)(El).addPattern(o);case 13:e.next=17;break;case 15:e.prev=15,e.t0=e.catch(1);case 17:case"end":return e.stop()}}),e,null,[[1,15]])})));return function(t){return e.apply(this,arguments)}}()},(0,s.__)("Import Pattern From JSON File","pattern-wrangler"))),React.createElement("div",{className:"dlx-patterns-view-grid"},React.createElement("div",{className:"dlx-patterns-view-search-filters-wrapper"},React.createElement(Uo.Search,{label:(0,s.__)("Search Patterns","pattern-wrangler")}),React.createElement(Uo.FiltersToggle,null)),React.createElement("div",{className:"dlx-patterns-view-button-actions-wrapper"},React.createElement(l.__experimentalToggleGroupControl,{label:(0,s.__)("Pattern Type","pattern-wrangler"),isAdaptiveWidth:!0,hideLabelFromVision:!0,value:(null==ce||null===(n=ce.filters)||void 0===n||null===(n=n.find((function(e){return"patternType"===e.field})))||void 0===n?void 0:n.value)||"all",onChange:function(e){var t,n=Il({},ce),r=(null===(t=n.filters)||void 0===t?void 0:t.filter((function(e){return"patternType"!==e.field})))||[];n.filters=[].concat(Ml(r),[{field:"patternType",operator:"is",value:e}]),n.page=1,me(n);var i=window.location.href;switch(e){case"all":i=(0,So.removeQueryArgs)(i,"patternStatus"),i=(0,So.removeQueryArgs)(i,"patternRegisteredStatus"),i=(0,So.removeQueryArgs)(i,"patternLocalStatus"),i=(0,So.removeQueryArgs)(i,"patternLocalRegisteredStatus"),window.history.pushState({},"",i);break;case"local":i=(0,So.removeQueryArgs)(i,"patternRegisteredStatus"),i=(0,So.removeQueryArgs)(i,"patternLocalRegisteredStatus"),window.history.pushState({},"",i);break;case"registered":i=(0,So.removeQueryArgs)(i,"patternStatus"),i=(0,So.removeQueryArgs)(i,"patternLocalStatus"),i=(0,So.removeQueryArgs)(i,"patternLocalRegisteredStatus"),window.history.pushState({},"",i)}}},React.createElement(l.__experimentalToggleGroupControlOption,{value:"local",label:(0,s.__)("Local","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Local Patterns","pattern-wrangler")}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"all",label:(0,s.__)("All","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show All Patterns","pattern-wrangler")}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"registered",label:(0,s.__)("Registered","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Registered Patterns","pattern-wrangler")})),"registered"===(null==ce||null===(i=ce.filters)||void 0===i||null===(i=i.find((function(e){return"patternType"===e.field})))||void 0===i?void 0:i.value)&&React.createElement(React.Fragment,null,React.createElement(l.__experimentalToggleGroupControl,{label:(0,s.__)("Registered Status","pattern-wrangler"),isAdaptiveWidth:!0,hideLabelFromVision:!0,value:(null==ce||null===(o=ce.filters)||void 0===o||null===(o=o.find((function(e){return"patternRegisteredStatus"===e.field})))||void 0===o?void 0:o.value)||"both",onChange:function(e){var t,n=Il({},ce),r=(null===(t=n.filters)||void 0===t?void 0:t.filter((function(e){return"patternRegisteredStatus"!==e.field})))||[];n.filters=[].concat(Ml(r),[{field:"patternRegisteredStatus",operator:"is",value:e}]),n.page=1,me(n)}},React.createElement(l.__experimentalToggleGroupControlOption,{value:"paused",label:(0,s.__)("Disabled","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Disabled Patterns","pattern-wrangler")}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"both",label:(0,s.__)("Both","pattern-wrangler"),"aria-label":(0,s.__)("Show Both Disabled and Enabled Patterns","pattern-wrangler"),showTooltip:!0}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"unpaused",label:(0,s.__)("Enabled","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Enabled Patterns","pattern-wrangler")}))),"local"===(null==ce||null===(c=ce.filters)||void 0===c||null===(c=c.find((function(e){return"patternType"===e.field})))||void 0===c?void 0:c.value)&&React.createElement(React.Fragment,null,React.createElement(l.__experimentalToggleGroupControl,{label:(0,s.__)("Pattern Status","pattern-wrangler"),isAdaptiveWidth:!0,hideLabelFromVision:!0,value:(null==ce||null===(d=ce.filters)||void 0===d||null===(d=d.find((function(e){return"patternStatus"===e.field})))||void 0===d?void 0:d.value)||"both",onChange:function(e){var t,n=Il({},ce),r=(null===(t=n.filters)||void 0===t?void 0:t.filter((function(e){return"patternStatus"!==e.field})))||[];n.filters=[].concat(Ml(r),[{field:"patternStatus",operator:"is",value:e}]),n.page=1,me(n)}},React.createElement(l.__experimentalToggleGroupControlOption,{value:"unsynced",label:(0,s.__)("Unsynced","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Unsynced Patterns","pattern-wrangler")}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"both",label:(0,s.__)("Both","pattern-wrangler"),"aria-label":(0,s.__)("Show Both Synced and Unsynced Patterns","pattern-wrangler"),showTooltip:!0}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"synced",label:(0,s.__)("Synced","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Synced Patterns","pattern-wrangler")})),React.createElement(l.__experimentalToggleGroupControl,{label:(0,s.__)("Published Status","pattern-wrangler"),isAdaptiveWidth:!0,hideLabelFromVision:!0,value:(null==ce||null===(f=ce.filters)||void 0===f||null===(f=f.find((function(e){return"patternLocalStatus"===e.field})))||void 0===f?void 0:f.value)||"both",onChange:function(e){var t,n=Il({},ce),r=(null===(t=n.filters)||void 0===t?void 0:t.filter((function(e){return"patternLocalStatus"!==e.field})))||[];n.filters=[].concat(Ml(r),[{field:"patternLocalStatus",operator:"is",value:e}]),n.page=1,me(n)}},React.createElement(l.__experimentalToggleGroupControlOption,{value:"draft",label:(0,s.__)("Draft","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Draft Patterns","pattern-wrangler")}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"both",label:(0,s.__)("Both","pattern-wrangler"),"aria-label":(0,s.__)("Show Both Draft and Published Patterns","pattern-wrangler"),showTooltip:!0}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"published",label:(0,s.__)("Published","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Published Patterns","pattern-wrangler")}))),"all"===(null==ce||null===(h=ce.filters)||void 0===h||null===(h=h.find((function(e){return"patternType"===e.field})))||void 0===h?void 0:h.value)&&React.createElement(React.Fragment,null,React.createElement(l.__experimentalToggleGroupControl,{label:(0,s.__)("Disabled Status","pattern-wrangler"),isAdaptiveWidth:!0,hideLabelFromVision:!0,value:(null==ce||null===(p=ce.filters)||void 0===p||null===(p=p.find((function(e){return"patternLocalRegisteredStatus"===e.field})))||void 0===p?void 0:p.value)||"both",onChange:function(e){var t,n=Il({},ce),r=(null===(t=n.filters)||void 0===t?void 0:t.filter((function(e){return"patternLocalRegisteredStatus"!==e.field})))||[];n.filters=[].concat(Ml(r),[{field:"patternLocalRegisteredStatus",operator:"is",value:e}]),n.page=1,me(n)}},React.createElement(l.__experimentalToggleGroupControlOption,{value:"disabled",label:(0,s.__)("Disabled","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Disabled Local and Registered Patterns","pattern-wrangler")}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"both",label:(0,s.__)("Both","pattern-wrangler"),"aria-label":(0,s.__)("Show Both Disabled and Enabled Local and Registered Patterns","pattern-wrangler"),showTooltip:!0}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"enabled",label:(0,s.__)("Enabled","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Enabled Local and Registered Patterns","pattern-wrangler")})))),React.createElement("div",{className:"dlx-patterns-view-layout-pagination-wrapper"},React.createElement(Uo.ViewConfig,null),React.createElement(Uo.LayoutSwitcher,null))),React.createElement("div",{className:"dlx-patterns-view-filters-wrapper"},React.createElement(Uo.Filters,null)),React.createElement("div",{className:"dlx-bulk-action-toolbar-top"},React.createElement(Uo.BulkActionToolbar,null)),React.createElement(Uo.Layout,null),React.createElement(Uo.BulkActionToolbar,null),React.createElement(Uo.Pagination,null)),T.isVisible&&React.createElement(ha,{isVisible:T.isVisible,message:T.message,title:T.title,type:T.type,onClose:function(){I({isVisible:!1})}})),M&&React.createElement(Ds,{isOpen:M,onRequestClose:function(){return N(!1)},categories:C,title:(0,s.__)("Create New Pattern","pattern-wrangler")}),F&&React.createElement(Ds,{isOpen:F,onRequestClose:function(){return D(!1)},categories:C,title:(0,s.__)("Copy Pattern to Local","pattern-wrangler"),syncedDefaultStatus:"unsynced",copyPatternId:F.item.id}),H&&React.createElement(Ds,{isOpen:H,onRequestClose:function(){return $(null)},pattern:H.item,patternTitle:H.item.title,categories:C,patternCategories:H.item.categories,title:(0,s.__)("Quick Edit Pattern","pattern-wrangler"),syncedDisabled:!0,patternId:H.item.id,patternNonce:H.item.editNonce,isEditMode:!0,onEdit:function(e){(0,ai.dispatch)(El).upsertCategory(e.categories),(0,ai.dispatch)(El).setPattern(e.patternId,e.patternTitle,e.categorySlugs,e.categorySlugs),$(null)}}),U&&React.createElement($s,{items:U.items,onPause:function(e,t){(0,ai.dispatch)(El).disablePatterns(t),W(null),I({isVisible:!0,message:(0,s.__)("Patterns disabled","pattern-wrangler"),title:(0,s.__)("Patterns Disabled","pattern-wrangler"),type:"success",onClose:function(){I({isVisible:!1})}})},onRequestClose:function(){return W(null)}}),Y&&React.createElement(Ys,{items:Y.items,onPublish:function(e,t){(0,ai.dispatch)(El).enablePatterns(t),X(null),I({isVisible:!0,message:(0,s.__)("Patterns published","pattern-wrangler"),title:(0,s.__)("Patterns Published","pattern-wrangler"),type:"success",onClose:function(){I({isVisible:!1})}})},onRequestClose:function(){return X(null)}}),Z&&React.createElement(Js,{items:Z.items,onReenable:function(e,t){(0,ai.dispatch)(El).enablePatterns(t),Q(null),I({isVisible:!0,message:(0,s.__)("Patterns re-enabled","pattern-wrangler"),title:(0,s.__)("Patterns Re-enabled","pattern-wrangler"),type:"success",onClose:function(){I({isVisible:!1})}})},onRequestClose:function(){return Q(null)}}),ee&&React.createElement(il,{items:ee.items,onDelete:function(e,t){(0,ai.dispatch)(El).deletePatterns(t),te(null)},onRequestClose:function(){return te(null)}}),re&&React.createElement(dl,{item:re.item,onRequestClose:function(){return ie(null)}}))};const Wl=function(e){var n=(0,ai.useSelect)((function(e){return{data:e(El).getData(),loading:e(El).getLoading(),error:e(El).getError()}})),r=n.data,i=n.loading,o=n.error;return(0,t.useEffect)((function(){(0,ai.dispatch)(El).fetchData()}),[]),i?React.createElement("div",{className:"dlx-patterns-view-container-wrapper"},React.createElement("div",{className:"dlx-patterns-view-container"},React.createElement("div",{className:"dataviews-wrapper"},React.createElement("div",{className:"dlx-patterns-view-container-header"},React.createElement("h1",null,(0,s.__)("Loading patterns…","pattern-wrangler")),React.createElement(qo(),{size:30,color:"#3c434a"}))))):o?React.createElement("div",{className:"dlx-patterns-view-error"},React.createElement("p",null,(0,s.__)("Error loading patterns:","pattern-wrangler")," ",o),React.createElement(l.Button,{variant:"primary",onClick:function(){return(0,ai.dispatch)(El).fetchData()}},(0,s.__)("Retry","pattern-wrangler"))):React.createElement(Ul,Dl({data:r},e))};var ql=document.getElementById("dlx-pattern-wrangler-view");ql&&(0,e.createRoot)(ql).render(React.createElement(Wl,null))})()})();
     41(0,s._x)("Show %s","field"),e.label)}),p&&(0,f.jsx)(mo,{previewOptions:p,onChangePreviewOption:m,onMenuOpenChange:v,activeOption:e.id})]})]})})}function vo({index:e,field:t,view:n,onChangeView:r}){var i;const o=null!==(i=n.fields)&&void 0!==i?i:[],a=void 0!==e&&o.includes(t.id);return(0,f.jsx)(go,{field:t,isVisible:a,isFirst:void 0!==e&&e<1,isLast:void 0!==e&&e===o.length-1,onToggleVisibility:()=>{r({...n,fields:a?o.filter((e=>e!==t.id)):[...o,t.id]})},onMoveUp:void 0!==e?()=>{var i;r({...n,fields:[...null!==(i=o.slice(0,e-1))&&void 0!==i?i:[],t.id,o[e-1],...o.slice(e+1)]})}:void 0,onMoveDown:void 0!==e?()=>{var i;r({...n,fields:[...null!==(i=o.slice(0,e))&&void 0!==i?i:[],o[e+1],t.id,...o.slice(e+2)]})}:void 0})}function yo(e){return!!e}function bo(){var e;const{view:n,fields:r,onChangeView:i}=(0,t.useContext)(q),o=[n?.titleField,n?.mediaField,n?.descriptionField].filter(Boolean),a=null!==(e=n.fields)&&void 0!==e?e:[],c=r.filter((e=>!a.includes(e.id)&&!o.includes(e.id)&&"media"!==e.type)),u=a.map((e=>r.find((t=>t.id===e)))).filter(yo);if(!u?.length&&!c?.length)return null;const d=r.find((e=>e.id===n.titleField)),h=r.find((e=>e.id===n.mediaField)),p=r.find((e=>e.id===n.descriptionField)),m=r.filter((e=>"media"===e.type));let g;if(m.length>1){var v;const e=yo(h)&&(null===(v=n.showMedia)||void 0===v||v);g=yo(h)&&(0,f.jsx)(go,{field:h,label:(0,s.__)("Preview"),description:h.label,isVisible:e,onToggleVisibility:()=>{i({...n,showMedia:!e})},canMove:!1,previewOptions:m.map((e=>({label:e.label,id:e.id}))),onChangePreviewOption:e=>i({...n,mediaField:e})},h.id)}const y=[{field:d,isVisibleFlag:"showTitle"},{field:h,isVisibleFlag:"showMedia",ui:g},{field:p,isVisibleFlag:"showDescription"}].filter((({field:e})=>yo(e))),b=y.filter((({field:e,isVisibleFlag:t})=>{var r;return yo(e)&&(null===(r=n[t])||void 0===r||r)})),w=y.filter((({field:e,isVisibleFlag:t})=>{var r;return yo(e)&&!(null===(r=n[t])||void 0===r||r)}));return(0,f.jsxs)(l.__experimentalVStack,{className:"dataviews-field-control",spacing:6,children:[(0,f.jsx)(l.__experimentalVStack,{className:"dataviews-view-config__properties",spacing:0,children:(b.length>0||!!u?.length)&&(0,f.jsxs)(l.__experimentalItemGroup,{isBordered:!0,isSeparated:!0,children:[b.map((({field:e,isVisibleFlag:t,ui:r})=>null!=r?r:(0,f.jsx)(go,{field:e,isVisible:!0,onToggleVisibility:()=>{i({...n,[t]:!1})},canMove:!1},e.id))),u.map(((e,t)=>(0,f.jsx)(vo,{field:e,view:n,onChangeView:i,index:t},e.id)))]})}),(!!c?.length||!!w.length)&&(0,f.jsxs)(l.__experimentalVStack,{spacing:4,children:[(0,f.jsx)(l.BaseControl.VisualLabel,{style:{margin:0},children:(0,s.__)("Hidden")}),(0,f.jsx)(l.__experimentalVStack,{className:"dataviews-view-config__properties",spacing:0,children:(0,f.jsxs)(l.__experimentalItemGroup,{isBordered:!0,isSeparated:!0,children:[w.length>0&&w.map((({field:e,isVisibleFlag:t,ui:r})=>null!=r?r:(0,f.jsx)(go,{field:e,isVisible:!1,onToggleVisibility:()=>{i({...n,[t]:!0})},canMove:!1},e.id))),c.map((e=>(0,f.jsx)(vo,{field:e,view:n,onChangeView:i},e.id)))]})})]})]})}function wo({title:e,description:t,children:n}){return(0,f.jsxs)(l.__experimentalGrid,{columns:12,className:"dataviews-settings-section",gap:4,children:[(0,f.jsxs)("div",{className:"dataviews-settings-section__sidebar",children:[(0,f.jsx)(l.__experimentalHeading,{level:2,className:"dataviews-settings-section__title",children:e}),t&&(0,f.jsx)(l.__experimentalText,{variant:"muted",className:"dataviews-settings-section__description",children:t})]}),(0,f.jsx)(l.__experimentalGrid,{columns:8,gap:4,className:"dataviews-settings-section__content",children:n})]})}function xo(){const{view:e}=(0,t.useContext)(q),r=(0,n.useInstanceId)(_o,"dataviews-view-config-dropdown"),i=qi.find((t=>t.type===e.type));return(0,f.jsx)(l.Dropdown,{expandOnMobile:!0,popoverProps:{...lo,id:r},renderToggle:({onToggle:e,isOpen:t})=>(0,f.jsx)(l.Button,{size:"compact",icon:ao,label:(0,s._x)("View options","View is used as a noun"),onClick:e,"aria-expanded":t?"true":"false","aria-controls":r}),renderContent:()=>(0,f.jsx)(l.__experimentalDropdownContentWrapper,{paddingSize:"medium",className:"dataviews-config__popover-content-wrapper",children:(0,f.jsxs)(l.__experimentalVStack,{className:"dataviews-view-config",spacing:6,children:[(0,f.jsxs)(wo,{title:(0,s.__)("Appearance"),children:[(0,f.jsxs)(l.__experimentalHStack,{expanded:!0,className:"is-divided-in-two",children:[(0,f.jsx)(uo,{}),(0,f.jsx)(fo,{})]}),!!i?.viewConfigOptions&&(0,f.jsx)(i.viewConfigOptions,{}),(0,f.jsx)(po,{})]}),(0,f.jsx)(wo,{title:(0,s.__)("Properties"),children:(0,f.jsx)(bo,{})})]})})})}function _o(){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(co,{}),(0,f.jsx)(xo,{})]})}const Eo=(0,t.memo)(_o),So=window.wp.url;function Co({item:e,field:t}){const n=t.getValue({item:e});return t?.elements?.find((e=>e.value===n))?.label||t.getValue({item:e})}const Oo={sort:function(e,t,n){return"asc"===n?e.localeCompare(t):t.localeCompare(e)},isValid:function(e,t){if(""===e)return!1;if(!(0,So.isEmail)(e))return!1;if(t?.elements){const n=t?.elements?.map((e=>e.value));if(!n.includes(e))return!1}return!0},Edit:"email",render:({item:e,field:t})=>t.elements?Co({item:e,field:t}):t.getValue({item:e}),enableSorting:!0,filterBy:{defaultOperators:[v,y],validOperators:[m,g,L,k,T,v,y,b,w]}},Po={sort:function(e,t,n){return"asc"===n?e-t:t-e},isValid:function(e,t){if(""===e)return!1;if(!Number.isInteger(Number(e)))return!1;if(t?.elements){const n=t?.elements.map((e=>e.value));if(!n.includes(Number(e)))return!1}return!0},Edit:"integer",render:({item:e,field:t})=>t.elements?Co({item:e,field:t}):t.getValue({item:e}),enableSorting:!0,filterBy:{defaultOperators:[m,g,x,_,E,S,I],validOperators:[m,g,x,_,E,S,I,v,y,b,w]}},jo={sort:function(e,t,n){return"asc"===n?e.localeCompare(t):t.localeCompare(e)},isValid:function(e,t){if(t?.elements){const n=t?.elements?.map((e=>e.value));if(!n.includes(e))return!1}return!0},Edit:"text",render:({item:e,field:t})=>t.elements?Co({item:e,field:t}):t.getValue({item:e}),enableSorting:!0,filterBy:{defaultOperators:[v,y],validOperators:[m,g,L,k,T,v,y,b,w]}},Lo={sort:function(e,t,n){const r=new Date(e).getTime(),i=new Date(t).getTime();return"asc"===n?r-i:i-r},isValid:function(e,t){if(t?.elements){const n=t?.elements.map((e=>e.value));if(!n.includes(e))return!1}return!0},Edit:"datetime",render:({item:e,field:t})=>t.elements?Co({item:e,field:t}):t.getValue({item:e}),enableSorting:!0,filterBy:{defaultOperators:[A,M,C,O,P,j,N,R],validOperators:[A,M,C,O,P,j,N,R]}},ko=window.wp.date,To={sort:function(e,t,n){const r=new Date(e).getTime(),i=new Date(t).getTime();return"asc"===n?r-i:i-r},isValid:function(e,t){if(t?.elements){const n=t?.elements.map((e=>e.value));if(!n.includes(e))return!1}return!0},Edit:null,render:({item:e,field:t})=>{if(t.elements)return Co({item:e,field:t});const n=t.getValue({item:e});return n?(r=n,(0,ko.dateI18n)((0,ko.getSettings)().formats.date,(0,ko.getDate)(r))):"";var r},enableSorting:!0,filterBy:!1},Io={sort:function(e,t,n){const r=Boolean(e);return r===Boolean(t)?0:"asc"===n?r?1:-1:r?-1:1},isValid:function(e){return!![!0,!1,void 0].includes(e)},Edit:"boolean",render:({item:e,field:t})=>t.elements?Co({item:e,field:t}):!0===t.getValue({item:e})?(0,s.__)("True"):!1===t.getValue({item:e})?(0,s.__)("False"):null,enableSorting:!0,filterBy:{defaultOperators:[m,g],validOperators:[m,g]}},Ao={sort:function(){return 0},isValid:function(e,t){if(t?.elements){const n=t?.elements.map((e=>e.value));if(!n.includes(e))return!1}return!0},Edit:null,render:()=>null,enableSorting:!1,filterBy:!1},Mo={sort:function(e,t,n){const r=Array.isArray(e)?e:[],i=Array.isArray(t)?t:[];if(r.length!==i.length)return"asc"===n?r.length-i.length:i.length-r.length;const o=r.join(","),a=i.join(",");return"asc"===n?o.localeCompare(a):a.localeCompare(o)},isValid:function(e,t){if(!Array.isArray(e))return!1;if(!e.every((e=>"string"==typeof e)))return!1;if(t?.elements){const n=t.elements.map((e=>e.value));if(!e.every((e=>n.includes(e))))return!1}return!0},Edit:null,render:function({item:e,field:t}){return(t.getValue({item:e})||[]).join(", ")},enableSorting:!0,filterBy:{defaultOperators:[v,y],validOperators:[v,y,b,w]}},No={[N]:[{value:"days",label:(0,s.__)("Days")},{value:"weeks",label:(0,s.__)("Weeks")},{value:"months",label:(0,s.__)("Months")},{value:"years",label:(0,s.__)("Years")}],[R]:[{value:"days",label:(0,s.__)("Days ago")},{value:"weeks",label:(0,s.__)("Weeks ago")},{value:"months",label:(0,s.__)("Months ago")},{value:"years",label:(0,s.__)("Years ago")}]};function Ro({id:e,value:n,onChange:r,label:i,hideLabelFromVision:o,options:a}){const{value:c="",unit:u=a[0].value}=n,d=(0,t.useCallback)((t=>r({[e]:{value:Number(t),unit:u}})),[e,r,u]),h=(0,t.useCallback)((t=>r({[e]:{value:c,unit:t}})),[e,r,c]);return(0,f.jsx)(l.BaseControl,{id:e,__nextHasNoMarginBottom:!0,className:"dataviews-controls__datetime",label:i,hideLabelFromVision:o,children:(0,f.jsxs)(l.__experimentalHStack,{spacing:2.5,children:[(0,f.jsx)(l.__experimentalNumberControl,{__next40pxDefaultSize:!0,className:"dataviews-controls__datetime-number",spinControls:"none",min:1,step:1,value:c,onChange:d}),(0,f.jsx)(l.SelectControl,{className:"dataviews-controls__datetime-unit",__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,s.__)("Unit"),value:u,options:a,onChange:h,hideLabelFromVision:!0})]})})}function Fo({id:e,value:n,onChange:r,hideLabelFromVision:i}){const[o="",a=""]=Array.isArray(n)?n:[],c=(0,t.useCallback)((t=>r({[e]:[Number(t),a]})),[e,r,a]),u=(0,t.useCallback)((t=>r({[e]:[o,Number(t)]})),[e,r,o]);return(0,f.jsx)(l.BaseControl,{__nextHasNoMarginBottom:!0,help:(0,s.__)("The max. value must be greater than the min. value."),children:(0,f.jsxs)(l.Flex,{direction:"row",gap:4,children:[(0,f.jsx)(l.__experimentalNumberControl,{label:(0,s.__)("Min."),value:o,max:a?Number(a)-1:void 0,onChange:c,__next40pxDefaultSize:!0,hideLabelFromVision:i}),(0,f.jsx)(l.__experimentalNumberControl,{label:(0,s.__)("Max."),value:a,min:o?Number(o)+1:void 0,onChange:u,__next40pxDefaultSize:!0,hideLabelFromVision:i})]})})}const Do={boolean:function({field:e,onChange:t,data:n,hideLabelFromVision:r}){const{id:i,getValue:o,label:a}=e;return(0,f.jsx)(l.ToggleControl,{hidden:r,__nextHasNoMarginBottom:!0,label:a,checked:o({item:n}),onChange:()=>t({[i]:!o({item:n})})})},checkbox:function({field:e,onChange:t,data:n,hideLabelFromVision:r}){const{id:i,getValue:o,label:a,description:s}=e;return(0,f.jsx)(l.CheckboxControl,{__nextHasNoMarginBottom:!0,hidden:r,label:a,help:s,checked:o({item:n}),onChange:()=>t({[i]:!o({item:n})})})},datetime:function({data:e,field:n,onChange:r,hideLabelFromVision:i,operator:o}){const{id:a,label:s}=n,c=n.getValue({item:e}),u=(0,t.useCallback)((e=>r({[a]:e})),[a,r]);return o===N||o===R?(0,f.jsx)(Ro,{id:a,value:c&&"object"==typeof c?c:{},onChange:r,label:s,hideLabelFromVision:i,options:No[o]}):(0,f.jsxs)("fieldset",{className:"dataviews-controls__datetime",children:[!i&&(0,f.jsx)(l.BaseControl.VisualLabel,{as:"legend",children:s}),i&&(0,f.jsx)(l.VisuallyHidden,{as:"legend",children:s}),(0,f.jsx)(l.TimePicker,{currentTime:"string"==typeof c?c:void 0,onChange:u,hideLabelFromVision:!0})]})},email:function({data:e,field:n,onChange:r,hideLabelFromVision:i}){const{id:o,label:a,placeholder:s,description:c}=n,u=n.getValue({item:e}),d=(0,t.useCallback)((e=>r({[o]:e})),[o,r]);return(0,f.jsx)(l.TextControl,{type:"email",label:a,placeholder:s,value:null!=u?u:"",help:c,onChange:d,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,hideLabelFromVision:i})},integer:function({data:e,field:n,onChange:r,hideLabelFromVision:i,operator:o}){var a;const{id:s,label:c,description:u}=n,d=null!==(a=n.getValue({item:e}))&&void 0!==a?a:"",h=(0,t.useCallback)((e=>r({[s]:Number(e)})),[s,r]);return o===I?(0,f.jsx)(Fo,{id:s,value:d,onChange:r,hideLabelFromVision:i}):(0,f.jsx)(l.__experimentalNumberControl,{label:c,help:u,value:d,onChange:h,__next40pxDefaultSize:!0,hideLabelFromVision:i})},radio:function({data:e,field:n,onChange:r,hideLabelFromVision:i}){const{id:o,label:a}=n,s=n.getValue({item:e}),c=(0,t.useCallback)((e=>r({[o]:e})),[o,r]);return n.elements?(0,f.jsx)(l.RadioControl,{label:a,onChange:c,options:n.elements,selected:s,hideLabelFromVision:i}):null},select:function({data:e,field:n,onChange:r,hideLabelFromVision:i}){var o,a;const{id:c,label:u}=n,d=null!==(o=n.getValue({item:e}))&&void 0!==o?o:"",h=(0,t.useCallback)((e=>r({[c]:e})),[c,r]),p=[{label:(0,s.__)("Select item"),value:""},...null!==(a=n?.elements)&&void 0!==a?a:[]];return(0,f.jsx)(l.SelectControl,{label:u,value:d,help:n.description,options:p,onChange:h,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,hideLabelFromVision:i})},text:function({data:e,field:n,onChange:r,hideLabelFromVision:i}){const{id:o,label:a,placeholder:s,description:c}=n,u=n.getValue({item:e}),d=(0,t.useCallback)((e=>r({[o]:e})),[o,r]);return(0,f.jsx)(l.TextControl,{label:a,placeholder:s,value:null!=u?u:"",help:c,onChange:d,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,hideLabelFromVision:i})},toggleGroup:function({data:e,field:n,onChange:r,hideLabelFromVision:i}){const{id:o}=n,a=n.getValue({item:e}),s=(0,t.useCallback)((e=>r({[o]:e})),[o,r]);if(n.elements){const e=n.elements.find((e=>e.value===a));return(0,f.jsx)(l.__experimentalToggleGroupControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,isBlock:!0,label:n.label,help:e?.description||n.description,onChange:s,value:a,hideLabelFromVision:i,children:n.elements.map((e=>(0,f.jsx)(l.__experimentalToggleGroupControlOption,{label:e.label,value:e.value},e.value)))})}return null}};function Vo(e){if(Object.keys(Do).includes(e))return Do[e];throw"Control "+e+" not found"}const Bo=e=>e.id,zo=()=>!0,Ho=[];function $o({header:e,search:n=!0,searchLabel:r}){const{isShowingFilter:i}=(0,t.useContext)(q);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(l.__experimentalHStack,{alignment:"top",justify:"space-between",className:"dataviews__view-actions",spacing:1,children:[(0,f.jsxs)(l.__experimentalHStack,{justify:"start",expanded:!1,className:"dataviews__search",children:[n&&(0,f.jsx)(to,{label:r}),(0,f.jsx)(Zr,{})]}),(0,f.jsxs)(l.__experimentalHStack,{spacing:1,expanded:!1,style:{flexShrink:0},children:[(0,f.jsx)(Eo,{}),e]})]}),i&&(0,f.jsx)(Jr,{className:"dataviews-filters__container"}),(0,f.jsx)(Yi,{}),(0,f.jsx)(eo,{})]})}const Go=function({view:e,onChangeView:r,fields:i,search:o=!0,searchLabel:a,actions:s=Ho,data:l,getItemId:c=Bo,getItemLevel:u,isLoading:d=!1,paginationInfo:h,defaultLayouts:p,selection:v,onChangeSelection:y,onClickItem:b,renderItemLink:w,isItemClickable:x=zo,header:_,children:E,perPageSizes:S}){const C=(0,t.useRef)(null),[O,P]=(0,t.useState)(0),j=(0,n.useResizeObserver)((e=>{P(e[0].borderBoxSize[0].inlineSize)}),{box:"border-box"}),[L,k]=(0,t.useState)([]),T=void 0===v||void 0===y,A=T?L:v,[M,N]=(0,t.useState)(null),R=(0,t.useMemo)((()=>function(e){return e.map((e=>{var t,n,r,i,o,a,s,l;const c="email"===(u=e.type)?Oo:"integer"===u?Po:"text"===u?jo:"datetime"===u?Lo:"date"===u?To:"boolean"===u?Io:"media"===u?Ao:"array"===u?Mo:{sort:(e,t,n)=>"number"==typeof e&&"number"==typeof t?"asc"===n?e-t:t-e:"asc"===n?e.localeCompare(t):t.localeCompare(e),isValid:(e,t)=>{if(t?.elements){const n=t?.elements?.map((e=>e.value));if(!n.includes(e))return!1}return!0},Edit:null,render:({item:e,field:t})=>t.elements?Co({item:e,field:t}):t.getValue({item:e}),enableSorting:!0,filterBy:{defaultOperators:[m,g],validOperators:F}};var u;const d=e.getValue||(f=e.id,({item:e})=>{const t=f.split(".");let n=e;for(const e of t)n=n.hasOwnProperty(e)?n[e]:void 0;return n});var f;const h=null!==(t=e.sort)&&void 0!==t?t:function(e,t,n){return c.sort(d({item:e}),d({item:t}),n)},p=null!==(n=e.isValid)&&void 0!==n?n:function(e,t){return c.isValid(d({item:e}),t)},v=function(e,t){return"function"==typeof e.Edit?e.Edit:"string"==typeof e.Edit?Vo(e.Edit):e.elements?Vo("select"):"string"==typeof t.Edit?Vo(t.Edit):t.Edit}(e,c),y=null!==(r=e.render)&&void 0!==r?r:function({item:e,field:t}){return c.render({item:e,field:t})},b=function(e,t){if(!1===e.filterBy)return!1;if("object"==typeof e.filterBy){let n=e.filterBy.operators;n&&Array.isArray(n)||(n=t.filterBy?t.filterBy.defaultOperators:[]);let r=F;return"object"==typeof t.filterBy&&(r=t.filterBy.validOperators),n=n.filter((e=>r.includes(e))),e.elements&&n.includes(I)&&(n=n.filter((e=>e!==I))),n.some((e=>D.includes(e)))&&(n=n.filter((e=>[...D,I].includes(e)))),0!==n.length&&{isPrimary:!!e.filterBy.isPrimary,operators:n}}if(!1===t.filterBy)return!1;let n=t.filterBy.defaultOperators;return e.elements&&n.includes(I)&&(n=n.filter((e=>e!==I))),{operators:n}}(e,c);return{...e,label:e.label||e.id,header:e.header||e.label||e.id,getValue:d,render:y,sort:h,isValid:p,Edit:v,enableHiding:null===(i=e.enableHiding)||void 0===i||i,enableSorting:null===(o=null!==(a=e.enableSorting)&&void 0!==a?a:c.enableSorting)||void 0===o||o,filterBy:b,readOnly:null!==(s=null!==(l=e.readOnly)&&void 0!==l?l:c.readOnly)&&void 0!==s&&s}}))}(i)),[i]),V=(0,t.useMemo)((()=>A.filter((e=>l.some((t=>c(t)===e))))),[A,l,c]),B=Kr(R,e),[z,H]=(0,t.useState)((()=>(B||[]).some((e=>e.isPrimary))));return(0,f.jsx)(q.Provider,{value:{view:e,onChangeView:r,fields:R,actions:s,data:l,isLoading:d,paginationInfo:h,selection:V,onChangeSelection:function(e){const t="function"==typeof e?e(A):e;T&&k(t),y&&y(t)},openedFilter:M,setOpenedFilter:N,getItemId:c,getItemLevel:u,isItemClickable:x,onClickItem:b,renderItemLink:w,containerWidth:O,containerRef:C,defaultLayouts:p,filters:B,isShowingFilter:z,setIsShowingFilter:H,perPageSizes:S},children:(0,f.jsx)("div",{className:"dataviews-wrapper",ref:(0,n.useMergeRefs)([C,j]),children:null!=E?E:(0,f.jsx)($o,{header:_,search:o,searchLabel:a})})})};Go.BulkActionToolbar=Ci,Go.Filters=Jr,Go.FiltersToggle=Zr,Go.Layout=Yi,Go.LayoutSwitcher=co,Go.Pagination=Zi,Go.Search=to,Go.ViewConfig=xo;const Uo=Go;var Wo=i(270),qo=i.n(Wo);const Yo=(...e)=>e.filter(((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t)).join(" ").trim();var Xo={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Ko=(0,Pe.forwardRef)((({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:o,iconNode:a,...s},l)=>(0,Pe.createElement)("svg",{ref:l,...Xo,width:t,height:t,stroke:e,strokeWidth:r?24*Number(n)/Number(t):n,className:Yo("lucide",i),...s},[...a.map((([e,t])=>(0,Pe.createElement)(e,t))),...Array.isArray(o)?o:[o]]))),Zo=(e,t)=>{const n=(0,Pe.forwardRef)((({className:n,...r},i)=>{return(0,Pe.createElement)(Ko,{ref:i,iconNode:t,className:Yo(`lucide-${o=e,o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,n),...r});var o}));return n.displayName=`${e}`,n},Qo=Zo("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Jo=Zo("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),ea=Zo("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);var ta=i(942),na=i.n(ta),ra=i(556),ia=i.n(ra);const oa=window.wp.a11y;function aa(e){return aa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},aa(e)}function sa(){return sa=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},sa.apply(null,arguments)}function la(e,t,n){return(t=function(e){var t=function(e){if("object"!=aa(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=aa(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==aa(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ca=function(e){var t=e.message,n=e.status,r=e.politeness,i=e.icon,o=e.className,a=e.inline,c=e.children,u=e.hasToTop,d=void 0!==u&&u;(0,Pe.useEffect)((function(){(0,oa.speak)(t,r)}),[t,n,r]);var f=function(){return null!==i},h=na()(o,"dlx-pw-admin__notice",la(la(la({"dlx-pw-admin__notice--has-icon":f()},"dlx-pw-admin__notice-type--".concat(n),!0),"dlx-pw-admin__notice-appearance--inline",a),"dlx-pw-admin__notice-appearance--block",!a)),p=[{label:(0,s.__)("Back to Top","wp-dlx-pw-comments"),url:"#dlx-pw-admin-header",variant:"link",className:"dlx-pw-admin__notice-action dlx-pw-admin__notice-action--to-top"}];return Le().createElement("div",{className:h},Le().createElement(l.Notice,sa({isDismissible:!1,spokenMessage:t,actions:d?p:[]},e),f()&&Le().createElement("div",{className:"dlx-pw-admin__notice-icon"},function(e){return Le().createElement(e,{width:16,height:16,fill:"#6c757d"})}(i)),Le().createElement("div",{className:"dlx-pw-admin__notice-message"},Le().createElement(Le().Fragment,null,t," ",c," "))))};ca.defaultProps={message:"",status:"info",politeness:"polite",icon:null,className:"",inline:!1,hasToTop:!1},ca.propTypes={message:ia().string.isRequired,status:ia().oneOf(["info","warning","success","error"]),politeness:ia().oneOf(["assertive","polite"]),icon:ia().func,className:ia().string,inline:ia().bool,hasToTop:ia().bool};const ua=ca;function da(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return fa(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fa(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function fa(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const ha=function(e){var t=e.loadingMessage,n={type:e.type,message:e.message,title:e.title,isDismissable:!1,isPersistent:!1,isSuccess:!1,loadingMessage:t,politeness:"polite"},r=da((0,Pe.useState)(n),2),i=r[0],o=(r[1],da((0,Pe.useState)(!1),2)),a=o[0],c=(o[1],da((0,Pe.useState)(!1),2)),u=c[0],d=c[1];(0,Pe.useEffect)((function(){e.isVisible&&setTimeout((function(){e.onClose()}),5e3)}),[e.isVisible]);var f=function(){switch(i.type){case"success":return Le().createElement(Qo,null);case"error":case"critical":return Le().createElement(Jo,null);default:return Le().createElement(ea,null)}};return Le().createElement(Le().Fragment,null,Le().createElement(l.Snackbar,{className:na()("dlx-pw-snackbar dlx-pw-snackbar-".concat(i.type),{"dlx-pw-snackbar-loading":a}),actions:function(){var e=[];return"success"===i.type&&e.push({label:(0,s.__)("Back to Top","pattern-wrangler"),url:"#dlx-pw-admin-header",variant:"link",className:"dlx-pw-admin__notice-action dlx-pw-admin__notice-action--to-top"}),e}(),icon:f(),onDismiss:function(){d(!1),e.onClose()},explicitDismiss:i.isDismissable},a?t:i.message)," ",u&&function(){if("critical"===i.type)return Le().createElement(l.Modal,{className:na()("dlx-pw-modal dlx-pw-modal-".concat(i.type),{"dlx-pw-modal-loading":a}),bodyOpenClassName:"dlx-pw-modal-body-open",title:i.title,onRequestClose:function(){d(!1)},isDismissible:!0,shouldCloseOnClickOutside:i.isPersistent,shouldCloseOnEsc:i.isPersistent},Le().createElement(ua,{message:i.message,status:i.type,politeness:i.politeness,icon:f,inline:!1}),Le().createElement("div",{className:"dlx-pw-modal-button-group"},Le().createElement(l.Button,{className:"button button-error",variant:"secondary",onClick:function(){d(!1)}},(0,s.__)("OK","pattern-wrangler"))))}()," ")};i(912);const pa=Zo("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var ma=e=>"checkbox"===e.type,ga=e=>e instanceof Date,va=e=>null==e;const ya=e=>"object"==typeof e;var ba=e=>!va(e)&&!Array.isArray(e)&&ya(e)&&!ga(e),wa=e=>ba(e)&&e.target?ma(e.target)?e.target.checked:e.target.value:e,xa=(e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)),_a="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function Ea(e){let t;const n=Array.isArray(e),r="undefined"!=typeof FileList&&e instanceof FileList;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else{if(_a&&(e instanceof Blob||r)||!n&&!ba(e))return e;if(t=n?[]:{},n||(e=>{const t=e.constructor&&e.constructor.prototype;return ba(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const n in e)e.hasOwnProperty(n)&&(t[n]=Ea(e[n]));else t=e}return t}var Sa=e=>Array.isArray(e)?e.filter(Boolean):[],Ca=e=>void 0===e,Oa=(e,t,n)=>{if(!t||!ba(e))return n;const r=Sa(t.split(/[,[\].]+?/)).reduce(((e,t)=>va(e)?e:e[t]),e);return Ca(r)||r===e?Ca(e[t])?n:e[t]:r},Pa=e=>"boolean"==typeof e,ja=e=>/^\w*$/.test(e),La=e=>Sa(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ka=(e,t,n)=>{let r=-1;const i=ja(t)?[t]:La(t),o=i.length,a=o-1;for(;++r<o;){const t=i[r];let o=n;if(r!==a){const n=e[t];o=ba(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=o,e=e[t]}return e};const Ta="blur",Ia="onChange",Aa="onSubmit",Ma="all",Na="pattern",Ra="required",Fa=Pe.createContext(null),Da=()=>Pe.useContext(Fa);var Va=(e,t,n,r=!0)=>{const i={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(i,o,{get:()=>{const i=o;return t._proxyFormState[i]!==Ma&&(t._proxyFormState[i]=!r||Ma),n&&(n[i]=!0),e[i]}});return i},Ba=e=>ba(e)&&!Object.keys(e).length,za=(e,t,n,r)=>{n(e);const{name:i,...o}=e;return Ba(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find((e=>t[e]===(!r||Ma)))},Ha=e=>Array.isArray(e)?e:[e],$a=(e,t,n)=>!e||!t||e===t||Ha(e).some((e=>e&&(n?e===t:e.startsWith(t)||t.startsWith(e))));function Ga(e){const t=Pe.useRef(e);t.current=e,Pe.useEffect((()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}}),[e.disabled])}function Ua(e){const t=Da(),{control:n=t.control,disabled:r,name:i,exact:o}=e||{},[a,s]=Pe.useState(n._formState),l=Pe.useRef(!0),c=Pe.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),u=Pe.useRef(i);return u.current=i,Ga({disabled:r,next:e=>l.current&&$a(u.current,e.name,o)&&za(e,c.current,n._updateFormState)&&s({...n._formState,...e}),subject:n._subjects.state}),Pe.useEffect((()=>(l.current=!0,c.current.isValid&&n._updateValid(!0),()=>{l.current=!1})),[n]),Pe.useMemo((()=>Va(a,n,c.current,!1)),[a,n])}var Wa=e=>"string"==typeof e,qa=(e,t,n,r,i)=>Wa(e)?(r&&t.watch.add(e),Oa(n,e,i)):Array.isArray(e)?e.map((e=>(r&&t.watch.add(e),Oa(n,e)))):(r&&(t.watchAll=!0),n);function Ya(e){const t=Da(),{control:n=t.control,name:r,defaultValue:i,disabled:o,exact:a}=e||{},s=Pe.useRef(r);s.current=r,Ga({disabled:o,subject:n._subjects.values,next:e=>{$a(s.current,e.name,a)&&c(Ea(qa(s.current,n._names,e.values||n._formValues,!1,i)))}});const[l,c]=Pe.useState(n._getWatch(r,i));return Pe.useEffect((()=>n._removeUnmounted())),l}const Xa=e=>e.render(function(e){const t=Da(),{name:n,disabled:r,control:i=t.control,shouldUnregister:o}=e,a=xa(i._names.array,n),s=Ya({control:i,name:n,defaultValue:Oa(i._formValues,n,Oa(i._defaultValues,n,e.defaultValue)),exact:!0}),l=Ua({control:i,name:n,exact:!0}),c=Pe.useRef(i.register(n,{...e.rules,value:s,...Pa(e.disabled)?{disabled:e.disabled}:{}})),u=Pe.useMemo((()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Oa(l.errors,n)},isDirty:{enumerable:!0,get:()=>!!Oa(l.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!Oa(l.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!Oa(l.validatingFields,n)},error:{enumerable:!0,get:()=>Oa(l.errors,n)}})),[l,n]),d=Pe.useMemo((()=>({name:n,value:s,...Pa(r)||l.disabled?{disabled:l.disabled||r}:{},onChange:e=>c.current.onChange({target:{value:wa(e),name:n},type:"change"}),onBlur:()=>c.current.onBlur({target:{value:Oa(i._formValues,n),name:n},type:Ta}),ref:e=>{const t=Oa(i._fields,n);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}})),[n,i._formValues,r,l.disabled,s,i._fields]);return Pe.useEffect((()=>{const e=i._options.shouldUnregister||o,t=(e,t)=>{const n=Oa(i._fields,e);n&&n._f&&(n._f.mount=t)};if(t(n,!0),e){const e=Ea(Oa(i._options.defaultValues,n));ka(i._defaultValues,n,e),Ca(Oa(i._formValues,n))&&ka(i._formValues,n,e)}return()=>{(a?e&&!i._state.action:e)?i.unregister(n):t(n,!1)}}),[n,i,a,o]),Pe.useEffect((()=>{Pa(r)&&Oa(i._fields,n)&&i._updateDisabledField({disabled:r,fields:i._fields,name:n,value:Oa(i._fields,n)._f.value})}),[r,n,i]),Pe.useMemo((()=>({field:d,formState:l,fieldState:u})),[d,l,u])}(e));var Ka=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},Za=e=>({isOnSubmit:!e||e===Aa,isOnBlur:"onBlur"===e,isOnChange:e===Ia,isOnAll:e===Ma,isOnTouch:"onTouched"===e}),Qa=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some((t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))));const Ja=(e,t,n,r)=>{for(const i of n||Object.keys(e)){const n=Oa(e,i);if(n){const{_f:e,...o}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r)return!0;if(e.ref&&t(e.ref,e.name)&&!r)return!0;if(Ja(o,t))break}else if(ba(o)&&Ja(o,t))break}}};var es=(e,t,n)=>{const r=Ha(Oa(e,n));return ka(r,"root",t[n]),ka(e,n,r),e},ts=e=>"file"===e.type,ns=e=>"function"==typeof e,rs=e=>{if(!_a)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},is=e=>Wa(e),os=e=>"radio"===e.type,as=e=>e instanceof RegExp;const ss={value:!1,isValid:!1},ls={value:!0,isValid:!0};var cs=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter((e=>e&&e.checked&&!e.disabled)).map((e=>e.value));return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Ca(e[0].attributes.value)?Ca(e[0].value)||""===e[0].value?ls:{value:e[0].value,isValid:!0}:ls:ss}return ss};const us={isValid:!1,value:null};var ds=e=>Array.isArray(e)?e.reduce(((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e),us):us;function fs(e,t,n="validate"){if(is(e)||Array.isArray(e)&&e.every(is)||Pa(e)&&!e)return{type:n,message:is(e)?e:"",ref:t}}var hs=e=>ba(e)&&!as(e)?e:{value:e,message:""},ps=async(e,t,n,r,i)=>{const{ref:o,refs:a,required:s,maxLength:l,minLength:c,min:u,max:d,pattern:f,validate:h,name:p,valueAsNumber:m,mount:g,disabled:v}=e._f,y=Oa(t,p);if(!g||v)return{};const b=a?a[0]:o,w=e=>{r&&b.reportValidity&&(b.setCustomValidity(Pa(e)?"":e||""),b.reportValidity())},x={},_=os(o),E=ma(o),S=_||E,C=(m||ts(o))&&Ca(o.value)&&Ca(y)||rs(o)&&""===o.value||""===y||Array.isArray(y)&&!y.length,O=Ka.bind(null,p,n,x),P=(e,t,n,r="maxLength",i="minLength")=>{const a=e?t:n;x[p]={type:e?r:i,message:a,ref:o,...O(e?r:i,a)}};if(i?!Array.isArray(y)||!y.length:s&&(!S&&(C||va(y))||Pa(y)&&!y||E&&!cs(a).isValid||_&&!ds(a).isValid)){const{value:e,message:t}=is(s)?{value:!!s,message:s}:hs(s);if(e&&(x[p]={type:Ra,message:t,ref:b,...O(Ra,t)},!n))return w(t),x}if(!(C||va(u)&&va(d))){let e,t;const r=hs(d),i=hs(u);if(va(y)||isNaN(y)){const n=o.valueAsDate||new Date(y),a=e=>new Date((new Date).toDateString()+" "+e),s="time"==o.type,l="week"==o.type;Wa(r.value)&&y&&(e=s?a(y)>a(r.value):l?y>r.value:n>new Date(r.value)),Wa(i.value)&&y&&(t=s?a(y)<a(i.value):l?y<i.value:n<new Date(i.value))}else{const n=o.valueAsNumber||(y?+y:y);va(r.value)||(e=n>r.value),va(i.value)||(t=n<i.value)}if((e||t)&&(P(!!e,r.message,i.message,"max","min"),!n))return w(x[p].message),x}if((l||c)&&!C&&(Wa(y)||i&&Array.isArray(y))){const e=hs(l),t=hs(c),r=!va(e.value)&&y.length>+e.value,i=!va(t.value)&&y.length<+t.value;if((r||i)&&(P(r,e.message,t.message),!n))return w(x[p].message),x}if(f&&!C&&Wa(y)){const{value:e,message:t}=hs(f);if(as(e)&&!y.match(e)&&(x[p]={type:Na,message:t,ref:o,...O(Na,t)},!n))return w(t),x}if(h)if(ns(h)){const e=fs(await h(y,t),b);if(e&&(x[p]={...e,...O("validate",e.message)},!n))return w(e.message),x}else if(ba(h)){let e={};for(const r in h){if(!Ba(e)&&!n)break;const i=fs(await h[r](y,t),b,r);i&&(e={...i,...O(r,i.message)},w(i.message),n&&(x[p]=e))}if(!Ba(e)&&(x[p]={ref:b,...e},!n))return x}return w(!0),x};function ms(e,t){const n=Array.isArray(t)?t:ja(t)?[t]:La(t),r=1===n.length?e:function(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=Ca(e)?r++:e[t[r++]];return e}(e,n),i=n.length-1,o=n[i];return r&&delete r[o],0!==i&&(ba(r)&&Ba(r)||Array.isArray(r)&&function(e){for(const t in e)if(e.hasOwnProperty(t)&&!Ca(e[t]))return!1;return!0}(r))&&ms(e,n.slice(0,-1)),e}var gs=()=>{let e=[];return{get observers(){return e},next:t=>{for(const n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter((e=>e!==t))}}),unsubscribe:()=>{e=[]}}},vs=e=>va(e)||!ya(e);function ys(e,t){if(vs(e)||vs(t))return e===t;if(ga(e)&&ga(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n){const n=e[i];if(!r.includes(i))return!1;if("ref"!==i){const e=t[i];if(ga(n)&&ga(e)||ba(n)&&ba(e)||Array.isArray(n)&&Array.isArray(e)?!ys(n,e):n!==e)return!1}}return!0}var bs=e=>"select-multiple"===e.type,ws=e=>rs(e)&&e.isConnected,xs=e=>{for(const t in e)if(ns(e[t]))return!0;return!1};function _s(e,t={}){const n=Array.isArray(e);if(ba(e)||n)for(const n in e)Array.isArray(e[n])||ba(e[n])&&!xs(e[n])?(t[n]=Array.isArray(e[n])?[]:{},_s(e[n],t[n])):va(e[n])||(t[n]=!0);return t}function Es(e,t,n){const r=Array.isArray(e);if(ba(e)||r)for(const r in e)Array.isArray(e[r])||ba(e[r])&&!xs(e[r])?Ca(t)||vs(n[r])?n[r]=Array.isArray(e[r])?_s(e[r],[]):{..._s(e[r])}:Es(e[r],va(t)?{}:t[r],n[r]):n[r]=!ys(e[r],t[r]);return n}var Ss=(e,t)=>Es(e,t,_s(t)),Cs=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>Ca(e)?e:t?""===e?NaN:e?+e:e:n&&Wa(e)?new Date(e):r?r(e):e;function Os(e){const t=e.ref;if(!(e.refs?e.refs.every((e=>e.disabled)):t.disabled))return ts(t)?t.files:os(t)?ds(e.refs).value:bs(t)?[...t.selectedOptions].map((({value:e})=>e)):ma(t)?cs(e.refs).value:Cs(Ca(t.value)?e.ref.value:t.value,e)}var Ps=e=>Ca(e)?e:as(e)?e.source:ba(e)?as(e.value)?e.value.source:e.value:e;const js="AsyncFunction";function Ls(e,t,n){const r=Oa(e,n);if(r||ja(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const r=i.join("."),o=Oa(t,r),a=Oa(e,r);if(o&&!Array.isArray(o)&&n!==r)return{name:n};if(a&&a.type)return{name:r,error:a};i.pop()}return{name:n}}const ks={mode:Aa,reValidateMode:Ia,shouldFocusError:!0};function Ts(e={}){let t,n={...ks,...e},r={submitCount:0,isDirty:!1,isLoading:ns(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1},i={},o=(ba(n.defaultValues)||ba(n.values))&&Ea(n.defaultValues||n.values)||{},a=n.shouldUnregister?{}:Ea(o),s={action:!1,mount:!1,watch:!1},l={mount:new Set,unMount:new Set,array:new Set,watch:new Set},c=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={values:gs(),array:gs(),state:gs()},f=Za(n.mode),h=Za(n.reValidateMode),p=n.criteriaMode===Ma,m=async e=>{if(!n.disabled&&(u.isValid||e)){const e=n.resolver?Ba((await b()).errors):await w(i,!0);e!==r.isValid&&d.state.next({isValid:e})}},g=(e,t)=>{n.disabled||!u.isValidating&&!u.validatingFields||((e||Array.from(l.mount)).forEach((e=>{e&&(t?ka(r.validatingFields,e,t):ms(r.validatingFields,e))})),d.state.next({validatingFields:r.validatingFields,isValidating:!Ba(r.validatingFields)}))},v=(e,t,n,r)=>{const l=Oa(i,e);if(l){const i=Oa(a,e,Ca(n)?Oa(o,e):n);Ca(i)||r&&r.defaultChecked||t?ka(a,e,t?i:Os(l._f)):E(e,i),s.mount&&m()}},y=(e,t,a,s,l)=>{let c=!1,f=!1;const h={name:e};if(!n.disabled){const n=!!(Oa(i,e)&&Oa(i,e)._f&&Oa(i,e)._f.disabled);if(!a||s){u.isDirty&&(f=r.isDirty,r.isDirty=h.isDirty=x(),c=f!==h.isDirty);const i=n||ys(Oa(o,e),t);f=!(n||!Oa(r.dirtyFields,e)),i||n?ms(r.dirtyFields,e):ka(r.dirtyFields,e,!0),h.dirtyFields=r.dirtyFields,c=c||u.dirtyFields&&f!==!i}if(a){const t=Oa(r.touchedFields,e);t||(ka(r.touchedFields,e,a),h.touchedFields=r.touchedFields,c=c||u.touchedFields&&t!==a)}c&&l&&d.state.next(h)}return c?h:{}},b=async e=>{g(e,!0);const t=await n.resolver(a,n.context,((e,t,n,r)=>{const i={};for(const n of e){const e=Oa(t,n);e&&ka(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}})(e||l.mount,i,n.criteriaMode,n.shouldUseNativeValidation));return g(e),t},w=async(e,t,i={valid:!0})=>{for(const s in e){const c=e[s];if(c){const{_f:e,...d}=c;if(e){const d=l.array.has(e.name),f=c._f&&!!(o=c._f)&&!!o.validate&&!!(ns(o.validate)&&o.validate.constructor.name===js||ba(o.validate)&&Object.values(o.validate).find((e=>e.constructor.name===js)));f&&u.validatingFields&&g([s],!0);const h=await ps(c,a,p,n.shouldUseNativeValidation&&!t,d);if(f&&u.validatingFields&&g([s]),h[e.name]&&(i.valid=!1,t))break;!t&&(Oa(h,e.name)?d?es(r.errors,h,e.name):ka(r.errors,e.name,h[e.name]):ms(r.errors,e.name))}!Ba(d)&&await w(d,t,i)}}var o;return i.valid},x=(e,t)=>!n.disabled&&(e&&t&&ka(a,e,t),!ys(L(),o)),_=(e,t,n)=>qa(e,l,{...s.mount?a:Ca(t)?o:Wa(e)?{[e]:t}:t},n,t),E=(e,t,n={})=>{const r=Oa(i,e);let o=t;if(r){const n=r._f;n&&(!n.disabled&&ka(a,e,Cs(t,n)),o=rs(n.ref)&&va(t)?"":t,bs(n.ref)?[...n.ref.options].forEach((e=>e.selected=o.includes(e.value))):n.refs?ma(n.ref)?n.refs.length>1?n.refs.forEach((e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(o)?!!o.find((t=>t===e.value)):o===e.value))):n.refs[0]&&(n.refs[0].checked=!!o):n.refs.forEach((e=>e.checked=e.value===o)):ts(n.ref)?n.ref.value="":(n.ref.value=o,n.ref.type||d.values.next({name:e,values:{...a}})))}(n.shouldDirty||n.shouldTouch)&&y(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&j(e)},S=(e,t,n)=>{for(const r in t){const o=t[r],a=`${e}.${r}`,s=Oa(i,a);(l.array.has(e)||ba(o)||s&&!s._f)&&!ga(o)?S(a,o,n):E(a,o,n)}},C=(e,t,n={})=>{const c=Oa(i,e),f=l.array.has(e),h=Ea(t);ka(a,e,h),f?(d.array.next({name:e,values:{...a}}),(u.isDirty||u.dirtyFields)&&n.shouldDirty&&d.state.next({name:e,dirtyFields:Ss(o,a),isDirty:x(e,h)})):!c||c._f||va(h)?E(e,h,n):S(e,h,n),Qa(e,l)&&d.state.next({...r}),d.values.next({name:s.mount?e:void 0,values:{...a}})},O=async e=>{s.mount=!0;const o=e.target;let v=o.name,x=!0;const _=Oa(i,v),E=e=>{x=Number.isNaN(e)||ga(e)&&isNaN(e.getTime())||ys(e,Oa(a,v,e))};if(_){let s,C;const O=o.type?Os(_._f):wa(e),P=e.type===Ta||"focusout"===e.type,L=!((S=_._f).mount&&(S.required||S.min||S.max||S.maxLength||S.minLength||S.pattern||S.validate)||n.resolver||Oa(r.errors,v)||_._f.deps)||((e,t,n,r,i)=>!i.isOnAll&&(!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:!(n?r.isOnChange:i.isOnChange)||e))(P,Oa(r.touchedFields,v),r.isSubmitted,h,f),k=Qa(v,l,P);ka(a,v,O),P?(_._f.onBlur&&_._f.onBlur(e),t&&t(0)):_._f.onChange&&_._f.onChange(e);const T=y(v,O,P,!1),I=!Ba(T)||k;if(!P&&d.values.next({name:v,type:e.type,values:{...a}}),L)return u.isValid&&("onBlur"===n.mode?P&&m():m()),I&&d.state.next({name:v,...k?{}:T});if(!P&&k&&d.state.next({...r}),n.resolver){const{errors:e}=await b([v]);if(E(O),x){const t=Ls(r.errors,i,v),n=Ls(e,i,t.name||v);s=n.error,v=n.name,C=Ba(e)}}else g([v],!0),s=(await ps(_,a,p,n.shouldUseNativeValidation))[v],g([v]),E(O),x&&(s?C=!1:u.isValid&&(C=await w(i,!0)));x&&(_._f.deps&&j(_._f.deps),((e,i,o,a)=>{const s=Oa(r.errors,e),l=u.isValid&&Pa(i)&&r.isValid!==i;var f;if(n.delayError&&o?(f=()=>((e,t)=>{ka(r.errors,e,t),d.state.next({errors:r.errors})})(e,o),t=e=>{clearTimeout(c),c=setTimeout(f,e)},t(n.delayError)):(clearTimeout(c),t=null,o?ka(r.errors,e,o):ms(r.errors,e)),(o?!ys(s,o):s)||!Ba(a)||l){const t={...a,...l&&Pa(i)?{isValid:i}:{},errors:r.errors,name:e};r={...r,...t},d.state.next(t)}})(v,C,s,T))}var S},P=(e,t)=>{if(Oa(r.errors,t)&&e.focus)return e.focus(),1},j=async(e,t={})=>{let o,a;const s=Ha(e);if(n.resolver){const t=await(async e=>{const{errors:t}=await b(e);if(e)for(const n of e){const e=Oa(t,n);e?ka(r.errors,n,e):ms(r.errors,n)}else r.errors=t;return t})(Ca(e)?e:s);o=Ba(t),a=e?!s.some((e=>Oa(t,e))):o}else e?(a=(await Promise.all(s.map((async e=>{const t=Oa(i,e);return await w(t&&t._f?{[e]:t}:t)})))).every(Boolean),(a||r.isValid)&&m()):a=o=await w(i);return d.state.next({...!Wa(e)||u.isValid&&o!==r.isValid?{}:{name:e},...n.resolver||!e?{isValid:o}:{},errors:r.errors}),t.shouldFocus&&!a&&Ja(i,P,e?s:l.mount),a},L=e=>{const t={...s.mount?a:o};return Ca(e)?t:Wa(e)?Oa(t,e):e.map((e=>Oa(t,e)))},k=(e,t)=>({invalid:!!Oa((t||r).errors,e),isDirty:!!Oa((t||r).dirtyFields,e),error:Oa((t||r).errors,e),isValidating:!!Oa(r.validatingFields,e),isTouched:!!Oa((t||r).touchedFields,e)}),T=(e,t,n)=>{const o=(Oa(i,e,{_f:{}})._f||{}).ref,a=Oa(r.errors,e)||{},{ref:s,message:l,type:c,...u}=a;ka(r.errors,e,{...u,...t,ref:o}),d.state.next({name:e,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&o&&o.focus&&o.focus()},I=(e,t={})=>{for(const s of e?Ha(e):l.mount)l.mount.delete(s),l.array.delete(s),t.keepValue||(ms(i,s),ms(a,s)),!t.keepError&&ms(r.errors,s),!t.keepDirty&&ms(r.dirtyFields,s),!t.keepTouched&&ms(r.touchedFields,s),!t.keepIsValidating&&ms(r.validatingFields,s),!n.shouldUnregister&&!t.keepDefaultValue&&ms(o,s);d.values.next({values:{...a}}),d.state.next({...r,...t.keepDirty?{isDirty:x()}:{}}),!t.keepIsValid&&m()},A=({disabled:e,name:t,field:n,fields:r,value:i})=>{if(Pa(e)&&s.mount||e){const o=e?void 0:Ca(i)?Os(n?n._f:Oa(r,t)._f):i;(e||!e&&!Ca(o))&&ka(a,t,o),y(t,o,!1,!1,!0)}},M=(e,t={})=>{let r=Oa(i,e);const a=Pa(t.disabled)||Pa(n.disabled);return ka(i,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),l.mount.add(e),r?A({field:r,disabled:Pa(t.disabled)?t.disabled:n.disabled,name:e,value:t.value}):v(e,!0,t.value),{...a?{disabled:t.disabled||n.disabled}:{},...n.progressive?{required:!!t.required,min:Ps(t.min),max:Ps(t.max),minLength:Ps(t.minLength),maxLength:Ps(t.maxLength),pattern:Ps(t.pattern)}:{},name:e,onChange:O,onBlur:O,ref:a=>{if(a){M(e,t),r=Oa(i,e);const n=Ca(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,s=(e=>os(e)||ma(e))(n),l=r._f.refs||[];if(s?l.find((e=>e===n)):n===r._f.ref)return;ka(i,e,{_f:{...r._f,...s?{refs:[...l.filter(ws),n,...Array.isArray(Oa(o,e))?[{}]:[]],ref:{type:n.type,name:e}}:{ref:n}}}),v(e,!1,void 0,n)}else r=Oa(i,e,{}),r._f&&(r._f.mount=!1),(n.shouldUnregister||t.shouldUnregister)&&(!xa(l.array,e)||!s.action)&&l.unMount.add(e)}}},N=()=>n.shouldFocusError&&Ja(i,P,l.mount),R=(e,t)=>async o=>{let s;if(o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist()),n.disabled)return void(t&&await t({...r.errors},o));let l=Ea(a);if(d.state.next({isSubmitting:!0}),n.resolver){const{errors:e,values:t}=await b();r.errors=e,l=t}else await w(i);if(ms(r.errors,"root"),Ba(r.errors)){d.state.next({errors:{}});try{await e(l,o)}catch(e){s=e}}else t&&await t({...r.errors},o),N(),setTimeout(N);if(d.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Ba(r.errors)&&!s,submitCount:r.submitCount+1,errors:r.errors}),s)throw s},F=(e,t={})=>{const c=e?Ea(e):o,f=Ea(c),h=Ba(e),p=h?o:f;if(t.keepDefaultValues||(o=c),!t.keepValues){if(t.keepDirtyValues){const e=new Set([...l.mount,...Object.keys(Ss(o,a))]);for(const t of Array.from(e))Oa(r.dirtyFields,t)?ka(p,t,Oa(a,t)):C(t,Oa(p,t))}else{if(_a&&Ca(e))for(const e of l.mount){const t=Oa(i,e);if(t&&t._f){const e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(rs(e)){const t=e.closest("form");if(t){t.reset();break}}}}i={}}a=n.shouldUnregister?t.keepDefaultValues?Ea(o):{}:Ea(p),d.array.next({values:{...p}}),d.values.next({values:{...p}})}l={mount:t.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},s.mount=!u.isValid||!!t.keepIsValid||!!t.keepDirtyValues,s.watch=!!n.shouldUnregister,d.state.next({submitCount:t.keepSubmitCount?r.submitCount:0,isDirty:!h&&(t.keepDirty?r.isDirty:!(!t.keepDefaultValues||ys(e,o))),isSubmitted:!!t.keepIsSubmitted&&r.isSubmitted,dirtyFields:h?{}:t.keepDirtyValues?t.keepDefaultValues&&a?Ss(o,a):r.dirtyFields:t.keepDefaultValues&&e?Ss(o,e):t.keepDirty?r.dirtyFields:{},touchedFields:t.keepTouched?r.touchedFields:{},errors:t.keepErrors?r.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&r.isSubmitSuccessful,isSubmitting:!1})},D=(e,t)=>F(ns(e)?e(a):e,t);return{control:{register:M,unregister:I,getFieldState:k,handleSubmit:R,setError:T,_executeSchema:b,_getWatch:_,_getDirty:x,_updateValid:m,_removeUnmounted:()=>{for(const e of l.unMount){const t=Oa(i,e);t&&(t._f.refs?t._f.refs.every((e=>!ws(e))):!ws(t._f.ref))&&I(e)}l.unMount=new Set},_updateFieldArray:(e,t=[],l,c,f=!0,h=!0)=>{if(c&&l&&!n.disabled){if(s.action=!0,h&&Array.isArray(Oa(i,e))){const t=l(Oa(i,e),c.argA,c.argB);f&&ka(i,e,t)}if(h&&Array.isArray(Oa(r.errors,e))){const t=l(Oa(r.errors,e),c.argA,c.argB);f&&ka(r.errors,e,t),((e,t)=>{!Sa(Oa(e,t)).length&&ms(e,t)})(r.errors,e)}if(u.touchedFields&&h&&Array.isArray(Oa(r.touchedFields,e))){const t=l(Oa(r.touchedFields,e),c.argA,c.argB);f&&ka(r.touchedFields,e,t)}u.dirtyFields&&(r.dirtyFields=Ss(o,a)),d.state.next({name:e,isDirty:x(e,t),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ka(a,e,t)},_updateDisabledField:A,_getFieldArray:e=>Sa(Oa(s.mount?a:o,e,n.shouldUnregister?Oa(o,e,[]):[])),_reset:F,_resetDefaultValues:()=>ns(n.defaultValues)&&n.defaultValues().then((e=>{D(e,n.resetOptions),d.state.next({isLoading:!1})})),_updateFormState:e=>{r={...r,...e}},_disableForm:e=>{Pa(e)&&(d.state.next({disabled:e}),Ja(i,((t,n)=>{const r=Oa(i,n);r&&(t.disabled=r._f.disabled||e,Array.isArray(r._f.refs)&&r._f.refs.forEach((t=>{t.disabled=r._f.disabled||e})))}),0,!1))},_subjects:d,_proxyFormState:u,_setErrors:e=>{r.errors=e,d.state.next({errors:r.errors,isValid:!1})},get _fields(){return i},get _formValues(){return a},get _state(){return s},set _state(e){s=e},get _defaultValues(){return o},get _names(){return l},set _names(e){l=e},get _formState(){return r},set _formState(e){r=e},get _options(){return n},set _options(e){n={...n,...e}}},trigger:j,register:M,handleSubmit:R,watch:(e,t)=>ns(e)?d.values.subscribe({next:n=>e(_(void 0,t),n)}):_(e,t,!0),setValue:C,getValues:L,reset:D,resetField:(e,t={})=>{Oa(i,e)&&(Ca(t.defaultValue)?C(e,Ea(Oa(o,e))):(C(e,t.defaultValue),ka(o,e,Ea(t.defaultValue))),t.keepTouched||ms(r.touchedFields,e),t.keepDirty||(ms(r.dirtyFields,e),r.isDirty=t.defaultValue?x(e,Ea(Oa(o,e))):x()),t.keepError||(ms(r.errors,e),u.isValid&&m()),d.state.next({...r}))},clearErrors:e=>{e&&Ha(e).forEach((e=>ms(r.errors,e))),d.state.next({errors:e?r.errors:{}})},unregister:I,setError:T,setFocus:(e,t={})=>{const n=Oa(i,e),r=n&&n._f;if(r){const e=r.refs?r.refs[0]:r.ref;e.focus&&(e.focus(),t.shouldSelect&&ns(e.select)&&e.select())}},getFieldState:k}}function Is(e={}){const t=Pe.useRef(void 0),n=Pe.useRef(void 0),[r,i]=Pe.useState({isDirty:!1,isValidating:!1,isLoading:ns(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ns(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ts(e),formState:r});const o=t.current.control;return o._options=e,Ga({subject:o._subjects.state,next:e=>{za(e,o._proxyFormState,o._updateFormState,!0)&&i({...o._formState})}}),Pe.useEffect((()=>o._disableForm(e.disabled)),[o,e.disabled]),Pe.useEffect((()=>{if(o._proxyFormState.isDirty){const e=o._getDirty();e!==r.isDirty&&o._subjects.state.next({isDirty:e})}}),[o,r.isDirty]),Pe.useEffect((()=>{e.values&&!ys(e.values,n.current)?(o._reset(e.values,o._options.resetOptions),n.current=e.values,i((e=>({...e})))):o._resetDefaultValues()}),[e.values,o]),Pe.useEffect((()=>{e.errors&&o._setErrors(e.errors)}),[e.errors,o]),Pe.useEffect((()=>{o._state.mount||(o._updateValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()})),Pe.useEffect((()=>{e.shouldUnregister&&o._subjects.values.next({values:o._getWatch()})}),[e.shouldUnregister,o]),t.current.formState=Va(r,o),t.current}function As(e){return As="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},As(e)}function Ms(){Ms=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==As(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(As(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function Ns(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function Rs(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Fs(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Fs(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Fs(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const Ds=function(e){var t,n=e.categories||[],r=(e.categories||[]).map((function(e){return e.label||e.name})),i=(e.patternCategories||[]).map((function(e){return e.label||e.name})),o=Rs((0,Pe.useState)(e.copyPatternId||0),1)[0],a=Rs((0,Pe.useState)(e.syncedDefaultStatus||"synced"),1)[0],c=Rs((0,Pe.useState)(e.syncedDisabled||!1),1)[0],d=Rs((0,Pe.useState)(!1),2),f=d[0],h=d[1],p=Rs((0,Pe.useState)(e.isEditMode||!1),2),m=p[0],g=(p[1],Is({defaultValues:{patternId:e.patternId||0,patternNonce:e.patternNonce||"",patternTitle:e.patternTitle||"",patternCategories:i||[],patternSyncStatus:e.patternSyncStatus||a,patternCopyId:o}})),v=g.control,y=(g.getValues,g.handleSubmit),b=(g.reset,g.setError),w=(g.trigger,g.setValue,Ya({control:v}),Ua({control:v})),x=w.errors,_=(w.isDirty,w.dirtyFields,function(){var t,r=(t=Ms().mark((function t(r){var i,o,a,s,l;return Ms().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return h(!0),i=r.patternCategories.map((function(e){return{name:e,id:(t=e,r=n.find((function(e){return(e.label||e.name).toLowerCase()===t.toLowerCase()})),r?r.id:0)};var t,r})),o=m?"/dlxplugins/pattern-wrangler/v1/patterns/update/":"/dlxplugins/pattern-wrangler/v1/patterns/create/",t.next=5,u()({path:o,method:"POST",data:{patternId:r.patternId,patternNonce:r.patternNonce,nonce:dlxEnhancedPatternsView.createNonce,patternTitle:r.patternTitle,patternCategories:i,patternSyncStatus:r.patternSyncStatus,patternCopyId:r.patternCopyId}});case 5:null!=(a=t.sent)&&a.error?b("patternTitle",{message:a.error}):(s=a.patternId,m?e.onEdit(a):(l=encodeURIComponent(window.location.href),window.location.href="".concat(dlxEnhancedPatternsView.getSiteBaseUrl,"post.php?post=").concat(s,"&action=edit&redirect_to=").concat(l))),h(!1);case 8:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(e){Ns(o,r,i,a,s,"next",e)}function s(e){Ns(o,r,i,a,s,"throw",e)}a(void 0)}))});return function(_x){return r.apply(this,arguments)}}());return Le().createElement(Le().Fragment,null,Le().createElement(l.Modal,{title:e.title||(0,s.__)("Add Pattern","pattern-wrangler"),onRequestClose:e.onRequestClose,focusOnMount:"firstContentElement"},Le().createElement("div",{className:"dlx-pw-modal-content"},Le().createElement("form",{onSubmit:y(_)},Le().createElement("div",{className:"dlx-pw-modal-admin-row"},Le().createElement(Xa,{control:v,name:"patternTitle",rules:{required:(0,s.__)("Pattern title is required.","pattern-wrangler")},render:function(e){var t=e.field;return Le().createElement(l.TextControl,{label:(0,s.__)("Pattern Title","pattern-wrangler"),help:(0,s.__)("Enter the title of the pattern.","pattern-wrangler"),value:t.value,onChange:function(e){return t.onChange(e)},disabled:f})}})),Le().createElement("div",{className:"dlx-pw-modal-admin-row"},Le().createElement(Xa,{control:v,name:"patternCategories[]",render:function(e){var t=e.field;return Le().createElement(Le().Fragment,null,Le().createElement(l.FormTokenField,{label:(0,s.__)("Categories","pattern-wrangler"),help:(0,s.__)("Enter the categories of the pattern.","pattern-wrangler"),value:t.value,onChange:function(e){t.onChange(e)},tokenizeOnSpace:!1,allowMultiple:!0,placeholder:(0,s.__)("Add a category","pattern-wrangler"),suggestions:r,disabled:f,__experimentalShowHowTo:!1}),Le().createElement("p",{className:"description"},(0,s.__)("Separate with commas or press the Enter key.","pattern-wrangler")))}})),Le().createElement("div",{className:"dlx-pw-modal-admin-row"},Le().createElement(Xa,{control:v,name:"patternSyncStatus",render:function(e){var t=e.field;return Le().createElement(Le().Fragment,null,Le().createElement(l.__experimentalToggleGroupControl,{label:(0,s.__)("Sync Status","pattern-wrangler"),isAdaptiveWidth:!0,value:t.value,onChange:function(e){t.onChange(e)},disabled:f||c},Le().createElement(l.__experimentalToggleGroupControlOption,{value:"synced",label:(0,s.__)("Synced","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Synced","pattern-wrangler"),disabled:c}),Le().createElement(l.__experimentalToggleGroupControlOption,{value:"unsynced",label:(0,s.__)("Unsynced","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Unsynced","pattern-wrangler"),disabled:c})))}})),Le().createElement("div",{className:"dlx-pw-modal-admin-row dlx-pw-modal-admin-row-buttons"},Le().createElement(l.Button,{variant:"primary",type:"submit",disabled:f},(t=(0,s.__)("Add Pattern","pattern-wrangler"),m&&(t=(0,s.__)("Save Pattern","pattern-wrangler")),f&&(t=(0,s.__)("Saving Pattern…","pattern-wrangler")),t)),Le().createElement(l.Button,{variant:"secondary",onClick:e.onRequestClose,disabled:f},(0,s.__)("Cancel","pattern-wrangler"))),(null==x?void 0:x.patternTitle)&&Le().createElement(ua,{className:"dlx-pw-admin-notice",status:"error",inline:!0,icon:function(){return Le().createElement(pa,null)}},x.patternTitle.message)))))};function Vs(e){return Vs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Vs(e)}function Bs(){Bs=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==Vs(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Vs(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function zs(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function Hs(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const $s=function(e){var t,n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Hs(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Hs(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,Pe.useState)(!1),2),r=n[0],i=n[1],o=Is({defaultValues:{items:e.items||[],patternNonce:e.patternNonce||"",forceDelete:!1}}),a=o.control,c=(o.getValues,o.handleSubmit),d=(o.reset,o.setError,o.trigger,o.setValue,Ya({control:a}),Ua({control:a})),f=d.errors,h=(d.isDirty,d.dirtyFields,function(){var t,n=(t=Bs().mark((function t(n){var r,o;return Bs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i(!0),r=n.items.map((function(e){return{id:e.id,nonce:e.editNonce}})),t.next=5,u()({path:"/dlxplugins/pattern-wrangler/v1/patterns/pause/",method:"POST",data:{items:r}});case 5:o=t.sent,e.onPause(o,r),i(!1);case 8:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(e){zs(o,r,i,a,s,"next",e)}function s(e){zs(o,r,i,a,s,"throw",e)}a(void 0)}))});return function(_x){return n.apply(this,arguments)}}());return Le().createElement(Le().Fragment,null,Le().createElement(l.Modal,{title:1===e.items.length?(0,s.__)("Disable Pattern","pattern-wrangler"):(0,s._n)("Disable Pattern","Disable Patterns",e.items.length,"pattern-wrangler"),onRequestClose:e.onRequestClose,focusOnMount:"firstContentElement"},Le().createElement("div",{className:"dlx-pw-modal-content"},Le().createElement("form",{onSubmit:c(h)},Le().createElement("div",{className:"dlx-pw-modal-admin-row dlx-pw-modal-admin-row-buttons"},Le().createElement(l.Button,{variant:"primary",type:"submit",disabled:r},(t=(0,s._n)("Disable Pattern","Disable Patterns",e.items.length,"pattern-wrangler"),r&&(t=(0,s._n)("Disabling Pattern…","Disabling Patterns…",e.items.length,"pattern-wrangler")),t)),Le().createElement(l.Button,{variant:"secondary",onClick:e.onRequestClose,disabled:r},(0,s.__)("Cancel","pattern-wrangler"))),(null==f?void 0:f.patternTitle)&&Le().createElement(ua,{className:"dlx-pw-admin-notice",status:"error",inline:!0,icon:function(){return Le().createElement(pa,null)}},f.patternTitle.message)))))};function Gs(e){return Gs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gs(e)}function Us(){Us=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==Gs(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Gs(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function Ws(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function qs(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const Ys=function(e){var t,n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return qs(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?qs(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,Pe.useState)(!1),2),r=n[0],i=n[1],o=Is({defaultValues:{items:e.items||[],patternNonce:e.patternNonce||"",forceDelete:!1}}),a=o.control,c=(o.getValues,o.handleSubmit),d=(o.reset,o.setError,o.trigger,o.setValue,Ya({control:a}),Ua({control:a})),f=d.errors,h=(d.isDirty,d.dirtyFields,function(){var t,n=(t=Us().mark((function t(n){var r,o;return Us().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i(!0),r=n.items.map((function(e){return{id:e.id,nonce:e.editNonce}})),t.next=5,u()({path:"/dlxplugins/pattern-wrangler/v1/patterns/publish/",method:"POST",data:{items:r}});case 5:o=t.sent,e.onPublish(o,r),i(!1);case 8:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(e){Ws(o,r,i,a,s,"next",e)}function s(e){Ws(o,r,i,a,s,"throw",e)}a(void 0)}))});return function(_x){return n.apply(this,arguments)}}());return Le().createElement(Le().Fragment,null,Le().createElement(l.Modal,{title:1===e.items.length?(0,s.__)("Publish Pattern","pattern-wrangler"):(0,s._n)("Publish Pattern","Publish Patterns",e.items.length,"pattern-wrangler"),onRequestClose:e.onRequestClose,focusOnMount:"firstContentElement"},Le().createElement("div",{className:"dlx-pw-modal-content"},Le().createElement("form",{onSubmit:c(h)},Le().createElement("div",{className:"dlx-pw-modal-admin-row dlx-pw-modal-admin-row-buttons"},Le().createElement(l.Button,{variant:"primary",type:"submit",disabled:r},(t=(0,s._n)("Publish Pattern","Publish Patterns",e.items.length,"pattern-wrangler"),r&&(t=(0,s._n)("Publishing Pattern…","Publishing Patterns…",e.items.length,"pattern-wrangler")),t)),Le().createElement(l.Button,{variant:"secondary",onClick:e.onRequestClose,disabled:r},(0,s.__)("Cancel","pattern-wrangler"))),(null==f?void 0:f.patternTitle)&&Le().createElement(ua,{className:"dlx-pw-admin-notice",status:"error",inline:!0,icon:function(){return Le().createElement(pa,null)}},f.patternTitle.message)))))};function Xs(e){return Xs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xs(e)}function Ks(){Ks=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==Xs(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Xs(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function Zs(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function Qs(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const Js=function(e){var t,n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Qs(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qs(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,Pe.useState)(!1),2),r=n[0],i=n[1],o=Is({defaultValues:{items:e.items||[],patternNonce:e.patternNonce||"",forceDelete:!1}}),a=o.control,c=(o.getValues,o.handleSubmit),d=(o.reset,o.setError,o.trigger,o.setValue,Ya({control:a}),Ua({control:a})),f=d.errors,h=(d.isDirty,d.dirtyFields,function(){var t,n=(t=Ks().mark((function t(n){var r,o;return Ks().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i(!0),r=n.items.map((function(e){return{id:e.id,nonce:e.editNonce}})),t.next=5,u()({path:"/dlxplugins/pattern-wrangler/v1/patterns/publish/",method:"POST",data:{items:r}});case 5:o=t.sent,e.onReenable(o,r),i(!1);case 8:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(e){Zs(o,r,i,a,s,"next",e)}function s(e){Zs(o,r,i,a,s,"throw",e)}a(void 0)}))});return function(_x){return n.apply(this,arguments)}}());return Le().createElement(Le().Fragment,null,Le().createElement(l.Modal,{title:1===e.items.length?(0,s.__)("Re-enable Pattern","pattern-wrangler"):(0,s._n)("Re-enable Pattern","Re-enable Patterns",e.items.length,"pattern-wrangler"),onRequestClose:e.onRequestClose,focusOnMount:"firstContentElement"},Le().createElement("div",{className:"dlx-pw-modal-content"},Le().createElement("form",{onSubmit:c(h)},Le().createElement("div",{className:"dlx-pw-modal-admin-row dlx-pw-modal-admin-row-buttons"},Le().createElement(l.Button,{variant:"primary",type:"submit",disabled:r},(t=(0,s._n)("Re-enable Pattern","Re-enable Patterns",e.items.length,"pattern-wrangler"),r&&(t=(0,s._n)("Re-enabling Pattern…","Re-enabling Patterns…",e.items.length,"pattern-wrangler")),t)),Le().createElement(l.Button,{variant:"secondary",onClick:e.onRequestClose,disabled:r},(0,s.__)("Cancel","pattern-wrangler"))),(null==f?void 0:f.patternTitle)&&Le().createElement(ua,{className:"dlx-pw-admin-notice",status:"error",inline:!0,icon:function(){return Le().createElement(pa,null)}},f.patternTitle.message)))))};function el(e){return el="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},el(e)}function tl(){tl=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==el(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(el(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function nl(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function rl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const il=function(e){var t,n=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return rl(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?rl(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}((0,Pe.useState)(!1),2),r=n[0],i=n[1],o=Is({defaultValues:{items:e.items||[],patternNonce:e.patternNonce||"",forceDelete:!1}}),a=o.control,c=(o.getValues,o.handleSubmit),d=(o.reset,o.setError,o.trigger,o.setValue,Ya({control:a}),Ua({control:a})),f=d.errors,h=(d.isDirty,d.dirtyFields,function(){var t,n=(t=tl().mark((function t(n){var r,o;return tl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i(!0),r=n.items.map((function(e){return{id:e.id,nonce:e.editNonce}})),t.next=5,u()({path:"/dlxplugins/pattern-wrangler/v1/patterns/delete/",method:"POST",data:{items:r}});case 5:o=t.sent,e.onDelete(o,r),i(!1);case 8:case"end":return t.stop()}}),t)})),function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(e){nl(o,r,i,a,s,"next",e)}function s(e){nl(o,r,i,a,s,"throw",e)}a(void 0)}))});return function(_x){return n.apply(this,arguments)}}());return Le().createElement(Le().Fragment,null,Le().createElement(l.Modal,{title:1===e.items.length?(0,s.__)("Delete Pattern","pattern-wrangler"):(0,s._n)("Delete Pattern","Delete Patterns",e.items.length,"pattern-wrangler"),onRequestClose:e.onRequestClose,focusOnMount:"firstContentElement"},Le().createElement("div",{className:"dlx-pw-modal-content"},Le().createElement("form",{onSubmit:c(h)},Le().createElement("div",{className:"dlx-pw-modal-admin-row dlx-pw-modal-admin-row-buttons"},Le().createElement(l.Button,{variant:"primary",type:"submit",isDestructive:!0,disabled:r},(t=(0,s._n)("Delete Pattern","Delete Patterns",e.items.length,"pattern-wrangler"),r&&(t=(0,s._n)("Deleting Pattern…","Deleting Patterns…",e.items.length,"pattern-wrangler")),t)),Le().createElement(l.Button,{variant:"secondary",onClick:e.onRequestClose,disabled:r},(0,s.__)("Cancel","pattern-wrangler"))),(null==f?void 0:f.patternTitle)&&Le().createElement(ua,{className:"dlx-pw-admin-notice",status:"error",inline:!0,icon:function(){return Le().createElement(pa,null)}},f.patternTitle.message)))))};function ol(e){return ol="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ol(e)}function al(){al=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==ol(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(ol(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function sl(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function ll(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){sl(o,r,i,a,s,"next",e)}function s(e){sl(o,r,i,a,s,"throw",e)}a(void 0)}))}}function cl(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ul(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ul(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ul(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}const dl=function(e){var t=cl((0,Pe.useState)(dlxEnhancedPatternsView.isMultisite),1)[0],n=cl((0,Pe.useState)(null),2),r=n[0],i=n[1],o=cl((0,Pe.useState)(null),2),a=o[0],c=o[1],u=function(){var e=ll(al().mark((function e(t,n){var r,i;return al().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=document.createElement("button")).classList.add("dlx-pw-copy-shortcode"),r.innerHTML='<span class="dashicons dashicons-clipboard"></span>',i=function(){var e=ll(al().mark((function e(){var t,i,o;return al().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=!1,null===(t=navigator.clipboard)||void 0===t||!t.writeText){e.next=10;break}return e.prev=2,e.next=5,navigator.clipboard.writeText(n);case 5:i=!0,e.next=10;break;case 8:e.prev=8,e.t0=e.catch(2);case 10:if(!i){(o=document.createElement("textarea")).value=n,o.style.position="fixed",o.style.opacity="0",o.style.pointerEvents="none",document.body.appendChild(o),o.select();try{document.execCommand("copy"),i=!0}catch(e){}document.body.removeChild(o)}i&&(r.innerHTML='<span class="dashicons dashicons-yes"></span>',setTimeout((function(){r.innerHTML='<span class="dashicons dashicons-clipboard"></span>'}),1500));case 12:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(){return e.apply(this,arguments)}}(),r.addEventListener("click",i),t.parentElement.appendChild(r),e.abrupt("return",(function(){r.removeEventListener("click",i),r.remove()}));case 7:case"end":return e.stop()}}),e)})));return function(_x,t){return e.apply(this,arguments)}}();(0,Pe.useEffect)((function(){r&&u(r,d())}),[r]),(0,Pe.useEffect)((function(){a&&u(a,f())}),[a]);var d=function(){return t&&e.item.siteId?'[wp_block slug="'.concat(e.item.slug,'" site_id="').concat(e.item.siteId,'"]'):'[wp_block slug="'.concat(e.item.slug,'"]')},f=function(){return t&&e.item.siteId?"<?php function_exists( 'pw_wp_block' ) ? pw_wp_block( '".concat(e.item.slug,"', ").concat(e.item.siteId,", $echo = true ) : ''; ?>"):"<?php function_exists( 'pw_wp_block' ) ? pw_wp_block( '".concat(e.item.slug,"', null, $echo = true ) : ''; ?>")};return Le().createElement(Le().Fragment,null,Le().createElement(l.Modal,{title:(0,s.__)("Get Code","pattern-wrangler"),onRequestClose:e.onRequestClose,focusOnMount:"firstContentElement"},Le().createElement("div",{className:"dlx-pw-modal-content"},Le().createElement("p",{className:"description"},(0,s.__)("Use the fields below to get a shortcode or PHP function to output the pattern on your site.","pattern-wrangler")),Le().createElement("div",{className:"dlx-pw-modal-admin-row"},Le().createElement(l.TextControl,{label:(0,s.__)("Pattern Shortcode","pattern-wrangler"),value:d(),disabled:!0,ref:i,className:"dlx-pw-modal-admin-row-input"})),Le().createElement("div",{className:"dlx-pw-modal-admin-row"},Le().createElement(l.TextControl,{label:(0,s.__)("Pattern PHP Function","pattern-wrangler"),value:f(),disabled:!0,ref:c,className:"dlx-pw-modal-admin-row-input"})),Le().createElement("div",{className:"dlx-pw-modal-admin-row dlx-pw-modal-admin-row-buttons"},Le().createElement(l.Button,{variant:"secondary",onClick:e.onRequestClose},(0,s.__)("Cancel","pattern-wrangler"))))))};function fl(e){return fl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fl(e)}function hl(e){return function(e){if(Array.isArray(e))return pl(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return pl(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pl(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ml(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function gl(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ml(Object(n),!0).forEach((function(t){vl(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ml(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function vl(e,t,n){return(t=function(e){var t=function(e){if("object"!=fl(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=fl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==fl(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function yl(){yl=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==fl(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(fl(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function bl(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}var wl={patterns:[],categories:[],assets:[],data:{patterns:[],categories:[],assets:[]},loading:!1,error:null},xl={setPatterns:function(e){return{type:"SET_PATTERNS",patterns:e}},setPattern:function(e,t,n,r){return{type:"SET_PATTERN",patternId:e,patternTitle:t,patternCategories:n,patternCategorySlugs:r}},addPattern:function(e){return{type:"ADD_PATTERN",pattern:e}},disablePatterns:function(e){return{type:"DISABLE_PATTERNS",patternIdsAndNonces:e}},enablePatterns:function(e){return{type:"ENABLE_PATTERNS",patternIdsAndNonces:e}},setCategory:function(e,t){return{type:"SET_CATEGORY",categoryId:e,categoryTermData:t}},upsertCategory:function(e){return{type:"UPSERT_CATEGORY",categoryData:e}},setCategories:function(e){return{type:"SET_CATEGORIES",categories:e}},setAssets:function(e){return{type:"SET_ASSETS",assets:e}},setData:function(e){return{type:"SET_DATA",data:e}},setAllData:function(e,t,n,r){return{type:"SET_ALL_DATA",patterns:e,categories:t,assets:n,data:r}},setLoading:function(e){return{type:"SET_LOADING",loading:e}},setError:function(e){return{type:"SET_ERROR",error:e}},fetchData:function(){return function(){var e,t=(e=yl().mark((function e(t){var n,r;return yl().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.dispatch,e.prev=1,n(xl.setLoading(!0)),n(xl.setError(null)),e.next=6,u()({path:(0,So.addQueryArgs)("/dlxplugins/pattern-wrangler/v1/patterns/all/",{nonce:dlxEnhancedPatternsView.getNonce}),method:"GET"});case 6:r=e.sent,n(r?xl.setAllData(r.patterns,r.categories,r.assets,r):xl.setError("Failed to fetch data")),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(1),n(xl.setError(e.t0.message||"Network error occurred"));case 13:return e.prev=13,n(xl.setLoading(!1)),e.finish(13);case 16:case"end":return e.stop()}}),e,null,[[1,10,13,16]])})),function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){bl(o,r,i,a,s,"next",e)}function s(e){bl(o,r,i,a,s,"throw",e)}a(void 0)}))});return function(_x){return t.apply(this,arguments)}}()},deletePatterns:function(e){return{type:"DELETE_PATTERNS",patternIdsAndNonces:e}}},_l=(0,ai.createReduxStore)("dlxplugins/pattern-wrangler/patterns",{reducer:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:wl,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_ALL_DATA":return gl(gl({},e),{},{patterns:t.patterns,categories:t.categories,assets:t.assets,data:t.data,loading:!1,error:null});case"SET_PATTERNS":return gl(gl({},e),{},{patterns:t.patterns});case"SET_CATEGORIES":return gl(gl({},e),{},{categories:t.categories});case"UPSERT_CATEGORY":var n=gl(gl({},t.categoryData),e.categories);return gl(gl({},e),{},{categories:n,data:gl(gl({},e.data),{},{categories:n})});case"SET_PATTERN":var r=t.patternCategories,i=t.patternCategorySlugs,o=e.patterns.map((function(e){return e.id===t.patternId?gl(gl({},e),{title:t.patternTitle,categories:r,categorySlugs:i}):e}));return gl(gl({},e),{},{patterns:o,data:gl(gl({},e.data),{},{patterns:o})});case"ADD_PATTERN":return gl(gl({},e),{},{patterns:[].concat(hl(e.patterns),[t.pattern]),data:gl(gl({},e.data),{},{patterns:[].concat(hl(e.patterns),[t.pattern])})});case"SET_CATEGORY":var a=e.categories.map((function(e){return e.id===t.categoryId?gl(gl({},e),t.categoryTermData):e}));return gl(gl({},e),{},{categories:a,data:gl(gl({},e.data),{},{categories:a})});case"SET_DATA":return gl(gl({},e),{},{data:t.data});case"SET_ASSETS":return gl(gl({},e),{},{assets:t.assets});case"SET_LOADING":return gl(gl({},e),{},{loading:t.loading});case"SET_ERROR":return gl(gl({},e),{},{error:t.error});case"DISABLE_PATTERNS":var s=t.patternIdsAndNonces,l=[];return e.patterns.forEach((function(e){s.some((function(t){return t.id===e.id}))&&(e.isDisabled=!0),l.push(e)})),gl(gl({},e),{},{patterns:[].concat(l),data:gl(gl({},e.data),{},{patterns:[].concat(l)})});case"ENABLE_PATTERNS":var c=t.patternIdsAndNonces,u=[];return e.patterns.forEach((function(e){c.some((function(t){return t.id===e.id}))&&(e.isDisabled=!1),u.push(e)})),gl(gl({},e),{},{patterns:[].concat(u),data:gl(gl({},e.data),{},{patterns:[].concat(u)})});case"DELETE_PATTERNS":var d=t.patternIdsAndNonces,f=hl(e.patterns).filter((function(e){return!d.some((function(t){return t.id===e.id}))}));return gl(gl({},e),{},{patterns:f,data:gl(gl({},e.data),{},{patterns:f})});default:return e}},actions:xl,selectors:{getPatterns:function(e){return e.patterns},getCategories:function(e){return e.categories},getAssets:function(e){return e.assets},getData:function(e){return e.data},getLoading:function(e){return e.loading},getError:function(e){return e.error}}});(0,ai.register)(_l);const El=_l,Sl=window.wp.blocks;function Cl(e){return Cl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Cl(e)}function Ol(){Ol=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==Cl(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(Cl(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function Pl(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function jl(){var e;return e=Ol().mark((function e(t){var n,r,i,o;return Ol().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.text();case 2:n=e.sent,e.prev=3,r=JSON.parse(n),e.next=10;break;case 7:throw e.prev=7,e.t0=e.catch(3),new Error("Invalid JSON file (cannot parse)");case 10:if(r.title){e.next=12;break}throw new Error("Pattern JSON missing a title");case 12:if(i="","string"!=typeof r.content){e.next=17;break}i=r.content,e.next=22;break;case 17:if(!Array.isArray(r.blocks)){e.next=21;break}i=(0,Sl.serialize)(r.blocks),e.next=22;break;case 21:throw new Error("Pattern JSON missing content or blocks array");case 22:return o="string"==typeof r.syncStatus?r.syncStatus:"unsynced",e.abrupt("return",{title:r.title,content:i,syncStatus:o});case 24:case"end":return e.stop()}}),e,null,[[3,7]])})),jl=function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Pl(o,r,i,a,s,"next",e)}function s(e){Pl(o,r,i,a,s,"throw",e)}a(void 0)}))},jl.apply(this,arguments)}const Ll=function(_x){return jl.apply(this,arguments)};function kl(e){return kl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},kl(e)}function Tl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Il(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Tl(Object(n),!0).forEach((function(t){Al(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tl(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Al(e,t,n){return(t=function(e){var t=function(e){if("object"!=kl(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=kl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==kl(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ml(e){return function(e){if(Array.isArray(e))return zl(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Bl(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Nl(){Nl=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var o=t&&t.prototype instanceof v?t:v,a=Object.create(o.prototype),s=new k(r||[]);return i(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var f="suspendedStart",h="suspendedYield",p="executing",m="completed",g={};function v(){}function y(){}function b(){}var w={};c(w,a,(function(){return this}));var x=Object.getPrototypeOf,_=x&&x(x(T([])));_&&_!==n&&r.call(_,a)&&(w=_);var E=b.prototype=v.prototype=Object.create(w);function S(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function C(e,t){function n(i,o,a,s){var l=d(e[i],e,o);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==kl(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function O(t,n,r){var i=f;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=P(s,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?m:h,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=m,r.method="throw",r.arg=c.arg)}}}function P(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,g;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function j(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(j,this),this.reset(!0)}function T(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(kl(t)+" is not iterable")}return y.prototype=b,i(E,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:y,configurable:!0}),y.displayName=c(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,c(e,l,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},S(C.prototype),c(C.prototype,s,(function(){return this})),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(u(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},S(E),c(E,l,"Generator"),c(E,a,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(L),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:T(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function Rl(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function Fl(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Rl(o,r,i,a,s,"next",e)}function s(e){Rl(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Dl(){return Dl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Dl.apply(null,arguments)}function Vl(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||Bl(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Bl(e,t){if(e){if("string"==typeof e)return zl(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?zl(e,t):void 0}}function zl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var Hl=function(e){var r=e.src,i=e.title,o=e.item,a=(0,t.useRef)(null),s=(0,t.useRef)(null),l=Vl((0,t.useState)(!1),2),c=l[0],u=l[1],d=Vl((0,t.useState)(1),2),f=d[0],h=d[1],p=Vl((0,t.useState)(0),2),m=p[0],g=p[1],v=Vl((0,t.useState)(0),2),y=v[0],b=v[1],w=Vl((0,t.useState)(1),2),x=w[0],_=w[1];(0,t.useEffect)((function(){var e=a.current;if(e){var t=function(){u(!0),g(o.viewportWidth||e.offsetWidth)};return e.addEventListener("load",t),function(){e.removeEventListener("load",t)}}}),[r]);var E=Vl((0,n.useResizeObserver)(),2),S=E[0],C=E[1],O=C.width,P=C.height;return(0,t.useEffect)((function(){if(void 0!==O&&c&&0!==m){var e=O/(m||800),t=O/P,n=Math.max(m*t,100);b(n),h(e),_(t);var r=new CustomEvent("dlxPatternPreviewResize",{detail:{width:O}});window.dispatchEvent(r);try{window.parent.dispatchEvent(r)}catch(e){}}}),[O,c]),(0,t.useEffect)((function(){a.current&&g(a.current.offsetWidth)}),[a,y]),React.createElement("a",{href:r,className:"pattern-preview-iframe-link",target:"_blank",rel:"noopener noreferrer",onClick:function(e){e.preventDefault(),$l(o)},"aria-hidden":"true"},React.createElement("div",{className:"pattern-preview-iframe-scale-container-wrapper",ref:s,style:{transform:"scale(".concat(f,")")}},React.createElement("div",{className:"pattern-preview-iframe-scale-wrapper"},React.createElement("div",{className:"pattern-preview-iframe-scale-container"},S,React.createElement("div",{className:"pattern-preview-iframe-wrapper"},React.createElement("iframe",{ref:a,key:"preview-".concat(o.id),src:r,title:i,sandbox:"allow-same-origin allow-scripts allow-popups allow-forms",loading:"lazy",style:{position:"absolute",top:0,left:0,width:o.viewportWidth||800,aspectRatio:x,height:y+"px",maxHeight:"1200px",overflow:"visible"}}))))))},$l=function(e){var t=e.viewportWidth||1200,n=null!=e&&e.id?"".concat(ajaxurl,"?action=dlxpw_pattern_preview&pattern_id=").concat(e.id,"&viewport_width=").concat(t):"";o.Fancybox.show([{src:n,caption:e.title,type:"iframe",closeButton:!0}])},Gl={grid:{layout:{titleField:"title",mediaField:"pattern-view-json",columns:2,columnGap:"24px",rowGap:"24px",showMedia:!0,viewConfigOptions:{}}}},Ul=function(e){var n,i,o,c,d,f,h,p,m=e.data,g=Vl((0,t.useState)([]),2),v=g[0],y=g[1],b=(0,ai.useSelect)((function(e){return{patterns:e(El).getPatterns()}})).patterns,w=Vl((0,t.useState)([]),2),x=w[0],_=w[1],E=(0,ai.useSelect)((function(){return{categories:(0,ai.select)(El).getCategories()}})).categories,S=((0,ai.useSelect)((function(){return{assets:(0,ai.select)(El).getAssets()}})).assets,Vl((0,t.useState)([]),2)),C=S[0],O=S[1],P=Vl((0,t.useState)(!0),2),j=P[0],L=P[1],k=Vl((0,t.useState)({isVisible:!1,message:"",title:"",type:""}),2),T=k[0],I=k[1],A=Vl((0,t.useState)(!1),2),M=A[0],N=A[1],R=Vl((0,t.useState)(!1),2),F=R[0],D=R[1],V=Vl((0,t.useState)(0),2),B=(V[0],V[1]),z=Vl((0,t.useState)(null),2),H=z[0],$=z[1],G=Vl((0,t.useState)(null),2),U=G[0],W=G[1],q=Vl((0,t.useState)(null),2),Y=q[0],X=q[1],K=Vl((0,t.useState)(null),2),Z=K[0],Q=K[1],J=Vl((0,t.useState)(null),2),ee=J[0],te=J[1],ne=Vl((0,t.useState)(null),2),re=ne[0],ie=ne[1],oe=function(e){var t=e.isLocal,n=e.title,i="";t?i="unsynced":"synced"===e.patternType&&(i="synced");var o=JSON.stringify({__file:"wp_block",title:n,content:e.content,syncStatus:i},null,2);(0,r.downloadBlob)("".concat(n,".json"),o,"application/json")},ae=function(){var e,t,n,r,i,o;return{type:"grid",previewSize:"large",paginationInfo:{totalItems:b.length,totalPages:0},page:parseInt((0,So.getQueryArgs)(window.location.href).paged)||1,perPage:parseInt((0,So.getQueryArgs)(window.location.href).perPage)||12,defaultPerPage:12,sort:{field:(0,a.escapeAttribute)((0,So.getQueryArgs)(window.location.href).orderby||"title"),direction:(0,a.escapeAttribute)((0,So.getQueryArgs)(window.location.href).order||"asc")},titleField:"title",mediaField:"pattern-view-json",layout:Gl.grid.layout,fields:["title","pattern-view-json"],search:(0,a.escapeAttribute)((null===(e=(0,So.getQueryArgs)(window.location.href))||void 0===e?void 0:e.search)||""),filters:[{field:"patternType",value:(null===(t=(0,So.getQueryArgs)(window.location.href))||void 0===t?void 0:t.patternType)||"all"},{field:"patternStatus",value:(null===(n=(0,So.getQueryArgs)(window.location.href))||void 0===n?void 0:n.patternStatus)||"both"},{field:"patternLocalStatus",value:(null===(r=(0,So.getQueryArgs)(window.location.href))||void 0===r?void 0:r.patternLocalStatus)||"both"},{field:"patternRegisteredStatus",value:(null===(i=(0,So.getQueryArgs)(window.location.href))||void 0===i?void 0:i.patternRegisteredStatus)||"both"},{field:"patternLocalRegisteredStatus",value:(null===(o=(0,So.getQueryArgs)(window.location.href))||void 0===o?void 0:o.patternLocalRegisteredStatus)||"enabled"}]}},se=function(e){return React.createElement(React.Fragment,null,React.createElement("div",{className:"pattern-quick-links"},e.isLocal&&React.createElement(React.Fragment,null,!e.isDisabled&&React.createElement(React.Fragment,null,React.createElement(l.Button,{variant:"link",onClick:function(t){t.preventDefault(),t.stopPropagation(),$({item:e})}},(0,s.__)("Quick Edit","pattern-wrangler"))," | ",React.createElement(l.Button,{variant:"link",onClick:function(t){t.preventDefault(),t.stopPropagation(),ie({item:e})}},(0,s.__)("Get Code","pattern-wrangler"))," | "),React.createElement(l.Button,{variant:"link",onClick:function(t){t.preventDefault(),t.stopPropagation(),oe(e)}},(0,s.__)("Export Pattern","pattern-wrangler"))),!e.isLocal&&React.createElement(React.Fragment,null,React.createElement(l.Button,{variant:"link",onClick:function(t){t.preventDefault(),t.stopPropagation(),B(e.id),D({item:e})}},(0,s.__)("Copy to New Pattern","pattern-wrangler"))," | ",React.createElement(l.Button,{variant:"link",onClick:function(t){t.preventDefault(),t.stopPropagation(),oe(e)}},(0,s.__)("Export Pattern","pattern-wrangler")))))},le=Vl((0,t.useState)(ae()),2),ce=le[0],ue=le[1],de=(0,t.useMemo)((function(){return[{id:"title",label:(0,s.__)("Title","pattern-wrangler"),render:function(e){var t=e.item;if(null==t||!t.categorySlugs||0===t.categorySlugs.length)return React.createElement("div",{className:"pattern-title-categories"},React.createElement("div",{className:"pattern-title"},t.isLocal&&React.createElement(l.Button,{variant:"link",onClick:function(e){e.preventDefault();var n=encodeURIComponent(window.location.href);window.location.href="".concat(dlxEnhancedPatternsView.getSiteBaseUrl,"post.php?post=").concat(t.id,"&action=edit&redirect_to=").concat(n)}},t.title),!t.isLocal&&React.createElement("span",{className:"pattern-title"},t.title)),React.createElement("div",{className:"pattern-categories"},(0,s.__)("No categories","pattern-wrangler")),se(t));var n=(0,ai.select)(El).getCategories();return React.createElement(React.Fragment,null,React.createElement("div",{className:"pattern-title-categories"},React.createElement("div",{className:"pattern-title"},t.isLocal&&React.createElement(l.Button,{variant:"link",onClick:function(e){e.preventDefault();var n=encodeURIComponent(window.location.href);window.location.href="".concat(dlxEnhancedPatternsView.getSiteBaseUrl,"post.php?post=").concat(t.id,"&action=edit&redirect_to=").concat(n)}},t.title),!t.isLocal&&React.createElement("span",{className:"pattern-title"},t.title)),t.categorySlugs.length>0&&Object.values(n).length>0&&React.createElement("div",{className:"pattern-categories"},(0,s.__)("Categories:","pattern-wrangler")," ",t.categorySlugs.map((function(e,r){var i,o,a=(null==e?void 0:e.slug)||e.toString();if(!n.hasOwnProperty(a))return null;var s=(null===(i=n[a])||void 0===i?void 0:i.label)||(null===(o=n[a])||void 0===o?void 0:o.name);return React.createElement("span",{key:"category-".concat(r),className:"pattern-category"},s," ",r<t.categorySlugs.length-1&&", ")}))),se(t)))},enableSorting:!0,enableHiding:!1,enableGlobalSearch:!0},{id:"pattern-view-json",label:(0,s.__)("Preview","pattern-wrangler"),getValue:function(e){var t=e.item,n=t.viewportWidth||1200,r=null!=t&&t.id?"".concat(ajaxurl,"?action=dlxpw_pattern_preview&pattern_id=").concat(t.id,"&viewport_width=").concat(n):"",i=(0,s.__)("Local","pattern-wrangler"),o="pattern-badge-local",a=(0,s.__)("Disabled","pattern-wrangler"),l=!0;t.isDisabled&&t.isLocal?a=(0,s.__)("Draft","pattern-wrangler"):!t.isDisabled&&t.isLocal?l=!1:t.isDisabled||t.isLocal||(l=!1),t.isLocal?"synced"===t.patternType?(i=(0,s.__)("Local Synced","pattern-wrangler"),o="pattern-badge-synced"):(i=(0,s.__)("Local Unsynced","pattern-wrangler"),o="pattern-badge-unsynced"):(i=(0,s.__)("Registered","pattern-wrangler"),o="pattern-badge-registered");var c=React.createElement(React.Fragment,null,React.createElement("div",{className:"pattern-badge-wrapper"},l&&React.createElement("span",{className:"pattern-badge ".concat("pattern-badge-disabled")},a),React.createElement("span",{className:"pattern-badge ".concat(o)},i)));return React.createElement(React.Fragment,null,c,React.createElement("div",{className:"pattern-preview-wrapper"},React.createElement(Hl,{src:r,title:"Preview: ".concat(t.title),item:t})))},enableSorting:!1,enableHiding:!1},{id:"categories",label:(0,s.__)("Categories","pattern-wrangler"),render:function(e){return e.item,null},enableSorting:!1,enableHiding:!1,enableGlobalSearch:!0,type:"array",filterBy:{operators:["isAny","isNone"]},elements:Object.values(E).map((function(e){return{label:e.label||e.name,value:e.slug}}))},{id:"assets",label:(0,s.__)("Filter Patterns by Source","pattern-wrangler"),render:function(e){return e.item,null},enableHiding:!1,enableGlobalSearch:!0,enableSorting:!1,filterBy:{operators:["is"]},elements:Object.values((0,ai.select)(El).getAssets()||[]).map((function(e){return{label:e.label,value:e.slug}}))},{elements:[{label:(0,s.__)("All Patterns","pattern-wrangler"),value:"all"},{label:(0,s.__)("Local Patterns","pattern-wrangler"),value:"local"},{label:(0,s.__)("Registered Patterns","pattern-wrangler"),value:"registered"}],enableHiding:!1,enableSorting:!1,enableGlobalSearch:!1,filterBy:{operators:["is"]},default:"all",type:"array",id:"patternType",label:(0,s.__)("Pattern Type","pattern-wrangler")},{elements:[{label:(0,s.__)("Unsynced Patterns","pattern-wrangler"),value:"unsynced"},{label:(0,s.__)("Synced Patterns","pattern-wrangler"),value:"synced"},{label:(0,s.__)("Both","pattern-wrangler"),value:"both"}],enableHiding:!1,enableSorting:!1,enableGlobalSearch:!1,filterBy:{operators:["is"]},type:"array",id:"patternStatus",label:(0,s.__)("Pattern Status","pattern-wrangler")},{elements:[{label:(0,s.__)("Paused Patterns","pattern-wrangler"),value:"paused"},{label:(0,s.__)("Unpaused Patterns","pattern-wrangler"),value:"unpaused"},{label:(0,s.__)("Both","pattern-wrangler"),value:"both"}],enableHiding:!1,enableSorting:!1,enableGlobalSearch:!1,filterBy:{operators:["is"]},type:"array",id:"patternRegisteredStatus",label:(0,s.__)("Pattern Registered Status","pattern-wrangler")},{elements:[{label:(0,s.__)("Draft Patterns","pattern-wrangler"),value:"draft"},{label:(0,s.__)("Published Patterns","pattern-wrangler"),value:"published"},{label:(0,s.__)("Both","pattern-wrangler"),value:"both"}],enableHiding:!1,enableSorting:!1,enableGlobalSearch:!1,filterBy:{operators:["is"]},type:"array",id:"patternLocalStatus",label:(0,s.__)("Pattern Local Status","pattern-wrangler")},{elements:[{label:(0,s.__)("Disabled Patterns","pattern-wrangler"),value:"disabled"},{label:(0,s.__)("Enabled Patterns","pattern-wrangler"),value:"enabled"},{label:(0,s.__)("Both","pattern-wrangler"),value:"both"}],enableHiding:!1,enableSorting:!1,enableGlobalSearch:!1,filterBy:{operators:["is"]},type:"array",id:"patternLocalRegisteredStatus",label:(0,s.__)("Pattern Local and Registered Status","pattern-wrangler")}]}),[]),fe=(0,t.useMemo)((function(){return[{id:"quick-edit",label:(0,s.__)("Quick Edit","pattern-wrangler"),icon:"edit",callback:function(e){$({item:e[0]})},isEligible:function(e){return e.isLocal&&!e.isDisabled},isPrimary:!0},{id:"get-code",label:(0,s.__)("Get Code","pattern-wrangler"),icon:"code",callback:function(e){ie({item:e[0]})},isEligible:function(e){return e.isLocal&&!e.isDisabled},isPrimary:!1,supportsBulk:!1},{id:"delete",label:(0,s.__)("Delete Pattern","pattern-wrangler"),icon:"trash",isEligible:function(e){return e.isLocal&&e.isDisabled},callback:function(e){te({items:e})},isPrimary:!1,isDestructive:!0,supportsBulk:!0},{id:"publish",label:(0,s.__)("Publish Pattern","pattern-wrangler"),icon:"yes-alt",isEligible:function(e){return e.isLocal&&e.isDisabled},callback:function(e){X({items:e})},isPrimary:!1,isDestructive:!1,supportsBulk:!0},{id:"unpause",label:(0,s.__)("Re-enable Pattern","pattern-wrangler"),icon:"controls-play",isEligible:function(e){return!e.isLocal&&e.isDisabled},callback:function(e){Q({items:e})},isPrimary:!1,isDestructive:!1,supportsBulk:!0},{id:"copy-to-local",label:(0,s.__)("Copy to New Pattern","pattern-wrangler"),icon:"edit",callback:function(e){var t=e[0];B(t.id),D({item:t})},isEligible:function(e){return!e.isLocal},isPrimary:!1,isDestructive:!1},{id:"disable-preview",label:(0,s.__)("Disable Pattern","pattern-wrangler"),icon:"controls-pause",callback:function(e){W({items:e})},isEligible:function(e){return!e.isDisabled},isDestructive:!0,supportsBulk:!0,isPrimary:!1},{id:"copy",label:(0,s.__)("Copy Pattern to Clipboard","pattern-wrangler"),icon:"edit",callback:(e=Fl(Nl().mark((function e(t){var n,r,i,o;return Nl().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t[0].content.trim(),r=!1,e.prev=2,null===(i=navigator.clipboard)||void 0===i||!i.writeText){e.next=12;break}return e.prev=4,e.next=7,navigator.clipboard.writeText(n);case 7:r=!0,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:if(!r){(o=document.createElement("textarea")).value=n,o.style.position="fixed",o.style.opacity="0",o.style.pointerEvents="none",document.body.appendChild(o),o.select();try{document.execCommand("copy"),r=!0}catch(e){}document.body.removeChild(o)}I({isVisible:!0,message:(0,s.__)("Pattern copied to clipboard","pattern-wrangler"),title:(0,s.__)("Pattern Copied","pattern-wrangler"),type:"success",onClose:function(){I({isVisible:!1})}}),e.next=18;break;case 16:e.prev=16,e.t1=e.catch(2);case 18:case"end":return e.stop()}}),e,null,[[2,16],[4,10]])}))),function(_x){return e.apply(this,arguments)}),isEligible:function(e){return!0},isPrimary:!1,isDestructive:!1},{id:"export",label:(0,s.__)("Export to JSON","pattern-wrangler"),icon:"edit",callback:function(e){var t=e[0].isLocal,n=e[0].title,i="";t?i="unsynced":"synced"===e[0].patternType&&(i="synced");var o=JSON.stringify({__file:"wp_block",title:n,content:e[0].content,syncStatus:i},null,2);(0,r.downloadBlob)("".concat(n,".json"),o,"application/json")},isEligible:function(){return!0},isPrimary:!1,isDestructive:!1}];var e}),[E,b]),he=function(e){var t,n,r=Ml(b);null!==r&&0!==r.length||(r=Ml(m.patterns));var i=null==e||null===(t=e.sort)||void 0===t?void 0:t.field,o=null==e||null===(n=e.sort)||void 0===n?void 0:n.direction;"title"===i&&("desc"===o?r.sort((function(e,t){return t.title.localeCompare(e.title)})):r.sort((function(e,t){return e.title.localeCompare(t.title)})));var a=(null==e?void 0:e.filters)||[];a.length>0&&a.forEach((function(e){switch(e.field){case"categories":if(e.value){var t=e.value.map((function(e){return(0,So.cleanForSlug)(e)}));"isAny"===e.operator?r=r.filter((function(e){return(e.categorySlugs||[]).some((function(e){var n=e.name||(0,So.cleanForSlug)(e);return t.includes(n)}))})):"isNone"===e.operator&&(r=r.filter((function(e){return!(e.categorySlugs||[]).some((function(e){var n=e.name||(0,So.cleanForSlug)(e);return t.includes(n)}))})))}break;case"assets":e.value&&"is"===e.operator&&(r=r.filter((function(t){return t.asset===e.value})));break;case"patternType":if(e.value)switch(e.value){case"all":break;case"local":r=r.filter((function(e){return e.isLocal}));break;case"registered":r=r.filter((function(e){return!e.isLocal}))}break;case"patternStatus":if(e.value){var n=a.find((function(e){return"patternType"===e.field}));if(n&&"local"===n.value&&e.value)switch(e.value){case"unsynced":r=r.filter((function(e){return!!e.syncStatus&&"unsynced"===e.syncStatus&&e.isLocal}));break;case"synced":r=r.filter((function(e){return!!e.syncStatus&&"synced"===e.syncStatus&&e.isLocal}))}}break;case"patternLocalStatus":if(e.value){var i=a.find((function(e){return"patternType"===e.field}));if(i&&"local"===i.value&&e.value)switch(e.value){case"draft":r=r.filter((function(e){return e.isDisabled&&e.isLocal}));break;case"published":r=r.filter((function(e){return!e.isDisabled&&e.isLocal}))}}break;case"patternRegisteredStatus":if(e.value){var o=a.find((function(e){return"patternType"===e.field}));if(o&&"registered"===o.value&&e.value)switch(e.value){case"paused":r=r.filter((function(e){return e.isDisabled&&!e.isLocal}));break;case"unpaused":r=r.filter((function(e){return!e.isDisabled&&!e.isLocal}))}}break;case"patternLocalRegisteredStatus":if(e.value){var s=a.find((function(e){return"patternType"===e.field}));if(s&&"all"===s.value&&e.value)switch(e.value){case"disabled":r=r.filter((function(e){return e.isDisabled}));break;case"enabled":r=r.filter((function(e){return!e.isDisabled}))}}}}));var s=(null==e?void 0:e.search)||"";return"undefined"!==s&&""!==s&&(r=r.filter((function(t){return(t.label||t.title).toLowerCase().includes((e.search||s).toLowerCase())}))),r.length},pe=function(e){var t,n,r=Ml(b);null!==r&&0!==r.length||(r=Ml(m.patterns));var i=null==e||null===(t=e.sort)||void 0===t?void 0:t.field,o=null==e||null===(n=e.sort)||void 0===n?void 0:n.direction;"title"===i&&("desc"===o?r.sort((function(e,t){return t.title.localeCompare(e.title)})):r.sort((function(e,t){return e.title.localeCompare(t.title)})));var a=(null==e?void 0:e.filters)||[];a.length>0&&a.forEach((function(e){switch(e.field){case"categories":if(e.value){var t=e.value.map((function(e){return(0,So.cleanForSlug)(e)}));"isAny"===e.operator?r=r.filter((function(e){return(e.categorySlugs||[]).some((function(e){var n=e.name||(0,So.cleanForSlug)(e);return t.includes(n)}))})):"isNone"===e.operator&&(r=r.filter((function(e){return!(e.categorySlugs||[]).some((function(e){var n=e.name||(0,So.cleanForSlug)(e);return t.includes(n)}))})))}break;case"assets":e.value&&(r=r.filter((function(t){return t.asset===e.value})));break;case"patternType":if(e.value)switch(e.value){case"all":break;case"local":r=r.filter((function(e){return e.isLocal}));break;case"registered":r=r.filter((function(e){return!e.isLocal}))}break;case"patternStatus":if(e.value){var n=a.find((function(e){return"patternType"===e.field}));if(n&&"local"===n.value&&e.value)switch(e.value){case"unsynced":r=r.filter((function(e){return!!e.syncStatus&&"unsynced"===e.syncStatus&&e.isLocal}));break;case"synced":r=r.filter((function(e){return!!e.syncStatus&&"synced"===e.syncStatus&&e.isLocal}))}}break;case"patternLocalStatus":if(e.value){var i=a.find((function(e){return"patternType"===e.field}));if(i&&"local"===i.value&&e.value)switch(e.value){case"draft":case"paused":r=r.filter((function(e){return e.isDisabled&&e.isLocal}));break;case"published":r=r.filter((function(e){return!e.isDisabled&&e.isLocal}))}}break;case"patternRegisteredStatus":if(e.value){var o=a.find((function(e){return"patternType"===e.field}));if(o&&"registered"===o.value&&e.value)switch(e.value){case"paused":r=r.filter((function(e){return e.isDisabled&&!e.isLocal}));break;case"unpaused":r=r.filter((function(e){return!e.isDisabled&&!e.isLocal}))}}break;case"patternLocalRegisteredStatus":if(e.value){var s=a.find((function(e){return"patternType"===e.field}));if(s&&"all"===s.value&&e.value)switch(e.value){case"disabled":r=r.filter((function(e){return e.isDisabled}));break;case"enabled":r=r.filter((function(e){return!e.isDisabled}))}}}}));var s=(null==e?void 0:e.search)||"";return"undefined"!==s&&""!==s&&(r=r.filter((function(t){return(t.label||t.title).toLowerCase().includes((e.search||s).toLowerCase())}))),r.slice((e.page-1)*e.perPage,e.page*e.perPage)},me=function(e){var t,n,r,i,o,a,s=(0,So.getQueryArgs)(window.location.href);s.paged=e.page||1,s.perPage=e.perPage,e.search?s.search=e.search:s.search="",null!==(t=e.sort)&&void 0!==t&&t.field&&(s.orderby=e.sort.field,s.order=e.sort.direction);var l=null===(n=e.filters)||void 0===n?void 0:n.find((function(e){return"patternType"===e.field})),c=null===(r=e.filters)||void 0===r?void 0:r.find((function(e){return"patternStatus"===e.field}));l&&(s.patternType=l.value),c&&(s.patternStatus=c.value);var u=null===(i=e.filters)||void 0===i?void 0:i.find((function(e){return"patternRegisteredStatus"===e.field})),d=null===(o=e.filters)||void 0===o?void 0:o.find((function(e){return"patternLocalStatus"===e.field})),f=null===(a=e.filters)||void 0===a?void 0:a.find((function(e){return"patternLocalRegisteredStatus"===e.field}));u&&!f&&(s.patternRegisteredStatus=u.value),d&&!f&&(s.patternLocalStatus=d.value),f&&(s.patternLocalRegisteredStatus=f.value);var h=(0,So.addQueryArgs)(window.location.pathname,s);(0,So.getQueryArgs)(window.location.href).search&&!e.search&&(h=(0,So.removeQueryArgs)(h,"search")),_(pe(e)),window.history.pushState({},"",h),s.page=s.paged,ue(Il(Il({},e),s))};return(0,t.useEffect)((function(){window.addEventListener("popstate",(function(){me(ae())}))}),[ce]),(0,t.useEffect)((function(){if(m&&m.hasOwnProperty("patterns")&&m.categories){var e=de.findIndex((function(e){return"categories"===e.id}));if(-1===e)return void L(!1);var t=[],n="",r=Object.values(m.categories).map((function(e){var r=e.label;return n===e.label&&(r="".concat(r," (").concat(e.count+1,")")),n=e.label,e.registered||t.push({id:e.id,label:e.label}),{label:r,value:e.slug}})),i=Ml(de);i[e]=Il(Il({},i[e]),{},{elements:r}),0===t.length&&(i=i.filter((function(e){return"categories"!==e.id}))),0===Object.values(m.assets||{}).length&&(i=i.filter((function(e){return"assets"!==e.id})));var o=Il(Il({},ce),{},{fields:i});if(O(t),ue(o),m.patterns&&m.patterns!==x){var a=pe(ce);_(a)}L(!1)}}),[m]),j?React.createElement(React.Fragment,null,"Loading..."):React.createElement("div",{className:"dlx-patterns-view-container-wrapper"},React.createElement("div",{className:"dlx-patterns-view-container"},React.createElement(Uo,{data:x,fields:de,actions:fe,label:(0,s.__)("Patterns","pattern-wrangler"),view:ce,onChangeView:me,paginationInfo:{totalItems:he(ce),totalPages:Math.ceil(he(ce)/ce.perPage)},perPageSizes:[12,24,48,96],selection:v,onChangeSelection:y,defaultLayouts:Gl,searchLabel:(0,s.__)("Search Patterns","pattern-wrangler")},React.createElement("div",{className:"dlx-patterns-view-container-header"},React.createElement("h1",null,(0,s.__)("Pattern Library","pattern-wrangler"))),React.createElement("div",{className:"dlx-patterns-view-quick-buttons-wrapper"},React.createElement(l.Button,{variant:"primary",className:"dlx-patterns-view-quick-button",onClick:function(){N(!0)}},(0,s.__)("Add New Pattern","pattern-wrangler")),React.createElement(l.FormFileUpload,{accept:".json",variant:"secondary",className:"dlx-patterns-view-quick-button",onChange:function(){var e=Fl(Nl().mark((function e(t){var n,r,i,o;return Nl().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.target.files[0],e.prev=1,e.next=4,Ll(n);case 4:return r=e.sent,e.next=7,u()({path:"/wp/v2/blocks",method:"POST",data:{title:r.title,content:r.content,status:"publish",meta:{wp_pattern_sync_status:r.syncStatus}}});case 7:if(null==(i=e.sent)||!i.id){e.next=13;break}return e.next=11,u()({path:"/dlxplugins/pattern-wrangler/v1/patterns/get/".concat(i.id),method:"GET"});case 11:(o=e.sent)&&(0,ai.dispatch)(El).addPattern(o);case 13:e.next=17;break;case 15:e.prev=15,e.t0=e.catch(1);case 17:case"end":return e.stop()}}),e,null,[[1,15]])})));return function(t){return e.apply(this,arguments)}}()},(0,s.__)("Import Pattern From JSON File","pattern-wrangler"))),React.createElement("div",{className:"dlx-patterns-view-grid"},React.createElement("div",{className:"dlx-patterns-view-search-filters-wrapper"},React.createElement(Uo.Search,{label:(0,s.__)("Search Patterns","pattern-wrangler")}),React.createElement(Uo.FiltersToggle,null)),React.createElement("div",{className:"dlx-patterns-view-button-actions-wrapper"},React.createElement(l.__experimentalToggleGroupControl,{label:(0,s.__)("Pattern Type","pattern-wrangler"),isAdaptiveWidth:!0,hideLabelFromVision:!0,value:(null==ce||null===(n=ce.filters)||void 0===n||null===(n=n.find((function(e){return"patternType"===e.field})))||void 0===n?void 0:n.value)||"all",onChange:function(e){var t,n=Il({},ce),r=(null===(t=n.filters)||void 0===t?void 0:t.filter((function(e){return"patternType"!==e.field})))||[];n.filters=[].concat(Ml(r),[{field:"patternType",operator:"is",value:e}]),n.page=1,me(n);var i=window.location.href;switch(e){case"all":i=(0,So.removeQueryArgs)(i,"patternStatus"),i=(0,So.removeQueryArgs)(i,"patternRegisteredStatus"),i=(0,So.removeQueryArgs)(i,"patternLocalStatus"),i=(0,So.removeQueryArgs)(i,"patternLocalRegisteredStatus"),window.history.pushState({},"",i);break;case"local":i=(0,So.removeQueryArgs)(i,"patternRegisteredStatus"),i=(0,So.removeQueryArgs)(i,"patternLocalRegisteredStatus"),window.history.pushState({},"",i);break;case"registered":i=(0,So.removeQueryArgs)(i,"patternStatus"),i=(0,So.removeQueryArgs)(i,"patternLocalStatus"),i=(0,So.removeQueryArgs)(i,"patternLocalRegisteredStatus"),window.history.pushState({},"",i)}}},React.createElement(l.__experimentalToggleGroupControlOption,{value:"local",label:(0,s.__)("Local","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Local Patterns","pattern-wrangler")}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"all",label:(0,s.__)("All","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show All Patterns","pattern-wrangler")}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"registered",label:(0,s.__)("Registered","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Registered Patterns","pattern-wrangler")})),"registered"===(null==ce||null===(i=ce.filters)||void 0===i||null===(i=i.find((function(e){return"patternType"===e.field})))||void 0===i?void 0:i.value)&&React.createElement(React.Fragment,null,React.createElement(l.__experimentalToggleGroupControl,{label:(0,s.__)("Registered Status","pattern-wrangler"),isAdaptiveWidth:!0,hideLabelFromVision:!0,value:(null==ce||null===(o=ce.filters)||void 0===o||null===(o=o.find((function(e){return"patternRegisteredStatus"===e.field})))||void 0===o?void 0:o.value)||"both",onChange:function(e){var t,n=Il({},ce),r=(null===(t=n.filters)||void 0===t?void 0:t.filter((function(e){return"patternRegisteredStatus"!==e.field})))||[];n.filters=[].concat(Ml(r),[{field:"patternRegisteredStatus",operator:"is",value:e}]),n.page=1,me(n)}},React.createElement(l.__experimentalToggleGroupControlOption,{value:"paused",label:(0,s.__)("Disabled","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Disabled Patterns","pattern-wrangler")}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"both",label:(0,s.__)("Both","pattern-wrangler"),"aria-label":(0,s.__)("Show Both Disabled and Enabled Patterns","pattern-wrangler"),showTooltip:!0}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"unpaused",label:(0,s.__)("Enabled","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Enabled Patterns","pattern-wrangler")}))),"local"===(null==ce||null===(c=ce.filters)||void 0===c||null===(c=c.find((function(e){return"patternType"===e.field})))||void 0===c?void 0:c.value)&&React.createElement(React.Fragment,null,React.createElement(l.__experimentalToggleGroupControl,{label:(0,s.__)("Pattern Status","pattern-wrangler"),isAdaptiveWidth:!0,hideLabelFromVision:!0,value:(null==ce||null===(d=ce.filters)||void 0===d||null===(d=d.find((function(e){return"patternStatus"===e.field})))||void 0===d?void 0:d.value)||"both",onChange:function(e){var t,n=Il({},ce),r=(null===(t=n.filters)||void 0===t?void 0:t.filter((function(e){return"patternStatus"!==e.field})))||[];n.filters=[].concat(Ml(r),[{field:"patternStatus",operator:"is",value:e}]),n.page=1,me(n)}},React.createElement(l.__experimentalToggleGroupControlOption,{value:"unsynced",label:(0,s.__)("Unsynced","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Unsynced Patterns","pattern-wrangler")}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"both",label:(0,s.__)("Both","pattern-wrangler"),"aria-label":(0,s.__)("Show Both Synced and Unsynced Patterns","pattern-wrangler"),showTooltip:!0}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"synced",label:(0,s.__)("Synced","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Synced Patterns","pattern-wrangler")})),React.createElement(l.__experimentalToggleGroupControl,{label:(0,s.__)("Published Status","pattern-wrangler"),isAdaptiveWidth:!0,hideLabelFromVision:!0,value:(null==ce||null===(f=ce.filters)||void 0===f||null===(f=f.find((function(e){return"patternLocalStatus"===e.field})))||void 0===f?void 0:f.value)||"both",onChange:function(e){var t,n=Il({},ce),r=(null===(t=n.filters)||void 0===t?void 0:t.filter((function(e){return"patternLocalStatus"!==e.field})))||[];n.filters=[].concat(Ml(r),[{field:"patternLocalStatus",operator:"is",value:e}]),n.page=1,me(n)}},React.createElement(l.__experimentalToggleGroupControlOption,{value:"draft",label:(0,s.__)("Draft","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Draft Patterns","pattern-wrangler")}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"both",label:(0,s.__)("Both","pattern-wrangler"),"aria-label":(0,s.__)("Show Both Draft and Published Patterns","pattern-wrangler"),showTooltip:!0}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"published",label:(0,s.__)("Published","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Published Patterns","pattern-wrangler")}))),"all"===(null==ce||null===(h=ce.filters)||void 0===h||null===(h=h.find((function(e){return"patternType"===e.field})))||void 0===h?void 0:h.value)&&React.createElement(React.Fragment,null,React.createElement(l.__experimentalToggleGroupControl,{label:(0,s.__)("Disabled Status","pattern-wrangler"),isAdaptiveWidth:!0,hideLabelFromVision:!0,value:(null==ce||null===(p=ce.filters)||void 0===p||null===(p=p.find((function(e){return"patternLocalRegisteredStatus"===e.field})))||void 0===p?void 0:p.value)||"both",onChange:function(e){var t,n=Il({},ce),r=(null===(t=n.filters)||void 0===t?void 0:t.filter((function(e){return"patternLocalRegisteredStatus"!==e.field})))||[];n.filters=[].concat(Ml(r),[{field:"patternLocalRegisteredStatus",operator:"is",value:e}]),n.page=1,me(n)}},React.createElement(l.__experimentalToggleGroupControlOption,{value:"disabled",label:(0,s.__)("Disabled","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Disabled Local and Registered Patterns","pattern-wrangler")}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"both",label:(0,s.__)("Both","pattern-wrangler"),"aria-label":(0,s.__)("Show Both Disabled and Enabled Local and Registered Patterns","pattern-wrangler"),showTooltip:!0}),React.createElement(l.__experimentalToggleGroupControlOption,{value:"enabled",label:(0,s.__)("Enabled","pattern-wrangler"),showTooltip:!0,"aria-label":(0,s.__)("Show Only Enabled Local and Registered Patterns","pattern-wrangler")})))),React.createElement("div",{className:"dlx-patterns-view-layout-pagination-wrapper"},React.createElement(Uo.ViewConfig,null),React.createElement(Uo.LayoutSwitcher,null))),React.createElement("div",{className:"dlx-patterns-view-filters-wrapper"},React.createElement(Uo.Filters,null)),React.createElement("div",{className:"dlx-bulk-action-toolbar-top"},React.createElement(Uo.BulkActionToolbar,null)),React.createElement(Uo.Layout,null),React.createElement(Uo.BulkActionToolbar,null),React.createElement(Uo.Pagination,null)),T.isVisible&&React.createElement(ha,{isVisible:T.isVisible,message:T.message,title:T.title,type:T.type,onClose:function(){I({isVisible:!1})}})),M&&React.createElement(Ds,{isOpen:M,onRequestClose:function(){return N(!1)},categories:C,title:(0,s.__)("Create New Pattern","pattern-wrangler")}),F&&React.createElement(Ds,{isOpen:F,onRequestClose:function(){return D(!1)},categories:C,title:(0,s.__)("Copy Pattern to Local","pattern-wrangler"),syncedDefaultStatus:"unsynced",copyPatternId:F.item.id}),H&&React.createElement(Ds,{isOpen:H,onRequestClose:function(){return $(null)},pattern:H.item,patternTitle:H.item.title,categories:C,patternCategories:H.item.categories,title:(0,s.__)("Quick Edit Pattern","pattern-wrangler"),syncedDisabled:!0,patternId:H.item.id,patternNonce:H.item.editNonce,isEditMode:!0,onEdit:function(e){(0,ai.dispatch)(El).upsertCategory(e.categories),(0,ai.dispatch)(El).setPattern(e.patternId,e.patternTitle,e.categorySlugs,e.categorySlugs),$(null)}}),U&&React.createElement($s,{items:U.items,onPause:function(e,t){(0,ai.dispatch)(El).disablePatterns(t),W(null),I({isVisible:!0,message:(0,s.__)("Patterns disabled","pattern-wrangler"),title:(0,s.__)("Patterns Disabled","pattern-wrangler"),type:"success",onClose:function(){I({isVisible:!1})}})},onRequestClose:function(){return W(null)}}),Y&&React.createElement(Ys,{items:Y.items,onPublish:function(e,t){(0,ai.dispatch)(El).enablePatterns(t),X(null),I({isVisible:!0,message:(0,s.__)("Patterns published","pattern-wrangler"),title:(0,s.__)("Patterns Published","pattern-wrangler"),type:"success",onClose:function(){I({isVisible:!1})}})},onRequestClose:function(){return X(null)}}),Z&&React.createElement(Js,{items:Z.items,onReenable:function(e,t){(0,ai.dispatch)(El).enablePatterns(t),Q(null),I({isVisible:!0,message:(0,s.__)("Patterns re-enabled","pattern-wrangler"),title:(0,s.__)("Patterns Re-enabled","pattern-wrangler"),type:"success",onClose:function(){I({isVisible:!1})}})},onRequestClose:function(){return Q(null)}}),ee&&React.createElement(il,{items:ee.items,onDelete:function(e,t){(0,ai.dispatch)(El).deletePatterns(t),te(null)},onRequestClose:function(){return te(null)}}),re&&React.createElement(dl,{item:re.item,onRequestClose:function(){return ie(null)}}))};const Wl=function(e){var n=(0,ai.useSelect)((function(e){return{data:e(El).getData(),loading:e(El).getLoading(),error:e(El).getError()}})),r=n.data,i=n.loading,o=n.error;return(0,t.useEffect)((function(){(0,ai.dispatch)(El).fetchData()}),[]),i?React.createElement("div",{className:"dlx-patterns-view-container-wrapper"},React.createElement("div",{className:"dlx-patterns-view-container"},React.createElement("div",{className:"dataviews-wrapper"},React.createElement("div",{className:"dlx-patterns-view-container-header"},React.createElement("h1",null,(0,s.__)("Loading patterns…","pattern-wrangler")),React.createElement(qo(),{size:30,color:"#3c434a"}))))):o?React.createElement("div",{className:"dlx-patterns-view-error"},React.createElement("p",null,(0,s.__)("Error loading patterns:","pattern-wrangler")," ",o),React.createElement(l.Button,{variant:"primary",onClick:function(){return(0,ai.dispatch)(El).fetchData()}},(0,s.__)("Retry","pattern-wrangler"))):React.createElement(Ul,Dl({data:r},e))};var ql=document.getElementById("dlx-pattern-wrangler-view");ql&&(0,e.createRoot)(ql).render(React.createElement(Wl,null))})()})();
  • pattern-wrangler/trunk/pattern-wrangler.php

    r3425616 r3425712  
    44 * Plugin URI:        https://dlxplugins.com/plugins/pattern-wrangler/
    55 * Description:       Manage your block patterns.
    6  * Version:           2.1.0
     6 * Version:           2.1.1
    77 * Requires at least: 6.8
    88 * Requires PHP:      7.2
     
    2525require_once __DIR__ . '/functions.php';
    2626
    27 define( 'DLXPW_PATTERN_WRANGLER_VERSION', '2.1.0' );
     27define( 'DLXPW_PATTERN_WRANGLER_VERSION', '2.1.1' );
    2828define( 'DLXPW_PATTERN_WRANGLER_FILE', __FILE__ );
    2929
  • pattern-wrangler/trunk/readme.txt

    r3425616 r3425712  
    55Tested up to: 6.9
    66Requires PHP: 7.2
    7 Stable tag: 2.1.0
     7Stable tag: 2.1.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    121121== Changelog ==
    122122
     123= 2.1.1 =
     124* Released 2025-12-22
     125* Hot fix: Disabling/enabling patterns would error out on some installs.
     126
    123127= 2.1.0 =
    124128* Released 2025-12-22
     
    199203== Upgrade Notice ==
    200204
    201 = 2.1.0 =
    202 Disabling the enhanced patterns view could lead to a white screen because of a mis-placed PHP exit module. Removing JS debug warnings. Removing trailing slash added to admin-ajax causing previews to fail.
     205= 2.1.1 =
     206Hot fix: Disabling/enabling patterns would error out on some installs.
Note: See TracChangeset for help on using the changeset viewer.