403Webshell
Server IP : www.new.bangkokfinder.com  /  Your IP : 162.158.189.185
Web Server : nginx/1.20.1
System : Linux new 4.15.0-159-generic #167-Ubuntu SMP Tue Sep 21 08:55:05 UTC 2021 x86_64
User : bangkokfinder ( 1000)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/bangkokfinder/www/wp-content/plugins/generateblocks-pro/dist/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/bangkokfinder/www/wp-content/plugins/generateblocks-pro/dist/block-conditions.js
(()=>{var e={2694:(e,t,n)=>{"use strict";var r=n(6925);function o(){}function a(){}a.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,a,s){if(s!==r){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:o};return n.PropTypes=n,n}},5556:(e,t,n)=>{e.exports=n(2694)()},6925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},21020:(e,t,n)=>{"use strict";var r=n(51609),o=Symbol.for("react.element"),a=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),s=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,n){var r,l={},c=null,u=null;for(r in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)a.call(t,r)&&!i.hasOwnProperty(r)&&(l[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===l[r]&&(l[r]=t[r]);return{$$typeof:o,type:e,key:c,ref:u,props:l,_owner:s.current}}},22799:(e,t)=>{"use strict";Symbol.for("react.element"),Symbol.for("react.portal"),Symbol.for("react.fragment"),Symbol.for("react.strict_mode"),Symbol.for("react.profiler"),Symbol.for("react.provider"),Symbol.for("react.context"),Symbol.for("react.server_context"),Symbol.for("react.forward_ref"),Symbol.for("react.suspense"),Symbol.for("react.suspense_list"),Symbol.for("react.memo"),Symbol.for("react.lazy"),Symbol.for("react.offscreen");Symbol.for("react.module.reference")},44363:(e,t,n)=>{"use strict";n(22799)},51609:e=>{"use strict";e.exports=window.React},74848:(e,t,n)=>{"use strict";e.exports=n(21020)}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(51609),t=n.n(e);const r=window.wp.hooks,o=window.wp.compose,a=window.wp.blockEditor,s=window.wp.i18n,i=window.wp.components;var l=n(74848),c=e.createContext(void 0),u=t=>{const n=e.useContext(c);if(t)return t;if(!n)throw new Error("No QueryClient set, use QueryClientProvider to set one");return n},d=({client:t,children:n})=>(e.useEffect((()=>(t.mount(),()=>{t.unmount()})),[t]),(0,l.jsx)(c.Provider,{value:t,children:n})),p="undefined"==typeof window||"Deno"in globalThis;function h(){}function g(e){return"number"==typeof e&&e>=0&&e!==1/0}function m(e,t){return Math.max(e+(t||0)-Date.now(),0)}function f(e,t){return"function"==typeof e?e(t):e}function b(e,t){return"function"==typeof e?e(t):e}function y(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:a,queryKey:s,stale:i}=e;if(s)if(r){if(t.queryHash!==_(s,t.options))return!1}else if(!E(t.queryKey,s))return!1;if("all"!==n){const e=t.isActive();if("active"===n&&!e)return!1;if("inactive"===n&&e)return!1}return!("boolean"==typeof i&&t.isStale()!==i||o&&o!==t.state.fetchStatus||a&&!a(t))}function v(e,t){const{exact:n,status:r,predicate:o,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(w(t.options.mutationKey)!==w(a))return!1}else if(!E(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function _(e,t){return(t?.queryKeyHashFn||w)(e)}function w(e){return JSON.stringify(e,((e,t)=>I(t)?Object.keys(t).sort().reduce(((e,n)=>(e[n]=t[n],e)),{}):t))}function E(e,t){return e===t||typeof e==typeof t&&!(!e||!t||"object"!=typeof e||"object"!=typeof t)&&Object.keys(t).every((n=>E(e[n],t[n])))}function k(e,t){if(e===t)return e;const n=S(e)&&S(t);if(n||I(e)&&I(t)){const r=n?e:Object.keys(e),o=r.length,a=n?t:Object.keys(t),s=a.length,i=n?[]:{};let l=0;for(let o=0;o<s;o++){const s=n?o:a[o];(!n&&r.includes(s)||n)&&void 0===e[s]&&void 0===t[s]?(i[s]=void 0,l++):(i[s]=k(e[s],t[s]),i[s]===e[s]&&void 0!==e[s]&&l++)}return o===s&&l===o?e:i}return t}function C(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function S(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function I(e){if(!x(e))return!1;const t=e.constructor;if(void 0===t)return!0;const n=t.prototype;return!!x(n)&&!!n.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function x(e){return"[object Object]"===Object.prototype.toString.call(e)}function O(e,t,n){return"function"==typeof n.structuralSharing?n.structuralSharing(e,t):!1!==n.structuralSharing?k(e,t):t}function N(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function T(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var R=Symbol();function D(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==R?e.queryFn:()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`))}function M(e,t){return"function"==typeof e?e(...t):!!e}var P=e=>setTimeout(e,0),A=function(){let e=[],t=0,n=e=>{e()},r=e=>{e()},o=P;const a=r=>{t?e.push(r):o((()=>{n(r)}))};return{batch:a=>{let s;t++;try{s=a()}finally{t--,t||(()=>{const t=e;e=[],t.length&&o((()=>{r((()=>{t.forEach((e=>{n(e)}))}))}))})()}return s},batchCalls:e=>(...t)=>{a((()=>{e(...t)}))},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{o=e}}}(),F=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},$=new class extends F{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!p&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e((e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()}))}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach((t=>{t(e)}))}isFocused(){return"boolean"==typeof this.#e?this.#e:"hidden"!==globalThis.document?.visibilityState}},B=new class extends F{#r=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!p&&window.addEventListener){const t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#r!==e&&(this.#r=e,this.listeners.forEach((t=>{t(e)})))}isOnline(){return this.#r}};function q(){let e,t;const n=new Promise(((n,r)=>{e=n,t=r}));function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.status="pending",n.catch((()=>{})),n.resolve=t=>{r({status:"fulfilled",value:t}),e(t)},n.reject=e=>{r({status:"rejected",reason:e}),t(e)},n}function L(e){return Math.min(1e3*2**e,3e4)}function V(e){return"online"!==(e??"online")||B.isOnline()}var z=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Q(e){return e instanceof z}function j(e){let t,n=!1,r=0,o=!1;const a=q(),s=()=>$.isFocused()&&("always"===e.networkMode||B.isOnline())&&e.canRun(),i=()=>V(e.networkMode)&&e.canRun(),l=n=>{o||(o=!0,e.onSuccess?.(n),t?.(),a.resolve(n))},c=n=>{o||(o=!0,e.onError?.(n),t?.(),a.reject(n))},u=()=>new Promise((n=>{t=e=>{(o||s())&&n(e)},e.onPause?.()})).then((()=>{t=void 0,o||e.onContinue?.()})),d=()=>{if(o)return;let t;const a=0===r?e.initialPromise:void 0;try{t=a??e.fn()}catch(e){t=Promise.reject(e)}Promise.resolve(t).then(l).catch((t=>{if(o)return;const a=e.retry??(p?0:3),i=e.retryDelay??L,l="function"==typeof i?i(r,t):i,h=!0===a||"number"==typeof a&&r<a||"function"==typeof a&&a(r,t);var g;!n&&h?(r++,e.onFail?.(r,t),(g=l,new Promise((e=>{setTimeout(e,g)}))).then((()=>s()?void 0:u())).then((()=>{n?c(t):d()}))):c(t)}))};return{promise:a,cancel:t=>{o||(c(new z(t)),e.abort?.())},continue:()=>(t?.(),a),cancelRetry:()=>{n=!0},continueRetry:()=>{n=!1},canStart:i,start:()=>(i()?d():u().then(d),a)}}var H=class{#o;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),g(this.gcTime)&&(this.#o=setTimeout((()=>{this.optionalRemove()}),this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(p?1/0:3e5))}clearGcTimeout(){this.#o&&(clearTimeout(this.#o),this.#o=void 0)}},U=class extends H{#a;#s;#i;#l;#c;#u;#d;constructor(e){super(),this.#d=!1,this.#u=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#l=e.client,this.#i=this.#l.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#a=function(e){const t="function"==typeof e.initialData?e.initialData():e.initialData,n=void 0!==t,r=n?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}(this.options),this.state=e.state??this.#a,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#c?.promise}setOptions(e){this.options={...this.#u,...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#i.remove(this)}setData(e,t){const n=O(this.state.data,e,this.options);return this.#p({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#p({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#c?.promise;return this.#c?.cancel(e),t?t.then(h).catch(h):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#a)}isActive(){return this.observers.some((e=>!1!==b(e.options.enabled,this)))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===R||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return!!this.state.isInvalidated||(this.getObserversCount()>0?this.observers.some((e=>e.getCurrentResult().isStale)):void 0===this.state.data)}isStaleByTime(e=0){return this.state.isInvalidated||void 0===this.state.data||!m(this.state.dataUpdatedAt,e)}onFocus(){const e=this.observers.find((e=>e.shouldFetchOnWindowFocus()));e?.refetch({cancelRefetch:!1}),this.#c?.continue()}onOnline(){const e=this.observers.find((e=>e.shouldFetchOnReconnect()));e?.refetch({cancelRefetch:!1}),this.#c?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#i.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter((t=>t!==e)),this.observers.length||(this.#c&&(this.#d?this.#c.cancel({revert:!0}):this.#c.cancelRetry()),this.scheduleGc()),this.#i.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#p({type:"invalidate"})}fetch(e,t){if("idle"!==this.state.fetchStatus)if(void 0!==this.state.data&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#c)return this.#c.continueRetry(),this.#c.promise;if(e&&this.setOptions(e),!this.options.queryFn){const e=this.observers.find((e=>e.options.queryFn));e&&this.setOptions(e.options)}const n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#d=!0,n.signal)})},o={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#l,state:this.state,fetchFn:()=>{const e=D(this.options,t),n={client:this.#l,queryKey:this.queryKey,meta:this.meta};return r(n),this.#d=!1,this.options.persister?this.options.persister(e,n,this):e(n)}};r(o),this.options.behavior?.onFetch(o,this),this.#s=this.state,"idle"!==this.state.fetchStatus&&this.state.fetchMeta===o.fetchOptions?.meta||this.#p({type:"fetch",meta:o.fetchOptions?.meta});const a=e=>{Q(e)&&e.silent||this.#p({type:"error",error:e}),Q(e)||(this.#i.config.onError?.(e,this),this.#i.config.onSettled?.(this.state.data,e,this)),this.scheduleGc()};return this.#c=j({initialPromise:t?.initialPromise,fn:o.fetchFn,abort:n.abort.bind(n),onSuccess:e=>{if(void 0!==e){try{this.setData(e)}catch(e){return void a(e)}this.#i.config.onSuccess?.(e,this),this.#i.config.onSettled?.(e,this.state.error,this),this.scheduleGc()}else a(new Error(`${this.queryHash} data is undefined`))},onError:a,onFail:(e,t)=>{this.#p({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#p({type:"pause"})},onContinue:()=>{this.#p({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}),this.#c.start()}#p(e){this.state=(t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...K(t.data,this.options),fetchMeta:e.meta??null};case"success":return{...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return Q(n)&&n.revert&&this.#s?{...this.#s,fetchStatus:"idle"}:{...t,error:n,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}})(this.state),A.batch((()=>{this.observers.forEach((e=>{e.onQueryUpdate()})),this.#i.notify({query:this,type:"updated",action:e})}))}};function K(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:V(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}var W=class extends F{constructor(e={}){super(),this.config=e,this.#h=new Map}#h;build(e,t,n){const r=t.queryKey,o=t.queryHash??_(r,t);let a=this.get(o);return a||(a=new U({client:e,queryKey:r,queryHash:o,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#h.has(e.queryHash)||(this.#h.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#h.get(e.queryHash);t&&(e.destroy(),t===e&&this.#h.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){A.batch((()=>{this.getAll().forEach((e=>{this.remove(e)}))}))}get(e){return this.#h.get(e)}getAll(){return[...this.#h.values()]}find(e){const t={exact:!0,...e};return this.getAll().find((e=>y(t,e)))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter((t=>y(e,t))):t}notify(e){A.batch((()=>{this.listeners.forEach((t=>{t(e)}))}))}onFocus(){A.batch((()=>{this.getAll().forEach((e=>{e.onFocus()}))}))}onOnline(){A.batch((()=>{this.getAll().forEach((e=>{e.onOnline()}))}))}},G=class extends H{#g;#m;#c;constructor(e){super(),this.mutationId=e.mutationId,this.#m=e.mutationCache,this.#g=[],this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#g.includes(e)||(this.#g.push(e),this.clearGcTimeout(),this.#m.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#g=this.#g.filter((t=>t!==e)),this.scheduleGc(),this.#m.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#g.length||("pending"===this.state.status?this.scheduleGc():this.#m.remove(this))}continue(){return this.#c?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#p({type:"continue"})};this.#c=j({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(e,t)=>{this.#p({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#p({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#m.canRun(this)});const n="pending"===this.state.status,r=!this.#c.canStart();try{if(n)t();else{this.#p({type:"pending",variables:e,isPaused:r}),await(this.#m.config.onMutate?.(e,this));const t=await(this.options.onMutate?.(e));t!==this.state.context&&this.#p({type:"pending",context:t,variables:e,isPaused:r})}const o=await this.#c.start();return await(this.#m.config.onSuccess?.(o,e,this.state.context,this)),await(this.options.onSuccess?.(o,e,this.state.context)),await(this.#m.config.onSettled?.(o,null,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(o,null,e,this.state.context)),this.#p({type:"success",data:o}),o}catch(t){try{throw await(this.#m.config.onError?.(t,e,this.state.context,this)),await(this.options.onError?.(t,e,this.state.context)),await(this.#m.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(void 0,t,e,this.state.context)),t}finally{this.#p({type:"error",error:t})}}finally{this.#m.runNext(this)}}#p(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),A.batch((()=>{this.#g.forEach((t=>{t.onMutationUpdate(e)})),this.#m.notify({mutation:this,type:"updated",action:e})}))}},Y=class extends F{constructor(e={}){super(),this.config=e,this.#f=new Set,this.#b=new Map,this.#y=0}#f;#b;#y;build(e,t,n){const r=new G({mutationCache:this,mutationId:++this.#y,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#f.add(e);const t=J(e);if("string"==typeof t){const n=this.#b.get(t);n?n.push(e):this.#b.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#f.delete(e)){const t=J(e);if("string"==typeof t){const n=this.#b.get(t);if(n)if(n.length>1){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}else n[0]===e&&this.#b.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=J(e);if("string"==typeof t){const n=this.#b.get(t),r=n?.find((e=>"pending"===e.state.status));return!r||r===e}return!0}runNext(e){const t=J(e);if("string"==typeof t){const n=this.#b.get(t)?.find((t=>t!==e&&t.state.isPaused));return n?.continue()??Promise.resolve()}return Promise.resolve()}clear(){A.batch((()=>{this.#f.forEach((e=>{this.notify({type:"removed",mutation:e})})),this.#f.clear(),this.#b.clear()}))}getAll(){return Array.from(this.#f)}find(e){const t={exact:!0,...e};return this.getAll().find((e=>v(t,e)))}findAll(e={}){return this.getAll().filter((t=>v(e,t)))}notify(e){A.batch((()=>{this.listeners.forEach((t=>{t(e)}))}))}resumePausedMutations(){const e=this.getAll().filter((e=>e.state.isPaused));return A.batch((()=>Promise.all(e.map((e=>e.continue().catch(h))))))}};function J(e){return e.options.scope?.id}function Z(e){return{onFetch:(t,n)=>{const r=t.options,o=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],s=t.state.data?.pageParams||[];let i={pages:[],pageParams:[]},l=0;const c=async()=>{let n=!1;const c=D(t.options,t.fetchOptions),u=async(e,r,o)=>{if(n)return Promise.reject();if(null==r&&e.pages.length)return Promise.resolve(e);const a={client:t.client,queryKey:t.queryKey,pageParam:r,direction:o?"backward":"forward",meta:t.options.meta};var s;s=a,Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(t.signal.aborted?n=!0:t.signal.addEventListener("abort",(()=>{n=!0})),t.signal)});const i=await c(a),{maxPages:l}=t.options,u=o?T:N;return{pages:u(e.pages,i,l),pageParams:u(e.pageParams,r,l)}};if(o&&a.length){const e="backward"===o,t={pages:a,pageParams:s},n=(e?ee:X)(r,t);i=await u(t,n,e)}else{const t=e??a.length;do{const e=0===l?s[0]??r.initialPageParam:X(r,i);if(l>0&&null==e)break;i=await u(i,e),l++}while(l<t)}return i};t.options.persister?t.fetchFn=()=>t.options.persister?.(c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=c}}}function X(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ee(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var te=class{#v;#m;#u;#_;#w;#E;#k;#C;constructor(e={}){this.#v=e.queryCache||new W,this.#m=e.mutationCache||new Y,this.#u=e.defaultOptions||{},this.#_=new Map,this.#w=new Map,this.#E=0}mount(){this.#E++,1===this.#E&&(this.#k=$.subscribe((async e=>{e&&(await this.resumePausedMutations(),this.#v.onFocus())})),this.#C=B.subscribe((async e=>{e&&(await this.resumePausedMutations(),this.#v.onOnline())})))}unmount(){this.#E--,0===this.#E&&(this.#k?.(),this.#k=void 0,this.#C?.(),this.#C=void 0)}isFetching(e){return this.#v.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#m.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#v.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=this.#v.build(this,t),r=n.state.data;return void 0===r?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(f(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#v.findAll(e).map((({queryKey:e,state:t})=>[e,t.data]))}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),o=this.#v.get(r.queryHash),a=o?.state.data,s=function(e,t){return"function"==typeof e?e(t):e}(t,a);if(void 0!==s)return this.#v.build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return A.batch((()=>this.#v.findAll(e).map((({queryKey:e})=>[e,this.setQueryData(e,t,n)]))))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#v.get(t.queryHash)?.state}removeQueries(e){const t=this.#v;A.batch((()=>{t.findAll(e).forEach((e=>{t.remove(e)}))}))}resetQueries(e,t){const n=this.#v;return A.batch((()=>(n.findAll(e).forEach((e=>{e.reset()})),this.refetchQueries({type:"active",...e},t))))}cancelQueries(e,t={}){const n={revert:!0,...t},r=A.batch((()=>this.#v.findAll(e).map((e=>e.cancel(n)))));return Promise.all(r).then(h).catch(h)}invalidateQueries(e,t={}){return A.batch((()=>(this.#v.findAll(e).forEach((e=>{e.invalidate()})),"none"===e?.refetchType?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t))))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=A.batch((()=>this.#v.findAll(e).filter((e=>!e.isDisabled())).map((e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(h)),"paused"===e.state.fetchStatus?Promise.resolve():t}))));return Promise.all(r).then(h)}fetchQuery(e){const t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);const n=this.#v.build(this,t);return n.isStaleByTime(f(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(h).catch(h)}fetchInfiniteQuery(e){return e.behavior=Z(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(h).catch(h)}ensureInfiniteQueryData(e){return e.behavior=Z(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return B.isOnline()?this.#m.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#v}getMutationCache(){return this.#m}getDefaultOptions(){return this.#u}setDefaultOptions(e){this.#u=e}setQueryDefaults(e,t){this.#_.set(w(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#_.values()],n={};return t.forEach((t=>{E(e,t.queryKey)&&Object.assign(n,t.defaultOptions)})),n}setMutationDefaults(e,t){this.#w.set(w(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#w.values()],n={};return t.forEach((t=>{E(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)})),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#u.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=_(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===R&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#u.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#v.clear(),this.#m.clear()}};let ne=null;function re(){return ne||(ne=new te({defaultOptions:{queries:{staleTime:3e5,cacheTime:6e5,retry:1,refetchOnWindowFocus:!0}}})),ne}function oe(){const e=re();if(e.invalidateQueries({queryKey:["conditions"]}),e.invalidateQueries({queryKey:["condition"]}),window.dispatchEvent(new CustomEvent("gb-invalidate-conditions")),window.parent&&window.parent!==window)try{window.parent.postMessage({type:"gb_invalidate_conditions"},"*")}catch(e){}}"undefined"!=typeof window&&(window.addEventListener("gb-invalidate-conditions",(()=>{re().invalidateQueries({queryKey:["conditions"]})})),window.addEventListener("message",(e=>{"gb_invalidate_conditions"===e.data?.type&&re().invalidateQueries({queryKey:["conditions"]})})),window.addEventListener("gb-overlay-saved-global",(e=>{const t=re();t.invalidateQueries({queryKey:["overlays"]}),e.detail?.overlayId&&t.invalidateQueries({queryKey:["overlay",e.detail.overlayId]})})));const ae=window.wp.element,se=window.wp.primitives,ie=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),le=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"})),ce=window.wp.htmlEntities;var ue=class extends F{constructor(e,t){super(),this.options=t,this.#l=e,this.#S=null,this.#I=q(),this.options.experimental_prefetchInRender||this.#I.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(t)}#l;#x=void 0;#O=void 0;#N=void 0;#T;#R;#I;#S;#D;#M;#P;#A;#F;#$;#B=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#x.addObserver(this),de(this.#x,this.options)?this.#q():this.updateResult(),this.#L())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return pe(this.#x,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return pe(this.#x,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#V(),this.#z(),this.#x.removeObserver(this)}setOptions(e){const t=this.options,n=this.#x;if(this.options=this.#l.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof b(this.options.enabled,this.#x))throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#Q(),this.#x.setOptions(this.options),t._defaulted&&!C(this.options,t)&&this.#l.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#x,observer:this});const r=this.hasListeners();r&&he(this.#x,n,this.options,t)&&this.#q(),this.updateResult(),!r||this.#x===n&&b(this.options.enabled,this.#x)===b(t.enabled,this.#x)&&f(this.options.staleTime,this.#x)===f(t.staleTime,this.#x)||this.#j();const o=this.#H();!r||this.#x===n&&b(this.options.enabled,this.#x)===b(t.enabled,this.#x)&&o===this.#$||this.#U(o)}getOptimisticResult(e){const t=this.#l.getQueryCache().build(this.#l,e),n=this.createResult(t,e);return r=n,!C(this.getCurrentResult(),r)&&(this.#N=n,this.#R=this.options,this.#T=this.#x.state),n;var r}getCurrentResult(){return this.#N}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),Reflect.get(e,n))})}trackProp(e){this.#B.add(e)}getCurrentQuery(){return this.#x}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#l.defaultQueryOptions(e),n=this.#l.getQueryCache().build(this.#l,t);return n.fetch().then((()=>this.createResult(n,t)))}fetch(e){return this.#q({...e,cancelRefetch:e.cancelRefetch??!0}).then((()=>(this.updateResult(),this.#N)))}#q(e){this.#Q();let t=this.#x.fetch(this.options,e);return e?.throwOnError||(t=t.catch(h)),t}#j(){this.#V();const e=f(this.options.staleTime,this.#x);if(p||this.#N.isStale||!g(e))return;const t=m(this.#N.dataUpdatedAt,e)+1;this.#A=setTimeout((()=>{this.#N.isStale||this.updateResult()}),t)}#H(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#x):this.options.refetchInterval)??!1}#U(e){this.#z(),this.#$=e,!p&&!1!==b(this.options.enabled,this.#x)&&g(this.#$)&&0!==this.#$&&(this.#F=setInterval((()=>{(this.options.refetchIntervalInBackground||$.isFocused())&&this.#q()}),this.#$))}#L(){this.#j(),this.#U(this.#H())}#V(){this.#A&&(clearTimeout(this.#A),this.#A=void 0)}#z(){this.#F&&(clearInterval(this.#F),this.#F=void 0)}createResult(e,t){const n=this.#x,r=this.options,o=this.#N,a=this.#T,s=this.#R,i=e!==n?e.state:this.#O,{state:l}=e;let c,u={...l},d=!1;if(t._optimisticResults){const o=this.hasListeners(),a=!o&&de(e,t),s=o&&he(e,n,t,r);(a||s)&&(u={...u,...K(l.data,e.options)}),"isRestoring"===t._optimisticResults&&(u.fetchStatus="idle")}let{error:p,errorUpdatedAt:h,status:g}=u;c=u.data;let m=!1;if(void 0!==t.placeholderData&&void 0===c&&"pending"===g){let e;o?.isPlaceholderData&&t.placeholderData===s?.placeholderData?(e=o.data,m=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#P?.state.data,this.#P):t.placeholderData,void 0!==e&&(g="success",c=O(o?.data,e,t),d=!0)}if(t.select&&void 0!==c&&!m)if(o&&c===a?.data&&t.select===this.#D)c=this.#M;else try{this.#D=t.select,c=t.select(c),c=O(o?.data,c,t),this.#M=c,this.#S=null}catch(e){this.#S=e}this.#S&&(p=this.#S,c=this.#M,h=Date.now(),g="error");const f="fetching"===u.fetchStatus,b="pending"===g,y="error"===g,v=b&&f,_=void 0!==c,w={status:g,fetchStatus:u.fetchStatus,isPending:b,isSuccess:"success"===g,isError:y,isInitialLoading:v,isLoading:v,data:c,dataUpdatedAt:u.dataUpdatedAt,error:p,errorUpdatedAt:h,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>i.dataUpdateCount||u.errorUpdateCount>i.errorUpdateCount,isFetching:f,isRefetching:f&&!b,isLoadingError:y&&!_,isPaused:"paused"===u.fetchStatus,isPlaceholderData:d,isRefetchError:y&&_,isStale:ge(e,t),refetch:this.refetch,promise:this.#I};if(this.options.experimental_prefetchInRender){const t=e=>{"error"===w.status?e.reject(w.error):void 0!==w.data&&e.resolve(w.data)},r=()=>{const e=this.#I=w.promise=q();t(e)},o=this.#I;switch(o.status){case"pending":e.queryHash===n.queryHash&&t(o);break;case"fulfilled":"error"!==w.status&&w.data===o.value||r();break;case"rejected":"error"===w.status&&w.error===o.reason||r()}}return w}updateResult(){const e=this.#N,t=this.createResult(this.#x,this.options);this.#T=this.#x.state,this.#R=this.options,void 0!==this.#T.data&&(this.#P=this.#x),C(t,e)||(this.#N=t,this.#K({listeners:(()=>{if(!e)return!0;const{notifyOnChangeProps:t}=this.options,n="function"==typeof t?t():t;if("all"===n||!n&&!this.#B.size)return!0;const r=new Set(n??this.#B);return this.options.throwOnError&&r.add("error"),Object.keys(this.#N).some((t=>{const n=t;return this.#N[n]!==e[n]&&r.has(n)}))})()}))}#Q(){const e=this.#l.getQueryCache().build(this.#l,this.options);if(e===this.#x)return;const t=this.#x;this.#x=e,this.#O=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#L()}#K(e){A.batch((()=>{e.listeners&&this.listeners.forEach((e=>{e(this.#N)})),this.#l.getQueryCache().notify({query:this.#x,type:"observerResultsUpdated"})}))}};function de(e,t){return function(e,t){return!1!==b(t.enabled,e)&&void 0===e.state.data&&!("error"===e.state.status&&!1===t.retryOnMount)}(e,t)||void 0!==e.state.data&&pe(e,t,t.refetchOnMount)}function pe(e,t,n){if(!1!==b(t.enabled,e)){const r="function"==typeof n?n(e):n;return"always"===r||!1!==r&&ge(e,t)}return!1}function he(e,t,n,r){return(e!==t||!1===b(r.enabled,e))&&(!n.suspense||"error"!==e.state.status)&&ge(e,n)}function ge(e,t){return!1!==b(t.enabled,e)&&e.isStaleByTime(f(t.staleTime,e))}var me=e.createContext(function(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}()),fe=e.createContext(!1),be=(fe.Provider,(e,t,n)=>t.fetchOptimistic(e).catch((()=>{n.clearReset()})));function ye(t,n){return function(t,n,r){const o=u(r),a=e.useContext(fe),s=e.useContext(me),i=o.defaultQueryOptions(t);o.getDefaultOptions().queries?._experimental_beforeQuery?.(i),i._optimisticResults=a?"isRestoring":"optimistic",(e=>{const t=e.staleTime;e.suspense&&(e.staleTime="function"==typeof t?(...e)=>Math.max(t(...e),1e3):Math.max(t??1e3,1e3),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,1e3)))})(i),((e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))})(i,s),(t=>{e.useEffect((()=>{t.clearReset()}),[t])})(s);const l=!o.getQueryCache().get(i.queryHash),[c]=e.useState((()=>new n(o,i))),d=c.getOptimisticResult(i),g=!a&&!1!==t.subscribed;if(e.useSyncExternalStore(e.useCallback((e=>{const t=g?c.subscribe(A.batchCalls(e)):h;return c.updateResult(),t}),[c,g]),(()=>c.getCurrentResult()),(()=>c.getCurrentResult())),e.useEffect((()=>{c.setOptions(i)}),[i,c]),((e,t)=>e?.suspense&&t.isPending)(i,d))throw be(i,c,s);if((({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&void 0===e.data||M(n,[e.error,r])))({result:d,errorResetBoundary:s,throwOnError:i.throwOnError,query:o.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw d.error;if(o.getDefaultOptions().queries?._experimental_afterQuery?.(i,d),i.experimental_prefetchInRender&&!p&&((e,t)=>e.isLoading&&e.isFetching&&!t)(d,a)){const e=l?be(i,c,s):o.getQueryCache().get(i.queryHash)?.promise;e?.catch(h).finally((()=>{c.updateResult()}))}return i.notifyOnChangeProps?d:c.trackResult(d)}(t,ue,n)}var ve=class extends F{#l;#N=void 0;#W;#G;constructor(e,t){super(),this.#l=e,this.setOptions(t),this.bindMethods(),this.#Y()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#l.defaultMutationOptions(e),C(this.options,t)||this.#l.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#W,observer:this}),t?.mutationKey&&this.options.mutationKey&&w(t.mutationKey)!==w(this.options.mutationKey)?this.reset():"pending"===this.#W?.state.status&&this.#W.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#W?.removeObserver(this)}onMutationUpdate(e){this.#Y(),this.#K(e)}getCurrentResult(){return this.#N}reset(){this.#W?.removeObserver(this),this.#W=void 0,this.#Y(),this.#K()}mutate(e,t){return this.#G=t,this.#W?.removeObserver(this),this.#W=this.#l.getMutationCache().build(this.#l,this.options),this.#W.addObserver(this),this.#W.execute(e)}#Y(){const e=this.#W?.state??{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0};this.#N={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#K(e){A.batch((()=>{if(this.#G&&this.hasListeners()){const t=this.#N.variables,n=this.#N.context;"success"===e?.type?(this.#G.onSuccess?.(e.data,t,n),this.#G.onSettled?.(e.data,null,t,n)):"error"===e?.type&&(this.#G.onError?.(e.error,t,n),this.#G.onSettled?.(void 0,e.error,t,n))}this.listeners.forEach((e=>{e(this.#N)}))}))}};function _e(t,n){const r=u(n),[o]=e.useState((()=>new ve(r,t)));e.useEffect((()=>{o.setOptions(t)}),[o,t]);const a=e.useSyncExternalStore(e.useCallback((e=>o.subscribe(A.batchCalls(e))),[o]),(()=>o.getCurrentResult()),(()=>o.getCurrentResult())),s=e.useCallback(((e,t)=>{o.mutate(e,t).catch(h)}),[o]);if(a.error&&M(o.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:s,mutateAsync:a.mutate}}const we=window.wp.apiFetch;var Ee=n.n(we);async function ke(){return await Ee()({path:"/wp/v2/condition-categories"})}function Ce(e=100,t=1){return ye({queryKey:["conditions",{perPage:e,page:t}],queryFn:()=>async function({perPage:e=100,page:t=1}){const n=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/?page=${t}&per_page=${e}`});if(n.success)return n.response;throw new Error("Failed to fetch conditions")}({perPage:e,page:t}),select:e=>({conditions:e?.conditions||[],total:e?.total||0,pages:e?.pages||1})})}function Se(){const e=ye({queryKey:["condition-metadata","types"],queryFn:async()=>{const e=await Ee()({path:"/generateblocks-pro/advanced-conditions/v1/get_condition_types"});if(e.success)return e.response;throw new Error("Failed to fetch condition types")},staleTime:6e5}),t=(0,ae.useCallback)((async e=>{if(!e)return[];const t=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/get_condition_rules?type=${e}`});if(t.success)return t.response;throw new Error("Failed to fetch condition rules")}),[]),n=(0,ae.useCallback)((async(e,t)=>{if(!e||!t)return[];const n=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/get_condition_operators?type=${e}&rule=${t}`});if(n.success)return n.response;throw new Error("Failed to fetch condition operators")}),[]);return{conditionTypes:e.data||{},loading:e.isLoading,error:e.error,getRulesForType:t,getOperatorsForType:n}}const Ie=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"})),xe=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"}));function Oe({currentView:t,views:n={},className:r="",minHeight:o=400,viewOrder:a=[]}){const[s,i]=(0,ae.useState)(t),[l,c]=(0,ae.useState)(!1),[u,d]=(0,ae.useState)(!1),[p,h]=(0,ae.useState)("forward");(0,ae.useEffect)((()=>{u||d(!0)}),[]),(0,ae.useEffect)((()=>{if(u&&s!==t){const e=a.indexOf(t),n=a.indexOf(s);h(-1!==e&&-1!==n?e>n?"forward":"backward":"forward"),c(!0);const r=setTimeout((()=>{c(!1),i(t)}),260);return()=>clearTimeout(r)}}),[t,s,u,a]);const g=["gb-navigator",r,l?"gb-navigator--transitioning":"",l?`gb-navigator--${p}`:""].filter(Boolean).join(" ");return(0,e.createElement)("div",{className:g,style:{minHeight:`${o}px`}},Object.entries(n).map((([n,r])=>{const o=n===t,a=["gb-navigator-view",`gb-navigator-view--${n}`,o?"gb-navigator-view--active":"gb-navigator-view--inactive"].join(" ");return(0,e.createElement)("div",{key:n,className:a,"aria-hidden":!o},(o||l)&&r)})))}function Ne({trigger:t,itemId:n=null,itemType:r="item",dashboardView:o,editorView:a,onItemSelect:l=null,getNewTabUrl:c,modalProps:u={},labels:d={},className:p="",confirmMessages:h}){const g={backButton:(0,s.__)("Back to Dashboard","generateblocks-pro"),createNew:(0,s.__)("Create New Item","generateblocks-pro"),edit:(0,s.__)("Edit Item","generateblocks-pro"),dashboard:(0,s.__)("Dashboard","generateblocks-pro"),openInNewTab:(0,s.__)("Open in new tab","generateblocks-pro"),close:(0,s.__)("Close","generateblocks-pro"),unsavedChanges:(0,s.__)("Unsaved changes","generateblocks-pro"),...d},{isOpen:m,setIsOpen:f,currentView:b,contentHeight:y,selectedItemId:v,selectedItemTitle:_,selectedItemData:w,hasUnsavedChanges:E,setHasUnsavedChanges:k,headerRef:C,modalRef:S,handleItemSelect:I,handleBackToDashboard:x,handleBackToDashboardAfterSave:O,handleOpenInNewTab:N,handleClose:T}=function({itemId:e=null,onItemSelect:t=null,getNewTabUrl:n,confirmMessages:r={unsavedBack:(0,s.__)("You have unsaved changes. Are you sure you want to go back?","generateblocks-pro"),unsavedClose:(0,s.__)("You have unsaved changes. Are you sure you want to close?","generateblocks-pro")}}){const[o,a]=(0,ae.useState)(!1),[i,l]=(0,ae.useState)(e?"editor":"dashboard"),[c,u]=(0,ae.useState)(0),[d,p]=(0,ae.useState)(e),[h,g]=(0,ae.useState)(""),[m,f]=(0,ae.useState)(null),[b,y]=(0,ae.useState)(!1),v=(0,ae.useRef)(null),_=(0,ae.useRef)(null),w=(0,ae.useRef)(!1);(0,ae.useEffect)((()=>{w.current||(p(e),l(e?"editor":"dashboard")),w.current=!1}),[e]);const E=(0,ae.useCallback)(((e,n,r)=>{p(e),g(n||""),f(r||null),l("editor"),t&&t(e,n,r)}),[t]),k=(0,ae.useCallback)((()=>{b&&!window.confirm(r.unsavedBack)||(w.current=!0,l("dashboard"),p(null),g(""),f(null),y(!1))}),[b,r.unsavedBack]),C=(0,ae.useCallback)((()=>{w.current=!0,l("dashboard"),p(null),g(""),f(null),y(!1)}),[]),S=(0,ae.useCallback)((()=>{if("editor"===i&&d&&n){const e=n(d,m);e&&window.open(e,"_blank")}}),[i,d,m,n]),I=(0,ae.useCallback)((()=>{"editor"===i&&b&&!window.confirm(r.unsavedClose)||(a(!1),setTimeout((()=>{l(e?"editor":"dashboard"),p(e),g(""),y(!1)}),300))}),[i,b,r.unsavedClose,e]);return(0,ae.useEffect)((()=>{const e=()=>{if(!_.current||!v.current||!o)return;const e=_.current.querySelector(".components-modal__content"),t=v.current;if(e&&t){const n=e.clientHeight,r=t.offsetHeight;u(n-r)}};if(o){e();const t=new ResizeObserver(e);return _.current&&t.observe(_.current),v.current&&t.observe(v.current),window.addEventListener("resize",e),()=>{t.disconnect(),window.removeEventListener("resize",e)}}}),[o]),(0,ae.useEffect)((()=>{const e=e=>{"Escape"===e.key&&o&&(e.preventDefault(),I())};return o&&document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}}),[o,I]),{isOpen:o,setIsOpen:a,currentView:i,setCurrentView:l,contentHeight:c,selectedItemId:d,selectedItemTitle:h,selectedItemData:m,hasUnsavedChanges:b,setHasUnsavedChanges:y,headerRef:v,modalRef:_,handleItemSelect:E,handleBackToDashboard:k,handleBackToDashboardAfterSave:C,handleOpenInNewTab:S,handleClose:I}}({itemId:n,onItemSelect:l,getNewTabUrl:c,confirmMessages:h}),R={dashboard:o&&(0,ae.cloneElement)(o,{isModalMode:!0,isIframeMode:!0,onItemSelect:e=>{"object"==typeof e&&e.id&&I(e.id,e.title?.rendered||e.title||"")},onCreateItem:()=>I("new",g.createNew),onConditionSelect:e=>{I(e.id,e.title?.rendered||"",e)},onCreateCondition:()=>I("new",g.createNew),onModalSelect:(e,t)=>{I(e,t)},onCreateOverlay:(e,t)=>I(e||"new",g.createNew,{overlayType:t})}),editor:a&&v&&(0,ae.cloneElement)(a,{embedded:!0,onUnsavedChanges:k,conditionId:"new"===v?null:v,isNew:"new"===v,onNavigateBack:x,onSave:O,overlayId:v,overlayTitle:_,overlayType:w?.overlayType,onClose:x})},D={title:"",className:`gb-dashboard-trigger-modal ${p}`,isFullScreen:!0,isDismissible:!1,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,showHeader:!1,...u};return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{onClick:()=>f(!0),role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),f(!0))}},t),m&&(0,e.createElement)(i.Modal,{...D,onRequestClose:()=>{},ref:S},(0,e.createElement)("div",{className:"gb-dashboard-custom-header",ref:C,"data-item-type":r},(0,e.createElement)("div",{className:"gb-dashboard-header-left"},"editor"===b&&(0,e.createElement)(i.Button,{icon:"arrow-left-alt2",size:"compact",variant:"tertiary",onClick:x,label:g.backButton}),(0,e.createElement)("h2",{className:"gb-dashboard-custom-title"},(()=>{if("editor"===b){const e="new"===v?g.createNew:g.edit;return _&&"new"!==v?`${e}: ${_}`:e}return g.dashboard})())),(0,e.createElement)("div",{className:"gb-dashboard-header-actions"},E&&"editor"===b&&(0,e.createElement)("span",{className:"gb-dashboard-unsaved-indicator"},g.unsavedChanges),"editor"===b&&c&&(0,e.createElement)(i.Button,{icon:Ie,size:"compact",variant:"tertiary",onClick:N,label:g.openInNewTab}),(0,e.createElement)(i.Button,{icon:xe,size:"compact",variant:"tertiary",onClick:T,label:g.close}))),(0,e.createElement)("div",{className:"gb-dashboard-content-wrapper",style:{height:y>0?`${y}px`:"auto",minHeight:y>0?`${y}px`:"auto"}},(0,e.createElement)(Oe,{currentView:b,views:R,className:"gb-dashboard-navigator",minHeight:0,viewOrder:["dashboard","editor"]}))))}const Te=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"M20 5h-5.7c0-1.3-1-2.3-2.3-2.3S9.7 3.7 9.7 5H4v2h1.5v.3l1.7 11.1c.1 1 1 1.7 2 1.7h5.7c1 0 1.8-.7 2-1.7l1.7-11.1V7H20V5zm-3.2 2l-1.7 11.1c0 .1-.1.2-.3.2H9.1c-.1 0-.3-.1-.3-.2L7.2 7h9.6z"})),Re=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"})),De=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"})),Me=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z"}));function Pe({conditions:t,onConditionsImport:n}){const[r,o]=(0,ae.useState)(!1),[a,l]=(0,ae.useState)(""),[c,u]=(0,ae.useState)(!1),[d,p]=(0,ae.useState)(!1),h=()=>{if(!t.groups||0===t.groups.length)return"";const e={logic:t.logic,groups:t.groups.map((e=>({logic:e.logic,conditions:e.conditions.filter((e=>e.type&&e.rule&&e.operator)).map((e=>({type:e.type,rule:e.rule,operator:e.operator,value:e.value||""})))}))).filter((e=>0<e.conditions.length))};return JSON.stringify(e,null,2)},g=t.groups&&0<t.groups.length;return(0,e.createElement)("div",{className:"gb-conditions-preview"},c?(0,e.createElement)("div",{className:"gb-import-section"},(0,e.createElement)(i.TextareaControl,{label:(0,s.__)("Import Conditions (JSON format)","generateblocks-pro"),value:a,onChange:l,rows:8,placeholder:(0,s.__)("Paste exported conditions here…","generateblocks-pro")}),(0,e.createElement)(i.Button,{variant:"primary",onClick:()=>{if(a.trim())try{const e=JSON.parse(a);if(!e.groups||!Array.isArray(e.groups))throw new Error("Invalid format: missing groups array");e.groups.forEach(((e,t)=>{if(!e.logic||!["AND","OR"].includes(e.logic))throw new Error(`Invalid logic operator in group ${t+1}`);if(!e.conditions||!Array.isArray(e.conditions))throw new Error(`Invalid conditions in group ${t+1}`);e.conditions.forEach(((e,n)=>{if(!e.type||!e.rule||!e.operator)throw new Error(`Incomplete condition ${n+1} in group ${t+1}`)}))}));const t={logic:e.logic||"OR",groups:e.groups};n(t),l(""),u(!1),alert((0,s.__)("Conditions imported successfully!","generateblocks-pro"))}catch(e){alert((0,s.__)("Import failed: ","generateblocks-pro")+e.message)}else alert((0,s.__)("Please enter conditions to import.","generateblocks-pro"))},disabled:!a.trim()},(0,s.__)("Import Conditions","generateblocks-pro"))):(0,e.createElement)(e.Fragment,null,r&&g&&(0,e.createElement)("div",{className:"gb-preview-text"},(0,e.createElement)("pre",{className:"gb-export-format"},h()||(0,s.__)("No conditions to export","generateblocks-pro")))),(0,e.createElement)("div",{className:"gb-preview-footer"},g&&(0,e.createElement)(i.ToggleControl,{label:(0,s.__)("Show JSON Format","generateblocks-pro"),checked:r,onChange:o,help:(0,s.__)("View the raw JSON format for advanced users","generateblocks-pro")}),(0,e.createElement)("div",{className:"gb-preview-actions"},g&&r&&(0,e.createElement)(i.Button,{variant:"secondary",size:"compact",icon:Re,onClick:async()=>{const e=h();try{await navigator.clipboard.writeText(e),p(!0),setTimeout((()=>p(!1)),2e3)}catch(t){const n=document.createElement("textarea");n.value=e,document.body.appendChild(n),n.focus(),n.select(),document.execCommand("copy"),document.body.removeChild(n),p(!0),setTimeout((()=>p(!1)),2e3)}},className:"gb-copy-button"},d?(0,s.__)("Copied!","generateblocks-pro"):(0,s.__)("Copy JSON","generateblocks-pro")),(0,e.createElement)(i.Button,{variant:"secondary",size:"compact",icon:c?De:Me,onClick:()=>u(!c)},c?(0,s.__)("Cancel Import","generateblocks-pro"):(0,s.__)("Import","generateblocks-pro")))))}function Ae({isOpen:t,onClose:n,onCreateCategory:r}){const[o,a]=(0,ae.useState)(""),[l,c]=(0,ae.useState)(!1),u=async()=>{if(o.trim()){c(!0);try{const e=o.toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-");await r({name:o.trim(),slug:e}),a(""),n()}catch(e){}finally{c(!1)}}},d=()=>{a(""),n()};return t?(0,e.createElement)(i.Modal,{title:(0,s.__)("Create New Category","generateblocks-pro"),onRequestClose:d,className:"gb-create-category-modal"},(0,e.createElement)("div",{className:"gb-modal-content"},(0,e.createElement)(i.TextControl,{label:(0,s.__)("Category Name","generateblocks-pro"),value:o,onChange:a,placeholder:(0,s.__)("Enter category name…","generateblocks-pro"),disabled:l,onKeyDown:e=>{"Enter"===e.key&&u()}}),(0,e.createElement)("div",{className:"gb-modal-actions",style:{display:"flex",gap:"5px",justifyContent:"space-between"}},(0,e.createElement)(i.Button,{variant:"secondary",onClick:d,disabled:l},(0,s.__)("Cancel","generateblocks-pro")),(0,e.createElement)(i.Button,{variant:"primary",onClick:u,disabled:!o.trim()||l,isBusy:l},(0,s.__)("Create Category","generateblocks-pro"))))):null}const Fe=(0,ae.createElement)(se.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,ae.createElement)(se.Path,{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm.5 16c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7h15v12zM9 10H7v2h2v-2zm0 4H7v2h2v-2zm4-4h-2v2h2v-2zm4 0h-2v2h2v-2zm-4 4h-2v2h2v-2zm4 0h-2v2h2v-2z"}));function $e({currentDate:t,onChange:n,placeholder:r=(0,s.__)("Select date and time","generateblocks-pro")}){const[o,a]=(0,ae.useState)(!1),[l,c]=(0,ae.useState)(t),u=()=>{c(t),a(!1)};return(0,e.createElement)("div",{className:"gb-datetime-popover-wrapper"},(0,e.createElement)(i.Button,{variant:"secondary",icon:Fe,onClick:()=>{c(t),a(!0)},className:"gb-datetime-trigger",__next40pxDefaultSize:!0},(d=t)?d.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}):r),o&&(0,e.createElement)(i.Popover,{position:"bottom left",onClose:u,className:"gb-datetime-popover"},(0,e.createElement)("div",{className:"gb-datetime-popover-content"},(0,e.createElement)(i.DateTimePicker,{currentDate:l,onChange:c,is12Hour:!0}),(0,e.createElement)("div",{className:"gb-datetime-popover-actions"},t&&(0,e.createElement)(i.Button,{variant:"link",onClick:()=>{c(null),n(null),a(!1)},isDestructive:!0},(0,s.__)("Clear","generateblocks-pro")),(0,e.createElement)("div",{className:"gb-datetime-popover-main-actions"},(0,e.createElement)(i.Button,{variant:"tertiary",onClick:u},(0,s.__)("Cancel","generateblocks-pro")),(0,e.createElement)(i.Button,{variant:"primary",onClick:()=>{n(l),a(!1)}},(0,s.__)("Apply","generateblocks-pro")))))));var d}function Be({currentTime:t,onChange:n,placeholder:r=(0,s.__)("Select time","generateblocks-pro")}){const[o,a]=(0,ae.useState)(!1),[l,c]=(0,ae.useState)(t||""),[u,d]=(0,ae.useState)(null),p=()=>!(!l||!/^\d{2}:\d{2}$/.test(l))||!(u&&!u.validity.valid)&&(!l&&!t||!(!l&&t)||!!u&&u.validity.valid),h=()=>{a(!1)};return(0,e.createElement)("div",{className:"gb-datetime-popover-wrapper"},(0,e.createElement)(i.Button,{variant:"secondary",icon:Fe,onClick:()=>{c(t||""),a(!0)},className:"gb-datetime-trigger",__next40pxDefaultSize:!0},(e=>{if(!e)return r;const[t,n]=e.split(":").map(Number);if(isNaN(t)||isNaN(n))return e;const o=new Date;return o.setHours(t,n,0,0),o.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit",hour12:!0})})(t)),o&&(0,e.createElement)(i.Popover,{position:"bottom left",onClose:h,className:"gb-datetime-popover gb-time-only-popover"},(0,e.createElement)("div",{className:"gb-datetime-popover-content"},(0,e.createElement)("div",{className:"gb-time-input-wrapper"},(0,e.createElement)("label",{htmlFor:"gb-time-input",className:"gb-time-input-label"},(0,s.__)("Time","generateblocks-pro")),(0,e.createElement)("input",{id:"gb-time-input",type:"time",value:l,onChange:e=>c(e.target.value),className:"gb-time-input",ref:d}),(0,e.createElement)("small",{className:"gb-time-input-help"},(0,s.__)("Enter time in HH:MM format","generateblocks-pro"))),(0,e.createElement)("div",{className:"gb-datetime-popover-actions"},t&&(0,e.createElement)(i.Button,{variant:"link",onClick:()=>{c(""),n(""),a(!1)},isDestructive:!0},(0,s.__)("Clear","generateblocks-pro")),(0,e.createElement)("div",{className:"gb-datetime-popover-main-actions"},(0,e.createElement)(i.Button,{variant:"tertiary",onClick:h},(0,s.__)("Cancel","generateblocks-pro")),(0,e.createElement)(i.Button,{variant:"primary",onClick:()=>{p()&&(n(l),a(!1))},disabled:!p()},(0,s.__)("Apply","generateblocks-pro")))))))}function qe(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function Le(){return Le=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Le.apply(null,arguments)}var Ve=n(5556),ze=n.n(Ve);n(44363);const Qe=e=>"object"==typeof e&&null!=e&&1===e.nodeType,je=(e,t)=>(!t||"hidden"!==e)&&"visible"!==e&&"clip"!==e,He=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){const n=getComputedStyle(e,null);return je(n.overflowY,t)||je(n.overflowX,t)||(e=>{const t=(e=>{if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch(e){return null}})(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)})(e)}return!1},Ue=(e,t,n,r,o,a,s,i)=>a<e&&s>t||a>e&&s<t?0:a<=e&&i<=n||s>=t&&i>=n?a-e-r:s>t&&i<n||a<e&&i>n?s-t+o:0,Ke=e=>{const t=e.parentElement;return null==t?e.getRootNode().host||null:t};var We=function(){return We=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},We.apply(this,arguments)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var Ge=0;function Ye(){}function Je(e,t,n){return e===t||t instanceof n.Node&&e.contains&&e.contains(t)}function Ze(e,t){var n;function r(){n&&clearTimeout(n)}function o(){for(var o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];r(),n=setTimeout((function(){n=null,e.apply(void 0,a)}),t)}return o.cancel=r,o}function Xe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return t.some((function(t){return t&&t.apply(void 0,[e].concat(r)),e.preventDownshiftDefault||e.hasOwnProperty("nativeEvent")&&e.nativeEvent.preventDownshiftDefault}))}}function et(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){t.forEach((function(t){"function"==typeof t?t(e):t&&(t.current=e)}))}}function tt(e,t){return e&&t?Object.keys(e).reduce((function(n,r){return n[r]=nt(t,r)?t[r]:e[r],n}),{}):e}function nt(e,t){return void 0!==e[t]}function rt(e,t,n,r,o){void 0===o&&(o=!1);var a=n.length;if(0===a)return-1;var s=a-1;("number"!=typeof e||e<0||e>s)&&(e=t>0?-1:s+1);var i=e+t;i<0?i=o?s:0:i>s&&(i=o?0:s);var l=ot(i,t<0,n,r,o);return-1===l?e>=a?-1:e:l}function ot(e,t,n,r,o){void 0===o&&(o=!1);var a=n.length;if(t){for(var s=e;s>=0;s--)if(!r(n[s],s))return s}else for(var i=e;i<a;i++)if(!r(n[i],i))return i;return o?ot(t?a-1:0,t,n,r):-1}function at(e,t,n,r){return void 0===r&&(r=!0),n&&t.some((function(t){return t&&(Je(t,e,n)||r&&Je(t,n.document.activeElement,n))}))}var st=Ze((function(e){it(e).textContent=""}),500);function it(e){var t=e.getElementById("a11y-status-message");return t||((t=e.createElement("div")).setAttribute("id","a11y-status-message"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-relevant","additions text"),Object.assign(t.style,{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",width:"1px"}),e.body.appendChild(t),t)}var lt={highlightedIndex:-1,isOpen:!1,selectedItem:null,inputValue:""};var ct=Ze((function(e,t){!function(e,t){e&&t&&(it(t).textContent=e,st(t))}(e,t)}),200),ut="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?e.useLayoutEffect:e.useEffect,dt="useId"in t()?function(n){var r=n.id,o=n.labelId,a=n.menuId,s=n.getItemId,i=n.toggleButtonId,l=n.inputId,c="downshift-"+t().useId();return r||(r=c),(0,e.useRef)({labelId:o||r+"-label",menuId:a||r+"-menu",getItemId:s||function(e){return r+"-item-"+e},toggleButtonId:i||r+"-toggle-button",inputId:l||r+"-input"}).current}:function(t){var n=t.id,r=void 0===n?"downshift-"+String(Ge++):n,o=t.labelId,a=t.menuId,s=t.getItemId,i=t.toggleButtonId,l=t.inputId;return(0,e.useRef)({labelId:o||r+"-label",menuId:a||r+"-menu",getItemId:s||function(e){return r+"-item-"+e},toggleButtonId:i||r+"-toggle-button",inputId:l||r+"-input"}).current};function pt(e){return""+e.slice(0,1).toUpperCase()+e.slice(1)}function ht(t){var n=(0,e.useRef)(t);return n.current=t,n}function gt(t,n,r,o){var a=(0,e.useRef)(),s=(0,e.useRef)(),i=(0,e.useCallback)((function(e,n){s.current=n,e=tt(e,n.props);var r=t(e,n);return n.props.stateReducer(e,Le({},n,{changes:r}))}),[t]),l=(0,e.useReducer)(i,n,r),c=l[0],u=l[1],d=ht(n),p=(0,e.useCallback)((function(e){return u(Le({props:d.current},e))}),[d]),h=s.current;return(0,e.useEffect)((function(){var e=tt(a.current,null==h?void 0:h.props);h&&a.current&&!o(e,c)&&function(e,t,n){var r=e.props,o=e.type,a={};Object.keys(t).forEach((function(r){!function(e,t,n,r){var o=t.props,a=t.type,s="on"+pt(e)+"Change";o[s]&&void 0!==r[e]&&r[e]!==n[e]&&o[s](Le({type:a},r))}(r,e,t,n),n[r]!==t[r]&&(a[r]=n[r])})),r.onStateChange&&Object.keys(a).length&&r.onStateChange(Le({type:o},a))}(h,e,c),a.current=c}),[c,h,o]),[c,p]}var mt={itemToString:function(e){return e?String(e):""},itemToKey:function(e){return e},stateReducer:function(e,t){return t.changes},scrollIntoView:function(e,t){if(e){var n=((e,t)=>{var n,r,o,a;if("undefined"==typeof document)return[];const{scrollMode:s,block:i,inline:l,boundary:c,skipOverflowHiddenElements:u}=t,d="function"==typeof c?c:e=>e!==c;if(!Qe(e))throw new TypeError("Invalid target");const p=document.scrollingElement||document.documentElement,h=[];let g=e;for(;Qe(g)&&d(g);){if(g=Ke(g),g===p){h.push(g);break}null!=g&&g===document.body&&He(g)&&!He(document.documentElement)||null!=g&&He(g,u)&&h.push(g)}const m=null!=(r=null==(n=window.visualViewport)?void 0:n.width)?r:innerWidth,f=null!=(a=null==(o=window.visualViewport)?void 0:o.height)?a:innerHeight,{scrollX:b,scrollY:y}=window,{height:v,width:_,top:w,right:E,bottom:k,left:C}=e.getBoundingClientRect(),{top:S,right:I,bottom:x,left:O}=(e=>{const t=window.getComputedStyle(e);return{top:parseFloat(t.scrollMarginTop)||0,right:parseFloat(t.scrollMarginRight)||0,bottom:parseFloat(t.scrollMarginBottom)||0,left:parseFloat(t.scrollMarginLeft)||0}})(e);let N="start"===i||"nearest"===i?w-S:"end"===i?k+x:w+v/2-S+x,T="center"===l?C+_/2-O+I:"end"===l?E+I:C-O;const R=[];for(let e=0;e<h.length;e++){const t=h[e],{height:n,width:r,top:o,right:a,bottom:c,left:u}=t.getBoundingClientRect();if("if-needed"===s&&w>=0&&C>=0&&k<=f&&E<=m&&(t===p&&!He(t)||w>=o&&k<=c&&C>=u&&E<=a))return R;const d=getComputedStyle(t),g=parseInt(d.borderLeftWidth,10),S=parseInt(d.borderTopWidth,10),I=parseInt(d.borderRightWidth,10),x=parseInt(d.borderBottomWidth,10);let O=0,D=0;const M="offsetWidth"in t?t.offsetWidth-t.clientWidth-g-I:0,P="offsetHeight"in t?t.offsetHeight-t.clientHeight-S-x:0,A="offsetWidth"in t?0===t.offsetWidth?0:r/t.offsetWidth:0,F="offsetHeight"in t?0===t.offsetHeight?0:n/t.offsetHeight:0;if(p===t)O="start"===i?N:"end"===i?N-f:"nearest"===i?Ue(y,y+f,f,S,x,y+N,y+N+v,v):N-f/2,D="start"===l?T:"center"===l?T-m/2:"end"===l?T-m:Ue(b,b+m,m,g,I,b+T,b+T+_,_),O=Math.max(0,O+y),D=Math.max(0,D+b);else{O="start"===i?N-o-S:"end"===i?N-c+x+P:"nearest"===i?Ue(o,c,n,S,x+P,N,N+v,v):N-(o+n/2)+P/2,D="start"===l?T-u-g:"center"===l?T-(u+r/2)+M/2:"end"===l?T-a+I+M:Ue(u,a,r,g,I+M,T,T+_,_);const{scrollLeft:e,scrollTop:s}=t;O=0===F?0:Math.max(0,Math.min(s+O/F,t.scrollHeight-n/F+P)),D=0===A?0:Math.max(0,Math.min(e+D/A,t.scrollWidth-r/A+M)),N+=s-O,T+=e-D}R.push({el:t,top:O,left:D})}return R})(e,{boundary:t,block:"nearest",scrollMode:"if-needed"});n.forEach((function(e){var t=e.el,n=e.top,r=e.left;t.scrollTop=n,t.scrollLeft=r}))}},environment:"undefined"==typeof window?void 0:window};function ft(e,t,n){void 0===n&&(n=lt);var r=e["default"+pt(t)];return void 0!==r?r:n[t]}function bt(e,t,n){void 0===n&&(n=lt);var r=e[t];if(void 0!==r)return r;var o=e["initial"+pt(t)];return void 0!==o?o:ft(e,t,n)}function yt(e,t,n){var r=e.items,o=e.initialHighlightedIndex,a=e.defaultHighlightedIndex,s=e.isItemDisabled,i=e.itemToKey,l=t.selectedItem,c=t.highlightedIndex;return 0===r.length?-1:void 0===o||c!==o||s(r[o],o)?void 0===a||s(r[a],a)?l?r.findIndex((function(e){return i(l)===i(e)})):n<0&&!s(r[r.length-1],r.length-1)?r.length-1:n>0&&!s(r[0],0)?0:-1:a:o}var vt=Ye;function _t(e,t,n){var r;return void 0===n&&(n=!0),Le({isOpen:!1,highlightedIndex:-1},(null==(r=e.items)?void 0:r.length)&&t>=0&&Le({selectedItem:e.items[t],isOpen:ft(e,"isOpen"),highlightedIndex:ft(e,"highlightedIndex")},n&&{inputValue:e.itemToString(e.items[t])}))}function wt(e,t){return e.isOpen===t.isOpen&&e.inputValue===t.inputValue&&e.highlightedIndex===t.highlightedIndex&&e.selectedItem===t.selectedItem}function Et(){var e=t().useRef(!0);return t().useEffect((function(){return e.current=!1,function(){e.current=!0}}),[]),e.current}function kt(e){var t=ft(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}var Ct=Le({},{environment:ze().shape({addEventListener:ze().func.isRequired,removeEventListener:ze().func.isRequired,document:ze().shape({createElement:ze().func.isRequired,getElementById:ze().func.isRequired,activeElement:ze().any.isRequired,body:ze().any.isRequired}).isRequired,Node:ze().func.isRequired}),itemToString:ze().func,itemToKey:ze().func,stateReducer:ze().func},{getA11yStatusMessage:ze().func,highlightedIndex:ze().number,defaultHighlightedIndex:ze().number,initialHighlightedIndex:ze().number,isOpen:ze().bool,defaultIsOpen:ze().bool,initialIsOpen:ze().bool,selectedItem:ze().any,initialSelectedItem:ze().any,defaultSelectedItem:ze().any,id:ze().string,labelId:ze().string,menuId:ze().string,getItemId:ze().func,toggleButtonId:ze().string,onSelectedItemChange:ze().func,onHighlightedIndexChange:ze().func,onStateChange:ze().func,onIsOpenChange:ze().func,scrollIntoView:ze().func});We(We({},Ct),{items:ze().array.isRequired,isItemDisabled:ze().func}),We(We({},mt),{isItemDisabled:function(){return!1}});var St=Object.freeze({__proto__:null,ControlledPropUpdatedSelectedItem:22,FunctionCloseMenu:17,FunctionOpenMenu:16,FunctionReset:21,FunctionSelectItem:19,FunctionSetHighlightedIndex:18,FunctionSetInputValue:20,FunctionToggleMenu:15,InputBlur:9,InputChange:8,InputClick:10,InputKeyDownArrowDown:0,InputKeyDownArrowUp:1,InputKeyDownEnd:4,InputKeyDownEnter:7,InputKeyDownEscape:2,InputKeyDownHome:3,InputKeyDownPageDown:6,InputKeyDownPageUp:5,ItemClick:13,ItemMouseMove:12,MenuMouseLeave:11,ToggleButtonClick:14});function It(e){var t=function(e){var t=bt(e,"selectedItem"),n=bt(e,"isOpen"),r=function(e){var t=bt(e,"highlightedIndex");return t>-1&&e.isItemDisabled(e.items[t],t)?-1:t}(e),o=bt(e,"inputValue");return{highlightedIndex:r<0&&t&&n?e.items.findIndex((function(n){return e.itemToKey(n)===e.itemToKey(t)})):r,isOpen:n,selectedItem:t,inputValue:o}}(e),n=t.selectedItem,r=t.inputValue;return""===r&&n&&void 0===e.defaultInputValue&&void 0===e.initialInputValue&&void 0===e.inputValue&&(r=e.itemToString(n)),Le({},t,{inputValue:r})}Le({},Ct,{items:ze().array.isRequired,isItemDisabled:ze().func,inputValue:ze().string,defaultInputValue:ze().string,initialInputValue:ze().string,inputId:ze().string,onInputValueChange:ze().func});var xt=Ye,Ot=Le({},mt,{isItemDisabled:function(){return!1}});function Nt(e,t){var n,r,o=t.type,a=t.props,s=t.altKey;switch(o){case 13:r={isOpen:ft(a,"isOpen"),highlightedIndex:kt(a),selectedItem:a.items[t.index],inputValue:a.itemToString(a.items[t.index])};break;case 0:r=e.isOpen?{highlightedIndex:rt(e.highlightedIndex,1,a.items,a.isItemDisabled,!0)}:{highlightedIndex:s&&null==e.selectedItem?-1:yt(a,e,1),isOpen:a.items.length>=0};break;case 1:r=e.isOpen?s?_t(a,e.highlightedIndex):{highlightedIndex:rt(e.highlightedIndex,-1,a.items,a.isItemDisabled,!0)}:{highlightedIndex:yt(a,e,-1),isOpen:a.items.length>=0};break;case 7:r=_t(a,e.highlightedIndex);break;case 2:r=Le({isOpen:!1,highlightedIndex:-1},!e.isOpen&&{selectedItem:null,inputValue:""});break;case 5:r={highlightedIndex:rt(e.highlightedIndex,-10,a.items,a.isItemDisabled,!0)};break;case 6:r={highlightedIndex:rt(e.highlightedIndex,10,a.items,a.isItemDisabled,!0)};break;case 3:r={highlightedIndex:ot(0,!1,a.items,a.isItemDisabled)};break;case 4:r={highlightedIndex:ot(a.items.length-1,!0,a.items,a.isItemDisabled)};break;case 9:r=Le({isOpen:!1,highlightedIndex:-1},e.highlightedIndex>=0&&(null==(n=a.items)?void 0:n.length)&&t.selectItem&&{selectedItem:a.items[e.highlightedIndex],inputValue:a.itemToString(a.items[e.highlightedIndex])});break;case 8:r={isOpen:!0,highlightedIndex:kt(a),inputValue:t.inputValue};break;case 10:r={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:yt(a,e,0)};break;case 19:r={selectedItem:t.selectedItem,inputValue:a.itemToString(t.selectedItem)};break;case 22:r={inputValue:t.inputValue};break;default:return function(e,t,n){var r,o=t.type,a=t.props;switch(o){case n.ItemMouseMove:r={highlightedIndex:t.disabled?-1:t.index};break;case n.MenuMouseLeave:r={highlightedIndex:-1};break;case n.ToggleButtonClick:case n.FunctionToggleMenu:r={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:yt(a,e,0)};break;case n.FunctionOpenMenu:r={isOpen:!0,highlightedIndex:yt(a,e,0)};break;case n.FunctionCloseMenu:r={isOpen:!1};break;case n.FunctionSetHighlightedIndex:r={highlightedIndex:a.isItemDisabled(a.items[t.highlightedIndex],t.highlightedIndex)?-1:t.highlightedIndex};break;case n.FunctionSetInputValue:r={inputValue:t.inputValue};break;case n.FunctionReset:r={highlightedIndex:kt(a),isOpen:ft(a,"isOpen"),selectedItem:ft(a,"selectedItem"),inputValue:ft(a,"inputValue")};break;default:throw new Error("Reducer called without proper action type.")}return Le({},e,r)}(e,t,St)}return Le({},e,r)}var Tt=["onMouseLeave","refKey","ref"],Rt=["item","index","refKey","ref","onMouseMove","onMouseDown","onClick","onPress","disabled"],Dt=["onClick","onPress","refKey","ref"],Mt=["onKeyDown","onChange","onInput","onBlur","onChangeText","onClick","refKey","ref"];function Pt(t){void 0===t&&(t={}),xt(t,Pt);var n=Le({},Ot,t),r=n.items,o=n.scrollIntoView,a=n.environment,s=n.getA11yStatusMessage,i=function(t,n,r,o){var a=(0,e.useRef)(),s=gt(t,n,r,o),i=s[0],l=s[1],c=Et();return(0,e.useEffect)((function(){nt(n,"selectedItem")&&(c||n.itemToKey(n.selectedItem)!==n.itemToKey(a.current)&&l({type:22,inputValue:n.itemToString(n.selectedItem)}),a.current=i.selectedItem===a.current?n.selectedItem:i.selectedItem)}),[i.selectedItem,n.selectedItem]),[tt(i,n),l]}(Nt,n,It,wt),l=i[0],c=i[1],u=l.isOpen,d=l.highlightedIndex,p=l.selectedItem,h=l.inputValue,g=(0,e.useRef)(null),m=(0,e.useRef)({}),f=(0,e.useRef)(null),b=(0,e.useRef)(null),y=Et(),v=dt(n),_=(0,e.useRef)(),w=ht({state:l,props:n}),E=(0,e.useCallback)((function(e){return m.current[v.getItemId(e)]}),[v]);!function(t,n,r,o){void 0===o&&(o={});var a=o.document,s=Et();(0,e.useEffect)((function(){if(t&&!s&&a){var e=t(n);ct(e,a)}}),r),(0,e.useEffect)((function(){return function(){var e,t;ct.cancel(),(t=null==(e=a)?void 0:e.getElementById("a11y-status-message"))&&t.remove()}}),[a])}(s,l,[u,d,p,h],a);var k=function(t){var n=t.highlightedIndex,r=t.isOpen,o=t.itemRefs,a=t.getItemNodeFromIndex,s=t.menuElement,i=t.scrollIntoView,l=(0,e.useRef)(!0);return ut((function(){n<0||!r||!Object.keys(o.current).length||(!1===l.current?l.current=!0:i(a(n),s))}),[n]),l}({menuElement:g.current,highlightedIndex:d,isOpen:u,itemRefs:m,scrollIntoView:o,getItemNodeFromIndex:E});vt({props:n,state:l}),(0,e.useEffect)((function(){bt(n,"isOpen")&&f.current&&f.current.focus()}),[]),(0,e.useEffect)((function(){y||(_.current=r.length)}));var C=function(t,n,r){var o=(0,e.useRef)({isMouseDown:!1,isTouchMove:!1,isTouchEnd:!1});return(0,e.useEffect)((function(){if(!t)return Ye;var e=r.map((function(e){return e.current}));function a(){o.current.isTouchEnd=!1,o.current.isMouseDown=!0}function s(r){o.current.isMouseDown=!1,at(r.target,e,t)||n()}function i(){o.current.isTouchEnd=!1,o.current.isTouchMove=!1}function l(){o.current.isTouchMove=!0}function c(r){o.current.isTouchEnd=!0,o.current.isTouchMove||at(r.target,e,t,!1)||n()}return t.addEventListener("mousedown",a),t.addEventListener("mouseup",s),t.addEventListener("touchstart",i),t.addEventListener("touchmove",l),t.addEventListener("touchend",c),function(){t.removeEventListener("mousedown",a),t.removeEventListener("mouseup",s),t.removeEventListener("touchstart",i),t.removeEventListener("touchmove",l),t.removeEventListener("touchend",c)}}),[r,t,n]),o.current}(a,(0,e.useCallback)((function(){w.current.state.isOpen&&c({type:9,selectItem:!1})}),[c,w]),(0,e.useMemo)((function(){return[g,b,f]}),[g.current,b.current,f.current])),S=Ye;(0,e.useEffect)((function(){u||(m.current={})}),[u]),(0,e.useEffect)((function(){var e;u&&null!=a&&a.document&&null!=f&&null!=(e=f.current)&&e.focus&&a.document.activeElement!==f.current&&f.current.focus()}),[u,a]);var I=(0,e.useMemo)((function(){return{ArrowDown:function(e){e.preventDefault(),c({type:0,altKey:e.altKey})},ArrowUp:function(e){e.preventDefault(),c({type:1,altKey:e.altKey})},Home:function(e){w.current.state.isOpen&&(e.preventDefault(),c({type:3}))},End:function(e){w.current.state.isOpen&&(e.preventDefault(),c({type:4}))},Escape:function(e){var t=w.current.state;(t.isOpen||t.inputValue||t.selectedItem||t.highlightedIndex>-1)&&(e.preventDefault(),c({type:2}))},Enter:function(e){w.current.state.isOpen&&229!==e.which&&(e.preventDefault(),c({type:7}))},PageUp:function(e){w.current.state.isOpen&&(e.preventDefault(),c({type:5}))},PageDown:function(e){w.current.state.isOpen&&(e.preventDefault(),c({type:6}))}}}),[c,w]),x=(0,e.useCallback)((function(e){return Le({id:v.labelId,htmlFor:v.inputId},e)}),[v]),O=(0,e.useCallback)((function(e,t){var n,r=void 0===e?{}:e,o=r.onMouseLeave,a=r.refKey,s=void 0===a?"ref":a,i=r.ref,l=qe(r,Tt),u=(void 0===t?{}:t).suppressRefError;return S("getMenuProps",void 0!==u&&u,s,g),Le(((n={})[s]=et(i,(function(e){g.current=e})),n.id=v.menuId,n.role="listbox",n["aria-labelledby"]=l&&l["aria-label"]?void 0:""+v.labelId,n.onMouseLeave=Xe(o,(function(){c({type:11})})),n),l)}),[c,S,v]),N=(0,e.useCallback)((function(e){var t,n,r=void 0===e?{}:e,o=r.item,a=r.index,s=r.refKey,i=void 0===s?"ref":s,l=r.ref,u=r.onMouseMove,d=r.onMouseDown,p=r.onClick;r.onPress;var h=r.disabled,g=qe(r,Rt);void 0!==h&&console.warn('Passing "disabled" as an argument to getItemProps is not supported anymore. Please use the isItemDisabled prop from useCombobox.');var f=w.current,b=f.props,y=f.state,_=function(e,t,n,r){var o,a;if(void 0===e){if(void 0===t)throw new Error(r);o=n[t],a=t}else a=void 0===t?n.indexOf(e):t,o=e;return[o,a]}(o,a,b.items,"Pass either item or index to getItemProps!"),E=_[0],S=_[1],I=b.isItemDisabled(E,S),x=p;return Le(((t={})[i]=et(l,(function(e){e&&(m.current[v.getItemId(S)]=e)})),t["aria-disabled"]=I,t["aria-selected"]=S===y.highlightedIndex,t.id=v.getItemId(S),t.role="option",t),!I&&((n={}).onClick=Xe(x,(function(){c({type:13,index:S})})),n),{onMouseMove:Xe(u,(function(){C.isTouchEnd||S===y.highlightedIndex||(k.current=!1,c({type:12,index:S,disabled:I}))})),onMouseDown:Xe(d,(function(e){return e.preventDefault()}))},g)}),[c,v,w,C,k]),T=(0,e.useCallback)((function(e){var t,n=void 0===e?{}:e,r=n.onClick;n.onPress;var o=n.refKey,a=void 0===o?"ref":o,s=n.ref,i=qe(n,Dt),l=w.current.state;return Le(((t={})[a]=et(s,(function(e){b.current=e})),t["aria-controls"]=v.menuId,t["aria-expanded"]=l.isOpen,t.id=v.toggleButtonId,t.tabIndex=-1,t),!i.disabled&&Le({},{onClick:Xe(r,(function(){c({type:14})}))}),i)}),[c,w,v]),R=(0,e.useCallback)((function(e,t){var n,r=void 0===e?{}:e,o=r.onKeyDown,s=r.onChange,i=r.onInput,l=r.onBlur;r.onChangeText;var u=r.onClick,d=r.refKey,p=void 0===d?"ref":d,h=r.ref,g=qe(r,Mt),m=(void 0===t?{}:t).suppressRefError;S("getInputProps",void 0!==m&&m,p,f);var b,y=w.current.state,_={};return g.disabled||((b={}).onChange=Xe(s,i,(function(e){c({type:8,inputValue:e.target.value})})),b.onKeyDown=Xe(o,(function(e){var t=function(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&0!==t.indexOf("Arrow")?"Arrow"+t:t}(e);t&&I[t]&&I[t](e)})),b.onBlur=Xe(l,(function(e){if(null!=a&&a.document&&y.isOpen&&!C.isMouseDown){var t=null===e.relatedTarget&&a.document.activeElement!==a.document.body;c({type:9,selectItem:!t})}})),b.onClick=Xe(u,(function(){c({type:10})})),_=b),Le(((n={})[p]=et(h,(function(e){f.current=e})),n["aria-activedescendant"]=y.isOpen&&y.highlightedIndex>-1?v.getItemId(y.highlightedIndex):"",n["aria-autocomplete"]="list",n["aria-controls"]=v.menuId,n["aria-expanded"]=y.isOpen,n["aria-labelledby"]=g&&g["aria-label"]?void 0:v.labelId,n.autoComplete="off",n.id=v.inputId,n.role="combobox",n.value=y.inputValue,n),_,g)}),[c,v,a,I,w,C,S]),D=(0,e.useCallback)((function(){c({type:15})}),[c]),M=(0,e.useCallback)((function(){c({type:17})}),[c]),P=(0,e.useCallback)((function(){c({type:16})}),[c]),A=(0,e.useCallback)((function(e){c({type:18,highlightedIndex:e})}),[c]),F=(0,e.useCallback)((function(e){c({type:19,selectedItem:e})}),[c]);return{getItemProps:N,getLabelProps:x,getMenuProps:O,getInputProps:R,getToggleButtonProps:T,toggleMenu:D,openMenu:P,closeMenu:M,setHighlightedIndex:A,setInputValue:(0,e.useCallback)((function(e){c({type:20,inputValue:e})}),[c]),selectItem:F,reset:(0,e.useCallback)((function(){c({type:21})}),[c]),highlightedIndex:d,isOpen:u,selectedItem:p,inputValue:h}}Pt.stateChangeTypes=St,ze().array,ze().array,ze().array,ze().func,ze().number,ze().number,ze().number,ze().func,ze().func,ze().string,ze().string;const At=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})),Ft=(0,ae.createElement)(se.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,ae.createElement)(se.Path,{d:"M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"})),$t=(0,ae.createElement)(se.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,ae.createElement)(se.Path,{d:"M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"}));function Bt({rule:t,ruleMetadata:n,searchContent:r,searchResults:o,recentItems:a,isSearching:l,value:c,onSelect:u,placeholder:d,isMultiValue:p=!1,readOnly:h=!1,className:g="",currentSelectedValues:m=[]}){const[f,b]=(0,ae.useState)([]),[y,v]=(0,ae.useState)(!1),[_,w]=(0,ae.useState)(!1),E=(0,ae.useRef)(c),k=(0,ae.useRef)(t);(0,ae.useEffect)((()=>{c!==E.current&&(E.current=c,w(!1))}),[c]);const C=(0,ae.useCallback)((e=>{const t=e.id.toString();return m.map((e=>e.toString())).includes(t)}),[m]),S=(0,ae.useCallback)((e=>{if(!e)return"";const t=e.title||e.name||"";return""!==e.id&&e.id&&"searching"!==e.type?`${t} (ID: ${e.id})`:t}),[]),I=(0,ae.useCallback)((()=>{if(p)return null;if("object_selector"!==n.value_type&&"hierarchical_object_selector"!==n.value_type)return null;if("author_id"===t)return null;let e=(0,s.__)("All Items","generateblocks-pro");if(t.startsWith("post:")){const n=t.replace("post:","");switch(n){case"post":e=(0,s.__)("All Posts","generateblocks-pro");break;case"page":e=(0,s.__)("All Pages","generateblocks-pro");break;default:const t=n.charAt(0).toUpperCase()+n.slice(1);e=`${(0,s.__)("All","generateblocks-pro")} ${t}`}}else t.startsWith("taxonomy:")||t.startsWith("post_terms:")?e=(0,s.__)("All Terms","generateblocks-pro"):"child_of"===t?e=(0,s.__)("Any Parent","generateblocks-pro"):"parent_of"===t&&(e=(0,s.__)("Any Child","generateblocks-pro"));return{id:"",title:e,name:e}}),[t,n.value_type,p]),x=(0,ae.useCallback)((e=>{const t=I();return t&&e===(t.title||t.name)}),[I]),O=(0,ae.useCallback)((()=>p?0<m.length:c&&c.trim()&&!x(c)),[p,m,c,x]),N=(0,ae.useCallback)((e=>{h||(x(e)&&!_||!_?v(!1):(v(!0),r(e)))}),[r,h,x,_]),{isOpen:T,getMenuProps:R,getInputProps:D,highlightedIndex:M,getItemProps:P,selectItem:A,setHighlightedIndex:F,closeMenu:$,openMenu:B,setInputValue:q}=Pt({items:f,itemToString:e=>e?S(e):"",defaultInputValue:p?"":c,onInputValueChange:({inputValue:e,type:t})=>{t===Pt.stateChangeTypes.InputChange&&w(!0),N(e||"")},onSelectedItemChange:({selectedItem:e})=>{e&&"searching"!==e.type&&(w(!1),u(e))},onIsOpenChange:({isOpen:e})=>{e&&(v(!1),w(!1))},stateReducer:(e,t)=>{const{type:n,changes:r}=t;switch(n){case Pt.stateChangeTypes.InputKeyDownEnter:case Pt.stateChangeTypes.ItemClick:return r.selectedItem&&"searching"===r.selectedItem.type?e:{...r,inputValue:p?"":S(r.selectedItem),isOpen:p};case Pt.stateChangeTypes.InputBlur:return{...r,isOpen:!!h&&e.isOpen};case Pt.stateChangeTypes.MenuKeyDownEscape:return{...r,isOpen:!1};case Pt.stateChangeTypes.InputClick:case Pt.stateChangeTypes.InputFocus:return w(!1),v(!1),r;default:return r}}});(0,ae.useEffect)((()=>{!_&&q&&q((p?"":c)||"")}),[c,_,p,q]);const L=(0,ae.useCallback)((e=>{if(e.preventDefault(),e.stopPropagation(),h||p)return;const t=I();t?A(t):u({id:"",title:"",name:""})}),[h,p,I,A,u]);(0,ae.useEffect)((()=>{if(t!==k.current&&(k.current=t,!p&&(!c||x(c)))){const e=I();e&&A&&setTimeout((()=>{A(e)}),0)}}),[t,p,c,I,A,x]),(0,ae.useEffect)((()=>{const e=I(),t=[];l&&y&&_&&t.push({id:"searching",title:(0,s.__)("Searching…","generateblocks-pro"),name:(0,s.__)("Searching…","generateblocks-pro"),type:"searching"}),e&&t.push(e),y&&_&&0<o.length?t.push(...o):0<a.length&&t.push(...a),b(t)}),[o,a,y,_,I,l]);const V=(0,ae.useCallback)((e=>{if(!h||" "!==e.key||(e.preventDefault(),T)){if(T)switch(e.key){case"Tab":if(e.preventDefault(),e.shiftKey){const e=0>=M?f.length-1:M-1;F(e)}else{const e=f.length-1<=M?0:M+1;F(e)}break;case"Enter":e.preventDefault(),0<=M&&f[M]&&"searching"!==f[M].type&&A(f[M]);break;case"Escape":e.preventDefault(),$();break;case" ":h&&T&&(e.preventDefault(),0<=M&&f[M]&&"searching"!==f[M].type&&A(f[M]));break;case"ArrowDown":case"ArrowUp":break;default:h&&1===e.key.length&&e.preventDefault()}}else B()}),[T,M,f,F,A,$,B,h]);return(0,e.createElement)("div",{className:`gb-object-selector ${g}`},(0,e.createElement)("div",{className:"gb-combobox-container"},(0,e.createElement)("div",{className:"gb-input-wrapper"},(0,e.createElement)("input",{...D({placeholder:d,className:"components-text-control__input gb-object-search",onKeyDown:V,"aria-expanded":T,"aria-haspopup":"listbox",tabIndex:0}),style:{cursor:h?"pointer":"text",userSelect:h?"none":"text"}}),(0,e.createElement)("div",{className:"gb-input-icons"},O()&&!h&&(0,e.createElement)(i.Button,{icon:At,onClick:L,className:"gb-clear-button",size:"compact",label:(0,s.__)("Clear selection","generateblocks-pro"),iconSize:"16"}),0<f.length&&(0,e.createElement)("span",{className:"gb-dropdown-indicator "+(T?"gb-dropdown-indicator--open":""),"aria-hidden":"true"},T?Ft:$t))),(0,e.createElement)("ul",{...R({className:"gb-search-results",role:"listbox","aria-label":(0,s.__)("Search results","generateblocks-pro"),style:{display:T&&0<f.length?"block":"none"}})},T&&0<f.length&&(0,e.createElement)(e.Fragment,null,!h&&!y&&0<a.length&&!l&&(0,e.createElement)("li",{className:"gb-search-results-header",role:"presentation"},(0,s.__)("Recent Items","generateblocks-pro")),f.map(((t,n)=>{const r=C(t),o=M===n,a="searching"===t.type;return(0,e.createElement)("li",{key:`${t.id}-${n}`,...P({item:t,index:n,role:"option","aria-selected":r}),className:`gb-search-result-item ${o?"gb-search-result-item--highlighted":""} ${r?"gb-search-result-item--selected":""} ${a?"gb-search-result-item--searching":""}`,style:{cursor:a?"default":"pointer"}},a?(0,e.createElement)("div",{className:"gb-search-result-item__searching"},(0,e.createElement)(i.Spinner,{size:"16"}),(0,e.createElement)("span",{className:"gb-search-result-item__text"},t.title||t.name)):(0,e.createElement)(e.Fragment,null,(0,e.createElement)("span",{className:"gb-search-result-item__text"},S(t)),r&&(0,e.createElement)("span",{className:"gb-search-result-item__check","aria-hidden":"true"},"✓")))}))))))}const qt=({condition:t,groupIndex:n,conditionIndex:r,onUpdate:o,onRemove:a,conditionTypes:l,logicOperator:c="AND",selectedObjectTitles:u,setSelectedObjectTitles:d})=>{const{getRulesForType:p,getOperatorsForType:h}=Se(),[g,m]=(0,ae.useState)({}),[f,b]=(0,ae.useState)({}),[y,v]=(0,ae.useState)({}),[_,w]=(0,ae.useState)(!1),[E,k]=(0,ae.useState)([]),[C,S]=(0,ae.useState)([]),[I,x]=(0,ae.useState)(""),[O,N]=(0,ae.useState)(!1),[T,R]=(0,ae.useState)(!1),D=()=>t.type&&t.operator&&t.rule;(0,ae.useEffect)((()=>{t.type&&t.operator&&t.rule&&!T&&R(!0)}),[t.type,t.operator,t.rule,T]),(0,ae.useEffect)((()=>{t.type&&(async()=>{try{w(!0);const e=await p(t.type);let a;if(m(e),a=t.rule?await h(t.type,t.rule):await h(t.type),b(a),t.operator&&t.rule){const e=await h(t.type,t.rule);if(e&&!e[t.operator]){const a=Object.keys(e)[0];if(a){const e={...t,operator:a};o(n,r,e)}}}}catch(e){console.error("Error loading condition data:",e)}finally{w(!1)}})()}),[t.type,t.rule,p,h]),(0,ae.useEffect)((()=>{if(t.type&&t.rule&&t.operator&&0!==Object.keys(f).length&&!f[t.operator]){const e=Object.keys(f)[0];if(e){const a={...t,operator:e};o(n,r,a)}else{const e={...t,operator:""};o(n,r,e)}}}),[t.operator,f]),(0,ae.useEffect)((()=>{t.type&&t.rule?(async()=>{try{const e=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/get_rule_metadata?type=${t.type}&rule=${encodeURIComponent(t.rule)}`});e.success&&v(e.response)}catch(e){console.error("Error loading rule metadata:",e),v({needs_value:!0,value_type:"text",supports_multi:!1})}})():v({})}),[t.type,t.rule]),(0,ae.useEffect)((()=>{P()?S(M()):Z()&&t.rule?(async()=>{try{let e;if("hierarchical_object_selector"===y.value_type)e=await Ee()({path:"/generateblocks-pro/advanced-conditions/v1/search_hierarchical_posts"});else if("author_id"===t.rule)e=await Ee()({path:"/generateblocks-pro/advanced-conditions/v1/search_users"});else if(t.rule.startsWith("post:")){const n=t.rule.replace("post:","");e=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_posts?post_type=${n}`})}else if(t.rule.startsWith("taxonomy:")){const n=t.rule.replace("taxonomy:","");e=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_terms?taxonomy=${n}`})}else if(t.rule.startsWith("post_terms:")){const n=t.rule.replace("post_terms:","");e=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_terms?taxonomy=${n}`})}e?.success&&S(e.response)}catch(e){console.error("Error loading recent items:",e)}})():S([])}),[t.rule,y.value_type]);const M=()=>[{id:"1",name:(0,s.__)("Monday","generateblocks-pro")},{id:"2",name:(0,s.__)("Tuesday","generateblocks-pro")},{id:"3",name:(0,s.__)("Wednesday","generateblocks-pro")},{id:"4",name:(0,s.__)("Thursday","generateblocks-pro")},{id:"5",name:(0,s.__)("Friday","generateblocks-pro")},{id:"6",name:(0,s.__)("Saturday","generateblocks-pro")},{id:"7",name:(0,s.__)("Sunday","generateblocks-pro")}],P=()=>"day_selector"===y.value_type,A=()=>"datetime"===y.value_type,F=()=>"time"===y.value_type,$=()=>A()&&"between"===t.operator,B=()=>F()&&"between"===t.operator,q=()=>!!t.operator&&(K()&&W()||Z()&&L()||$()||B()),L=()=>["includes_any","includes_all","excludes_any","excludes_all"].includes(t.operator),V=()=>(e=>{if(!e)return[];if(Array.isArray(e))return e;try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch(e){}return[e]})(t.value),z=e=>{if(!e)return null;const t=new Date(e);return isNaN(t.getTime())?null:t},Q=e=>e?("string"==typeof e&&(e=new Date(e)),isNaN(e.getTime())?"":`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}T${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`):"",j=()=>{if(!$()||!t.value)return null;const e=t.value.split(",").map((e=>e.trim()));return z(e[0])},H=()=>{if(!$()||!t.value)return null;const e=t.value.split(",").map((e=>e.trim()));return z(e[1])},U=(e,t)=>{const n=[e?Q(e):"",t?Q(t):""].filter((e=>e)).join(", ");te("value",n)},K=()=>"custom_field"===y.value_type,W=()=>!!K()&&["equals","contains","not_contains","starts_with","ends_with","greater_than","less_than"].includes(t.operator),G=()=>K()&&t.value?t.value.includes("|")?t.value.split("|")[0]:t.value:"",Y=()=>K()&&t.value&&t.value.includes("|")&&t.value.split("|")[1]||"",J=(e,t="")=>{let n=e;t&&W()&&(n=`${e}|${t}`),te("value",n)},Z=()=>"object_selector"===y.value_type||"hierarchical_object_selector"===y.value_type||"day_selector"===y.value_type,X=()=>{switch(y.value_type){case"custom_field":return"query_arg"===t.type?(0,s.__)("Parameter name","generateblocks-pro"):"post_meta"===t.type?(0,s.__)("Meta key","generateblocks-pro"):(0,s.__)("Field name","generateblocks-pro");case"datetime":return(0,s.__)("Select date and time","generateblocks-pro");case"time":return(0,s.__)("Select time","generateblocks-pro");case"day_selector":return L()?(0,s.__)("Select days…","generateblocks-pro"):(0,s.__)("Select day…","generateblocks-pro");case"hierarchical_object_selector":return"child_of"===t.rule?L()?(0,s.__)("Select parent posts (or leave empty for any parent)","generateblocks-pro"):(0,s.__)("Any Parent (or search for specific)","generateblocks-pro"):"parent_of"===t.rule?L()?(0,s.__)("Select child posts (or leave empty for any child)","generateblocks-pro"):(0,s.__)("Any Child (or search for specific)","generateblocks-pro"):L()?(0,s.__)("Select multiple…","generateblocks-pro"):(0,s.__)("Search or select…","generateblocks-pro");case"object_selector":if("author_id"===t.rule)return L()?(0,s.__)("Select multiple authors…","generateblocks-pro"):(0,s.__)("Select author…","generateblocks-pro");if("location"===t.type&&t.rule.startsWith("post:")){const e=t.rule.replace("post:","");switch(e){case"post":return L()?(0,s.__)("Select multiple posts…","generateblocks-pro"):(0,s.__)("All Posts (or search for specific)","generateblocks-pro");case"page":return L()?(0,s.__)("Select multiple pages…","generateblocks-pro"):(0,s.__)("All Pages (or search for specific)","generateblocks-pro");default:const t=e.charAt(0).toUpperCase()+e.slice(1);return L()?`${(0,s.__)("Select multiple","generateblocks-pro")} ${t}...`:`${(0,s.__)("All","generateblocks-pro")} ${t} (${(0,s.__)("or search for specific","generateblocks-pro")})`}}return L()?(0,s.__)("Select multiple…","generateblocks-pro"):(0,s.__)("Search or select…","generateblocks-pro");default:return"referrer"===t.type?(0,s.__)("Referrer URL or domain","generateblocks-pro"):(0,s.__)("Value","generateblocks-pro")}},ee=(0,ae.useCallback)((async e=>{if(P())return k([]),void N(!1);if(!t.rule||!e)return k([]),void N(!1);try{let n;N(!0);const r=/^\d+$/.test(e.trim()),o=new URLSearchParams;if("hierarchical_object_selector"===y.value_type)r?o.set("id",e.trim()):o.set("search",e),n=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_hierarchical_posts?${o.toString()}`});else if("author_id"===t.rule)r?o.set("id",e.trim()):o.set("search",e),n=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_users?${o.toString()}`});else if(t.rule.startsWith("post:")){const a=t.rule.replace("post:","");o.set("post_type",a),r?o.set("id",e.trim()):o.set("search",e),n=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_posts?${o.toString()}`})}else if(t.rule.startsWith("taxonomy:")){const a=t.rule.replace("taxonomy:","");o.set("taxonomy",a),r?o.set("id",e.trim()):o.set("search",e),n=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_terms?${o.toString()}`})}else if(t.rule.startsWith("post_terms:")){const a=t.rule.replace("post_terms:","");o.set("taxonomy",a),r?o.set("id",e.trim()):o.set("search",e),n=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_terms?${o.toString()}`})}n?.success&&k(n.response)}catch(e){console.error("Error searching content:",e)}finally{N(!1)}}),[t.rule,y.value_type]),te=(e,a)=>{R(!0);const s={...t,[e]:a};if("type"===e){if(s.rule="",s.operator="",s.value="",a){const e={location:{operator:"is",rule:"general:front_page"},user_role:{operator:"is",rule:"general:logged_in"},date_time:{operator:"after",rule:"current_date"},device:{operator:"is",rule:"mobile"},query_arg:{operator:"exists",rule:"custom"},referrer:{operator:"contains",rule:"custom"},post_meta:{operator:"exists",rule:"custom"},user_meta:{operator:"exists",rule:"custom"},cookie:{operator:"exists",rule:"custom"},language:{operator:"is",rule:"locale"},options:{operator:"equals",rule:"custom"},author:{operator:"is",rule:"author_id"}}[a]||{operator:null,rule:null};e.operator&&(s.operator=e.operator),e.rule&&(s.rule=e.rule)}}else"operator"===e?L()!==["includes_any","includes_all","excludes_any","excludes_all"].includes(a)&&(s.value=""):"rule"===e&&(s.value="",d((e=>{const t={...e};return delete t[`${n}-${r}`],Object.keys(t).forEach((e=>{e.startsWith(`${n}-${r}-`)&&delete t[e]})),t})));o(n,r,s)};return(0,e.createElement)("div",{className:(()=>{let e="gb-condition-row";return T&&D()?e+=" gb-condition-complete":T&&!D()&&(e+=" gb-condition-incomplete"),e})()},(0,e.createElement)("div",{className:"gb-condition-row-main"},0===r?(0,e.createElement)("div",{className:"gb-logic-label"},(0,e.createElement)("span",{className:`gb-logic-operator gb-logic-${c.toLowerCase()}`},"IF")):(0,e.createElement)("div",{className:"gb-logic-label"},(0,e.createElement)("span",{className:`gb-logic-operator gb-logic-${c.toLowerCase()}`},c)),(0,e.createElement)("div",{className:"gb-condition-fields"},(0,e.createElement)(i.SelectControl,{value:t.type,onChange:e=>te("type",e),options:[{label:(0,s.__)("Select type…","generateblocks-pro"),value:""},...Object.entries(l).sort((([,e],[,t])=>e.label.localeCompare(t.label))).map((([e,t])=>({label:t.label,value:e})))],className:"gb-condition-type",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),_&&(0,e.createElement)(i.Spinner,null),t.type&&!_&&(0,e.createElement)(i.SelectControl,{value:t.operator,onChange:e=>te("operator",e),options:[{label:(0,s.__)("Select operator…","generateblocks-pro"),value:""},...Object.entries(f).map((([e,t])=>({label:t,value:e})))],className:"gb-condition-operator",disabled:_,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),t.type&&!_&&(0,e.createElement)(i.SelectControl,{value:t.rule,onChange:e=>te("rule",e),options:[{label:(0,s.__)("Select rule…","generateblocks-pro"),value:""},...Object.entries(g).filter((([e])=>"date_time"!==t.type||"time_of_day"!==e||"time_of_day"===t.rule)).map((([e,t])=>({label:t,value:e})))],className:"gb-condition-rule",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),t.rule&&t.operator&&!q()&&(0,e.createElement)(e.Fragment,null,K()&&!W()&&(0,e.createElement)(i.TextControl,{value:G(),onChange:e=>J(e),placeholder:X(),className:"gb-condition-value",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),!(!t.operator||["exists","not_exists"].includes(t.operator))&&(void 0===y.needs_value||y.needs_value)&&!K()&&!Z()&&!A()&&!F()&&(0,e.createElement)(i.TextControl,{value:t.value||"",onChange:e=>te("value",e),placeholder:X(),className:"gb-condition-value",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),A()&&!$()&&(0,e.createElement)($e,{currentDate:A()&&t.value&&!$()?z(t.value):null,onChange:e=>{const t=Q(e);te("value",t)},placeholder:X()}),F()&&!B()&&(0,e.createElement)(Be,{currentTime:t.value||"",onChange:e=>te("value",e),placeholder:X()}),Z()&&!L()&&(0,e.createElement)(Bt,{rule:t.rule,ruleMetadata:y,searchContent:ee,searchResults:E,recentItems:C,isSearching:O,value:(()=>{let e=u[`${n}-${r}`];if(!e&&t.value&&t.value.trim()){const o=`${n}-${r}-${t.value.trim()}`;e=u[o]}if(e)return t.value&&t.value.trim()&&!e.startsWith("ID: ")?`${e} (ID: ${t.value.trim()})`:e;if(!t.value||""===t.value){if("author_id"===t.rule)return"";if(t.rule.startsWith("post:")){const e=t.rule.replace("post:","");switch(e){case"post":return(0,s.__)("All Posts","generateblocks-pro");case"page":return(0,s.__)("All Pages","generateblocks-pro");default:const t=e.charAt(0).toUpperCase()+e.slice(1);return`${(0,s.__)("All","generateblocks-pro")} ${t}`}}else{if(t.rule.startsWith("taxonomy:")||t.rule.startsWith("post_terms:"))return(0,s.__)("All Terms","generateblocks-pro");if("child_of"===t.rule)return(0,s.__)("Any Parent","generateblocks-pro");if("parent_of"===t.rule)return(0,s.__)("Any Child","generateblocks-pro")}return(0,s.__)("All Items","generateblocks-pro")}return t.value&&t.value.trim()?`ID: ${t.value.trim()}`:""})(),onSelect:e=>{te("value",e.id.toString()),d((t=>({...t,[`${n}-${r}`]:e.title||e.name}))),k([])},placeholder:X(),isMultiValue:!1,readOnly:P(),className:"gb-inline-selector",currentSelectedValues:[t.value||""]}))),(0,e.createElement)(i.Button,{isDestructive:!0,variant:"tertiary",icon:Te,onClick:()=>a(n,r),className:"gb-remove-condition",label:(0,s.__)("Remove condition","generateblocks-pro"),size:"compact",iconSize:"16"})),t.rule&&t.operator&&q()&&(0,e.createElement)("div",{className:"gb-condition-expansion"},K()&&W()&&(0,e.createElement)("div",{className:"gb-custom-field-expansion"},(0,e.createElement)("div",{className:"gb-custom-field-inputs"},(0,e.createElement)(i.TextControl,{value:G(),onChange:e=>J(e,Y()),label:X(),className:"gb-condition-custom-field"}),(0,e.createElement)(i.TextControl,{value:Y(),onChange:e=>J(G(),e),label:(0,s.__)("Value to compare","generateblocks-pro"),className:"gb-condition-comparison-value"}))),$()&&(0,e.createElement)("div",{className:"gb-date-range-expansion"},(0,e.createElement)("div",{className:"gb-date-range-inputs"},(0,e.createElement)("div",{className:"gb-datetime-picker-field"},(0,e.createElement)("div",{className:"components-base-control__label"},(0,s.__)("Start Date & Time","generateblocks-pro")),(0,e.createElement)($e,{currentDate:j(),onChange:e=>U(e,H()),placeholder:(0,s.__)("Select start date…","generateblocks-pro")})),(0,e.createElement)("div",{className:"gb-datetime-picker-field"},(0,e.createElement)("div",{className:"components-base-control__label"},(0,s.__)("End Date & Time","generateblocks-pro")),(0,e.createElement)($e,{currentDate:H(),onChange:e=>U(j(),e),placeholder:(0,s.__)("Select end date…","generateblocks-pro")})))),B()&&(0,e.createElement)("div",{className:"gb-time-range-expansion"},(0,e.createElement)("div",{className:"gb-time-range-inputs"},(0,e.createElement)("div",{className:"gb-time-picker-field"},(0,e.createElement)("div",{className:"components-base-control__label"},(0,s.__)("Start Time","generateblocks-pro")),(0,e.createElement)(Be,{currentTime:t.value?t.value.split(",")[0]?.trim():"",onChange:e=>{const n=t.value?t.value.split(",")[1]?.trim():"";te("value",e&&n?`${e}, ${n}`:e||"")},placeholder:(0,s.__)("Select start time…","generateblocks-pro")})),(0,e.createElement)("div",{className:"gb-time-picker-field"},(0,e.createElement)("div",{className:"components-base-control__label"},(0,s.__)("End Time","generateblocks-pro")),(0,e.createElement)(Be,{currentTime:t.value?t.value.split(",")[1]?.trim():"",onChange:e=>{const n=t.value?t.value.split(",")[0]?.trim():"";te("value",n&&e?`${n}, ${e}`:e||"")},placeholder:(0,s.__)("Select end time…","generateblocks-pro")})))),Z()&&L()&&(0,e.createElement)("div",{className:"gb-multi-select-expansion"},(0,e.createElement)("div",{className:"gb-multi-object-selector"},(0,e.createElement)("div",{className:"gb-selected-items"},0===V().length?(0,e.createElement)("div",{className:"gb-empty-selection"},(0,e.createElement)("span",null,(0,s.__)("No items selected","generateblocks-pro"))):V().map((t=>{const o=u[`${n}-${r}-${t}`]||`ID: ${t}`;return(0,e.createElement)("div",{key:t,className:"gb-selected-item"},(0,e.createElement)("span",null,o),(0,e.createElement)(i.Button,{icon:xe,onClick:()=>(e=>{const t=V().filter((t=>t!==e));te("value",t.length>0?JSON.stringify(t):""),d((t=>{const o={...t};return delete o[`${n}-${r}-${e}`],o}))})(t),className:"gb-remove-selected-item",size:"compact",iconSize:"12",label:(0,s.__)("Remove item","generateblocks-pro")}))}))),(0,e.createElement)(Bt,{rule:t.rule,ruleMetadata:y,searchContent:ee,searchResults:E,recentItems:C,isSearching:O,value:I,onSelect:e=>{const t=V(),o=e.id.toString();if(!t.includes(o)){const a=[...t,o];te("value",JSON.stringify(a)),d((t=>({...t,[`${n}-${r}-${o}`]:e.title||e.name})))}x(""),k([])},placeholder:P()?(0,s.__)("Click to select days…","generateblocks-pro"):(0,s.__)("Search to add items…","generateblocks-pro"),isMultiValue:!0,readOnly:P(),className:"",currentSelectedValues:V()})))))};function Lt(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(Lt);if("object"==typeof e){const t={};for(const n in e)e.hasOwnProperty(n)&&(t[n]=Lt(e[n]));return t}return e}function Vt(e,t){if(e===t)return!0;if(null===e||null===t||"object"!=typeof e||"object"!=typeof t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){if(!r.includes(o))return!1;if(!Vt(e[o],t[o]))return!1}return!0}function zt({onNavigateBack:t,onSave:n=null,initialConditions:r=null,initialTitle:o="",conditionId:a=null,isNew:l=!1,onUnsavedChanges:c=null}){const{conditionTypes:u,loading:d}=Se(),p=_e({mutationFn:async({title:e,conditions:t,category:n,status:r})=>{let o;o=n?Array.isArray(n)?n:[n]:[];const a=await Ee()({path:"/generateblocks-pro/advanced-conditions/v1/conditions/",method:"POST",data:{title:e,conditions:t||{logic:"OR",groups:[]},category:o.length>0?o:"",status:r||"publish"}});if(a.success)return a.response;throw new Error("Failed to create condition")},onSuccess:()=>{oe()}}),h=_e({mutationFn:async({id:e,title:t,conditions:n,category:r,status:o})=>{let a;a=r?Array.isArray(r)?r:[r]:[];const s=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${e}`,method:"PUT",data:{title:t,category:a.length>0?a:"",conditions:n,status:o}});if(s.success)return s.response;throw new Error("Failed to update condition")},onSuccess:()=>{oe()}}),g=(0,ae.useRef)(null),m=!!a&&!l,f=(0,ae.useMemo)((()=>({conditions:r?.groups?.length>0?Lt(r):{logic:"OR",groups:[{logic:"AND",conditions:[{type:"",rule:"",operator:"",value:""}]}]},conditionTitle:o||"",selectedObjectTitles:{},isSaving:!1})),[r,o]),[b,y]=(0,ae.useState)(f.conditions),[v,_]=(0,ae.useState)(f.conditionTitle),[w,E]=(0,ae.useState)(""),[k,C]=(0,ae.useState)("publish"),[S,I]=(0,ae.useState)([]),[x,O]=(0,ae.useState)(!1),[N,T]=(0,ae.useState)(f.selectedObjectTitles),[R,D]=(0,ae.useState)(f.isSaving),[M,P]=(0,ae.useState)(null),[A,F]=(0,ae.useState)(null);(0,ae.useEffect)((()=>{y(r?.groups?.length>0?Lt(r):{logic:"OR",groups:[{logic:"AND",conditions:[{type:"",rule:"",operator:"",value:""}]}]}),_(o||""),T({})}),[r,o]),(0,ae.useEffect)((()=>{m&&a&&(async()=>{try{const e=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${a}`});if(e?.success){if(e.response?.gblocks_condition_cat?.length>0){const t=e.response.gblocks_condition_cat[0],n=await Ee()({path:`/wp/v2/condition-categories/${t}`});n&&n.slug&&E(n.slug)}e.response?.status&&(C(e.response.status),F((t=>({...t,conditionStatus:e.response.status}))))}}catch(e){}})()}),[m,a]),(0,ae.useEffect)((()=>{(async()=>{try{const e=await Ee()({path:"/wp/v2/condition-categories"});e&&I(e)}catch(e){}})()}),[]),(0,ae.useEffect)((()=>{y(f.conditions),_(f.conditionTitle),T(f.selectedObjectTitles),D(f.isSaving),P(null),F({conditions:Lt(f.conditions),conditionTitle:f.conditionTitle,conditionStatus:"publish"})}),[f]);const $=(0,ae.useMemo)((()=>!!A&&!Vt({conditions:b,conditionTitle:v,conditionStatus:k},A)),[b,v,k,A]);(0,ae.useEffect)((()=>{c&&c($);const e=new CustomEvent("gb-conditions-unsaved-changes",{detail:{hasUnsavedChanges:$}});window.dispatchEvent(e)}),[$,c]),(0,ae.useEffect)((()=>{if(!$)return;const e=e=>(e.preventDefault(),e.returnValue=(0,s.__)("You have unsaved changes. Are you sure you want to leave?","generateblocks-pro"),e.returnValue);return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}}),[$]),(0,ae.useEffect)((()=>{b.groups&&(g.current&&g.current.abort(),(async()=>{g.current=new AbortController;try{await B(g.current.signal)}catch(e){"AbortError"!==e.name&&console.debug("Title loading failed:",e)}})())}),[b.groups]),(0,ae.useEffect)((()=>()=>{g.current&&g.current.abort()}),[]);const B=async e=>{const t={};for(let n=0;n<b.groups.length;n++){const r=b.groups[n];for(let o=0;o<r.conditions.length;o++){const a=r.conditions[o];if(e?.aborted)throw new Error("AbortError");if(!a.rule||!a.value)continue;const s=q(a.value);if(0!==s.length)if("date_time"!==a.type||"day_of_week"!==a.rule){if(a.rule.startsWith("post:")||a.rule.startsWith("taxonomy:")||a.rule.startsWith("post_terms:")||"child_of"===a.rule||"parent_of"===a.rule||"author_id"===a.rule)for(const r of s){if(!r)continue;if(e?.aborted)throw new Error("AbortError");const s=["includes_any","includes_all","excludes_any","excludes_all"].includes(a.operator)?`${n}-${o}-${r}`:`${n}-${o}`;if(t[s])continue;let i=null;if("author_id"===a.rule)i=await j(r,e);else if("child_of"===a.rule||"parent_of"===a.rule)i=await Q(r,e);else if(a.rule.startsWith("post:")){const t=a.rule.replace("post:","");i=await V(r,t,e)}else if(a.rule.startsWith("taxonomy:")||a.rule.startsWith("post_terms:")){let t;t=a.rule.startsWith("taxonomy:")?a.rule.replace("taxonomy:",""):a.rule.replace("post_terms:",""),i=await z(r,t,e)}t[s]=i||`ID: ${r}`}}else for(const e of s)t[["includes_any","includes_all","excludes_any","excludes_all"].includes(a.operator)?`${n}-${o}-${e}`:`${n}-${o}`]=L(e)}}T(t)},q=e=>{if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch(e){}return[e]},L=e=>({1:(0,s.__)("Monday","generateblocks-pro"),2:(0,s.__)("Tuesday","generateblocks-pro"),3:(0,s.__)("Wednesday","generateblocks-pro"),4:(0,s.__)("Thursday","generateblocks-pro"),5:(0,s.__)("Friday","generateblocks-pro"),6:(0,s.__)("Saturday","generateblocks-pro"),7:(0,s.__)("Sunday","generateblocks-pro")}[e]||e),V=async(e,t,n=null)=>{try{const r=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_posts?post_type=${t}`,signal:n});if(r?.success&&r.response){const t=r.response.find((t=>t.id.toString()===e.toString()));if(t)return t.title}const o=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_posts?post_type=${t}&id=${encodeURIComponent(e)}`,signal:n});if(o?.success&&o.response){const t=o.response.find((t=>t.id.toString()===e.toString()));if(t)return t.title}}catch(n){if("AbortError"===n.name)throw n;console.debug("Could not fetch post title for ID:",e,"Type:",t,n)}return null},z=async(e,t,n=null)=>{try{const r=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_terms?taxonomy=${t}`,signal:n});if(r?.success&&r.response){const t=r.response.find((t=>t.id.toString()===e.toString()));if(t)return t.name}const o=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_terms?taxonomy=${t}&id=${encodeURIComponent(e)}`,signal:n});if(o?.success&&o.response){const t=o.response.find((t=>t.id.toString()===e.toString()));if(t)return t.name}}catch(n){if("AbortError"===n.name)throw n;console.debug("Could not fetch term name for ID:",e,"Taxonomy:",t,n)}return null},Q=async(e,t=null)=>{try{const n=await Ee()({path:"/generateblocks-pro/advanced-conditions/v1/search_hierarchical_posts",signal:t});if(n?.success&&n.response){const t=n.response.find((t=>t.id.toString()===e.toString()));if(t)return t.title.replace(/^(—\s*)+/,"")}const r=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_hierarchical_posts?id=${encodeURIComponent(e)}`,signal:t});if(r?.success&&r.response){const t=r.response.find((t=>t.id.toString()===e.toString()));if(t)return t.title.replace(/^(—\s*)+/,"")}}catch(t){if("AbortError"===t.name)throw t;console.debug("Could not fetch hierarchical post title for ID:",e,t)}return null},j=async(e,t=null)=>{try{const n=await Ee()({path:"/generateblocks-pro/advanced-conditions/v1/search_users",signal:t});if(n?.success&&n.response){const t=n.response.find((t=>t.id.toString()===e.toString()));if(t)return t.name||t.title}const r=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/search_users?id=${encodeURIComponent(e)}`,signal:t});if(r?.success&&r.response){const t=r.response.find((t=>t.id.toString()===e.toString()));if(t)return t.name||t.title}}catch(t){if("AbortError"===t.name)throw t;console.debug("Could not fetch user name for ID:",e,t)}return null},H=(e,t,n)=>{y((r=>{const o={...r};return o.groups[e].conditions[t]=n,o}))},U=(e,t)=>{y((n=>({...n,groups:n.groups.map(((n,r)=>{if(r!==e)return n;const o=n.conditions.filter(((e,n)=>n!==t));return{...n,conditions:o}})).filter((e=>0<e.conditions.length))})))},K=async(e,t)=>{try{let r;if(r=m?await h.mutateAsync({id:a,title:e,conditions:t,category:w,status:k}):await p.mutateAsync({title:e,conditions:t,category:w,status:k}),!r)throw new Error("Failed to save condition");n&&n({id:r.id||a,title:e,conditions:t,isNew:!m})}catch(e){throw console.error("Error saving condition:",e),P((0,s.__)("Failed to save condition. Please try again.","generateblocks-pro")),e}},W=!l||v.trim();return(0,e.createElement)("div",{className:"gb-conditions-editor"},(0,e.createElement)("div",{className:"gb-conditions-editor-header"},(0,e.createElement)("div",{className:"gb-conditions-title-section"},(0,e.createElement)(i.TextControl,{label:(0,s.__)("Condition Name","generateblocks-pro"),value:v,onChange:_,placeholder:(0,s.__)("Enter condition name…","generateblocks-pro"),className:"gb-condition-title-input",disabled:R,hideLabelFromVision:!0}),(0,e.createElement)(i.SelectControl,{label:(0,s.__)("Category","generateblocks-pro"),value:w,onChange:e=>{"new"===e?O(!0):E(e)},options:[{label:(0,s.__)("No category","generateblocks-pro"),value:""},...S.map((e=>({label:(0,ce.decodeEntities)(e.name),value:e.slug}))),{label:(0,s.__)("+ Add new category","generateblocks-pro"),value:"new"}],className:"gb-condition-category-select",disabled:R,hideLabelFromVision:!0,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})),(0,e.createElement)("div",{className:"gb-conditions-header-actions"},(0,e.createElement)(i.SelectControl,{label:(0,s.__)("Status","generateblocks-pro"),value:k,onChange:C,options:[{label:(0,s.__)("Published","generateblocks-pro"),value:"publish"},{label:(0,s.__)("Draft","generateblocks-pro"),value:"draft"}],className:"gb-condition-status-select",disabled:R,hideLabelFromVision:!0,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)(i.Button,{variant:"secondary",onClick:()=>{if($){const e=(0,s.__)("You have unsaved changes. Are you sure you want to go back without saving?","generateblocks-pro");if(!window.confirm(e))return}t()},disabled:R},(0,s.__)("Cancel","generateblocks-pro")),(0,e.createElement)(i.Button,{variant:"primary",onClick:async()=>{try{if(P(null),!v.trim())return void P((0,s.__)("Please enter a condition name.","generateblocks-pro"));const e=(e=>{const t=[];return e.groups&&0!==e.groups.length?(e.groups.forEach(((e,n)=>{e.conditions&&0!==e.conditions.length?e.conditions.filter((e=>e.type)).forEach((r=>{const o=e.conditions.indexOf(r)+1,a=(0,s.sprintf)(
// translators: %1$s is the condition number (1-based index), %2$s is the group number (1-based index).
// translators: %1$s is the condition number (1-based index), %2$s is the group number (1-based index).
(0,s.__)("Condition %1$s in Group %2$s","generateblocks-pro"),o,n+1);r.operator||t.push(`${a}: ${(0,s.__)("Please select an operator.","generateblocks-pro")}`),r.rule||t.push(`${a}: ${(0,s.__)("Please select a rule.","generateblocks-pro")}`)})):t.push((0,s.sprintf)(
// translators: %d is the group number (1-based index).
// translators: %d is the group number (1-based index).
(0,s.__)("Group %d has no conditions.","generateblocks-pro"),n+1))})),{isValid:0===t.length,errors:t}):{isValid:!0,errors:[]}})(b);if(!e.isValid){const t=(0,s.__)("Please complete the following:","generateblocks-pro")+"\n\n"+e.errors.join("\n");return void P(t)}if(!b.groups||0===b.groups.length)return void await K(v,{logic:"OR",groups:[]});D(!0);const t=(e=>{if(!e.groups)return e;const t=e.groups.map((e=>({...e,conditions:e.conditions.filter((e=>!!(e.type&&e.operator&&e.rule)||(e.type||e.operator||e.rule||e.value,!1)))}))).filter((e=>e.conditions.length>0));return{...e,groups:t}})(b);if(!(await Ee()({path:"/generateblocks-pro/advanced-conditions/v1/validate_conditions",method:"POST",data:{conditions:t}})).success)return void P((0,s.__)("Condition validation failed. Please check your configuration and try again.","generateblocks-pro"));await K(v,t)}catch(e){console.error("Error saving condition:",e);let t=(0,s.__)("Failed to save condition. Please try again.","generateblocks-pro");e.message&&e.message.includes("validation")&&(t=(0,s.__)("Condition validation failed. Please check that all fields are properly filled out.","generateblocks-pro")),P(t)}finally{D(!1)}},disabled:!v.trim()||R,isBusy:R},R?(0,s.__)("Saving…","generateblocks-pro"):(0,s.__)("Save Conditions","generateblocks-pro")))),(0,e.createElement)("div",{className:"gb-conditions-content"},$&&(0,e.createElement)(i.Notice,{status:"info",isDismissible:!1,className:"gb-conditions-unsaved-notice"},(0,s.__)("You have unsaved changes.","generateblocks-pro")),!!M&&(0,e.createElement)(i.Notice,{status:"error",isDismissible:!1,className:"gb-conditions-error-notice"},(0,e.createElement)("div",{style:{whiteSpace:"pre-line"}},M)),d?(0,e.createElement)("div",{className:"gb-loading"},(0,e.createElement)(i.Spinner,null),(0,e.createElement)("p",null,(0,s.__)("Loading condition types…","generateblocks-pro"))):(0,e.createElement)(e.Fragment,null,W&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"gb-conditions-groups"},b.groups&&0<b.groups.length?b.groups.map(((t,n)=>(0,e.createElement)("div",{key:n,className:"gb-condition-group"},(0,e.createElement)("div",{className:"gb-group-header"},(0,e.createElement)("div",{className:"gb-group-logic"},(0,e.createElement)("span",{className:"gb-group-label"},(0,s.__)("Group Logic","generateblocks-pro")),(0,e.createElement)(i.SelectControl,{value:t.logic,onChange:e=>((e,t)=>{y((n=>{const r={...n};return r.groups[e].logic=t,r}))})(n,e),options:[{label:(0,s.__)("AND","generateblocks-pro"),value:"AND"},{label:(0,s.__)("OR","generateblocks-pro"),value:"OR"}],className:"gb-group-logic-select",disabled:R,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})),1<b.groups.length&&(0,e.createElement)(i.Button,{isDestructive:!0,variant:"tertiary",icon:Te,onClick:()=>(e=>{y((t=>({...t,groups:t.groups.filter(((t,n)=>n!==e))})))})(n),className:"gb-remove-group",label:(0,s.__)("Remove group","generateblocks-pro"),size:"compact",iconSize:"16",disabled:R})),(0,e.createElement)("div",{className:"gb-group-conditions"},t.conditions.map(((r,o)=>(0,e.createElement)(qt,{key:o,condition:r,groupIndex:n,conditionIndex:o,onUpdate:H,onRemove:U,conditionTypes:u,logicOperator:t.logic,selectedObjectTitles:N,setSelectedObjectTitles:T})))),(0,e.createElement)(i.Button,{variant:"secondary",icon:le,onClick:()=>(e=>{y((t=>({...t,groups:t.groups.map(((t,n)=>n===e?{...t,conditions:[...t.conditions,{type:"",rule:"",operator:"",value:""}]}:t))})))})(n),className:"gb-add-condition",disabled:R},(0,s.__)("Add","generateblocks-pro")," ",t.logic.toUpperCase()," ",(0,s.__)("condition","generateblocks-pro"))))):(0,e.createElement)("div",{className:"gb-no-conditions"},(0,e.createElement)("p",null,(0,s.__)("No conditions set","generateblocks-pro")),(0,e.createElement)(i.Button,{variant:"primary",icon:le,onClick:()=>{y({logic:"OR",groups:[{logic:"AND",conditions:[{type:"",rule:"",operator:"",value:""}]}]})},disabled:R},(0,s.__)("Add first condition","generateblocks-pro")))),b.groups&&0===b.groups.length&&W&&(0,e.createElement)("div",{className:"gb-conditions-help-text"},(0,e.createElement)("p",null,(0,s.__)("Create your first condition to control when this content should appear.","generateblocks-pro"))),b.groups&&0<b.groups.length&&(0,e.createElement)(i.Button,{variant:"tertiary",icon:le,onClick:()=>{y((e=>({...e,logic:e.logic||"OR",groups:[...e.groups,{logic:"AND",conditions:[{type:"",rule:"",operator:"",value:""}]}]})))},className:"gb-add-group",disabled:R},"AND"===(b.logic||"OR")?(0,s.__)("Add AND condition group","generateblocks-pro"):(0,s.__)("Add OR condition group","generateblocks-pro")),b.groups&&1<b.groups.length&&(0,e.createElement)("div",{className:"gb-top-level-logic"},(0,e.createElement)(i.SelectControl,{label:(0,s.__)("How should these condition groups be combined?","generateblocks-pro"),value:b.logic||"OR",onChange:e=>{y((t=>({...t,logic:e})))},options:[{label:(0,s.__)("OR - Show if ANY group matches","generateblocks-pro"),value:"OR"},{label:(0,s.__)("AND - Show only if ALL groups match","generateblocks-pro"),value:"AND"}],help:"OR"===(b.logic||"OR")?(0,s.__)("Content will show if any condition group is satisfied.","generateblocks-pro"):(0,s.__)("Content will show only if all condition groups are satisfied.","generateblocks-pro"),disabled:R,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0})),(0,e.createElement)(Pe,{conditions:b,onConditionsImport:e=>{y(e)}})),l&&!v.trim()&&(0,e.createElement)("div",{className:"gb-conditions-help-text"},(0,e.createElement)("p",null,(0,s.__)("Enter a condition name above to start building your conditions.","generateblocks-pro"))))),(0,e.createElement)(Ae,{isOpen:x,onClose:()=>O(!1),onCreateCategory:async({name:e,slug:t})=>{try{await Ee()({path:"/wp/v2/condition-categories",method:"POST",data:{name:e,slug:t}})&&(I([...S,{name:e,slug:t}]),E(t))}catch(e){throw e}}}))}function Qt(t){return(0,e.createElement)(d,{client:re()},(0,e.createElement)(zt,{...t}))}const jt=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})),Ht=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"M14.5 13.8c-1.1 0-2.1.7-2.4 1.8H4V17h8.1c.3 1 1.3 1.8 2.4 1.8s2.1-.7 2.4-1.8H20v-1.5h-3.1c-.3-1-1.3-1.7-2.4-1.7zM11.9 7c-.3-1-1.3-1.8-2.4-1.8S7.4 6 7.1 7H4v1.5h3.1c.3 1 1.3 1.8 2.4 1.8s2.1-.7 2.4-1.8H20V7h-8.1z"})),Ut=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z"})),Kt=(0,ae.createElement)(se.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,ae.createElement)(se.Path,{d:"M19 6.2h-5.9l-.6-1.1c-.3-.7-1-1.1-1.8-1.1H5c-1.1 0-2 .9-2 2v11.8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8.2c0-1.1-.9-2-2-2zm.5 11.6c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h5.8c.2 0 .4.1.4.3l1 2H19c.3 0 .5.2.5.5v9.5zM8 12.8h8v-1.5H8v1.5zm0 3h8v-1.5H8v1.5z"})),Wt=(0,ae.createElement)(se.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,ae.createElement)(se.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),Gt=window.gbp.components;function Yt({condition:t,onClose:n}){const{conditionTypes:r,getRulesForType:o,getOperatorsForType:a}=Se(),{loadObjectTitles:l}=function(){const e=re();return{loadObjectTitles:(0,ae.useCallback)((async t=>{if(!t||0===t.length)return{};const n=[],r={};if(t.forEach((t=>{const o=["object-title",t.type,t.id],a=e.getQueryData(o);a?r[`${t.type}-${t.id}`]=a:n.push(t)})),0===n.length)return r;const o=await Ee()({path:"/generateblocks-pro/advanced-conditions/v1/batch_object_titles",method:"POST",data:{requests:n}});return o.success&&o.response?(Object.entries(o.response).forEach((([t,n])=>{const[r,o]=t.split("-");e.setQueryData(["object-title",r,o],n)})),{...r,...o.response}):r}),[e])}}(),[c,u]=(0,ae.useState)({}),[d,p]=(0,ae.useState)({}),[h,g]=(0,ae.useState)({}),[m,f]=(0,ae.useState)(!0);(0,ae.useEffect)((()=>{(async()=>{try{f(!0);const e=t.gbConditions||{groups:[]},n=new Set,r={},s={};e.groups?.forEach((e=>{e.conditions?.forEach((e=>{e.type&&n.add(e.type)}))}));for(const e of n)try{const t=await o(e);r[e]=t;const n=await a(e);s[e]=n}catch(t){console.error(`Error loading data for type ${e}:`,t)}p(r),g(s),await b(e)}catch(e){console.error("Error loading condition data:",e)}finally{f(!1)}})()}),[t,o,a,l]);const b=async e=>{const t=[];if(e.groups?.forEach((e=>{e.conditions?.forEach((e=>{if(!e.rule||!e.value)return;const n=y(e.value);0!==n.length&&(e.rule.startsWith("post:")||e.rule.startsWith("taxonomy:")||e.rule.startsWith("post_terms:")||"child_of"===e.rule||"parent_of"===e.rule||"date_time"===e.type&&"day_of_week"===e.rule)&&n.forEach((n=>{n&&t.push({type:e.type,rule:e.rule,value:n})}))}))})),t.length>0){const e=t.map((e=>{let t;return t=e.rule.startsWith("post:")?"post":e.rule.startsWith("taxonomy:")||e.rule.startsWith("post_terms:")?"term":"author_id"===e.rule?"user":e.type,{type:t,id:e.value}})),n=await l(e);u(n)}},y=e=>{if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch(e){}return[e]},v=t.gbConditions||{groups:[]},_=v.groups&&0<v.groups.length;return(0,e.createElement)(i.Modal,{title:t.title?.rendered||t.title||(0,s.__)("Untitled Condition","generateblocks-pro"),onRequestClose:n,className:"gb-modal-condition-details",size:"medium"},(0,e.createElement)("div",{className:"gb-modal-details-content"},m?(0,e.createElement)("div",{className:"gb-modal-loading"},(0,e.createElement)(i.Spinner,null),(0,e.createElement)("p",null,(0,s.__)("Loading condition details…","generateblocks-pro"))):(0,e.createElement)("div",{className:"gb-modal-details-body"},_?(0,e.createElement)(e.Fragment,null,1<v.groups.length&&(0,e.createElement)("div",{className:"gb-modal-main-logic"},(0,e.createElement)("strong",null,(0,s.__)("Overall Logic:","generateblocks-pro"))," ","AND"===v.logic?(0,s.__)("ALL condition groups must match","generateblocks-pro"):(0,s.__)("ANY condition group can match","generateblocks-pro")),(0,e.createElement)("div",{className:"gb-modal-condition-groups"},v.groups.map(((t,n)=>(0,e.createElement)("div",{key:n,className:"gb-modal-condition-group"},(0,e.createElement)("div",{className:"gb-modal-group-header"},(0,e.createElement)("h4",null,1<v.groups.length?`${(0,s.__)("Group","generateblocks-pro")} ${n+1}`:(0,s.__)("Conditions","generateblocks-pro")),1<t.conditions.length&&(0,e.createElement)("span",{className:"gb-modal-group-logic-badge"},"AND"===t.logic?(0,s.__)("ALL must match","generateblocks-pro"):(0,s.__)("ANY can match","generateblocks-pro"))),(0,e.createElement)("div",{className:"gb-modal-condition-list"},t.conditions.filter((e=>e.type&&e.rule&&e.operator)).map(((t,n)=>{return(0,e.createElement)("div",{key:n,className:"gb-modal-condition-item"},(0,e.createElement)("div",{className:"gb-modal-condition-summary"},(0,e.createElement)("span",{className:"gb-modal-condition-type-badge"},(i=t.type,r[i]?.label||i)),(0,e.createElement)("span",{className:"gb-modal-condition-rule-badge"},((e,t)=>d[e]?.[t]||t)(t.type,t.rule)),(0,e.createElement)("span",{className:"gb-modal-condition-operator-badge"},((e,t)=>h[e]?.[t]||t)(t.type,t.operator))),(!(!(o=t).value||!o.value.trim())||(a=o.operator,!["exists","not_exists"].includes(a)))&&(0,e.createElement)("div",{className:"gb-modal-condition-value"},(0,e.createElement)("strong",null,(0,s.__)("Value:","generateblocks-pro"))," ",(t=>{if(!t.value)return(0,s.__)("(no value)","generateblocks-pro");if("date_time"===t.type&&"day_of_week"===t.rule){const e=y(t.value);return 0===e.length?(0,s.__)("(no days selected)","generateblocks-pro"):e.map((e=>e)).join(", ")}if(t.value.includes("|")){const n=t.value.split("|",2);return(0,e.createElement)("div",{className:"gb-modal-custom-field-value"},(0,e.createElement)("div",null,(0,e.createElement)("strong",null,(0,s.__)("Field:","generateblocks-pro"))," ",n[0]),n[1]&&(0,e.createElement)("div",null,(0,e.createElement)("strong",null,(0,s.__)("Value:","generateblocks-pro"))," ",n[1]))}if(t.value.includes(",")&&"between"===t.operator){const n=t.value.split(",").map((e=>e.trim()));return(0,e.createElement)("div",{className:"gb-modal-date-range-value"},(0,e.createElement)("div",null,(0,e.createElement)("strong",null,(0,s.__)("From:","generateblocks-pro"))," ",n[0]),(0,e.createElement)("div",null,(0,e.createElement)("strong",null,(0,s.__)("To:","generateblocks-pro"))," ",n[1]||(0,s.__)("(not set)","generateblocks-pro")))}const n=y(t.value);if(0===n.length)return t.value;const r=n.map((e=>{let n;return n=t.rule.startsWith("post:")?"post":t.rule.startsWith("taxonomy:")||t.rule.startsWith("post_terms:")?"term":"author_id"===t.rule?"user":t.type,c[`${n}-${e}`]||e}));return 1===r.length?r[0]:r.join(", ")})(t)));var o,a,i})))))))):(0,e.createElement)("div",{className:"gb-modal-no-conditions"},(0,e.createElement)("p",null,(0,s.__)("This condition has no rules configured.","generateblocks-pro"))))))}function Jt({condition:t,onClose:n}){const[r,o]=(0,ae.useState)(null),[a,l]=(0,ae.useState)(!0),[c,u]=(0,ae.useState)(null),d=async()=>{try{l(!0),u(null);const e=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${t.id}/usage`});e.success?o(e.response):u(e.response||(0,s.__)("Failed to load usage data","generateblocks-pro"))}catch(e){console.error("Error loading usage data:",e),u((0,s.__)("Error loading usage data. Please try again.","generateblocks-pro"))}finally{l(!1)}};(0,ae.useEffect)((()=>{d()}),[t.id]);const p=r&&r.usage&&0<Object.keys(r.usage).length;return(0,e.createElement)(i.Modal,{title:t.title?.rendered||t.title||(0,s.__)("Untitled Condition","generateblocks-pro"),onRequestClose:n,className:"gb-modal-condition-usage",size:"medium"},(0,e.createElement)("div",{className:"gb-modal-usage-content"},a&&(0,e.createElement)("div",{className:"gb-modal-loading"},(0,e.createElement)(i.Spinner,null),(0,e.createElement)("p",null,(0,s.__)("Searching for usage…","generateblocks-pro"))),!a&&c&&(0,e.createElement)("div",{className:"gb-modal-error"},(0,e.createElement)("p",{style:{color:"#d63638"}},c),(0,e.createElement)(i.Button,{variant:"secondary",onClick:d},(0,s.__)("Try Again","generateblocks-pro"))),!a&&!c&&(0,e.createElement)("div",{className:"gb-modal-usage-body"},!p&&(0,e.createElement)("div",{className:"gb-modal-no-usage"},(0,e.createElement)("p",{style:{fontSize:"16px",textAlign:"center",color:"#666"}},(0,s.__)("This condition is not currently being used anywhere on your site.","generateblocks-pro")),(0,e.createElement)("p",{style:{fontSize:"14px",textAlign:"center",color:"#999"}},(0,s.__)("You can safely delete it, or keep it for future use.","generateblocks-pro"))),p&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"gb-modal-usage-summary"},(0,e.createElement)("p",{style:{fontSize:"14px",color:"#666",margin:"0"}},(0,s.__)("Found usage in","generateblocks-pro")," ",(0,e.createElement)("strong",null,r.total)," ",1===r.total?(0,s.__)("location","generateblocks-pro"):(0,s.__)("locations","generateblocks-pro"))),(0,e.createElement)("div",{className:"gb-modal-usage-sections"},Object.entries(r.usage).map((([t,n])=>(0,e.createElement)("div",{key:t,className:"gb-modal-usage-section"},(0,e.createElement)("h4",{className:"gb-modal-usage-section-title"},n.label,(0,e.createElement)("span",{className:"gb-modal-usage-count"},"(",n.total,")")),(0,e.createElement)("div",{className:"gb-modal-usage-items"},n.items.map((t=>(0,e.createElement)("div",{key:`${t.type}-${t.id}`,className:"gb-modal-usage-item"},(0,e.createElement)("div",{className:"gb-modal-usage-item-main"},(0,e.createElement)("div",{className:"gb-modal-usage-item-title"},(0,e.createElement)("strong",null,t.title),(t=>{const n={publish:(0,s.__)("Published","generateblocks-pro"),draft:(0,s.__)("Draft","generateblocks-pro"),private:(0,s.__)("Private","generateblocks-pro")},r={publish:{bg:"#d1fae5",color:"#065f46",border:"#a7f3d0"},draft:{bg:"#fef3c7",color:"#92400e",border:"#fcd34d"},private:{bg:"#e0e7ff",color:"#3730a3",border:"#c7d2fe"}},o=r[t]||r.draft;return(0,e.createElement)("span",{style:{background:o.bg,color:o.color,border:`1px solid ${o.border}`,padding:"2px 6px",borderRadius:"4px",fontSize:"11px",fontWeight:"500",textTransform:"uppercase"}},n[t]||t)})(t.status)),(0,e.createElement)("div",{className:"gb-modal-usage-item-meta"},(0,e.createElement)("span",{className:"gb-modal-usage-item-type"},t.type_label),(0,e.createElement)("span",{className:"gb-modal-usage-item-usage-type"},(e=>({overlay_display_condition:(0,s.__)("Overlay Panel Display Condition","generateblocks-pro"),block_conditions:(0,s.__)("Block Conditions","generateblocks-pro"),menu_item_conditions:(0,s.__)("Menu Item Conditions","generateblocks-pro")}[e]||e))(t.usage_type),t.block_count>1&&"block_conditions"===t.usage_type&&(0,e.createElement)("span",{style:{marginLeft:"5px",opacity:.7}},"(",t.block_count," ",(0,s.__)("blocks","generateblocks-pro"),")")))),(0,e.createElement)("div",{className:"gb-modal-usage-item-actions"},t.edit_url&&(0,e.createElement)(i.Button,{variant:"secondary",size:"compact",icon:ie,href:t.edit_url,target:"_blank",iconSize:"14"},(0,s.__)("Edit","generateblocks-pro")),t.view_url&&(0,e.createElement)(i.Button,{variant:"tertiary",size:"compact",icon:Ie,href:t.view_url,target:"_blank",iconSize:"14"},(0,s.__)("View","generateblocks-pro")))))))))))))))}function Zt({conditions:t,onEditCondition:n,refreshKey:r}){const o=_e({mutationFn:async e=>{const t=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${e}`,method:"DELETE"});if(t.success)return t.response;throw new Error("Failed to delete condition")},onSuccess:()=>{oe()}}),a=_e({mutationFn:async({id:e,status:t})=>{const n=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${e}`,method:"PUT",data:{status:t}});if(n.success)return n.response;throw new Error("Failed to update condition status")},onSuccess:()=>{oe()}}),l=_e({mutationFn:async e=>{const t=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${e}`});if(!t?.success)throw new Error("Failed to fetch condition for duplication");const n=t.response;let r=n.title;"object"==typeof r&&r?.rendered&&(r=r.rendered);let o=n.gblocks_condition_cat||n.category||[];Array.isArray(o)||(o=o?[o]:[]);let a=[];if(o.length>0){const e=await Ee()({path:"/wp/v2/condition-categories?include="+o.join(",")});e&&Array.isArray(e)&&(a=e.map((e=>e.slug)))}const s=n.gbConditions||n.conditions||{logic:"OR",groups:[]},i=await Ee()({path:"/generateblocks-pro/advanced-conditions/v1/conditions/",method:"POST",data:{title:r+" (Copy)",conditions:s,category:a,status:n.status||"publish"}});if(i.success)return i.response;throw new Error("Failed to duplicate condition")},onSuccess:()=>{oe(),re().invalidateQueries({queryKey:["condition-categories"]})}}),[c,u]=(0,ae.useState)(null),[d,p]=(0,ae.useState)(null),[h,g]=(0,ae.useState)(null),[m,f]=(0,ae.useState)([]),b=re();(0,ae.useEffect)((()=>{(async()=>{try{const e=await Ee()({path:"/wp/v2/condition-categories"});e&&f(e)}catch(e){}})()}),[r]);const y=(0,ae.useMemo)((()=>[{id:"name",header:(0,s.__)("Name","generateblocks-pro"),accessorKey:"title.rendered",cell:t=>{const r=t.row.original,o="draft"===r.status;return(0,e.createElement)("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},(0,e.createElement)(i.Button,{variant:"link",onClick:()=>n(r)},t.getValue()),o&&(0,e.createElement)("span",{style:{color:"#999",fontSize:"0.9em"}},"(",(0,s.__)("draft","generateblocks-pro"),")"))}},{id:"category",header:(0,s.__)("Category","generateblocks-pro"),cell:t=>{const n=t.row.original,r=n.gblocks_condition_cat?.[0];if(!r)return(0,e.createElement)("span",{className:"gb-condition-category gb-condition-category--uncategorized"},(0,s.__)("Uncategorized","generateblocks-pro"));const o=m.find((e=>e.id===r)),a=o?(0,ce.decodeEntities)(o.name):`ID: ${r}`;return(0,e.createElement)("span",{className:"gb-condition-category"},a)}},{id:"conditions_count",header:(0,s.__)("Conditions","generateblocks-pro"),cell:t=>{const n=t.row.original,r=n.gbConditions||{groups:[]},o=r.groups?.reduce(((e,t)=>e+(t.conditions?.filter((e=>e.type&&e.rule&&e.operator)).length||0)),0)||0;return 0===o?(0,e.createElement)(e.Fragment,null,(0,s.__)("No conditions","generateblocks-pro")):(0,e.createElement)(i.Button,{variant:"link",iconSize:"14",onClick:()=>p(n),className:"gb-conditions-details-button"},o," ",1===o?(0,s.__)("condition","generateblocks-pro"):(0,s.__)("conditions","generateblocks-pro"))}},{id:"actions",header:null,cell:t=>{const{status:r,id:o}=t.row.original;return(0,e.createElement)(i.DropdownMenu,{icon:jt,label:(0,s.__)("More options","generateblocks-pro"),className:"gb-cloud-public-keys__dropdown",popoverProps:{placement:"left"}},(({onClose:c})=>(0,e.createElement)(e.Fragment,null,(0,e.createElement)(i.MenuGroup,null,(0,e.createElement)(i.MenuItem,{onClick:()=>{n(t.row.original),c()},icon:Ht},(0,s.__)("Edit Condition","generateblocks-pro")),(0,e.createElement)(i.MenuItem,{onClick:()=>{g(t.row.original),c()},icon:Ut},(0,s.__)("Check Usage","generateblocks-pro")),(0,e.createElement)(i.MenuItem,{onClick:()=>{l.mutateAsync(o).then((e=>{b.invalidateQueries({queryKey:["conditions"]}),e&&n(e)})),c()},icon:Re},(0,s.__)("Duplicate","generateblocks-pro")),(0,e.createElement)(i.MenuItem,{onClick:()=>{const e="publish"===r?"draft":"publish";a.mutateAsync({id:o,status:e}).then((()=>{b.invalidateQueries({queryKey:["conditions"]})})),c()},icon:"publish"===r?Kt:Wt},"publish"===r?(0,s.__)("Set as Draft","generateblocks-pro"):(0,s.__)("Publish","generateblocks-pro")),(0,e.createElement)(i.MenuItem,{isDestructive:!0,onClick:()=>{u(o),c()},icon:Te},(0,s.__)("Delete Condition","generateblocks-pro"))))))}}]),[n,m]);return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"gb-dashboard-table-wrapper"},t.length?(0,e.createElement)(Gt.Table,{className:"gb-dashboard-table table-view-list",columns:y,data:t,"aria-labelledby":"conditions-table-header"}):(0,e.createElement)("p",{style:{marginTop:"0"}},(0,s.__)("No conditions found.","generateblocks-pro"))),!!c&&(0,e.createElement)(i.Modal,{title:(0,s.__)("Confirm","generateblocks-pro"),isDismissible:!1,onRequestClose:()=>null,style:{maxWidth:"300px"}},(0,e.createElement)("div",{style:{marginBottom:"1em"}},(0,s.__)("This will permanently delete this condition. You cannot undo this action.","generateblocks-pro")),(0,e.createElement)(i.Button,{variant:"primary",onClick:async()=>{await o.mutateAsync(c),b.invalidateQueries({queryKey:["conditions"]}),u(null)}},(0,s.__)("OK","generateblocks-pro")),(0,e.createElement)(i.Button,{variant:"tertiary",onClick:()=>u(null)},(0,s.__)("Cancel","generateblocks-pro"))),d&&(0,e.createElement)(Yt,{condition:d,onClose:()=>p(null)}),h&&(0,e.createElement)(Jt,{condition:h,onClose:()=>g(null)}))}function Xt({category:t,updateCategory:n,saving:r}){const[o,a]=(0,ae.useState)(!1),[l,c]=(0,ae.useState)((0,ce.decodeEntities)(t.name)),[u,d]=(0,ae.useState)(!1),p=async()=>{d(!0),await n(t.id,l),d(!1),a(!1)},h=()=>{a(!1),c((0,ce.decodeEntities)(t.name))};return o&&!t.isUncategorized?(0,e.createElement)("div",{className:"gb-edit-taxonomy-form"},(0,e.createElement)(i.TextControl,{value:l,onChange:c,disabled:u||r,onKeyDown:e=>{"Enter"===e.key?p():"Escape"===e.key&&h()},__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)("div",{className:"gb-edit-actions"},(0,e.createElement)(i.Button,{variant:"primary",size:"small",onClick:p,disabled:!l.trim()||u||r,isBusy:u||r,__next40pxDefaultSize:!0},(0,s.__)("Save","generateblocks-pro")),(0,e.createElement)(i.Button,{variant:"secondary",size:"small",onClick:h,disabled:u||r,__next40pxDefaultSize:!0},(0,s.__)("Cancel","generateblocks-pro")))):(0,e.createElement)("div",{style:{display:"flex",alignItems:"center",gap:"10px"}},(0,e.createElement)("strong",{className:t.isUncategorized?"gb-uncategorized-label":""},(0,ce.decodeEntities)(t.name)),!t.isUncategorized&&(0,e.createElement)(i.Button,{icon:ie,size:"small",onClick:()=>{a(!0),c((0,ce.decodeEntities)(t.name))},label:(0,s.__)("Edit category name","generateblocks-pro"),style:{visibility:"hidden"},className:"gb-taxonomy-edit-button"}))}function en({taxonomyConfig:t={slug:"",restBase:"",labels:{singular:"Category",plural:"Categories",uncategorized:"Uncategorized",itemsCount:"items"}},itemsEndpoint:n,itemsTaxonomyField:r,manageEndpoint:o,onNavigateBack:a,onTaxonomyChange:l}){const[c,u]=(0,ae.useState)([]),[d,p]=(0,ae.useState)(!1),[h,g]=(0,ae.useState)(!1),[m,f]=(0,ae.useState)(null),[b,y]=(0,ae.useState)(""),{labels:v={},restBase:_}=t;(0,ae.useEffect)((()=>{w()}),[]);const w=async()=>{p(!0),f(null);try{const e=[Ee()({path:`/wp/v2/${_}`})];n&&e.push(Ee()({path:`${n}?per_page=100`}));const t=await Promise.all(e),o=t[0],a=t[1];if(o){let e=[...o];if(a?.success&&r){const t=(a.response?.[Object.keys(a.response)[0]]||[]).filter((e=>!e[r]||0===e[r].length)).length;e=[{id:"uncategorized",name:v.uncategorized||(0,s.__)("Uncategorized","generateblocks-pro"),slug:"",count:t,isUncategorized:!0},...o]}u(e)}}catch(e){f((0,s.__)("Failed to load categories.","generateblocks-pro"))}finally{p(!1)}},E=async()=>{if(b.trim()){g(!0),f(null);try{const e=b.toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-");(await Ee()({path:o,method:"POST",data:{name:b.trim(),slug:e}})).success&&(await w(),y(""),l&&l())}catch(e){f((0,s.__)("Failed to create category.","generateblocks-pro"))}finally{g(!1)}}},k=async(e,t)=>{if(t.trim()){g(!0),f(null);try{(await Ee()({path:`${o}/${e}`,method:"POST",data:{name:t.trim()}})).success&&(await w(),l&&l())}catch(e){f((0,s.__)("Failed to update category.","generateblocks-pro"))}finally{g(!1)}}},C=async e=>{const t=v.singular?.toLowerCase()||"category",n=(0,s.sprintf)(/* translators: %1$s: singular taxonomy label, %2$s: singular taxonomy label */ /* translators: %1$s: singular taxonomy label, %2$s: singular taxonomy label */
(0,s.__)("Are you sure you want to delete this %1$s? Items using this %2$s will become uncategorized.","generateblocks-pro"),t,t);if(confirm(n)){g(!0),f(null);try{(await Ee()({path:`${o}/${e}`,method:"DELETE"})).success&&(await w(),l&&l())}catch(e){f((0,s.__)("Failed to delete category.","generateblocks-pro"))}finally{g(!1)}}},S=(0,ae.useMemo)((()=>[{id:"name",header:(0,s.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */
(0,s.__)("%s Name","generateblocks-pro"),v.singular||"Category"),accessorKey:"name",cell:t=>{const n=t.row.original;return(0,e.createElement)(Xt,{category:n,updateCategory:k,saving:h})}},{id:"items",header:v.itemsCount?v.itemsCount.charAt(0).toUpperCase()+v.itemsCount.slice(1):(0,s.__)("Items","generateblocks-pro"),cell:e=>`${e.row.original.count||0} ${v.itemsCount||"items"}`},{id:"actions",header:(0,s.__)("Actions","generateblocks-pro"),cell:t=>{const n=t.row.original;return n.isUncategorized?(0,e.createElement)("span",{className:"gb-uncategorized-actions"},(0,s.__)("Built-in","generateblocks-pro")):(0,e.createElement)(i.DropdownMenu,{icon:jt,label:(0,s.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */
(0,s.__)("%s actions","generateblocks-pro"),v.singular||"Category"),className:"gb-taxonomy-actions",popoverProps:{placement:"left"}},(({onClose:t})=>(0,e.createElement)(i.MenuGroup,null,(0,e.createElement)(i.MenuItem,{icon:Te,onClick:()=>{C(n.id),t()},isDestructive:!0},(0,s.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */
(0,s.__)("Delete %s","generateblocks-pro"),v.singular||"Category")))))}}]),[v,k,C,h]);return(0,e.createElement)("div",{className:"gb-taxonomy-manager"},(0,e.createElement)("div",{className:"gb-taxonomy-manager-header"},(0,e.createElement)("div",{className:"gb-taxonomy-title-section"},(0,e.createElement)("h2",null,(0,s.sprintf)(/* translators: %s: plural taxonomy label */ /* translators: %s: plural taxonomy label */
(0,s.__)("Manage %s","generateblocks-pro"),v.plural||"Categories"))),(0,e.createElement)("div",{className:"gb-taxonomy-header-actions"},(0,e.createElement)(i.Button,{variant:"secondary",onClick:()=>{a()},disabled:h},(0,s.__)("Back","generateblocks-pro")))),(0,e.createElement)("div",{className:"gb-taxonomy-content"},!!m&&(0,e.createElement)(i.Notice,{status:"error",isDismissible:!1,className:"gb-taxonomy-error-notice"},m),(0,e.createElement)("div",{className:"gb-create-taxonomy-section"},(0,e.createElement)("h3",null,(0,s.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */
(0,s.__)("Create New %s","generateblocks-pro"),v.singular||"Category")),(0,e.createElement)("div",{className:"gb-create-taxonomy-form"},(0,e.createElement)(i.TextControl,{label:(0,s.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */
(0,s.__)("%s Name","generateblocks-pro"),v.singular||"Category"),value:b,onChange:y,placeholder:(0,s.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */
(0,s.__)("Enter %s name…","generateblocks-pro"),v.singular?.toLowerCase()||"category"),disabled:h,onKeyDown:e=>{"Enter"===e.key&&E()},__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,e.createElement)(i.Button,{variant:"primary",icon:le,onClick:E,disabled:!b.trim()||h,isBusy:h,__next40pxDefaultSize:!0},(0,s.sprintf)(/* translators: %s: singular taxonomy label */ /* translators: %s: singular taxonomy label */
(0,s.__)("Create %s","generateblocks-pro"),v.singular||"Category")))),(0,e.createElement)("div",{className:"gb-taxonomy-list-section"},(0,e.createElement)("h3",null,(0,s.sprintf)(/* translators: %s: plural taxonomy label */ /* translators: %s: plural taxonomy label */
(0,s.__)("Existing %s","generateblocks-pro"),v.plural||"Categories")),d?(0,e.createElement)("div",{className:"gb-taxonomy-loading"},(0,e.createElement)(i.Spinner,null),(0,e.createElement)("span",null,(0,s.sprintf)(/* translators: %s: plural taxonomy label */ /* translators: %s: plural taxonomy label */
(0,s.__)("Loading %s…","generateblocks-pro"),v.plural?.toLowerCase()||"categories"))):(0,e.createElement)("div",{className:"gb-dashboard-table-wrapper"},0===c.length?(0,e.createElement)("p",{style:{marginTop:"0"}},(0,s.sprintf)(/* translators: %s: plural taxonomy label */ /* translators: %s: plural taxonomy label */
(0,s.__)("No %s created yet.","generateblocks-pro"),v.plural?.toLowerCase()||"categories")):(0,e.createElement)(Gt.Table,{className:"gb-dashboard-table table-view-list",columns:S,data:c,"aria-labelledby":"taxonomy-table-header"})))))}const tn={taxonomyConfig:{slug:"gblocks_condition_cat",restBase:"condition-categories",labels:{singular:(0,s.__)("Category","generateblocks-pro"),plural:(0,s.__)("Categories","generateblocks-pro"),uncategorized:(0,s.__)("Uncategorized","generateblocks-pro"),itemsCount:"conditions"}},itemsEndpoint:"/generateblocks-pro/advanced-conditions/v1/conditions",itemsTaxonomyField:"gblocks_condition_cat",manageEndpoint:"/generateblocks-pro/advanced-conditions/v1/manage_category"};function nn({onNavigateBack:t,onCategoriesChange:n}){return(0,e.createElement)("div",{className:"gb-categories-manager"},(0,e.createElement)(en,{...tn,onNavigateBack:t,onTaxonomyChange:n}))}function rn({isModalMode:t=!1,onConditionSelect:n=null,onCreateCondition:r=null}={}){const[o,a]=(0,ae.useState)((()=>{const e=new URLSearchParams(window.location.search);return parseInt(e.get("conditionPage")||"1",10)})),[l,c]=(0,ae.useState)("list"),[u,d]=(0,ae.useState)({conditionId:null,initialConditions:null,initialTitle:"",isNew:!1}),{data:p,isLoading:h}=Ce(20,o),g=p?.conditions||[],m=p?.pages||1,[f,b]=(0,ae.useState)(0),y=re(),v=(0,ae.useMemo)((()=>g&&g.length>0?g.map((e=>{const t=e.title?.rendered||e.title||"Untitled";return{...e,title:{...e.title,rendered:t}}})):[]),[g]);(0,ae.useEffect)((()=>{if(t)return;const e=new URLSearchParams(window.location.search),n=e.get("edit");if(e.get("categories"))c("categories");else if(n&&"new"!==n){const e=v.find((e=>e.id.toString()===n));e&&(d({conditionId:e.id,initialConditions:e.gbConditions||{logic:"OR",groups:[]},initialTitle:e.title?.rendered||"",isNew:!1}),c("edit"))}else"new"===n?(d({conditionId:null,initialConditions:{logic:"OR",groups:[]},initialTitle:"",isNew:!0}),c("edit")):c("list")}),[v,t]);const _=(e,n=null)=>{if(t)return;const r=new URL(window.location);"edit"===e?(n?r.searchParams.set("edit",n):r.searchParams.set("edit","new"),r.searchParams.delete("categories")):"categories"===e?(r.searchParams.set("categories","manage"),r.searchParams.delete("edit")):(r.searchParams.delete("edit"),r.searchParams.delete("categories")),window.history.pushState({},"",r)};(0,ae.useEffect)((()=>{if(t)return;const e=new URL(window.location);e.searchParams.set("conditionPage",o),window.history.replaceState({},"",e)}),[o,t]);const w=e=>{a(e)},E=()=>{c("list"),_("list"),d({conditionId:null,initialConditions:null,initialTitle:"",isNew:!1})};if((0,ae.useEffect)((()=>{if(t)return;const e=()=>{const e=new URLSearchParams(window.location.search),t=e.get("edit");if(e.get("categories"))c("categories");else if(t&&"new"!==t){const e=v.find((e=>e.id.toString()===t));e&&(d({conditionId:e.id,initialConditions:e.gbConditions||{logic:"OR",groups:[]},initialTitle:e.title?.rendered||"",isNew:!1}),c("edit"))}else"new"===t?(d({conditionId:null,initialConditions:{logic:"OR",groups:[]},initialTitle:"",isNew:!0}),c("edit")):c("list")};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),[v,t]),h)return(0,e.createElement)("div",{className:"gb-dashboard-admin"},(0,e.createElement)(i.Spinner,null));const k={list:(0,e.createElement)("div",{className:"gb-dashboard-admin"},(0,e.createElement)("div",{className:"gb-dashboard-admin__header"},(0,e.createElement)("div",{className:"gb-dashboard-admin__header-buttons"},(0,e.createElement)(i.Button,{variant:"primary",onClick:()=>{t&&r?r():(d({conditionId:null,initialConditions:{logic:"OR",groups:[]},initialTitle:"",isNew:!0}),c("edit"),_("edit"))}},(0,s.__)("Add New","generateblocks-pro"))),(0,e.createElement)("div",{className:"gb-dashboard-admin__header-buttons-right"},(0,e.createElement)(i.Button,{variant:"secondary",onClick:()=>{c("categories"),_("categories")}},(0,s.__)("Manage Categories","generateblocks-pro")))),(0,e.createElement)("div",{className:"gb-dashboard-admin__inner"},(0,e.createElement)(Zt,{conditions:v,onEditCondition:e=>{t&&n?n(e):(d({conditionId:e.id,initialConditions:e.gbConditions||{logic:"OR",groups:[]},initialTitle:e.title?.rendered||"",isNew:!1}),c("edit"),_("edit",e.id))},refreshKey:f}),m>1&&(0,e.createElement)("div",{className:"gb-dashboard__pagination"},(0,e.createElement)(i.Button,{disabled:1===o,onClick:()=>w(o-1),variant:"secondary"},(0,s.__)("Previous","generateblocks-pro")),(0,e.createElement)("span",null,(0,s.sprintf)(
// translators: %1$s: current page, %2$s: total pages
// translators: %1$s: current page, %2$s: total pages
(0,s.__)("Page %1$s of %2$s","generateblocks-pro"),o,m)),(0,e.createElement)(i.Button,{disabled:o===m,onClick:()=>w(o+1),variant:"secondary"},(0,s.__)("Next","generateblocks-pro"))))),edit:(0,e.createElement)("div",{className:"gb-dashboard-admin"},(0,e.createElement)(Qt,{onNavigateBack:E,onSave:async()=>{y.invalidateQueries({queryKey:["conditions"]}),E()},conditionId:u.conditionId,initialConditions:u.initialConditions,initialTitle:u.initialTitle,isNew:u.isNew})),categories:(0,e.createElement)("div",{className:"gb-dashboard-admin"},(0,e.createElement)(nn,{onNavigateBack:()=>{c("list"),_("list")},onCategoriesChange:()=>{b((e=>e+1))}}))},C=t?{list:k.list,categories:k.categories}:k,S=t?["list","categories"]:["list","edit","categories"];return(0,e.createElement)(Oe,{currentView:l,views:C,viewOrder:S,className:"gb-conditions-dashboard",minHeight:400})}function on(t){return(0,e.createElement)(d,{client:re()},(0,e.createElement)(rn,{...t}))}function an({trigger:t,conditionId:n=null,modalProps:r={}}){var o;const[a,i]=(0,ae.useState)(n),l=re(),{data:c,isLoading:u}=function(e){return ye({queryKey:["condition",e],queryFn:async()=>{const t=await Ee()({path:`/generateblocks-pro/advanced-conditions/v1/conditions/${e}`});if(t?.success)return t.response;throw new Error("Failed to fetch condition")},enabled:!!e&&"new"!==e,staleTime:12e4,cacheTime:3e5})}(a),d={backButton:(0,s.__)("Back to Conditions","generateblocks-pro"),createNew:(0,s.__)("Create New Condition","generateblocks-pro"),edit:(0,s.__)("Edit Condition","generateblocks-pro"),dashboard:(0,s.__)("Conditions","generateblocks-pro")},p=(0,e.createElement)(on,null),h=a&&("new"===a?(0,e.createElement)(Qt,{conditionId:null,initialConditions:{logic:"OR",groups:[]},initialTitle:""}):!u&&c&&(0,e.createElement)(Qt,{conditionId:c.id,initialConditions:c?.gbConditions||{logic:"OR",groups:[]},initialTitle:c?.title?.rendered?.replace(` (${(0,s.__)("inactive","generateblocks-pro")})`,"")||""}));return(0,ae.useEffect)((()=>{i(n)}),[n]),null!==(o=window.gbConditionsPermissions?.canManageConditions)&&void 0!==o&&o?(0,e.createElement)(Ne,{trigger:t,itemId:a,itemType:"condition",dashboardView:p,editorView:h,modalProps:r,labels:d,className:"gb-conditions-dashboard-fullscreen",getNewTabUrl:e=>"new"===e?`${window.location.origin}/wp-admin/admin.php?page=generateblocks-conditions&edit=new`:`${window.location.origin}/wp-admin/admin.php?page=generateblocks-conditions&edit=${e}`,onItemSelect:e=>{i(e),e&&"new"!==e&&l.invalidateQueries({queryKey:["condition",e]})}}):null}function sn({label:t,help:n,value:r="",onChange:o,options:a=[],emptyLabel:l=(0,s.__)("None","generateblocks-pro"),className:c="",disabled:u=!1,editButton:d=null,emptyMessage:p="",uncategorizedLabel:h=(0,s.__)("Uncategorized","generateblocks-pro")}){const[g]=(0,ae.useState)((()=>`gb-select-control-${Math.random().toString(36).substr(2,9)}`)),m=a&&"object"==typeof a&&!Array.isArray(a),f=m?Object.keys(a).length>0:a.length>0;return(0,e.createElement)(i.BaseControl,{id:g,label:t,help:n,htmlFor:g,className:`gb-select-group-control ${c}`,__nextHasNoMarginBottom:!0},(0,e.createElement)("div",{className:"gb-select-group-control__container"},(0,e.createElement)(i.SelectControl,{id:g,className:"gb-select-group-control__select",value:r,onChange:e=>o(e),disabled:u,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0},(0,e.createElement)("option",{value:""},l),m?Object.entries(a).map((([t,n])=>{const r="uncategorized"===t?n:n.items||[],o="uncategorized"===t?h:n.label;return"uncategorized"===t&&1===Object.keys(a).length?r.map((t=>(0,e.createElement)("option",{key:t.value,value:t.value},t.label))):(0,e.createElement)("optgroup",{key:t,label:o},r.map((t=>(0,e.createElement)("option",{key:t.value,value:t.value},t.label))))})):a.map((t=>(0,e.createElement)("option",{key:t.value,value:t.value},t.label)))),d&&("object"==typeof d&&d.show?(0,e.createElement)(i.Button,{variant:"tertiary",icon:d.icon,onClick:d.onClick,label:d.label||(0,s.__)("Edit","generateblocks-pro"),__next40pxDefaultSize:!0}):d)),!f&&p&&(0,e.createElement)("p",{className:"gb-select-group-control__empty"},p))}function ln({value:t="",onChange:n,label:r=(0,s.__)("Display Conditions","generateblocks-pro"),help:o=""}){const{data:a,isLoading:l}=Ce(100,1),{data:c=[],isLoading:u}=ye({queryKey:["condition-categories"],queryFn:ke}),d=l||u,[p,h]=(0,ae.useState)({});(0,ae.useEffect)((()=>{!d&&a?.conditions&&t&&(a.conditions.some((e=>e.id.toString()===t.toString()))||setTimeout((()=>{n("")}),0))}),[t,a?.conditions,d,n]),(0,ae.useEffect)((()=>{if(!d&&a?.conditions&&c){const e=a.conditions,t={},n=e.filter((e=>!e.gblocks_condition_cat||0===e.gblocks_condition_cat.length));n.length>0&&(t.uncategorized=n.map((e=>{let t=(0,s.__)("Untitled","generateblocks-pro");return"string"==typeof e.title?t=e.title:e.title?.rendered&&(t=e.title.rendered),"draft"===e.status&&(t=(0,s.__)("[Draft]","generateblocks-pro")+" "+t),{value:e.id.toString(),label:(0,ce.decodeEntities)(t)}}))),c.forEach((n=>{const r=e.filter((e=>e.gblocks_condition_cat?.includes(n.id)));r.length>0&&(t[n.slug]={label:(0,ce.decodeEntities)(n.name),items:r.map((e=>{let t=(0,s.__)("Untitled","generateblocks-pro");return"string"==typeof e.title?t=e.title:e.title?.rendered&&(t=e.title.rendered),"draft"===e.status&&(t=(0,s.__)("[Draft]","generateblocks-pro")+" "+t),{value:e.id.toString(),label:(0,ce.decodeEntities)(t)}}))})})),h(t)}}),[a?.conditions,c,d]);const g=t?parseInt(t,10):null,m=g&&g>0,f=!m;let b=null;m?b=(0,e.createElement)(an,{trigger:(0,e.createElement)(i.Button,{variant:"tertiary",icon:ie}),conditionId:g}):f&&(b=(0,e.createElement)(an,{trigger:(0,e.createElement)(i.Button,{variant:"tertiary",icon:le}),conditionId:"new"}));const y=d?[]:p;return(0,e.createElement)(sn,{label:r,help:o,value:t,onChange:n,options:y,emptyLabel:d?(0,s.__)("Loading conditions…","generateblocks-pro"):(0,s.__)("No condition","generateblocks-pro"),editButton:b,emptyMessage:"",disabled:d})}function cn({value:t="",onChange:n,label:r=(0,s.__)("Display Conditions","generateblocks-pro"),help:o=""}){return(0,e.createElement)(d,{client:re()},(0,e.createElement)(ln,{value:t,onChange:n,label:r,help:o}))}const un=(0,o.createHigherOrderComponent)((t=>n=>{const{isSelected:r,attributes:o,setAttributes:l}=n,{gbBlockCondition:c,gbBlockConditionInvert:u}=o;return r?(0,e.createElement)(e.Fragment,null,(0,e.createElement)(t,{...n}),(0,e.createElement)(a.InspectorAdvancedControls,null,(0,e.createElement)(cn,{value:c||"",onChange:e=>l({gbBlockCondition:e}),label:(0,s.__)("Display Condition","generateblocks-pro"),help:(0,s.__)('Choose a condition to control when this block appears. Leave as "no condition" to display everywhere.',"generateblocks-pro")}),c&&(0,e.createElement)(i.CheckboxControl,{label:(0,s.__)("Invert condition","generateblocks-pro"),help:(0,s.__)("Hide the block when the condition is true instead of false.","generateblocks-pro"),checked:null!=u&&u,onChange:e=>l({gbBlockConditionInvert:e}),__nextHasNoMarginBottom:!0}))):(0,e.createElement)(t,{...n})}),"withConditionsControl");(0,r.addFilter)("blocks.registerBlockType","generateblocks-pro/block-conditions/add-attributes",(function(e){return void 0!==e.attributes&&(e.attributes=Object.assign(e.attributes,{gbBlockCondition:{type:"string",default:""},gbBlockConditionInvert:{type:"boolean",default:!1}})),e})),(0,r.addFilter)("editor.BlockEdit","generateblocks-pro/block-conditions/add-control",un,20)})()})();

Youez - 2016 - github.com/yon3zu
LinuXploit