403Webshell
Server IP : 207.135.97.11  /  Your IP : 172.19.0.1
Web Server : LiteSpeed
System : Linux 6d372a2d2e33 5.14.0-611.24.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jan 23 11:42:43 UTC 2026 x86_64
User : nobody ( 65534)
PHP Version : 8.3.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/html/ed.net.au/wp-content/plugins/search-regex/build/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/ed.net.au/wp-content/plugins/search-regex/build/search-regex.js
(()=>{"use strict";var e={6(e,t,r){var s=r(795),n=r(609),a=r.n(n),l=r(603);const c=window.wp.i18n;function o(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!o(e[r],t[r]))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(const s of r){if(!Object.prototype.hasOwnProperty.call(t,s))return!1;if(!o(e[s],t[s]))return!1}return!0}return!1}function i(e){const t=new URLSearchParams;for(const r in e){const s=e[r];if(null!=s)if(Array.isArray(s))if(s.some(e=>"object"==typeof e&&null!==e))t.append(r,JSON.stringify(s));else for(const e of s)null!=e&&t.append(`${r}[]`,String(e));else"object"==typeof s?t.append(r,JSON.stringify(s)):t.append(r,String(s))}return t.toString()}function u(e,t){const r=h(e,t,"?");document.location.search!==r&&history.pushState({},"",r)}function d(e){return function(e){const t=new URLSearchParams(e),r={},s=new Map;t.forEach((e,t)=>{const r=t.replace(/\[\d*\]$/,"");s.has(r)||s.set(r,[]),s.get(r).push({key:t,value:e})});for(const[e,t]of s){const s=t.map(e=>e.value);s.length>1?r[e]=s:1===s.length&&(r[e]=s[0])}return r}(e?e.slice(1):document.location.search.slice(1))}function h(e,t,r){const s=d(r);for(const r in e){const n=o(t[r],e[r]);e[r]&&!n||"page"===r?s[r.toLowerCase()]=e[r]:n&&delete s[r.toLowerCase()]}return"?"+i(s)}const p=["search","options","support","presets"];function g(e=""){const t=d(e);return t.sub&&-1!==p.indexOf(t.sub)?t.sub:p[0]}class x extends n.Component{constructor(e){super(e),this.state={error:!1,stack:null,errorInfo:null}}static getDerivedStateFromError(e){return{error:!0,stack:e}}componentDidCatch(e,t){this.setState({error:!0,stack:e,errorInfo:t}),console.error(e,t)}render(){const{error:e,stack:t,errorInfo:r}=this.state,{renderCrash:s,children:n,extra:a}=this.props;return e?s(t,r,a):n}}const m=x;var _=r(790);const f=({value:e,label:t,disabled:r=!1})=>Array.isArray(e)?(0,_.jsx)("optgroup",{label:String(t),disabled:r,children:e.map((e,t)=>(0,_.jsx)(f,{label:e.label,value:e.value,disabled:e.disabled||!1},t))}):(0,_.jsx)("option",{value:e,disabled:r,children:t}),v=f,j=({items:e,value:t,name:r,onChange:s,disabled:n=!1,className:a})=>(0,_.jsx)("select",{name:r,value:t,onChange:s,disabled:n,className:a,children:e.map((e,t)=>(0,_.jsx)(v,{value:e.value,label:e.label,disabled:e.disabled||!1},t))}),b=({item:e,isCurrent:t,onClick:r,isLast:s,urlBase:n})=>{const a=n+(""===e.value?"":"&sub="+e.value);return(0,_.jsxs)("li",{children:[(0,_.jsx)("a",{className:t?"current":"",href:a,onClick:t=>{t.preventDefault(),r(e.value,a)},children:e.name})," ",!s&&"|"," "]})},y=(e,t,r)=>e===t.value||e===r&&""===t.value,w=({onChangePage:e,menu:t,home:r,urlBase:s,currentPage:n})=>t.length<2?null:(0,_.jsx)("div",{className:"subsubsub-container",children:(0,_.jsx)("ul",{className:"subsubsub",children:t.map((a,l)=>(0,_.jsx)(b,{item:a,isCurrent:y(n,a,r),isLast:l===t.length-1,onClick:e,urlBase:s},l))})});var S=r(526),C=r(589);const k=function(e){const{error:t,mini:r,context:s,renderDebug:a,versions:l,noParse:o=!1,details:i=[],locale:u}=e,[d,h]=(0,n.useState)(!r);if(!d)return(0,_.jsx)("p",{children:(0,_.jsx)("button",{className:"button button-secondary",type:"button",onClick:()=>h(!0),children:(0,c.__)("Show debug",u)})});const p=o?[t]:function(e,t,r){const s=t?[t]:[],{request:n=!1,data:a}=e;s.push("");const{apiFetch:l}=n||{};l&&l.status&&l.statusText&&(s.push("Action: "+l.action),l.body&&"{}"!==l.body&&s.push("Params: "+l.body),s.push("Code: "+l.status+" "+l.statusText),s.push(""));const c=function(e){if("string"==typeof e)return e;const t=e;return 0===t.code?t.message:t.data&&t.data.wpdb?`${t.message} (${t.code}): ${t.data.wpdb}`:t.code?`${t.message} (${t.code})`:t.message}(e);return"string"==typeof c&&c.length>0&&s.push("Error: "+c),a&&s.push("Raw: "+a),r&&(s.push(""),s.push("Context:"),s.push(r)),s}(t,l,s);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("h3",{children:(0,c.__)("Debug Information",u)}),a&&a(i.concat(p).join("\n")),(0,_.jsx)("p",{children:(0,_.jsx)(C.A,{readOnly:!0,cols:120,value:i.concat(p).join("\n"),maxRows:40,spellCheck:!1})})]})},N=function(e){const{locale:t}=e;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("h2",{children:(0,c.__)("You are using an old or cached session",t)}),(0,_.jsx)("p",{children:(0,c.__)("This is usually fixed by doing one of the following:",t)}),(0,_.jsxs)("ul",{children:[(0,_.jsx)("li",{children:(0,c.__)("Reload the page - your current session is old.",t)}),(0,_.jsx)("li",{children:(0,c.__)("Log out, clear your browser cache, and log in again - your browser has cached an old session.",t)}),(0,_.jsx)("li",{children:(0,c.__)("Your admin pages are being cached. Clear this cache and try again. There may be multiple caches involved.",t)})]}),(0,_.jsx)(k,{...e,error:e.error||{},mini:!0})]})},R=({url:e,children:t,title:r,className:s})=>(0,_.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:r,className:s,children:t});function P(e){return 404===e?.request?.apiFetch?.status}function A(e){const t=e.code;return"disabled"===t||"rest_disabled"===t}function O(e){return"rest_api_redirected"===e?.code}function F(e){const t=e;return 0===t.code?t.message:t.data&&t.data.wpdb?(0,_.jsxs)("span",{children:[`${t.message} (${t.code})`,": ",(0,_.jsx)("code",{children:t.data.wpdb})]}):t.code?(0,_.jsxs)(_.Fragment,{children:[t.message," (",(0,_.jsx)("code",{children:t.code}),")"]}):t.message}const D=window.wp.element;function I(e,t){try{return(0,D.createInterpolateElement)(e.replace(/\{\{/g,"<").replace(/\}\}/g,">"),t)}catch(t){return e}}const E=({error:e,links:t,locale:r})=>{if("string"==typeof e)return(0,_.jsx)("p",{children:e});if(function(e){return void 0!==e.code&&0===e.code}(e))return(0,_.jsx)("p",{children:(0,c.__)("WordPress did not return a response. This could mean an error occurred or that the request was blocked. Please check your server error_log.",r)});if(function(e){const t=e,{request:r,code:s}=t;return!!(r&&r.status&&s)&&(-1!==[400,401,403,405].indexOf(r.status)||"rest_no_route"===s)&&0===parseInt(String(s),10)}(e))return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{children:F(e)}),(0,_.jsx)("p",{children:(0,c.__)("Your REST API is probably being blocked by a security plugin. Please disable this, or configure it to allow REST API requests.",r)}),(0,_.jsx)("p",{children:(0,_.jsx)(R,{url:t.api,children:(0,c.__)("Read this REST API guide for more information.",r)})})]});if(P(e))return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{children:(0,c.__)("Your WordPress REST API is returning a 404 page. This is almost certainly an external plugin or server configuration issue.",r)}),(0,_.jsx)("p",{className:"wpl-error__highlight",children:(0,_.jsx)("strong",{children:(0,c.__)("You will will need to fix this on your site. Redirection is not causing the error.",r)})}),(0,_.jsxs)("ul",{children:[(0,_.jsx)("li",{children:I((0,c.__)("Can you access your {{api}}REST API{{/api}} without it redirecting?",r),{api:(0,_.jsx)(R,{url:t.rootUrl,children:t.rootUrl})})}),(0,_.jsx)("li",{children:I((0,c.__)("Check your {{link}}Site Health{{/link}} and fix any issues.",r),{link:(0,_.jsx)(R,{url:t.siteHealth,children:t.siteHealth})})}),(0,_.jsx)("li",{children:(0,c.__)("Your server configuration is blocking access to the REST API.",r)}),(0,_.jsx)("li",{children:(0,c.__)("A security plugin or firewall is blocking access. You will need to whitelist the REST API.",r)})]}),(0,_.jsx)("p",{children:(0,_.jsx)(R,{url:t.api,children:(0,c.__)("Read this REST API guide for more information.",r)})})]});if(O(e))return(0,_.jsx)("p",{children:(0,c.__)("Your REST API is being redirected. Please remove the redirection for the API.",r)});if(function(e){return 413===e?.request?.apiFetch?.status}(e))return(0,_.jsx)("p",{children:(0,c.__)("Your server has rejected the request for being too big. You will need to reconfigure it to continue.",r)});if(function(e){return void 0===e.message}(e))return(0,_.jsx)("p",{children:(0,c.__)("An unknown error occurred.",r)});if(function(e){const t=e.data;return"string"==typeof t&&-1!==t.indexOf("<b>Deprecated</b>:  Directive")}(e))return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{children:F(e)}),(0,_.jsx)("p",{children:(0,c.__)("Your REST API is showing a deprecated PHP error. Please fix this error.",r)})]});if(function(e){return-1!==[500,502,503].indexOf(e?.request?.apiFetch?.status??0)}(e))return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{children:F(e)}),(0,_.jsx)("p",{children:(0,c.__)("This could be a security plugin, or your server is out of memory or has an external error. Please check your server error log",r)}),(0,_.jsx)("p",{children:(0,_.jsx)(R,{url:t.http,children:(0,c.__)("Read this REST API guide for more information.",r)})})]});if(A(e))return(0,_.jsx)("p",{children:(0,c.__)("Your WordPress REST API has been disabled. You will need to enable it to continue.",r)});if(function(e){return"SyntaxError"===e.code}(e)){const t=function(e){const t=e.lastIndexOf("}");if(t!==e.length)return e.substring(t+1).trim();const r=e.split("<br />").filter(e=>e);return r.slice(0,r.length-1).join(" ").trim()}(e?.request?.apiFetch?.body||"");return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{children:F(e)}),(0,_.jsx)("p",{children:(0,c.__)("WordPress returned an unexpected message. This could be a PHP error from another plugin, or data inserted by your theme.",r)}),t.length>1&&(0,_.jsxs)("p",{children:[(0,_.jsxs)("strong",{children:[(0,c.__)("Possible cause",r),":"]})," ",(0,_.jsx)("code",{children:t.slice(0,1e3)})]})]})}return function(e){const t=e?.message?.toString().toLowerCase();return!!t&&("failed to fetch"===t||"not allowed to request resource"===t||-1!==t.indexOf("networkerror"))}(e)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{children:F(e)}),(0,_.jsx)("p",{children:(0,c.__)("Unable to make request due to browser security. This is typically because your WordPress and Site URL settings are inconsistent, or the request was blocked by your site CORS policy.",r)}),(0,_.jsx)("p",{children:(0,_.jsx)(R,{url:t.url,children:(0,c.__)("Read this REST API guide for more information.",r)})})]}):function(e){const{headers:t}=e.request??{};if(t&&Symbol.iterator in Object(t))for(const[e]of t)if(-1!==e.toLowerCase().indexOf("cf-"))return!0;return!1}(e)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{children:F(e)}),(0,_.jsx)("p",{children:(0,c.__)("Your REST API appears to be cached and this will cause problems. Please exclude your REST API from your caching system.",r)})]}):(0,_.jsx)("p",{children:F(e)})};function T(e,t,r){return P(e)?(0,c.__)("REST API 404"):t||(0,c.__)("Something went wrong 🙁",r)}const M=function(e){const{title:t,children:r,error:s,links:n,locale:a}=e,l=function(e){return!P(e)&&!O(e)&&!A(e)}(s),c=function(e){return!!P(e)||!!O(e)||!!A(e)}(s),o=!P(s);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("h2",{children:T(s,t,a)}),(0,_.jsx)("div",{className:"wpl-error__title",children:(0,_.jsx)(E,{error:s,links:n,locale:a})}),l&&r,(0,_.jsx)(k,{error:s,locale:a,...c?{mini:!0}:{},...!o&&e.renderDebug?{renderDebug:e.renderDebug}:{},...e.details?{details:e.details}:{},...e.versions?{versions:e.versions}:{},...e.context?{context:e.context}:{}})]})},Y=function(e){const{title:t,children:r,error:s,links:n,locale:a}=e;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("h2",{children:t||(0,c.__)("Something went wrong 🙁",a)}),(0,_.jsx)("div",{className:"wpl-error__detail",children:(0,_.jsx)(E,{error:s,links:n,locale:a})}),r,(0,_.jsx)(k,{...e})]})},L=function(e){const{title:t,children:r,error:s,links:n,locale:a}=e;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("h2",{children:t||(0,c.__)("Something went wrong 🙁",a)}),(0,_.jsx)("div",{className:"wpl-error__detail",children:(0,_.jsx)(E,{error:s,links:n,locale:a})}),r,(0,_.jsx)(k,{...e})]})},V=function(e){const{locale:t}=e;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("h2",{children:(0,c.__)("Bad data",t)}),(0,_.jsx)("p",{children:(0,c.__)("There was a problem making a request to your site. This could indicate you provided data that did not match requirements, or that the plugin sent a bad request.",t)}),(0,_.jsx)("p",{children:(0,c.__)("Please review your data and try again.",t)}),(0,_.jsx)(k,{...e,error:e.error||{},mini:!0})]})};function $({current:e,change:t,total:r}){return(0,_.jsxs)("div",{className:"wpl-error__page",children:[e>0&&(0,_.jsx)("span",{onClick:()=>t(e-1),onKeyDown:r=>{"Enter"!==r.key&&" "!==r.key||(r.preventDefault(),t(e-1))},role:"button",tabIndex:0,children:"←"}),`${e+1}/${r}`,e+1<r&&(0,_.jsx)("span",{onClick:()=>t(e+1),onKeyDown:r=>{"Enter"!==r.key&&" "!==r.key||(r.preventDefault(),t(e+1))},role:"button",tabIndex:0,children:"→"})]})}const U=function(e){const{onClear:t,mini:r=!1,type:s=""}=e,a=(0,n.useMemo)(()=>Array.isArray(e.errors)?e.errors:[e.errors],[e.errors]),[l,c]=(0,n.useState)(0);(0,n.useEffect)(()=>{!r&&a.length>0&&window.scrollTo(0,0)},[a,r]);const o=e=>{"click"!==e.type&&("keydown"!==e.type||"Enter"!==e.key&&" "!==e.key)||("keydown"===e.type&&e.preventDefault(),t&&t())};if(0===a.length)return null;const i=function(e,t){const r=e[0];return"rest_cookie_invalid_nonce"===r?.code?N:400===r?.jsonData?.status?V:"error"===t?Y:"fixed"===t?L:M}(a,s);return(0,_.jsxs)("div",{className:(0,S.A)("wpl-error",{"wpl-error__mini":r}),children:[t&&(0,_.jsx)("div",{className:"closer",onClick:o,onKeyDown:o,role:"button",tabIndex:0,children:(0,_.jsx)("span",{className:"dashicons dashicons-no-alt"})}),a.length>1&&(0,_.jsx)($,{current:l,change:c,total:a.length}),(0,_.jsx)(i,{error:a[l],...e})]})};let q=!1;function B({notices:e}){const t=e[e.length-1],r=t?.message??"";return(0,_.jsx)(_.Fragment,{children:r+(e.length>1?" ("+e.length+")":"")})}const K=function({notices:e,onClear:t,snackBarViewText:r}){const[s,a]=(0,n.useState)(!1);if((0,n.useEffect)(()=>(e.length>0&&(a(!1),q&&clearTimeout(q),q=setTimeout(()=>a(!0),5e3)),()=>{q&&clearTimeout(q)}),[e]),0===e.length)return null;function l(){s?a(!1):t()}const c=(0,S.A)("notice","notice-info","wpl-notice",s&&"wpl-notice_shrunk");return(0,_.jsxs)("div",{className:c,onClick:l,onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),l())},role:"button",tabIndex:0,children:[(0,_.jsx)("div",{className:"closer",children:(0,_.jsx)("span",{className:"dashicons dashicons-yes"})}),(0,_.jsx)("p",{children:s?(0,_.jsx)("span",{className:"dashicons dashicons-warning",title:r}):(0,_.jsx)(B,{notices:e})})]})};function G(e){return-1!==SearchRegexi10n.caps.pages.indexOf(e)}var W=r(778);const H=(0,W.v)()(e=>({errors:[],notices:[],addError:t=>{e(e=>({errors:[...e.errors,t]})),console.error(t)},addNotice:t=>{e(e=>({notices:[...e.notices,t]}))},clearErrors:()=>e({errors:[]}),clearNotices:()=>e({notices:[]})}));var J=r(537),z=r(928);const Q=e=>"object"==typeof e&&null!==e,X=e=>0===e?"Admin AJAX returned 0":"string"==typeof e?e:Q(e)&&e.message?e.message:(console.error(e),"Unknown error "+(Q(e)?Object.keys(e):e));let Z=[];function ee(e,t,r){return{code:(s=e,"number"==typeof s?`${s}`:Q(s)&&s.error_code?s.error_code:Q(s)&&s.code?s.code:Q(s)&&s.name?s.name:Q(s)&&s.data?.error_code?s.data.error_code:String(s)),message:X(t),request:r,data:r.apiFetch?.data?r.apiFetch?.data:null,jsonData:e&&e.data?e.data:null};var s}const te=e=>{if(e.status>=200&&e.status<300)return e;throw e};function re(e){return e.headers.get("x-wp-nonce")&&ne.nonceMiddleware&&(ne.nonceMiddleware.nonce=e.headers.get("x-wp-nonce")??ne.nonceMiddleware.nonce),e}const se=e=>e.text(),ne=e=>{const t=[...Z,e=>(e=>fetch(e.url,e).then(re).then(t=>((e,t)=>(t.apiFetch={action:t.url.replace(/[\?&]_wpnonce=[a-f0-9]*/,"")+" "+t.method.toUpperCase(),body:"object"==typeof t.body?JSON.stringify(t.body):t.body},t.headers=e.headers,e.status&&void 0!==e.statusText&&(t.apiFetch.status=e.status,t.apiFetch.statusText=e.statusText),e))(t,e)).then(se).then(t=>((e,t)=>(t.apiFetch&&(t.apiFetch.data=e),e))(t,e)).then(t=>((e,t)=>{const r=t.apiFetch?.status;if(""===e&&void 0!==r&&(r<200||r>300))return e;try{const r=JSON.parse(e.replace(/\ufeff/,""));if(0===r)throw ee("json-zero","Failed to get data",t);return r}catch(e){throw ee(e,e?.message,t)}})(t,e)).then(t=>((e,t)=>{if(e?.error||e?.error_code)throw ee(e,e.message,t);if(t.apiFetch){const{status:r,statusText:s}=t.apiFetch;if(e?.code&&e?.message)throw ee(e,e,t);if(void 0!==r&&(r<200||r>=300))throw ee(r,s,t)}return e})(t,e)))(e)],r=e=>s=>{const n=t[e];return n?n(s,e===t.length-1?()=>Promise.resolve():r(e+1)):Promise.reject(new Error("Middleware step is undefined"))};return new Promise((t,s)=>{r(0)(e).then(e=>t(e)).catch(r=>{if("rest_cookie_invalid_nonce"!==r.code)return s(r);window.fetch("admin-ajax.php?action=rest-nonce").then(te).then(se).then(r=>{ne.nonceMiddleware.nonce=r,ne(e).then(t).catch(s)}).catch(s)})})};ne.getUrl=e=>ne.rootURLMiddleware({url:e},e=>ne.nonceMiddleware(e,e=>e.url)),ne.use=function(e){Z.unshift(e)},ne.createNonceMiddleware=e=>{const t=(e=>{const t=(e,r)=>{const{headers:s={}}=e;for(const n in s)if("x-wp-nonce"===n.toLowerCase()&&s[n]===t.nonce)return r(e);return r({...e,headers:{...s,"X-WP-Nonce":t.nonce}})};return t.nonce=e,t})(e);return ne.nonceMiddleware=t,t},ne.createRootURLMiddleware=e=>{const t=function(e){const t=(t,r)=>{return t.url.startsWith("http")?r(t):r({...t,url:(s=e,n=t.url,function(e){return e.replace("wp-json/wp-json","wp-json").replace("=/wp-json","=")}((a=function(e){return e.replace(/\/$/,"")}(s),l=function(e,t){return-1!==e.indexOf("?")?t.replace("?","&"):t}(s,function(e){return e.replace(/^\//,"")}(n)),a+"/"+l)))});var s,n,a,l};return t.rootURL=e,t}(e);return ne.rootURLMiddleware=t,t},ne.resetMiddlewares=()=>{Z=[]},ne.replaceRootURLMiddleware=e=>{for(let t=0;t<Z.length;t++)Z[t]===ne.rootURLMiddleware&&(Z[t]=ne.createRootURLMiddleware(e))};const ae=ne,le=(e,t={})=>{const r=e+"/";if(Object.keys(t).length>0){const e=function(e){const t=new URLSearchParams;function r(e,s){for(const n in s){const a=s[n];if(null!=a)if(Array.isArray(a))for(const r of a)null!=r&&t.append(`${e}[${n}][]`,String(r));else"object"==typeof a?r(`${e}[${n}]`,a):t.append(`${e}[${n}]`,String(a))}}for(const s in e){const n=e[s];if(null!=n)if(Array.isArray(n))for(const e of n)null!=e&&t.append(`${s}[]`,String(e));else"object"==typeof n?r(s,n):t.append(s,String(n))}return t.toString()}(t);if(e.length>0)return r+(-1===r.indexOf("?")?"?":"&")+e}return r},ce=(e,t={})=>({headers:{Accept:"application/json, */*;q=0.1"},url:le(e,t),credentials:"include",method:"get",redirect:"error"}),oe=(e,t={},r={})=>{const s={headers:{"Content-Type":"application/json; charset=utf-8",Accept:"application/json, */*;q=0.1"},url:le(e,r),credentials:"include",method:"post",body:"{}"};return Object.keys(t).length>0&&(s.body=JSON.stringify(t)),s};function ie(e,t){return"undefined"!=typeof SearchRegexi10n&&SearchRegexi10n.preload&&e in SearchRegexi10n.preload&&void 0!==SearchRegexi10n.preload[e]?SearchRegexi10n.preload[e]:t}var ue=r(973);const de=ue.Ik({context_offset:ue.ai(),pos_id:ue.ai(),match:ue.Yj(),replacement:ue.Yj(),captures:ue.YO(ue.Yj())}),he=ue.KC([ue.Ik({context_id:ue.KC([ue.Yj(),ue.ai()]),type:ue.eu("string"),context:ue.Yj(),crop:ue.Ik({start:ue.ai().optional(),end:ue.ai().optional()}).optional(),search:ue.Yj().optional(),flags:ue.L5().optional(),matches:ue.YO(de),match_count:ue.ai(),value_type:ue.Yj().optional()}),ue.Ik({context_id:ue.KC([ue.Yj(),ue.ai()]),type:ue.eu("value"),value:ue.Yj(),value_type:ue.Yj(),value_label:ue.Yj(),value_length:ue.ai()}),ue.Ik({context_id:ue.KC([ue.Yj(),ue.ai()]),type:ue.eu("replace"),value:ue.Yj(),value_type:ue.Yj(),value_label:ue.Yj(),value_length:ue.ai(),replacement:ue.Yj(),replacement_label:ue.Yj()}),ue.Ik({context_id:ue.KC([ue.Yj(),ue.ai()]),type:ue.eu("add"),value:ue.Yj(),value_type:ue.Yj(),value_label:ue.Yj(),value_length:ue.ai()}),ue.Ik({context_id:ue.KC([ue.Yj(),ue.ai()]),type:ue.eu("delete"),value:ue.Yj(),value_type:ue.Yj(),value_label:ue.Yj(),value_length:ue.ai()}),ue.Ik({context_id:ue.KC([ue.Yj(),ue.ai()]),type:ue.eu("keyvalue"),key:ue.bz(),value:ue.bz()}),ue.Ik({context_id:ue.KC([ue.Yj(),ue.ai()]),type:ue.eu("empty")}),ue.Ik({context_id:ue.KC([ue.Yj(),ue.ai()]).transform(e=>String(e)).optional(),type:ue.Yj()}).passthrough()]),pe=ue.Ik({row_id:ue.KC([ue.Yj(),ue.ai()]).transform(e=>String(e)),match_count:ue.ai().optional(),source_name:ue.Yj(),source_type:ue.Yj(),title:ue.Yj(),actions:ue.L5(),columns:ue.YO(ue.Ik({column_id:ue.Yj(),column_label:ue.Yj().optional(),contexts:ue.YO(he),context_count:ue.ai().optional(),match_count:ue.ai().optional()}))}),ge=ue.Ik({current:ue.ai().optional(),rows:ue.ai().optional(),next:ue.KC([ue.zM(),ue.ai()]),previous:ue.KC([ue.zM(),ue.ai()]).optional()}),xe=ue.Ik({matched_rows:ue.ai(),rows:ue.ai(),custom:ue.YO(ue.Ik({name:ue.Yj(),value:ue.ai()})).optional()}),me=ue.Ik({results:ue.YO(pe),progress:ge,totals:xe,status:ue.Yj().optional()}),_e=ue.Ik({results:ue.YO(ue.KC([ue.Yj(),ue.g1(ue.Yj(),ue.L5())])),progress:ge,totals:xe,status:ue.Yj().optional()}),fe=ue.Ik({result:ue.Yj()}),ve=(ue.Ik({result:ue.Ik({row_id:ue.Yj(),source_name:ue.Yj(),source_type:ue.Yj(),title:ue.Yj(),actions:ue.L5(),columns:ue.YO(ue.Ik({column_id:ue.Yj(),contexts:ue.YO(ue.L5())}))})}),ue.Ik({result:ue.Ik({row_id:ue.KC([ue.Yj(),ue.ai()]).transform(e=>String(e)),match_count:ue.ai().optional(),source_name:ue.Yj(),source_type:ue.Yj(),title:ue.Yj(),actions:ue.L5(),columns:ue.YO(ue.Ik({column_id:ue.Yj(),column_label:ue.Yj().optional(),contexts:ue.YO(ue.L5()),context_count:ue.ai().optional(),match_count:ue.ai().optional()}))}),row:ue.Ik({row_id:ue.Yj(),source_name:ue.Yj(),source_type:ue.Yj(),title:ue.Yj(),actions:ue.L5(),columns:ue.YO(ue.Ik({column_id:ue.Yj(),contexts:ue.YO(ue.L5())}))}).optional()})),je=(ue.YO(ue.Ik({value:ue.Yj(),label:ue.Yj()})),ue.Ik({name:ue.Yj(),title:ue.Yj()})),be=ue.Ik({search:ue.L5(),id:ue.Yj(),name:ue.Yj(),description:ue.Yj().optional(),locked:ue.YO(ue.Yj()),tags:ue.YO(je)}),ye=ue.Ik({search:ue.L5(),id:ue.Yj().optional(),name:ue.Yj(),description:ue.Yj().optional(),locked:ue.YO(ue.Yj()).optional().default([]),tags:ue.YO(je).optional().default([])}),we=ue.KC([ye,ue.YO(ye)]).transform(e=>Array.isArray(e)?e:[e]),Se=ue.Ik({presets:ue.YO(be)}),Ce=ue.Ik({presets:ue.YO(be),imported:ue.ai()}),ke=ue.Ik({support:ue.zM(),rest_api:ue.ai(),startupMode:ue.k5(["simple","advanced","preset"]),startupPreset:ue.Yj().optional(),update_notice:ue.KC([ue.Yj(),ue.eu(!1)]).optional()}),Ne=ue.Ik({settings:ke,warning:ue.L5().optional()}),Re=ue.Ik({column:ue.Yj(),logic:ue.Yj().optional(),value:ue.Yj().optional(),startValue:ue.KC([ue.ai(),ue.Yj()]).optional(),endValue:ue.KC([ue.ai(),ue.Yj()]).optional(),flags:ue.YO(ue.Yj()).optional(),values:ue.YO(ue.Yj()).optional(),key:ue.Yj().optional(),keyLogic:ue.Yj().optional(),keyFlags:ue.YO(ue.Yj()).optional(),valueLogic:ue.Yj().optional(),valueFlags:ue.YO(ue.Yj()).optional()}),Pe=ue.Ik({type:ue.Yj(),items:ue.YO(Re)}),Ae=ue.Ik({searchPhrase:ue.Yj().optional(),searchFlags:ue.YO(ue.Yj()).optional(),source:ue.YO(ue.Yj()).optional(),replacement:ue.Yj().optional(),perPage:ue.ai().optional(),filters:ue.YO(Pe).optional(),view:ue.YO(ue.Yj()).optional(),action:ue.Yj().optional(),actionOption:ue.L5().optional()}).passthrough(),Oe=ue.Ik({searchphrase:ue.Yj().optional(),searchflags:ue.Yj().optional().transform(e=>e?e.split(",").filter(Boolean):void 0),source:ue.Yj().optional().transform(e=>e?e.split(",").filter(Boolean):[]),replacement:ue.Yj().optional(),perpage:ue.Yj().optional().transform(e=>e?parseInt(e,10):void 0).pipe(ue.ai().optional()),filters:ue.Yj().optional().transform(e=>{if(e)try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}),view:ue.Yj().optional().transform(e=>e?e.split(",").filter(Boolean):void 0),mode:ue.k5(["simple","advanced"]).optional()}).passthrough(),Fe=["presets"];function De(){return(0,J.I)({queryKey:Fe,queryFn:async()=>ie("presets",[]),initialData:ie("presets",[]),staleTime:1/0})}function Ie(){const e=(0,l.jE)(),t=H(e=>e.addNotice),r=H(e=>e.addError);return(0,z.n)({mutationFn:async e=>{const t=await ae(oe(`search-regex/v1/preset/id/${e.id}`,e));return Se.parse(t)},onSuccess:r=>{e.setQueryData(Fe,r.presets),t((0,c.__)("Preset saved","search-regex"))},onError:e=>{r(e)}})}const Ee=(0,W.v)()(e=>({currentPreset:null,setCurrentPreset:(t,r=!1)=>{e({currentPreset:t}),r||(t?u({page:"search-regex.php",preset:t.id},d()):function(){const e=d();delete e.preset;const t=0===Object.keys(e).length?"":"?"+i(e);document.location.search!==t&&history.pushState({},"",t)}())}})),Te=function(e){const t="mailto:john@searchregex.com?subject=Search%20Regex%20Error&body="+encodeURIComponent(e),r="https://github.com/johngodley/search-regex/issues/new?title=Search%20Regex%20Error&body="+encodeURIComponent("```\n"+e+"\n```\n\n");return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{className:"wpl-error__highlight",children:I((0,c.__)("Please check the {{link}}support site{{/link}} before proceeding further.","search-regex"),{link:(0,_.jsx)(R,{url:"https://searchregex.com/support/"})})}),(0,_.jsx)("p",{children:I((0,c.__)("If that did not help then {{strong}}create an issue{{/strong}} or send it in an {{strong}}email{{/strong}}.","search-regex"),{strong:(0,_.jsx)("strong",{})})}),(0,_.jsxs)("p",{children:[(0,_.jsx)("a",{href:r,className:"button-primary",children:(0,c.__)("Create An Issue","search-regex")})," ",(0,_.jsx)("a",{href:t,className:"button-secondary",children:(0,c.__)("Email","search-regex")})]}),(0,_.jsx)("p",{children:(0,c.__)("Include these details in your report along with a description of what you were doing and a screenshot.","search-regex")})]})},Me=function(e){const{request:t}=e.error,r=(e=>!!(e&&e.apiFetch?.body&&e.apiFetch.body.length>500))(t),[s,a]=(0,n.useState)(r),l=e=>{e.preventDefault(),a(!s)};return t?.apiFetch?.body?(0,_.jsxs)(_.Fragment,{children:[s&&r&&(0,_.jsx)("button",{className:"api-result-hide",onClick:l,type:"button",children:(0,c.__)("Show Full","search-regex")}),!s&&r&&(0,_.jsx)("button",{className:"api-result-hide",onClick:l,type:"button",children:(0,c.__)("Hide","search-regex")}),(0,_.jsx)("pre",{children:s?t.apiFetch.body.substring(0,500)+" ...":t.apiFetch.body})]}):null};function Ye(){return{url:"https://searchregex.com/support/problems/rest-api/#url",http:"https://searchregex.com/support/problems/rest-api/#http",api:"https://searchregex.com/support/problems/rest-api/",rootUrl:SearchRegexi10n.api.WP_API_root,siteHealth:SearchRegexi10n.api.site_health}}function Le(){return SearchRegexi10n.versions.split("\n").concat(["Query: "+document.location.search])}const Ve=function({error:e,methods:t}){const r=(e=>e.code?String(e.code):null)(e);return(0,_.jsxs)("div",{className:"api-result-log_details",children:[(0,_.jsx)("p",{children:(0,_.jsx)("span",{className:"dashicons dashicons-no"})}),(0,_.jsxs)("div",{children:[(0,_.jsxs)("p",{children:[t.map((t,r)=>(0,_.jsxs)("span",{className:"api-result-method_fail",children:[t," ",e.request?.status]},r)),r&&(0,_.jsxs)("strong",{children:[r,": "]}),e.message]}),(0,_.jsx)(E,{error:e,links:Ye(),locale:"en"}),(0,_.jsx)(Me,{error:e})]})]},t.join())},$e=function({methods:e}){return(0,_.jsxs)("p",{children:[(0,_.jsx)("span",{className:"dashicons dashicons-yes"}),e.map((e,t)=>(0,_.jsx)("span",{className:"api-result-method_pass",children:e},t)),(0,c.__)("Working!","search-regex")]},e.join())},Ue=e=>e.code?e.code:0,qe=function({result:e}){const t=[],{GET:r,POST:s}=e;return r.status===s.status&&Ue(r)===Ue(s)?("fail"===r.status?t.push((0,_.jsx)(Ve,{error:r.error,methods:["GET","POST"]},"get-post")):t.push((0,_.jsx)($e,{methods:["GET","POST"]},"get-post")),t):("fail"===r.status?t.push((0,_.jsx)(Ve,{error:r.error,methods:["GET"]},"get")):t.push((0,_.jsx)($e,{methods:["GET"]},"get")),"fail"===s.status?t.push((0,_.jsx)(Ve,{error:s.error,methods:["POST"]},"post")):t.push((0,_.jsx)($e,{methods:["POST"]},"post")),t)},Be=function({item:e,result:t,routes:r,isCurrent:s,allowChange:n}){return(e=>0===Object.keys(e).length||"loading"===e.GET.status||"loading"===e.POST.status)(t)?null:(0,_.jsxs)("div",{className:"api-result-log",children:[(0,_.jsxs)("form",{className:"api-result-select",action:SearchRegexi10n.pluginRoot+"&sub=support",method:"POST",children:[n&&!s&&(0,_.jsx)("input",{type:"submit",className:"button button-secondary",value:(0,c.__)("Switch to this API","search-regex")}),n&&s&&(0,_.jsx)("span",{children:(0,c.__)("Current API","search-regex")}),(0,_.jsx)("input",{type:"hidden",name:"rest_api",value:e.value}),(0,_.jsx)("input",{type:"hidden",name:"_wpnonce",value:SearchRegexi10n.api.WP_API_nonce}),(0,_.jsx)("input",{type:"hidden",name:"action",value:"rest_api"})]}),(0,_.jsx)("h4",{children:e.text}),(0,_.jsxs)("p",{children:["URL:"," ",(0,_.jsx)("code",{children:(0,_.jsx)(R,{url:r[e.value]||"",children:r[e.value]||""})})]}),(0,_.jsx)(qe,{result:t})]})},Ke=({size:e=""})=>{const t=(0,S.A)("wpl-spinner__container",e&&" spinner-"+e);return(0,_.jsx)("div",{className:t,children:(0,_.jsx)("span",{className:"wpl-spinner__item"})})},Ge=({className:e,children:t})=>(0,_.jsx)("table",{className:(0,S.A)("wpl-table",e),children:(0,_.jsx)("tbody",{children:t})}),We=e=>{const{title:t,url:r=!1,children:s}=e;return(0,_.jsxs)("tr",{children:[(0,_.jsxs)("th",{children:[!r&&t,r&&(0,_.jsx)("a",{href:r,target:"_blank",rel:"noreferrer",children:t})]}),(0,_.jsx)("td",{children:s})]})},He=["settings"];function Je(){const e=SearchRegexi10n.settings;return(0,J.I)({queryKey:He,queryFn:async()=>{const e=await ae(ce("search-regex/v1/setting"));return Ne.parse(e).settings},...e?{initialData:e}:{},staleTime:1/0})}function ze(){const e=(0,l.jE)(),t=H(e=>e.addNotice),r=H(e=>e.addError);return(0,z.n)({mutationFn:async e=>{const t=await ae(oe("search-regex/v1/setting",e));return Ne.parse(t)},onSuccess:r=>{e.setQueryData(He,r.settings),t((0,c.__)("Settings saved","search-regex"))},onError:e=>{r(e)}})}const Qe=()=>[{value:0,label:(0,c.__)("Default REST API","search-regex")},{value:1,label:(0,c.__)("Raw REST API","search-regex")},{value:3,label:(0,c.__)("Relative REST API","search-regex")}],Xe=function(){const{data:e}=Je(),{mutate:t,isPending:r}=ze(),{data:s=[]}=De(),[a,l]=(0,n.useState)(()=>e?"preset"===e.startupMode&&e.startupPreset?e.startupPreset:e.startupMode:"advanced"),[o,i]=(0,n.useState)(e?.rest_api??0);return e?(0,_.jsxs)("form",{onSubmit:function(e){e.preventDefault();let r,s="advanced";"simple"===a||"advanced"===a?(s=a,r=""):(s="preset",r=a),t({startupMode:s,startupPreset:r,rest_api:o})},children:[(0,_.jsxs)(Ge,{className:"form-table",children:[(0,_.jsx)(We,{title:(0,c.__)("Startup Mode","search-regex"),children:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(j,{items:[{value:"simple",label:(0,c.__)("Simple","search-regex")},{value:"advanced",label:(0,c.__)("Advanced","search-regex")},...s.map(e=>({value:String(e.id),label:e.name}))],name:"startupMode",value:a,onChange:e=>l(e.target.value)}),(0,_.jsx)("p",{className:"sub",children:(0,c.__)("Choose which mode Search Regex should start in. You can still switch modes in the UI.","search-regex")})]})}),(0,_.jsxs)(We,{title:(0,c.__)("REST API","search-regex"),children:[(0,_.jsx)(j,{items:Qe().map(e=>({value:String(e.value),label:e.label})),name:"rest_api",onChange:e=>i(parseInt(e.target.value,10)),value:String(o)})," ",(0,_.jsx)("p",{className:"sub",children:(0,c.__)("How Search Regex uses the REST API - don't change unless necessary","search-regex")})]})]}),(0,_.jsx)("input",{className:"button-primary",type:"submit",name:"update",value:(0,c.__)("Update","search-regex"),disabled:r})]}):null},Ze=(e,t,r)=>ce(`search-regex/v1/source/${e}/complete/${t}`,{value:r}),et=(e,t)=>ce(`search-regex/v1/source/${e}/row/${t}`),tt=(e,t=!1)=>{const r=t?oe("search-regex/v1/plugin/test",{test:"ping"}):ce("search-regex/v1/plugin/test");return{...r,url:e.startsWith("http")?e+r.url:r.url}},rt="ok",st="fail",nt="loading",at="warning-current",lt="warning-not-selected",ct=function({allowChange:e=!1}){const{data:t}=Je(),[r,s]=(0,n.useState)({}),[a,l]=(0,n.useState)(!1),o=SearchRegexi10n.api.routes,i=t?.rest_api,u=String(void 0!==i?i:0),d=()=>{(e=>{for(let t=0;t<e.length;t++){const r=e[t];if(!r)continue;const{id:n,url:a}=r;s(e=>({...e,[n]:{GET:{status:nt},POST:{status:nt}}})),setTimeout(()=>{ae(tt(a)).then(()=>{s(e=>({...e,[n]:{...e[n],GET:{status:rt}}}))}).catch(()=>{s(e=>({...e,[n]:{...e[n],GET:{status:st}}}))}),ae(tt(a,!0)).then(()=>{s(e=>({...e,[n]:{...e[n],POST:{status:rt}}}))}).catch(()=>{s(e=>({...e,[n]:{...e[n],POST:{status:st}}}))})},1e3)}})(Object.keys(o).map(e=>{const t=o[e];return t?{id:e,url:t}:null}).filter(e=>null!==e))},h=()=>{l(!0)},p=e=>a||e===st||e===lt;(0,n.useEffect)(()=>{d()},[]);const g=Qe(),x=((e,t)=>{if(0===Object.keys(e).length)return 0;const r=2*t.length;let s=0;for(const t in e){if(!e[t])continue;const r=e[t];r.GET&&r.GET.status!==nt&&s++,r.POST&&r.POST.status!==nt&&s++}return Math.round(s/r*100)})(r,g),m=((e,t,r)=>{const s=Object.keys(e).filter(t=>{const r=e[t];return!!r&&(e=>!(!e.GET||!e.POST||e.GET.status!==st&&e.POST.status!==st))(r)}).length;if(0===s)return"ok";if(s<t.length){const t=e[r];return t&&(n=t).GET&&n.POST&&n.GET.status===rt&&n.POST.status===rt?at:lt}var n;return"fail"})(r,g,u),f=x>=100&&p(m)||a,v=(0,S.A)({"api-result-status":!0,"api-result-status_good":m===rt&&x>=100,"api-result-status_problem":m===at&&x>=100,"api-result-status_failed":(m===st||m===lt)&&x>=100});return(0,_.jsxs)("div",{className:"api-result-wrapper",children:[(0,_.jsxs)("div",{className:"api-result-header",children:[(0,_.jsx)("strong",{children:"REST API:"}),(0,_.jsxs)("div",{className:"api-result-progress",children:[(0,_.jsxs)("span",{className:v,children:[/* translators: %s: test percent */
x<100&&(0,c.sprintf)((0,c.__)("Testing - %s%%","search-regex"),String(x)),x>=100&&(e=>e===rt?(0,c.__)("Good","search-regex"):e===at?(0,c.__)("Working but some issues","search-regex"):e===lt?(0,c.__)("Not working but fixable","search-regex"):(0,c.__)("Unavailable","search-regex"))(m)]}),x<100&&(0,_.jsx)(Ke,{})]}),x>=100&&m!==rt&&(0,_.jsx)("button",{className:"button button-secondary api-result-retry",onClick:e=>{e.preventDefault(),l(!1),s({}),d()},children:(0,c.__)("Check Again","search-regex")})]}),x>=100&&m!==rt&&(e=>{const t=p(e);let r=(0,c.__)("There are some problems connecting to your REST API. It is not necessary to fix these problems and the plugin is able to work.","search-regex");return e===st?r=(0,c.__)("Your REST API is not working and the plugin will not be able to continue until this is fixed.","search-regex"):e===lt&&(r=(0,c.__)("You are using a broken REST API route. Changing to a working API should fix the problem.","search-regex")),(0,_.jsxs)("div",{className:"api-result-log",children:[(0,_.jsxs)("p",{children:[(0,_.jsx)("strong",{children:(0,c.__)("Summary","search-regex")}),": ",r]}),!t&&(0,_.jsx)("p",{children:(0,_.jsx)("button",{className:"button-secondary",type:"button",onClick:h,children:(0,c.__)("Show Problems","search-regex")})})]})})(m),f&&g.map((t,s)=>{const n={value:String(t.value),text:t.label},a=(l=r,c=String(t.value),l&&l[c]?l[c]:{});var l,c;return a.GET&&a.POST?(0,_.jsx)(Be,{item:n,result:{GET:a.GET,POST:a.POST},routes:o,isCurrent:u===String(t.value),allowChange:e},s):null})]})};function ot(){return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(ct,{}),(0,_.jsx)("h3",{children:(0,c.__)("What do I do next?","search-regex")}),(0,_.jsxs)("ol",{children:[(0,_.jsx)("li",{children:I((0,c.__)("{{link}}Caching software{{/link}}, in particular Cloudflare, can cache the wrong thing. Try clearing all your caches.","search-regex"),{link:(0,_.jsx)(R,{url:"https://searchregex.com/support/problems/cloudflare/"})})}),(0,_.jsx)("li",{children:I((0,c.__)("{{link}}Please temporarily disable other plugins!{{/link}} This fixes so many problems.","search-regex"),{link:(0,_.jsx)(R,{url:"https://searchregex.com/support/problems/plugins/"})})}),(0,_.jsx)("li",{children:I((0,c.__)("Look at your {{link}}Site Health{{/link}} and resolve any issues.","search-regex"),{link:(0,_.jsx)(R,{url:"/wp-admin/site-health.php"})})})]})]})}function it(){return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("p",{children:(0,_.jsx)("strong",{children:(0,c.__)("This error is typically caused by a browser extension (such as Google Translate, Grammarly, ad blocker, etc) modifying the page.","search-regex")})}),(0,_.jsx)("p",{children:(0,c.__)("To fix this:","search-regex")}),(0,_.jsxs)("ul",{style:{listStyle:"disc",marginLeft:"20px"},children:[(0,_.jsx)("li",{children:(0,c.__)("Disable browser extensions for this page","search-regex")}),(0,_.jsx)("li",{children:(0,c.__)("Try using a different browser or incognito/private mode","search-regex")})]})]})}function ut(){return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)("p",{children:[(0,c.__)("Search Regex is not working. Try clearing your browser cache and reloading this page.","search-regex")," "," ",(0,c.__)("If you are using a page caching plugin or service (CloudFlare, OVH, etc) then you can also try clearing that cache.","search-regex")]}),(0,_.jsx)("p",{children:I((0,c.__)("If that doesn't help, open your browser's error console and create a {{link}}new issue{{/link}} with the details.","search-regex"),{link:(0,_.jsx)(R,{url:"https://github.com/johngodley/search-regex/issues"})})})]})}const dt=function(e,t){const r=e?.stack||"",s=t?.componentStack||"",n=function(e){const t=e?.message||"",r=e?.stack||"";return!(!r.includes("chrome-extension://")&&!r.includes("moz-extension://"))||t.includes("Failed to execute 'removeChild'")||t.includes("Failed to execute 'insertBefore'")||t.includes("Failed to execute 'appendChild'")||t.includes("The node to be removed is not a child of this node")}(e);return(0,_.jsx)(U,{errors:"",renderDebug:Te,type:"fixed",links:Ye(),details:Le().concat(["",r,s]),locale:SearchRegexi10n.locale,children:n?(0,_.jsx)(it,{}):(0,_.jsx)(ut,{})})},ht=function(e){const{page:t,setPage:r,children:s,onPageChange:a}=e,l=(0,n.useRef)(void 0);return(0,n.useEffect)(()=>{function e(){const e=g("");r(e)}return window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)}},[r]),(0,n.useEffect)(()=>{void 0!==l.current?(l.current&&l.current!==t&&(a(),history.pushState({},"",h({sub:t},{sub:"search"},"?page=search-regex.php"))),l.current=t):l.current=t},[t,a]),s},pt=function({level:e="notice",children:t,className:r}){return(0,_.jsx)("div",{className:(0,S.A)(`inline-notice inline-${e}`,r),children:t})},gt=()=>(0,_.jsxs)("div",{children:[(0,_.jsx)("h2",{children:(0,c.__)("Need more help?","search-regex")}),(0,_.jsx)("p",{children:I((0,c.__)("Full documentation for Search Regex can be found at {{site}}https://searchregex.com{{/site}}.","search-regex"),{site:(0,_.jsx)(R,{url:"https://searchregex.com/support/"})})}),(0,_.jsx)("p",{children:(0,_.jsx)("strong",{children:I((0,c.__)("If you want to report a bug please read the {{report}}Reporting Bugs{{/report}} guide.","search-regex"),{report:(0,_.jsx)(R,{url:"https://searchregex.com/support/reporting-bugs/"})})})}),(0,_.jsx)(pt,{level:"general",className:"searchregex-help__github-notice",children:(0,_.jsxs)("p",{className:"github",children:[(0,_.jsx)(R,{url:"https://github.com/johngodley/search-regex/issues",children:(0,_.jsx)("img",{src:SearchRegexi10n.pluginBaseUrl+"/includes/GitHub-Mark-64px.png",width:"32",height:"32",alt:"GitHub"})}),(0,_.jsx)(R,{url:"https://github.com/johngodley/search-regex/issues",children:"https://github.com/johngodley/search-regex/"})]})}),(0,_.jsx)("p",{children:(0,c.__)("Please note that any support is provide on as-time-is-available basis and is not guaranteed. I do not provide paid support.","search-regex")}),(0,_.jsx)("p",{children:I((0,c.__)("If you want to submit information that you don't want in a public repository then send it directly via {{email}}email{{/email}} - include as much information as you can!","search-regex"),{email:(0,_.jsx)("a",{href:"mailto:john@searchregex.com?subject=Search%20Regex%20Issue&body="+encodeURIComponent("Search Regex: "+SearchRegexi10n.versions),children:"email"})})}),(0,_.jsx)("h2",{children:(0,c.__)("Redirection","search-regex")}),(0,_.jsx)("p",{children:I((0,c.__)("Like this plugin? You might want to consider {{link}}Redirection{{/link}}, a plugin to manage redirects, from the same author.","search-regex"),{link:(0,_.jsx)(R,{url:"https://redirection.me"})})})]}),xt=()=>(0,_.jsx)(gt,{});var mt=r(28),_t=r(173),ft=r(919);function vt(e){if(null===e)return null;const{left:t,top:r,height:s}=e;return{left:t,top:r+s}}function jt(e,t){return t?{...e,width:t.getBoundingClientRect().width}:e}function bt({style:e,align:t}){const r=(0,S.A)("wpl-popover__arrows",{"wpl-popover__arrows__left":"left"===t,"wpl-popover__arrows__right":"right"===t,"wpl-popover__arrows__centre":"centre"===t});return(0,_.jsx)("div",{className:r,style:e})}const yt=function(e){const{position:t,children:r,popoverPosition:s,align:a,valign:l,hasArrow:c}=e,[o,i]=(0,n.useState)({arrow:{},content:{visibility:"hidden",...t}}),u=(0,n.useCallback)(e=>{if(e){const r=function(e,t,r,s,n,a){if(null===e||null===t)return{};if(!n)return{...e,visibility:"hidden"};const l=e.width?e.width:n.getBoundingClientRect().width,c=t.parentWidth-l-20,o=function(e,t,r,s){return"right"===s?e+t-r:"centre"===s?e-r/2:e}(t.left,t.width,e.width?e.width:l,r);return{...e,left:Math.min(c,o),top:a?e.top+5:e.top}}(t,s,a,0,e,!!c);i({content:r,arrow:jt(r,e)})}},[t,s,a,l,c]);return(0,_.jsxs)(_.Fragment,{children:[c&&(0,_.jsx)(bt,{style:o.arrow,align:a}),(0,_.jsx)("div",{className:"wpl-popover__content",style:{...o.content,visibility:t&&t.left?"visible":"hidden",...null!==e.style?e.style:{}},ref:u,children:r})]})};function wt(e,t){if(!t)return!1;const r=e.target;return!(r&&t.contains(r)||"keydown"===e.type||r&&(r.closest(".wpl-dropdowntext__suggestions")||r.closest(".wpl-multioption")))}function St(e){const t=(0,n.useRef)(null),{children:r,onOutside:s,className:a}=e,l=(0,n.useCallback)(e=>{(wt(e,t.current)||"key"in e&&"Escape"===e.key)&&s(e)},[s]);return(0,n.useEffect)(()=>(addEventListener("mousedown",l),addEventListener("keydown",l),()=>{removeEventListener("mousedown",l),removeEventListener("keydown",l)}),[l]),(0,_.jsx)("div",{className:a,ref:t,children:r})}function Ct(e){let t=document.getElementById(e);if(null===t){const r=document.getElementById("wpbody");t=document.createElement("div"),r&&r.parentNode&&(t.setAttribute("id",e),r.parentNode.appendChild(t))}return t}function kt(e,t="bottom"){const r=document.getElementById("wpwrap");if(null===e||null===r)return null;const s=r.getBoundingClientRect(),{height:n,width:a,left:l,top:c}=e.getBoundingClientRect();return{left:"bottom"===t?l-s.left:l+a/2-s.left-7,top:c-s.top+1,width:a,height:n,parentWidth:s.width,parentHeight:s.height,ref:e}}const Nt=function(e){const{children:t,className:r,align:a="left",valign:l="bottom",onClose:c,hasArrow:o=!1,popoverPosition:i,style:u=null,focusLock:d=!0}=e;return(0,n.useEffect)(()=>(window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}),[c]),(0,s.createPortal)((0,_.jsx)(St,{className:(0,S.A)("wpl-popover",r),onOutside:e=>{i&&!1===wt(e,i.ref)&&"Escape"!==e.key||c()},children:(0,_.jsx)(ft.Ay,{returnFocus:!0,disabled:!d,children:(0,_.jsx)(yt,{position:vt(i),popoverPosition:i,align:a,hasArrow:o,valign:l,style:u,children:t})})}),Ct("wpl-dropdown-portal")||document.body)},Rt=function(e){const{renderContent:t,className:r,renderToggle:s,align:a="left",valign:l="bottom",hasArrow:c=!1,matchMinimum:o=!1,disabled:i=!1,onClose:u}=e,[d,h]=(0,n.useState)(!1),[p,g]=(0,n.useState)(null),x=(0,n.useRef)(null);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:(0,S.A)("wpl-popover__toggle",r,i&&"wpl-popover__toggle__disabled"),ref:x,children:s(d,e=>{if(!x.current)return;const t=kt(x.current,l);e?.stopPropagation(),i||(g(t),h(!d))})}),d&&p&&(0,_.jsx)(Nt,{align:a,valign:l,hasArrow:c,...void 0!==r?{className:r}:{},onClose:function(){h(!1),u?.()},popoverPosition:p,...o&&p.width?{style:{minWidth:`${p.width}px`}}:{},children:t(()=>h(!1))})]})};function Pt({option:e,onChange:t,isSelected:r,optionsType:s="checkbox",name:n}){const{value:a,disabled:l=!1,label:c}=e,o="radio"===s?`multi_${a}`:`multi_${n}_${a}`;return(0,_.jsxs)("p",{children:[(0,_.jsx)("input",{id:o,type:s,name:n||a,value:a,onChange:e=>t(n,a,"checkbox"!==s||e.target.checked),checked:r(n,a),disabled:l,tabIndex:0}),(0,_.jsx)("label",{"aria-label":e.label,htmlFor:o,children:c})]})}const At=function(e){const{option:t,optionsType:r,onChange:s,isSelected:n}=e,{options:a=[],label:l,value:c}=t;return(0,_.jsxs)("div",{className:"wpl-multioption__group",children:[(0,_.jsx)("h5",{children:l}),a.map((e,t)=>(0,_.jsx)(Pt,{option:e,isSelected:n,onChange:s,name:c||e.value,optionsType:r},t))]})},Ot=function(e){const{option:t,isSelected:r,onChange:s}=e;if(t.options){const{optionsType:e="checkbox"}=t;return(0,_.jsx)(At,{option:t,optionsType:e,isSelected:r,onChange:s})}const n=t.value||"";return(0,_.jsx)(Pt,{option:{label:t.label,value:n,disabled:t.disabled??!1,default:t.default??!1},isSelected:r,onChange:s,optionsType:"checkbox",name:n})},Ft=e=>{const{children:t,className:r,onClick:s,title:n="",onCancel:a,disabled:l=!1,small:c=!1}=e,o={title:n,onClick:s};return(0,_.jsxs)("div",{className:(0,S.A)("wpl-badge",r,{"wpl-badge__click":s,"wpl-badge__small":c,"wpl-badge__disabled":l}),...o,children:[(0,_.jsx)("div",{className:"wpl-badge__content",children:t}),a&&(0,_.jsx)("div",{className:"wpl-badge__close dashicons dashicons-no-alt",onClick:e=>{e.preventDefault(),!l&&a&&a(e)},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),!l&&a&&a(e))},role:"button",tabIndex:0})]})};function Dt(e,t){for(let r=0;r<e.length;r++){const s=e[r];if(s){if(s.value===t)return s;if(s.options){const e=Dt(s.options,t);if(e)return e}}}return null}function It(e,t){return e&&t?{title:e.badge||e.label,default:e.default??!1,onRemove:r=>{if(e.value===t.value)return r(e.value||"",e.value||"",!1);const s=(t.options||[]).find(e=>e.default);s?r(t.value||"",s.value,!0):r(t.value||"",e.value||"",!1)}}:null}function Et(e){const t=Dt(e,""),r=It(t,t);return r?[r]:[]}function Tt({selected:e,title:t,options:r,showBadges:s,onChange:n,disabled:a}){let l;if(l=function(e){return Array.isArray(e)?-1!==e.indexOf(""):Boolean(e?.[""])}(e)&&r.length>0?Et(r):Array.isArray(e)?function(e,t){return-1!==e.indexOf("")?Et(t):e.map(e=>{const r=Dt(t,e);return It(r,r)}).filter(e=>null!==e)}(e,r):function(e,t){return Object.keys(e).map(r=>{const s=Dt(t,r);return"string"==typeof e[r]?It(Dt(t,e[r]),s):e[r]?It(s,s):null}).filter(e=>null!==e).filter(e=>e&&!0!==e.default)}(e,r),l.length>0&&s){const e=l.slice(0,3).map((e,t)=>e?(0,_.jsx)(Ft,{small:!0,onCancel:t=>function(e,t){e.preventDefault(),e.stopPropagation(),t.onRemove(n)}(t,e),disabled:a,children:e.title},t):null);return l.length>3?e.concat([(0,_.jsx)("span",{children:"..."},"end")]):e}return t.length>0&&(!s||0===l.length)?(0,_.jsx)("h5",{children:t}):null}const Mt=function({onClick:e}){return(0,_.jsx)("svg",{height:"20",width:"20",viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",onClick:e,children:(0,_.jsx)("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"})})},Yt=function(e){const{options:t,selected:r,onChange:s,title:n="",badges:a=!1,compact:l=!1,disabled:c=!1,className:o,asObject:i=!1}=e,u=(0,S.A)(o,l&&"wpl-multioption__compact");function d(e,t){if(i){const s=r;return e===t?Boolean(s[t]):s[e]===t}return-1!==r.indexOf(t)}function h(e,t,n){if(i)s({...r,[e]:e===t?n:t});else{const a=r,l=e===t?e:t;s(n?[...a,l]:a.filter(e=>e!==l))}}return(0,_.jsx)(Rt,{className:u,renderToggle:(e,s)=>(0,_.jsxs)("div",{className:(0,S.A)("action","wpl-multioption__button",c&&"wpl-multioption__disabled",e?"wpl-multioption__button_enabled":null),onClick:s,tabIndex:0,"aria-label":n||"",children:[(0,_.jsx)(Tt,{selected:r,title:n,showBadges:a,options:t,disabled:c,onChange:h}),(0,_.jsx)(Mt,{})]}),disabled:c,align:"right",matchMinimum:!0,renderContent:()=>(0,_.jsx)("div",{className:(0,S.A)("wpl-multioption",u),children:t.map((e,t)=>(0,_.jsx)(Ot,{option:e,isSelected:d,onChange:h},t))})})},Lt=function(e){const{isPrimary:t=!1,isSecondary:r=!0,isSubmit:s=!1,isSaving:n=!1,className:a,children:l,disabled:c=!1,isDestructive:o=!1,...i}=e,u=(0,S.A)("button",a,{"button-primary":t,"button-secondary":r,"button-delete":o,"wpl-spinner":n});return(0,_.jsxs)("button",{className:u,disabled:c,type:s?"submit":"button",...i,children:[n&&(0,_.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,_.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"})}),l]})},Vt=function(e){const{disabled:t,replacement:r,setReplace:s,placeholder:a}=e,[l,o]=(0,n.useState)("single");let i;i="remove"===l?(0,c.__)("Matched values will be removed","search-regex"):"string"==typeof a?a:(0,c.__)("Enter replacement value","search-regex");const u={id:"replace",value:r??"",disabled:t||"remove"===l,placeholder:i,name:"replace",onChange:e=>{s({replacement:e.target.value})}};return(0,n.useEffect)(()=>{"remove"===l&&null!==r?s({replacement:null}):"remove"!==l&&null===r&&s({replacement:""})},[l]),(0,_.jsxs)(_.Fragment,{children:[-1===l.indexOf("multi")?(0,_.jsx)("input",{type:"text",...u}):(0,_.jsx)("textarea",{...u}),(0,_.jsx)(j,{disabled:t,items:[{value:"",label:(0,c.__)("Single","search-regex")},{value:"multi",label:(0,c.__)("Multi","search-regex")},{value:"remove",label:(0,c.__)("Remove","search-regex")}],value:l,name:"search-flags",onChange:e=>o(e.target.value)})]})};function $t(e,t){return e&&-1!==e.indexOf(t)}function Ut(e,t){if(t)for(let r=0;r<e.length;r++){const s=e[r];if(s&&-1!==t.indexOf(s.name))return!0}return!1}function qt(e,t){return void 0!==t?.value&&Ut(e,t.value)}function Bt(e,t){return void 0!==t.searchValue&&(Ut(e,t.searchValue)||void 0!==t.replaceValue&&Ut(e,t.replaceValue))}function Kt(e){const t=function(e){let t=0;for(let r=0;r<e.length;r++){const s=e[r];s&&(t=Math.max(t,s.title.length))}return t}(e);return{"searchregex-search__tag__short":t<12,"searchregex-search__tag__medium":t>=12&&t<30,"searchregex-search__tag__long":t>=30}}function Gt(e,t){return t.reduce((e,t)=>e.replace(t.name,t.value),e)}function Wt(e){if(!e)return null;const t=e.tags.map(e=>({name:e.name,value:""}));return{...e.search,searchPhrase:Gt(e.search.searchPhrase??"",t),replacement:Gt(e.search.replacement??"",t)}}const Ht=()=>[{value:"regex",label:(0,c.__)("Regular Expression","search-regex"),alt:(0,c.__)("Regex","search-regex")},{value:"case",label:(0,c.__)("Ignore Case","search-regex"),alt:(0,c.__)("Case","search-regex")},{value:"multi",label:(0,c.__)("Multiline","search-regex"),alt:(0,c.__)("Multi","search-regex")}],Jt=()=>[{value:25,label:(0,c.__)("25 per page","search-regex")},{value:50,label:(0,c.__)("50 per page","search-regex")},{value:100,label:(0,c.__)("100 per page","search-regex")},{value:250,label:(0,c.__)("250 per page","search-regex")},{value:500,label:(0,c.__)("500 per page","search-regex")},{value:1e3,label:(0,c.__)("1000 per page","search-regex")},{value:2e3,label:(0,c.__)("2000 per page","search-regex")}];function zt(e){const{searchFlags:t,searchPhrase:r,filters:s}=e;if(t&&r&&-1!==t.indexOf("regex")&&r.length>0)return!0;if(!s)return!1;for(let e=0;e<s.length;e++){const t=s[e];if(t&&t.items)for(let e=0;e<t.items.length;e++){const r=t.items[e];if(r&&r.flags&&-1!==r.flags.indexOf("regex"))return!0}}return!1}function Qt(){return{searchPhrase:"",searchFlags:["case"],replacement:"",source:["posts"],perPage:25,filters:Xt("posts"),action:"replace",actionOption:[],view:[]}}function Xt(e){return"posts"===e?[{type:"posts",items:[{column:"post_type",logic:"include",values:["post","page"]}]}]:"comment"===e?[{type:"comment",items:[{column:"comment_approved",logic:"exclude",values:["spam"]}]}]:[]}function Zt(e=null){const t=e||d(),r={};for(const e in t){const s=e.toLowerCase();let n=t[e];Array.isArray(n)&&(n=n.join(",")),r[s]=n,"searchPhrase"!==e||r.searchphrase||(r.searchphrase=Array.isArray(t[e])?t[e].join(","):t[e]),"searchFlags"!==e||r.searchflags||(r.searchflags=Array.isArray(t[e])?t[e].join(","):t[e]),"perPage"!==e||r.perpage||(r.perpage=Array.isArray(t[e])?t[e].join(","):t[e])}const s=Oe.safeParse(r);if(!s.success)return{};const n=s.data,a={};return n.searchphrase&&(a.searchPhrase=n.searchphrase),void 0!==n.searchflags&&(a.searchFlags=n.searchflags),void 0!==n.source&&n.source.length>0&&(a.source=n.source),n.replacement&&(a.replacement=n.replacement),void 0!==n.perpage&&(a.perPage=n.perpage),void 0!==n.filters&&(a.filters=n.filters),void 0!==n.view&&(a.view=n.view),n.mode&&(a.mode=n.mode),a}function er(e,t){return e.find(e=>e.type===t)}function tr(e,t){return e.find(e=>e.column===t)}function rr(e){return e?{...e.search,...Wt(e)}:Qt()}function sr(e,t){const r=t.columns[0];return r?{type:e,items:[{column:r.column??""}]}:{type:e,items:[{column:""}]}}function nr(e,t,r){for(let r=0;r<e.length;r++){const s=e[r];if(s&&s.value===t)return s.label}return r||t}function ar(e,t){return e.map(e=>({label:t.find(t=>t.type===e)?.name||"",value:e}))}function lr(e,t,r){const s=function(e,t){return t&&"member"===t.type?{values:e.contexts.filter(e=>"empty"!==e.type).map(e=>e.replacement_value?e.replacement_value:e.value)}:{}}(e,t);return{column:t?.column||"",operation:"",source:r,...s}}function cr(e,t,r){return t.find(t=>t.value===e||t.name===e)?e:r}function or(e,t,r){return e.filter(e=>{const s=er(t,e.type);return!(!s||-1===r.indexOf(s.type))&&(e.items.filter(e=>void 0!==s.columns.find(t=>t.column===e.column)).length=e.items.length)})}function ir(e,t){return Array.isArray(e)?e.filter(e=>{const r=e.split("__");if(2===r.length){const e=er(t,r[0]);if(e)return void 0!==e.columns.find(e=>e.column===r[1])}return!1}):[]}const ur=function(e){const{value:t,onChange:r,disabled:s=!1,multiline:n=!1,className:a,placeholder:l,multilinePlaceholder:o}=e;return n?(0,_.jsx)(C.A,{value:t,name:"searchPhrase",cols:120,minRows:2,maxRows:5,onChange:e=>r(e.target.value),disabled:s,className:a,placeholder:o??(0,c.__)("Enter search phrase","search-regex")}):(0,_.jsx)("input",{value:t,type:"text",name:"searchPhrase",disabled:s,onChange:e=>r(e.target.value),className:a,placeholder:l??(0,c.__)("Optional global search phrase. Leave blank to use filters only.","search-regex")})};function dr(){return[{value:"equals",label:(0,c.__)("Equals","search-regex")},{value:"notequals",label:(0,c.__)("Not Equals","search-regex")},{value:"greater",label:(0,c.__)("Greater","search-regex")},{value:"less",label:(0,c.__)("Less","search-regex")},{value:"range",label:(0,c.__)("Range","search-regex")}]}function hr(){return[{value:"equals",label:(0,c.__)("Equals","search-regex")},{value:"notequals",label:(0,c.__)("Not Equals","search-regex")},{value:"contains",label:(0,c.__)("Contains","search-regex")},{value:"notcontains",label:(0,c.__)("Not contains","search-regex")},{value:"begins",label:(0,c.__)("Begins","search-regex")},{value:"ends",label:(0,c.__)("End","search-regex")}]}function pr(e){return"member"===e?[{value:"include",label:(0,c.__)("Includes any","search-regex")},{value:"exclude",label:(0,c.__)("Excludes any","search-regex")}]:"string"===e?hr():"keyvalue"===e?[{value:"any",label:(0,c.__)("Any","search-regex")},...hr()]:"integer-join"===e?[...dr(),{value:"has",label:(0,c.__)("Has Owner","search-regex")},{value:"hasnot",label:(0,c.__)("No Owner","search-regex")}]:dr()}function gr({value:e,disabled:t,onChange:r,type:s}){return(0,_.jsx)(j,{name:"logic",items:pr(s),disabled:t,value:e,onChange:e=>r(e.target.value)})}var xr=r(814);const mr=function(){return(0,_.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:[(0,_.jsx)("circle",{transform:"translate(8 0)",cx:"0",cy:"16",r:"0",children:(0,_.jsx)("animate",{attributeName:"r",values:"0; 4; 0; 0",dur:"1.2s",repeatCount:"indefinite",begin:"0",keyTimes:"0;0.2;0.7;1",keySplines:"0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8",calcMode:"spline"})}),(0,_.jsx)("circle",{transform:"translate(16 0)",cx:"0",cy:"16",r:"0",children:(0,_.jsx)("animate",{attributeName:"r",values:"0; 4; 0; 0",dur:"1.2s",repeatCount:"indefinite",begin:"0.3",keyTimes:"0;0.2;0.7;1",keySplines:"0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8",calcMode:"spline"})}),(0,_.jsx)("circle",{transform:"translate(24 0)",cx:"0",cy:"16",r:"0",children:(0,_.jsx)("animate",{attributeName:"r",values:"0; 4; 0; 0",dur:"1.2s",repeatCount:"indefinite",begin:"0.6",keyTimes:"0;0.2;0.7;1",keySplines:"0.2 0.2 0.4 0.8;0.2 0.6 0.4 0.8;0.2 0.6 0.4 0.8",calcMode:"spline"})})]})};var _r=r(465),fr=r.n(_r);const vr=function({options:e,value:t,onSelect:r,onClose:s}){return(0,_.jsx)("ul",{children:e.map((e,n)=>(0,_.jsx)("li",{children:(0,_.jsx)("button",{type:"button",onClick:t=>function(e,t){e.preventDefault(),r(t),s()}(t,e),onKeyDown:t=>function(e,t){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r(t),s())}(t,e),children:(0,_.jsx)(fr(),{searchWords:[t],textToHighlight:e.title,autoEscape:!0})})},n))})},jr=function(e){const{placeholder:t="",onChange:r,value:s,fetchData:a,name:l="text",disabled:c=!1,className:o,maxChoices:i=-1,maxLength:u=0,canMakeRequest:d=e=>e.length>0,onBlur:h,getLabel:p,setLabel:g=()=>{},loadOnFocus:x=!1,onlyChoices:m=!1}=e,[f,v]=(0,n.useState)(!1),[j,b]=(0,n.useState)([]),[y,w]=(0,n.useState)(Array.isArray(s)?"":s),C=(0,n.useRef)(null),k={"wpl-dropdowntext__suggestion__hide":i>0&&Array.isArray(s)&&s.length>=i,"wpl-dropdowntext__suggestion":i>1},N=(0,xr.YQ)(R,450);function R(e){a&&(v(!0),a(e).then(e=>{C.current&&C.current.ownerDocument.activeElement===C.current&&b(e),v(!1)}).catch(()=>{b([]),v(!1)}))}function P(e){if(p)return O(e).map(t=>p(t,e))}function A(e){if(i>0){if(!O(s).find(t=>t===`${e.value}`)){const t=[`${e.value}`].concat(O(s).filter(t=>t!==`${e.value}`)).slice(0,i);r(1!==i||m?t:t[0],[e.title].concat(P(t)?.slice(1)||[])),g(e.value,e.title)}w("")}else w(e.value),r(e.value,P(s));b([])}function O(e){return Array.isArray(e)?e:e?[e]:[]}return(0,n.useEffect)(()=>{s!==y&&w(Array.isArray(s)?"":s)},[s,y]),(0,_.jsxs)("div",{className:(0,S.A)("wpl-dropdowntext",o,k),children:[i>0&&O(s).map(e=>(0,_.jsx)(Ft,{title:e,onCancel:()=>function(e){const t=O(s).filter(t=>t!==e);g(e,null),Array.isArray(s)?r(1===i?t[0]:t,P(t)):r(""),C.current?.focus()}(e),disabled:c,children:p?p(e,s):e},e)),(0,_.jsx)("input",{type:"text",className:(0,S.A)("regular-text",{"wpl-dropdowntext__max":i>=0&&O(s).length>=i}),name:l,value:y,disabled:c,onChange:function(e){w(e.target.value),i<1&&r(e.target.value),a&&N&&(d(e.target.value.trim())?N(e.target.value):b([]))},maxLength:u>0?u:void 0,placeholder:t,ref:C,onFocus:function(){const e=(Array.isArray(s),s.length>0);x&&!e&&R("")},onBlur:function(e){if(e.relatedTarget&&e.relatedTarget.closest(".wpl-dropdowntext__suggestions"))return;const t=`${(h?h(y):y)??""}`;0===j.length?m?w(""):i>0&&a?A({value:t,label:t,title:t}):r(t):t!==y&&w(t),v(!1)},onKeyDown:function(e){"Enter"===e.code&&(v(!1),b([]))}}),f&&(0,_.jsx)("div",{className:"wpl-dropdowntext__loading",children:(0,_.jsx)(mr,{})}),j.length>0&&C.current&&(0,_.jsx)(Nt,{align:"left",onClose:()=>b([]),popoverPosition:kt(C.current),className:"wpl-dropdowntext__suggestions",focusLock:!1,children:(0,_.jsx)(vr,{options:j,value:y,onSelect:A,onClose:()=>b([])})})]})},br="STATUS_IN_PROGRESS",yr="STATUS_FAILED",wr="STATUS_COMPLETE",Sr="forward";function Cr(e){return e.map(e=>({...e,row_id:String(e.row_id)}))}function kr(e){const t={matched_rows:e.matched_rows,rows:e.rows};return void 0!==e.custom&&(t.custom=e.custom),t}function Nr(e){const t="current"in e&&void 0!==e.current,r="rows"in e&&void 0!==e.rows,s="previous"in e&&void 0!==e.previous,n={next:e.next};return t&&(n.current=e.current),r&&(n.rows=e.rows),s&&void 0!==e.previous&&(n.previous=e.previous),n}function Rr(e,t,r){const s=d(),n=Qt(),a=SearchRegexi10n.settings;let l=a?.startupMode,c=a?.startupPreset;if(!l&&a&&void 0!==a.defaultPreset){const e=a.defaultPreset;e&&(l="preset",c=String(e))}return function(e,t=null,r=null){const s=t||ie("sources",[]),n=r||ie("schema",[]),a=Ae.safeParse(e),l=a.success?a.data:e,{searchPhrase:c,searchFlags:o,replacement:i,perPage:u,view:d,action:h,actionOption:p}=l,g=function(e,t){let r=[];return e.forEach(e=>{r=[...r,...e.sources.map(e=>e.name)]}),t.filter(e=>-1!==r.indexOf(e))}(s,l.source&&l.source.length>0?l.source:[]);let x;if("number"==typeof u)x=cr(u,Jt(),25);else if("string"==typeof u){const e=parseInt(u,10);x=cr(isNaN(e)?25:e,Jt(),25)}else x=25;return{searchPhrase:c,searchFlags:(m=o??[],_=Ht(),m.filter(e=>cr(e,_,""))),source:g,replacement:i,perPage:x,filters:or(l.filters??[],n,g),view:ir(d,n),action:h,actionOption:p};var m,_}({...n,...rr(e.find(e=>e.id===s.preset||"preset"===l&&c&&e.id===c)),...Zt()},t,r)}function Pr(){const e=SearchRegexi10n.settings,t=e?.startupMode,r=Zt();return r.mode?r.mode:"simple"===t?"simple":"advanced"}const Ar=(0,W.v)()((e,t)=>{const r=ie("sources",[]),s=ie("schema",[]);return{search:Rr([],r,s),mode:Pr(),results:[],status:null,isSaving:!1,canCancel:!1,isBusy:!1,totals:{matched_rows:0,rows:0},progress:{next:!1},replaceAll:!1,replacing:[],exportData:[],searchDirection:null,showLoading:!1,resultsDirty:!1,cumulativeMatchedRows:0,sources:r,schema:s,labels:ie("labels",[]),setSearch:t=>e(e=>{const r=null!==e.status&&Object.keys(t).length>0;return{search:{...e.search,...t},resultsDirty:!!r||e.resultsDirty}}),setResults:t=>e({results:t}),setStatus:t=>e(e=>({status:t,isBusy:t===br||e.replaceAll})),setIsSaving:t=>e({isSaving:t}),setMode:t=>e({mode:t}),setCanCancel:t=>e({canCancel:t}),setTotals:t=>e({totals:t}),setProgress:t=>e({progress:t}),setCumulativeMatchedRows:t=>e({cumulativeMatchedRows:t}),addToCumulativeMatchedRows:t=>e(e=>({cumulativeMatchedRows:e.cumulativeMatchedRows+t})),setReplaceAll:t=>e(e=>({replaceAll:t,isBusy:e.status===br||t})),setReplacing:t=>e({replacing:t}),appendExportData:t=>e(e=>({exportData:[...e.exportData,...t]})),clearExportData:()=>e({exportData:[]}),setSearchDirection:t=>e({searchDirection:t}),setShowLoading:t=>e({showLoading:t}),setResultsDirty:t=>e({resultsDirty:t}),setLabels:t=>e({labels:t}),clearResults:()=>e({results:[],status:null,totals:{matched_rows:0,rows:0},progress:{next:!1},replacing:[],exportData:[],resultsDirty:!1,cumulativeMatchedRows:0}),updateSearchUrl:()=>{const e=d();if(e.preset)return void u({page:"search-regex.php",preset:e.preset},{});const{search:r,mode:s}=t(),n=Qt(),a=SearchRegexi10n.settings,l="simple"===a?.startupMode?"simple":"advanced",c={searchPhrase:n.searchPhrase,searchFlags:n.searchFlags,source:n.source,perPage:n.perPage,sub:"search",filters:n.filters,view:n.view,mode:l};u({page:"search-regex.php",searchPhrase:r.searchPhrase,searchFlags:r.searchFlags,source:r.source,perPage:r.perPage,filters:r.filters&&r.filters.length>0?r.filters:null,view:r.view?r.view:[],mode:s},c)},initialize:(r=[])=>{const s=t(),n=Rr(r,s.sources,s.schema);e({search:n})}}}),Or=function({value:e,name:t,onChange:r,disabled:s,remote:n,column:a}){const l=Ar(e=>e.labels),c=Ar(e=>e.setLabels),o=null==e?"":String(e),i={name:t,className:"searchregex-integer-input",value:o,onBlur:function(e){const t=String(e).replace(/[^0-9]/g,"").trim();return t.length>0?String(parseInt(t,10)):""},onChange:e=>{const s=Array.isArray(e)?e[0]:e;void 0!==s&&r({[t]:s})},canMakeRequest:e=>e.length>0&&e.replace(/[0-9]/g,"").length>0,maxChoices:n?1:-1,onlyChoices:!!n,setLabel:(e,t)=>{const r=l.findIndex(t=>t.value===a+"_"+e);if(r>=0){const s=[...l];s[r]={value:a+"_"+e,label:t||""},c(s)}else c([...l,{value:a+"_"+e,label:t||""}])},getLabel:(e,t)=>{const r=Array.isArray(t)?t[0]:t;return nr(l,a+"_"+e,r)},...void 0!==s?{disabled:s}:{},...n?{fetchData:e=>fetch(n+"?search="+encodeURIComponent(e)).then(e=>e.json())}:{}};return(0,_.jsx)(jr,{...i})};function Fr({disabled:e,item:t,onChange:r,schema:s,fetchData:n}){const{logic:a="equals",startValue:l="",endValue:o=""}=t,i="api"===s.options&&n,u="equals"===a||"notequals"===a?1:-1;return"has"===a||"hasnot"===a?(0,_.jsx)(gr,{type:"integer-join",value:a,disabled:e,onChange:e=>r({logic:e,startValue:"",endValue:""})}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(gr,{type:s.joined_by?"integer-join":"integer",value:a,disabled:e,onChange:e=>r({logic:e,startValue:"",endValue:""})}),"range"!==a&&(0,_.jsx)(Or,{name:"startValue",column:t.column,value:l,onChange:r,disabled:e,...u&&!1!==i&&{remote:i}}),"range"===a&&I((0,c.__)("between {{first/}} and {{second/}}","search-regex"),{first:(0,_.jsx)(Or,{name:"startValue",value:l,onChange:r,disabled:e,column:t.column}),second:(0,_.jsx)(Or,{name:"endValue",value:o,onChange:r,disabled:e,column:t.column})})]})}var Dr=r(546),Ir=r(431);function Er({selected:e,onChange:t,disabled:r=!1,showTimeSelect:s=!1,dateFormat:a,selectsStart:l,selectsEnd:o,startDate:i,endDate:u,minDate:d,maxDate:h,withPortal:p=!1,placeholderText:g}){const[x,m]=(0,n.useState)(!1),[f,v]=(0,n.useState)({hours:0,minutes:0}),j=(0,n.useRef)(null),b=(0,n.useRef)(null);(0,n.useEffect)(()=>{e&&s&&v({hours:e.getHours(),minutes:e.getMinutes()})},[e,s]);const y=(r,s)=>{const n={...f,[r]:s};if(v(n),e){const r=new Date(e);r.setHours(n.hours),r.setMinutes(n.minutes),r.setSeconds(0),r.setMilliseconds(0),t(r)}},w={};d&&(w.fromDate=d),h&&(w.toDate=h),o&&i&&(w.fromDate=i),l&&u&&(w.toDate=u);const S=(0,_.jsx)(Dr.hv,{mode:"single",selected:e||void 0,onSelect:e=>{if(e)if(s){const r=new Date(e);r.setHours(f.hours),r.setMinutes(f.minutes),r.setSeconds(0),r.setMilliseconds(0),t(r)}else t(e);else t(null)},disabled:r,...w}),C=s?(0,_.jsx)("div",{className:"wpl-datepicker-time",children:(0,_.jsxs)("label",{htmlFor:"wpl-datepicker-time-input",children:[(0,c.__)("Time","search-regex"),(0,_.jsx)("input",{id:"wpl-datepicker-time-input",type:"time",value:`${String(f.hours).padStart(2,"0")}:${String(f.minutes).padStart(2,"0")}`,onChange:e=>{const[t,r]=e.target.value.split(":").map(Number);y("hours",t||0),y("minutes",r||0)},disabled:r})]})}):null;(0,n.useEffect)(()=>{function e(e){j.current&&!j.current.contains(e.target)&&m(!1)}if(x)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[x]);const k=(0,_.jsxs)("div",{className:"wpl-datepicker-popup",ref:j,children:[S,C]});return(0,_.jsxs)("div",{className:"wpl-datepicker-wrapper",children:[(0,_.jsx)("input",{ref:b,type:"text",value:(e=>{if(!e)return g||"";if(a){const t=["January","February","March","April","May","June","July","August","September","October","November","December"][e.getMonth()],r=t?t.substring(0,3):"";let s=a;s=s.replace(/MMMM/g,t||""),s=s.replace(/MMM/g,r),s=s.replace(/MM/g,String(e.getMonth()+1).padStart(2,"0")),s=s.replace(/M/g,String(e.getMonth()+1));const n=e.toLocaleDateString("en-US",{weekday:"long"}),l=e.toLocaleDateString("en-US",{weekday:"short"});return s=s.replace(/dddd/g,n),s=s.replace(/ddd/g,l),s=s.replace(/dd/g,String(e.getDate()).padStart(2,"0")),s=s.replace(/d/g,String(e.getDate())),s=s.replace(/yyyy/g,String(e.getFullYear())),s=s.replace(/yy/g,String(e.getFullYear()).slice(-2)),s=s.replace(/hh/g,String(e.getHours()).padStart(2,"0")),s=s.replace(/h/g,String(e.getHours())),s=s.replace(/mm/g,String(e.getMinutes()).padStart(2,"0")),s=s.replace(/m/g,String(e.getMinutes())),s=s.replace(/ss/g,String(e.getSeconds()).padStart(2,"0")),s=s.replace(/s/g,String(e.getSeconds())),s}return e.toLocaleDateString()+(s?" "+e.toLocaleTimeString():"")})(e??null),onClick:()=>!r&&m(!x),onFocus:()=>!r&&m(!0),readOnly:!0,disabled:r,placeholder:g,className:"wpl-datepicker-input"}),x&&(p?(0,_.jsx)(Ir.ZL,{children:k}):k)]})}function Tr(e){if(null==e)return null;if("string"==typeof e){const t=new Date(e);return isNaN(t.getTime())?null:t}return new Date(e)}function Mr({disabled:e,item:t,onChange:r}){const{logic:s="=",startValue:n,endValue:a}=t,l=Tr(n),o=Tr(a);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(gr,{type:"integer",value:s,disabled:e,onChange:e=>r({logic:e})}),"range"!==s&&(0,_.jsx)(Er,{disabled:e,selected:l,onChange:e=>{e&&r({startValue:e.toISOString()})},showTimeSelect:!0,dateFormat:"MMMM d, yyyy hh:mm"}),"range"===s&&I((0,c.__)("between {{first/}} and {{second/}}","search-regex"),{first:(0,_.jsx)(Er,{selected:l,onChange:e=>{e&&r({startValue:e.toISOString()})},selectsStart:!0,startDate:l,endDate:o,showTimeSelect:!0,dateFormat:"MMMM d, yyyy hh:mm"}),second:(0,_.jsx)(Er,{selected:o,onChange:e=>{e&&r({endValue:e.toISOString()})},selectsEnd:!0,startDate:l,endDate:o,...null!==l&&{minDate:l},showTimeSelect:!0,dateFormat:"MMMM d, yyyy hh:mm"})})]})}const Yr=function(e){const{flags:t,onChange:r,disabled:s,allowRegex:n=!0,allowMultiline:a=!1,allowCase:l=!0}=e,o=Ht().filter(e=>"regex"!==e.value||n).filter(e=>"case"!==e.value||l).filter(e=>"multi"!==e.value||a).map(e=>({...e,badge:e.alt}));return(0,_.jsx)(Yt,{options:o,selected:t,onChange:e=>{const t=Array.isArray(e)?e:[];r(t)},title:(0,c.__)("Flags","search-regex"),...void 0!==s?{disabled:s}:{},multiple:!0,badges:!0})};function Lr({disabled:e,item:t,onChange:r,schema:s,fetchData:n}){const{logic:a="equals",value:l="",flags:c=["case"]}=t,o="api"===s.options&&-1===c.indexOf("regex")&&n;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(gr,{type:"string",value:a,disabled:e,onChange:e=>r({logic:e,flags:["case"]})}),-1===c.indexOf("multi")?(0,_.jsx)(jr,{value:l,disabled:e,onChange:e=>r({value:e}),...!1!==o&&{fetchData:o}}):(0,_.jsx)("textarea",{value:l,disabled:e,onChange:e=>r({value:e.target.value})}),(0,_.jsx)(Yr,{flags:c,disabled:e,onChange:e=>r({flags:e}),allowRegex:"equals"===a||"notcontains"===a,allowMultiline:s.multiline||!1})]})}function Vr(e,t,r){return""===t?-1===e.indexOf("")?[]:r:e.filter(e=>""!==e)}function $r(e,t){return e.length===t?["",...e]:e}function Ur(e){return[{value:"",label:(0,c.__)("All","search-regex")},...e]}function qr({disabled:e,item:t,onChange:r,schema:s,fetchData:n}){const{logic:a="include",values:l=[],flags:c=["case"]}=t,o="api"===s.options&&n,i=Ar(e=>e.labels),u=Ar(e=>e.setLabels),d=(0,_.jsx)(gr,{type:"member",value:a,disabled:e,onChange:e=>r({logic:e,values:[]})});if("contains"===a||"notcontains"===a)return(0,_.jsxs)(_.Fragment,{children:[d,(0,_.jsx)(jr,{value:l[0]??"",disabled:e,onChange:e=>r({values:[e]})}),(0,_.jsx)(Yr,{flags:c,disabled:e,onChange:e=>r({flags:e}),allowRegex:!1,allowMultiline:!1})]});if(o)return(0,_.jsxs)(_.Fragment,{children:[d,(0,_.jsx)(jr,{value:l,disabled:e,onChange:e=>r({values:e}),fetchData:o,...void 0!==s.preload&&{loadOnFocus:s.preload},maxChoices:20,onlyChoices:!0,setLabel:(e,t)=>{const r=i.findIndex(t=>t.value===s.column+"_"+e);if(r>=0){const n=[...i];n[r]={value:s.column+"_"+e,label:t||""},u(n)}else u([...i,{value:s.column+"_"+e,label:t||""}])},getLabel:e=>nr(i,s.column+"_"+e)})]});const h=Array.isArray(s.options)?s.options:[];return(0,_.jsxs)(_.Fragment,{children:[d,!o&&(0,_.jsx)(Yt,{options:Ur(h),selected:$r(l,h.length),onChange:e=>{const t=Array.isArray(e)?e:[],s=function(e,t){const r=t.find(t=>-1===e.indexOf(t));return void 0!==r?r:e.find(e=>-1===t.indexOf(e))||""}($r(l,h.length),t),n=h.map(e=>e.value);r({values:Vr(t,s,n)})},multiple:s.multiple??!0,disabled:e,hideTitle:!0,...void 0!==s.title&&{title:s.title},badges:!0})]})}function Br({disabled:e,item:t,onChange:r,schema:s,fetchData:n}){const{key:a="",keyLogic:l="equals",keyFlags:o=["case"],value:i="",valueLogic:u="any",valueFlags:d=["case"]}=t,h="api"===s.options?e=>n(e):void 0;return(0,_.jsxs)("div",{className:"searchregex-filter__keyvalue",children:[(0,_.jsxs)("div",{className:"searchregex-filter__keyvalue__item",children:[(0,_.jsx)("span",{children:(0,c.__)("Meta Key","search-regex")}),(0,_.jsx)(gr,{type:"keyvalue",value:l,disabled:e,onChange:e=>r({keyLogic:e,key:"any"===e?"":a})}),(0,_.jsx)(jr,{value:a,disabled:e||"any"===l,onChange:e=>r({key:Array.isArray(e)?e[0]??"":e}),...void 0!==h&&{fetchData:h},...void 0!==s.preload&&{loadOnFocus:s.preload}}),(0,_.jsx)(Yr,{flags:o,disabled:e||"any"===l,onChange:e=>r({keyFlags:e}),allowRegex:!1,allowMultiline:!1})]}),(0,_.jsxs)("div",{className:"searchregex-filter__keyvalue__item",children:[(0,_.jsx)("span",{children:(0,c.__)("Meta Value","search-regex")}),(0,_.jsx)(gr,{type:"keyvalue",value:u,disabled:e,onChange:e=>r({valueLogic:e,value:"any"===e?"":i})}),-1===d.indexOf("multi")?(0,_.jsx)(jr,{value:i,disabled:e||"any"===u,onChange:e=>r({value:Array.isArray(e)?e[0]??"":e})}):(0,_.jsx)("textarea",{value:i,disabled:e||"any"===u,onChange:e=>r({value:e.target.value})}),(0,_.jsx)(Yr,{flags:d,disabled:e||"any"===u,onChange:e=>r({valueFlags:e}),allowRegex:!1,allowMultiline:!0})]})]})}const Kr=function(e){const{type:t}=e.schema;return"integer"===t?(0,_.jsx)(Fr,{...e}):"date"===t?(0,_.jsx)(Mr,{...e}):"string"===t?(0,_.jsx)(Lr,{...e}):"member"===t?(0,_.jsx)(qr,{...e}):"keyvalue"===t?(0,_.jsx)(Br,{...e}):null};function Gr(e){return e.filter(e=>e.column&&e.title).map(e=>({label:e.title,value:e.column}))}function Wr({item:e,columns:t,disabled:r,onChange:s,schema:n,fetchData:a,onRemove:l}){return n?(0,_.jsxs)("div",{className:(0,S.A)("searchregex-filter__item",`searchregex-filter__type__${n.type}`),children:[(0,_.jsx)(j,{name:"filter_type",items:Gr(t),value:e.column,disabled:r,onChange:e=>{return t=e.target.value,void s({column:t});var t}}),(0,_.jsx)("button",{type:"button","aria-label":(0,c.__)("Remove filter","search-regex"),onClick:l,disabled:r,className:(0,S.A)("dashicons","dashicons-trash",r&&"dashicons__disabled")}),(0,_.jsx)(Kr,{schema:n,item:e,disabled:r,fetchData:a,onChange:t=>s({...e,...t})})]}):null}const Hr=function({schema:e,items:t,disabled:r,onChange:s,onRemove:a,source:l}){return e?(0,_.jsxs)("div",{className:"searchregex-filter__column",children:[(0,_.jsxs)("div",{className:"searchregex-filter__name",children:[(0,_.jsx)("span",{children:e.name}),(0,_.jsx)("button",{type:"button","aria-label":(0,c.__)("Remove filter group","search-regex"),onClick:a,disabled:r,className:(0,S.A)("dashicons","dashicons-trash",r&&"dashicons__disabled")})]}),(0,_.jsx)("div",{className:(0,S.A)("searchregex-filter__content",t.length>1&&"searchregex-filter__content__multiple"),children:t.map((o,i)=>(0,_.jsxs)(n.Fragment,{children:[(0,_.jsx)(Wr,{item:o,schema:e.columns.find(e=>o.column===e.column),columns:e.columns,disabled:r,fetchData:e=>function(e,t){return ae(Ze(l,e,t))}(o.column,e),onChange:e=>{const r=1===Object.keys(e).length&&"column"in e?e:{...o,...e};s([...t.slice(0,i),r,...t.slice(i+1)])},onRemove:()=>{return e=i,void(1===t.length?a():s([...t.slice(0,e),...t.slice(e+1)]));var e}}),i!==t.length-1&&(0,_.jsx)(Ft,{disabled:r,children:(0,c.__)("OR","search-regex")})]},`${e.name}-${o.column}-${i}`))}),(0,_.jsx)("div",{className:"searchregex-filter__action",children:(0,_.jsx)(Lt,{disabled:r||10===t.length,onClick:function(){const e=t[t.length-1];e&&s([...t,{column:e.column}])},children:(0,c.__)("Add sub-filter (OR)","search-regex")})})]}):null};function Jr(e){return"string"==typeof e.type}const zr=function({filters:e,disabled:t,onSetSearch:r,tags:s,presetFilters:n}){const l=Ar(e=>e.schema);function o(e){const t=e.filter(Jr);r({filters:t})}function i(t,r){if(t===e.length-1)return!1;const s=e[t+1];return!!s&&s.type===r}return 0===e.length?null:(0,_.jsxs)("tr",{children:[(0,_.jsx)("th",{children:(0,c.__)("Filters","search-regex")}),(0,_.jsx)("td",{children:(0,_.jsx)("div",{className:"searchregex-filters",children:e.map(({type:r,items:u},d)=>{const h=n.find(e=>e.type===r),p=u.filter((e,t)=>{if(h){const e=h.items[t];return!e||!qt(s,e)}return!0});if(0===p.length)return null;const g=er(l,r);return g?(0,_.jsxs)(a().Fragment,{children:[(0,_.jsx)(Hr,{schema:g,items:p,disabled:t,source:r,onChange:t=>{const r=e[d];r&&o([...e.slice(0,d),{type:r.type,items:t},...e.slice(d+1)])},onRemove:()=>o([...e.slice(0,d),...e.slice(d+1)])}),i(d,r)?(0,_.jsx)(Ft,{disabled:t,children:(0,c.__)("AND","search-regex")}):(0,_.jsx)("div",{className:"searchregex-filters__break"})]},r+"_"+d):null})})})]})};function Qr(e){return e.map(e=>({label:e.label,value:e.name,options:e.sources.map(({label:e,name:t})=>({label:e,value:t}))}))}const Xr=function(e){const{disabled:t,columns:r,source:s,onSetSearch:a}=e,l=er(Ar(e=>e.schema),s),o=(0,n.useMemo)(()=>{return l?(e=r,l.columns.filter(e=>e.column&&e.title).filter(e=>void 0===e.modify||e.modify).filter(t=>(void 0===e.find(e=>e.column===t.column)||void 0!==t.join||"keyvalue"===t.type)&&t).map(e=>({label:e.title,value:e.column}))):[];var e},[l,r]),i=o.length>0?o[0]:null,[u,d]=(0,n.useState)(i?.value||"");return(0,n.useEffect)(()=>{const e=o.length>0?o[0]:null;d(e?.value||"")},[o]),l&&0!==o.length?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{children:(0,c.__)("Column","search-regex")}),(0,_.jsx)(j,{items:o,name:"modify",value:u,disabled:t,className:"searchregex-search__action__modify",onChange:e=>d(e.target.value)}),(0,_.jsx)(Lt,{disabled:t,onClick:function(){if(!l)return;const e=o.length>0?o[0]:null,t=u||e?.value;if(!t)return;const s=function(e,t){const r=t.columns?tr(t.columns,e):t,s=r?function(e){if("member"===e.type&&Array.isArray(e.options)&&e.options.length>0){const t=e.options[0];if(t)return{values:[t.value]}}return{}}(r):{};return{column:r.column,operation:"",source:t.type,...s}}(t,l);a({actionOption:r.concat([s])})},children:(0,c.__)("Add","search-regex")})]}):null};function Zr(e){return"member"===e?[{value:"replace",label:(0,c.__)("Replace With","search-regex")},{value:"include",label:(0,c.__)("Add","search-regex")},{value:"exclude",label:(0,c.__)("Remove","search-regex")}]:"string"===e?[{value:"set",label:(0,c.__)("Set Value","search-regex")},{value:"replace",label:(0,c.__)("Replace","search-regex")}]:"keyvalue"===e?[{value:"add",label:(0,c.__)("Add","search-regex")},{value:"remove",label:(0,c.__)("Remove","search-regex")}]:[{value:"set",label:(0,c.__)("Set Value","search-regex")},{value:"increment",label:(0,c.__)("Increment","search-regex")},{value:"decrement",label:(0,c.__)("Decrement","search-regex")}]}function es({value:e,disabled:t,onChange:r,type:s,extraItems:n=[]}){return(0,_.jsx)(j,{name:"operation",items:[...Zr(s),...n],disabled:t,value:e,onChange:e=>r(e.target.value)})}function ts({disabled:e,item:t,onChange:r,schema:s,fetchData:n,fixOperation:a}){const{operation:l=a||"set",value:c=""}=t,o="api"===s.options&&n,i=Ar(e=>e.labels),u=Ar(e=>e.setLabels);return o?(0,_.jsx)(jr,{value:""===c||void 0===c?[]:[c],disabled:e,onChange:(e,t)=>{const s=e[0],n=t[0];e&&s?r({value:s},n??""):r({value:""},"")},fetchData:o,loadOnFocus:!0,maxChoices:1,onlyChoices:!0,setLabel:(e,t)=>{const r=i.findIndex(t=>t.value===s.column+"_"+e);if(r>=0){const n=[...i];n[r]={value:s.column+"_"+e,label:t||""},u(n)}else u([...i,{value:s.column+"_"+e,label:t||""}])},getLabel:e=>nr(i,s.column+"_"+e)}):(0,_.jsxs)(_.Fragment,{children:[!a&&(0,_.jsx)(es,{type:"integer",value:l,disabled:e,onChange:e=>r({operation:e,value:""})}),(0,_.jsx)(Or,{name:"value",column:t.column,value:c,onChange:r,disabled:e})]})}function rs({disabled:e,item:t,onChange:r,fixOperation:s}){const{operation:n=s||"set",value:a="",unit:l="second"}=t;return(0,_.jsxs)(_.Fragment,{children:[!s&&(0,_.jsx)(es,{type:"date",value:n,disabled:e,onChange:e=>r({operation:e,unit:"second"})}),("set"===n||""===n)&&(0,_.jsx)(Er,{selected:"string"==typeof a?new Date(a):a,onChange:e=>r({value:e||""}),showTimeSelect:!0,dateFormat:"MMMM d, yyyy hh:mm",withPortal:!!s}),"set"!==n&&""!==n&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("input",{type:"number",value:"string"==typeof a?a:"",onChange:e=>r({value:e.target.value}),disabled:e}),(0,_.jsx)(j,{name:"unit",value:l,onChange:e=>r({unit:e.target.value}),disabled:e,items:[{value:"second",label:(0,c.__)("Seconds","search-regex")},{value:"minute",label:(0,c.__)("Minutes","search-regex")},{value:"hour",label:(0,c.__)("Hours","search-regex")},{value:"day",label:(0,c.__)("Days","search-regex")},{value:"week",label:(0,c.__)("Weeks","search-regex")},{value:"month",label:(0,c.__)("Months","search-regex")},{value:"year",label:(0,c.__)("Year","search-regex")}]})]})]})}function ss(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ns(e){return"begins"===e.logic||"ends"===e.logic||e.flags&&-1!==e.flags.indexOf("regex")?[...e.flags||[],"regex"]:e.flags||[]}function as(e){return"begins"===e.logic&&e.value?"^"+ss(e.value):"ends"===e.logic&&e.value?ss(e.value)+"$":e.value||""}function ls({disabled:e,item:t,onChange:r,schema:s,fetchData:a}){const{operation:l="set",searchValue:o="",replaceValue:i="",searchFlags:u=["case"]}=t,[d,h]=(0,n.useState)("set"),p="api"===s.options&&-1===(g=u).indexOf("regex")&&-1===g.indexOf("multi")&&a;var g;const x=Ar(e=>e.search),{filters:m=[],searchPhrase:f="",searchFlags:v=[]}=x,j=(0,n.useMemo)(()=>function(e,t,r,s){const n=[];r&&n.push({column:"global",value:r,logic:"contains",flags:s});for(let r=0;r<e.length;r++){const s=e[r];if(s&&s.type===t.source)for(let e=0;e<s.items.length;e++){const r=s.items[e];r&&r.column===t.column&&"notcontains"!==r.logic&&"notequals"!==r.logic&&r.value&&n.push(r)}}return n}(m,t,f,v),[m,t,f,v]),b={value:o,disabled:e,onChange:e=>r({searchValue:e})},y={value:i,disabled:e,onChange:e=>r({replaceValue:e}),length:s.length?s.length:0},w=-1===u.indexOf("multi")&&!1!==p?{...b,fetchData:p}:b,S=-1===u.indexOf("multi")&&!1!==p?{...y,fetchData:p}:y;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(es,{type:"string",value:d,disabled:e,onChange:function(e){h(e),r(function(e,t){const r=t.find(t=>t.column+"-"+t.value===e);return{operation:r?"replace":e,searchValue:r?as(r):"",searchFlags:r?ns(r):[]}}(e,j))},extraItems:j.map(e=>({value:e.column+"-"+e.value,label:(0,c.sprintf)(/* translators: %s: value being replaced */ /* translators: %s: value being replaced */
(0,c.__)('Replace "%s"',"search-regex"),(e.value||"").slice(0,20))}))}),"replace"===l&&"replace"===d&&(0,_.jsxs)(_.Fragment,{children:[(0,c.__)("Search","search-regex"),-1===u.indexOf("multi")?(0,_.jsx)(jr,{...w}):(0,_.jsx)("textarea",{...b,onChange:e=>r({searchValue:e.target.value})}),(0,c.__)("Replace","search-regex")]}),-1===u.indexOf("multi")?(0,_.jsx)(jr,{...S}):(0,_.jsx)("textarea",{...y,onChange:e=>r({replaceValue:e.target.value})}),(s.multiline||"replace"===l&&"replace"===d)&&(0,_.jsx)(Yr,{flags:u,disabled:e,onChange:e=>r({searchFlags:e}),allowRegex:"replace"===l,allowMultiline:s.multiline||!1,allowCase:"replace"===l})]})}function cs({disabled:e,item:t,onChange:r,schema:s,fetchData:n,fixOperation:a,localLabels:l=[]}){const{operation:c="include",values:o=[]}=t,i="api"===s.options&&n,u=Ar(e=>e.labels),d=Ar(e=>e.setLabels),h=void 0!==s.join;if(!i){const t=Array.isArray(s.options)?s.options:[];return(0,_.jsx)(j,{name:"member",items:t,value:(o[0]??t[0]?.value)||"",disabled:e,onChange:e=>r({values:[e.target.value]})})}return(0,_.jsxs)(_.Fragment,{children:[h&&!a&&(0,_.jsx)(es,{type:"member",value:c,disabled:e,onChange:e=>r({operation:e})}),(0,_.jsx)(jr,{value:o,disabled:e,onChange:(e,t)=>{const s=Array.isArray(e)?e:[e];r({values:s},t)},fetchData:i,...void 0!==s.preload&&{loadOnFocus:s.preload},maxChoices:h?20:1,onlyChoices:!0,setLabel:(e,t)=>{const r=u.findIndex(t=>t.value===s.column+"_"+e);if(r>=0){const n=[...u];n[r]={value:s.column+"_"+e,label:t||""},d(n)}else d([...u,{value:s.column+"_"+e,label:t||""}])},getLabel:e=>nr(Array.isArray(u)?[...u,...l]:l,s.column+"_"+e)})]})}function os({disabled:e,item:t,onChange:r,schema:s,fetchData:n}){const{operation:a="add",key:l="",value:o="",valueFlags:i=["case"]}=t,u="api"===s.options&&n;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(es,{type:"keyvalue",value:a,disabled:e,onChange:e=>r({operation:e,key:"",value:""})}),(0,_.jsxs)("div",{className:"searchregex-filter__keyvalue",children:[(0,_.jsxs)("div",{className:"searchregex-filter__keyvalue__item",children:[(0,_.jsx)("span",{children:(0,c.__)("Meta Key","search-regex")}),"replace_key"===a&&(0,c.__)("Search","search-regex"),(0,_.jsx)(jr,{value:l,disabled:e,onChange:e=>r({key:e}),...u&&"replace_key"!==a&&{fetchData:u},...void 0!==s.preload&&{loadOnFocus:s.preload}})]}),"remove"!==a&&(0,_.jsxs)("div",{className:"searchregex-filter__keyvalue__item",children:[(0,_.jsx)("span",{children:(0,c.__)("Meta Value","search-regex")}),"replace_value"===a&&(0,c.__)("Search","search-regex"),-1===i.indexOf("multi")?(0,_.jsx)(jr,{value:o,disabled:e,onChange:e=>r({value:e})}):(0,_.jsx)("textarea",{value:o,disabled:e,onChange:e=>r({value:e.target.value})}),(0,_.jsx)(Yr,{flags:i,disabled:e,onChange:e=>r({valueFlags:e}),allowRegex:!1,allowMultiline:!0,allowCase:!1})]})]})]})}const is=function(e){const{type:t}=e.schema;return"integer"===t?(0,_.jsx)(ts,{...e}):"date"===t?(0,_.jsx)(rs,{...e}):"string"===t?(0,_.jsx)(ls,{...e}):"member"===t?(0,_.jsx)(cs,{...e}):"keyvalue"===t?(0,_.jsx)(os,{...e}):null};function us({disabled:e,schema:t,column:r,onRemove:s,onChange:n}){return(0,_.jsxs)("div",{className:"searchregex-modify",children:[(0,_.jsxs)("div",{className:"searchregex-modify__name",children:[(0,_.jsx)("span",{children:t.title}),s&&(0,_.jsx)("button",{type:"button","aria-label":(0,c.__)("Remove modification","search-regex"),onClick:s,disabled:e,className:(0,S.A)("dashicons","dashicons-trash",e&&"dashicons__disabled")})]}),(0,_.jsx)(is,{disabled:e,schema:t,item:r,onChange:n,fetchData:function(e){return ae(Ze(r.source||"",r.column,e))}})]})}function ds(e,t){return[{label:(0,c.__)("No action","search-regex"),value:"",desc:(0,c.__)("Just show matching results.","search-regex")},{label:(0,c.__)("Global Text Replace","search-regex"),value:"replace",desc:(0,c.__)("Replace the global search values.","search-regex")},{label:(0,c.__)("Modify Matches","search-regex"),value:"modify",desc:(0,c.__)("Perform changes to specific values of the matching results.","search-regex")},{label:(0,c.__)("Export Matches","search-regex"),value:"export",desc:(0,c.__)("Export matching results to JSON, CSV, or SQL.","search-regex"),disabled:!t},{label:(0,c.__)("Delete Matching Rows","search-regex"),value:"delete",desc:(0,c.__)("Delete matching rows.","search-regex")},{label:(0,c.__)("Run Action","search-regex"),value:"action",desc:(0,c.__)("Run a WordPress action for each matching result.","search-regex")}]}const hs=function(e){const{locked:t,tags:r,preset:s,headerClass:a,searchPhrase:l,disabled:o,sources:i,onSetSearch:u,search:d}=e,h=Ar(e=>e.schema),{action:p="",actionOption:g={},replacement:x}=d,m=ds(Boolean(l&&l.length>0),1===i.length),f=m.find(e=>e.value===p)||m[0],v=m[0],[b,y]=(0,n.useState)(i.length>0?i[0]:""),w=ar(i,h),C="searchregex-export-selected",k=Array.isArray(g)?g:[],N=Array.isArray(g)?{}:g,R=(0,n.useCallback)(e=>{const t=e.replacement;u({replacement:t??null})},[u]);return(0,n.useEffect)(()=>{f&&f.disabled&&v&&u({action:v.value,actionOption:[]}),y(i.length>0?i[0]:"")},[m,f,v,u,i]),(0,_.jsxs)(_.Fragment,{children:[!$t(t,"replacement")&&!Ut(r,s?.search?.replacement??"")&&(0,_.jsxs)("tr",{className:(0,S.A)("searchregex-search__action",a),children:[(0,_.jsx)("th",{children:(0,c.__)("Action","search-regex")}),(0,_.jsxs)("td",{children:[(0,_.jsx)(j,{items:m,name:"action",value:p,disabled:o,className:"searchregex-search__action__type",onChange:e=>u({action:e.target.value,actionOption:[]})}),"modify"===p&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{children:(0,c.__)("Source","search-regex")}),(0,_.jsx)(j,{disabled:o,name:"actionSource",value:b||"",onChange:e=>y(e.target.value),items:w}),(0,_.jsx)(Xr,{columns:k,disabled:o,source:b||"",onSetSearch:u})]}),"export"===p&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{children:(0,c.__)("Export Format","search-regex")}),(0,_.jsx)(j,{items:[{value:"json",label:(0,c.__)("JSON","search-regex")},{value:"csv",label:(0,c.__)("CSV","search-regex")},{value:"sql",label:(0,c.__)("SQL","search-regex")}],name:"export",value:N.format||"json",disabled:o,onChange:e=>u({actionOption:{format:e.target.value}})})]}),"action"===p&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{children:(0,c.__)("WordPress Action","search-regex")}),(0,_.jsx)("input",{type:"text",className:"",value:N.hook||"",onChange:e=>u({actionOption:{hook:e.target.value}}),disabled:o})]}),(0,_.jsx)("span",{children:f?.desc||""})]})]}),"export"===p&&(0,_.jsxs)("tr",{className:"searchregex-search__export",children:[(0,_.jsx)("th",{}),(0,_.jsx)("td",{children:(0,_.jsxs)("p",{children:[(0,_.jsx)("input",{id:C,type:"checkbox",checked:N.selectedOnly||!1,onChange:e=>u({actionOption:{...N,selectedOnly:e.target.checked}})}),(0,_.jsx)("label",{htmlFor:C,children:(0,c.__)("Only include selected columns","search-regex")})]})})]}),"modify"===p&&k.length>0&&(0,_.jsxs)("tr",{children:[(0,_.jsx)("th",{}),(0,_.jsx)("td",{children:k.filter((e,t)=>!Bt(r,function(e,t){return e&&Array.isArray(e.search.actionOption)?e.search.actionOption[t]:{}}(s,t))).map((e,t)=>{const r=function(e,t,r){const s=er(e,t);return s&&tr(s.columns,r)||null}(h,e.source??"",e.column??"");return r?(0,_.jsx)(us,{column:e,disabled:o,schema:r,onRemove:()=>function(e){u({actionOption:k.filter(t=>t.column!==e.column)})}(e),onChange:e=>function(e,t){u({actionOption:[...k.slice(0,e),{...k[e],...t},...k.slice(e+1)]})}(t,e)},t+"-"+e.column):null})})]}),"replace"===p&&!Ut(r,s?.search?.replacement??"")&&(0,_.jsxs)("tr",{className:"searchregex-search__replace",children:[(0,_.jsx)("th",{children:(0,c.__)("Replace","search-regex")}),(0,_.jsx)("td",{children:(0,_.jsx)(Vt,{disabled:o||0===l.length,setReplace:R,replacement:x,preset:s,schema:{type:"string"},column:{column_id:"global",column_label:(0,c.__)("Global","search-regex"),contexts:[],context_count:0,match_count:0},placeholder:(0,c.__)("Optional global replacement phrase. Only applies to the global search.","search-regex")})})]})]})};function ps(e,t,r){return t.reduce((e,t,s)=>{const n=r[s];return void 0!==n?function(e,t,r){const s=t.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&");return e.replace(new RegExp(s,"g"),r)}(e,t.name,n):e},e)}function gs(e,t,r){return{searchPhrase:ps(e.searchPhrase,t,r),replacement:ps(e.replacement,t,r),filters:e.filters.map(e=>({...e,items:e.items.map(e=>({...e,...void 0===e.value?{}:{value:ps(e.value,t,r)}}))})),actionOption:Array.isArray(e.actionOption)?e.actionOption.map(e=>void 0===e.searchValue?e:{...e,searchValue:ps(e.searchValue,t,r),replaceValue:ps(e.replaceValue,t,r)}):e.actionOption}}const xs=function(e){const{search:t,values:r,onChange:s,className:a,tags:l,disabled:c=!1}=e,[o,i]=(0,n.useState)(l.map(()=>""));return l.map((e,n)=>(0,_.jsxs)("tr",{className:(0,S.A)("searchregex-preset__tag",a),children:[(0,_.jsx)("th",{children:e.title}),(0,_.jsx)("td",{children:(0,_.jsx)("input",{type:"text",value:o[n],placeholder:e.title,onChange:e=>function(e,n){const a=o.slice(0,n).concat(e,o.slice(n+1));i(a),s({...r,...gs(t,l,a)})}(e.target.value,n),disabled:c})})]},e.name))};function ms(e,t,r,s){return e.map(e=>{const n=er(t,e);if(!n)return null;const a=n.columns.filter(t=>t.column&&!function(e,t,r){return void 0!==e.find(e=>e.type===t&&e.items.find(e=>e.column===r))}(r,e,t.column)&&!function(e,t,r){return!!Array.isArray(e)&&void 0!==e.find(e=>e.source===t&&e.column===r)}(s,e,t.column));return a.length>0?{value:e,label:n.name,options:a.map(t=>({value:e+"__"+String(t.column||""),label:t.title||""}))}:null}).filter(e=>null!==e)}function _s(e,t,r){if(r){if(e!==r.searchPhrase&&""!==e)return!0;if(""!==t&&t!==r.replacement)return!0}return!1}function fs(e,t,r){if(!r||!Array.isArray(e)||0===t.length)return!0;let s=0,n=0;for(let r=0;r<e.length;r++){const a=e[r];a&&(n++,s+=Bt(t,a)?1:0)}return s!==n}const vs=function({search:e,onSetSearch:t,isBusy:r,preset:s}){const a=Ar(e=>e.sources),l=Ar(e=>e.schema),o=Ar(e=>e.mode),{searchPhrase:i="",searchFlags:u=[],source:d=[],perPage:h=25,replacement:p="",filters:g=[],actionOption:x=[],view:m=[]}=e,f=s?s.locked:[],v=s?s.tags:[],b=Kt(v),y=(0,S.A)(b),w=Wt(s),C=ar(d,l),k=C.length>0?C[0]:null,N=k&&"string"==typeof k.value?k.value:"",[R,P]=(0,n.useState)(N),A=function(e,t){if(0===t.length)return!0;let r=0,s=0;for(let n=0;n<e.length;n++){const a=e[n];if(a)for(let e=0;e<a.items.length;e++){const n=a.items[e];n&&(s++,r+=qt(t,n)?1:0)}}return r!==s}(g,v)&&!$t(f,"filters"),O=!($t(f,"searchFlags")&&$t(f,"searchPhrase")||Ut(v,s?.search?.searchPhrase??"")),F=!$t(f,"replacement")&&!Ut(v,s?.search?.replacement??"");return(0,n.useEffect)(()=>{if(!C.find(e=>e.value===R)){const e=C.length>0?C[0]:null,t=e&&"string"==typeof e.value?e.value:"";P(t)}},[d,R,C]),"simple"===o?(0,_.jsxs)(_.Fragment,{children:[s&&s.description?(0,_.jsxs)("tr",{children:[(0,_.jsx)("th",{}),(0,_.jsx)("td",{children:(0,_.jsx)("h3",{className:"searchregex-preset__description",children:s.description})})]}):null,O&&(0,_.jsxs)("tr",{className:(0,S.A)("searchregex-search__search",y),children:[(0,_.jsx)("th",{children:(0,c.__)("Search","search-regex")}),(0,_.jsxs)("td",{children:[!$t(f,"searchPhrase")&&(0,_.jsx)(ur,{disabled:r,value:i,onChange:e=>t({searchPhrase:e}),multiline:-1!==u.indexOf("multi"),placeholder:(0,c.__)("Phrase to search for","search-regex"),multilinePlaceholder:(0,c.__)("Phrase to search for","search-regex")}),!$t(f,"searchFlags")&&(0,_.jsx)(Yr,{flags:u,disabled:r,onChange:e=>t({searchFlags:e}),allowMultiline:!0})]})]}),F&&(0,_.jsxs)("tr",{className:(0,S.A)("searchregex-search__replace",y),children:[(0,_.jsx)("th",{children:(0,c.__)("Replace","search-regex")}),(0,_.jsx)("td",{children:(0,_.jsx)(Vt,{disabled:r,setReplace:e=>{const r=e.replacement;t({replacement:r??""})},replacement:p??null,preset:s,schema:{type:"string"},column:{column_id:"global",column_label:(0,c.__)("Global","search-regex"),contexts:[],context_count:0,match_count:0},placeholder:(0,c.__)("Phrase to replace with (optional)","search-regex")})})]})]}):(0,_.jsxs)(_.Fragment,{children:[s&&s.description?(0,_.jsxs)("tr",{children:[(0,_.jsx)("th",{}),(0,_.jsx)("td",{children:(0,_.jsx)("h3",{className:"searchregex-preset__description",children:s.description})})]}):null,(!$t(f,"source")||A)&&(0,_.jsxs)("tr",{className:(0,S.A)("searchregex-search__source",y),children:[(0,_.jsx)("th",{children:(0,c.__)("Source","search-regex")}),(0,_.jsxs)("td",{children:[!$t(f,"source")&&(0,_.jsx)(Yt,{options:Qr(a),selected:d,onChange:e=>{const r=Array.isArray(e)?e:[],s=r.find(e=>!d.includes(e))||r[0]||"";t(function(e,t){const r=function(e){return 0===e.length?["posts"]:e}(e),s=ar(r,l).map(e=>e.value),n=-1!==r.indexOf(t)?Xt(t).filter(e=>-1===s.indexOf(e.type)):[];return{source:r,filters:g.filter(e=>-1!==s.indexOf(e.type)).concat(n),actionOption:[],view:m.filter(e=>{const t=e.split("__")[0];return!!t&&-1!==r.indexOf(t)})}}(r,s))},multiple:!0,disabled:r,badges:!0,title:0===d.length?(0,c.__)("Source","search-regex"):"","aria-label":(0,c.__)("Sources","search-regex")}),A&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("span",{children:(0,_.jsx)("strong",{children:(0,c.__)("Filters","search-regex")})}),(0,_.jsx)(j,{disabled:r,name:"filter",value:R,onChange:e=>P(e.target.value),items:C}),(0,_.jsx)(Lt,{onClick:function(){const e=er(l,R);e&&"string"==typeof R&&t({filters:g.concat(sr(R,e))})},disabled:r||g.length>=20,children:(0,c.__)("Add","search-regex")})]})]})]}),A&&(0,_.jsx)(zr,{filters:g,disabled:r,onSetSearch:t,tags:v,presetFilters:s?.search?.filters??[]}),(!$t(f,"searchFlags")||!$t(f,"searchPhrase"))&&!Ut(v,s?.search?.searchPhrase??"")&&(0,_.jsxs)("tr",{className:(0,S.A)("searchregex-search__search",y),children:[(0,_.jsx)("th",{children:(0,c.__)("Search","search-regex")}),(0,_.jsxs)("td",{children:[!$t(f,"searchPhrase")&&(0,_.jsx)(ur,{disabled:r,value:i,onChange:e=>t({searchPhrase:e}),multiline:-1!==u.indexOf("multi")}),!$t(f,"searchFlags")&&(0,_.jsx)(Yr,{flags:u,disabled:r,onChange:e=>t({searchFlags:e}),allowMultiline:!0})]})]}),s&&(0,_.jsx)(xs,{disabled:r,search:s.search,values:e,onChange:e=>t(e),tags:v,className:y},s.id),!$t(f,"action")&&fs(x,v,s)&&(0,_.jsx)(hs,{locked:f,tags:v,preset:s,headerClass:y,searchPhrase:i,disabled:r,sources:d,onSetSearch:t,search:{action:e.action||"",actionOption:x,replacement:p||null}}),(!$t(f,"perPage")||!$t(f,"view"))&&(0,_.jsxs)("tr",{className:(0,S.A)("searchregex-search__results",y),children:[(0,_.jsx)("th",{children:(0,c.__)("Results","search-regex")}),(0,_.jsxs)("td",{children:[!$t(f,"perPage")&&(0,_.jsx)(j,{name:"perPage",items:Jt(),value:String(h),onChange:e=>t({perPage:parseInt(e.target.value,10)}),disabled:r}),!$t(f,"view")&&d.length>0&&(0,_.jsx)(Yt,{options:ms(d,l,g,x),selected:m,onChange:e=>t({view:Array.isArray(e)?e:[]}),multiple:!0,disabled:r,title:(0,c.__)("View Columns","search-regex"),badges:!0})]})]}),_s(i,p,w)?(0,_.jsxs)("tr",{className:(0,S.A)(y),children:[(0,_.jsx)("th",{}),(0,_.jsxs)("td",{children:[(0,_.jsx)("code",{children:i}),p&&(0,_.jsxs)(_.Fragment,{children:[" →  ",(0,_.jsx)("code",{children:p})]})]})]}):null]})},js=function(e){const{preset:t,onCancel:r,onUpdate:s}=e,{id:a,name:l,search:o,locked:i,tags:u,description:d}=t,[h,p]=(0,n.useState)(o),[g,x]=(0,n.useState)(l),[m,f]=(0,n.useState)(d||""),[v,j]=(0,n.useState)(i),[b,y]=(0,n.useState)(0===u.length?[{name:"",title:""}]:u),w=[{value:"searchPhrase",label:(0,c.__)("Global Search","search-regex")},{value:"replacement",label:(0,c.__)("Global Replace","search-regex")},{value:"searchFlags",label:(0,c.__)("Global Search Flags","search-regex")},{value:"source",label:(0,c.__)("Source","search-regex")},{value:"perPage",label:(0,c.__)("Results per page","search-regex")},{value:"filters",label:(0,c.__)("Filters","search-regex")},{value:"action",label:(0,c.__)("Action","search-regex")},{value:"view",label:(0,c.__)("View Columns","search-regex")}];function S(e,t){const r=b[e];r&&y([...b.slice(0,e),{name:t.name??r.name,title:t.title??r.title},...b.slice(e+1)])}function C(e){if(1===e.length){const t=e[0];if(t&&""===t.name&&""===t.title)return[]}return e}return(0,_.jsx)("td",{colSpan:3,children:(0,_.jsx)("table",{children:(0,_.jsxs)("tbody",{children:[(0,_.jsx)("tr",{children:(0,_.jsx)("td",{colSpan:2,children:(0,_.jsxs)("h2",{children:[(0,c.__)("Edit preset","search-regex")," "]})})}),(0,_.jsxs)("tr",{className:"searchregex-search__search",children:[(0,_.jsx)("th",{children:(0,c.__)("Preset Name","search-regex")}),(0,_.jsx)("td",{children:(0,_.jsx)("input",{type:"text",value:g,onChange:e=>x(e.target.value),placeholder:(0,c.__)("Give the preset a name","search-regex")})})]}),(0,_.jsxs)("tr",{className:"searchregex-search__search",children:[(0,_.jsx)("th",{children:(0,c.__)("Preset Description","search-regex")}),(0,_.jsx)("td",{children:(0,_.jsx)("input",{type:"text",value:m,onChange:e=>f(e.target.value),placeholder:(0,c.__)("Describe the preset","search-regex")})})]}),(0,_.jsx)(vs,{search:h,onSetSearch:e=>p({...h,...e}),isBusy:!1,preset:null}),(0,_.jsx)("tr",{className:"searchregex-search__advanced__title",children:(0,_.jsx)("td",{colSpan:2,children:(0,_.jsxs)("h2",{children:[(0,c.__)("Advanced preset","search-regex")," "]})})}),(0,_.jsxs)("tr",{className:"searchregex-search__advanced",children:[(0,_.jsx)("th",{children:(0,c.__)("Locked Fields","search-regex")}),(0,_.jsxs)("td",{children:[(0,_.jsx)(Yt,{options:w,selected:v,onChange:e=>{const t=Array.isArray(e)?e:[];j(t)},multiple:!0,title:(0,c.__)("Fields","search-regex"),badges:!0}),(0,_.jsx)("p",{children:(0,c.__)("Locking a field removes it from the search form and prevents changes.","search-regex")})]})]}),(0,_.jsxs)("tr",{className:"searchregex-search__advanced",children:[(0,_.jsx)("th",{children:(0,c.__)("Tags","search-regex")}),(0,_.jsxs)("td",{children:[b.map((e,t)=>(0,_.jsxs)("p",{children:[(0,_.jsxs)("label",{children:[(0,c.__)("Title","search-regex")," ",(0,_.jsx)("input",{type:"text",placeholder:(0,c.__)("Enter tag title shown to user","search-regex"),value:e.title,onChange:e=>S(t,{title:e.target.value})})]})," ",(0,_.jsxs)("label",{children:[(0,c.__)("Tag","search-regex")," ",(0,_.jsx)("input",{type:"text",placeholder:(0,c.__)("Enter tag which is used in the field","search-regex"),value:e.name,onChange:e=>S(t,{name:e.target.value})})]}),t<20&&(0,_.jsx)(Lt,{className:"searchregex-preset__tag-button",onClick:()=>t===b.length-1?void y(b.concat({name:"",title:""})):function(e){y([...b.slice(0,e),...b.slice(e+1)])}(t),children:t===b.length-1?"+":"-"})]},t)),(0,_.jsx)("p",{children:(0,c.__)("A tag creates a custom input field. Insert the tag anywhere in the search, replace, text filter, or text action and when the preset is used it will be replaced with a custom text field with the tag title.","search-regex")}),(0,_.jsx)("p",{children:I((0,c.__)('For example, create tag {{code}}URL{{/code}} and title {{code}}Image URL{{/code}}. Your search could be {{code}}<img src="URL">{{/code}}. When the preset is used it will ask the user for the {{code}}Image URL{{/code}} instead of the full search phrase.',"search-regex"),{code:(0,_.jsx)("code",{})})})]})]}),(0,_.jsxs)("tr",{children:[(0,_.jsx)("th",{}),(0,_.jsxs)("td",{children:[(0,_.jsx)("input",{type:"submit",className:"button button-primary",value:(0,c.__)("Save","search-regex"),onClick:e=>function(e){e.preventDefault(),s({id:a,name:g,description:m,search:h,tags:C(b),locked:v})}(e)}),(0,_.jsx)("button",{className:"button button-secondary",onClick:r,type:"button",children:(0,c.__)("Cancel","search-regex")})]})]})]})})})};function bs(e,t){for(let r=0;r<e.length;r++){const s=e[r];if(s&&s.sources)for(let e=0;e<s.sources.length;e++){const r=s.sources[e];if(r&&r.name===t)return r}}return null}const ys=function(e){const t=Ar(e=>e.sources),{preset:r}=e,{search:s,locked:n}=r,a=[],{searchFlags:l=[],source:o=[]}=s;for(let e=0;e<o.length;e++){const r=o[e];if(!r)continue;const s=bs(t,r);s&&a.push(s.label)}for(let e=0;e<l.length;e++){const t=Ht().find(t=>t.value===l[e]);t&&"case"!==l[e]&&a.push(t.label)}return n.length>0&&a.push((0,c.__)("Locked fields","search-regex")),(0,_.jsx)("p",{children:a.join(", ")})};function ws(e,t,r){const s=e.split(t),n=[];for(let e=0;e<s.length;e++)e%2!=0&&n.push((0,_.jsx)("code",{title:r,children:t},`${t}-${e}`)),n.push(s[e]);return n}function Ss(e,t){let r=[`${e}`];for(let e=0;e<t.length;e++){const s=t[e];if(!s)continue;const n=[];for(let e=0;e<r.length;e++){const t=r[e];if("string"==typeof t){const e=ws(t,s.name,s.title);n.push(...e)}else n.push(t)}r=n}return r}const Cs=function({phrase:e,tags:t}){return""===e?(0,_.jsx)("em",{children:(0,c.__)("no phrase","search-regex")}):null===e?(0,_.jsx)("em",{children:(0,c.__)("remove phrase","search-regex")}):(0,_.jsx)(_.Fragment,{children:Ss(e,t)})},ks=function(e){const{children:t,preset:r}=e,{search:s,name:n,tags:a}=r,{searchPhrase:l="",replacement:o="",filters:i=[],action:u}=s,d=ds(0,!0).find(e=>e.value===u);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("td",{className:"searchregex-preset__name",children:n}),(0,_.jsxs)("td",{className:"searchregex-preset__search",children:[l.length>0&&(0,_.jsxs)("p",{children:[(0,_.jsx)("strong",{children:(0,c.__)("Search","search-regex")}),":"," ",(0,_.jsx)(Cs,{phrase:l,tags:a})]}),i.length>0&&(0,_.jsxs)("p",{children:[(0,_.jsx)("strong",{children:(0,c.__)("Filters","search-regex")}),": ",i.length]}),d&&(0,_.jsxs)("p",{children:[(0,_.jsx)("strong",{children:(0,c.__)("Action","search-regex")}),": ",d.label]}),o.length>0&&(0,_.jsxs)("p",{children:[(0,_.jsx)("strong",{children:(0,c.__)("Replace","search-regex")}),":"," ",(0,_.jsx)(Cs,{phrase:o,tags:a})]}),t]}),(0,_.jsx)("td",{className:"searchregex-preset__flags",children:(0,_.jsx)(ys,{preset:r})})]})};function Ns(e){const{id:t,tags:r,locked:s,...n}=e,a={...n};return r.length>0&&(a.tags=r),s.length>0&&(a.locked=s),a}const Rs=function(e){const{preset:t}=e,{id:r}=t,[s,a]=(0,n.useState)(!1),o=function(){const e=(0,l.jE)(),t=H(e=>e.addError);return(0,z.n)({mutationFn:async e=>{const t=await ae(oe(`search-regex/v1/preset/id/${e}/delete`));return Se.parse(t)},onSuccess:t=>{e.setQueryData(Fe,t.presets)},onError:e=>{t(e)}})}(),i=Ie(),u=o.isPending||i.isPending;return(0,_.jsx)("tr",{className:u?"searchregex-preset__saving":"",children:s?(0,_.jsx)(js,{preset:t,onCancel:()=>a(!1),onUpdate:function(e){i.mutate(e),a(!1)}}):(0,_.jsx)(ks,{preset:t,children:(0,_.jsx)("div",{className:"row-actions",children:u?(0,_.jsx)(_.Fragment,{children:" "}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("a",{href:"#",onClick:function(e){e.preventDefault(),a(!0)},children:(0,c.__)("Edit","search-regex")})," ","|"," ",(0,_.jsx)("a",{href:"#",onClick:function(e){e.preventDefault(),confirm((0,c.__)("Are you sure you want to delete this preset?","search-regex"))&&o.mutate(r)},children:(0,c.__)("Delete","search-regex")})," ","|"," ",(0,_.jsx)(_t.CopyToClipboard,{text:JSON.stringify(Ns(t)),children:(0,_.jsx)("a",{href:"#",onClick:e=>e.preventDefault(),children:(0,c.__)("Copy to clipboard","search-regex")})})]})})})})},Ps=function(e){const{hover:t,dropzone:r,renderUnselected:s,file:n,clearFile:a,onUpload:l,isUploading:c,isUploaded:o,renderSelected:i,renderUploaded:u,renderUploading:d,disabled:h,addFileText:p,uploadText:g,cancelText:x}=e,{getRootProps:m,getInputProps:f,open:v}=r,j=(0,S.A)("wpl-dropzone",{"wpl-dropzone__hover":t}),b=m({onClick:e=>e.stopPropagation(),onKeyDown:e=>{32!==e.keyCode&&13!==e.keyCode||e.stopPropagation()}}),y=f(),{ref:w,...C}=y;return(0,_.jsxs)("div",{...b,className:j,children:[(0,_.jsx)("input",{...C,ref:w}),(null===n||h&&!c)&&(0,_.jsxs)(_.Fragment,{children:[s(v),(0,_.jsx)("button",{type:"button",className:"button-secondary",onClick:v,disabled:h,children:p})]}),null!==n&&!c&&!o&&(0,_.jsxs)(_.Fragment,{children:[i(n),(0,_.jsx)("button",{className:"button-primary",onClick:()=>l(n),children:g})," ",(0,_.jsx)("button",{className:"button-secondary",onClick:a,children:x})]}),null!==n&&c&&d(n),null!==n&&o&&u(a)]})},As=function(e){const[t,r]=(0,n.useState)(null),s=function(e){const{onDrop:t,multiple:r=!1,onDragEnter:s,onDragLeave:a}=e,[l,c]=(0,n.useState)(!1),o=(0,n.useRef)(null),i=(0,n.useRef)(0),u=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),i.current+=1,e.dataTransfer.types.includes("Files")&&(c(!0),s?.())},[s]),d=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),h=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),i.current-=1,0===i.current&&(c(!1),a?.())},[a]),p=(0,n.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),i.current=0,c(!1);const s=Array.from(e.dataTransfer.files);if(s.length>0){const e=r?s:[s[0]];t(e.filter(e=>void 0!==e))}},[t,r]),g=(0,n.useCallback)(e=>{const s=Array.from(e.target.files||[]);if(s.length>0){const e=r?s:[s[0]];t(e.filter(e=>void 0!==e))}o.current&&(o.current.value="")},[t,r]),x=(0,n.useCallback)(()=>{o.current?.click()},[]);return{getRootProps:(0,n.useCallback)(e=>({onDragEnter:u,onDragOver:d,onDragLeave:h,onDrop:p,...e?.onClick&&{onClick:e.onClick},...e?.onKeyDown&&{onKeyDown:e.onKeyDown}}),[u,d,h,p]),getInputProps:(0,n.useCallback)(()=>({type:"file",style:{display:"none"},onChange:g,ref:o,...!r&&{multiple:!1}}),[g,r]),open:x,isDragActive:l}}({multiple:!1,onDrop:function(e){const t=e[0];t&&r(t)},onDragEnter:()=>{},onDragLeave:()=>{}});return(0,_.jsx)(Ps,{dropzone:s,hover:s.isDragActive,file:t,clearFile:()=>r(null),...e})},Os=()=>(0,_.jsx)("div",{className:"wpl-placeholder__container",children:(0,_.jsx)("div",{className:"wpl-placeholder__loading"})});function Fs(e){return(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)("p",{children:[(0,_.jsx)("a",{href:"mailto:john@searchregex.com?subject=Search%20Regex%20Error&body="+encodeURIComponent(e),className:"button-secondary",children:(0,c.__)("Create An Issue","search-regex")})," ",(0,_.jsx)("a",{href:"https://github.com/johngodley/search-regex/issues/new?title=Search%20Regex%20Error&body="+encodeURIComponent(e),className:"button-secondary",children:(0,c.__)("Email","search-regex")})]})})}const Ds=function(){const{data:e=[]}=De(),t=function(){const e=(0,l.jE)(),t=H(e=>e.addNotice),r=H(e=>e.addError);return(0,z.n)({mutationFn:async e=>{const t=await ae(((e,t,r)=>{const s=oe("search-regex/v1/preset/import",{});delete s.headers["Content-Type"];const n=new FormData;return n.append("file",r),s.body=n,s})(0,0,e));return Ce.parse(t)},onSuccess:r=>{e.setQueryData(Fe,r.presets),t((0,c.__)("Preset uploaded","search-regex"))},onError:e=>{r(e)}})}(),{exportPresets:r}={exportPresets:()=>{const e=ce("search-regex/v1/preset",{force:!0});document.location.href=ae.getUrl(e.url)+"&_wpnonce="+SearchRegexi10n.api.WP_API_nonce}},[s,a]=(0,n.useState)(""),[o,i]=(0,n.useState)(null),u=t.isPending&&!s,d=t.isPending&&s.length>0,h=t.isSuccess,p=null!==o;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)("table",{className:(0,S.A)("wp-list-table","widefat","fixed","striped","items","searchregex-presets"),children:[(0,_.jsx)("thead",{children:(0,_.jsxs)("tr",{children:[(0,_.jsx)("th",{className:"searchregex-preset__name",children:(0,c.__)("Name","search-regex")}),(0,_.jsx)("th",{className:"searchregex-preset__search",children:(0,c.__)("Search","search-regex")}),(0,_.jsx)("th",{className:"searchregex-preset__flags",children:(0,c.__)("Flags","search-regex")})]})}),(0,_.jsxs)("tbody",{children:[e.map(e=>(0,_.jsx)(Rs,{preset:e},e.id)),0===e.length&&(0,_.jsx)("tr",{children:(0,_.jsx)("td",{colSpan:3,children:(0,c.__)("There are no presets","search-regex")})})]})]}),(0,_.jsx)("p",{children:(0,_.jsx)(R,{url:"https://searchregex.com/preset/",children:(0,c.__)("Download presets!","search-regex")})}),(0,_.jsx)("div",{className:"searchregex-presetactions",children:e.length>0&&(0,_.jsx)("button",{className:"button button-secondary",onClick:r,children:(0,c.__)("Export JSON","search-regex")})}),(0,_.jsx)("h3",{children:(0,c.__)("Import JSON","search-regex")}),(0,_.jsxs)("div",{className:"searchregex-presetimport",children:[(0,_.jsx)(As,{addFileText:(0,c.__)("Add file","search-regex"),uploadText:(0,c.__)("Upload","search-regex"),cancelText:(0,c.__)("Cancel","search-regex"),isUploading:u,isUploaded:h,disabled:d||u,renderUnselected:()=>(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("h3",{children:(0,c.__)("Import a JSON file","search-regex")}),(0,_.jsx)("p",{children:(0,c.__)("Click 'Add File' or drag and drop here.","search-regex")})]}),renderSelected:e=>(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("h3",{children:(0,c.__)("File selected","search-regex")}),(0,_.jsx)("p",{children:(0,_.jsx)("code",{children:e.name})})]}),renderUploading:e=>(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("h3",{children:(0,c.__)("Importing","search-regex")}),(0,_.jsx)("p",{children:(0,_.jsx)("code",{children:e.name})}),(0,_.jsx)(Os,{})]}),renderUploaded:e=>(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("h3",{children:(0,c.sprintf)(/* translators: %(total)d: number of presets uploaded */ /* translators: %(total)d: number of presets uploaded */
(0,c._n)("Uploaded %(total)d preset","Uploaded %(total)d presets",t.data?.imported??0,"search-regex"),{total:t.data?.imported??0})}),(0,_.jsx)("button",{className:"button-secondary",onClick:e,children:(0,c.__)("Done","search-regex")})]}),onUpload:e=>{t.mutate(e)}}),(0,_.jsx)("h4",{children:(0,c.__)("Import preset from clipboard","search-regex")}),p&&(0,_.jsx)(U,{mini:!0,errors:o?.error?[o.error]:[],title:(0,c.__)("Unable to import preset","search-regex"),type:"error",onClear:()=>{i(null),t.reset()},context:o?.context??null,renderDebug:Fs,versions:SearchRegexi10n.versions,locale:SearchRegexi10n.locale,children:(0,c.__)("Please check your JSON data is a valid preset. You may have copied it incorrectly, or pasted something that is not a preset.","search-regex")}),(0,_.jsx)("textarea",{placeholder:(0,c.__)("Paste preset JSON.","search-regex"),rows:3,value:s,onChange:e=>a(e.target.value),disabled:u}),(0,_.jsx)("p",{children:(0,_.jsx)("button",{disabled:u||0===s.length,className:"button button-secondary",onClick:()=>(e=>{try{const r=JSON.parse(e),s=we.safeParse(r);if(!s.success){const t=s.error.issues.map(e=>{const t=e.path.join(".");return`${t?`${t}: `:""}${e.message}`}).join("; ");return void i({error:new globalThis.Error(`Invalid preset structure: ${t}`),context:e})}const n=s.data,a=new Blob([JSON.stringify(n)],{type:"application/json"}),l=new File([a],"preset.json",{type:"application/json"});i(null),t.mutate(l)}catch(t){if(t instanceof SyntaxError)i({error:new globalThis.Error(`Invalid JSON: ${t.message}`),context:e});else if(t instanceof mt.G){const r=t.issues.map(e=>{const t=e.path.join(".");return`${t?`${t}: `:""}${e.message}`}).join("; ");i({error:new globalThis.Error(`Invalid preset structure: ${r}`),context:e})}else i({error:t instanceof globalThis.Error?t:new globalThis.Error(String(t)),context:e})}})(s),children:(0,c.__)("Import","search-regex")})}),d&&(0,_.jsx)(Ke,{})]})]})},Is=function({onClose:e,children:t,className:r}){return(0,_.jsx)(St,{className:"wpl-click-outside",onOutside:t=>{t.target instanceof HTMLElement&&t.target.classList.contains("wpl-modal_main")&&e()},children:(0,_.jsxs)("div",{className:(0,S.A)("wpl-modal_content",r),children:[(0,_.jsx)("div",{className:"wpl-modal_close",children:(0,_.jsx)("button",{type:"button",onClick:e,children:"✖"})}),t]})})},Es="wpl-modal_shown",Ts=function({padding:e=!0,onClose:t,...r}){const s=(0,n.useCallback)(e=>{"Escape"===e.key&&t()},[t]);(0,n.useEffect)(()=>(document.body.classList.add(Es),document.addEventListener("keydown",s),()=>{document.body.classList.remove(Es),document.removeEventListener("keydown",s)}),[s]);const a=(0,S.A)({"wpl-modal_wrapper":!0,"wpl-modal_wrapper-padding":e});return(0,_.jsxs)("div",{className:a,children:[(0,_.jsx)("div",{className:"wpl-modal_backdrop"}),(0,_.jsx)("div",{className:"wpl-modal_main",children:(0,_.jsx)(Is,{onClose:t,...r})})]})},Ms=e=>(0,s.createPortal)((0,_.jsx)(Ts,{...e}),Ct("wpl-modal")||document.body),Ys=function({isOpen:e=!1}){return e?(0,_.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",role:"img","aria-hidden":"true",focusable:"false",children:(0,_.jsx)("path",{d:"M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"})}):(0,_.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24",role:"img","aria-hidden":"true",focusable:"false",children:(0,_.jsx)("path",{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})})},Ls=function({menu:e,align:t="right",disabled:r=!1}){return(0,_.jsx)(Rt,{align:t,hasArrow:!0,renderToggle:(e,t)=>(0,_.jsx)("button",{type:"button",className:"wpl-dropdownmenu",onClick:e=>t(e.nativeEvent),disabled:r,children:(0,_.jsx)(Ys,{isOpen:e})}),renderContent:t=>(0,_.jsx)("ul",{className:"wpl-dropdownmenu__menu",role:"menu",tabIndex:-1,onClick:t,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),t())},children:e.map((e,t)=>(0,_.jsx)("li",{children:e},t))})})},Vs=function(){const{data:e=[],isLoading:t}=De(),r=Ee(e=>e.currentPreset),s=Ee(e=>e.setCurrentPreset),a=Ar(e=>e.search),o=Ar(e=>e.setSearch),i=Ar(e=>e.isBusy),u=function(){const e=(0,l.jE)(),t=H(e=>e.addNotice),r=H(e=>e.addError);return(0,z.n)({mutationFn:async({name:e,searchValues:t})=>{const r=await ae(oe("search-regex/v1/preset",{...t,name:e}));return Se.parse(r)},onSuccess:r=>{e.setQueryData(Fe,r.presets),t((0,c.__)("Preset saved","search-regex"))},onError:e=>{r(e)}})}(),d=Ie(),[h,p]=(0,n.useState)(!1),[g,x]=(0,n.useState)(""),m=t?br:"",f=[{label:(0,c.__)("Saving preset","search-regex"),value:""}],v=[{label:(0,c.__)("No preset","search-regex"),value:""},...e.map(e=>({label:e.name.substring(0,50),value:e.id}))],b=[];return r&&r.id||b.push((0,_.jsx)("button",{type:"button",onClick:e=>{e.preventDefault(),p(!0),x("")},children:(0,c.__)("Save search as new preset","search-regex")},"save-new")),r&&r.id&&b.push((0,_.jsx)("button",{type:"button",onClick:t=>{t.preventDefault(),r&&r.id&&((t,r)=>{const s=e.find(e=>e.id===t);s&&d.mutate({...s,...r})})(r.id,{search:a})},children:(0,c.__)("Update current preset","search-regex")},"update")),(0,_.jsxs)("div",{className:"searchregex-saved",children:[h&&(0,_.jsxs)(Ms,{onClose:()=>p(!1),className:"searchregex-preset__name",children:[(0,_.jsx)("h2",{children:(0,c.__)("Saving Preset","search-regex")}),(0,_.jsx)("p",{children:(0,c.__)("Enter a name for your preset","search-regex")}),(0,_.jsxs)("form",{onSubmit:e=>{var t,r;e.preventDefault(),e.stopPropagation(),t=g,r=a,u.mutate({name:t,searchValues:r}),p(!1),x("")},children:[(0,_.jsx)("input",{type:"text",name:"name",value:g,onChange:e=>x(e.target.value),placeholder:(0,c.__)("Enter preset name","search-regex")}),(0,_.jsx)("button",{className:"button button-primary",disabled:0===g.length,children:(0,c.__)("Save","search-regex")}),(0,_.jsx)("button",{className:"button button-secondary",onClick:()=>p(!1),type:"button",children:(0,c.__)("Cancel","search-regex")})]})]}),(0,_.jsx)(j,{name:"saved-search",value:r?.id??"0",disabled:m===br||i,items:m===br?f:v,onChange:t=>{(e=>{s(e??null);const t=rr(e??null);o(t)})(e.find(e=>e.id===t.target.value))}}),(0,_.jsx)(Ls,{menu:b,align:"left",disabled:m===br})]})},$s=function(){const e=Ar(e=>e.search),t=Ar(e=>e.setSearch),r=Ar(e=>e.isBusy),s=Ar(e=>e.mode),n=Ee(e=>e.currentPreset),a=Kt(n?n.tags:[]);return(0,_.jsx)("table",{children:(0,_.jsxs)("tbody",{children:["advanced"===s&&(0,_.jsxs)("tr",{className:(0,S.A)(a),children:[(0,_.jsx)("th",{children:(0,c.__)("Preset","search-regex")}),(0,_.jsx)("td",{children:(0,_.jsx)(Vs,{})})]}),(0,_.jsx)(vs,{search:e,onSetSearch:t,isBusy:r,preset:n})]})})};function Us(e,t){return t.label?t.label:parseInt(t.value,10)}function qs(e,t,r){return"delete"===e?{...t,type:"delete"}:"replace"===e?{type:"replace",value:t.context||t.value,value_label:t.context||t.value,replacement:r,replacement_label:r}:t}function Bs(e,t){return{key:qs(t.type,e.key,t.key),value:qs(t.type_value,e.value,t.value)}}function Ks(e,t,r){if("integer"===r.type&&!isNaN(parseInt(t.value||"",10))&&parseInt(e.value,10)!==parseInt(t.value||"",10))return{type:"replace",replacement_value:parseInt(t.value||"",10),replacement_label:Us(0,t)};if("member"===r.type&&t.values&&t.values[0]!==e.value&&"api"!==r.api){const e=Array.isArray(r.api)?r.api:[],s=t.values?.[0],n=s?e.find(e=>e.value===s):void 0;return{type:"replace",replacement_value:s||"",replacement_label:n?.label||s||""}}if("date"===r.type&&t.value)return{type:"replace",replacement_value:t.value.toDateString()+" "+t.value.toLocaleTimeString(),replacement_label:t.value.toDateString()+" "+t.value.toLocaleTimeString()};if("string"===r.type&&void 0!==t.replaceValue){if("string"===e.type&&!t.matchesOnly)return{};if(t.originalValue&&t.originalValue.replace(/\r\n/g,"\n").trim()===t.replaceValue.replace(/\r\n/g,"\n").trim())return{};if(e.value===t.replaceValue)return{};if(t.matchesOnly){const r=e.matches?.map(e=>({...e,replacement:t.replaceValue||""})),s={value:e.value};return void 0!==e.type&&(s.type=e.type),void 0!==e.value_label&&(s.value_label=e.value_label),void 0!==r&&(s.matches=r),s}return""===t.replaceValue?{type:"delete"}:{...e,type:"replace",replacement:t.replaceValue,replacement_label:t.replaceValue}}return{}}function Gs(e,t,r){if(!t)return e;const s=function(e,t,r){if("member"===r.type&&"api"===r.api){const r=e.filter(e=>"empty"!==e.type).filter(e=>-1===t.values?.indexOf(e.value)),s=e.filter(e=>-1!==t.values?.indexOf(e.value)).filter(e=>"empty"!==e.type),n=(t.values||[]).map((e,r)=>!s.find(t=>t.value===e)&&{type:"add",value:e,value_label:t.label&&t.label[r]||e}).filter(Boolean);return[...s,...r.map(e=>({type:"delete",value:e.value,value_label:e.value_label})),...n].map((e,t)=>({...e,context_id:t}))}if("keyvalue"===r.type&&t.items){const r=t.items||[];return e.map((e,t)=>{const s=r[t];return{...e,...0!==r.length&&s?Bs(e,s):{}}}).concat(r.slice(e.length).map((t,r)=>({type:"keyvalue",context_id:e.length+r,key:{type:"add",value:t.key,value_label:t.key},value:{type:"add",value:t.value,value_label:t.value}})))}if("string"===r.type&&!t.matchesOnly&&e.length>0&&"string"===e[0].type){const s=e[0],n=t.originalValue?t.originalValue:s.context,a={type:"string",context:n,value:n,value_label:n,context_id:s.context_id??e.length,hasMultiple:!0,value_type:s.value_type,value_length:n.length+1,...s.matches?{matches:s.matches}:{},...void 0!==s.match_count?{match_count:s.match_count}:{},...s.crop?{crop:s.crop}:{},...s.search?{search:s.search}:{}};return[{...a,...Ks(a,t,r)}]}return e}(e.contexts.map(e=>({...e,...Ks(e,t,r)})),t,r);return{...e,context_count:s.length,contexts:s}}const Ws=function(){return(0,_.jsx)("div",{className:"searchregex-result__more",children:(0,c.__)("Maximum number of matches exceeded and hidden from view. These will be included in any replacements.","search-regex")})};function Hs(e){return"php"===e?(0,c.__)("Serialized PHP","search-regex"):"json"===e?(0,c.__)("JSON","search-regex"):"blocks"===e?(0,c.__)("Blocks","search-regex"):"html"===e?(0,c.__)("HTML","search-regex"):null}const Js=function(e){const{column:t,schema:r,setReplacement:s,replacement:n,toggle:a,disabled:l,canEdit:o,source:i,context:u}=e,{column_label:d}=t,h="keyvalue"===u.type?u.value:u,p=h.value_type?Hs(h.value_type):null;return(0,_.jsxs)("button",{type:"button",className:(0,S.A)("searchregex-match__column","searchregex-match__column__"+u.type,l||!o?"searchregex-match__column__disabled":null),title:p?(0,c.__)("This column contains special formatting. Modifying it could break the format.","search-regex"):(0,c.__)("Click to replace column","search-regex"),onClick:function(){if(l||!o)return;const e=r.columns.find(e=>e.column===t.column_id),c=lr(t,e||null,i);s(null===n?c:null),a&&a()},children:[d,p&&(0,_.jsx)("div",{className:"searchregex-match__column__type",children:p})]})},zs=({className:e,children:t,onSubmit:r})=>(0,_.jsx)("form",{className:e,onSubmit:function(e){e.preventDefault(),r()},children:t});function Qs({schema:e,replacement:t,disabled:r,setReplacement:s,fetchData:n}){return(0,_.jsx)(ts,{schema:e,disabled:r,item:t,fixOperation:"set",onChange:s,fetchData:n})}function Xs({schema:e,replacement:t,disabled:r,setReplacement:s}){return(0,_.jsx)(rs,{schema:e,disabled:r,item:t,fixOperation:"set",onChange:s,fetchData:()=>Promise.resolve()})}function Zs(e){return"string"!==e.type&&e.value.length!==e.value_length}function en({schema:e,replacement:t,setReplacement:r,context:s,loadColumn:a}){const l=t&&"object"==typeof t&&"replaceValue"in t&&void 0!==t.replaceValue?t.replaceValue:s.value,o=t?.matchesOnly??!1,i=t?.hasMultiple??function(e){return!!e.hasMultiple||void 0!==e.matches}(s),[u,d]=(0,n.useState)(Zs(s)),[h,p]=(0,n.useState)(s.value),g=(0,n.useRef)(void 0),x=(0,n.useRef)(!1),m=(0,n.useRef)(!1),f=(0,n.useRef)(`matches-only-${Math.random().toString(36).slice(2)}`);return(0,n.useEffect)(()=>{Zs(s)&&(m.current||(m.current=!0,d(!0),a().then(e=>{r({replaceValue:e.value,originalValue:e.value}),p(e.value),d(!1)})))},[]),(0,n.useEffect)(()=>{if(!u&&!x.current)if(t&&"object"==typeof t&&"replaceValue"in t&&void 0!==t.replaceValue&&""!==t.replaceValue)x.current=!0;else if(x.current=!0,o&&void 0!==s.search)r({replaceValue:s.search,searchValue:s.search});else{const e=h||s.value;void 0!==e&&r({replaceValue:e})}},[u]),(0,n.useEffect)(()=>{if(u)return;const e=void 0!==g.current&&g.current!==o;if(g.current=o,e)if(o)void 0!==s.search&&r({replaceValue:s.search,searchValue:s.search});else{const e=h||s.value;void 0!==e&&r({replaceValue:e})}},[o,u]),u?(0,_.jsx)(Os,{}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("div",{className:"searchregex-modify__string__row",children:!e.multiline||s.forceSingle||o?(0,_.jsx)("input",{type:"text",value:l||"",onChange:e=>r({replaceValue:e.target.value}),placeholder:(0,c.__)("Enter replacement","search-regex")}):(0,_.jsx)("textarea",{value:l||"",onChange:e=>r({replaceValue:e.target.value})})}),i&&(0,_.jsx)("p",{className:"searchregex-modify__string__row",children:(0,_.jsxs)("label",{htmlFor:f.current,children:[(0,_.jsx)("input",{id:f.current,type:"checkbox",value:o?"true":"false",onChange:e=>{const t=e.target.checked,n={matchesOnly:t,operation:t?"replace":"set"};t?(void 0!==s.search&&(n.searchValue=s.search,n.replaceValue=s.search),void 0!==s.flags&&(n.searchFlags=s.flags)):(n.searchValue=null,n.searchFlags=null,void 0!==h&&(n.replaceValue=h)),r(n)}})," ",(0,c.__)("Apply to matches only","search-regex")]})})]})}function tn({schema:e,replacement:t,disabled:r,setReplacement:s,fetchData:n,column:a}){return(0,_.jsx)(cs,{schema:e,disabled:r,item:t,fixOperation:"set",onChange:s,fetchData:n,localLabels:a.contexts.map(e=>({value:a.column_id+"_"+e.value,label:e.value_label}))})}function rn(e){return e.context?e.context:e.value||""}function sn({disabled:e,item:t,onChange:r,onAdd:s,onDelete:a,type:l,original:o,isNew:i=!1}){const[u,d]=(0,n.useState)([]),h=Hs(t.value_type||"");return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)("div",{className:"searchregex-filter__keyvalue__item",children:[(0,_.jsx)("span",{children:(0,c.__)("Meta Key","search-regex")}),(0,_.jsx)("input",{type:"text",value:t.key,disabled:e||"delete"===t.type,placeholder:"add"===t.type?(0,c.__)("New meta key","search-regex"):"",onChange:e=>r({key:e.target.value,type:o&&rn(o.key)===e.target.value?"value":l})}),"add"===l&&i&&(0,_.jsx)(Lt,{onClick:s,children:(0,c.__)("Add","search-regex")}),"add"===l&&!i&&(0,_.jsx)(Lt,{onClick:()=>a(),children:(0,c.__)("Delete","search-regex")}),"add"!==l&&(0,_.jsx)("input",{type:"checkbox",disabled:e,onChange:e=>a(e.target.checked),checked:"delete"!==t.type})]}),(0,_.jsxs)("div",{className:"searchregex-filter__keyvalue__item searchregex-filter__keyvalue__item__value",children:[(0,_.jsx)("span",{children:(0,c.__)("Meta Value","search-regex")}),-1===u.indexOf("multi")?(0,_.jsx)("input",{type:"text",value:t.value,disabled:e||"delete"===t.type,onChange:e=>r({value:e.target.value,type_value:o&&rn(o.value)===e.target.value?"value":l}),placeholder:"add"===t.type?(0,c.__)("New meta value","search-regex"):""}):(0,_.jsx)("textarea",{value:t.value,disabled:e||"delete"===t.type,onChange:e=>r({value:e.target.value,type_value:o&&rn(o.value)===e.target.value?"value":l}),placeholder:"add"===t.type?(0,c.__)("New meta value","search-regex"):""}),(0,_.jsx)(Yr,{flags:u,disabled:e||"delete"===t.type,onChange:d,allowRegex:!1,allowMultiline:!0,allowCase:!1})]}),h&&(0,_.jsx)("div",{className:"searchregex-list__encoded",children:h})]})}function nn({schema:e,replacement:t,disabled:r,setReplacement:s,column:a,loadColumn:l}){const[c,o]=(0,n.useState)(!0),[i,u]=(0,n.useState)(null);if((0,n.useEffect)(()=>{l().then(e=>{e?(s({items:e.items.map(e=>{const t={type:"value",key:e.key,value:e.value};return void 0!==e.value_type&&(t.value_type=e.value_type),t})}),u({type:"add",key:"",value:"",type_value:"add"})):s({items:[]}),o(!1)})},[]),c)return(0,_.jsx)(Os,{});function d(e,r){const n=t.items[e];if(!n)return;const a={...n};void 0!==r.type&&(a.type=r.type),void 0!==r.key&&(a.key=r.key),void 0!==r.value&&(a.value=r.value),void 0!==r.value_type&&(a.value_type=r.value_type),void 0!==r.type_value&&(a.type_value=r.type_value),s({items:[...t.items.slice(0,e),a,...t.items.slice(e+1)]})}return(0,_.jsxs)(_.Fragment,{children:[t.items.map((e,n)=>{const l=a.contexts[n];return(0,_.jsx)(sn,{disabled:r,item:e,onChange:e=>d(n,e),type:"add"===e.type?"add":"replace",onDelete:e=>function(e,r){const n=t.items[e];if(n)if("add"===n.type)s({items:[...t.items.slice(0,e),...t.items.slice(e+1)]});else{const t=a.contexts[e];t&&d(e,{key:t.key.value,value:t.value.value,type:r?"value":"delete",type_value:r?"value":"delete"})}}(n,e),...void 0!==l&&{original:l}},n)}),i&&(0,_.jsx)(sn,{disabled:r,item:i,type:"add",isNew:!0,onChange:e=>u({...i,...e}),onAdd:function(){i&&(s({items:[...t.items,i]}),u({type:"add",key:"",value:"",type_value:"add"}))},onDelete:()=>{}})]})}const an=function(e){const{type:t}=e.schema;return"integer"===t?(0,_.jsx)(Qs,{...e}):"date"===t?(0,_.jsx)(Xs,{...e}):"string"===t?(0,_.jsx)(en,{...e}):"member"===t?(0,_.jsx)(tn,{...e}):"keyvalue"===t?(0,_.jsx)(nn,{...e}):null};function ln({disabled:e,schema:t,column:r,setReplacement:s,replacement:a,rowId:l,source:c,context:o}){const i=(0,n.useCallback)(e=>ae(Ze(c,r.column_id,e)),[c,r.column_id]),u=(0,n.useCallback)(async()=>(await ae(et(c,l))).result.find(e=>e.column===r.column_id),[c,l,r.column_id]),d=s;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("h5",{children:r.column_label}),(0,_.jsx)("div",{className:"searchregex-modify searchregex-modify__"+t.type,children:(0,_.jsx)(an,{disabled:e,schema:t,column:r,fetchData:i,context:o,setReplacement:d,replacement:a,loadColumn:u})})]})}const cn=function(e){const{setReplacement:t,replacement:r,canReplace:s,context:a,onSave:l,source:o,description:i,className:u,column:d,schema:h,onCancel:p,rowId:g}=e,x=(0,n.useRef)(null);return(0,n.useEffect)(()=>{setTimeout(()=>{if(x.current){const e=x.current.querySelector("input[type=text],textarea");e&&(e.focus(),e.select())}},50)},[x]),(0,_.jsx)("div",{className:"searchregex-replace__form",ref:x,children:(0,_.jsxs)(zs,{onSubmit:()=>l(r),...u?{className:u}:{},children:[(0,_.jsx)(ln,{schema:h,column:d,disabled:!1,setReplacement:t,replacement:r,source:o,context:a,rowId:g}),(0,_.jsxs)("div",{className:"searchregex-replace__action",children:[i&&(0,_.jsx)("p",{children:i}),(0,_.jsxs)("p",{className:"searchregex-replace__actions",children:[(0,_.jsx)("input",{type:"submit",className:"button button-primary",value:(0,c.__)("Replace","search-regex"),disabled:!s}),(0,_.jsx)("input",{type:"button",className:"button button-secondary",value:(0,c.__)("Cancel","search-regex"),onClick:p})]})]})]})})};function on(){const e=H(e=>e.addError),t=Ar(e=>e.appendExportData);return(0,z.n)({mutationFn:async e=>{const r=await ae(oe("search-regex/v1/search",e));if("export"===e.action&&e.save){const e=_e.parse(r);return t(e.results),{...e,results:[]}}return me.parse(r)},onError:t=>{e(t)}})}function un(){const e=H(e=>e.addError),t=Ar(e=>e.search),r=Ar(e=>e.setResults);return(0,z.n)({mutationFn:async({replacement:e,rowId:r})=>{const s=await ae(oe(`search-regex/v1/source/${e.source}/row/${r}`,{...t,replacement:e}));return ve.parse(s)},onMutate:async({rowId:e})=>({previousResults:[...Ar.getState().results],rowId:String(e)}),onSuccess:(e,{rowId:t})=>{const s=Ar.getState().results,n=String(t),a=s.map(t=>String(t.row_id)===n?{...e.result,row_id:String(e.result.row_id)}:t);r(a)},onError:(t,s,n)=>{n?.previousResults&&r(n.previousResults),e(t)}})}const dn=function(e){const{column:t,schema:r,replacement:s,save:n,disabled:a,source:l,rowId:o,children:i,context:u}=e,d=function(e,t,r){return!(null===e||e.column!==t.column_id||("integer"===r.type?isNaN(parseInt(e.value||"",10))||parseInt(t.contexts[0].value,10)===parseInt(e.value||"",10):"member"===r.type?!e.values||e.values[0]===t.contexts[0].value:"keyvalue"===r.type&&e.items?!e.items.find(e=>function(e){return"value"!==e.type||"value"!==e.type_value}(e)):"string"===r.type?0===t.contexts.length?void 0===e.replaceValue||""===e.replaceValue:e.originalValue&&e.originalValue===e.replaceValue||void 0===e.replaceValue||e.replaceValue===(t.contexts[0].value||t.contexts[0].search):"date"!==r.type||void 0===e.value))}(s,t,r),h=un();return(0,_.jsxs)("div",{className:"searchregex-match searchregex-match__list",children:[(0,_.jsx)(Rt,{renderToggle:(e,c)=>(0,_.jsx)(Js,{column:t,schema:{name:"",type:"",columns:[r]},replacement:s,setReplacement:n,disabled:a,source:l,toggle:c,canEdit:!1!==r.modify,context:u}),hasArrow:!0,align:"centre",valign:"top",onClose:()=>n(null),renderContent:e=>(0,_.jsx)(cn,{setReplacement:n,replacement:s,context:u,canReplace:d,rowId:String(o),onSave:()=>function(e){e(),n(null),h.mutate({replacement:{...s,source:l},rowId:String(o)})}(e),onCancel:()=>{n(null),e()},column:t,schema:r,source:l,className:"searchregex-replace__modal inline-edit-row",description:Hs("keyvalue"===u.type?u.value.value_type:u.value_type)?(0,c.__)("Contains encoded data","search-regex"):""})}),i]})},hn=(e,t)=>" ".repeat(t.length);function pn(e,t){return e&&t.length>0?e.replace(/(\\?\$|\\?\\)+(\d{1,2})/g,(e,r,s)=>{if("\\$"===e.substring(0,2))return e.replace("\\","");const n=parseInt(s,10),a=t[n-1];return void 0!==a?a:e}):e}const gn=({match:e,originalMatch:t})=>null===e?(0,_.jsx)("s",{children:t}):String(e).replace(/\n/g,"↵").replace(/^(\s+)/,hn).replace(/(\s+)$/,hn),xn=function(e){const{match:t,captures:r,replacement:s,rowId:a,canReplace:l,column:o,schema:i,onSave:u}=e,[d,h]=(0,n.useState)(null),p=[d?d.replaceValue:null,s,t].filter(e=>null!=e)[0]||t,g=function(e,t){return""===e?"delete":e!==t?"replace":"match"}(p,t),x=e=>{h(null),e&&e()};return(0,_.jsx)(Rt,{renderToggle:(e,s)=>(0,_.jsx)("button",{onClick:()=>function(e){const r=i.columns.find(e=>e.column===o);h({...lr(o,r||null,i.source||""),replaceValue:t,operation:"replace"}),e()}(s),title:(0,c.__)("Click to replace match","search-regex"),className:(0,S.A)({"searchregex-result__replaced":"replace"===g,"searchregex-result__highlight":"match"===g,"searchregex-result__deleted":"delete"===g}),type:"button",children:(0,_.jsx)(gn,{match:p?pn(""===p?t:p,r):null,originalMatch:t})}),hasArrow:!0,onClose:x,align:"centre",valign:"bottom",renderContent:e=>{const r=i.columns.find(e=>e.column===o);return(0,_.jsx)(cn,{setReplacement:e=>h({...d||{},...e}),replacement:d,canReplace:l,onCancel:()=>x(e),onSave:()=>function(e){d&&u(d),x(e)}(e),column:{column_id:r?.column||o,column_label:r?.column||o},schema:r||{type:"string"},rowId:String(a),context:{value:t,type:"string",forceSingle:!0},className:"searchregex-replace__modal inline-edit-row",source:i.source||""})}})};function mn(e){const{beforePhrase:t,onReplace:r,column:s,schema:n,rowId:a}=e,{match:l,pos_id:c,captures:o,replacement:i}=e.match;return(0,_.jsxs)(_.Fragment,{children:[t,(0,_.jsx)(xn,{onSave:e=>r({...e,searchValue:l,posId:c,source:n.source||""}),match:l,replacement:i,captures:o,canReplace:!0,column:s,schema:n,rowId:a})]})}const fn=function(e){const{matches:t,count:r,source:s,column:n,schema:a,className:l,rowId:c,crop:o={}}=e,i=un();let u=0;const d=e=>{i.mutate({replacement:e,rowId:String(c)})};return(0,_.jsxs)("div",{className:(0,S.A)("searchregex-match__context",l),children:[t.map((e,t)=>{const r=u;return u=e.context_offset+e.match.length,(0,_.jsx)(mn,{match:e,onReplace:d,beforePhrase:(0,_.jsxs)(_.Fragment,{children:[o.start&&o.start>0&&0===t&&(0,_.jsx)(_.Fragment,{children:"… "}),s.substring(r,e.context_offset)]}),column:n,schema:a,rowId:c},e.pos_id)}),s.substring(u),o.end&&o.end>0&&(0,_.jsx)(_.Fragment,{children:" …"}),t.length!==r&&(0,_.jsx)(Ws,{})]})},vn=500,jn=function(e){const{context:t,rowId:r,column:s,schema:n,setReplacement:a,className:l}=e;e.setReplacement;const{type:o}=t,i=t.value_label||t.context||"",u=t.replacement_label||"";if("replace"===o){const e=i.length>100||u.length>100;return(0,_.jsxs)("div",{className:(0,S.A)("searchregex-list-replace",e&&"searchregex-list-replace__vertical",l),children:[(0,_.jsxs)(Ft,{className:"searchregex-list__delete",children:[i.substring(0,vn)||(0,c.__)("No value","search-regex"),i.length>vn&&(0,_.jsx)("span",{children:"..."})]}),(0,_.jsx)("span",{className:(0,S.A)("dashicons",{"dashicons-arrow-right-alt":!e,"dashicons-arrow-down-alt":e,"searchregex-list-replace__break":e})}),0===u.length?(0,_.jsx)("span",{className:(0,S.A)("searchregex-list__value","searchregex-list__novalue",l),children:(0,c.__)("Empty value","search-regex")}):(0,_.jsxs)(Ft,{className:"searchregex-list__add",children:[u.substring(0,vn),u.length>vn&&(0,_.jsx)("span",{children:"..."})]})]})}if("empty"===o||"value"===o&&0===i.length)return(0,_.jsx)("span",{className:(0,S.A)("searchregex-list__value","searchregex-list__novalue",l),children:(0,c.__)("No value","search-regex")});if("value"===o)return(0,_.jsxs)("div",{className:(0,S.A)(l),children:[i.substring(0,vn),i.length>vn&&(0,_.jsx)("span",{children:"..."})]});if("string"===o){const e=n.source||"";return(0,_.jsx)(fn,{source:t.context||"",crop:t.crop,matches:t.matches||[],count:t.match_count||0,rowId:Number(r),column:s.column_id,schema:{name:"",type:e,columns:[n],source:e},...void 0!==l?{className:l}:{}})}return(0,_.jsx)(Ft,{className:(0,S.A)("searchregex-list__"+o,l),children:i})},bn=function e({context:t,rowId:r,column:s,schema:n,setReplacement:a,className:l}){return"keyvalue"===t.type?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(e,{rowId:r,column:s,schema:n,setReplacement:a,context:t.key,className:"searchregex-list__key"}),"=",(0,_.jsx)(e,{rowId:r,column:s,schema:n,setReplacement:a,context:t.value,className:"searchregex-list__value"})]}):(0,_.jsx)(_.Fragment,{children:(0,_.jsx)(jn,{context:t,rowId:r,column:s,schema:n,setReplacement:a,...void 0!==l?{className:l}:{}})})};function yn({context:e}){const t=Hs("keyvalue"===e.type?e.value.value_type:e.value_type);return"string"!==e.type&&t?(0,_.jsx)(Ft,{children:t}):null}const wn=function(e){const{rowId:t,source:r}=e,s={...e.schema,source:r},[a,l]=(0,n.useState)(null),[o,i]=(0,n.useState)(!1),u=Gs(e.column,a,s),{contexts:d,context_count:h}=u,p=0===d.length?[{type:"empty",context_id:0}]:d.slice(0,o?d.length:2),g=d.length-p.length;function x(e,t){l(null===e?null:r=>({...r||{},...e,...t?{label:t}:{}}))}return 1===p.length?(0,_.jsx)(dn,{replacement:a,save:x,...e,context:p[0],children:(0,_.jsx)(bn,{rowId:t,column:u,schema:s,setReplacement:l,context:p[0]})}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(dn,{replacement:a,save:x,...e,context:p[0]}),(0,_.jsx)("ul",{className:"searchregex-match__contexts",children:p.map(e=>(0,_.jsxs)("li",{children:[(0,_.jsx)(yn,{context:e}),(0,_.jsx)(bn,{rowId:t,column:u,schema:s,setReplacement:l,context:e},e.context_id)]},e.context_id))}),!o&&d.length>2&&(0,_.jsx)("p",{children:(0,_.jsx)("button",{className:"button button-secondary",onClick:()=>i(!0),type:"button",children:/* translators: %s: number of results to show */ /* translators: %s: number of results to show */(0,c.sprintf)((0,c._n)("Show %s more","Show %s more",g,"search-regex"),new Intl.NumberFormat(SearchRegexi10n.locale).format(g))})}),o&&d.length!==h&&(0,_.jsx)(Ws,{})]})},Sn=function({view:e,title:t}){const r=t||(0,c.__)("No title","search-regex");return e?(0,_.jsx)(R,{url:e,children:r}):r},Cn=function(e){const{result:t,disabled:r}=e,{actions:s,source_type:n,row_id:a}=t,l=function(){const e=H(e=>e.addError);return(0,z.n)({mutationFn:async({source:e,rowId:t})=>{const r=await ae(oe(`search-regex/v1/source/${e}/row/${t}/delete`));return fe.parse(r)},onError:t=>{e(t)}})}(),o=Ar(e=>e.results),i=Ar(e=>e.setResults),u=[],d={edit:(0,c.__)("Edit","search-regex"),view:(0,c.__)("View","search-regex")},h=Object.keys(s);for(let e=0;e<h.length;e++){const t=h[e];if(!t)continue;const r=s[t],n=d[t];n&&r&&u.push((0,_.jsx)(R,{url:r,children:n},t))}return u.push((0,_.jsx)("button",{type:"button",onClick:function(e){e.preventDefault(),confirm((0,c.__)("Are you sure you want to delete this database row?","search-regex"))&&l.mutate({source:n,rowId:a},{onSuccess:()=>{i(o.filter(e=>e.row_id!==a))}})},className:"button-link",children:(0,c.__)("Delete database row","search-regex")},"delete")),(0,_.jsx)("div",{className:"row-actions",children:r?(0,_.jsx)(_.Fragment,{children:" "}):u.reduce((e,t,r)=>0===r?[t]:[...e," | ",t],[])})};function kn(e,t,r){if(!r)return t;if(e&&e.length>0&&"global"===e[0]?.column){const s=r?.columns.find(e=>e.column===t.column_id);if(s&&s.global){const s=r?.columns.find(e=>e.column===t.column_id);if(s)return Gs(t,e[0],s)}}const s=e.find(e=>e.column===t.column_id);if(s){const e=r.columns.find(e=>e.column===t.column_id);return Gs(t,s,e)}return t}const Nn=function(e){const{result:t}=e,r=Ar(e=>e.replacing),s=Ar(e=>e.search),n=Ar(e=>e.schema),{columns:a,actions:l,row_id:c,source_name:o,source_type:i,title:u}=t,d=-1!==r.indexOf(c),h=function({action:e,actionOption:t,replacement:r}){return"modify"===e?t:"replace"===e?[{column:"global",operation:"replace",value:r}]:[]}(s),p=er(n,i);return p?(0,_.jsxs)("tr",{className:(0,S.A)("searchregex-result",{"searchregex-result__updating":d}),children:[(0,_.jsx)("td",{className:"searchregex-result__table",children:(0,_.jsx)("span",{title:i,children:o})}),(0,_.jsx)("td",{className:"searchregex-result__row",children:c}),(0,_.jsxs)("td",{className:"searchregex-result__match",children:[(0,_.jsx)("h2",{children:(0,_.jsx)(Sn,{view:l.view,title:u})}),a.map(e=>{const t=tr(p.columns,e.column_id)||{column:e.column_id,title:e.column_id,type:"string"};return(0,_.jsx)(wn,{column:kn(h,e,p),rowId:c,disabled:d,schema:t,source:p.type},e.column_id)}),(0,_.jsx)(Cn,{result:t,disabled:d})]})]}):(0,_.jsxs)("tr",{className:(0,S.A)("searchregex-result",{"searchregex-result__updating":d}),children:[(0,_.jsx)("td",{className:"searchregex-result__table",children:(0,_.jsx)("span",{title:i,children:o})}),(0,_.jsx)("td",{className:"searchregex-result__row",children:c}),(0,_.jsxs)("td",{className:"searchregex-result__match",children:[(0,_.jsx)("h2",{children:u}),(0,_.jsxs)("p",{children:["Schema not found for ",i]})]})]})},Rn=function({columns:e}){const t=[];for(let r=0;r<e;r++)t.push((0,_.jsx)("td",{children:(0,_.jsx)(Os,{})},r));return(0,_.jsx)("tr",{children:t})},Pn=function({columns:e}){return(0,_.jsx)("tr",{children:(0,_.jsx)("td",{colSpan:e,children:(0,c.__)("No matching results found.","search-regex")})})},An=e=>{const{title:t,button:r,className:s,enabled:n,onClick:a}=e;return n?(0,_.jsxs)("a",{className:s+" button",href:"#",onClick:e=>{e.preventDefault(),a()},children:[(0,_.jsx)("span",{className:"screen-reader-text",children:t}),(0,_.jsx)("span",{"aria-hidden":"true",children:r})]}):(0,_.jsx)("span",{className:"tablenav-pages-navspan button disabled","aria-hidden":"true",children:r})},On=function(e){const t=Ar(e=>e.search),r=Ar(e=>e.searchDirection),s=Ar(e=>e.setResults),n=Ar(e=>e.setTotals),a=Ar(e=>e.setProgress),l=Ar(e=>e.setStatus),o=Ar(e=>e.setShowLoading),i=Ar(e=>e.setCanCancel),u=Ar(e=>e.setResultsDirty),d=on(),{progress:h,isLoading:p,matchedRows:g,perPage:x,noTotal:m=!1,total:f}=e,{current:v=0,previous:j,next:b}=h,y=Math.ceil(g/x),w=0===v?0:Math.floor(v/x),S=!1!==b&&w<y;function C(e){s([]),u(!1),o(!0),i(!0),l(br),d.mutate({...t,page:e,searchDirection:r||Sr},{onSuccess:e=>{s(Cr(e.results)),n(kr(e.totals)),a(Nr(e.progress)),l(e.status??wr),o(!1),i(!1)},onError:()=>{l(yr),o(!1),i(!1)}})}return(0,_.jsxs)("div",{className:"tablenav tablenav-pages",children:[m&&(0,_.jsx)("div",{children:" "}),!m&&(0,_.jsxs)("div",{className:"displaying-num",children:[/* translators: matches=number of matched rows, total=total number of rows */ /* translators: matches=number of matched rows, total=total number of rows */
(0,c.sprintf)((0,c.__)("Matched rows: %(matches)s out of %(total)s total.","search-regex"),{matches:new Intl.NumberFormat(SearchRegexi10n.locale).format(g),total:new Intl.NumberFormat(SearchRegexi10n.locale).format(f)})," "]}),(0,_.jsxs)("div",{className:"pagination-links",children:[(0,_.jsx)(An,{title:(0,c.__)("First page","search-regex"),button:"«",className:"first-page",enabled:!1!==j&&!p,onClick:()=>C(0)}),(0,_.jsx)(An,{title:(0,c.__)("Prev page","search-regex"),button:"‹",className:"prev-page",enabled:!1!==j&&!p,onClick:()=>C(j)}),(0,_.jsx)("span",{className:"tablenav-paging-text",children:(0,c.sprintf)(/* translators: current=current page, total=total number of pages */ /* translators: current=current page, total=total number of pages */
(0,c.__)("Page %(current)s of %(total)s","search-regex"),{current:new Intl.NumberFormat(SearchRegexi10n.locale).format(w+1),total:new Intl.NumberFormat(SearchRegexi10n.locale).format(y)})}),(0,_.jsx)(An,{title:(0,c.__)("Next page","search-regex"),button:"›",className:"next-page",enabled:S&&!p,onClick:()=>C(b)}),(0,_.jsx)(An,{title:(0,c.__)("Last page","search-regex"),button:"»",className:"last-page",enabled:S&&!p,onClick:()=>C((y-1)*x)})]})]})},Fn=(e,t)=>!1===t?100:t/e*100,Dn=(e,t)=>!1===t||0===t?0:t/e*100;function In(e){const t=Ar(e=>e.search),r=Ar(e=>e.results),s=Ar(e=>e.cumulativeMatchedRows),n=Ar(e=>e.setResults),a=Ar(e=>e.setTotals),l=Ar(e=>e.setProgress),o=Ar(e=>e.setStatus),i=Ar(e=>e.setShowLoading),u=Ar(e=>e.setCanCancel),d=Ar(e=>e.setResultsDirty),h=Ar(e=>e.setSearchDirection),p=Ar(e=>e.addToCumulativeMatchedRows),g=Ar(e=>e.setCumulativeMatchedRows),x=on(),{total:m,progress:f,isLoading:v,searchDirection:j,noTotal:b=!1,totals:y}=e,{previous:w=!1,next:S=!1}=f;return(0,_.jsxs)("div",{className:"tablenav tablenav-pages",children:[b&&(0,_.jsx)("div",{children:" "}),!b&&(0,_.jsxs)("div",{className:"displaying-num",children:[(0,c.sprintf)(/* translators: %s: total number of rows searched */ /* translators: %s: total number of rows searched */
(0,c._n)("%s database row in total","%s database rows in total",m,"search-regex"),new Intl.NumberFormat(SearchRegexi10n.locale).format(m))," — ",(0,c.sprintf)(/* translators: %(searched)s: number of rows matched */ /* translators: %(searched)s: number of rows matched */
(0,c.__)("matched rows = %(searched)s","search-regex"),{searched:new Intl.NumberFormat(SearchRegexi10n.locale).format(y.matched_rows)})]}),(0,_.jsxs)("div",{className:"pagination-links",children:[(0,_.jsx)(An,{title:(0,c.__)("First page","search-regex"),button:"«",className:"first-page",enabled:s>0&&!1!==w&&!v,onClick:function(){g(0),n([]),d(!1),i(!0),u(!0),h(Sr),o(br),x.mutate({...t,page:0,searchDirection:Sr},{onSuccess:e=>{n(Cr(e.results)),a(kr(e.totals)),l(Nr(e.progress)),o(e.status??wr),i(!1),u(!1)},onError:()=>{o(yr),i(!1),u(!1)}})}}),(0,_.jsx)("span",{className:"tablenav-paging-text",children:(0,c.sprintf)(/* translators: %current: current percent progress */ /* translators: %current: current percent progress */
(0,c.__)("Progress %(current)s%%","search-regex"),{current:j===Sr?Fn(m,S).toFixed(1):Dn(m,!1===S?w:S).toFixed(1)})}),(0,_.jsx)(An,{title:(0,c.__)("Next page","search-regex"),button:"›",className:"next-page",enabled:!1!==S&&!v,onClick:()=>{return e=S,s=Sr,p(r.length),n([]),d(!1),i(!0),u(!0),h(s),o(br),void x.mutate({...t,page:e,searchDirection:s},{onSuccess:e=>{n(Cr(e.results)),a(kr(e.totals)),l(Nr(e.progress)),o(e.status??wr),i(!1),u(!1)},onError:()=>{o(yr),i(!1),u(!1)}});var e,s}})]})]})}const En=function(e){const{totals:t,searchDirection:r,advanced:s,resultsDirty:n,progress:a,isLoading:l=!1,perPage:o=25,noTotal:i=!1}=e,{matched_rows:u,rows:d}=t;return(s?null!=u:null!=u&&0!==u||a.next||a.prev)?n?(0,_.jsx)("p",{className:"searchregex-resultsdirty",children:(0,c.__)("Your search conditions have changed. Please refresh to see the latest results.","search-regex")}):s?(0,_.jsx)(In,{total:d,progress:a,isLoading:l,searchDirection:r,noTotal:i,totals:t}):(0,_.jsx)(On,{progress:a,isLoading:l,matchedRows:u,perPage:o,noTotal:i,total:d}):(0,_.jsx)("div",{className:"tablenav tablenav-pages",children:(0,_.jsx)("div",{className:"displaying-num",children:" "})})};r(957);let Tn=0;function Mn(e,t,r,s,a){const l=(0,n.useRef)(s),c=(0,n.useRef)(a),o=(0,n.useRef)(e),i=(0,n.useRef)(t);(0,n.useEffect)(()=>{l.current=s,c.current=a},[s,a]),(0,n.useEffect)(()=>{o.current=e,i.current=t},[e,t]),(0,n.useEffect)(()=>{if(0===t||!e)return;if(t>1e3)return void c.current();const s=function(e,t,r=1.2){return e>3?Math.min(2e3,Math.round(t*e*r)):t}(t,r);!function(e){const t=(new Date).getTime();setTimeout(()=>{Tn=t,e()},t-Tn>500?0:500)}(()=>{0!==i.current&&o.current&&l.current(s)})},[e,r,t])}function Yn(e){return!1!==e&&!0!==e&&void 0!==e&&e}function Ln(e){return{next:Yn(e.next),previous:Yn(e.previous),...void 0!==e.current&&{current:e.current},...void 0!==e.rows&&{rows:e.rows}}}function Vn(e,t){const r=Yn(t.next),s=Yn(t.previous);return e===Sr&&!1!==r||"backward"===e&&!1!==s}const $n=function(){const e=Ar(e=>e.results),t=Ar(e=>e.totals),r=Ar(e=>e.progress),s=Ar(e=>e.isBusy),a=Ar(e=>e.search),l=Ar(e=>e.searchDirection),o=Ar(e=>e.resultsDirty),i=Ar(e=>e.cumulativeMatchedRows),u=Ar(e=>e.setResults),d=Ar(e=>e.setTotals),h=Ar(e=>e.setProgress),p=Ar(e=>e.setStatus),g=H(e=>e.addError),[x,m]=(0,n.useState)(0),f=on(),{perPage:v}=a,j=zt(a);(0,n.useEffect)(()=>{0===x&&j&&!s&&Vn(l??Sr,r)?m(1):0===e.length&&x>0&&!Vn(l??Sr,r)&&m(0)},[e.length,x,j,s,l,r]);const b=s,y=((e,t,r)=>e>0&&void 0!==r&&t.length<r)(x,e,v),w=Vn(l??Sr,r),C=j&&void 0!==v&&y&&w&&x>0,k=v??25,N=j?{...t,matched_rows:i+e.length}:t;return Mn(C,x,k,e=>{const t=Ar.getState().progress,r=Ar.getState().searchDirection,s=Ar.getState().results,n=Yn(t.next),c=Yn(t.previous);var o,i,g;o=r===Sr?n:c,i=e,g=k-s.length,!1!==o&&(p(br),f.mutate({...a,page:o,perPage:i,limit:g,searchDirection:l||Sr},{onSuccess:e=>{const t=[...Ar.getState().results,...Cr(e.results)];u(t),d(kr(e.totals));const r=Nr(e.progress);h(r);const s=j&&void 0!==v&&t.length<v&&Vn(l??Sr,r);p(s?br:e.status??wr),m(e=>e+1)}}))},()=>{p(yr),g((0,c.__)("Your search resulted in too many requests. Please narrow your search terms.","search-regex"))}),(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(En,{totals:N,perPage:v??25,isLoading:b,progress:Ln(r),searchDirection:l||Sr,advanced:j,resultsDirty:o}),(0,_.jsxs)("table",{className:(0,S.A)("wp-list-table","widefat","fixed","striped","items","searchregex-results"),children:[(0,_.jsx)("thead",{children:(0,_.jsxs)("tr",{children:[(0,_.jsx)("th",{className:"searchregex-result__table",children:(0,c.__)("Source","search-regex")}),(0,_.jsx)("th",{className:"searchregex-result__row",children:(0,c.__)("Row ID","search-regex")}),(0,_.jsx)("th",{className:"searchregex-result__match",children:(0,c.__)("Matched Content","search-regex")})]})}),(0,_.jsxs)("tbody",{children:[e.map(e=>(0,_.jsx)(Nn,{result:e},e.source_type+"-"+e.row_id)),b&&0===e.length&&(0,_.jsx)(Rn,{columns:3}),!b&&0===e.length&&(0,_.jsx)(Pn,{columns:3})]})]}),(0,_.jsx)(En,{totals:N,perPage:v??25,isLoading:b,progress:Ln(r),searchDirection:l||Sr,noTotal:!0,advanced:j,resultsDirty:o})]})};function Un(e,t,r){return"replace"===e&&null===r||"replace"===e&&null!==r&&r.length>0||"delete"===e||("modify"===e?void 0!==t.length&&t.length>0:"action"===e?void 0!==t.hook&&t.hook.length>0:"export"===e||"global"===e)}const qn=function(){const e=Ar(e=>e.search),t=Ar(e=>e.canCancel),r=Ar(e=>e.resultsDirty),s=Ar(e=>e.isBusy),n=Ar(e=>e.setStatus),a=Ar(e=>e.setResults),l=Ar(e=>e.clearExportData),o=Ar(e=>e.setTotals),i=Ar(e=>e.setProgress),u=Ar(e=>e.setIsSaving),d=Ar(e=>e.setCanCancel),h=Ar(e=>e.setReplaceAll),p=Ar(e=>e.mode),{action:g="",actionOption:x={},replacement:m=null}=e,f="simple"===p?"replace":g,v="simple"===p?{}:x,j=on();return(0,_.jsxs)("div",{className:"searchregex-search__action",children:[(0,_.jsx)(Lt,{isPrimary:!0,isSubmit:!0,disabled:s,name:"search",children:r?(0,c.__)("Refresh","search-regex"):(0,c.__)("Search","search-regex")}),""!==f&&(0,_.jsx)(Lt,{isDestructive:!0,disabled:!Un(f,v,m)||s,onClick:()=>{if("delete"===f&&!confirm((0,c.__)("Are you sure you want to delete all matching rows?","search-regex")))return;u(!0),d(!0),h(!0),n(br),i({next:!1}),l();const t="simple"===p?{...e,action:"replace",actionOption:{}}:e;j.mutate({...t,page:0,save:!0},{onSuccess:e=>{a(Cr(e.results)),o(kr(e.totals)),i(Nr(e.progress)),!1!==e.progress.next?n(br):(n(e.status??wr),d(!1),h(!1),"export"!==f&&u(!1))},onError:()=>{n(yr),u(!1),d(!1),h(!1)}})},children:(b=f,"delete"===b?(0,c.__)("Delete Matching Rows","search-regex"):"export"===b?(0,c.__)("Export Matches","search-regex"):"action"===b?(0,c.__)("Run Action","search-regex"):(0,c.__)("Replace All","search-regex"))}),s&&t&&(0,_.jsxs)(_.Fragment,{children:[" ",(0,_.jsx)(Lt,{isDestructive:!0,onClick:()=>{d(!1),u(!1),h(!1),n(null)},children:(0,c.__)("Cancel","search-regex")}),(0,_.jsx)(Ke,{})]})]});var b};var Bn=r(867),Kn=r(972);function Gn(e,t){const r=new Intl.NumberFormat(SearchRegexi10n.locale).format(t);return"delete"===e?(0,c.sprintf)((0,c._n)("%s row deleted.","%s rows deleted.",t,"search-regex"),r):(0,c.sprintf)((0,c._n)("%s row.","%s rows.",t,"search-regex"),r)
/* translators: %s: number of rows */}function Wn({totals:e,current:t}){const{custom:r=[]}=e;return r.length>0?(0,_.jsx)(_.Fragment,{children:r.map(e=>(0,_.jsx)("p",{children:Gn(e.name,e.value)},e.name))}):0===t?(0,_.jsx)("p",{children:" "}):(0,_.jsx)("p",{children:Gn("rows",t)})}const Hn=function(){const e=Ar(e=>e.progress),t=Ar(e=>e.totals),r=Ar(e=>e.status),s=Ar(e=>e.search),a=Ar(e=>e.results),l=Ar(e=>e.setResults),o=Ar(e=>e.exportData),i=Ar(e=>e.setTotals),u=Ar(e=>e.setProgress),d=Ar(e=>e.setStatus),h=Ar(e=>e.setIsSaving),p=Ar(e=>e.setCanCancel),g=Ar(e=>e.setReplaceAll),x=Ar(e=>e.clearResults),m=H(e=>e.addError),[f,v]=(0,n.useState)(0),j=(0,n.useRef)(!1),b=on(),y=zt(s),w=((e,t)=>e?t.rows:t.matched_rows)(y,t),{current:S=0,next:C=0,rows:k=0}=e,N=Math.min(100,r===wr&&!1===C?100:((e,t)=>t>0?Math.round(e/t*100):0)(S,w));(0,n.useEffect)(()=>{r===br&&!1!==e.next&&0===f&&v(1)},[r,e.next,f]);const R=!1!==e.next&&r===br&&f>0,P=s.perPage??200;return(0,n.useEffect)(()=>{r===yr&&(h(!1),p(!1),g(!1))},[r,h,p,g]),(0,n.useEffect)(()=>{if(0!==o.length){if(r===wr&&!1===e.next&&"export"===s.action&&!j.current){j.current=!0;const{actionOption:e}=Ar.getState().search;!function(e,t){const r=function(e,t){return"json"===t?JSON.stringify(e):e.join("\n")}(e,t),s=function(e){return"json"===e?"export.json":"csv"===e?"export.csv":"sql"===e?"export.sql":"export.txt"}(t);(0,Kn.saveAs)(new Blob([r]),s)}(o,e?.format||"json")}}else j.current=!1},[r,e.next,s.action,o]),Mn(R,f,P,e=>{var t,r;r=e,!1!==(t=Ar.getState().progress.next)&&(d(br),b.mutate({...s,page:t,save:!0,perPage:r},{onSuccess:e=>{l([...a,...Cr(e.results)]),i({matched_rows:e.totals.matched_rows,rows:e.totals.rows,...e.totals.custom?{custom:e.totals.custom}:{}}),u({next:e.progress.next,...void 0!==e.progress.current?{current:e.progress.current}:{},...void 0!==e.progress.rows?{rows:e.progress.rows}:{},...void 0!==e.progress.previous?{previous:e.progress.previous}:{}});const t=!1!==e.progress.next;d(t?br:e.status??wr),v(e=>e+1)},onError:()=>{d(yr)}}))},()=>{m((0,c.__)("Your search resulted in too many requests. Please narrow your search terms.","search-regex"))}),(0,_.jsxs)("div",{className:"searchregex-replaceall",children:[(0,_.jsx)("h3",{children:(0,c.__)("Progress","search-regex")}),(0,_.jsxs)("div",{className:"searchregex-replaceall__progress",children:[(0,_.jsx)("div",{className:"searchregex-replaceall__container",children:(0,_.jsx)(Bn.N1,{percent:N,strokeWidth:4,trailWidth:4,strokeLinecap:"square"})}),(0,_.jsx)("div",{className:"searchregex-replaceall__status",children:`${N}%`})]}),(0,_.jsxs)("div",{className:"searchregex-replaceall__stats",children:[(0,_.jsx)(Wn,{totals:t,current:y?S:S+k}),r===wr&&(0,_.jsx)("button",{type:"button",className:"button button-primary",onClick:()=>{x(),h(!1),p(!1),g(!1)},children:(0,c.__)("Finished!","search-regex")})]})]})},Jn=function(){const e=Ar(e=>e.status),t=Ar(e=>e.isSaving),r=Ar(e=>e.search),s=Ar(e=>e.searchDirection),n=Ar(e=>e.setStatus),a=Ar(e=>e.setResults),l=Ar(e=>e.setTotals),o=Ar(e=>e.setProgress),i=Ar(e=>e.setShowLoading),u=Ar(e=>e.setCanCancel),d=Ar(e=>e.setResultsDirty),h=Ar(e=>e.setSearchDirection),p=Ar(e=>e.setCumulativeMatchedRows),g=Ar(e=>e.updateSearchUrl),x=on();return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(pt,{level:"warning",children:(0,_.jsx)("p",{children:(0,c.__)("Please backup your data before making modifications.","search-regex")})}),(0,_.jsx)("p",{children:(0,c.__)("Search and replace information in your database.","search-regex")}),(0,_.jsxs)("form",{className:"searchregex-search",onSubmit:e=>function(e){e.preventDefault(),a([]),d(!1),p(0),i(!0),u(!0),h(Sr),g(),n(br),x.mutate({...r,page:0,searchDirection:s||Sr},{onSuccess:e=>{a(Cr(e.results)),l(kr(e.totals)),o(Nr(e.progress)),n(e.status??wr),i(!1),u(!1)},onError:()=>{n(yr),i(!1),u(!1)}})}(e),children:[(0,_.jsx)($s,{}),(0,_.jsx)(qn,{})]}),null!==e&&e!==yr&&t&&(0,_.jsx)(Hn,{}),null!==e&&e!==yr&&!t&&(0,_.jsx)($n,{})]})},zn=function({page:e}){switch(e){case"support":return(0,_.jsx)(xt,{});case"options":return(0,_.jsx)(Xe,{});case"presets":return(0,_.jsx)(Ds,{})}return(0,_.jsx)(Jn,{})},Qn=function(){return(0,_.jsxs)(U,{errors:"",details:Le().concat(["Buster: 3.4.3 === "+SearchRegexi10n.version]),type:"fixed",title:(0,c.__)("Cached Search Regex detected","search-regex"),links:Ye(),locale:SearchRegexi10n.locale,children:[(0,_.jsx)("p",{children:(0,c.__)("Please clear your browser cache and reload this page.","search-regex")}),(0,_.jsxs)("p",{children:[(0,c.__)("If you are using a caching system such as Cloudflare then please read this:","search-regex")," ",(0,_.jsx)(R,{url:"https://searchregex.com/support/problems/cloudflare/",children:(0,c.__)("clearing your cache.","search-regex")})]})]})},Xn=function(e){const{error:t,onClear:r}=e,s=t.jsonData,n="mailto:john@searchregex.com?subject=Search%20Regex%20Query%20Error&body="+encodeURIComponent(s),a="https://github.com/johngodley/search-regex/issues/new?title=Search%20Regex%20Query%20Error&body="+encodeURIComponent("```\n"+s+"\n```\n\n");return(0,_.jsxs)("div",{className:"wpl-error",children:[(0,_.jsx)("div",{className:"closer",onClick:r,onKeyDown:r,role:"button",tabIndex:0,children:(0,_.jsx)("span",{className:"dashicons dashicons-no-alt"})}),(0,_.jsx)("h2",{children:(0,c.__)("Query Problem","search-regex")}),(0,_.jsx)("p",{children:(0,c.__)("A problem occurred with your last query. This is likely caused by a combination of search filters that haven't been handled properly.")}),(0,_.jsx)("p",{children:(0,_.jsx)("code",{children:t.jsonData})}),(0,_.jsx)("h3",{children:(0,c.__)("What do I do next?","search-regex")}),(0,_.jsxs)("p",{children:[(0,_.jsx)("a",{href:a,className:"button-primary",children:(0,c.__)("Create An Issue","search-regex")})," ",(0,_.jsx)("a",{href:n,className:"button-secondary",children:(0,c.__)("Email","search-regex")})]})]})},Zn=function(){const{update_notice:e=!1}=SearchRegexi10n,t=ze();return e&&-1!==SearchRegexi10n.caps.capabilities.indexOf("searchregex_cap_options")?(0,_.jsx)(pt,{children:(0,_.jsxs)("p",{children:[I((0,c.sprintf)(/* translators: %s: version installed */ /* translators: %s: version installed */
(0,c.__)("Version %s installed! Please read the {{url}}release notes{{/url}} for details.","search-regex"),e),{url:(0,_.jsx)(R,{url:"https://searchregex.com/blog/searchregex-version-"+e.replace(".","-")+"/"})})," ",(0,_.jsx)(Lt,{onClick:function(){const e=SearchRegexi10n.update_notice;void 0!==e&&t.mutate({update_notice:e}),SearchRegexi10n.update_notice=!1},children:(0,c.__)("OK","search-regex")})]})}):null},ea=function(){const[e,t]=(0,n.useState)(g()),r=Ar(e=>e.mode),s=Ar(e=>e.setMode),a=Ar(e=>e.updateSearchUrl),l=H(e=>e.errors),o=H(e=>e.notices),i=H(e=>e.clearErrors),u=H(e=>e.clearNotices),d=Ee(e=>e.setCurrentPreset),{data:h=[]}=De();return"3.4.3"!==SearchRegexi10n.version?(0,_.jsx)(Qn,{}):(0,_.jsx)(m,{renderCrash:dt,extra:{page:e},children:(0,_.jsx)("div",{className:"wrap searchregex notranslate",translate:"no",children:(0,_.jsxs)(ht,{page:e,setPage:e=>t(e),onPageChange:function(){i();const e=SearchRegexi10n.settings;let t=e?.startupMode,r=e?.startupPreset;if(!t&&e&&void 0!==e.defaultPreset){const s=e.defaultPreset;s&&(t="preset",r=String(s))}if("preset"===t&&r){const e=h.find(e=>e.id===r);if(e)return void d(e)}d(null)},children:[(0,_.jsxs)("div",{className:"searchregex-header",children:[(0,_.jsx)("h1",{className:"wp-heading-inline",children:{search:(0,c.__)("Search Regex","search-regex"),options:(0,c.__)("Options","search-regex"),support:(0,c.__)("Support","search-regex"),presets:(0,c.__)("Presets","search-regex")}[e]}),"search"===e&&(0,_.jsx)("div",{className:"inline-edit-row searchregex-search-mode",children:(0,_.jsx)(j,{items:[{value:"simple",label:(0,c.__)("Simple mode","search-regex")},{value:"advanced",label:(0,c.__)("Advanced mode","search-regex")}],name:"search-mode",value:r,onChange:e=>{s(e.target.value),a()}})})]}),(0,_.jsx)(Zn,{}),(0,_.jsx)(w,{onChangePage:e=>t(""===e?"search":e),menu:[{name:(0,c.__)("Search & Replace","search-regex"),value:""},{name:(0,c.__)("Presets","search-regex"),value:"presets"},{name:(0,c.__)("Options","search-regex"),value:"options"},{name:(0,c.__)("Support","search-regex"),value:"support"}].filter(e=>G(e.value)||""===e.value&&G("search")),home:"search",currentPage:e,urlBase:SearchRegexi10n.pluginRoot}),l.length>0&&"searchregex_database"===l[0].code?(0,_.jsx)(Xn,{error:l[0],onClear:i}):(0,_.jsx)(U,{errors:l,onClear:i,renderDebug:Te,details:Le(),links:Ye(),locale:SearchRegexi10n.locale,children:(0,_.jsx)(ot,{})}),(0,_.jsx)(zn,{page:e}),(0,_.jsx)(K,{notices:o.map(e=>({message:e})),onClear:u,snackBarViewText:(0,c.__)("View")})]})})})},ta=new(r(896).E)({defaultOptions:{queries:{staleTime:3e5,gcTime:6e5,retry:!1,refetchOnWindowFocus:!1},mutations:{retry:!1}}});try{new Intl.NumberFormat(SearchRegexi10n.locale)}catch{SearchRegexi10n.locale="en-US"}ae.resetMiddlewares(),ae.use(ae.createRootURLMiddleware(SearchRegexi10n?.api?.WP_API_root??"/wp-json/")),ae.use(ae.createNonceMiddleware(SearchRegexi10n?.api?.WP_API_nonce??""));const ra=ie("presets",[]);function sa({children:e}){const t=Ar(e=>e.initialize),r=Ee(e=>e.setCurrentPreset);return(0,n.useEffect)(()=>{t(ra);const e=d();if(e.preset){const t=ra.find(t=>t.id===e.preset);t&&r(t,!0)}},[]),(0,_.jsx)(_.Fragment,{children:e})}const na=()=>(0,_.jsxs)(l.Ht,{client:ta,children:[(0,_.jsx)(sa,{children:(0,_.jsx)(n.StrictMode,{children:(0,_.jsx)(ea,{})})}),!1]});if(document.querySelector("#react-ui")){const e=document.querySelector(".jquery-migrate-deprecation-notice");e&&e.remove(),function(){const e=document.getElementById("react-ui");e&&(0,s.createRoot)(e).render((0,_.jsx)(na,{}))}()}window.searchregex=SearchRegexi10n.version},609(e){e.exports=window.React},795(e){e.exports=window.ReactDOM},790(e){e.exports=window.ReactJSXRuntime}};const t={};function r(s){const n=t[s];if(void 0!==n)return n.exports;const a=t[s]={exports:{}};return e[s].call(a.exports,a,a.exports,r),a.exports}r.m=e,(()=>{const e=[];r.O=(t,s,n,a)=>{if(s){a=a||0;for(var l=e.length;l>0&&e[l-1][2]>a;l--)e[l]=e[l-1];return void(e[l]=[s,n,a])}let c=1/0;for(l=0;l<e.length;l++){let[s,n,a]=e[l],i=!0;for(var o=0;o<s.length;o++)(!1&a||c>=a)&&Object.keys(r.O).every(e=>r.O[e](s[o]))?s.splice(o--,1):(i=!1,a<c&&(c=a));if(i){e.splice(l--,1);const r=n();void 0!==r&&(t=r)}}return t}})(),r.n=e=>{const t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},(()=>{const e=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;let t;r.t=function(s,n){if(1&n&&(s=this(s)),8&n)return s;if("object"==typeof s&&s){if(4&n&&s.__esModule)return s;if(16&n&&"function"==typeof s.then)return s}const a=Object.create(null);r.r(a);const l={};t=t||[null,e({}),e([]),e(e)];for(var c=2&n&&s;("object"==typeof c||"function"==typeof c)&&!~t.indexOf(c);c=e(c))Object.getOwnPropertyNames(c).forEach(e=>l[e]=()=>s[e]);return l.default=()=>s,r.d(a,l),a}})(),r.d=(e,t)=>{if(Array.isArray(t))for(var s=0;s<t.length;){var n=t[s++],a=t[s++];r.o(e,n)?0===a&&s++:0===a?Object.defineProperty(e,n,{enumerable:!0,value:t[s++]}):Object.defineProperty(e,n,{enumerable:!0,get:a})}else for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.hasOwn(e,t),r.r=e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.dn=e=>{(Object.getOwnPropertyDescriptor(e,"name")||{}).writable||Object.defineProperty(e,"name",{value:"default",configurable:!0})},(()=>{const e={609:0};r.O.j=t=>0===e[t];const t=(t,s)=>{let[n,a,l]=s;var c,o,i=0;if(n.some(t=>0!==e[t])){for(c in a)r.o(a,c)&&(r.m[c]=a[c]);if(l)var u=l(r)}for(t&&t(s);i<n.length;i++)o=n[i],r.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return r.O(u)},s=globalThis.webpackChunksearch_regex||=[];s.forEach(t.bind(null,0)),s.push=t.bind(null,s.push.bind(s))})();let s=r.O(void 0,[121],()=>r(6));s=r.O(s)})();

Youez - 2016 - github.com/yon3zu
LinuXploit