diff --git a/CHANGELOG.md b/CHANGELOG.md index 242183b..9e0aaae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ All notable changes to this module are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the module adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.2.1] 2026-11-06 + +### Changed +- `in` and `notIn` on a field with a `values_query` pick the values in a multiselect instead of typing ids in a textarea (`openstudio/query-builder-bundle` 1.2, now required as `^1.2`, built into the editor script). The picked values are stored as an array, which `SqlBuilder` already reads; a list saved before as a comma-separated string reopens in the multiselect. +- A `values_query` falls back to the free input beyond 1000 rows instead of 300: a category tree of a few hundred entries kept every category field (`product_default_category`, `cart_has_category`, `context_category_id`, `context_category_parent_id`, `product_category_title`) on the free input, without any list. + +### Added +- `product_category_id` ("Category (ID)") lists the categories, like the other category fields. + ## [2.2.0] 2026-11-06 Fixes of the 1.x line (1.4.0 to 1.6.1) carried over to 2.x. @@ -90,6 +99,9 @@ Port of the module to Thelia 3. The Thelia 2 line (1.x) is maintained on the `th - The `/query_builder/products/{hookCode}` Symfony route, replaced by the API Platform resource. - The `product.top` and `product.bottom` `BaseHook` front hooks, replaced by the theme hook implementation. +[2.2.1]: https://github.com/thelia-modules/QueryBuilder/releases/tag/2.2.1 +[2.2.0]: https://github.com/thelia-modules/QueryBuilder/releases/tag/2.2.0 +[2.1.1]: https://github.com/thelia-modules/QueryBuilder/releases/tag/2.1.1 [2.1.0]: https://github.com/thelia-modules/QueryBuilder/releases/tag/2.1.0 [2.0.1]: https://github.com/thelia-modules/QueryBuilder/releases/tag/2.0.1 [2.0.0]: https://github.com/thelia-modules/QueryBuilder/releases/tag/2.0.0 diff --git a/Config/module.xml b/Config/module.xml index 548dfa4..b487317 100644 --- a/Config/module.xml +++ b/Config/module.xml @@ -15,7 +15,7 @@ en_US fr_FR - 2.2.0 + 2.2.1 Samuel Diakité diff --git a/Config/query_builder.yml b/Config/query_builder.yml index b1a6618..e550c70 100644 --- a/Config/query_builder.yml +++ b/Config/query_builder.yml @@ -57,8 +57,9 @@ # fields..operators : restrict allowed operators (react-querybuilder names) # fields..values_query : SQL listing the possible values — "value" column required, "label" # optional, :locale allowed. The BO editor then offers a select ("list of -# values" operator) next to the free operators. Executed on the editor -# screens only; falls back to the free input beyond 300 rows or on SQL +# values" operator, and a multiselect for in/notIn) next to the free +# operators. Executed on the editor screens only; falls back to the free +# input beyond 1000 rows or on SQL # error. Not allowed on boolean fields. # # contexts.: hooks usable by rules of this context. Each entry is either a plain @@ -149,6 +150,7 @@ fields: label: "Category (ID)" field: product_category.category_id type: number + values_query: "SELECT c.id AS value, ci.title AS label FROM category c JOIN category_i18n ci ON ci.id = c.id AND ci.locale = :locale ORDER BY ci.title" product_category_title: label: "Product category title" field: category_i18n.title diff --git a/README.md b/README.md index 2c1eea1..75c300e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Only the fields of a data dictionary and a closed list of operators are accepted - Thelia 3.2 or later (`thelia/core` ^3.2: the catalog price contract the product discounts plug into), Flexy front theme, default-twig back-office - PHP 8.3+ -- `openstudio/query-builder-bundle` ^1.1 (the back-office editor) +- `openstudio/query-builder-bundle` ^1.2 (the back-office editor) Thelia 2 shops use the 1.x line, maintained on the [`thelia2`](https://github.com/thelia-modules/QueryBuilder/tree/thelia2) branch. @@ -75,7 +75,7 @@ Runtime placeholders: `:customer_id`, `:cart_id`, `:cart_product_ids`, `:product An expression may contain the `:value` token: the value entered in the editor is then expanded inside the expression, one placeholder per item, and the field must restrict its `operators` to `in` and `notIn`, which only set the polarity, or to `=` and `!=`, compiled as a one-item `in` and `notIn`. The "list of values" pick of a field with a `values_query` is stored as `=`, so such a field needs no more than `[in, notIn]` for the pick to compile. -Field types: `text`, `number`, `date`, `datetime` (entered as a date, compared on `DATE()`), `boolean`. A field may declare `values_query` (a `value` column, an optional `label` column, `:locale` allowed): the editor then offers a "list of values" select next to the free operators. Beyond 300 rows or on SQL error the field falls back to the free input. Labels of fields and hooks are translation keys of the `querybuilder` domain. +Field types: `text`, `number`, `date`, `datetime` (entered as a date, compared on `DATE()`), `boolean`. A field may declare `values_query` (a `value` column, an optional `label` column, `:locale` allowed): the editor then offers a "list of values" select next to the free operators, and a multiselect for `in` and `notIn`, stored as an array. Beyond 1000 rows or on SQL error the field falls back to the free input. Labels of fields and hooks are translation keys of the `querybuilder` domain. A field declares the contexts it is offered in with `contexts`, a list of `QueryBuilder\Enum\Context` values; `GLOBAL`, the default, means every context, and a `GLOBAL` rule itself only sees `GLOBAL` fields. Restrict a field to the contexts where its placeholder is filled: `:product_id` to `PRODUCT`, `:category_id` to `CATEGORY`, `:brand_id` to `BRAND`, `:order_id` to `ORDER`. The cart and the customer come from the session in every context, so their fields stay `GLOBAL` (a `PRODUCT` rule can select the products sharing a brand with the cart). A field also declares the editors it is offered in with `usage`, a list among `rule` (trigger conditions) and `action` (product selection), both by default: a field comparing the selected product to the object of the context is always true in the rule editor and belongs to `[action]`, a field reading the object itself (`:category_id` in a list) selects all or nothing in the action editor and belongs to `[rule]`. diff --git a/Service/FieldsBuilder.php b/Service/FieldsBuilder.php index a1056ad..aff8ef5 100644 --- a/Service/FieldsBuilder.php +++ b/Service/FieldsBuilder.php @@ -18,8 +18,9 @@ */ final readonly class FieldsBuilder { - //Beyond this size a select is unusable: fall back to the free input - private const MAX_VALUES = 300; + //Beyond this size a select is unusable: fall back to the free input. A shop's category tree + //easily passes 300 entries, still usable in a select searched by typing + private const MAX_VALUES = 1000; //The editor stores the values picked in a select as a plain equality private const VALUES_LIST_OPERATOR = 'valuesList'; diff --git a/composer.json b/composer.json index ce05dcb..9b1fb9d 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": ">=8.3", "thelia/installer": "~1.1", - "openstudio/query-builder-bundle": "^1.1" + "openstudio/query-builder-bundle": "^1.2" }, "require-dev": { "thelia/core": "^3.2", diff --git a/templates/backOffice/default-twig/assets/dist/query-builder-admin.js b/templates/backOffice/default-twig/assets/dist/query-builder-admin.js index 2e02d84..a08af67 100644 --- a/templates/backOffice/default-twig/assets/dist/query-builder-admin.js +++ b/templates/backOffice/default-twig/assets/dist/query-builder-admin.js @@ -7,7 +7,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */function i(e){var t="https://react.dev/errors/"+e;if(1z||(e.current=F[z],F[z]=null,z--)}function B(e,t){z++,F[z]=e.current,e.current=t}var V,H,U=j(null),W=j(null),Q=j(null),K=j(null);function X(e,t){switch(B(Q,t),B(W,e),B(U,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?yd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=wd(t=yd(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}q(U),B(U,e)}function Y(){q(U),q(W),q(Q)}function J(e){null!==e.memoizedState&&B(K,e);var t=U.current,n=wd(t,e.type);t!==n&&(B(W,e),B(U,n))}function Z(e){W.current===e&&(q(U),q(W)),K.current===e&&(q(K),pf._currentValue=G)}function ee(e){if(void 0===V)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);V=t&&t[1]||"",H=-1)":-1--o||s[r]!==u[o]){var c="\n"+s[r].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}}while(1<=r&&0<=o);break}}}finally{te=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?ee(n):""}function re(e,t){switch(e.tag){case 26:case 27:case 5:return ee(e.type);case 16:return ee("Lazy");case 13:return e.child!==t&&null!==t?ee("Suspense Fallback"):ee("Suspense");case 19:return ee("SuspenseList");case 0:case 15:return ne(e.type,!1);case 11:return ne(e.type.render,!1);case 1:return ne(e.type,!0);case 31:return ee("Activity");default:return""}}function oe(e){try{var t="",n=null;do{t+=re(e,n),n=e,e=e.return}while(e);return t}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}var ae=Object.prototype.hasOwnProperty,ie=n.unstable_scheduleCallback,le=n.unstable_cancelCallback,se=n.unstable_shouldYield,ue=n.unstable_requestPaint,ce=n.unstable_now,de=n.unstable_getCurrentPriorityLevel,fe=n.unstable_ImmediatePriority,pe=n.unstable_UserBlockingPriority,he=n.unstable_NormalPriority,me=n.unstable_LowPriority,ge=n.unstable_IdlePriority,ve=n.log,be=n.unstable_setDisableYieldValue,ye=null,we=null;function Se(e){if("function"==typeof ve&&be(e),we&&"function"==typeof we.setStrictMode)try{we.setStrictMode(ye,e)}catch(e){}}var ke=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(Ee(e)/Oe|0)|0},Ee=Math.log,Oe=Math.LN2;var Ne=256,Ce=262144,De=4194304;function Ae(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Te(e,t,n){var r=e.pendingLanes;if(0===r)return 0;var o=0,a=e.suspendedLanes,i=e.pingedLanes;e=e.warmLanes;var l=134217727&r;return 0!==l?0!==(r=l&~a)?o=Ae(r):0!==(i&=l)?o=Ae(i):n||0!==(n=l&~e)&&(o=Ae(n)):0!==(l=r&~a)?o=Ae(l):0!==i?o=Ae(i):n||0!==(n=r&~e)&&(o=Ae(n)),0===o?0:0!==t&&t!==o&&0===(t&a)&&((a=o&-o)>=(n=t&-t)||32===a&&4194048&n)?t:o}function $e(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Me(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function Re(){var e=De;return!(62914560&(De<<=1))&&(De=4194304),e}function xe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ie(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Pe(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-ke(t);e.entangledLanes|=t,e.entanglements[r]=1073741824|e.entanglements[r]|261930&n}function _e(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-ke(n),o=1<=An),Mn=String.fromCharCode(32),Rn=!1;function xn(e,t){switch(e){case"keyup":return-1!==Cn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function In(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Pn=!1;var _n={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Ln(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!_n[e.type]:"textarea"===t}function Gn(e,t,n,r){Lt?Gt?Gt.push(r):Gt=[r]:Lt=r,0<(t=ad(t,"onChange")).length&&(n=new on("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Fn=null,zn=null;function jn(e){Yc(e,0)}function qn(e){if(gt(et(e)))return e}function Bn(e,t){if("change"===e)return t}var Vn=!1;if(Bt){var Hn;if(Bt){var Un="oninput"in document;if(!Un){var Wn=document.createElement("div");Wn.setAttribute("oninput","return;"),Un="function"==typeof Wn.oninput}Hn=Un}else Hn=!1;Vn=Hn&&(!document.documentMode||9=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=nr(r)}}function or(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?or(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function ar(e){for(var t=vt((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(e){n=!1}if(!n)break;t=vt((e=t.contentWindow).document)}return t}function ir(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var lr=Bt&&"documentMode"in document&&11>=document.documentMode,sr=null,ur=null,cr=null,dr=!1;function fr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;dr||null==sr||sr!==vt(r)||("selectionStart"in(r=sr)&&ir(r)?r={start:r.selectionStart,end:r.selectionEnd}:r={anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},cr&&tr(cr,r)||(cr=r,0<(r=ad(ur,"onSelect")).length&&(t=new on("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=sr)))}function pr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var hr={animationend:pr("Animation","AnimationEnd"),animationiteration:pr("Animation","AnimationIteration"),animationstart:pr("Animation","AnimationStart"),transitionrun:pr("Transition","TransitionRun"),transitionstart:pr("Transition","TransitionStart"),transitioncancel:pr("Transition","TransitionCancel"),transitionend:pr("Transition","TransitionEnd")},mr={},gr={};function vr(e){if(mr[e])return mr[e];if(!hr[e])return e;var t,n=hr[e];for(t in n)if(n.hasOwnProperty(t)&&t in gr)return mr[e]=n[t];return e}Bt&&(gr=document.createElement("div").style,"AnimationEvent"in window||(delete hr.animationend.animation,delete hr.animationiteration.animation,delete hr.animationstart.animation),"TransitionEvent"in window||delete hr.transitionend.transition);var br=vr("animationend"),yr=vr("animationiteration"),wr=vr("animationstart"),Sr=vr("transitionrun"),kr=vr("transitionstart"),Er=vr("transitioncancel"),Or=vr("transitionend"),Nr=new Map,Cr="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Dr(e,t){Nr.set(e,t),at(t,[e])}Cr.push("scrollEnd");var Ar="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},Tr=[],$r=0,Mr=0;function Rr(){for(var e=$r,t=Mr=$r=0;t>=i,o-=i,oo=1<<32-ke(t)+o|n<m?(g=d,d=null):g=d.sibling;var v=p(o,d,l[m],s);if(null===v){null===d&&(d=g);break}e&&d&&null===v.alternate&&t(o,d),i=a(v,i,m),null===c?u=v:c.sibling=v,c=v,d=g}if(m===l.length)return n(o,d),ho&&io(o,m),u;if(null===d){for(;mg?(v=m,m=null):v=m.sibling;var y=p(o,m,b.value,u);if(null===y){null===m&&(m=v);break}e&&m&&null===y.alternate&&t(o,m),l=a(y,l,g),null===d?c=y:d.sibling=y,d=y,m=v}if(b.done)return n(o,m),ho&&io(o,g),c;if(null===m){for(;!b.done;g++,b=s.next())null!==(b=f(o,b.value,u))&&(l=a(b,l,g),null===d?c=b:d.sibling=b,d=b);return ho&&io(o,g),c}for(m=r(m);!b.done;g++,b=s.next())null!==(b=h(m,o,g,b.value,u))&&(e&&null!==b.alternate&&m.delete(null===b.key?g:b.key),l=a(b,l,g),null===d?c=b:d.sibling=b,d=b);return e&&m.forEach(function(e){return t(o,e)}),ho&&io(o,g),c}(s,u,c=g.call(c),d)}if("function"==typeof c.then)return m(s,u,fa(c),d);if(c.$$typeof===E)return m(s,u,_o(s,c),d);ha(s,c)}return"string"==typeof c&&""!==c||"number"==typeof c||"bigint"==typeof c?(c=""+c,null!==u&&6===u.tag?(n(s,u.sibling),(d=o(u,c)).return=s,s=d):(n(s,u),(d=Ur(c,s.mode,d)).return=s,s=d),l(s)):n(s,u)}return function(e,t,n,r){try{da=0;var o=m(e,t,n,r);return ca=null,o}catch(t){if(t===ea||t===na)throw t;var a=zr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var ga=ma(!0),va=ma(!1),ba=!1;function ya(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Sa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ka(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,2&mu){var o=r.pending;return null===o?t.next=t:(t.next=o.next,o.next=t),r.pending=t,t=Lr(e),_r(e,null,n),t}return xr(e,r,t,n),Lr(e)}function Ea(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,_e(e,n)}}function Oa(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var o=null,a=null;if(null!==(n=n.firstBaseUpdate)){do{var i={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===a?o=a=i:a=a.next=i,n=n.next}while(null!==n);null===a?o=a=t:a=a.next=t}else o=a=t;return n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Na=!1;function Ca(){if(Na){if(null!==Wo)throw Wo}}function Da(e,t,n,r){Na=!1;var o=e.updateQueue;ba=!1;var a=o.firstBaseUpdate,i=o.lastBaseUpdate,l=o.shared.pending;if(null!==l){o.shared.pending=null;var s=l,u=s.next;s.next=null,null===i?a=u:i.next=u,i=s;var c=e.alternate;null!==c&&((l=(c=c.updateQueue).lastBaseUpdate)!==i&&(null===l?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=s))}if(null!==a){var d=o.baseState;for(i=0,c=u=s=null,l=a;;){var f=-536870913&l.lane,p=f!==l.lane;if(p?(bu&f)===f:(r&f)===f){0!==f&&f===Uo&&(Na=!0),null!==c&&(c=c.next={lane:0,tag:l.tag,payload:l.payload,callback:null,next:null});e:{var h=e,g=l;f=t;var v=n;switch(g.tag){case 1:if("function"==typeof(h=g.payload)){d=h.call(v,d,f);break e}d=h;break e;case 3:h.flags=-65537&h.flags|128;case 0:if(null==(f="function"==typeof(h=g.payload)?h.call(v,d,f):h))break e;d=m({},d,f);break e;case 2:ba=!0}}null!==(f=l.callback)&&(e.flags|=64,p&&(e.flags|=8192),null===(p=o.callbacks)?o.callbacks=[f]:p.push(f))}else p={lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},null===c?(u=c=p,s=d):c=c.next=p,i|=f;if(null===(l=l.next)){if(null===(l=o.shared.pending))break;l=(p=l).next,p.next=null,o.lastBaseUpdate=p,o.shared.pending=null}}null===c&&(s=d),o.baseState=s,o.firstBaseUpdate=u,o.lastBaseUpdate=c,null===a&&(o.shared.lanes=0),Cu|=i,e.lanes=i,e.memoizedState=d}}function Aa(e,t){if("function"!=typeof e)throw Error(i(191,e));e.call(t)}function Ta(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;ea?a:8;var i,l,s,u=_.T,c={};_.T=c,pl(e,!1,t,n);try{var d=o(),f=_.S;if(null!==f&&f(c,d),null!==d&&"object"==typeof d&&"function"==typeof d.then)fl(e,t,(i=r,l=[],s={status:"pending",value:null,reason:null,then:function(e){l.push(e)}},d.then(function(){s.status="fulfilled",s.value=i;for(var e=0;e<\/script>",a=a.removeChild(a.firstChild);break;case"select":a="string"==typeof r.is?l.createElement("select",{is:r.is}):l.createElement("select"),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a="string"==typeof r.is?l.createElement(o,{is:r.is}):l.createElement(o)}}a[Be]=t,a[Ve]=r;e:for(l=t.child;null!==l;){if(5===l.tag||6===l.tag)a.appendChild(l.stateNode);else if(4!==l.tag&&27!==l.tag&&null!==l.child){l.child.return=l,l=l.child;continue}if(l===t)break e;for(;null===l.sibling;){if(null===l.return||l.return===t)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}t.stateNode=a;e:switch(hd(a,o,r),o){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&us(t)}}return hs(t),cs(t,t.type,null===e||e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==r&&us(t);else{if("string"!=typeof r&&null===t.stateNode)throw Error(i(166));if(e=Q.current,So(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,null!==(o=fo))switch(o.tag){case 27:case 5:r=o.memoizedProps}e[Be]=t,(e=!!(e.nodeValue===n||null!==r&&!0===r.suppressHydrationWarning||dd(e.nodeValue,n)))||bo(t,!0)}else(e=bd(e).createTextNode(r))[Be]=t,t.stateNode=e}return hs(t),null;case 31:if(n=t.memoizedState,null===e||null!==e.memoizedState){if(r=So(t),null!==n){if(null===e){if(!r)throw Error(i(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(i(557));e[Be]=t}else ko(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;hs(t),e=!1}else n=Eo(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return 256&t.flags?(ja(t),t):(ja(t),null);if(128&t.flags)throw Error(i(558))}return hs(t),null;case 13:if(r=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(o=So(t),null!==r&&null!==r.dehydrated){if(null===e){if(!o)throw Error(i(318));if(!(o=null!==(o=t.memoizedState)?o.dehydrated:null))throw Error(i(317));o[Be]=t}else ko(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;hs(t),o=!1}else o=Eo(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=o),o=!0;if(!o)return 256&t.flags?(ja(t),t):(ja(t),null)}return ja(t),128&t.flags?(t.lanes=n,t):(n=null!==r,e=null!==e&&null!==e.memoizedState,n&&(o=null,null!==(r=t.child).alternate&&null!==r.alternate.memoizedState&&null!==r.alternate.memoizedState.cachePool&&(o=r.alternate.memoizedState.cachePool.pool),a=null,null!==r.memoizedState&&null!==r.memoizedState.cachePool&&(a=r.memoizedState.cachePool.pool),a!==o&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),fs(t,t.updateQueue),hs(t),null);case 4:return Y(),null===e&&td(t.stateNode.containerInfo),hs(t),null;case 10:return To(t.type),hs(t),null;case 19:if(q(qa),null===(r=t.memoizedState))return hs(t),null;if(o=!!(128&t.flags),null===(a=r.rendering))if(o)ps(r,!1);else{if(0!==Nu||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(a=Ba(e))){for(t.flags|=128,ps(r,!1),e=a.updateQueue,t.updateQueue=e,fs(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)Br(n,e),n=n.sibling;return B(qa,1&qa.current|2),ho&&io(t,r.treeForkCount),t.child}e=e.sibling}null!==r.tail&&ce()>_u&&(t.flags|=128,o=!0,ps(r,!1),t.lanes=4194304)}else{if(!o)if(null!==(e=Ba(a))){if(t.flags|=128,o=!0,e=e.updateQueue,t.updateQueue=e,fs(t,e),ps(r,!0),null===r.tail&&"hidden"===r.tailMode&&!a.alternate&&!ho)return hs(t),null}else 2*ce()-r.renderingStartTime>_u&&536870912!==n&&(t.flags|=128,o=!0,ps(r,!1),t.lanes=4194304);r.isBackwards?(a.sibling=t.child,t.child=a):(null!==(e=r.last)?e.sibling=a:t.child=a,r.last=a)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=ce(),e.sibling=null,n=qa.current,B(qa,o?1&n|2:1&n),ho&&io(t,r.treeForkCount),e):(hs(t),null);case 22:case 23:return ja(t),Ia(),r=null!==t.memoizedState,null!==e?null!==e.memoizedState!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?!!(536870912&n)&&!(128&t.flags)&&(hs(t),6&t.subtreeFlags&&(t.flags|=8192)):hs(t),null!==(n=t.updateQueue)&&fs(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),r=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),null!==e&&q(Xo),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),To(jo),hs(t),null;case 25:case 30:return null}throw Error(i(156,t.tag))}function gs(e,t){switch(uo(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return To(jo),Y(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return Z(t),null;case 31:if(null!==t.memoizedState){if(ja(t),null===t.alternate)throw Error(i(340));ko()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(ja(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(i(340));ko()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return q(qa),null;case 4:return Y(),null;case 10:return To(t.type),null;case 22:case 23:return ja(t),Ia(),null!==e&&q(Xo),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return To(jo),null;default:return null}}function vs(e,t){switch(uo(t),t.tag){case 3:To(jo),Y();break;case 26:case 27:case 5:Z(t);break;case 4:Y();break;case 31:null!==t.memoizedState&&ja(t);break;case 13:ja(t);break;case 19:q(qa);break;case 10:To(t.type);break;case 22:case 23:ja(t),Ia(),null!==e&&q(Xo);break;case 24:To(jo)}}function bs(e,t){try{var n=t.updateQueue,r=null!==n?n.lastEffect:null;if(null!==r){var o=r.next;n=o;do{if((n.tag&e)===e){r=void 0;var a=n.create,i=n.inst;r=a(),i.destroy=r}n=n.next}while(n!==o)}}catch(e){Nc(t,t.return,e)}}function ys(e,t,n){try{var r=t.updateQueue,o=null!==r?r.lastEffect:null;if(null!==o){var a=o.next;r=a;do{if((r.tag&e)===e){var i=r.inst,l=i.destroy;if(void 0!==l){i.destroy=void 0,o=t;var s=n,u=l;try{u()}catch(e){Nc(o,s,e)}}}r=r.next}while(r!==a)}}catch(e){Nc(t,t.return,e)}}function ws(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{Ta(t,n)}catch(t){Nc(e,e.return,t)}}}function Ss(e,t,n){n.props=Nl(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Nc(e,t,n)}}function ks(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;default:r=e.stateNode}"function"==typeof n?e.refCleanup=n(r):n.current=r}}catch(n){Nc(e,t,n)}}function Es(e,t){var n=e.ref,r=e.refCleanup;if(null!==n)if("function"==typeof r)try{r()}catch(n){Nc(e,t,n)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(n){Nc(e,t,n)}else n.current=null}function Os(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&r.focus();break e;case"img":n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Nc(e,e.return,t)}}function Ns(e,t,n){try{var r=e.stateNode;!function(e,t,n,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var o=null,a=null,l=null,s=null,u=null,c=null,d=null;for(h in n){var f=n[h];if(n.hasOwnProperty(h)&&null!=f)switch(h){case"checked":case"value":break;case"defaultValue":u=f;default:r.hasOwnProperty(h)||fd(e,t,h,null,r,f)}}for(var p in r){var h=r[p];if(f=n[p],r.hasOwnProperty(p)&&(null!=h||null!=f))switch(p){case"type":a=h;break;case"name":o=h;break;case"checked":c=h;break;case"defaultChecked":d=h;break;case"value":l=h;break;case"defaultValue":s=h;break;case"children":case"dangerouslySetInnerHTML":if(null!=h)throw Error(i(137,t));break;default:h!==f&&fd(e,t,p,h,r,f)}}return void wt(e,l,s,u,c,d,a,o);case"select":for(a in h=l=s=p=null,n)if(u=n[a],n.hasOwnProperty(a)&&null!=u)switch(a){case"value":break;case"multiple":h=u;default:r.hasOwnProperty(a)||fd(e,t,a,null,r,u)}for(o in r)if(a=r[o],u=n[o],r.hasOwnProperty(o)&&(null!=a||null!=u))switch(o){case"value":p=a;break;case"defaultValue":s=a;break;case"multiple":l=a;default:a!==u&&fd(e,t,o,a,r,u)}return t=s,n=l,r=h,void(null!=p?Et(e,!!n,p,!1):!!r!=!!n&&(null!=t?Et(e,!!n,t,!0):Et(e,!!n,n?[]:"",!1)));case"textarea":for(s in h=p=null,n)if(o=n[s],n.hasOwnProperty(s)&&null!=o&&!r.hasOwnProperty(s))switch(s){case"value":case"children":break;default:fd(e,t,s,null,r,o)}for(l in r)if(o=r[l],a=n[l],r.hasOwnProperty(l)&&(null!=o||null!=a))switch(l){case"value":p=o;break;case"defaultValue":h=o;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=o)throw Error(i(91));break;default:o!==a&&fd(e,t,l,o,r,a)}return void Ot(e,p,h);case"option":for(var m in n)if(p=n[m],n.hasOwnProperty(m)&&null!=p&&!r.hasOwnProperty(m))if("selected"===m)e.selected=!1;else fd(e,t,m,null,r,p);for(u in r)if(p=r[u],h=n[u],r.hasOwnProperty(u)&&p!==h&&(null!=p||null!=h))if("selected"===u)e.selected=p&&"function"!=typeof p&&"symbol"!=typeof p;else fd(e,t,u,p,r,h);return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var g in n)p=n[g],n.hasOwnProperty(g)&&null!=p&&!r.hasOwnProperty(g)&&fd(e,t,g,null,r,p);for(c in r)if(p=r[c],h=n[c],r.hasOwnProperty(c)&&p!==h&&(null!=p||null!=h))switch(c){case"children":case"dangerouslySetInnerHTML":if(null!=p)throw Error(i(137,t));break;default:fd(e,t,c,p,r,h)}return;default:if($t(t)){for(var v in n)p=n[v],n.hasOwnProperty(v)&&void 0!==p&&!r.hasOwnProperty(v)&&pd(e,t,v,void 0,r,p);for(d in r)p=r[d],h=n[d],!r.hasOwnProperty(d)||p===h||void 0===p&&void 0===h||pd(e,t,d,p,r,h);return}}for(var b in n)p=n[b],n.hasOwnProperty(b)&&null!=p&&!r.hasOwnProperty(b)&&fd(e,t,b,null,r,p);for(f in r)p=r[f],h=n[f],!r.hasOwnProperty(f)||p===h||null==p&&null==h||fd(e,t,f,p,r,h)}(r,e.type,n,t),r[Ve]=t}catch(t){Nc(e,e.return,t)}}function Cs(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&Ad(e.type)||4===e.tag}function Ds(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||Cs(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&Ad(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function As(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=It));else if(4!==r&&(27===r&&Ad(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(As(e,t,n),e=e.sibling;null!==e;)As(e,t,n),e=e.sibling}function Ts(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&(27===r&&Ad(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(Ts(e,t,n),e=e.sibling;null!==e;)Ts(e,t,n),e=e.sibling}function $s(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,o=t.attributes;o.length;)t.removeAttributeNode(o[0]);hd(t,r,n),t[Be]=e,t[Ve]=n}catch(t){Nc(e,e.return,t)}}var Ms=!1,Rs=!1,xs=!1,Is="function"==typeof WeakSet?WeakSet:Set,Ps=null;function _s(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Xs(e,n),4&r&&bs(5,n);break;case 1:if(Xs(e,n),4&r)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(e){Nc(n,n.return,e)}else{var o=Nl(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(o,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Nc(n,n.return,e)}}64&r&&ws(n),512&r&&ks(n,n.return);break;case 3:if(Xs(e,n),64&r&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{Ta(e,t)}catch(e){Nc(n,n.return,e)}}break;case 27:null===t&&4&r&&$s(n);case 26:case 5:Xs(e,n),null===t&&4&r&&Os(n),512&r&&ks(n,n.return);break;case 12:Xs(e,n);break;case 31:Xs(e,n),4&r&&qs(e,n);break;case 13:Xs(e,n),4&r&&Bs(e,n),64&r&&(null!==(e=n.memoizedState)&&(null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==n.readyState)t();else{var r=function(){t(),n.removeEventListener("DOMContentLoaded",r)};n.addEventListener("DOMContentLoaded",r),e._reactRetry=r}}(e,n=Tc.bind(null,n))));break;case 22:if(!(r=null!==n.memoizedState||Ms)){t=null!==t&&null!==t.memoizedState||Rs,o=Ms;var a=Rs;Ms=r,(Rs=t)&&!a?Js(e,n,!!(8772&n.subtreeFlags)):Xs(e,n),Ms=o,Rs=a}break;case 30:break;default:Xs(e,n)}}function Ls(e){var t=e.alternate;null!==t&&(e.alternate=null,Ls(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&Ye(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Gs=null,Fs=!1;function zs(e,t,n){for(n=n.child;null!==n;)js(e,t,n),n=n.sibling}function js(e,t,n){if(we&&"function"==typeof we.onCommitFiberUnmount)try{we.onCommitFiberUnmount(ye,n)}catch(e){}switch(n.tag){case 26:Rs||Es(n,t),zs(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Rs||Es(n,t);var r=Gs,o=Fs;Ad(n.type)&&(Gs=n.stateNode,Fs=!1),zs(e,t,n),zd(n.stateNode),Gs=r,Fs=o;break;case 5:Rs||Es(n,t);case 6:if(r=Gs,o=Fs,Gs=null,zs(e,t,n),Fs=o,null!==(Gs=r))if(Fs)try{(9===Gs.nodeType?Gs.body:"HTML"===Gs.nodeName?Gs.ownerDocument.body:Gs).removeChild(n.stateNode)}catch(e){Nc(n,t,e)}else try{Gs.removeChild(n.stateNode)}catch(e){Nc(n,t,e)}break;case 18:null!==Gs&&(Fs?(Td(9===(e=Gs).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Wf(e)):Td(Gs,n.stateNode));break;case 4:r=Gs,o=Fs,Gs=n.stateNode.containerInfo,Fs=!0,zs(e,t,n),Gs=r,Fs=o;break;case 0:case 11:case 14:case 15:ys(2,n,t),Rs||ys(4,n,t),zs(e,t,n);break;case 1:Rs||(Es(n,t),"function"==typeof(r=n.stateNode).componentWillUnmount&&Ss(n,t,r)),zs(e,t,n);break;case 21:zs(e,t,n);break;case 22:Rs=(r=Rs)||null!==n.memoizedState,zs(e,t,n),Rs=r;break;default:zs(e,t,n)}}function qs(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&null!==(e=e.memoizedState))){e=e.dehydrated;try{Wf(e)}catch(e){Nc(t,t.return,e)}}}function Bs(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&(null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))))try{Wf(e)}catch(e){Nc(t,t.return,e)}}function Vs(e,t){var n=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Is),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Is),t;default:throw Error(i(435,e.tag))}}(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=$c.bind(null,e,t);t.then(r,r)}})}function Hs(e,t){var n=t.deletions;if(null!==n)for(var r=0;r title"))),hd(a,r,n),a[Be]=e,nt(a),r=a;break e;case"link":var l=of("link","href",o).get(r+(n.href||""));if(l)for(var s=0;sl)break;var c=s.transferSize,d=s.initiatorType;c&&md(d)&&(i+=c*((s=s.responseEnd)sf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(o)}}:null}(d,h)))return qu=a,e.cancelPendingCommit=h(vc.bind(null,e,t,a,n,r,o,i,l,s,c,d,null,f,p)),void ec(e,a,i,!u)}vc(e,t,a,n,r,o,i,l,s)}function Zu(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&(null!==(n=t.updateQueue)&&null!==(n=n.stores)))for(var r=0;rg&&(i=g,g=m,m=i);var v=rr(l,m),b=rr(l,g);if(v&&b&&(1!==p.rangeCount||p.anchorNode!==v.node||p.anchorOffset!==v.offset||p.focusNode!==b.node||p.focusOffset!==b.offset)){var y=d.createRange();y.setStart(v.node,v.offset),p.removeAllRanges(),m>g?(p.addRange(y),p.extend(b.node,b.offset)):(y.setEnd(b.node,b.offset),p.addRange(y))}}}}for(d=[],p=l;p=p.parentNode;)1===p.nodeType&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for("function"==typeof l.focus&&l.focus(),l=0;ln?32:n,_.T=null,n=Vu,Vu=null;var a=zu,l=qu;if(Fu=0,ju=zu=null,qu=0,6&mu)throw Error(i(331));var s=mu;if(mu|=4,cu(a.current),nu(a,a.current,l,n),mu=s,Gc(0,!1),we&&"function"==typeof we.onPostCommitFiberRoot)try{we.onPostCommitFiberRoot(ye,a)}catch(e){}return!0}finally{L.p=o,_.T=r,Sc(e,t)}}function Oc(e,t,n){t=Xr(n,t),null!==(e=ka(e,t=Ml(e.stateNode,t,2),2))&&(Ie(e,2),Lc(e))}function Nc(e,t,n){if(3===e.tag)Oc(e,e,n);else for(;null!==t;){if(3===t.tag){Oc(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===Gu||!Gu.has(r))){e=Xr(n,e),null!==(r=ka(t,n=Rl(2),2))&&(xl(n,r,t,e),Ie(r,2),Lc(r));break}}t=t.return}}function Cc(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new hu;var o=new Set;r.set(t,o)}else void 0===(o=r.get(t))&&(o=new Set,r.set(t,o));o.has(n)||(Eu=!0,o.add(n),e=Dc.bind(null,e,t,n),t.then(e,e))}function Dc(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,gu===e&&(bu&n)===n&&(4===Nu||3===Nu&&(62914560&bu)===bu&&300>ce()-Iu?!(2&mu)&&rc(e,0):Au|=n,$u===bu&&($u=0)),Lc(e)}function Ac(e,t){0===t&&(t=Re()),null!==(e=Pr(e,t))&&(Ie(e,t),Lc(e))}function Tc(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Ac(e,n)}function $c(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,o=e.memoizedState;null!==o&&(n=o.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}null!==r&&r.delete(t),Ac(e,n)}var Mc=null,Rc=null,xc=!1,Ic=!1,Pc=!1,_c=0;function Lc(e){e!==Rc&&null===e.next&&(null===Rc?Mc=Rc=e:Rc=Rc.next=e),Ic=!0,xc||(xc=!0,Cd(function(){6&mu?ie(fe,Fc):zc()}))}function Gc(e,t){if(!Pc&&Ic){Pc=!0;do{for(var n=!1,r=Mc;null!==r;){if(!t)if(0!==e){var o=r.pendingLanes;if(0===o)var a=0;else{var i=r.suspendedLanes,l=r.pingedLanes;a=(1<<31-ke(42|e)+1)-1,a=201326741&(a&=o&~(i&~l))?201326741&a|1:a?2|a:0}0!==a&&(n=!0,Bc(r,a))}else a=bu,!(3&(a=Te(r,r===gu?a:0,null!==r.cancelPendingCommit||-1!==r.timeoutHandle)))||$e(r,a)||(n=!0,Bc(r,a));r=r.next}}while(n);Pc=!1}}function Fc(){zc()}function zc(){Ic=xc=!1;var e=0;0!==_c&&function(){var e=window.event;if(e&&"popstate"===e.type)return e!==kd&&(kd=e,!0);return kd=null,!1}()&&(e=_c);for(var t=ce(),n=null,r=Mc;null!==r;){var o=r.next,a=jc(r,t);0===a?(r.next=null,null===n?Mc=o:n.next=o,null===o&&(Rc=n)):(n=r,(0!==e||3&a)&&(Ic=!0)),r=o}0!==Fu&&5!==Fu||Gc(e,!1),0!==_c&&(_c=0)}function jc(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,o=e.expirationTimes,a=-62914561&e.pendingLanes;0 title"):null)}function lf(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var sf=0;function uf(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)df(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var cf=null;function df(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,cf=new Map,t.forEach(ff,e),cf=null,uf.call(e))}function ff(e,t){if(!(4&t.state.loading)){var n=cf.get(e);if(n)var r=n.get(null);else{n=new Map,cf.set(e,n);for(var o=e.querySelectorAll("link[data-precedence],style[data-precedence]"),a=0;az||(e.current=F[z],F[z]=null,z--)}function q(e,t){z++,F[z]=e.current,e.current=t}var B,H,U=j(null),W=j(null),Q=j(null),K=j(null);function X(e,t){switch(q(Q,t),q(W,e),q(U,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?yd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=wd(t=yd(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}V(U),q(U,e)}function Y(){V(U),V(W),V(Q)}function J(e){null!==e.memoizedState&&q(K,e);var t=U.current,n=wd(t,e.type);t!==n&&(q(W,e),q(U,n))}function Z(e){W.current===e&&(V(U),V(W)),K.current===e&&(V(K),pf._currentValue=G)}function ee(e){if(void 0===B)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);B=t&&t[1]||"",H=-1)":-1--o||s[r]!==u[o]){var c="\n"+s[r].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}}while(1<=r&&0<=o);break}}}finally{te=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?ee(n):""}function re(e,t){switch(e.tag){case 26:case 27:case 5:return ee(e.type);case 16:return ee("Lazy");case 13:return e.child!==t&&null!==t?ee("Suspense Fallback"):ee("Suspense");case 19:return ee("SuspenseList");case 0:case 15:return ne(e.type,!1);case 11:return ne(e.type.render,!1);case 1:return ne(e.type,!0);case 31:return ee("Activity");default:return""}}function oe(e){try{var t="",n=null;do{t+=re(e,n),n=e,e=e.return}while(e);return t}catch(e){return"\nError generating stack: "+e.message+"\n"+e.stack}}var ae=Object.prototype.hasOwnProperty,ie=n.unstable_scheduleCallback,le=n.unstable_cancelCallback,se=n.unstable_shouldYield,ue=n.unstable_requestPaint,ce=n.unstable_now,de=n.unstable_getCurrentPriorityLevel,fe=n.unstable_ImmediatePriority,pe=n.unstable_UserBlockingPriority,he=n.unstable_NormalPriority,me=n.unstable_LowPriority,ge=n.unstable_IdlePriority,ve=n.log,be=n.unstable_setDisableYieldValue,ye=null,we=null;function Se(e){if("function"==typeof ve&&be(e),we&&"function"==typeof we.setStrictMode)try{we.setStrictMode(ye,e)}catch(e){}}var ke=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(Ee(e)/Oe|0)|0},Ee=Math.log,Oe=Math.LN2;var Ne=256,Ce=262144,De=4194304;function Ae(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Te(e,t,n){var r=e.pendingLanes;if(0===r)return 0;var o=0,a=e.suspendedLanes,i=e.pingedLanes;e=e.warmLanes;var l=134217727&r;return 0!==l?0!==(r=l&~a)?o=Ae(r):0!==(i&=l)?o=Ae(i):n||0!==(n=l&~e)&&(o=Ae(n)):0!==(l=r&~a)?o=Ae(l):0!==i?o=Ae(i):n||0!==(n=r&~e)&&(o=Ae(n)),0===o?0:0!==t&&t!==o&&0===(t&a)&&((a=o&-o)>=(n=t&-t)||32===a&&4194048&n)?t:o}function $e(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function Me(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function Re(){var e=De;return!(62914560&(De<<=1))&&(De=4194304),e}function xe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ie(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Pe(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-ke(t);e.entangledLanes|=t,e.entanglements[r]=1073741824|e.entanglements[r]|261930&n}function _e(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-ke(n),o=1<=An),Mn=String.fromCharCode(32),Rn=!1;function xn(e,t){switch(e){case"keyup":return-1!==Cn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function In(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Pn=!1;var _n={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Ln(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!_n[e.type]:"textarea"===t}function Gn(e,t,n,r){Lt?Gt?Gt.push(r):Gt=[r]:Lt=r,0<(t=ad(t,"onChange")).length&&(n=new on("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Fn=null,zn=null;function jn(e){Yc(e,0)}function Vn(e){if(gt(et(e)))return e}function qn(e,t){if("change"===e)return t}var Bn=!1;if(qt){var Hn;if(qt){var Un="oninput"in document;if(!Un){var Wn=document.createElement("div");Wn.setAttribute("oninput","return;"),Un="function"==typeof Wn.oninput}Hn=Un}else Hn=!1;Bn=Hn&&(!document.documentMode||9=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=nr(r)}}function or(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?or(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function ar(e){for(var t=vt((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(e){n=!1}if(!n)break;t=vt((e=t.contentWindow).document)}return t}function ir(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var lr=qt&&"documentMode"in document&&11>=document.documentMode,sr=null,ur=null,cr=null,dr=!1;function fr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;dr||null==sr||sr!==vt(r)||("selectionStart"in(r=sr)&&ir(r)?r={start:r.selectionStart,end:r.selectionEnd}:r={anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},cr&&tr(cr,r)||(cr=r,0<(r=ad(ur,"onSelect")).length&&(t=new on("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=sr)))}function pr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var hr={animationend:pr("Animation","AnimationEnd"),animationiteration:pr("Animation","AnimationIteration"),animationstart:pr("Animation","AnimationStart"),transitionrun:pr("Transition","TransitionRun"),transitionstart:pr("Transition","TransitionStart"),transitioncancel:pr("Transition","TransitionCancel"),transitionend:pr("Transition","TransitionEnd")},mr={},gr={};function vr(e){if(mr[e])return mr[e];if(!hr[e])return e;var t,n=hr[e];for(t in n)if(n.hasOwnProperty(t)&&t in gr)return mr[e]=n[t];return e}qt&&(gr=document.createElement("div").style,"AnimationEvent"in window||(delete hr.animationend.animation,delete hr.animationiteration.animation,delete hr.animationstart.animation),"TransitionEvent"in window||delete hr.transitionend.transition);var br=vr("animationend"),yr=vr("animationiteration"),wr=vr("animationstart"),Sr=vr("transitionrun"),kr=vr("transitionstart"),Er=vr("transitioncancel"),Or=vr("transitionend"),Nr=new Map,Cr="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Dr(e,t){Nr.set(e,t),at(t,[e])}Cr.push("scrollEnd");var Ar="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof process&&"function"==typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)},Tr=[],$r=0,Mr=0;function Rr(){for(var e=$r,t=Mr=$r=0;t>=i,o-=i,oo=1<<32-ke(t)+o|n<m?(g=d,d=null):g=d.sibling;var v=p(o,d,l[m],s);if(null===v){null===d&&(d=g);break}e&&d&&null===v.alternate&&t(o,d),i=a(v,i,m),null===c?u=v:c.sibling=v,c=v,d=g}if(m===l.length)return n(o,d),ho&&io(o,m),u;if(null===d){for(;mg?(v=m,m=null):v=m.sibling;var y=p(o,m,b.value,u);if(null===y){null===m&&(m=v);break}e&&m&&null===y.alternate&&t(o,m),l=a(y,l,g),null===d?c=y:d.sibling=y,d=y,m=v}if(b.done)return n(o,m),ho&&io(o,g),c;if(null===m){for(;!b.done;g++,b=s.next())null!==(b=f(o,b.value,u))&&(l=a(b,l,g),null===d?c=b:d.sibling=b,d=b);return ho&&io(o,g),c}for(m=r(m);!b.done;g++,b=s.next())null!==(b=h(m,o,g,b.value,u))&&(e&&null!==b.alternate&&m.delete(null===b.key?g:b.key),l=a(b,l,g),null===d?c=b:d.sibling=b,d=b);return e&&m.forEach(function(e){return t(o,e)}),ho&&io(o,g),c}(s,u,c=g.call(c),d)}if("function"==typeof c.then)return m(s,u,fa(c),d);if(c.$$typeof===E)return m(s,u,_o(s,c),d);ha(s,c)}return"string"==typeof c&&""!==c||"number"==typeof c||"bigint"==typeof c?(c=""+c,null!==u&&6===u.tag?(n(s,u.sibling),(d=o(u,c)).return=s,s=d):(n(s,u),(d=Ur(c,s.mode,d)).return=s,s=d),l(s)):n(s,u)}return function(e,t,n,r){try{da=0;var o=m(e,t,n,r);return ca=null,o}catch(t){if(t===ea||t===na)throw t;var a=zr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var ga=ma(!0),va=ma(!1),ba=!1;function ya(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Sa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ka(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,2&mu){var o=r.pending;return null===o?t.next=t:(t.next=o.next,o.next=t),r.pending=t,t=Lr(e),_r(e,null,n),t}return xr(e,r,t,n),Lr(e)}function Ea(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194048&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,_e(e,n)}}function Oa(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var o=null,a=null;if(null!==(n=n.firstBaseUpdate)){do{var i={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===a?o=a=i:a=a.next=i,n=n.next}while(null!==n);null===a?o=a=t:a=a.next=t}else o=a=t;return n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Na=!1;function Ca(){if(Na){if(null!==Wo)throw Wo}}function Da(e,t,n,r){Na=!1;var o=e.updateQueue;ba=!1;var a=o.firstBaseUpdate,i=o.lastBaseUpdate,l=o.shared.pending;if(null!==l){o.shared.pending=null;var s=l,u=s.next;s.next=null,null===i?a=u:i.next=u,i=s;var c=e.alternate;null!==c&&((l=(c=c.updateQueue).lastBaseUpdate)!==i&&(null===l?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=s))}if(null!==a){var d=o.baseState;for(i=0,c=u=s=null,l=a;;){var f=-536870913&l.lane,p=f!==l.lane;if(p?(bu&f)===f:(r&f)===f){0!==f&&f===Uo&&(Na=!0),null!==c&&(c=c.next={lane:0,tag:l.tag,payload:l.payload,callback:null,next:null});e:{var h=e,g=l;f=t;var v=n;switch(g.tag){case 1:if("function"==typeof(h=g.payload)){d=h.call(v,d,f);break e}d=h;break e;case 3:h.flags=-65537&h.flags|128;case 0:if(null==(f="function"==typeof(h=g.payload)?h.call(v,d,f):h))break e;d=m({},d,f);break e;case 2:ba=!0}}null!==(f=l.callback)&&(e.flags|=64,p&&(e.flags|=8192),null===(p=o.callbacks)?o.callbacks=[f]:p.push(f))}else p={lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},null===c?(u=c=p,s=d):c=c.next=p,i|=f;if(null===(l=l.next)){if(null===(l=o.shared.pending))break;l=(p=l).next,p.next=null,o.lastBaseUpdate=p,o.shared.pending=null}}null===c&&(s=d),o.baseState=s,o.firstBaseUpdate=u,o.lastBaseUpdate=c,null===a&&(o.shared.lanes=0),Cu|=i,e.lanes=i,e.memoizedState=d}}function Aa(e,t){if("function"!=typeof e)throw Error(i(191,e));e.call(t)}function Ta(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;ea?a:8;var i,l,s,u=_.T,c={};_.T=c,pl(e,!1,t,n);try{var d=o(),f=_.S;if(null!==f&&f(c,d),null!==d&&"object"==typeof d&&"function"==typeof d.then)fl(e,t,(i=r,l=[],s={status:"pending",value:null,reason:null,then:function(e){l.push(e)}},d.then(function(){s.status="fulfilled",s.value=i;for(var e=0;e<\/script>",a=a.removeChild(a.firstChild);break;case"select":a="string"==typeof r.is?l.createElement("select",{is:r.is}):l.createElement("select"),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a="string"==typeof r.is?l.createElement(o,{is:r.is}):l.createElement(o)}}a[qe]=t,a[Be]=r;e:for(l=t.child;null!==l;){if(5===l.tag||6===l.tag)a.appendChild(l.stateNode);else if(4!==l.tag&&27!==l.tag&&null!==l.child){l.child.return=l,l=l.child;continue}if(l===t)break e;for(;null===l.sibling;){if(null===l.return||l.return===t)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}t.stateNode=a;e:switch(hd(a,o,r),o){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&us(t)}}return hs(t),cs(t,t.type,null===e||e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==r&&us(t);else{if("string"!=typeof r&&null===t.stateNode)throw Error(i(166));if(e=Q.current,So(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,null!==(o=fo))switch(o.tag){case 27:case 5:r=o.memoizedProps}e[qe]=t,(e=!!(e.nodeValue===n||null!==r&&!0===r.suppressHydrationWarning||dd(e.nodeValue,n)))||bo(t,!0)}else(e=bd(e).createTextNode(r))[qe]=t,t.stateNode=e}return hs(t),null;case 31:if(n=t.memoizedState,null===e||null!==e.memoizedState){if(r=So(t),null!==n){if(null===e){if(!r)throw Error(i(318));if(!(e=null!==(e=t.memoizedState)?e.dehydrated:null))throw Error(i(557));e[qe]=t}else ko(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;hs(t),e=!1}else n=Eo(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return 256&t.flags?(ja(t),t):(ja(t),null);if(128&t.flags)throw Error(i(558))}return hs(t),null;case 13:if(r=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(o=So(t),null!==r&&null!==r.dehydrated){if(null===e){if(!o)throw Error(i(318));if(!(o=null!==(o=t.memoizedState)?o.dehydrated:null))throw Error(i(317));o[qe]=t}else ko(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;hs(t),o=!1}else o=Eo(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=o),o=!0;if(!o)return 256&t.flags?(ja(t),t):(ja(t),null)}return ja(t),128&t.flags?(t.lanes=n,t):(n=null!==r,e=null!==e&&null!==e.memoizedState,n&&(o=null,null!==(r=t.child).alternate&&null!==r.alternate.memoizedState&&null!==r.alternate.memoizedState.cachePool&&(o=r.alternate.memoizedState.cachePool.pool),a=null,null!==r.memoizedState&&null!==r.memoizedState.cachePool&&(a=r.memoizedState.cachePool.pool),a!==o&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),fs(t,t.updateQueue),hs(t),null);case 4:return Y(),null===e&&td(t.stateNode.containerInfo),hs(t),null;case 10:return To(t.type),hs(t),null;case 19:if(V(Va),null===(r=t.memoizedState))return hs(t),null;if(o=!!(128&t.flags),null===(a=r.rendering))if(o)ps(r,!1);else{if(0!==Nu||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(a=qa(e))){for(t.flags|=128,ps(r,!1),e=a.updateQueue,t.updateQueue=e,fs(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)qr(n,e),n=n.sibling;return q(Va,1&Va.current|2),ho&&io(t,r.treeForkCount),t.child}e=e.sibling}null!==r.tail&&ce()>_u&&(t.flags|=128,o=!0,ps(r,!1),t.lanes=4194304)}else{if(!o)if(null!==(e=qa(a))){if(t.flags|=128,o=!0,e=e.updateQueue,t.updateQueue=e,fs(t,e),ps(r,!0),null===r.tail&&"hidden"===r.tailMode&&!a.alternate&&!ho)return hs(t),null}else 2*ce()-r.renderingStartTime>_u&&536870912!==n&&(t.flags|=128,o=!0,ps(r,!1),t.lanes=4194304);r.isBackwards?(a.sibling=t.child,t.child=a):(null!==(e=r.last)?e.sibling=a:t.child=a,r.last=a)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=ce(),e.sibling=null,n=Va.current,q(Va,o?1&n|2:1&n),ho&&io(t,r.treeForkCount),e):(hs(t),null);case 22:case 23:return ja(t),Ia(),r=null!==t.memoizedState,null!==e?null!==e.memoizedState!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?!!(536870912&n)&&!(128&t.flags)&&(hs(t),6&t.subtreeFlags&&(t.flags|=8192)):hs(t),null!==(n=t.updateQueue)&&fs(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),r=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),null!==e&&V(Xo),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),To(jo),hs(t),null;case 25:case 30:return null}throw Error(i(156,t.tag))}function gs(e,t){switch(uo(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return To(jo),Y(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return Z(t),null;case 31:if(null!==t.memoizedState){if(ja(t),null===t.alternate)throw Error(i(340));ko()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(ja(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(i(340));ko()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return V(Va),null;case 4:return Y(),null;case 10:return To(t.type),null;case 22:case 23:return ja(t),Ia(),null!==e&&V(Xo),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return To(jo),null;default:return null}}function vs(e,t){switch(uo(t),t.tag){case 3:To(jo),Y();break;case 26:case 27:case 5:Z(t);break;case 4:Y();break;case 31:null!==t.memoizedState&&ja(t);break;case 13:ja(t);break;case 19:V(Va);break;case 10:To(t.type);break;case 22:case 23:ja(t),Ia(),null!==e&&V(Xo);break;case 24:To(jo)}}function bs(e,t){try{var n=t.updateQueue,r=null!==n?n.lastEffect:null;if(null!==r){var o=r.next;n=o;do{if((n.tag&e)===e){r=void 0;var a=n.create,i=n.inst;r=a(),i.destroy=r}n=n.next}while(n!==o)}}catch(e){Nc(t,t.return,e)}}function ys(e,t,n){try{var r=t.updateQueue,o=null!==r?r.lastEffect:null;if(null!==o){var a=o.next;r=a;do{if((r.tag&e)===e){var i=r.inst,l=i.destroy;if(void 0!==l){i.destroy=void 0,o=t;var s=n,u=l;try{u()}catch(e){Nc(o,s,e)}}}r=r.next}while(r!==a)}}catch(e){Nc(t,t.return,e)}}function ws(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{Ta(t,n)}catch(t){Nc(e,e.return,t)}}}function Ss(e,t,n){n.props=Nl(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Nc(e,t,n)}}function ks(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;default:r=e.stateNode}"function"==typeof n?e.refCleanup=n(r):n.current=r}}catch(n){Nc(e,t,n)}}function Es(e,t){var n=e.ref,r=e.refCleanup;if(null!==n)if("function"==typeof r)try{r()}catch(n){Nc(e,t,n)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"==typeof n)try{n(null)}catch(n){Nc(e,t,n)}else n.current=null}function Os(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&r.focus();break e;case"img":n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Nc(e,e.return,t)}}function Ns(e,t,n){try{var r=e.stateNode;!function(e,t,n,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var o=null,a=null,l=null,s=null,u=null,c=null,d=null;for(h in n){var f=n[h];if(n.hasOwnProperty(h)&&null!=f)switch(h){case"checked":case"value":break;case"defaultValue":u=f;default:r.hasOwnProperty(h)||fd(e,t,h,null,r,f)}}for(var p in r){var h=r[p];if(f=n[p],r.hasOwnProperty(p)&&(null!=h||null!=f))switch(p){case"type":a=h;break;case"name":o=h;break;case"checked":c=h;break;case"defaultChecked":d=h;break;case"value":l=h;break;case"defaultValue":s=h;break;case"children":case"dangerouslySetInnerHTML":if(null!=h)throw Error(i(137,t));break;default:h!==f&&fd(e,t,p,h,r,f)}}return void wt(e,l,s,u,c,d,a,o);case"select":for(a in h=l=s=p=null,n)if(u=n[a],n.hasOwnProperty(a)&&null!=u)switch(a){case"value":break;case"multiple":h=u;default:r.hasOwnProperty(a)||fd(e,t,a,null,r,u)}for(o in r)if(a=r[o],u=n[o],r.hasOwnProperty(o)&&(null!=a||null!=u))switch(o){case"value":p=a;break;case"defaultValue":s=a;break;case"multiple":l=a;default:a!==u&&fd(e,t,o,a,r,u)}return t=s,n=l,r=h,void(null!=p?Et(e,!!n,p,!1):!!r!=!!n&&(null!=t?Et(e,!!n,t,!0):Et(e,!!n,n?[]:"",!1)));case"textarea":for(s in h=p=null,n)if(o=n[s],n.hasOwnProperty(s)&&null!=o&&!r.hasOwnProperty(s))switch(s){case"value":case"children":break;default:fd(e,t,s,null,r,o)}for(l in r)if(o=r[l],a=n[l],r.hasOwnProperty(l)&&(null!=o||null!=a))switch(l){case"value":p=o;break;case"defaultValue":h=o;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=o)throw Error(i(91));break;default:o!==a&&fd(e,t,l,o,r,a)}return void Ot(e,p,h);case"option":for(var m in n)if(p=n[m],n.hasOwnProperty(m)&&null!=p&&!r.hasOwnProperty(m))if("selected"===m)e.selected=!1;else fd(e,t,m,null,r,p);for(u in r)if(p=r[u],h=n[u],r.hasOwnProperty(u)&&p!==h&&(null!=p||null!=h))if("selected"===u)e.selected=p&&"function"!=typeof p&&"symbol"!=typeof p;else fd(e,t,u,p,r,h);return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var g in n)p=n[g],n.hasOwnProperty(g)&&null!=p&&!r.hasOwnProperty(g)&&fd(e,t,g,null,r,p);for(c in r)if(p=r[c],h=n[c],r.hasOwnProperty(c)&&p!==h&&(null!=p||null!=h))switch(c){case"children":case"dangerouslySetInnerHTML":if(null!=p)throw Error(i(137,t));break;default:fd(e,t,c,p,r,h)}return;default:if($t(t)){for(var v in n)p=n[v],n.hasOwnProperty(v)&&void 0!==p&&!r.hasOwnProperty(v)&&pd(e,t,v,void 0,r,p);for(d in r)p=r[d],h=n[d],!r.hasOwnProperty(d)||p===h||void 0===p&&void 0===h||pd(e,t,d,p,r,h);return}}for(var b in n)p=n[b],n.hasOwnProperty(b)&&null!=p&&!r.hasOwnProperty(b)&&fd(e,t,b,null,r,p);for(f in r)p=r[f],h=n[f],!r.hasOwnProperty(f)||p===h||null==p&&null==h||fd(e,t,f,p,r,h)}(r,e.type,n,t),r[Be]=t}catch(t){Nc(e,e.return,t)}}function Cs(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&Ad(e.type)||4===e.tag}function Ds(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||Cs(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&Ad(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function As(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=It));else if(4!==r&&(27===r&&Ad(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(As(e,t,n),e=e.sibling;null!==e;)As(e,t,n),e=e.sibling}function Ts(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&(27===r&&Ad(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(Ts(e,t,n),e=e.sibling;null!==e;)Ts(e,t,n),e=e.sibling}function $s(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,o=t.attributes;o.length;)t.removeAttributeNode(o[0]);hd(t,r,n),t[qe]=e,t[Be]=n}catch(t){Nc(e,e.return,t)}}var Ms=!1,Rs=!1,xs=!1,Is="function"==typeof WeakSet?WeakSet:Set,Ps=null;function _s(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Xs(e,n),4&r&&bs(5,n);break;case 1:if(Xs(e,n),4&r)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(e){Nc(n,n.return,e)}else{var o=Nl(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(o,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Nc(n,n.return,e)}}64&r&&ws(n),512&r&&ks(n,n.return);break;case 3:if(Xs(e,n),64&r&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{Ta(e,t)}catch(e){Nc(n,n.return,e)}}break;case 27:null===t&&4&r&&$s(n);case 26:case 5:Xs(e,n),null===t&&4&r&&Os(n),512&r&&ks(n,n.return);break;case 12:Xs(e,n);break;case 31:Xs(e,n),4&r&&Vs(e,n);break;case 13:Xs(e,n),4&r&&qs(e,n),64&r&&(null!==(e=n.memoizedState)&&(null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$~"===e.data)e._reactRetry=t;else if("$?"!==e.data||"loading"!==n.readyState)t();else{var r=function(){t(),n.removeEventListener("DOMContentLoaded",r)};n.addEventListener("DOMContentLoaded",r),e._reactRetry=r}}(e,n=Tc.bind(null,n))));break;case 22:if(!(r=null!==n.memoizedState||Ms)){t=null!==t&&null!==t.memoizedState||Rs,o=Ms;var a=Rs;Ms=r,(Rs=t)&&!a?Js(e,n,!!(8772&n.subtreeFlags)):Xs(e,n),Ms=o,Rs=a}break;case 30:break;default:Xs(e,n)}}function Ls(e){var t=e.alternate;null!==t&&(e.alternate=null,Ls(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&Ye(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Gs=null,Fs=!1;function zs(e,t,n){for(n=n.child;null!==n;)js(e,t,n),n=n.sibling}function js(e,t,n){if(we&&"function"==typeof we.onCommitFiberUnmount)try{we.onCommitFiberUnmount(ye,n)}catch(e){}switch(n.tag){case 26:Rs||Es(n,t),zs(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:Rs||Es(n,t);var r=Gs,o=Fs;Ad(n.type)&&(Gs=n.stateNode,Fs=!1),zs(e,t,n),zd(n.stateNode),Gs=r,Fs=o;break;case 5:Rs||Es(n,t);case 6:if(r=Gs,o=Fs,Gs=null,zs(e,t,n),Fs=o,null!==(Gs=r))if(Fs)try{(9===Gs.nodeType?Gs.body:"HTML"===Gs.nodeName?Gs.ownerDocument.body:Gs).removeChild(n.stateNode)}catch(e){Nc(n,t,e)}else try{Gs.removeChild(n.stateNode)}catch(e){Nc(n,t,e)}break;case 18:null!==Gs&&(Fs?(Td(9===(e=Gs).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Wf(e)):Td(Gs,n.stateNode));break;case 4:r=Gs,o=Fs,Gs=n.stateNode.containerInfo,Fs=!0,zs(e,t,n),Gs=r,Fs=o;break;case 0:case 11:case 14:case 15:ys(2,n,t),Rs||ys(4,n,t),zs(e,t,n);break;case 1:Rs||(Es(n,t),"function"==typeof(r=n.stateNode).componentWillUnmount&&Ss(n,t,r)),zs(e,t,n);break;case 21:zs(e,t,n);break;case 22:Rs=(r=Rs)||null!==n.memoizedState,zs(e,t,n),Rs=r;break;default:zs(e,t,n)}}function Vs(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&null!==(e=e.memoizedState))){e=e.dehydrated;try{Wf(e)}catch(e){Nc(t,t.return,e)}}}function qs(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&(null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))))try{Wf(e)}catch(e){Nc(t,t.return,e)}}function Bs(e,t){var n=function(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new Is),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new Is),t;default:throw Error(i(435,e.tag))}}(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=$c.bind(null,e,t);t.then(r,r)}})}function Hs(e,t){var n=t.deletions;if(null!==n)for(var r=0;r title"))),hd(a,r,n),a[qe]=e,nt(a),r=a;break e;case"link":var l=of("link","href",o).get(r+(n.href||""));if(l)for(var s=0;sl)break;var c=s.transferSize,d=s.initiatorType;c&&md(d)&&(i+=c*((s=s.responseEnd)sf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(o)}}:null}(d,h)))return Vu=a,e.cancelPendingCommit=h(vc.bind(null,e,t,a,n,r,o,i,l,s,c,d,null,f,p)),void ec(e,a,i,!u)}vc(e,t,a,n,r,o,i,l,s)}function Zu(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&(null!==(n=t.updateQueue)&&null!==(n=n.stores)))for(var r=0;rg&&(i=g,g=m,m=i);var v=rr(l,m),b=rr(l,g);if(v&&b&&(1!==p.rangeCount||p.anchorNode!==v.node||p.anchorOffset!==v.offset||p.focusNode!==b.node||p.focusOffset!==b.offset)){var y=d.createRange();y.setStart(v.node,v.offset),p.removeAllRanges(),m>g?(p.addRange(y),p.extend(b.node,b.offset)):(y.setEnd(b.node,b.offset),p.addRange(y))}}}}for(d=[],p=l;p=p.parentNode;)1===p.nodeType&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for("function"==typeof l.focus&&l.focus(),l=0;ln?32:n,_.T=null,n=Bu,Bu=null;var a=zu,l=Vu;if(Fu=0,ju=zu=null,Vu=0,6&mu)throw Error(i(331));var s=mu;if(mu|=4,cu(a.current),nu(a,a.current,l,n),mu=s,Gc(0,!1),we&&"function"==typeof we.onPostCommitFiberRoot)try{we.onPostCommitFiberRoot(ye,a)}catch(e){}return!0}finally{L.p=o,_.T=r,Sc(e,t)}}function Oc(e,t,n){t=Xr(n,t),null!==(e=ka(e,t=Ml(e.stateNode,t,2),2))&&(Ie(e,2),Lc(e))}function Nc(e,t,n){if(3===e.tag)Oc(e,e,n);else for(;null!==t;){if(3===t.tag){Oc(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===Gu||!Gu.has(r))){e=Xr(n,e),null!==(r=ka(t,n=Rl(2),2))&&(xl(n,r,t,e),Ie(r,2),Lc(r));break}}t=t.return}}function Cc(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new hu;var o=new Set;r.set(t,o)}else void 0===(o=r.get(t))&&(o=new Set,r.set(t,o));o.has(n)||(Eu=!0,o.add(n),e=Dc.bind(null,e,t,n),t.then(e,e))}function Dc(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,gu===e&&(bu&n)===n&&(4===Nu||3===Nu&&(62914560&bu)===bu&&300>ce()-Iu?!(2&mu)&&rc(e,0):Au|=n,$u===bu&&($u=0)),Lc(e)}function Ac(e,t){0===t&&(t=Re()),null!==(e=Pr(e,t))&&(Ie(e,t),Lc(e))}function Tc(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Ac(e,n)}function $c(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,o=e.memoizedState;null!==o&&(n=o.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}null!==r&&r.delete(t),Ac(e,n)}var Mc=null,Rc=null,xc=!1,Ic=!1,Pc=!1,_c=0;function Lc(e){e!==Rc&&null===e.next&&(null===Rc?Mc=Rc=e:Rc=Rc.next=e),Ic=!0,xc||(xc=!0,Cd(function(){6&mu?ie(fe,Fc):zc()}))}function Gc(e,t){if(!Pc&&Ic){Pc=!0;do{for(var n=!1,r=Mc;null!==r;){if(!t)if(0!==e){var o=r.pendingLanes;if(0===o)var a=0;else{var i=r.suspendedLanes,l=r.pingedLanes;a=(1<<31-ke(42|e)+1)-1,a=201326741&(a&=o&~(i&~l))?201326741&a|1:a?2|a:0}0!==a&&(n=!0,qc(r,a))}else a=bu,!(3&(a=Te(r,r===gu?a:0,null!==r.cancelPendingCommit||-1!==r.timeoutHandle)))||$e(r,a)||(n=!0,qc(r,a));r=r.next}}while(n);Pc=!1}}function Fc(){zc()}function zc(){Ic=xc=!1;var e=0;0!==_c&&function(){var e=window.event;if(e&&"popstate"===e.type)return e!==kd&&(kd=e,!0);return kd=null,!1}()&&(e=_c);for(var t=ce(),n=null,r=Mc;null!==r;){var o=r.next,a=jc(r,t);0===a?(r.next=null,null===n?Mc=o:n.next=o,null===o&&(Rc=n)):(n=r,(0!==e||3&a)&&(Ic=!0)),r=o}0!==Fu&&5!==Fu||Gc(e,!1),0!==_c&&(_c=0)}function jc(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,o=e.expirationTimes,a=-62914561&e.pendingLanes;0 title"):null)}function lf(e){return!!("stylesheet"!==e.type||3&e.state.loading)}var sf=0;function uf(){if(this.count--,0===this.count&&(0===this.imgCount||!this.waitingForImages))if(this.stylesheets)df(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var cf=null;function df(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,cf=new Map,t.forEach(ff,e),cf=null,uf.call(e))}function ff(e,t){if(!(4&t.state.loading)){var n=cf.get(e);if(n)var r=n.get(null);else{n=new Map,cf.set(e,n);for(var o=e.querySelectorAll("link[data-precedence],style[data-precedence]"),a=0;a>>1,o=e[r];if(!( * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -var n=s();var r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=n.useSyncExternalStore,a=n.useRef,i=n.useEffect,l=n.useMemo,u=n.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,n,s,c){var d=a(null);if(null===d.current){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!i){if(i=!0,o=e,e=s(e),void 0!==c&&f.hasValue){var t=f.value;if(c(t,e))return a=t}return a=e}if(t=a,r(o,e))return t;var n=s(e);return void 0!==c&&c(t,n)?(o=e,t):(o=e,a=n)}var o,a,i=!1,l=void 0===n?null:n;return[function(){return e(t())},null===l?void 0:function(){return e(l())}]},[t,n,s,c]);var p=o(e,d[0],d[1]);return i(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}}),p=n.cw(function(e,t){e.exports=f()}),h={};n.r(h),n.d(h,{DndContext:()=>uc,DndProvider:()=>md,DragPreviewImage:()=>vd,useDrag:()=>_d,useDragDropManager:()=>$d,useDragLayer:()=>Ld,useDrop:()=>Vd});var m={};n.r(m),n.d(m,{FILE:()=>Qd,HTML:()=>Yd,TEXT:()=>Xd,URL:()=>Kd});var g={};n.r(g),n.d(g,{FILE:()=>Qd,HTML:()=>Yd,TEXT:()=>Xd,URL:()=>Kd});var v={};n.r(v),n.d(v,{HTML5Backend:()=>hf,NativeTypes:()=>m,getEmptyImage:()=>pf});var b={};n.r(b),n.d(b,{ListenerType:()=>mf,TouchBackend:()=>Nf,TouchBackendImpl:()=>Of});class y{constructor(e,t,n){this.eventTarget=e,this.eventName=t,this.eventOptions=n,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(e){this.unorderedBindings.add(e)}bindingDisconnected(e){this.unorderedBindings.delete(e)}handleEvent(e){const t=function(e){if("immediatePropagationStopped"in e)return e;{const{stopImmediatePropagation:t}=e;return Object.assign(e,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,t.call(this)}})}}(e);for(const e of this.bindings){if(t.immediatePropagationStopped)break;e.handleEvent(t)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort((e,t)=>{const n=e.index,r=t.index;return nr?1:0})}}class w{constructor(e){this.application=e,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach(e=>e.connect()))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach(e=>e.disconnect()))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce((e,t)=>e.concat(Array.from(t.values())),[])}bindingConnected(e){this.fetchEventListenerForBinding(e).bindingConnected(e)}bindingDisconnected(e,t=!1){this.fetchEventListenerForBinding(e).bindingDisconnected(e),t&&this.clearEventListenersForBinding(e)}handleError(e,t,n={}){this.application.handleError(e,`Error ${t}`,n)}clearEventListenersForBinding(e){const t=this.fetchEventListenerForBinding(e);t.hasBindings()||(t.disconnect(),this.removeMappedEventListenerFor(e))}removeMappedEventListenerFor(e){const{eventTarget:t,eventName:n,eventOptions:r}=e,o=this.fetchEventListenerMapForEventTarget(t),a=this.cacheKey(n,r);o.delete(a),0==o.size&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){const{eventTarget:t,eventName:n,eventOptions:r}=e;return this.fetchEventListener(t,n,r)}fetchEventListener(e,t,n){const r=this.fetchEventListenerMapForEventTarget(e),o=this.cacheKey(t,n);let a=r.get(o);return a||(a=this.createEventListener(e,t,n),r.set(o,a)),a}createEventListener(e,t,n){const r=new y(e,t,n);return this.started&&r.connect(),r}fetchEventListenerMapForEventTarget(e){let t=this.eventListenerMaps.get(e);return t||(t=new Map,this.eventListenerMaps.set(e,t)),t}cacheKey(e,t){const n=[e];return Object.keys(t).sort().forEach(e=>{n.push(`${t[e]?"":"!"}${e}`)}),n.join(":")}}const S={stop:({event:e,value:t})=>(t&&e.stopPropagation(),!0),prevent:({event:e,value:t})=>(t&&e.preventDefault(),!0),self:({event:e,value:t,element:n})=>!t||n===e.target},k=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function E(e){return"window"==e?window:"document"==e?document:void 0}function O(e){return e.replace(/(?:[_-])([a-z0-9])/g,(e,t)=>t.toUpperCase())}function N(e){return O(e.replace(/--/g,"-").replace(/__/g,"_"))}function C(e){return e.charAt(0).toUpperCase()+e.slice(1)}function D(e){return e.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}function A(e){return null!=e}function T(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const $=["meta","ctrl","alt","shift"];class M{constructor(e,t,n,r){this.element=e,this.index=t,this.eventTarget=n.eventTarget||e,this.eventName=n.eventName||function(e){const t=e.tagName.toLowerCase();if(t in R)return R[t](e)}(e)||x("missing event name"),this.eventOptions=n.eventOptions||{},this.identifier=n.identifier||x("missing identifier"),this.methodName=n.methodName||x("missing method name"),this.keyFilter=n.keyFilter||"",this.schema=r}static forToken(e,t){return new this(e.element,e.index,function(e){const t=e.trim().match(k)||[];let n=t[2],r=t[3];return r&&!["keydown","keyup","keypress"].includes(n)&&(n+=`.${r}`,r=""),{eventTarget:E(t[4]),eventName:n,eventOptions:t[7]?(o=t[7],o.split(":").reduce((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)}),{})):{},identifier:t[5],methodName:t[6],keyFilter:t[1]||r};var o}(e.content),t)}toString(){const e=this.keyFilter?`.${this.keyFilter}`:"",t=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${e}${t}->${this.identifier}#${this.methodName}`}shouldIgnoreKeyboardEvent(e){if(!this.keyFilter)return!1;const t=this.keyFilter.split("+");if(this.keyFilterDissatisfied(e,t))return!0;const n=t.filter(e=>!$.includes(e))[0];return!!n&&(T(this.keyMappings,n)||x(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[n].toLowerCase()!==e.key.toLowerCase())}shouldIgnoreMouseEvent(e){if(!this.keyFilter)return!1;const t=[this.keyFilter];return!!this.keyFilterDissatisfied(e,t)}get params(){const e={},t=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(const{name:n,value:r}of Array.from(this.element.attributes)){const o=n.match(t),a=o&&o[1];a&&(e[O(a)]=I(r))}return e}get eventTargetName(){return(e=this.eventTarget)==window?"window":e==document?"document":void 0;var e}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(e,t){const[n,r,o,a]=$.map(e=>t.includes(e));return e.metaKey!==n||e.ctrlKey!==r||e.altKey!==o||e.shiftKey!==a}}const R={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:e=>"submit"==e.getAttribute("type")?"click":"input",select:()=>"change",textarea:()=>"input"};function x(e){throw new Error(e)}function I(e){try{return JSON.parse(e)}catch(t){return e}}class P{constructor(e,t){this.context=e,this.action=t}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(e){const t=this.prepareActionEvent(e);this.willBeInvokedByEvent(e)&&this.applyEventModifiers(t)&&this.invokeWithEvent(t)}get eventName(){return this.action.eventName}get method(){const e=this.controller[this.methodName];if("function"==typeof e)return e;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(e){const{element:t}=this.action,{actionDescriptorFilters:n}=this.context.application,{controller:r}=this.context;let o=!0;for(const[a,i]of Object.entries(this.eventOptions))if(a in n){const l=n[a];o=o&&l({name:a,value:i,event:e,element:t,controller:r})}return o}prepareActionEvent(e){return Object.assign(e,{params:this.action.params})}invokeWithEvent(e){const{target:t,currentTarget:n}=e;try{this.method.call(this.controller,e),this.context.logDebugActivity(this.methodName,{event:e,target:t,currentTarget:n,action:this.methodName})}catch(t){const{identifier:n,controller:r,element:o,index:a}=this,i={identifier:n,controller:r,element:o,index:a,event:e};this.context.handleError(t,`invoking action "${this.action}"`,i)}}willBeInvokedByEvent(e){const t=e.target;return!(e instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(e))&&(!(e instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(e))&&(this.element===t||(t instanceof Element&&this.element.contains(t)?this.scope.containsElement(t):this.scope.containsElement(this.action.element))))}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class _{constructor(e,t){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=e,this.started=!1,this.delegate=t,this.elements=new Set,this.mutationObserver=new MutationObserver(e=>this.processMutations(e))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(e){this.started&&(this.mutationObserver.disconnect(),this.started=!1),e(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){const e=new Set(this.matchElementsInTree());for(const t of Array.from(this.elements))e.has(t)||this.removeElement(t);for(const t of Array.from(e))this.addElement(t)}}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){"attributes"==e.type?this.processAttributeChange(e.target,e.attributeName):"childList"==e.type&&(this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes))}processAttributeChange(e,t){this.elements.has(e)?this.delegate.elementAttributeChanged&&this.matchElement(e)?this.delegate.elementAttributeChanged(e,t):this.removeElement(e):this.matchElement(e)&&this.addElement(e)}processRemovedNodes(e){for(const t of Array.from(e)){const e=this.elementFromNode(t);e&&this.processTree(e,this.removeElement)}}processAddedNodes(e){for(const t of Array.from(e)){const e=this.elementFromNode(t);e&&this.elementIsActive(e)&&this.processTree(e,this.addElement)}}matchElement(e){return this.delegate.matchElement(e)}matchElementsInTree(e=this.element){return this.delegate.matchElementsInTree(e)}processTree(e,t){for(const n of this.matchElementsInTree(e))t.call(this,n)}elementFromNode(e){if(e.nodeType==Node.ELEMENT_NODE)return e}elementIsActive(e){return e.isConnected==this.element.isConnected&&this.element.contains(e)}addElement(e){this.elements.has(e)||this.elementIsActive(e)&&(this.elements.add(e),this.delegate.elementMatched&&this.delegate.elementMatched(e))}removeElement(e){this.elements.has(e)&&(this.elements.delete(e),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(e))}}class L{constructor(e,t,n){this.attributeName=t,this.delegate=n,this.elementObserver=new _(e,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(e){return e.hasAttribute(this.attributeName)}matchElementsInTree(e){const t=this.matchElement(e)?[e]:[],n=Array.from(e.querySelectorAll(this.selector));return t.concat(n)}elementMatched(e){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(e,this.attributeName)}elementUnmatched(e){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(e,this.attributeName)}elementAttributeChanged(e,t){this.delegate.elementAttributeValueChanged&&this.attributeName==t&&this.delegate.elementAttributeValueChanged(e,t)}}function G(e,t,n){z(e,t).add(n)}function F(e,t,n){z(e,t).delete(n),function(e,t){const n=e.get(t);null!=n&&0==n.size&&e.delete(t)}(e,t)}function z(e,t){let n=e.get(t);return n||(n=new Set,e.set(t,n)),n}class j{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce((e,t)=>e.concat(Array.from(t)),[])}get size(){return Array.from(this.valuesByKey.values()).reduce((e,t)=>e+t.size,0)}add(e,t){G(this.valuesByKey,e,t)}delete(e,t){F(this.valuesByKey,e,t)}has(e,t){const n=this.valuesByKey.get(e);return null!=n&&n.has(t)}hasKey(e){return this.valuesByKey.has(e)}hasValue(e){return Array.from(this.valuesByKey.values()).some(t=>t.has(e))}getValuesForKey(e){const t=this.valuesByKey.get(e);return t?Array.from(t):[]}getKeysForValue(e){return Array.from(this.valuesByKey).filter(([t,n])=>n.has(e)).map(([e,t])=>e)}}class q{constructor(e,t,n,r){this._selector=t,this.details=r,this.elementObserver=new _(e,this),this.delegate=n,this.matchesByElement=new j}get started(){return this.elementObserver.started}get selector(){return this._selector}set selector(e){this._selector=e,this.refresh()}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(e){const{selector:t}=this;if(t){const n=e.matches(t);return this.delegate.selectorMatchElement?n&&this.delegate.selectorMatchElement(e,this.details):n}return!1}matchElementsInTree(e){const{selector:t}=this;if(t){const n=this.matchElement(e)?[e]:[],r=Array.from(e.querySelectorAll(t)).filter(e=>this.matchElement(e));return n.concat(r)}return[]}elementMatched(e){const{selector:t}=this;t&&this.selectorMatched(e,t)}elementUnmatched(e){const t=this.matchesByElement.getKeysForValue(e);for(const n of t)this.selectorUnmatched(e,n)}elementAttributeChanged(e,t){const{selector:n}=this;if(n){const t=this.matchElement(e),r=this.matchesByElement.has(n,e);t&&!r?this.selectorMatched(e,n):!t&&r&&this.selectorUnmatched(e,n)}}selectorMatched(e,t){this.delegate.selectorMatched(e,t,this.details),this.matchesByElement.add(t,e)}selectorUnmatched(e,t){this.delegate.selectorUnmatched(e,t,this.details),this.matchesByElement.delete(t,e)}}class B{constructor(e,t){this.element=e,this.delegate=t,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver(e=>this.processMutations(e))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(const e of this.knownAttributeNames)this.refreshAttribute(e,null)}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){const t=e.attributeName;t&&this.refreshAttribute(t,e.oldValue)}refreshAttribute(e,t){const n=this.delegate.getStringMapKeyForAttribute(e);if(null!=n){this.stringMap.has(e)||this.stringMapKeyAdded(n,e);const r=this.element.getAttribute(e);if(this.stringMap.get(e)!=r&&this.stringMapValueChanged(r,n,t),null==r){const t=this.stringMap.get(e);this.stringMap.delete(e),t&&this.stringMapKeyRemoved(n,e,t)}else this.stringMap.set(e,r)}}stringMapKeyAdded(e,t){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,n){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(e,t,n)}stringMapKeyRemoved(e,t,n){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(e,t,n)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map(e=>e.name)}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}class V{constructor(e,t,n){this.attributeObserver=new L(e,t,this),this.delegate=n,this.tokensByElement=new j}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(e){this.attributeObserver.pause(e)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(e){this.tokensMatched(this.readTokensForElement(e))}elementAttributeValueChanged(e){const[t,n]=this.refreshTokensForElement(e);this.tokensUnmatched(t),this.tokensMatched(n)}elementUnmatchedAttribute(e){this.tokensUnmatched(this.tokensByElement.getValuesForKey(e))}tokensMatched(e){e.forEach(e=>this.tokenMatched(e))}tokensUnmatched(e){e.forEach(e=>this.tokenUnmatched(e))}tokenMatched(e){this.delegate.tokenMatched(e),this.tokensByElement.add(e.element,e)}tokenUnmatched(e){this.delegate.tokenUnmatched(e),this.tokensByElement.delete(e.element,e)}refreshTokensForElement(e){const t=this.tokensByElement.getValuesForKey(e),n=this.readTokensForElement(e),r=function(e,t){const n=Math.max(e.length,t.length);return Array.from({length:n},(n,r)=>[e[r],t[r]])}(t,n).findIndex(([e,t])=>{return r=t,!((n=e)&&r&&n.index==r.index&&n.content==r.content);var n,r});return-1==r?[[],[]]:[t.slice(r),n.slice(r)]}readTokensForElement(e){const t=this.attributeName;return function(e,t,n){return e.trim().split(/\s+/).filter(e=>e.length).map((e,r)=>({element:t,attributeName:n,content:e,index:r}))}(e.getAttribute(t)||"",e,t)}}class H{constructor(e,t,n){this.tokenListObserver=new V(e,t,this),this.delegate=n,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(e){const{element:t}=e,{value:n}=this.fetchParseResultForToken(e);n&&(this.fetchValuesByTokenForElement(t).set(e,n),this.delegate.elementMatchedValue(t,n))}tokenUnmatched(e){const{element:t}=e,{value:n}=this.fetchParseResultForToken(e);n&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,n))}fetchParseResultForToken(e){let t=this.parseResultsByToken.get(e);return t||(t=this.parseToken(e),this.parseResultsByToken.set(e,t)),t}fetchValuesByTokenForElement(e){let t=this.valuesByTokenByElement.get(e);return t||(t=new Map,this.valuesByTokenByElement.set(e,t)),t}parseToken(e){try{return{value:this.delegate.parseValueForToken(e)}}catch(e){return{error:e}}}}class U{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new H(this.element,this.actionAttribute,this),this.valueListObserver.start())}stop(){this.valueListObserver&&(this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions())}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(e){const t=new P(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)}disconnectAction(e){const t=this.bindingsByAction.get(e);t&&(this.bindingsByAction.delete(e),this.delegate.bindingDisconnected(t))}disconnectAllActions(){this.bindings.forEach(e=>this.delegate.bindingDisconnected(e,!0)),this.bindingsByAction.clear()}parseValueForToken(e){const t=M.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}}class W{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new B(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(e){if(e in this.valueDescriptorMap)return this.valueDescriptorMap[e].name}stringMapKeyAdded(e,t){const n=this.valueDescriptorMap[t];this.hasValue(e)||this.invokeChangedCallback(e,n.writer(this.receiver[e]),n.writer(n.defaultValue))}stringMapValueChanged(e,t,n){const r=this.valueDescriptorNameMap[t];null!==e&&(null===n&&(n=r.writer(r.defaultValue)),this.invokeChangedCallback(t,e,n))}stringMapKeyRemoved(e,t,n){const r=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,r.writer(this.receiver[e]),n):this.invokeChangedCallback(e,r.writer(r.defaultValue),n)}invokeChangedCallbacksForDefaultValues(){for(const{key:e,name:t,defaultValue:n,writer:r}of this.valueDescriptors)null==n||this.controller.data.has(e)||this.invokeChangedCallback(t,r(n),void 0)}invokeChangedCallback(e,t,n){const r=`${e}Changed`,o=this.receiver[r];if("function"==typeof o){const r=this.valueDescriptorNameMap[e];try{const e=r.reader(t);let a=n;n&&(a=r.reader(n)),o.call(this.receiver,e,a)}catch(e){throw e instanceof TypeError&&(e.message=`Stimulus Value "${this.context.identifier}.${r.name}" - ${e.message}`),e}}}get valueDescriptors(){const{valueDescriptorMap:e}=this;return Object.keys(e).map(t=>e[t])}get valueDescriptorNameMap(){const e={};return Object.keys(this.valueDescriptorMap).forEach(t=>{const n=this.valueDescriptorMap[t];e[n.name]=n}),e}hasValue(e){const t=`has${C(this.valueDescriptorNameMap[e].name)}`;return this.receiver[t]}}class Q{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new j}start(){this.tokenListObserver||(this.tokenListObserver=new V(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:e,content:t}){this.scope.containsElement(e)&&this.connectTarget(e,t)}tokenUnmatched({element:e,content:t}){this.disconnectTarget(e,t)}connectTarget(e,t){var n;this.targetsByName.has(t,e)||(this.targetsByName.add(t,e),null===(n=this.tokenListObserver)||void 0===n||n.pause(()=>this.delegate.targetConnected(e,t)))}disconnectTarget(e,t){var n;this.targetsByName.has(t,e)&&(this.targetsByName.delete(t,e),null===(n=this.tokenListObserver)||void 0===n||n.pause(()=>this.delegate.targetDisconnected(e,t)))}disconnectAllTargets(){for(const e of this.targetsByName.keys)for(const t of this.targetsByName.getValuesForKey(e))this.disconnectTarget(t,e)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}function K(e,t){const n=Y(e);return Array.from(n.reduce((e,n)=>(function(e,t){const n=e[t];return Array.isArray(n)?n:[]}(n,t).forEach(t=>e.add(t)),e),new Set))}function X(e,t){return Y(e).reduce((e,n)=>(e.push(...function(e,t){const n=e[t];return n?Object.keys(n).map(e=>[e,n[e]]):[]}(n,t)),e),[])}function Y(e){const t=[];for(;e;)t.push(e),e=Object.getPrototypeOf(e);return t.reverse()}class J{constructor(e,t){this.started=!1,this.context=e,this.delegate=t,this.outletsByName=new j,this.outletElementsByName=new j,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){this.started||(this.outletDefinitions.forEach(e=>{this.setupSelectorObserverForOutlet(e),this.setupAttributeObserverForOutlet(e)}),this.started=!0,this.dependentContexts.forEach(e=>e.refresh()))}refresh(){this.selectorObserverMap.forEach(e=>e.refresh()),this.attributeObserverMap.forEach(e=>e.refresh())}stop(){this.started&&(this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers())}stopSelectorObservers(){this.selectorObserverMap.size>0&&(this.selectorObserverMap.forEach(e=>e.stop()),this.selectorObserverMap.clear())}stopAttributeObservers(){this.attributeObserverMap.size>0&&(this.attributeObserverMap.forEach(e=>e.stop()),this.attributeObserverMap.clear())}selectorMatched(e,t,{outletName:n}){const r=this.getOutlet(e,n);r&&this.connectOutlet(r,e,n)}selectorUnmatched(e,t,{outletName:n}){const r=this.getOutletFromMap(e,n);r&&this.disconnectOutlet(r,e,n)}selectorMatchElement(e,{outletName:t}){const n=this.selector(t),r=this.hasOutlet(e,t),o=e.matches(`[${this.schema.controllerAttribute}~=${t}]`);return!!n&&(r&&o&&e.matches(n))}elementMatchedAttribute(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}elementAttributeValueChanged(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}elementUnmatchedAttribute(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}connectOutlet(e,t,n){var r;this.outletElementsByName.has(n,t)||(this.outletsByName.add(n,e),this.outletElementsByName.add(n,t),null===(r=this.selectorObserverMap.get(n))||void 0===r||r.pause(()=>this.delegate.outletConnected(e,t,n)))}disconnectOutlet(e,t,n){var r;this.outletElementsByName.has(n,t)&&(this.outletsByName.delete(n,e),this.outletElementsByName.delete(n,t),null===(r=this.selectorObserverMap.get(n))||void 0===r||r.pause(()=>this.delegate.outletDisconnected(e,t,n)))}disconnectAllOutlets(){for(const e of this.outletElementsByName.keys)for(const t of this.outletElementsByName.getValuesForKey(e))for(const n of this.outletsByName.getValuesForKey(e))this.disconnectOutlet(n,t,e)}updateSelectorObserverForOutlet(e){const t=this.selectorObserverMap.get(e);t&&(t.selector=this.selector(e))}setupSelectorObserverForOutlet(e){const t=this.selector(e),n=new q(document.body,t,this,{outletName:e});this.selectorObserverMap.set(e,n),n.start()}setupAttributeObserverForOutlet(e){const t=this.attributeNameForOutletName(e),n=new L(this.scope.element,t,this);this.attributeObserverMap.set(e,n),n.start()}selector(e){return this.scope.outlets.getSelectorForOutletName(e)}attributeNameForOutletName(e){return this.scope.schema.outletAttributeForScope(this.identifier,e)}getOutletNameFromOutletAttributeName(e){return this.outletDefinitions.find(t=>this.attributeNameForOutletName(t)===e)}get outletDependencies(){const e=new j;return this.router.modules.forEach(t=>{K(t.definition.controllerConstructor,"outlets").forEach(n=>e.add(n,t.identifier))}),e}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){const e=this.dependentControllerIdentifiers;return this.router.contexts.filter(t=>e.includes(t.identifier))}hasOutlet(e,t){return!!this.getOutlet(e,t)||!!this.getOutletFromMap(e,t)}getOutlet(e,t){return this.application.getControllerForElementAndIdentifier(e,t)}getOutletFromMap(e,t){return this.outletsByName.getValuesForKey(t).find(t=>t.element===e)}get scope(){return this.context.scope}get schema(){return this.context.schema}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}}class Z{constructor(e,t){this.logDebugActivity=(e,t={})=>{const{identifier:n,controller:r,element:o}=this;t=Object.assign({identifier:n,controller:r,element:o},t),this.application.logDebugActivity(this.identifier,e,t)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new U(this,this.dispatcher),this.valueObserver=new W(this,this.controller),this.targetObserver=new Q(this,this),this.outletObserver=new J(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(e){this.handleError(e,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(e){this.handleError(e,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(e){this.handleError(e,"disconnecting controller")}this.outletObserver.stop(),this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(e,t,n={}){const{identifier:r,controller:o,element:a}=this;n=Object.assign({identifier:r,controller:o,element:a},n),this.application.handleError(e,`Error ${t}`,n)}targetConnected(e,t){this.invokeControllerMethod(`${t}TargetConnected`,e)}targetDisconnected(e,t){this.invokeControllerMethod(`${t}TargetDisconnected`,e)}outletConnected(e,t,n){this.invokeControllerMethod(`${N(n)}OutletConnected`,e,t)}outletDisconnected(e,t,n){this.invokeControllerMethod(`${N(n)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){const n=this.controller;"function"==typeof n[e]&&n[e](...t)}}function ee(e){return function(e,t){const n=ne(e),r=function(e,t){return te(t).reduce((n,r)=>{const o=function(e,t,n){const r=Object.getOwnPropertyDescriptor(e,n);if(!r||!("value"in r)){const e=Object.getOwnPropertyDescriptor(t,n).value;return r&&(e.get=r.get||e.get,e.set=r.set||e.set),e}}(e,t,r);return o&&Object.assign(n,{[r]:o}),n},{})}(e.prototype,t);return Object.defineProperties(n.prototype,r),n}(e,function(e){const t=K(e,"blessings");return t.reduce((t,n)=>{const r=n(e);for(const e in r){const n=t[e]||{};t[e]=Object.assign(n,r[e])}return t},{})}(e))}const te="function"==typeof Object.getOwnPropertySymbols?e=>[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)]:Object.getOwnPropertyNames,ne=(()=>{function e(e){function t(){return Reflect.construct(e,arguments,new.target)}return t.prototype=Object.create(e.prototype,{constructor:{value:t}}),Reflect.setPrototypeOf(t,e),t}try{return function(){const t=e(function(){this.a.call(this)});t.prototype.a=function(){},new t}(),e}catch(e){return e=>class extends e{}}})();class re{constructor(e,t){this.application=e,this.definition=function(e){return{identifier:e.identifier,controllerConstructor:ee(e.controllerConstructor)}}(t),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(e){const t=this.fetchContextForScope(e);this.connectedContexts.add(t),t.connect()}disconnectContextForScope(e){const t=this.contextsByScope.get(e);t&&(this.connectedContexts.delete(t),t.disconnect())}fetchContextForScope(e){let t=this.contextsByScope.get(e);return t||(t=new Z(this,e),this.contextsByScope.set(e,t)),t}}class oe{constructor(e){this.scope=e}has(e){return this.data.has(this.getDataKey(e))}get(e){return this.getAll(e)[0]}getAll(e){const t=this.data.get(this.getDataKey(e))||"";return t.match(/[^\s]+/g)||[]}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}}class ae{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(e){const t=this.getAttributeNameForKey(e);return this.element.getAttribute(t)}set(e,t){const n=this.getAttributeNameForKey(e);return this.element.setAttribute(n,t),this.get(e)}has(e){const t=this.getAttributeNameForKey(e);return this.element.hasAttribute(t)}delete(e){if(this.has(e)){const t=this.getAttributeNameForKey(e);return this.element.removeAttribute(t),!0}return!1}getAttributeNameForKey(e){return`data-${this.identifier}-${D(e)}`}}class ie{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,n){let r=this.warnedKeysByObject.get(e);r||(r=new Set,this.warnedKeysByObject.set(e,r)),r.has(t)||(r.add(t),this.logger.warn(n,e))}}function le(e,t){return`[${e}~="${t}"]`}class se{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return null!=this.find(e)}find(...e){return e.reduce((e,t)=>e||this.findTarget(t)||this.findLegacyTarget(t),void 0)}findAll(...e){return e.reduce((e,t)=>[...e,...this.findAllTargets(t),...this.findAllLegacyTargets(t)],[])}findTarget(e){const t=this.getSelectorForTargetName(e);return this.scope.findElement(t)}findAllTargets(e){const t=this.getSelectorForTargetName(e);return this.scope.findAllElements(t)}getSelectorForTargetName(e){return le(this.schema.targetAttributeForScope(this.identifier),e)}findLegacyTarget(e){const t=this.getLegacySelectorForTargetName(e);return this.deprecate(this.scope.findElement(t),e)}findAllLegacyTargets(e){const t=this.getLegacySelectorForTargetName(e);return this.scope.findAllElements(t).map(t=>this.deprecate(t,e))}getLegacySelectorForTargetName(e){const t=`${this.identifier}.${e}`;return le(this.schema.targetAttribute,t)}deprecate(e,t){if(e){const{identifier:n}=this,r=this.schema.targetAttribute,o=this.schema.targetAttributeForScope(n);this.guide.warn(e,`target:${t}`,`Please replace ${r}="${n}.${t}" with ${o}="${t}". The ${r} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}}class ue{constructor(e,t){this.scope=e,this.controllerElement=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return null!=this.find(e)}find(...e){return e.reduce((e,t)=>e||this.findOutlet(t),void 0)}findAll(...e){return e.reduce((e,t)=>[...e,...this.findAllOutlets(t)],[])}getSelectorForOutletName(e){const t=this.schema.outletAttributeForScope(this.identifier,e);return this.controllerElement.getAttribute(t)}findOutlet(e){const t=this.getSelectorForOutletName(e);if(t)return this.findElement(t,e)}findAllOutlets(e){const t=this.getSelectorForOutletName(e);return t?this.findAllElements(t,e):[]}findElement(e,t){return this.scope.queryElements(e).filter(n=>this.matchesElement(n,e,t))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter(n=>this.matchesElement(n,e,t))}matchesElement(e,t,n){const r=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&r.split(" ").includes(n)}}class ce{constructor(e,t,n,r){this.targets=new se(this),this.classes=new oe(this),this.data=new ae(this),this.containsElement=e=>e.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=n,this.guide=new ie(r),this.outlets=new ue(this.documentScope,t)}findElement(e){return this.element.matches(e)?this.element:this.queryElements(e).find(this.containsElement)}findAllElements(e){return[...this.element.matches(e)?[this.element]:[],...this.queryElements(e).filter(this.containsElement)]}queryElements(e){return Array.from(this.element.querySelectorAll(e))}get controllerSelector(){return le(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new ce(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class de{constructor(e,t,n){this.element=e,this.schema=t,this.delegate=n,this.valueListObserver=new H(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(e){const{element:t,content:n}=e;return this.parseValueForElementAndIdentifier(t,n)}parseValueForElementAndIdentifier(e,t){const n=this.fetchScopesByIdentifierForElement(e);let r=n.get(t);return r||(r=this.delegate.createScopeForElementAndIdentifier(e,t),n.set(t,r)),r}elementMatchedValue(e,t){const n=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,n),1==n&&this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){const n=this.scopeReferenceCounts.get(t);n&&(this.scopeReferenceCounts.set(t,n-1),1==n&&this.delegate.scopeDisconnected(t))}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t}}class fe{constructor(e){this.application=e,this.scopeObserver=new de(this.element,this.schema,this),this.scopesByIdentifier=new j,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce((e,t)=>e.concat(t.contexts),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(e){this.unloadIdentifier(e.identifier);const t=new re(this.application,e);this.connectModule(t);const n=e.controllerConstructor.afterLoad;n&&n.call(e.controllerConstructor,e.identifier,this.application)}unloadIdentifier(e){const t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){const n=this.modulesByIdentifier.get(t);if(n)return n.contexts.find(t=>t.element==e)}proposeToConnectScopeForElementAndIdentifier(e,t){const n=this.scopeObserver.parseValueForElementAndIdentifier(e,t);n?this.scopeObserver.elementMatchedValue(n.element,n):console.error(`Couldn't find or create scope for identifier: "${t}" and element:`,e)}handleError(e,t,n){this.application.handleError(e,t,n)}createScopeForElementAndIdentifier(e,t){return new ce(this.schema,e,t,this.logger)}scopeConnected(e){this.scopesByIdentifier.add(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.connectContextForScope(e)}scopeDisconnected(e){this.scopesByIdentifier.delete(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.disconnectContextForScope(e)}connectModule(e){this.modulesByIdentifier.set(e.identifier,e);this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(t=>e.connectContextForScope(t))}disconnectModule(e){this.modulesByIdentifier.delete(e.identifier);this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(t=>e.disconnectContextForScope(t))}}const pe={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:e=>`data-${e}-target`,outletAttributeForScope:(e,t)=>`data-${e}-${t}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",page_up:"PageUp",page_down:"PageDown"},he("abcdefghijklmnopqrstuvwxyz".split("").map(e=>[e,e]))),he("0123456789".split("").map(e=>[e,e])))};function he(e){return e.reduce((e,[t,n])=>Object.assign(Object.assign({},e),{[t]:n}),{})}function me(e,t,n){return e.application.getControllerForElementAndIdentifier(t,n)}function ge(e,t,n){let r=me(e,t,n);return r||(e.application.router.proposeToConnectScopeForElementAndIdentifier(t,n),r=me(e,t,n),r||void 0)}function ve([e,t],n){return function(e){const{token:t,typeDefinition:n}=e,r=`${D(t)}-value`,o=function(e){const{controller:t,token:n,typeDefinition:r}=e,o={controller:t,token:n,typeObject:r},a=function(e){const{controller:t,token:n,typeObject:r}=e,o=A(r.type),a=A(r.default),i=o&&a,l=o&&!a,s=!o&&a,u=be(r.type),c=ye(e.typeObject.default);if(l)return u;if(s)return c;if(u!==c){throw new Error(`The specified default value for the Stimulus Value "${t?`${t}.${n}`:n}" must match the defined type "${u}". The provided default value of "${r.default}" is of type "${c}".`)}if(i)return u}(o),i=ye(r),l=be(r),s=a||i||l;if(s)return s;const u=t?`${t}.${r}`:n;throw new Error(`Unknown value type "${u}" for "${n}" value`)}(e);return{type:o,key:r,name:O(r),get defaultValue(){return function(e){const t=be(e);if(t)return we[t];const n=T(e,"default"),r=T(e,"type"),o=e;if(n)return o.default;if(r){const{type:e}=o,t=be(e);if(t)return we[t]}return e}(n)},get hasCustomDefaultValue(){return void 0!==ye(n)},reader:Se[o],writer:ke[o]||ke.default}}({controller:n,token:e,typeDefinition:t})}function be(e){switch(e){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function ye(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}return Array.isArray(e)?"array":"[object Object]"===Object.prototype.toString.call(e)?"object":void 0}const we={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},Se={array(e){const t=JSON.parse(e);if(!Array.isArray(t))throw new TypeError(`expected value of type "array" but instead got value "${e}" of type "${ye(t)}"`);return t},boolean:e=>!("0"==e||"false"==String(e).toLowerCase()),number:e=>Number(e.replace(/_/g,"")),object(e){const t=JSON.parse(e);if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError(`expected value of type "object" but instead got value "${e}" of type "${ye(t)}"`);return t},string:e=>e},ke={default:function(e){return`${e}`},array:Ee,object:Ee};function Ee(e){return JSON.stringify(e)}class Oe{constructor(e){this.context=e}static get shouldLoad(){return!0}static afterLoad(e,t){}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get outlets(){return this.scope.outlets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(e,{target:t=this.element,detail:n={},prefix:r=this.identifier,bubbles:o=!0,cancelable:a=!0}={}){const i=new CustomEvent(r?`${r}:${e}`:e,{detail:n,bubbles:o,cancelable:a});return t.dispatchEvent(i),i}}Oe.blessings=[function(e){return K(e,"classes").reduce((e,t)=>{return Object.assign(e,(n=t,{[`${n}Class`]:{get(){const{classes:e}=this;if(e.has(n))return e.get(n);{const t=e.getAttributeName(n);throw new Error(`Missing attribute "${t}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${C(n)}Class`]:{get(){return this.classes.has(n)}}}));var n},{})},function(e){return K(e,"targets").reduce((e,t)=>{return Object.assign(e,(n=t,{[`${n}Target`]:{get(){const e=this.targets.find(n);if(e)return e;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${C(n)}Target`]:{get(){return this.targets.has(n)}}}));var n},{})},function(e){const t=X(e,"values"),n={valueDescriptorMap:{get(){return t.reduce((e,t)=>{const n=ve(t,this.identifier),r=this.data.getAttributeNameForKey(n.key);return Object.assign(e,{[r]:n})},{})}}};return t.reduce((e,t)=>Object.assign(e,function(e,t){const n=ve(e,t),{key:r,name:o,reader:a,writer:i}=n;return{[o]:{get(){const e=this.data.get(r);return null!==e?a(e):n.defaultValue},set(e){void 0===e?this.data.delete(r):this.data.set(r,i(e))}},[`has${C(o)}`]:{get(){return this.data.has(r)||n.hasCustomDefaultValue}}}}(t)),n)},function(e){return K(e,"outlets").reduce((e,t)=>Object.assign(e,function(e){const t=N(e);return{[`${t}Outlet`]:{get(){const t=this.outlets.find(e),n=this.outlets.getSelectorForOutletName(e);if(t){const n=ge(this,t,e);if(n)return n;throw new Error(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`)}throw new Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${n}".`)}},[`${t}Outlets`]:{get(){const t=this.outlets.findAll(e);return t.length>0?t.map(t=>{const n=ge(this,t,e);if(n)return n;console.warn(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`,t)}).filter(e=>e):[]}},[`${t}OutletElement`]:{get(){const t=this.outlets.find(e),n=this.outlets.getSelectorForOutletName(e);if(t)return t;throw new Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${n}".`)}},[`${t}OutletElements`]:{get(){return this.outlets.findAll(e)}},[`has${C(t)}Outlet`]:{get(){return this.outlets.has(e)}}}}(t)),{})}],Oe.targets=[],Oe.outlets=[],Oe.values={};n(236);s(),o();const Ne=()=>{},Ce=(0,l().createContext)({dragPreviewState:null,updatePreviewPosition:Ne,commitDrag:Ne,cancelDrag:Ne}),De=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296,66720,68912,68928,69734,69872,69942,70096,70384,70736,70864,71248,71360,71376,71386,71472,71904,72016,72688,72784,73040,73120,73184,73552,90416,92768,92864,93008,93552,118e3,120782,120792,120802,120812,120822,123200,123632,124144,124401,125264,130032],Ae={"⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9"},Te=/[⁰¹²³⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅₆₇₈₉]/g,$e={"¼":"1/4","½":"1/2","¾":"3/4","⅐":"1/7","⅑":"1/9","⅒":"1/10","⅓":"1/3","⅔":"2/3","⅕":"1/5","⅖":"2/5","⅗":"3/5","⅘":"4/5","⅙":"1/6","⅚":"5/6","⅛":"1/8","⅜":"3/8","⅝":"5/8","⅞":"7/8","⅟":"1/"},Me=/^(?=[-+]?\s*\.\d|[-+]?\s*\d)([-+])?\s*((?:\d(?:[,_]\d|\d)*)*)(([eE][+-]?\d(?:[,_]\d|\d)*)?|\.\d(?:[,_]\d|\d)*([eE][+-]?\d(?:[,_]\d|\d)*)?|(\s+\d(?:[,_]\d|\d)*\s*)?\s*\/\s*\d(?:[,_]\d|\d)*)?$/,Re=/^(?=[-+]?\s*\.\d|[-+]?\s*\d)([-+])?\s*((?:\d(?:[,_]\d|\d)*)*)(([eE][+-]?\d(?:[,_]\d|\d)*)?|\.\d(?:[,_]\d|\d)*([eE][+-]?\d(?:[,_]\d|\d)*)?|(\s+\d(?:[,_]\d|\d)*\s*)?\s*\/\s*\d(?:[,_]\d|\d)*)?(\s*[^.\d/].*)?/,xe=/([¼½¾⅐⅑⅒⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞⅟])/g,Ie={MMM:3e3,MM:2e3,M:1e3,CM:900,DCCC:800,DCC:700,DC:600,D:500,CD:400,CCC:300,CC:200,C:100,XC:90,LXXX:80,LXX:70,LX:60,L:50,XL:40,XXX:30,XX:20,XII:12,XI:11,X:10,IX:9,VIII:8,VII:7,VI:6,V:5,IV:4,III:3,II:2,I:1},Pe={Ⅰ:"I",Ⅱ:"II",Ⅲ:"III",Ⅳ:"IV",Ⅴ:"V",Ⅵ:"VI",Ⅶ:"VII",Ⅷ:"VIII",Ⅸ:"IX",Ⅹ:"X",Ⅺ:"XI",Ⅻ:"XII",Ⅼ:"L",Ⅽ:"C",Ⅾ:"D",Ⅿ:"M",ⅰ:"I",ⅱ:"II",ⅲ:"III",ⅳ:"IV",ⅴ:"V",ⅵ:"VI",ⅶ:"VII",ⅷ:"VIII",ⅸ:"IX",ⅹ:"X",ⅺ:"XI",ⅻ:"XII",ⅼ:"L",ⅽ:"C",ⅾ:"D",ⅿ:"M"},_e=/([ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿ])/gi,Le=/^(?=[MDCLXVI])(M{0,3})(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$/i,Ge={round:3,allowTrailingInvalid:!1,romanNumerals:!1,bigIntOnOverflow:!1,decimalSeparator:".",allowCurrency:!1,percentage:!1,verbose:!1},Fe=/^\s*\//,ze=/^([-+]?)\s*(\p{Sc}+)\s*/u,je=/\s*(\p{Sc}+)\s*$/u,qe=/\s*%$/,Be=BigInt(Number.MAX_SAFE_INTEGER),Ve=e=>10n**BigInt(e);function He(e,t=Ge){var n;const r={...Ge,...t};let o,a,i,l,s,u,c,d,f;if("string"==typeof e)o=e;else try{o=String(e)}catch{o=""}const p=e=>r.verbose?(e=>{const t={value:e,input:o};return a&&(t.currencyPrefix=a),i&&(t.currencySuffix=i),l&&(t.percentageSuffix=l),s&&(t.trailingInvalid=s),u&&(t.sign=u),void 0!==c&&(t.whole=c),void 0!==d&&(t.numerator=d),void 0!==f&&(t.denominator=f),t})(e):e,h=e=>l&&"number"!==r.percentage?e/100:e;if("symbol"==typeof e)return p(NaN);if("number"==typeof e||"bigint"==typeof e)return p(e);let m=NaN,g=o,v=!0;for(;v;){if(v=!1,r.allowCurrency){const e=ze.exec(g);(null==e?void 0:e[2])&&(a=(a??"")+e[2],g=(e[1]||"")+g.slice(e[0].length),v=!0);const t=je.exec(g);t&&(i=t[1]+(i??""),g=g.slice(0,-t[0].length),v=!0)}if(!l&&r.percentage){const e=qe.exec(g);e&&(l=!0,g=g.slice(0,-e[0].length),v=!0)}}const b=g.replace(xe,(e,t)=>` ${$e[t]}`).replace(Te,e=>Ae[e]).replace("⁄","/").trim().replace(/\p{Nd}/gu,e=>{const t=e.codePointAt(0);if(t<=57)return e;let n=0,r=De.length-1;for(;n>>1;De[e]<=t?n=e:r=e-1}return String(t-De[n])});if(0===b.length)return p(NaN);let y=b;if(","===r.decimalSeparator){const e=(b.match(/,/g)||[]).length;if(1===e)y=b.replaceAll(".","_").replace(",",".");else if(e>1){const e=b.indexOf(","),t=b.indexOf(",",e+1);y=b.substring(0,t).replaceAll(".","_").replace(",",".")}else y=b.replaceAll(".","_")}const w=Re.exec(y);if(!w)return r.romanNumerals?p(h((e=>{const t=e.replace(_e,(e,t)=>Pe[t]).toUpperCase(),n=Le.exec(t);if(!n)return NaN;const[,r,o,a,i]=n;return(Ie[r]??0)+(Ie[o]??0)+(Ie[a]??0)+(Ie[i]??0)})(b))):p(NaN);const S=w[0].length-((null===(n=w[7])||void 0===n?void 0:n.length)??0),k=b.slice(S).trim();if(k&&(s=k,!r.allowTrailingInvalid))return p(NaN);const[,E,O,N]=w;"-"!==E&&"+"!==E||(u=E);const C=O.replaceAll(",","").replaceAll("_",""),D=null==N?void 0:N.replaceAll(",","").replaceAll("_","");if(r.bigIntOnOverflow){const e=((e,t,n)=>{let r,o=1n;if(t)if(t.startsWith(".")||t.startsWith("e")||t.startsWith("E")){const n=t.search(/[eE]/),a=-1===n?0:parseInt(t.slice(n+1));if(!Number.isFinite(a)||Math.abs(a)>1e4)return;const i=(-1===n?t:t.slice(0,n)).slice(1);r=BigInt(`${e}${i}`),i&&(o=Ve(i.length)),a>0?r*=Ve(a):a<0&&(o*=Ve(-a))}else if(Fe.test(t))r=BigInt(e),o=BigInt(t.replace("/","").trim());else{const[n,a]=t.split("/");o=BigInt(a.trim()),r=BigInt(e)*o+BigInt(n.trim())}else r=BigInt(e);if(n&&(o*=100n),0n===o)return;const a=(2n*r+o)/(2n*o);return a>Be?a:void 0})(C,D,!!l&&"number"!==r.percentage);if(void 0!==e)return p("-"===E?-e:e)}if(m=!C&&D&&D.startsWith(".")?0:parseInt(C),!D)return m="-"===E?-1*m:m,p(h(m));const A=!("number"!=typeof r.round||!Number.isFinite(r.round))&&Math.floor(Math.max(0,r.round)),T=!1===A?NaN:10**A,$=Number.isFinite(T)?T:NaN,M=(e,t)=>{const n=Math.round(t)/$;return Number.isFinite(n)||!Number.isFinite(e)?n:e};if(D.startsWith(".")||D.startsWith("e")||D.startsWith("E")){const e=parseFloat(`${m}${D}`);m=isNaN($)?e:M(e,e*$)}else if(Fe.test(D)){const e=parseInt(C),t=parseInt(D.replace("/",""));d=e,f=t,m=isNaN($)?e/t:M(e/t,e*$/t)}else{const[e,t]=D.split("/").map(e=>parseInt(e));c=m,d=e,f=t,m+=isNaN($)?e/t:M(e/t,e*$/t)}return m="-"===E?-1*m:m,p(h(m))}var Ue=Symbol.for("immer-nothing"),We=Symbol.for("immer-draftable"),Qe=Symbol.for("immer-state");function Ke(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Xe=Object,Ye=Xe.getPrototypeOf,Je="constructor",Ze="prototype",et="configurable",tt="enumerable",nt="writable",rt="value",ot=e=>!!e&&!!e[Qe];function at(e){return!!e&&(st(e)||ht(e)||!!e[We]||!!e[Je]?.[We]||mt(e)||gt(e))}var it=Xe[Ze][Je].toString(),lt=new WeakMap;function st(e){if(!e||!vt(e))return!1;const t=Ye(e);if(null===t||t===Xe[Ze])return!0;const n=Xe.hasOwnProperty.call(t,Je)&&t[Je];if(n===Object)return!0;if(!bt(n))return!1;let r=lt.get(n);return void 0===r&&(r=Function.toString.call(n),lt.set(n,r)),r===it}function ut(e,t,n=!0){if(0===ct(e)){(n?Reflect.ownKeys(e):Xe.keys(e)).forEach(n=>{t(n,e[n],e)})}else e.forEach((n,r)=>t(r,n,e))}function ct(e){const t=e[Qe];return t?t.type_:ht(e)?1:mt(e)?2:gt(e)?3:0}var dt=(e,t,n=ct(e))=>2===n?e.has(t):Xe[Ze].hasOwnProperty.call(e,t),ft=(e,t,n=ct(e))=>2===n?e.get(t):e[t],pt=(e,t,n,r=ct(e))=>{2===r?e.set(t,n):3===r?e.add(n):e[t]=n};var ht=Array.isArray,mt=e=>e instanceof Map,gt=e=>e instanceof Set,vt=e=>"object"==typeof e,bt=e=>"function"==typeof e,yt=e=>"boolean"==typeof e;var wt=e=>e.copy_||e.base_,St=e=>e.modified_?e.copy_:e.base_;function kt(e,t){if(mt(e))return new Map(e);if(gt(e))return new Set(e);if(ht(e))return Array[Ze].slice.call(e);const n=st(e);if(!0===t||"class_only"===t&&!n){const t=Xe.getOwnPropertyDescriptors(e);delete t[Qe];let n=Reflect.ownKeys(t);for(let r=0;r1&&Xe.defineProperties(e,{set:Ot,add:Ot,clear:Ot,delete:Ot}),Xe.freeze(e),t&&ut(e,(e,t)=>{Et(t,!0)},!1)),e}var Ot={[rt]:function(){Ke(2)}};function Nt(e){return null===e||!vt(e)||Xe.isFrozen(e)}var Ct="MapSet",Dt="Patches",At="ArrayMethods",Tt={};function $t(e){const t=Tt[e];return t||Ke(0),t}var Mt,Rt=e=>!!Tt[e];var xt=()=>Mt;function It(e,t){t&&(e.patchPlugin_=$t(Dt),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Pt(e){_t(e),e.drafts_.forEach(Gt),e.drafts_=null}function _t(e){e===Mt&&(Mt=e.parent_)}var Lt=e=>Mt={drafts_:[],parent_:Mt,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Rt(Ct)?$t(Ct):void 0,arrayMethodsPlugin_:Rt(At)?$t(At):void 0};function Gt(e){const t=e[Qe];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Ft(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(void 0!==e&&e!==n){n[Qe].modified_&&(Pt(t),Ke(4)),at(e)&&(e=zt(t,e));const{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[Qe].base_,e,t)}else e=zt(t,n);return function(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Et(t,n)}(t,e,!0),Pt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ue?e:void 0}function zt(e,t){if(Nt(t))return t;const n=t[Qe];if(!n){return Wt(t,e.handledSet_,e)}if(!qt(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:t}=n;if(t)for(;t.length>0;){t.pop()(e)}Ht(n,e)}return n.copy_}function jt(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var qt=(e,t)=>e.scope_===t,Bt=[];function Vt(e,t,n,r){const o=wt(e),a=e.type_;if(void 0!==r){if(ft(o,r,a)===t)return void pt(o,r,n,a)}if(!e.draftLocations_){const t=e.draftLocations_=new Map;ut(o,(e,n)=>{if(ot(n)){const r=t.get(n)||[];r.push(e),t.set(n,r)}})}const i=e.draftLocations_.get(t)??Bt;for(const e of i)pt(o,e,n,a)}function Ht(e,t){if(e.modified_&&!e.finalized_&&(3===e.type_||1===e.type_&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:n}=t;if(n){const r=n.getPath(e);r&&n.generatePatches_(e,r,t)}jt(e)}}function Ut(e,t,n){const{scope_:r}=e;if(ot(n)){const o=n[Qe];qt(o,r)&&o.callbacks_.push(function(){Zt(e);const r=St(o);Vt(e,n,r,t)})}else at(n)&&e.callbacks_.push(function(){const o=wt(e);3===e.type_?o.has(n)&&Wt(n,r.handledSet_,r):ft(o,t,e.type_)===n&&r.drafts_.length>1&&!0===(e.assigned_.get(t)??!1)&&e.copy_&&Wt(ft(e.copy_,t,e.type_),r.handledSet_,r)})}function Wt(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||ot(e)||t.has(e)||!at(e)||Nt(e)||(t.add(e),ut(e,(r,o)=>{if(ot(o)){const t=o[Qe];if(qt(t,n)){const n=St(t);pt(e,r,n,e.type_),jt(t)}}else at(o)&&Wt(o,t,n)})),e}var Qt={get(e,t){if(t===Qe)return e;let n=e.scope_.arrayMethodsPlugin_;const r=1===e.type_&&"string"==typeof t;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const o=wt(e);if(!dt(o,t,e.type_))return function(e,t,n){const r=Yt(t,n);return r?rt in r?r[rt]:r.get?.call(e.draft_):void 0}(e,o,t);const a=o[t];if(e.finalized_||!at(a))return a;if(r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&function(e){const t=+e;return Number.isInteger(t)&&String(t)===e}(t))return a;if(a===Xt(e.base_,t)||function(e,t,n){if(1!==e.type_||!e.allIndicesReassigned_||e.assigned_?.get(t)||!at(n)||n[Qe])return!1;return e.baseRefs_.has(n)}(e,t,a)){Zt(e);const n=1===e.type_?+t:t,r=tn(e.scope_,a,e,n);return e.copy_[n]=r}return a},has:(e,t)=>t in wt(e),ownKeys:e=>Reflect.ownKeys(wt(e)),set(e,t,n){const r=Yt(wt(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=Xt(wt(e),t),i=r?.[Qe];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(((o=n)===(a=r)?0!==o||1/o==1/a:o!=o&&a!=a)&&(void 0!==n||dt(e.base_,t,e.type_)))return!0;Zt(e),Jt(e)}var o,a;return e.copy_[t]===n&&(void 0!==n||dt(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),Ut(e,t,n)),!0},deleteProperty:(e,t)=>(Zt(e),void 0!==Xt(e.base_,t)||t in e.base_?(e.assigned_.set(t,!1),Jt(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=wt(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{[nt]:!0,[et]:1!==e.type_||"length"!==t,[tt]:r[tt],[rt]:n[t]}:r},defineProperty(){Ke(11)},getPrototypeOf:e=>Ye(e.base_),setPrototypeOf(){Ke(12)}},Kt={};for(let e in Qt){let t=Qt[e];Kt[e]=function(){const e=arguments;return e[0]=e[0][0],t.apply(this,e)}}function Xt(e,t){const n=e[Qe];return(n?wt(n):e)[t]}function Yt(e,t){if(!(t in e))return;let n=Ye(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Ye(n)}}function Jt(e){e.modified_||(e.modified_=!0,e.parent_&&Jt(e.parent_))}function Zt(e){e.copy_||(e.assigned_=new Map,e.copy_=kt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Kt.deleteProperty=function(e,t){return Kt.set.call(this,e,t,void 0)},Kt.set=function(e,t,n){return Qt.set.call(this,e[0],t,n,e[0])};var en=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(bt(e)&&!bt(t)){const n=t;t=e;const r=this;return function(e=n,...o){return r.produce(e,e=>t.call(this,e,...o))}}let r;if(bt(t)||Ke(6),void 0===n||bt(n)||Ke(7),at(e)){const o=Lt(this),a=tn(o,e,void 0);let i=!0;try{r=t(a),i=!1}finally{i?Pt(o):_t(o)}return It(o,n),Ft(r,o)}if(!e||!vt(e)){if(r=t(e),void 0===r&&(r=e),r===Ue&&(r=void 0),this.autoFreeze_&&Et(r,!0),n){const t=[],o=[];$t(Dt).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:o}),n(t,o)}return r}Ke(1)},this.produceWithPatches=(e,t)=>{if(bt(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},yt(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),yt(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),yt(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){at(e)||Ke(8),ot(e)&&(e=nn(e));const t=Lt(this),n=tn(t,e,void 0);return n[Qe].isManual_=!0,_t(t),n}finishDraft(e,t){const n=e&&e[Qe];n&&n.isManual_||Ke(9);const{scope_:r}=n;return It(r,t),Ft(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=$t(Dt).applyPatches_;return ot(e)?r(e,t):this.produce(e,e=>r(e,t))}};function tn(e,t,n,r){const[o,a]=mt(t)?$t(Ct).proxyMap_(t,n):gt(t)?$t(Ct).proxySet_(t,n):function(e,t){const n=ht(e),r={type_:n?1:0,scope_:t?t.scope_:xt(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let o=r,a=Qt;n&&(o=[r],a=Kt);const{revoke:i,proxy:l}=Proxy.revocable(o,a);return r.draft_=l,r.revoke_=i,[l,r]}(t,n);return(n?.scope_??xt()).drafts_.push(o),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&void 0!==r?function(e,t,n){e.callbacks_.push(function(r){const o=t;if(!o||!qt(o,r))return;r.mapSetPlugin_?.fixSetContents(o);const a=St(o);Vt(e,o.draft_??o,a,n),Ht(o,r)})}(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),o}function nn(e){return ot(e)||Ke(10),rn(e)}function rn(e){if(!at(e)||Nt(e))return e;const t=e[Qe];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=kt(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=kt(e,!0);return ut(n,(e,t)=>{pt(n,e,rn(t))},r),t&&(t.finalized_=!1),n}globalThis.Iterator;var on=new en,an=on.produce;const ln="------",sn={fields:{title:"Field",placeholderName:"~",placeholderLabel:ln,placeholderGroupLabel:ln},operators:{title:"Operator",placeholderName:"~",placeholderLabel:ln,placeholderGroupLabel:ln},values:{title:"Values",placeholderName:"~",placeholderLabel:ln,placeholderGroupLabel:ln},matchMode:{title:"Match mode"},matchThreshold:{title:"Match threshold",placeholderName:"#"},value:{title:"Value"},removeRule:{label:"⨯",title:"Remove rule"},removeGroup:{label:"⨯",title:"Remove group"},addRule:{label:"+ Rule",title:"Add rule"},addGroup:{label:"+ Group",title:"Add group"},combinators:{title:"Combinator"},notToggle:{label:"Not",title:"Invert this group"},cloneRule:{label:"⧉",title:"Clone rule"},cloneRuleGroup:{label:"⧉",title:"Clone group"},shiftActionUp:{label:"˄",title:"Shift up"},shiftActionDown:{label:"˅",title:"Shift down"},undo:{label:"↶",title:"Undo"},redo:{label:"↷",title:"Redo"},dragHandle:{label:"⁞⁞",title:"Drag handle"},lockRule:{label:"🔓",title:"Lock rule"},lockGroup:{label:"🔓",title:"Lock group"},lockRuleDisabled:{label:"🔒",title:"Unlock rule"},lockGroupDisabled:{label:"🔒",title:"Unlock group"},muteRule:{label:"🔊",title:"Mute rule"},muteGroup:{label:"🔊",title:"Mute group"},unmuteRule:{label:"🔇",title:"Unmute rule"},unmuteGroup:{label:"🔇",title:"Unmute group"},valueSourceSelector:{title:"Value source"}},un={"=":"=","!=":"!=","<":"<",">":">","<=":"<=",">=":">=",contains:"contains",beginsWith:"begins with",endsWith:"ends with",doesNotContain:"does not contain",doesNotBeginWith:"does not begin with",doesNotEndWith:"does not end with",null:"is null",notNull:"is not null",in:"in",notIn:"not in",between:"between",notBetween:"not between"},cn={and:"AND",or:"OR",xor:"XOR"},dn=[{name:"=",value:"=",label:"="},{name:"!=",value:"!=",label:"!="},{name:"<",value:"<",label:"<"},{name:">",value:">",label:">"},{name:"<=",value:"<=",label:"<="},{name:">=",value:">=",label:">="},{name:"contains",value:"contains",label:"contains"},{name:"beginsWith",value:"beginsWith",label:"begins with"},{name:"endsWith",value:"endsWith",label:"ends with"},{name:"doesNotContain",value:"doesNotContain",label:"does not contain"},{name:"doesNotBeginWith",value:"doesNotBeginWith",label:"does not begin with"},{name:"doesNotEndWith",value:"doesNotEndWith",label:"does not end with"},{name:"null",value:"null",label:"is null"},{name:"notNull",value:"notNull",label:"is not null"},{name:"in",value:"in",label:"in"},{name:"notIn",value:"notIn",label:"not in"},{name:"between",value:"between",label:"between"},{name:"notBetween",value:"notBetween",label:"not between"}],fn=[{name:"and",value:"and",label:"AND"},{name:"or",value:"or",label:"OR"}],pn=[{name:"all",value:"all",label:"all"},{name:"some",value:"some",label:"some"},{name:"none",value:"none",label:"none"},{name:"atLeast",value:"atLeast",label:"at least"},{name:"atMost",value:"atMost",label:"at most"},{name:"exactly",value:"exactly",label:"exactly"}],hn={queryBuilder:"queryBuilder",ruleGroup:"ruleGroup",header:"ruleGroup-header",body:"ruleGroup-body",combinators:"ruleGroup-combinators",addRule:"ruleGroup-addRule",addGroup:"ruleGroup-addGroup",cloneRule:"rule-cloneRule",cloneGroup:"ruleGroup-cloneGroup",removeGroup:"ruleGroup-remove",notToggle:"ruleGroup-notToggle",rule:"rule",fields:"rule-fields",matchMode:"rule-matchMode",matchThreshold:"rule-matchThreshold",operators:"rule-operators",value:"rule-value",removeRule:"rule-remove",betweenRules:"betweenRules",valid:"queryBuilder-valid",invalid:"queryBuilder-invalid",shiftActions:"shiftActions",undoRedoActions:"undoRedoActions",undoAction:"undoRedoActions-undo",redoAction:"undoRedoActions-redo",dndDragging:"dndDragging",dndOver:"dndOver",dndCopy:"dndCopy",dndGroup:"dndGroup",dndDropNotAllowed:"dndDropNotAllowed",dndPreviewPosition:"dndPreviewPosition",dndHidden:"dndHidden",dragHandle:"queryBuilder-dragHandle",disabled:"queryBuilder-disabled",muted:"queryBuilder-muted",lockRule:"rule-lock",lockGroup:"ruleGroup-lock",muteRule:"rule-mute",muteGroup:"ruleGroup-mute",valueSource:"rule-valueSource",valueListItem:"rule-value-list-item",branches:"queryBuilder-branches",justified:"queryBuilder-justified",responsive:"queryBuilder-responsive",hasSubQuery:"rule-hasSubQuery",loading:"queryBuilder-loading",valueDateTimeRelative:"rule-value-dateTimeRelative"},mn="empty",gn="invalid combinator",vn="invalid independent combinators",bn="rule",yn="rule-group",wn="inline-combinator",Sn="add-group",kn="remove-group",En="clone-group",On="clone-rule",Nn="add-rule",Cn="remove-rule",Dn="combinators",An="fields",Tn="operators",$n="value-editor",Mn="not-toggle",Rn="shift-actions",xn="undo-redo-actions",In="drag-handle",Pn="lock-rule",_n="lock-group",Ln="mute-rule",Gn="mute-group",Fn="value-source-selector",zn="match-mode-editor",jn="action aborted: parent path disabled",qn="action aborted: path is disabled",Bn="onAddRule callback returned false",Vn="onAddGroup callback returned false",Hn="onGroupRule callback returned false",Un="onGroupGroup callback returned false",Wn="onMoveRule callback returned false",Qn="onMoveGroup callback returned false",Kn="onRemove callback returned false",Xn="rule or group added",Yn="rule or group removed",Jn="rule or group updated",Zn="rule or group moved",er="rule or group grouped with another",tr=[],nr={addRuleToNewGroups:!1,autoSelectField:!0,autoSelectOperator:!0,autoSelectValue:!1,debugMode:!1,enableDragAndDrop:!1,enableMountQueryChange:!0,listsAsArrays:!1,preserveQueryStateOnUnmount:!1,resetOnFieldChange:!0,resetOnOperatorChange:!1,showCloneButtons:!1,showCombinatorsBetweenRules:!1,showLockButtons:!1,showMuteButtons:!1,showNotToggle:!1,showShiftActions:!1,showUndoRedo:!1,suppressStandardClassnames:!1},rr=new Set(["target-not-found","parent-not-found","parent-not-a-group","destination-not-found","root-not-allowed","not-a-combinator-slot","target-disabled","parent-disabled","max-levels-exceeded"]),or=(e,t=",")=>"string"==typeof e?e.split(`\\${t}`).map(e=>e.split(t)).reduce((e,n,r)=>0===r?n:[...e.slice(0,-1),`${e.at(-1)}${t}${n[0]}`,...n.slice(1)],[]):[],ar=(e,t=",")=>e.map(e=>`${e??""}`.replaceAll(t[0],`\\${t[0]}`)).join(t),ir=e=>"string"==typeof e?e.trim():e,lr=(e,{retainEmptyStrings:t}={})=>Array.isArray(e)?e.map(ir):"string"==typeof e?or(e,",").filter(t?()=>!0:e=>!/^\s*$/.test(e)).map(e=>e.trim()):"number"==typeof e?[e]:[];function sr(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t"string"==typeof e?e.toLowerCase():e,dr=new RegExp(Me.source.replace(/^\^/,String.raw`^\s*`).replace(/\$$/,String.raw`\s*$`)),fr=e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype,pr=e=>null==e||""===e,hr=e=>fr(e)&&Array.isArray(e.rules),mr=e=>hr(e)&&"string"==typeof e.combinator,gr=e=>hr(e)&&void 0===e.combinator,vr="~structural",br=(e,t)=>{const n=new Set([...Object.keys(e),...Object.keys(t)]);n.delete("rules");const r=[];for(const o of n)Object.is(e[o],t[o])||r.push(o);return r.toSorted()},yr=(e,t,n,r)=>{if(e===t)return"";if("string"==typeof e||"string"==typeof t)return typeof e==typeof t?`${n}:combinator[${r}]`:vr;const o=hr(e),a=hr(t);if(o!==a)return vr;if(!o||!a){const n=br(e,t);return 0===n.length?"":`${t.id??""}:${n.join(",")}`}if(e.rules.length!==t.rules.length)return vr;const i=br(e,t);let l=-1;for(const[n,r]of e.rules.entries())if(r!==t.rules[n]){if(-1!==l)return vr;l=n}return-1===l?0===i.length?"":`${t.id??""}:${i.join(",")}`:i.length>0?vr:yr(e.rules[l],t.rules[l],t.id??"",l)},wr=(e,t)=>yr(e,t,"",-1),Sr=["or","xor","and"],kr=(e,t)=>cr(e)===t,Er=(e,t=0)=>{const n=Sr[t];if(!e.rules.includes(n))return t{if(mr(e))return e;const t=Er(e),n=[];let r="and";for(const[e,o]of t.rules.entries())"string"==typeof o?1===e&&(r=o):n.push(hr(o)?Or(o):o);return{...t,combinator:r,rules:n}},Nr=e=>{if(gr(e))return e;const{combinator:t,...n}=e,r=[],{length:o}=e.rules;for(let n=0;ne.isOver,standardOnly:!0},{key:"dndCopy",when:e=>e.isOver&&"copy"===e.dropEffect},{key:"dndDropNotAllowed",when:e=>e.dropNotAllowed}]},shiftActions:["shiftActions"],undoRedoActions:["undoRedoActions"],undoAction:["actionElement","undoAction"],redoAction:["actionElement","redoAction"],dragHandle:["dragHandle"],combinators:["valueSelector","combinators"],notToggle:["notToggle"],addRule:["actionElement","addRule"],addGroup:["actionElement","addGroup"],cloneGroup:["actionElement","cloneGroup"],lockGroup:["actionElement","lockGroup"],muteGroup:["actionElement","muteGroup"],removeGroup:["actionElement","removeGroup"],body:["body"]},Ar=[{key:"disabled",when:e=>e.disabled},{key:"muted",when:e=>e.muted},{key:"dndDragging",when:e=>e.isDragging},{key:"dndOver",when:e=>e.isOver},{key:"dndCopy",when:e=>e.isOver&&"copy"===e.dropEffect},{key:"dndGroup",when:e=>e.isOver&&e.groupItems},{key:"dndDropNotAllowed",when:e=>e.dropNotAllowed},{key:"hasSubQuery",when:e=>e.hasSubQuery}],Tr=[{key:"disabled",when:e=>e.disabled},{key:"muted",when:e=>e.muted},{key:"dndDragging",when:e=>e.isDragging},{key:"dndGroup",when:e=>e.isOver&&e.groupItems}],$r=[{key:"disabled",when:e=>e.disabled},{key:"valid",when:e=>"boolean"==typeof e.validationResult&&e.validationResult},{key:"invalid",when:e=>"boolean"==typeof e.validationResult&&!e.validationResult}],Mr=(e,t,{classNames:n,suppressStandardClassnames:r})=>{const o=e.map(e=>[e,!!e.when(t)]);return[...o.filter(([e])=>!e.standardOnly).map(([e,t])=>t&&n?.[e.key]),r||Object.fromEntries(o.map(([e,t])=>[hn[e.key],t]))]},Rr=(e,t,n,r)=>{const{sources:o,conditions:a}=Array.isArray(t)?{sources:t}:t;return ur(r.suppressStandardClassnames||hn[e],...o.map(e=>r.classNames?.[e]),...a?Mr(a,n,r):[])},xr=(e,t,n)=>{const r={};for(const[o,a]of Object.entries(e))r[o]=Rr(o,a,t,n);return r},Ir=(e,t,n)=>{const{classNames:r,suppressStandardClassnames:o,leadingClassNames:a=[],validationClassName:i}=n;return ur(...a,o||hn[e],r?.[e],...Mr(t,n,n),i)},Pr=e=>{const t={},n=e=>{ +var n=s();var r="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=n.useSyncExternalStore,a=n.useRef,i=n.useEffect,l=n.useMemo,u=n.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,t,n,s,c){var d=a(null);if(null===d.current){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!i){if(i=!0,o=e,e=s(e),void 0!==c&&f.hasValue){var t=f.value;if(c(t,e))return a=t}return a=e}if(t=a,r(o,e))return t;var n=s(e);return void 0!==c&&c(t,n)?(o=e,t):(o=e,a=n)}var o,a,i=!1,l=void 0===n?null:n;return[function(){return e(t())},null===l?void 0:function(){return e(l())}]},[t,n,s,c]);var p=o(e,d[0],d[1]);return i(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}}),p=n.cw(function(e,t){e.exports=f()}),h={};n.r(h),n.d(h,{DndContext:()=>uc,DndProvider:()=>md,DragPreviewImage:()=>vd,useDrag:()=>_d,useDragDropManager:()=>$d,useDragLayer:()=>Ld,useDrop:()=>Bd});var m={};n.r(m),n.d(m,{FILE:()=>Qd,HTML:()=>Yd,TEXT:()=>Xd,URL:()=>Kd});var g={};n.r(g),n.d(g,{FILE:()=>Qd,HTML:()=>Yd,TEXT:()=>Xd,URL:()=>Kd});var v={};n.r(v),n.d(v,{HTML5Backend:()=>hf,NativeTypes:()=>m,getEmptyImage:()=>pf});var b={};n.r(b),n.d(b,{ListenerType:()=>mf,TouchBackend:()=>Nf,TouchBackendImpl:()=>Of});class y{constructor(e,t,n){this.eventTarget=e,this.eventName=t,this.eventOptions=n,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(e){this.unorderedBindings.add(e)}bindingDisconnected(e){this.unorderedBindings.delete(e)}handleEvent(e){const t=function(e){if("immediatePropagationStopped"in e)return e;{const{stopImmediatePropagation:t}=e;return Object.assign(e,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,t.call(this)}})}}(e);for(const e of this.bindings){if(t.immediatePropagationStopped)break;e.handleEvent(t)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort((e,t)=>{const n=e.index,r=t.index;return nr?1:0})}}class w{constructor(e){this.application=e,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach(e=>e.connect()))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach(e=>e.disconnect()))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce((e,t)=>e.concat(Array.from(t.values())),[])}bindingConnected(e){this.fetchEventListenerForBinding(e).bindingConnected(e)}bindingDisconnected(e,t=!1){this.fetchEventListenerForBinding(e).bindingDisconnected(e),t&&this.clearEventListenersForBinding(e)}handleError(e,t,n={}){this.application.handleError(e,`Error ${t}`,n)}clearEventListenersForBinding(e){const t=this.fetchEventListenerForBinding(e);t.hasBindings()||(t.disconnect(),this.removeMappedEventListenerFor(e))}removeMappedEventListenerFor(e){const{eventTarget:t,eventName:n,eventOptions:r}=e,o=this.fetchEventListenerMapForEventTarget(t),a=this.cacheKey(n,r);o.delete(a),0==o.size&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){const{eventTarget:t,eventName:n,eventOptions:r}=e;return this.fetchEventListener(t,n,r)}fetchEventListener(e,t,n){const r=this.fetchEventListenerMapForEventTarget(e),o=this.cacheKey(t,n);let a=r.get(o);return a||(a=this.createEventListener(e,t,n),r.set(o,a)),a}createEventListener(e,t,n){const r=new y(e,t,n);return this.started&&r.connect(),r}fetchEventListenerMapForEventTarget(e){let t=this.eventListenerMaps.get(e);return t||(t=new Map,this.eventListenerMaps.set(e,t)),t}cacheKey(e,t){const n=[e];return Object.keys(t).sort().forEach(e=>{n.push(`${t[e]?"":"!"}${e}`)}),n.join(":")}}const S={stop:({event:e,value:t})=>(t&&e.stopPropagation(),!0),prevent:({event:e,value:t})=>(t&&e.preventDefault(),!0),self:({event:e,value:t,element:n})=>!t||n===e.target},k=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function E(e){return"window"==e?window:"document"==e?document:void 0}function O(e){return e.replace(/(?:[_-])([a-z0-9])/g,(e,t)=>t.toUpperCase())}function N(e){return O(e.replace(/--/g,"-").replace(/__/g,"_"))}function C(e){return e.charAt(0).toUpperCase()+e.slice(1)}function D(e){return e.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}function A(e){return null!=e}function T(e,t){return Object.prototype.hasOwnProperty.call(e,t)}const $=["meta","ctrl","alt","shift"];class M{constructor(e,t,n,r){this.element=e,this.index=t,this.eventTarget=n.eventTarget||e,this.eventName=n.eventName||function(e){const t=e.tagName.toLowerCase();if(t in R)return R[t](e)}(e)||x("missing event name"),this.eventOptions=n.eventOptions||{},this.identifier=n.identifier||x("missing identifier"),this.methodName=n.methodName||x("missing method name"),this.keyFilter=n.keyFilter||"",this.schema=r}static forToken(e,t){return new this(e.element,e.index,function(e){const t=e.trim().match(k)||[];let n=t[2],r=t[3];return r&&!["keydown","keyup","keypress"].includes(n)&&(n+=`.${r}`,r=""),{eventTarget:E(t[4]),eventName:n,eventOptions:t[7]?(o=t[7],o.split(":").reduce((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)}),{})):{},identifier:t[5],methodName:t[6],keyFilter:t[1]||r};var o}(e.content),t)}toString(){const e=this.keyFilter?`.${this.keyFilter}`:"",t=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${e}${t}->${this.identifier}#${this.methodName}`}shouldIgnoreKeyboardEvent(e){if(!this.keyFilter)return!1;const t=this.keyFilter.split("+");if(this.keyFilterDissatisfied(e,t))return!0;const n=t.filter(e=>!$.includes(e))[0];return!!n&&(T(this.keyMappings,n)||x(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[n].toLowerCase()!==e.key.toLowerCase())}shouldIgnoreMouseEvent(e){if(!this.keyFilter)return!1;const t=[this.keyFilter];return!!this.keyFilterDissatisfied(e,t)}get params(){const e={},t=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(const{name:n,value:r}of Array.from(this.element.attributes)){const o=n.match(t),a=o&&o[1];a&&(e[O(a)]=I(r))}return e}get eventTargetName(){return(e=this.eventTarget)==window?"window":e==document?"document":void 0;var e}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(e,t){const[n,r,o,a]=$.map(e=>t.includes(e));return e.metaKey!==n||e.ctrlKey!==r||e.altKey!==o||e.shiftKey!==a}}const R={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:e=>"submit"==e.getAttribute("type")?"click":"input",select:()=>"change",textarea:()=>"input"};function x(e){throw new Error(e)}function I(e){try{return JSON.parse(e)}catch(t){return e}}class P{constructor(e,t){this.context=e,this.action=t}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(e){const t=this.prepareActionEvent(e);this.willBeInvokedByEvent(e)&&this.applyEventModifiers(t)&&this.invokeWithEvent(t)}get eventName(){return this.action.eventName}get method(){const e=this.controller[this.methodName];if("function"==typeof e)return e;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(e){const{element:t}=this.action,{actionDescriptorFilters:n}=this.context.application,{controller:r}=this.context;let o=!0;for(const[a,i]of Object.entries(this.eventOptions))if(a in n){const l=n[a];o=o&&l({name:a,value:i,event:e,element:t,controller:r})}return o}prepareActionEvent(e){return Object.assign(e,{params:this.action.params})}invokeWithEvent(e){const{target:t,currentTarget:n}=e;try{this.method.call(this.controller,e),this.context.logDebugActivity(this.methodName,{event:e,target:t,currentTarget:n,action:this.methodName})}catch(t){const{identifier:n,controller:r,element:o,index:a}=this,i={identifier:n,controller:r,element:o,index:a,event:e};this.context.handleError(t,`invoking action "${this.action}"`,i)}}willBeInvokedByEvent(e){const t=e.target;return!(e instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(e))&&(!(e instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(e))&&(this.element===t||(t instanceof Element&&this.element.contains(t)?this.scope.containsElement(t):this.scope.containsElement(this.action.element))))}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class _{constructor(e,t){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=e,this.started=!1,this.delegate=t,this.elements=new Set,this.mutationObserver=new MutationObserver(e=>this.processMutations(e))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(e){this.started&&(this.mutationObserver.disconnect(),this.started=!1),e(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){const e=new Set(this.matchElementsInTree());for(const t of Array.from(this.elements))e.has(t)||this.removeElement(t);for(const t of Array.from(e))this.addElement(t)}}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){"attributes"==e.type?this.processAttributeChange(e.target,e.attributeName):"childList"==e.type&&(this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes))}processAttributeChange(e,t){this.elements.has(e)?this.delegate.elementAttributeChanged&&this.matchElement(e)?this.delegate.elementAttributeChanged(e,t):this.removeElement(e):this.matchElement(e)&&this.addElement(e)}processRemovedNodes(e){for(const t of Array.from(e)){const e=this.elementFromNode(t);e&&this.processTree(e,this.removeElement)}}processAddedNodes(e){for(const t of Array.from(e)){const e=this.elementFromNode(t);e&&this.elementIsActive(e)&&this.processTree(e,this.addElement)}}matchElement(e){return this.delegate.matchElement(e)}matchElementsInTree(e=this.element){return this.delegate.matchElementsInTree(e)}processTree(e,t){for(const n of this.matchElementsInTree(e))t.call(this,n)}elementFromNode(e){if(e.nodeType==Node.ELEMENT_NODE)return e}elementIsActive(e){return e.isConnected==this.element.isConnected&&this.element.contains(e)}addElement(e){this.elements.has(e)||this.elementIsActive(e)&&(this.elements.add(e),this.delegate.elementMatched&&this.delegate.elementMatched(e))}removeElement(e){this.elements.has(e)&&(this.elements.delete(e),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(e))}}class L{constructor(e,t,n){this.attributeName=t,this.delegate=n,this.elementObserver=new _(e,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(e){return e.hasAttribute(this.attributeName)}matchElementsInTree(e){const t=this.matchElement(e)?[e]:[],n=Array.from(e.querySelectorAll(this.selector));return t.concat(n)}elementMatched(e){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(e,this.attributeName)}elementUnmatched(e){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(e,this.attributeName)}elementAttributeChanged(e,t){this.delegate.elementAttributeValueChanged&&this.attributeName==t&&this.delegate.elementAttributeValueChanged(e,t)}}function G(e,t,n){z(e,t).add(n)}function F(e,t,n){z(e,t).delete(n),function(e,t){const n=e.get(t);null!=n&&0==n.size&&e.delete(t)}(e,t)}function z(e,t){let n=e.get(t);return n||(n=new Set,e.set(t,n)),n}class j{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce((e,t)=>e.concat(Array.from(t)),[])}get size(){return Array.from(this.valuesByKey.values()).reduce((e,t)=>e+t.size,0)}add(e,t){G(this.valuesByKey,e,t)}delete(e,t){F(this.valuesByKey,e,t)}has(e,t){const n=this.valuesByKey.get(e);return null!=n&&n.has(t)}hasKey(e){return this.valuesByKey.has(e)}hasValue(e){return Array.from(this.valuesByKey.values()).some(t=>t.has(e))}getValuesForKey(e){const t=this.valuesByKey.get(e);return t?Array.from(t):[]}getKeysForValue(e){return Array.from(this.valuesByKey).filter(([t,n])=>n.has(e)).map(([e,t])=>e)}}class V{constructor(e,t,n,r){this._selector=t,this.details=r,this.elementObserver=new _(e,this),this.delegate=n,this.matchesByElement=new j}get started(){return this.elementObserver.started}get selector(){return this._selector}set selector(e){this._selector=e,this.refresh()}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(e){const{selector:t}=this;if(t){const n=e.matches(t);return this.delegate.selectorMatchElement?n&&this.delegate.selectorMatchElement(e,this.details):n}return!1}matchElementsInTree(e){const{selector:t}=this;if(t){const n=this.matchElement(e)?[e]:[],r=Array.from(e.querySelectorAll(t)).filter(e=>this.matchElement(e));return n.concat(r)}return[]}elementMatched(e){const{selector:t}=this;t&&this.selectorMatched(e,t)}elementUnmatched(e){const t=this.matchesByElement.getKeysForValue(e);for(const n of t)this.selectorUnmatched(e,n)}elementAttributeChanged(e,t){const{selector:n}=this;if(n){const t=this.matchElement(e),r=this.matchesByElement.has(n,e);t&&!r?this.selectorMatched(e,n):!t&&r&&this.selectorUnmatched(e,n)}}selectorMatched(e,t){this.delegate.selectorMatched(e,t,this.details),this.matchesByElement.add(t,e)}selectorUnmatched(e,t){this.delegate.selectorUnmatched(e,t,this.details),this.matchesByElement.delete(t,e)}}class q{constructor(e,t){this.element=e,this.delegate=t,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver(e=>this.processMutations(e))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(const e of this.knownAttributeNames)this.refreshAttribute(e,null)}processMutations(e){if(this.started)for(const t of e)this.processMutation(t)}processMutation(e){const t=e.attributeName;t&&this.refreshAttribute(t,e.oldValue)}refreshAttribute(e,t){const n=this.delegate.getStringMapKeyForAttribute(e);if(null!=n){this.stringMap.has(e)||this.stringMapKeyAdded(n,e);const r=this.element.getAttribute(e);if(this.stringMap.get(e)!=r&&this.stringMapValueChanged(r,n,t),null==r){const t=this.stringMap.get(e);this.stringMap.delete(e),t&&this.stringMapKeyRemoved(n,e,t)}else this.stringMap.set(e,r)}}stringMapKeyAdded(e,t){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,n){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(e,t,n)}stringMapKeyRemoved(e,t,n){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(e,t,n)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map(e=>e.name)}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}class B{constructor(e,t,n){this.attributeObserver=new L(e,t,this),this.delegate=n,this.tokensByElement=new j}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(e){this.attributeObserver.pause(e)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(e){this.tokensMatched(this.readTokensForElement(e))}elementAttributeValueChanged(e){const[t,n]=this.refreshTokensForElement(e);this.tokensUnmatched(t),this.tokensMatched(n)}elementUnmatchedAttribute(e){this.tokensUnmatched(this.tokensByElement.getValuesForKey(e))}tokensMatched(e){e.forEach(e=>this.tokenMatched(e))}tokensUnmatched(e){e.forEach(e=>this.tokenUnmatched(e))}tokenMatched(e){this.delegate.tokenMatched(e),this.tokensByElement.add(e.element,e)}tokenUnmatched(e){this.delegate.tokenUnmatched(e),this.tokensByElement.delete(e.element,e)}refreshTokensForElement(e){const t=this.tokensByElement.getValuesForKey(e),n=this.readTokensForElement(e),r=function(e,t){const n=Math.max(e.length,t.length);return Array.from({length:n},(n,r)=>[e[r],t[r]])}(t,n).findIndex(([e,t])=>{return r=t,!((n=e)&&r&&n.index==r.index&&n.content==r.content);var n,r});return-1==r?[[],[]]:[t.slice(r),n.slice(r)]}readTokensForElement(e){const t=this.attributeName;return function(e,t,n){return e.trim().split(/\s+/).filter(e=>e.length).map((e,r)=>({element:t,attributeName:n,content:e,index:r}))}(e.getAttribute(t)||"",e,t)}}class H{constructor(e,t,n){this.tokenListObserver=new B(e,t,this),this.delegate=n,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(e){const{element:t}=e,{value:n}=this.fetchParseResultForToken(e);n&&(this.fetchValuesByTokenForElement(t).set(e,n),this.delegate.elementMatchedValue(t,n))}tokenUnmatched(e){const{element:t}=e,{value:n}=this.fetchParseResultForToken(e);n&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,n))}fetchParseResultForToken(e){let t=this.parseResultsByToken.get(e);return t||(t=this.parseToken(e),this.parseResultsByToken.set(e,t)),t}fetchValuesByTokenForElement(e){let t=this.valuesByTokenByElement.get(e);return t||(t=new Map,this.valuesByTokenByElement.set(e,t)),t}parseToken(e){try{return{value:this.delegate.parseValueForToken(e)}}catch(e){return{error:e}}}}class U{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new H(this.element,this.actionAttribute,this),this.valueListObserver.start())}stop(){this.valueListObserver&&(this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions())}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(e){const t=new P(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)}disconnectAction(e){const t=this.bindingsByAction.get(e);t&&(this.bindingsByAction.delete(e),this.delegate.bindingDisconnected(t))}disconnectAllActions(){this.bindings.forEach(e=>this.delegate.bindingDisconnected(e,!0)),this.bindingsByAction.clear()}parseValueForToken(e){const t=M.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}}class W{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new q(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(e){if(e in this.valueDescriptorMap)return this.valueDescriptorMap[e].name}stringMapKeyAdded(e,t){const n=this.valueDescriptorMap[t];this.hasValue(e)||this.invokeChangedCallback(e,n.writer(this.receiver[e]),n.writer(n.defaultValue))}stringMapValueChanged(e,t,n){const r=this.valueDescriptorNameMap[t];null!==e&&(null===n&&(n=r.writer(r.defaultValue)),this.invokeChangedCallback(t,e,n))}stringMapKeyRemoved(e,t,n){const r=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,r.writer(this.receiver[e]),n):this.invokeChangedCallback(e,r.writer(r.defaultValue),n)}invokeChangedCallbacksForDefaultValues(){for(const{key:e,name:t,defaultValue:n,writer:r}of this.valueDescriptors)null==n||this.controller.data.has(e)||this.invokeChangedCallback(t,r(n),void 0)}invokeChangedCallback(e,t,n){const r=`${e}Changed`,o=this.receiver[r];if("function"==typeof o){const r=this.valueDescriptorNameMap[e];try{const e=r.reader(t);let a=n;n&&(a=r.reader(n)),o.call(this.receiver,e,a)}catch(e){throw e instanceof TypeError&&(e.message=`Stimulus Value "${this.context.identifier}.${r.name}" - ${e.message}`),e}}}get valueDescriptors(){const{valueDescriptorMap:e}=this;return Object.keys(e).map(t=>e[t])}get valueDescriptorNameMap(){const e={};return Object.keys(this.valueDescriptorMap).forEach(t=>{const n=this.valueDescriptorMap[t];e[n.name]=n}),e}hasValue(e){const t=`has${C(this.valueDescriptorNameMap[e].name)}`;return this.receiver[t]}}class Q{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new j}start(){this.tokenListObserver||(this.tokenListObserver=new B(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:e,content:t}){this.scope.containsElement(e)&&this.connectTarget(e,t)}tokenUnmatched({element:e,content:t}){this.disconnectTarget(e,t)}connectTarget(e,t){var n;this.targetsByName.has(t,e)||(this.targetsByName.add(t,e),null===(n=this.tokenListObserver)||void 0===n||n.pause(()=>this.delegate.targetConnected(e,t)))}disconnectTarget(e,t){var n;this.targetsByName.has(t,e)&&(this.targetsByName.delete(t,e),null===(n=this.tokenListObserver)||void 0===n||n.pause(()=>this.delegate.targetDisconnected(e,t)))}disconnectAllTargets(){for(const e of this.targetsByName.keys)for(const t of this.targetsByName.getValuesForKey(e))this.disconnectTarget(t,e)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}function K(e,t){const n=Y(e);return Array.from(n.reduce((e,n)=>(function(e,t){const n=e[t];return Array.isArray(n)?n:[]}(n,t).forEach(t=>e.add(t)),e),new Set))}function X(e,t){return Y(e).reduce((e,n)=>(e.push(...function(e,t){const n=e[t];return n?Object.keys(n).map(e=>[e,n[e]]):[]}(n,t)),e),[])}function Y(e){const t=[];for(;e;)t.push(e),e=Object.getPrototypeOf(e);return t.reverse()}class J{constructor(e,t){this.started=!1,this.context=e,this.delegate=t,this.outletsByName=new j,this.outletElementsByName=new j,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){this.started||(this.outletDefinitions.forEach(e=>{this.setupSelectorObserverForOutlet(e),this.setupAttributeObserverForOutlet(e)}),this.started=!0,this.dependentContexts.forEach(e=>e.refresh()))}refresh(){this.selectorObserverMap.forEach(e=>e.refresh()),this.attributeObserverMap.forEach(e=>e.refresh())}stop(){this.started&&(this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers())}stopSelectorObservers(){this.selectorObserverMap.size>0&&(this.selectorObserverMap.forEach(e=>e.stop()),this.selectorObserverMap.clear())}stopAttributeObservers(){this.attributeObserverMap.size>0&&(this.attributeObserverMap.forEach(e=>e.stop()),this.attributeObserverMap.clear())}selectorMatched(e,t,{outletName:n}){const r=this.getOutlet(e,n);r&&this.connectOutlet(r,e,n)}selectorUnmatched(e,t,{outletName:n}){const r=this.getOutletFromMap(e,n);r&&this.disconnectOutlet(r,e,n)}selectorMatchElement(e,{outletName:t}){const n=this.selector(t),r=this.hasOutlet(e,t),o=e.matches(`[${this.schema.controllerAttribute}~=${t}]`);return!!n&&(r&&o&&e.matches(n))}elementMatchedAttribute(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}elementAttributeValueChanged(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}elementUnmatchedAttribute(e,t){const n=this.getOutletNameFromOutletAttributeName(t);n&&this.updateSelectorObserverForOutlet(n)}connectOutlet(e,t,n){var r;this.outletElementsByName.has(n,t)||(this.outletsByName.add(n,e),this.outletElementsByName.add(n,t),null===(r=this.selectorObserverMap.get(n))||void 0===r||r.pause(()=>this.delegate.outletConnected(e,t,n)))}disconnectOutlet(e,t,n){var r;this.outletElementsByName.has(n,t)&&(this.outletsByName.delete(n,e),this.outletElementsByName.delete(n,t),null===(r=this.selectorObserverMap.get(n))||void 0===r||r.pause(()=>this.delegate.outletDisconnected(e,t,n)))}disconnectAllOutlets(){for(const e of this.outletElementsByName.keys)for(const t of this.outletElementsByName.getValuesForKey(e))for(const n of this.outletsByName.getValuesForKey(e))this.disconnectOutlet(n,t,e)}updateSelectorObserverForOutlet(e){const t=this.selectorObserverMap.get(e);t&&(t.selector=this.selector(e))}setupSelectorObserverForOutlet(e){const t=this.selector(e),n=new V(document.body,t,this,{outletName:e});this.selectorObserverMap.set(e,n),n.start()}setupAttributeObserverForOutlet(e){const t=this.attributeNameForOutletName(e),n=new L(this.scope.element,t,this);this.attributeObserverMap.set(e,n),n.start()}selector(e){return this.scope.outlets.getSelectorForOutletName(e)}attributeNameForOutletName(e){return this.scope.schema.outletAttributeForScope(this.identifier,e)}getOutletNameFromOutletAttributeName(e){return this.outletDefinitions.find(t=>this.attributeNameForOutletName(t)===e)}get outletDependencies(){const e=new j;return this.router.modules.forEach(t=>{K(t.definition.controllerConstructor,"outlets").forEach(n=>e.add(n,t.identifier))}),e}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){const e=this.dependentControllerIdentifiers;return this.router.contexts.filter(t=>e.includes(t.identifier))}hasOutlet(e,t){return!!this.getOutlet(e,t)||!!this.getOutletFromMap(e,t)}getOutlet(e,t){return this.application.getControllerForElementAndIdentifier(e,t)}getOutletFromMap(e,t){return this.outletsByName.getValuesForKey(t).find(t=>t.element===e)}get scope(){return this.context.scope}get schema(){return this.context.schema}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}}class Z{constructor(e,t){this.logDebugActivity=(e,t={})=>{const{identifier:n,controller:r,element:o}=this;t=Object.assign({identifier:n,controller:r,element:o},t),this.application.logDebugActivity(this.identifier,e,t)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new U(this,this.dispatcher),this.valueObserver=new W(this,this.controller),this.targetObserver=new Q(this,this),this.outletObserver=new J(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(e){this.handleError(e,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(e){this.handleError(e,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(e){this.handleError(e,"disconnecting controller")}this.outletObserver.stop(),this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(e,t,n={}){const{identifier:r,controller:o,element:a}=this;n=Object.assign({identifier:r,controller:o,element:a},n),this.application.handleError(e,`Error ${t}`,n)}targetConnected(e,t){this.invokeControllerMethod(`${t}TargetConnected`,e)}targetDisconnected(e,t){this.invokeControllerMethod(`${t}TargetDisconnected`,e)}outletConnected(e,t,n){this.invokeControllerMethod(`${N(n)}OutletConnected`,e,t)}outletDisconnected(e,t,n){this.invokeControllerMethod(`${N(n)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){const n=this.controller;"function"==typeof n[e]&&n[e](...t)}}function ee(e){return function(e,t){const n=ne(e),r=function(e,t){return te(t).reduce((n,r)=>{const o=function(e,t,n){const r=Object.getOwnPropertyDescriptor(e,n);if(!r||!("value"in r)){const e=Object.getOwnPropertyDescriptor(t,n).value;return r&&(e.get=r.get||e.get,e.set=r.set||e.set),e}}(e,t,r);return o&&Object.assign(n,{[r]:o}),n},{})}(e.prototype,t);return Object.defineProperties(n.prototype,r),n}(e,function(e){const t=K(e,"blessings");return t.reduce((t,n)=>{const r=n(e);for(const e in r){const n=t[e]||{};t[e]=Object.assign(n,r[e])}return t},{})}(e))}const te="function"==typeof Object.getOwnPropertySymbols?e=>[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)]:Object.getOwnPropertyNames,ne=(()=>{function e(e){function t(){return Reflect.construct(e,arguments,new.target)}return t.prototype=Object.create(e.prototype,{constructor:{value:t}}),Reflect.setPrototypeOf(t,e),t}try{return function(){const t=e(function(){this.a.call(this)});t.prototype.a=function(){},new t}(),e}catch(e){return e=>class extends e{}}})();class re{constructor(e,t){this.application=e,this.definition=function(e){return{identifier:e.identifier,controllerConstructor:ee(e.controllerConstructor)}}(t),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(e){const t=this.fetchContextForScope(e);this.connectedContexts.add(t),t.connect()}disconnectContextForScope(e){const t=this.contextsByScope.get(e);t&&(this.connectedContexts.delete(t),t.disconnect())}fetchContextForScope(e){let t=this.contextsByScope.get(e);return t||(t=new Z(this,e),this.contextsByScope.set(e,t)),t}}class oe{constructor(e){this.scope=e}has(e){return this.data.has(this.getDataKey(e))}get(e){return this.getAll(e)[0]}getAll(e){const t=this.data.get(this.getDataKey(e))||"";return t.match(/[^\s]+/g)||[]}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}}class ae{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(e){const t=this.getAttributeNameForKey(e);return this.element.getAttribute(t)}set(e,t){const n=this.getAttributeNameForKey(e);return this.element.setAttribute(n,t),this.get(e)}has(e){const t=this.getAttributeNameForKey(e);return this.element.hasAttribute(t)}delete(e){if(this.has(e)){const t=this.getAttributeNameForKey(e);return this.element.removeAttribute(t),!0}return!1}getAttributeNameForKey(e){return`data-${this.identifier}-${D(e)}`}}class ie{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,n){let r=this.warnedKeysByObject.get(e);r||(r=new Set,this.warnedKeysByObject.set(e,r)),r.has(t)||(r.add(t),this.logger.warn(n,e))}}function le(e,t){return`[${e}~="${t}"]`}class se{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return null!=this.find(e)}find(...e){return e.reduce((e,t)=>e||this.findTarget(t)||this.findLegacyTarget(t),void 0)}findAll(...e){return e.reduce((e,t)=>[...e,...this.findAllTargets(t),...this.findAllLegacyTargets(t)],[])}findTarget(e){const t=this.getSelectorForTargetName(e);return this.scope.findElement(t)}findAllTargets(e){const t=this.getSelectorForTargetName(e);return this.scope.findAllElements(t)}getSelectorForTargetName(e){return le(this.schema.targetAttributeForScope(this.identifier),e)}findLegacyTarget(e){const t=this.getLegacySelectorForTargetName(e);return this.deprecate(this.scope.findElement(t),e)}findAllLegacyTargets(e){const t=this.getLegacySelectorForTargetName(e);return this.scope.findAllElements(t).map(t=>this.deprecate(t,e))}getLegacySelectorForTargetName(e){const t=`${this.identifier}.${e}`;return le(this.schema.targetAttribute,t)}deprecate(e,t){if(e){const{identifier:n}=this,r=this.schema.targetAttribute,o=this.schema.targetAttributeForScope(n);this.guide.warn(e,`target:${t}`,`Please replace ${r}="${n}.${t}" with ${o}="${t}". The ${r} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}}class ue{constructor(e,t){this.scope=e,this.controllerElement=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return null!=this.find(e)}find(...e){return e.reduce((e,t)=>e||this.findOutlet(t),void 0)}findAll(...e){return e.reduce((e,t)=>[...e,...this.findAllOutlets(t)],[])}getSelectorForOutletName(e){const t=this.schema.outletAttributeForScope(this.identifier,e);return this.controllerElement.getAttribute(t)}findOutlet(e){const t=this.getSelectorForOutletName(e);if(t)return this.findElement(t,e)}findAllOutlets(e){const t=this.getSelectorForOutletName(e);return t?this.findAllElements(t,e):[]}findElement(e,t){return this.scope.queryElements(e).filter(n=>this.matchesElement(n,e,t))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter(n=>this.matchesElement(n,e,t))}matchesElement(e,t,n){const r=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&r.split(" ").includes(n)}}class ce{constructor(e,t,n,r){this.targets=new se(this),this.classes=new oe(this),this.data=new ae(this),this.containsElement=e=>e.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=n,this.guide=new ie(r),this.outlets=new ue(this.documentScope,t)}findElement(e){return this.element.matches(e)?this.element:this.queryElements(e).find(this.containsElement)}findAllElements(e){return[...this.element.matches(e)?[this.element]:[],...this.queryElements(e).filter(this.containsElement)]}queryElements(e){return Array.from(this.element.querySelectorAll(e))}get controllerSelector(){return le(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new ce(this.schema,document.documentElement,this.identifier,this.guide.logger)}}class de{constructor(e,t,n){this.element=e,this.schema=t,this.delegate=n,this.valueListObserver=new H(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(e){const{element:t,content:n}=e;return this.parseValueForElementAndIdentifier(t,n)}parseValueForElementAndIdentifier(e,t){const n=this.fetchScopesByIdentifierForElement(e);let r=n.get(t);return r||(r=this.delegate.createScopeForElementAndIdentifier(e,t),n.set(t,r)),r}elementMatchedValue(e,t){const n=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,n),1==n&&this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){const n=this.scopeReferenceCounts.get(t);n&&(this.scopeReferenceCounts.set(t,n-1),1==n&&this.delegate.scopeDisconnected(t))}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t}}class fe{constructor(e){this.application=e,this.scopeObserver=new de(this.element,this.schema,this),this.scopesByIdentifier=new j,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce((e,t)=>e.concat(t.contexts),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(e){this.unloadIdentifier(e.identifier);const t=new re(this.application,e);this.connectModule(t);const n=e.controllerConstructor.afterLoad;n&&n.call(e.controllerConstructor,e.identifier,this.application)}unloadIdentifier(e){const t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){const n=this.modulesByIdentifier.get(t);if(n)return n.contexts.find(t=>t.element==e)}proposeToConnectScopeForElementAndIdentifier(e,t){const n=this.scopeObserver.parseValueForElementAndIdentifier(e,t);n?this.scopeObserver.elementMatchedValue(n.element,n):console.error(`Couldn't find or create scope for identifier: "${t}" and element:`,e)}handleError(e,t,n){this.application.handleError(e,t,n)}createScopeForElementAndIdentifier(e,t){return new ce(this.schema,e,t,this.logger)}scopeConnected(e){this.scopesByIdentifier.add(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.connectContextForScope(e)}scopeDisconnected(e){this.scopesByIdentifier.delete(e.identifier,e);const t=this.modulesByIdentifier.get(e.identifier);t&&t.disconnectContextForScope(e)}connectModule(e){this.modulesByIdentifier.set(e.identifier,e);this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(t=>e.connectContextForScope(t))}disconnectModule(e){this.modulesByIdentifier.delete(e.identifier);this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(t=>e.disconnectContextForScope(t))}}const pe={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:e=>`data-${e}-target`,outletAttributeForScope:(e,t)=>`data-${e}-${t}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",page_up:"PageUp",page_down:"PageDown"},he("abcdefghijklmnopqrstuvwxyz".split("").map(e=>[e,e]))),he("0123456789".split("").map(e=>[e,e])))};function he(e){return e.reduce((e,[t,n])=>Object.assign(Object.assign({},e),{[t]:n}),{})}function me(e,t,n){return e.application.getControllerForElementAndIdentifier(t,n)}function ge(e,t,n){let r=me(e,t,n);return r||(e.application.router.proposeToConnectScopeForElementAndIdentifier(t,n),r=me(e,t,n),r||void 0)}function ve([e,t],n){return function(e){const{token:t,typeDefinition:n}=e,r=`${D(t)}-value`,o=function(e){const{controller:t,token:n,typeDefinition:r}=e,o={controller:t,token:n,typeObject:r},a=function(e){const{controller:t,token:n,typeObject:r}=e,o=A(r.type),a=A(r.default),i=o&&a,l=o&&!a,s=!o&&a,u=be(r.type),c=ye(e.typeObject.default);if(l)return u;if(s)return c;if(u!==c){throw new Error(`The specified default value for the Stimulus Value "${t?`${t}.${n}`:n}" must match the defined type "${u}". The provided default value of "${r.default}" is of type "${c}".`)}if(i)return u}(o),i=ye(r),l=be(r),s=a||i||l;if(s)return s;const u=t?`${t}.${r}`:n;throw new Error(`Unknown value type "${u}" for "${n}" value`)}(e);return{type:o,key:r,name:O(r),get defaultValue(){return function(e){const t=be(e);if(t)return we[t];const n=T(e,"default"),r=T(e,"type"),o=e;if(n)return o.default;if(r){const{type:e}=o,t=be(e);if(t)return we[t]}return e}(n)},get hasCustomDefaultValue(){return void 0!==ye(n)},reader:Se[o],writer:ke[o]||ke.default}}({controller:n,token:e,typeDefinition:t})}function be(e){switch(e){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function ye(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}return Array.isArray(e)?"array":"[object Object]"===Object.prototype.toString.call(e)?"object":void 0}const we={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},Se={array(e){const t=JSON.parse(e);if(!Array.isArray(t))throw new TypeError(`expected value of type "array" but instead got value "${e}" of type "${ye(t)}"`);return t},boolean:e=>!("0"==e||"false"==String(e).toLowerCase()),number:e=>Number(e.replace(/_/g,"")),object(e){const t=JSON.parse(e);if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError(`expected value of type "object" but instead got value "${e}" of type "${ye(t)}"`);return t},string:e=>e},ke={default:function(e){return`${e}`},array:Ee,object:Ee};function Ee(e){return JSON.stringify(e)}class Oe{constructor(e){this.context=e}static get shouldLoad(){return!0}static afterLoad(e,t){}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get outlets(){return this.scope.outlets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(e,{target:t=this.element,detail:n={},prefix:r=this.identifier,bubbles:o=!0,cancelable:a=!0}={}){const i=new CustomEvent(r?`${r}:${e}`:e,{detail:n,bubbles:o,cancelable:a});return t.dispatchEvent(i),i}}Oe.blessings=[function(e){return K(e,"classes").reduce((e,t)=>{return Object.assign(e,(n=t,{[`${n}Class`]:{get(){const{classes:e}=this;if(e.has(n))return e.get(n);{const t=e.getAttributeName(n);throw new Error(`Missing attribute "${t}"`)}}},[`${n}Classes`]:{get(){return this.classes.getAll(n)}},[`has${C(n)}Class`]:{get(){return this.classes.has(n)}}}));var n},{})},function(e){return K(e,"targets").reduce((e,t)=>{return Object.assign(e,(n=t,{[`${n}Target`]:{get(){const e=this.targets.find(n);if(e)return e;throw new Error(`Missing target element "${n}" for "${this.identifier}" controller`)}},[`${n}Targets`]:{get(){return this.targets.findAll(n)}},[`has${C(n)}Target`]:{get(){return this.targets.has(n)}}}));var n},{})},function(e){const t=X(e,"values"),n={valueDescriptorMap:{get(){return t.reduce((e,t)=>{const n=ve(t,this.identifier),r=this.data.getAttributeNameForKey(n.key);return Object.assign(e,{[r]:n})},{})}}};return t.reduce((e,t)=>Object.assign(e,function(e,t){const n=ve(e,t),{key:r,name:o,reader:a,writer:i}=n;return{[o]:{get(){const e=this.data.get(r);return null!==e?a(e):n.defaultValue},set(e){void 0===e?this.data.delete(r):this.data.set(r,i(e))}},[`has${C(o)}`]:{get(){return this.data.has(r)||n.hasCustomDefaultValue}}}}(t)),n)},function(e){return K(e,"outlets").reduce((e,t)=>Object.assign(e,function(e){const t=N(e);return{[`${t}Outlet`]:{get(){const t=this.outlets.find(e),n=this.outlets.getSelectorForOutletName(e);if(t){const n=ge(this,t,e);if(n)return n;throw new Error(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`)}throw new Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${n}".`)}},[`${t}Outlets`]:{get(){const t=this.outlets.findAll(e);return t.length>0?t.map(t=>{const n=ge(this,t,e);if(n)return n;console.warn(`The provided outlet element is missing an outlet controller "${e}" instance for host controller "${this.identifier}"`,t)}).filter(e=>e):[]}},[`${t}OutletElement`]:{get(){const t=this.outlets.find(e),n=this.outlets.getSelectorForOutletName(e);if(t)return t;throw new Error(`Missing outlet element "${e}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${n}".`)}},[`${t}OutletElements`]:{get(){return this.outlets.findAll(e)}},[`has${C(t)}Outlet`]:{get(){return this.outlets.has(e)}}}}(t)),{})}],Oe.targets=[],Oe.outlets=[],Oe.values={};n(236);s(),o();const Ne=()=>{},Ce=(0,l().createContext)({dragPreviewState:null,updatePreviewPosition:Ne,commitDrag:Ne,cancelDrag:Ne}),De=[48,1632,1776,1984,2406,2534,2662,2790,2918,3046,3174,3302,3430,3558,3664,3792,3872,4160,4240,6112,6160,6470,6608,6784,6800,6992,7088,7232,7248,42528,43216,43264,43472,43504,43600,44016,65296,66720,68912,68928,69734,69872,69942,70096,70384,70736,70864,71248,71360,71376,71386,71472,71904,72016,72688,72784,73040,73120,73184,73552,90416,92768,92864,93008,93552,118e3,120782,120792,120802,120812,120822,123200,123632,124144,124401,125264,130032],Ae={"⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9"},Te=/[⁰¹²³⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅₆₇₈₉]/g,$e={"¼":"1/4","½":"1/2","¾":"3/4","⅐":"1/7","⅑":"1/9","⅒":"1/10","⅓":"1/3","⅔":"2/3","⅕":"1/5","⅖":"2/5","⅗":"3/5","⅘":"4/5","⅙":"1/6","⅚":"5/6","⅛":"1/8","⅜":"3/8","⅝":"5/8","⅞":"7/8","⅟":"1/"},Me=/^(?=[-+]?\s*\.\d|[-+]?\s*\d)([-+])?\s*((?:\d(?:[,_]\d|\d)*)*)(([eE][+-]?\d(?:[,_]\d|\d)*)?|\.\d(?:[,_]\d|\d)*([eE][+-]?\d(?:[,_]\d|\d)*)?|(\s+\d(?:[,_]\d|\d)*\s*)?\s*\/\s*\d(?:[,_]\d|\d)*)?$/,Re=/^(?=[-+]?\s*\.\d|[-+]?\s*\d)([-+])?\s*((?:\d(?:[,_]\d|\d)*)*)(([eE][+-]?\d(?:[,_]\d|\d)*)?|\.\d(?:[,_]\d|\d)*([eE][+-]?\d(?:[,_]\d|\d)*)?|(\s+\d(?:[,_]\d|\d)*\s*)?\s*\/\s*\d(?:[,_]\d|\d)*)?(\s*[^.\d/].*)?/,xe=/([¼½¾⅐⅑⅒⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞⅟])/g,Ie={MMM:3e3,MM:2e3,M:1e3,CM:900,DCCC:800,DCC:700,DC:600,D:500,CD:400,CCC:300,CC:200,C:100,XC:90,LXXX:80,LXX:70,LX:60,L:50,XL:40,XXX:30,XX:20,XII:12,XI:11,X:10,IX:9,VIII:8,VII:7,VI:6,V:5,IV:4,III:3,II:2,I:1},Pe={Ⅰ:"I",Ⅱ:"II",Ⅲ:"III",Ⅳ:"IV",Ⅴ:"V",Ⅵ:"VI",Ⅶ:"VII",Ⅷ:"VIII",Ⅸ:"IX",Ⅹ:"X",Ⅺ:"XI",Ⅻ:"XII",Ⅼ:"L",Ⅽ:"C",Ⅾ:"D",Ⅿ:"M",ⅰ:"I",ⅱ:"II",ⅲ:"III",ⅳ:"IV",ⅴ:"V",ⅵ:"VI",ⅶ:"VII",ⅷ:"VIII",ⅸ:"IX",ⅹ:"X",ⅺ:"XI",ⅻ:"XII",ⅼ:"L",ⅽ:"C",ⅾ:"D",ⅿ:"M"},_e=/([ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿ])/gi,Le=/^(?=[MDCLXVI])(M{0,3})(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$/i,Ge={round:3,allowTrailingInvalid:!1,romanNumerals:!1,bigIntOnOverflow:!1,decimalSeparator:".",allowCurrency:!1,percentage:!1,verbose:!1},Fe=/^\s*\//,ze=/^([-+]?)\s*(\p{Sc}+)\s*/u,je=/\s*(\p{Sc}+)\s*$/u,Ve=/\s*%$/,qe=BigInt(Number.MAX_SAFE_INTEGER),Be=e=>10n**BigInt(e);function He(e,t=Ge){var n;const r={...Ge,...t};let o,a,i,l,s,u,c,d,f;if("string"==typeof e)o=e;else try{o=String(e)}catch{o=""}const p=e=>r.verbose?(e=>{const t={value:e,input:o};return a&&(t.currencyPrefix=a),i&&(t.currencySuffix=i),l&&(t.percentageSuffix=l),s&&(t.trailingInvalid=s),u&&(t.sign=u),void 0!==c&&(t.whole=c),void 0!==d&&(t.numerator=d),void 0!==f&&(t.denominator=f),t})(e):e,h=e=>l&&"number"!==r.percentage?e/100:e;if("symbol"==typeof e)return p(NaN);if("number"==typeof e||"bigint"==typeof e)return p(e);let m=NaN,g=o,v=!0;for(;v;){if(v=!1,r.allowCurrency){const e=ze.exec(g);(null==e?void 0:e[2])&&(a=(a??"")+e[2],g=(e[1]||"")+g.slice(e[0].length),v=!0);const t=je.exec(g);t&&(i=t[1]+(i??""),g=g.slice(0,-t[0].length),v=!0)}if(!l&&r.percentage){const e=Ve.exec(g);e&&(l=!0,g=g.slice(0,-e[0].length),v=!0)}}const b=g.replace(xe,(e,t)=>` ${$e[t]}`).replace(Te,e=>Ae[e]).replace("⁄","/").trim().replace(/\p{Nd}/gu,e=>{const t=e.codePointAt(0);if(t<=57)return e;let n=0,r=De.length-1;for(;n>>1;De[e]<=t?n=e:r=e-1}return String(t-De[n])});if(0===b.length)return p(NaN);let y=b;if(","===r.decimalSeparator){const e=(b.match(/,/g)||[]).length;if(1===e)y=b.replaceAll(".","_").replace(",",".");else if(e>1){const e=b.indexOf(","),t=b.indexOf(",",e+1);y=b.substring(0,t).replaceAll(".","_").replace(",",".")}else y=b.replaceAll(".","_")}const w=Re.exec(y);if(!w)return r.romanNumerals?p(h((e=>{const t=e.replace(_e,(e,t)=>Pe[t]).toUpperCase(),n=Le.exec(t);if(!n)return NaN;const[,r,o,a,i]=n;return(Ie[r]??0)+(Ie[o]??0)+(Ie[a]??0)+(Ie[i]??0)})(b))):p(NaN);const S=w[0].length-((null===(n=w[7])||void 0===n?void 0:n.length)??0),k=b.slice(S).trim();if(k&&(s=k,!r.allowTrailingInvalid))return p(NaN);const[,E,O,N]=w;"-"!==E&&"+"!==E||(u=E);const C=O.replaceAll(",","").replaceAll("_",""),D=null==N?void 0:N.replaceAll(",","").replaceAll("_","");if(r.bigIntOnOverflow){const e=((e,t,n)=>{let r,o=1n;if(t)if(t.startsWith(".")||t.startsWith("e")||t.startsWith("E")){const n=t.search(/[eE]/),a=-1===n?0:parseInt(t.slice(n+1));if(!Number.isFinite(a)||Math.abs(a)>1e4)return;const i=(-1===n?t:t.slice(0,n)).slice(1);r=BigInt(`${e}${i}`),i&&(o=Be(i.length)),a>0?r*=Be(a):a<0&&(o*=Be(-a))}else if(Fe.test(t))r=BigInt(e),o=BigInt(t.replace("/","").trim());else{const[n,a]=t.split("/");o=BigInt(a.trim()),r=BigInt(e)*o+BigInt(n.trim())}else r=BigInt(e);if(n&&(o*=100n),0n===o)return;const a=(2n*r+o)/(2n*o);return a>qe?a:void 0})(C,D,!!l&&"number"!==r.percentage);if(void 0!==e)return p("-"===E?-e:e)}if(m=!C&&D&&D.startsWith(".")?0:parseInt(C),!D)return m="-"===E?-1*m:m,p(h(m));const A=!("number"!=typeof r.round||!Number.isFinite(r.round))&&Math.floor(Math.max(0,r.round)),T=!1===A?NaN:10**A,$=Number.isFinite(T)?T:NaN,M=(e,t)=>{const n=Math.round(t)/$;return Number.isFinite(n)||!Number.isFinite(e)?n:e};if(D.startsWith(".")||D.startsWith("e")||D.startsWith("E")){const e=parseFloat(`${m}${D}`);m=isNaN($)?e:M(e,e*$)}else if(Fe.test(D)){const e=parseInt(C),t=parseInt(D.replace("/",""));d=e,f=t,m=isNaN($)?e/t:M(e/t,e*$/t)}else{const[e,t]=D.split("/").map(e=>parseInt(e));c=m,d=e,f=t,m+=isNaN($)?e/t:M(e/t,e*$/t)}return m="-"===E?-1*m:m,p(h(m))}var Ue=Symbol.for("immer-nothing"),We=Symbol.for("immer-draftable"),Qe=Symbol.for("immer-state");function Ke(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Xe=Object,Ye=Xe.getPrototypeOf,Je="constructor",Ze="prototype",et="configurable",tt="enumerable",nt="writable",rt="value",ot=e=>!!e&&!!e[Qe];function at(e){return!!e&&(st(e)||ht(e)||!!e[We]||!!e[Je]?.[We]||mt(e)||gt(e))}var it=Xe[Ze][Je].toString(),lt=new WeakMap;function st(e){if(!e||!vt(e))return!1;const t=Ye(e);if(null===t||t===Xe[Ze])return!0;const n=Xe.hasOwnProperty.call(t,Je)&&t[Je];if(n===Object)return!0;if(!bt(n))return!1;let r=lt.get(n);return void 0===r&&(r=Function.toString.call(n),lt.set(n,r)),r===it}function ut(e,t,n=!0){if(0===ct(e)){(n?Reflect.ownKeys(e):Xe.keys(e)).forEach(n=>{t(n,e[n],e)})}else e.forEach((n,r)=>t(r,n,e))}function ct(e){const t=e[Qe];return t?t.type_:ht(e)?1:mt(e)?2:gt(e)?3:0}var dt=(e,t,n=ct(e))=>2===n?e.has(t):Xe[Ze].hasOwnProperty.call(e,t),ft=(e,t,n=ct(e))=>2===n?e.get(t):e[t],pt=(e,t,n,r=ct(e))=>{2===r?e.set(t,n):3===r?e.add(n):e[t]=n};var ht=Array.isArray,mt=e=>e instanceof Map,gt=e=>e instanceof Set,vt=e=>"object"==typeof e,bt=e=>"function"==typeof e,yt=e=>"boolean"==typeof e;var wt=e=>e.copy_||e.base_,St=e=>e.modified_?e.copy_:e.base_;function kt(e,t){if(mt(e))return new Map(e);if(gt(e))return new Set(e);if(ht(e))return Array[Ze].slice.call(e);const n=st(e);if(!0===t||"class_only"===t&&!n){const t=Xe.getOwnPropertyDescriptors(e);delete t[Qe];let n=Reflect.ownKeys(t);for(let r=0;r1&&Xe.defineProperties(e,{set:Ot,add:Ot,clear:Ot,delete:Ot}),Xe.freeze(e),t&&ut(e,(e,t)=>{Et(t,!0)},!1)),e}var Ot={[rt]:function(){Ke(2)}};function Nt(e){return null===e||!vt(e)||Xe.isFrozen(e)}var Ct="MapSet",Dt="Patches",At="ArrayMethods",Tt={};function $t(e){const t=Tt[e];return t||Ke(0),t}var Mt,Rt=e=>!!Tt[e];var xt=()=>Mt;function It(e,t){t&&(e.patchPlugin_=$t(Dt),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Pt(e){_t(e),e.drafts_.forEach(Gt),e.drafts_=null}function _t(e){e===Mt&&(Mt=e.parent_)}var Lt=e=>Mt={drafts_:[],parent_:Mt,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Rt(Ct)?$t(Ct):void 0,arrayMethodsPlugin_:Rt(At)?$t(At):void 0};function Gt(e){const t=e[Qe];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function Ft(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];if(void 0!==e&&e!==n){n[Qe].modified_&&(Pt(t),Ke(4)),at(e)&&(e=zt(t,e));const{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[Qe].base_,e,t)}else e=zt(t,n);return function(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Et(t,n)}(t,e,!0),Pt(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Ue?e:void 0}function zt(e,t){if(Nt(t))return t;const n=t[Qe];if(!n){return Wt(t,e.handledSet_,e)}if(!Vt(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:t}=n;if(t)for(;t.length>0;){t.pop()(e)}Ht(n,e)}return n.copy_}function jt(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Vt=(e,t)=>e.scope_===t,qt=[];function Bt(e,t,n,r){const o=wt(e),a=e.type_;if(void 0!==r){if(ft(o,r,a)===t)return void pt(o,r,n,a)}if(!e.draftLocations_){const t=e.draftLocations_=new Map;ut(o,(e,n)=>{if(ot(n)){const r=t.get(n)||[];r.push(e),t.set(n,r)}})}const i=e.draftLocations_.get(t)??qt;for(const e of i)pt(o,e,n,a)}function Ht(e,t){if(e.modified_&&!e.finalized_&&(3===e.type_||1===e.type_&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){const{patchPlugin_:n}=t;if(n){const r=n.getPath(e);r&&n.generatePatches_(e,r,t)}jt(e)}}function Ut(e,t,n){const{scope_:r}=e;if(ot(n)){const o=n[Qe];Vt(o,r)&&o.callbacks_.push(function(){Zt(e);const r=St(o);Bt(e,n,r,t)})}else at(n)&&e.callbacks_.push(function(){const o=wt(e);3===e.type_?o.has(n)&&Wt(n,r.handledSet_,r):ft(o,t,e.type_)===n&&r.drafts_.length>1&&!0===(e.assigned_.get(t)??!1)&&e.copy_&&Wt(ft(e.copy_,t,e.type_),r.handledSet_,r)})}function Wt(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||ot(e)||t.has(e)||!at(e)||Nt(e)||(t.add(e),ut(e,(r,o)=>{if(ot(o)){const t=o[Qe];if(Vt(t,n)){const n=St(t);pt(e,r,n,e.type_),jt(t)}}else at(o)&&Wt(o,t,n)})),e}var Qt={get(e,t){if(t===Qe)return e;let n=e.scope_.arrayMethodsPlugin_;const r=1===e.type_&&"string"==typeof t;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);const o=wt(e);if(!dt(o,t,e.type_))return function(e,t,n){const r=Yt(t,n);return r?rt in r?r[rt]:r.get?.call(e.draft_):void 0}(e,o,t);const a=o[t];if(e.finalized_||!at(a))return a;if(r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&function(e){const t=+e;return Number.isInteger(t)&&String(t)===e}(t))return a;if(a===Xt(e.base_,t)||function(e,t,n){if(1!==e.type_||!e.allIndicesReassigned_||e.assigned_?.get(t)||!at(n)||n[Qe])return!1;return e.baseRefs_.has(n)}(e,t,a)){Zt(e);const n=1===e.type_?+t:t,r=tn(e.scope_,a,e,n);return e.copy_[n]=r}return a},has:(e,t)=>t in wt(e),ownKeys:e=>Reflect.ownKeys(wt(e)),set(e,t,n){const r=Yt(wt(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=Xt(wt(e),t),i=r?.[Qe];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(((o=n)===(a=r)?0!==o||1/o==1/a:o!=o&&a!=a)&&(void 0!==n||dt(e.base_,t,e.type_)))return!0;Zt(e),Jt(e)}var o,a;return e.copy_[t]===n&&(void 0!==n||dt(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_.set(t,!0),Ut(e,t,n)),!0},deleteProperty:(e,t)=>(Zt(e),void 0!==Xt(e.base_,t)||t in e.base_?(e.assigned_.set(t,!1),Jt(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=wt(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{[nt]:!0,[et]:1!==e.type_||"length"!==t,[tt]:r[tt],[rt]:n[t]}:r},defineProperty(){Ke(11)},getPrototypeOf:e=>Ye(e.base_),setPrototypeOf(){Ke(12)}},Kt={};for(let e in Qt){let t=Qt[e];Kt[e]=function(){const e=arguments;return e[0]=e[0][0],t.apply(this,e)}}function Xt(e,t){const n=e[Qe];return(n?wt(n):e)[t]}function Yt(e,t){if(!(t in e))return;let n=Ye(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Ye(n)}}function Jt(e){e.modified_||(e.modified_=!0,e.parent_&&Jt(e.parent_))}function Zt(e){e.copy_||(e.assigned_=new Map,e.copy_=kt(e.base_,e.scope_.immer_.useStrictShallowCopy_))}Kt.deleteProperty=function(e,t){return Kt.set.call(this,e,t,void 0)},Kt.set=function(e,t,n){return Qt.set.call(this,e[0],t,n,e[0])};var en=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(bt(e)&&!bt(t)){const n=t;t=e;const r=this;return function(e=n,...o){return r.produce(e,e=>t.call(this,e,...o))}}let r;if(bt(t)||Ke(6),void 0===n||bt(n)||Ke(7),at(e)){const o=Lt(this),a=tn(o,e,void 0);let i=!0;try{r=t(a),i=!1}finally{i?Pt(o):_t(o)}return It(o,n),Ft(r,o)}if(!e||!vt(e)){if(r=t(e),void 0===r&&(r=e),r===Ue&&(r=void 0),this.autoFreeze_&&Et(r,!0),n){const t=[],o=[];$t(Dt).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:o}),n(t,o)}return r}Ke(1)},this.produceWithPatches=(e,t)=>{if(bt(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},yt(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),yt(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),yt(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){at(e)||Ke(8),ot(e)&&(e=nn(e));const t=Lt(this),n=tn(t,e,void 0);return n[Qe].isManual_=!0,_t(t),n}finishDraft(e,t){const n=e&&e[Qe];n&&n.isManual_||Ke(9);const{scope_:r}=n;return It(r,t),Ft(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=$t(Dt).applyPatches_;return ot(e)?r(e,t):this.produce(e,e=>r(e,t))}};function tn(e,t,n,r){const[o,a]=mt(t)?$t(Ct).proxyMap_(t,n):gt(t)?$t(Ct).proxySet_(t,n):function(e,t){const n=ht(e),r={type_:n?1:0,scope_:t?t.scope_:xt(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let o=r,a=Qt;n&&(o=[r],a=Kt);const{revoke:i,proxy:l}=Proxy.revocable(o,a);return r.draft_=l,r.revoke_=i,[l,r]}(t,n);return(n?.scope_??xt()).drafts_.push(o),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&void 0!==r?function(e,t,n){e.callbacks_.push(function(r){const o=t;if(!o||!Vt(o,r))return;r.mapSetPlugin_?.fixSetContents(o);const a=St(o);Bt(e,o.draft_??o,a,n),Ht(o,r)})}(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),o}function nn(e){return ot(e)||Ke(10),rn(e)}function rn(e){if(!at(e)||Nt(e))return e;const t=e[Qe];let n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=kt(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=kt(e,!0);return ut(n,(e,t)=>{pt(n,e,rn(t))},r),t&&(t.finalized_=!1),n}globalThis.Iterator;var on=new en,an=on.produce;const ln="------",sn={fields:{title:"Field",placeholderName:"~",placeholderLabel:ln,placeholderGroupLabel:ln},operators:{title:"Operator",placeholderName:"~",placeholderLabel:ln,placeholderGroupLabel:ln},values:{title:"Values",placeholderName:"~",placeholderLabel:ln,placeholderGroupLabel:ln},matchMode:{title:"Match mode"},matchThreshold:{title:"Match threshold",placeholderName:"#"},value:{title:"Value"},removeRule:{label:"⨯",title:"Remove rule"},removeGroup:{label:"⨯",title:"Remove group"},addRule:{label:"+ Rule",title:"Add rule"},addGroup:{label:"+ Group",title:"Add group"},combinators:{title:"Combinator"},notToggle:{label:"Not",title:"Invert this group"},cloneRule:{label:"⧉",title:"Clone rule"},cloneRuleGroup:{label:"⧉",title:"Clone group"},shiftActionUp:{label:"˄",title:"Shift up"},shiftActionDown:{label:"˅",title:"Shift down"},undo:{label:"↶",title:"Undo"},redo:{label:"↷",title:"Redo"},dragHandle:{label:"⁞⁞",title:"Drag handle"},lockRule:{label:"🔓",title:"Lock rule"},lockGroup:{label:"🔓",title:"Lock group"},lockRuleDisabled:{label:"🔒",title:"Unlock rule"},lockGroupDisabled:{label:"🔒",title:"Unlock group"},muteRule:{label:"🔊",title:"Mute rule"},muteGroup:{label:"🔊",title:"Mute group"},unmuteRule:{label:"🔇",title:"Unmute rule"},unmuteGroup:{label:"🔇",title:"Unmute group"},valueSourceSelector:{title:"Value source"}},un={"=":"=","!=":"!=","<":"<",">":">","<=":"<=",">=":">=",contains:"contains",beginsWith:"begins with",endsWith:"ends with",doesNotContain:"does not contain",doesNotBeginWith:"does not begin with",doesNotEndWith:"does not end with",null:"is null",notNull:"is not null",in:"in",notIn:"not in",between:"between",notBetween:"not between"},cn={and:"AND",or:"OR",xor:"XOR"},dn=[{name:"=",value:"=",label:"="},{name:"!=",value:"!=",label:"!="},{name:"<",value:"<",label:"<"},{name:">",value:">",label:">"},{name:"<=",value:"<=",label:"<="},{name:">=",value:">=",label:">="},{name:"contains",value:"contains",label:"contains"},{name:"beginsWith",value:"beginsWith",label:"begins with"},{name:"endsWith",value:"endsWith",label:"ends with"},{name:"doesNotContain",value:"doesNotContain",label:"does not contain"},{name:"doesNotBeginWith",value:"doesNotBeginWith",label:"does not begin with"},{name:"doesNotEndWith",value:"doesNotEndWith",label:"does not end with"},{name:"null",value:"null",label:"is null"},{name:"notNull",value:"notNull",label:"is not null"},{name:"in",value:"in",label:"in"},{name:"notIn",value:"notIn",label:"not in"},{name:"between",value:"between",label:"between"},{name:"notBetween",value:"notBetween",label:"not between"}],fn=[{name:"and",value:"and",label:"AND"},{name:"or",value:"or",label:"OR"}],pn=[{name:"all",value:"all",label:"all"},{name:"some",value:"some",label:"some"},{name:"none",value:"none",label:"none"},{name:"atLeast",value:"atLeast",label:"at least"},{name:"atMost",value:"atMost",label:"at most"},{name:"exactly",value:"exactly",label:"exactly"}],hn={queryBuilder:"queryBuilder",ruleGroup:"ruleGroup",header:"ruleGroup-header",body:"ruleGroup-body",combinators:"ruleGroup-combinators",addRule:"ruleGroup-addRule",addGroup:"ruleGroup-addGroup",cloneRule:"rule-cloneRule",cloneGroup:"ruleGroup-cloneGroup",removeGroup:"ruleGroup-remove",notToggle:"ruleGroup-notToggle",rule:"rule",fields:"rule-fields",matchMode:"rule-matchMode",matchThreshold:"rule-matchThreshold",operators:"rule-operators",value:"rule-value",removeRule:"rule-remove",betweenRules:"betweenRules",valid:"queryBuilder-valid",invalid:"queryBuilder-invalid",shiftActions:"shiftActions",undoRedoActions:"undoRedoActions",undoAction:"undoRedoActions-undo",redoAction:"undoRedoActions-redo",dndDragging:"dndDragging",dndOver:"dndOver",dndCopy:"dndCopy",dndGroup:"dndGroup",dndDropNotAllowed:"dndDropNotAllowed",dndPreviewPosition:"dndPreviewPosition",dndHidden:"dndHidden",dragHandle:"queryBuilder-dragHandle",disabled:"queryBuilder-disabled",muted:"queryBuilder-muted",lockRule:"rule-lock",lockGroup:"ruleGroup-lock",muteRule:"rule-mute",muteGroup:"ruleGroup-mute",valueSource:"rule-valueSource",valueListItem:"rule-value-list-item",branches:"queryBuilder-branches",justified:"queryBuilder-justified",responsive:"queryBuilder-responsive",hasSubQuery:"rule-hasSubQuery",loading:"queryBuilder-loading",valueDateTimeRelative:"rule-value-dateTimeRelative"},mn="empty",gn="invalid combinator",vn="invalid independent combinators",bn="rule",yn="rule-group",wn="inline-combinator",Sn="add-group",kn="remove-group",En="clone-group",On="clone-rule",Nn="add-rule",Cn="remove-rule",Dn="combinators",An="fields",Tn="operators",$n="value-editor",Mn="not-toggle",Rn="shift-actions",xn="undo-redo-actions",In="drag-handle",Pn="lock-rule",_n="lock-group",Ln="mute-rule",Gn="mute-group",Fn="value-source-selector",zn="match-mode-editor",jn="action aborted: parent path disabled",Vn="action aborted: path is disabled",qn="onAddRule callback returned false",Bn="onAddGroup callback returned false",Hn="onGroupRule callback returned false",Un="onGroupGroup callback returned false",Wn="onMoveRule callback returned false",Qn="onMoveGroup callback returned false",Kn="onRemove callback returned false",Xn="rule or group added",Yn="rule or group removed",Jn="rule or group updated",Zn="rule or group moved",er="rule or group grouped with another",tr=[],nr={addRuleToNewGroups:!1,autoSelectField:!0,autoSelectOperator:!0,autoSelectValue:!1,debugMode:!1,enableDragAndDrop:!1,enableMountQueryChange:!0,listsAsArrays:!1,preserveQueryStateOnUnmount:!1,resetOnFieldChange:!0,resetOnOperatorChange:!1,showCloneButtons:!1,showCombinatorsBetweenRules:!1,showLockButtons:!1,showMuteButtons:!1,showNotToggle:!1,showShiftActions:!1,showUndoRedo:!1,suppressStandardClassnames:!1},rr=new Set(["target-not-found","parent-not-found","parent-not-a-group","destination-not-found","root-not-allowed","not-a-combinator-slot","target-disabled","parent-disabled","max-levels-exceeded"]),or=(e,t=",")=>"string"==typeof e?e.split(`\\${t}`).map(e=>e.split(t)).reduce((e,n,r)=>0===r?n:[...e.slice(0,-1),`${e.at(-1)}${t}${n[0]}`,...n.slice(1)],[]):[],ar=(e,t=",")=>e.map(e=>`${e??""}`.replaceAll(t[0],`\\${t[0]}`)).join(t),ir=e=>"string"==typeof e?e.trim():e,lr=(e,{retainEmptyStrings:t}={})=>Array.isArray(e)?e.map(ir):"string"==typeof e?or(e,",").filter(t?()=>!0:e=>!/^\s*$/.test(e)).map(e=>e.trim()):"number"==typeof e?[e]:[];function sr(e){var t,n,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t"string"==typeof e?e.toLowerCase():e,dr=new RegExp(Me.source.replace(/^\^/,String.raw`^\s*`).replace(/\$$/,String.raw`\s*$`)),fr=e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype,pr=e=>null==e||""===e,hr=e=>fr(e)&&Array.isArray(e.rules),mr=e=>hr(e)&&"string"==typeof e.combinator,gr=e=>hr(e)&&void 0===e.combinator,vr="~structural",br=(e,t)=>{const n=new Set([...Object.keys(e),...Object.keys(t)]);n.delete("rules");const r=[];for(const o of n)Object.is(e[o],t[o])||r.push(o);return r.toSorted()},yr=(e,t,n,r)=>{if(e===t)return"";if("string"==typeof e||"string"==typeof t)return typeof e==typeof t?`${n}:combinator[${r}]`:vr;const o=hr(e),a=hr(t);if(o!==a)return vr;if(!o||!a){const n=br(e,t);return 0===n.length?"":`${t.id??""}:${n.join(",")}`}if(e.rules.length!==t.rules.length)return vr;const i=br(e,t);let l=-1;for(const[n,r]of e.rules.entries())if(r!==t.rules[n]){if(-1!==l)return vr;l=n}return-1===l?0===i.length?"":`${t.id??""}:${i.join(",")}`:i.length>0?vr:yr(e.rules[l],t.rules[l],t.id??"",l)},wr=(e,t)=>yr(e,t,"",-1),Sr=["or","xor","and"],kr=(e,t)=>cr(e)===t,Er=(e,t=0)=>{const n=Sr[t];if(!e.rules.includes(n))return t{if(mr(e))return e;const t=Er(e),n=[];let r="and";for(const[e,o]of t.rules.entries())"string"==typeof o?1===e&&(r=o):n.push(hr(o)?Or(o):o);return{...t,combinator:r,rules:n}},Nr=e=>{if(gr(e))return e;const{combinator:t,...n}=e,r=[],{length:o}=e.rules;for(let n=0;ne.isOver,standardOnly:!0},{key:"dndCopy",when:e=>e.isOver&&"copy"===e.dropEffect},{key:"dndDropNotAllowed",when:e=>e.dropNotAllowed}]},shiftActions:["shiftActions"],undoRedoActions:["undoRedoActions"],undoAction:["actionElement","undoAction"],redoAction:["actionElement","redoAction"],dragHandle:["dragHandle"],combinators:["valueSelector","combinators"],notToggle:["notToggle"],addRule:["actionElement","addRule"],addGroup:["actionElement","addGroup"],cloneGroup:["actionElement","cloneGroup"],lockGroup:["actionElement","lockGroup"],muteGroup:["actionElement","muteGroup"],removeGroup:["actionElement","removeGroup"],body:["body"]},Ar=[{key:"disabled",when:e=>e.disabled},{key:"muted",when:e=>e.muted},{key:"dndDragging",when:e=>e.isDragging},{key:"dndOver",when:e=>e.isOver},{key:"dndCopy",when:e=>e.isOver&&"copy"===e.dropEffect},{key:"dndGroup",when:e=>e.isOver&&e.groupItems},{key:"dndDropNotAllowed",when:e=>e.dropNotAllowed},{key:"hasSubQuery",when:e=>e.hasSubQuery}],Tr=[{key:"disabled",when:e=>e.disabled},{key:"muted",when:e=>e.muted},{key:"dndDragging",when:e=>e.isDragging},{key:"dndGroup",when:e=>e.isOver&&e.groupItems}],$r=[{key:"disabled",when:e=>e.disabled},{key:"valid",when:e=>"boolean"==typeof e.validationResult&&e.validationResult},{key:"invalid",when:e=>"boolean"==typeof e.validationResult&&!e.validationResult}],Mr=(e,t,{classNames:n,suppressStandardClassnames:r})=>{const o=e.map(e=>[e,!!e.when(t)]);return[...o.filter(([e])=>!e.standardOnly).map(([e,t])=>t&&n?.[e.key]),r||Object.fromEntries(o.map(([e,t])=>[hn[e.key],t]))]},Rr=(e,t,n,r)=>{const{sources:o,conditions:a}=Array.isArray(t)?{sources:t}:t;return ur(r.suppressStandardClassnames||hn[e],...o.map(e=>r.classNames?.[e]),...a?Mr(a,n,r):[])},xr=(e,t,n)=>{const r={};for(const[o,a]of Object.entries(e))r[o]=Rr(o,a,t,n);return r},Ir=(e,t,n)=>{const{classNames:r,suppressStandardClassnames:o,leadingClassNames:a=[],validationClassName:i}=n;return ur(...a,o||hn[e],r?.[e],...Mr(t,n,n),i)},Pr=e=>{const t={},n=e=>{ /* v8 ignore start -- @preserve */ e.id&&t[e.id] /* v8 ignore stop -- @preserve */},r=e=>{const o=[];if(0===e.rules.length)o.push(mn);else if(!mr(e)){let t=!1;for(let n=0;ne.name).includes(e.rules[n]))&&(t=!0);t&&o.push(vn)}mr(e)&&!fn.map(e=>e.name).includes(e.combinator)&&e.rules.length>1&&o.push(gn) -/* v8 ignore else -- @preserve */,e.id&&(t[e.id]=!(o.length>0)||{valid:!1,reasons:o});for(const t of e.rules)"string"==typeof t||(hr(t)?r(t):n(t))};return r(e),t},_r=Object.keys,Lr=Object.entries,Gr=e=>"__proto__"===e||"constructor"===e||"prototype"===e,Fr=e=>fr(e)&&"name"in e&&"string"==typeof e.name,zr=e=>fr(e)&&"value"in e&&"string"==typeof e.value;function jr(e,t,n){if("string"==typeof e)return{...t,name:e,value:e,label:n?.[e]??e};const r={};let o=!!t;return Fr(e)&&!zr(e)?(r.value=e.name,o=!0):!Fr(e)&&zr(e)&&(r.name=e.value,o=!0),o?Object.assign({},t,e,r):e}function qr(e,t,n){if(!Array.isArray(e))return[];const r=e;return Wr(r)?r.map(e=>({...e,options:e.options.map(e=>jr(e,t,n))})):r.map(e=>jr(e,t,n))}function Br(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,jr(n,t)]))}const Vr=e=>{const t=new Set,n=[];for(const r of e)t.has(r.value??r.name)||(t.add(r.value??r.name),n.push(r));return e.length===n.length?e:n},Hr=e=>Array.isArray(e)&&e.length>0&&fr(e[0])&&"options"in e[0]&&Array.isArray(e[0].options),Ur=e=>{let t=!1;if(Array.isArray(e))for(const n of e){if(!Fr(n)&&!zr(n))return!1;t=!0}return t},Wr=(e,{allowEmpty:t=!1}={})=>{let n=!1;if(Array.isArray(e))for(const r of e){if(!(fr(r)&&"options"in r&&(Ur(r.options)||t&&Array.isArray(r.options)&&0===r.options.length)))return!1;n=!0}return n};function Qr(e,t){return(Wr(e,{allowEmpty:!0})?e.flatMap(e=>e.options):e).find(e=>e.value===t||e.name===t)}function Kr(e){if(!Array.isArray(e)||0===e.length)return null;if(Wr(e,{allowEmpty:!0})){for(const t of e)if(t.options.length>0)return t.options[0].value??t.options[0].name;return null}return e[0].value??e[0].name}const Xr=e=>Vr(Hr(e)?e.flatMap(e=>e.options):e),Yr=e=>{const t=new Set,n=new Set,r=[];for(const o of e)if(!t.has(o.label)){t.add(o.label);const e=[];for(const t of o.options)n.has(t.value??t.name)||(n.add(t.value??t.name),e.push(jr(t)));r.push({...o,options:e})}return r},Jr=e=>{const{optionList:t,baseOption:n={},labelMap:r={},placeholder:{placeholderName:o="~",placeholderLabel:a=ln,placeholderGroupLabel:i=ln}={},autoSelectOption:l=!0}=e,s={id:o,name:o,value:o,label:a},u=t??[s];let c;const d=Array.isArray(u)?qr(u,n,r):_r(Br(u,n)).map(e=>({...u[e],name:e,value:e})).sort((e,t)=>e.label.localeCompare(t.label));c=Wr(d)?Yr(l?d:[{label:i,options:[s]},...d]):Vr(l?d:[s,...d]);let f={};if(Array.isArray(u))if(Wr(c))for(const e of c)for(const t of e.options)f[t.value?? +/* v8 ignore else -- @preserve */,e.id&&(t[e.id]=!(o.length>0)||{valid:!1,reasons:o});for(const t of e.rules)"string"==typeof t||(hr(t)?r(t):n(t))};return r(e),t},_r=Object.keys,Lr=Object.entries,Gr=e=>"__proto__"===e||"constructor"===e||"prototype"===e,Fr=e=>fr(e)&&"name"in e&&"string"==typeof e.name,zr=e=>fr(e)&&"value"in e&&"string"==typeof e.value;function jr(e,t,n){if("string"==typeof e)return{...t,name:e,value:e,label:n?.[e]??e};const r={};let o=!!t;return Fr(e)&&!zr(e)?(r.value=e.name,o=!0):!Fr(e)&&zr(e)&&(r.name=e.value,o=!0),o?Object.assign({},t,e,r):e}function Vr(e,t,n){if(!Array.isArray(e))return[];const r=e;return Wr(r)?r.map(e=>({...e,options:e.options.map(e=>jr(e,t,n))})):r.map(e=>jr(e,t,n))}function qr(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,jr(n,t)]))}const Br=e=>{const t=new Set,n=[];for(const r of e)t.has(r.value??r.name)||(t.add(r.value??r.name),n.push(r));return e.length===n.length?e:n},Hr=e=>Array.isArray(e)&&e.length>0&&fr(e[0])&&"options"in e[0]&&Array.isArray(e[0].options),Ur=e=>{let t=!1;if(Array.isArray(e))for(const n of e){if(!Fr(n)&&!zr(n))return!1;t=!0}return t},Wr=(e,{allowEmpty:t=!1}={})=>{let n=!1;if(Array.isArray(e))for(const r of e){if(!(fr(r)&&"options"in r&&(Ur(r.options)||t&&Array.isArray(r.options)&&0===r.options.length)))return!1;n=!0}return n};function Qr(e,t){return(Wr(e,{allowEmpty:!0})?e.flatMap(e=>e.options):e).find(e=>e.value===t||e.name===t)}function Kr(e){if(!Array.isArray(e)||0===e.length)return null;if(Wr(e,{allowEmpty:!0})){for(const t of e)if(t.options.length>0)return t.options[0].value??t.options[0].name;return null}return e[0].value??e[0].name}const Xr=e=>Br(Hr(e)?e.flatMap(e=>e.options):e),Yr=e=>{const t=new Set,n=new Set,r=[];for(const o of e)if(!t.has(o.label)){t.add(o.label);const e=[];for(const t of o.options)n.has(t.value??t.name)||(n.add(t.value??t.name),e.push(jr(t)));r.push({...o,options:e})}return r},Jr=e=>{const{optionList:t,baseOption:n={},labelMap:r={},placeholder:{placeholderName:o="~",placeholderLabel:a=ln,placeholderGroupLabel:i=ln}={},autoSelectOption:l=!0}=e,s={id:o,name:o,value:o,label:a},u=t??[s];let c;const d=Array.isArray(u)?Vr(u,n,r):_r(qr(u,n)).map(e=>({...u[e],name:e,value:e})).sort((e,t)=>e.label.localeCompare(t.label));c=Wr(d)?Yr(l?d:[{label:i,options:[s]},...d]):Br(l?d:[s,...d]);let f={};if(Array.isArray(u))if(Wr(c))for(const e of c)for(const t of e.options)f[t.value?? /* v8 ignore start -- @preserve */t.name]=jr(t,n);else for(const e of c)f[e.value?? -/* v8 ignore start -- @preserve */e.name]=jr(e,n);else{const e=Br(u,n);f=l?e:{...e,[o]:s}}return{defaultOption:s,optionList:c,optionsMap:f}},Zr=(e,t,n)=>{const r=jr(e),o=jr(n);return r.value!==o.value&&("string"==typeof r.comparator?r[r.comparator]===o[r.comparator]:r.comparator?.(o,t)?? +/* v8 ignore start -- @preserve */e.name]=jr(e,n);else{const e=qr(u,n);f=l?e:{...e,[o]:s}}return{defaultOption:s,optionList:c,optionsMap:f}},Zr=(e,t,n)=>{const r=jr(e),o=jr(n);return r.value!==o.value&&("string"==typeof r.comparator?r[r.comparator]===o[r.comparator]:r.comparator?.(o,t)?? /* v8 ignore start -- @preserve */!1)},eo=(e,t,n)=>{if(!e.comparator){const n=t=>(t.value??/* v8 ignore start -- @preserve */t.name)!==(e.value?? -/* v8 ignore start -- @preserve */e.name);return Wr(t)?t.map(e=>({...e,options:e.options.filter(e=>n(e))})):t.filter(e=>n(e))}return Wr(t)?t.map(t=>({...t,options:t.options.filter(t=>Zr(e,n,t))})).filter(e=>e.options.length>0):t.filter(t=>Zr(e,n,t))},to=(e,t)=>t?.[e]??{name:e,value:e,label:e},no=e=>{const t=e?.arity;return"string"==typeof t&&"unary"===t||"number"==typeof t&&t<2},ro=(e,t,n)=>{const r=n(e.field,e.operator,{fieldData:t});return e.valueSource&&!Qr(r,e.valueSource)?[...r,{name:e.valueSource,value:e.valueSource,label:e.valueSource}]:r},oo=e=>e&&e.length>0?e:null,ao=(e,t,n,r)=>"field"===e.valueSource?"select":"parameter"===e.valueSource?n?"in"===cr(e.operator)||"notin"===cr(e.operator)?"multiselect":"select":"text":r(e.field,e.operator,{fieldData:t}),io=(e,t,n,r,o)=>{const a="field"===e.valueSource?eo(t,n,e.operator):"parameter"===e.valueSource?r??[]:o(e.field,e.operator,{fieldData:t});return Ur(a)||Wr(a)?qr(a):a},lo=(e,t,n={},r=e.id??"")=>n[r]??("function"==typeof t.validator?t.validator(e):null),so=(e,t)=>mr(e)?e.combinator:Kr(t)??"",uo=(e,{parseNumbers:t,bigIntOnOverflow:n}={})=>{if(!t||"bigint"==typeof e||"number"==typeof e)return e;if("native"===t)return Number.parseFloat(e);const r=He(e,{allowTrailingInvalid:"enhanced"===t,bigIntOnOverflow:n,romanNumerals:!1,round:!1});return"bigint"!=typeof r&&Number.isNaN(r)?e:r},co=new Set(["between","notBetween","in","notIn"]),fo=(e,t)=>"bigint"===e||"in"===t||"notIn"===t?"text":e||"text",po=(e,t,n)=>{const r={};for(const o in e){if(Gr(o))continue;const a=t[o];!1!==a&&(a&&o!==a?(Gr(a)||(r[a]=e[o]),n||(r[o]=e[o])):r[o]=e[o])}return r};function ho(e,t={}){const{ruleProcessor:n=e=>e,ruleGroupProcessor:r=e=>e,propertyMap:o={},combinatorMap:a={},operatorMap:i={},omitPath:l=!1,deleteRemappedProperties:s=!0}=t,u=e=>({...r(po({...e,...mr(e)?{combinator:a[e.combinator]??e.combinator}:{}},o,s)),...!1===o.rules?null:{[o.rules??"rules"]:e.rules.map((t,r)=>{const c=l?null:{path:[...e.path,r]};return"string"==typeof t?a[t]??t:hr(t)?u({...t,...c}):n(po({...t,...c,..."operator"in t?{operator:i[t.operator]??t.operator}:{}},o,s))})}});return u({...e,...l?null:{path:[]}})}const mo=e=>fr(e)&&"boolean"==typeof e.valid,go=(e,t,n)=>{if(e.muted)return!1;if("boolean"==typeof t)return t;if(mo(t))return t.valid;if("function"==typeof n&&!hr(e)){const t=n(e);if("boolean"==typeof t)return t;if(mo(t))return t.valid}return!0},vo=({parseNumbers:e,inputType:t})=>{if("string"==typeof e){const[n,r]=e.split("-");return"limited"===r?"number"===t&&n:n}return!!e&&"strict"},bo=(e,t,{concatOperator:n="||",quoteValuesWith:r,wrapValueWith:o=["",""]}={})=>{const[a,i]=(e=>{switch(e){case"contains":case"doesnotcontain":return["%","%"];case"beginswith":case"doesnotbeginwith":return["","%"];case"endswith":case"doesnotendwith":return["%",""];default:return["",""]}})(t),l=r||"'",s=e=>`${o[0]}${l}${e}${l}${o[1]}`,u=[a&&s(a),e,i&&s(i)].filter(Boolean);return u.length>1?((e="||")=>(...t)=>"CONCAT"===e.toUpperCase()?`CONCAT(${t.join(", ")})`:t.join(` ${e} `))(n)(...u):e},yo={"=":"$eq","!=":"$ne","<":"$lt","<=":"$lte",">":"$gt",">=":"$gte",in:"$in",notin:"$nin",notIn:"$nin"},wo={"=":"equals","!=":"not","<":"lt","<=":"lte",">":"gt",">=":"gte",in:"in",notin:"notIn"},So={and:"&&",or:"||"},ko=(e,t)=>({...e,rules:e.rules.map(e=>{if("string"==typeof e)return e;if(hr(e))return ko(e,t);const n=Qr(t.fields,e.field),r=vo({parseNumbers:t.parseNumbers,inputType:n?.inputType});if(Array.isArray(e.value))return{...e,value:e.value.map(e=>uo(e,{parseNumbers:r}))};const o=lr(e.value,{retainEmptyStrings:!0}).map(e=>uo(e,{parseNumbers:r}));if(o.every(e=>"number"==typeof e)){if(o.length>1)return{...e,value:o};if(1===o.length)return{...e,value:o[0]}}return e})}),Eo=e=>"string"==typeof e&&e.length>0||"number"==typeof e&&!Number.isNaN(e)||"string"!=typeof e&&"number"!=typeof e,Oo=(e,t)=>!!t&&("number"==typeof e||"bigint"==typeof e||"string"==typeof e&&dr.test(e)),No=(e=["",""])=>Array.isArray(e)?e:"string"==typeof e?[e,e]:e??["",""],Co=(e,{quoteFieldNamesWith:t,fieldIdentifierSeparator:n})=>{const[r,o]=No(t);return"string"==typeof n&&n.length>0?ar(or(e,n).map(e=>`${r}${e}${o}`),n):`${r}${e}${o}`},Do=["S","V","O"],Ao=(e,t=":")=>{const n=`${e??""}`;return t&&n.startsWith(t)?n:`${t}${n}`},To=(e,t=":")=>{const n=`${e??""}`;return t&&n.startsWith(t)?n.slice(t.length):n},$o={groupPrefix:"",groupPrefix_not_xor:"either zero or more than one of",groupPrefix_xor:"exactly one of",groupSuffix:"is true",groupSuffix_not:"is not true"},Mo=(e,t,n)=>t.startsWith(e)&&n.every(e=>t.includes(`_${e}`)&&t.match(/_/g)?.length===n.length),Ro=(e,t,n=[])=>0===n.length?t[e]??$o[e]?? +/* v8 ignore start -- @preserve */e.name);return Wr(t)?t.map(e=>({...e,options:e.options.filter(e=>n(e))})):t.filter(e=>n(e))}return Wr(t)?t.map(t=>({...t,options:t.options.filter(t=>Zr(e,n,t))})).filter(e=>e.options.length>0):t.filter(t=>Zr(e,n,t))},to=(e,t)=>t?.[e]??{name:e,value:e,label:e},no=e=>{const t=e?.arity;return"string"==typeof t&&"unary"===t||"number"==typeof t&&t<2},ro=(e,t,n)=>{const r=n(e.field,e.operator,{fieldData:t});return e.valueSource&&!Qr(r,e.valueSource)?[...r,{name:e.valueSource,value:e.valueSource,label:e.valueSource}]:r},oo=e=>e&&e.length>0?e:null,ao=(e,t,n,r)=>"field"===e.valueSource?"select":"parameter"===e.valueSource?n?"in"===cr(e.operator)||"notin"===cr(e.operator)?"multiselect":"select":"text":r(e.field,e.operator,{fieldData:t}),io=(e,t,n,r,o)=>{const a="field"===e.valueSource?eo(t,n,e.operator):"parameter"===e.valueSource?r??[]:o(e.field,e.operator,{fieldData:t});return Ur(a)||Wr(a)?Vr(a):a},lo=(e,t,n={},r=e.id??"")=>n[r]??("function"==typeof t.validator?t.validator(e):null),so=(e,t)=>mr(e)?e.combinator:Kr(t)??"",uo=(e,{parseNumbers:t,bigIntOnOverflow:n}={})=>{if(!t||"bigint"==typeof e||"number"==typeof e)return e;if("native"===t)return Number.parseFloat(e);const r=He(e,{allowTrailingInvalid:"enhanced"===t,bigIntOnOverflow:n,romanNumerals:!1,round:!1});return"bigint"!=typeof r&&Number.isNaN(r)?e:r},co=new Set(["between","notBetween","in","notIn"]),fo=(e,t)=>"bigint"===e||"in"===t||"notIn"===t?"text":e||"text",po=(e,t,n)=>{const r={};for(const o in e){if(Gr(o))continue;const a=t[o];!1!==a&&(a&&o!==a?(Gr(a)||(r[a]=e[o]),n||(r[o]=e[o])):r[o]=e[o])}return r};function ho(e,t={}){const{ruleProcessor:n=e=>e,ruleGroupProcessor:r=e=>e,propertyMap:o={},combinatorMap:a={},operatorMap:i={},omitPath:l=!1,deleteRemappedProperties:s=!0}=t,u=e=>({...r(po({...e,...mr(e)?{combinator:a[e.combinator]??e.combinator}:{}},o,s)),...!1===o.rules?null:{[o.rules??"rules"]:e.rules.map((t,r)=>{const c=l?null:{path:[...e.path,r]};return"string"==typeof t?a[t]??t:hr(t)?u({...t,...c}):n(po({...t,...c,..."operator"in t?{operator:i[t.operator]??t.operator}:{}},o,s))})}});return u({...e,...l?null:{path:[]}})}const mo=e=>fr(e)&&"boolean"==typeof e.valid,go=(e,t,n)=>{if(e.muted)return!1;if("boolean"==typeof t)return t;if(mo(t))return t.valid;if("function"==typeof n&&!hr(e)){const t=n(e);if("boolean"==typeof t)return t;if(mo(t))return t.valid}return!0},vo=({parseNumbers:e,inputType:t})=>{if("string"==typeof e){const[n,r]=e.split("-");return"limited"===r?"number"===t&&n:n}return!!e&&"strict"},bo=(e,t,{concatOperator:n="||",quoteValuesWith:r,wrapValueWith:o=["",""]}={})=>{const[a,i]=(e=>{switch(e){case"contains":case"doesnotcontain":return["%","%"];case"beginswith":case"doesnotbeginwith":return["","%"];case"endswith":case"doesnotendwith":return["%",""];default:return["",""]}})(t),l=r||"'",s=e=>`${o[0]}${l}${e}${l}${o[1]}`,u=[a&&s(a),e,i&&s(i)].filter(Boolean);return u.length>1?((e="||")=>(...t)=>"CONCAT"===e.toUpperCase()?`CONCAT(${t.join(", ")})`:t.join(` ${e} `))(n)(...u):e},yo={"=":"$eq","!=":"$ne","<":"$lt","<=":"$lte",">":"$gt",">=":"$gte",in:"$in",notin:"$nin",notIn:"$nin"},wo={"=":"equals","!=":"not","<":"lt","<=":"lte",">":"gt",">=":"gte",in:"in",notin:"notIn"},So={and:"&&",or:"||"},ko=(e,t)=>({...e,rules:e.rules.map(e=>{if("string"==typeof e)return e;if(hr(e))return ko(e,t);const n=Qr(t.fields,e.field),r=vo({parseNumbers:t.parseNumbers,inputType:n?.inputType});if(Array.isArray(e.value))return{...e,value:e.value.map(e=>uo(e,{parseNumbers:r}))};const o=lr(e.value,{retainEmptyStrings:!0}).map(e=>uo(e,{parseNumbers:r}));if(o.every(e=>"number"==typeof e)){if(o.length>1)return{...e,value:o};if(1===o.length)return{...e,value:o[0]}}return e})}),Eo=e=>"string"==typeof e&&e.length>0||"number"==typeof e&&!Number.isNaN(e)||"string"!=typeof e&&"number"!=typeof e,Oo=(e,t)=>!!t&&("number"==typeof e||"bigint"==typeof e||"string"==typeof e&&dr.test(e)),No=(e=["",""])=>Array.isArray(e)?e:"string"==typeof e?[e,e]:e??["",""],Co=(e,{quoteFieldNamesWith:t,fieldIdentifierSeparator:n})=>{const[r,o]=No(t);return"string"==typeof n&&n.length>0?ar(or(e,n).map(e=>`${r}${e}${o}`),n):`${r}${e}${o}`},Do=["S","V","O"],Ao=(e,t=":")=>{const n=`${e??""}`;return t&&n.startsWith(t)?n:`${t}${n}`},To=(e,t=":")=>{const n=`${e??""}`;return t&&n.startsWith(t)?n.slice(t.length):n},$o={groupPrefix:"",groupPrefix_not_xor:"either zero or more than one of",groupPrefix_xor:"exactly one of",groupSuffix:"is true",groupSuffix_not:"is not true"},Mo=(e,t,n)=>t.startsWith(e)&&n.every(e=>t.includes(`_${e}`)&&t.match(/_/g)?.length===n.length),Ro=(e,t,n=[])=>0===n.length?t[e]??$o[e]?? /* v8 ignore start -- @preserve */"":Object.entries(t).find(([t])=>Mo(e,t,n))?.[1]??Object.entries($o).find(([t])=>Mo(e,t,n))?.[1]??$o[e]?? -/* v8 ignore next -- @preserve */"",xo=e=>{const{mode:t,threshold:n}=e.match??{};if(!t)return null;if(!hr(e.value))return!1;const r=cr(t),o="atleast"===r&&1===n?"some":"atmost"===r&&0===n?"none":r;return("atleast"!==o&&"atmost"!==o&&"exactly"!==o||!("number"!=typeof n||n<0))&&{mode:o,threshold:n}},Io="elem_alias",Po=(e=0)=>e>0?`${Io}_${e}`:Io,_o=(e,t)=>"bigint"==typeof t?{$bigint:t.toString()}:t,Lo=(e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,validateRule:u,validationMap:c}=t,d=(e,f)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return f?r:"";const p=[];let h="",m=!0;for(const r of e.rules){if("string"==typeof r){h=So[r];continue}if(hr(r)){const e=d(r);e&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(e));continue}const[e,c]=u(r);if(!go(r,e,c)||r.field===a||r.operator===i||void 0!==l&&r.value===l)continue;const f=Qr(n,r.field),g=s(r,{...t,parseNumbers:o(f?.inputType),escapeQuotes:"value"===(r.valueSource??"value"),fieldData:f});g&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(g))}const g=p.join(mr(e)?` ${So[e.combinator]} `:" "),[v,b]=e.not||!f?[(e.not?"!":"")+"(",")"]:["",""];return g?`${v}${g}${b}`:r};return d(e,!0)},Go=e=>e.startsWith("not")||e.startsWith("doesnot"),Fo=(e,t)=>"string"==typeof e&&t?e.replaceAll('"','\\"'):`${e}`,zo=(e,t={})=>{const{escapeQuotes:n,parseNumbers:r,preserveValueOrder:o}=t,{field:a,operator:i,value:l,valueSource:s}=e,u="field"===s||"parameter"===s,c=cr("="===i?"==":i),d="number"==typeof l||"boolean"==typeof l||"bigint"==typeof l||Oo(l,r),f=xo(e);if(!1===f)return"";if(f){const{mode:n,threshold:r}=f,o=t.subqueryDepth??0,i=Po(o),l=ho(e.value,{ruleProcessor:e=>({...e,field:`${i}${e.field?`.${e.field}`:""}`})}),s=Lo(l,{...t,subqueryDepth:o+1});switch(n){case"all":return`${a}.all(${i}, ${s})`;case"none":case"some":return`${"none"===n?"!":""}${a}.exists(${i}, ${s})`;case"atleast":case"atmost":case"exactly":{const e=`${a}.filter(${i}, ${s}).size()`,t="atleast"===n?">=":"atmost"===n?"<=":"==";return r>0&&r<1?`double(${e}) ${t} (${`double(${a}.size())`} * ${r})`:`${e} ${t} ${r}`}}}switch(c){case"<":case"<=":case"==":case"!=":case">":case">=":return`${a} ${c} ${u||d?ir(l):`"${Fo(l,n)}"`}`;case"contains":case"doesnotcontain":return`${Go(c)?"!":""}${a}.contains(${u?ir(l):`"${Fo(l,n)}"`})`;case"beginswith":case"doesnotbeginwith":return`${Go(c)?"!":""}${a}.startsWith(${u?ir(l):`"${Fo(l,n)}"`})`;case"endswith":case"doesnotendwith":return`${Go(c)?"!":""}${a}.endsWith(${u?ir(l):`"${Fo(l,n)}"`})`;case"null":return`${a} == null`;case"notnull":return`${a} != null`;case"in":case"notin":{const[e,t]=Go(c)?["!(",")"]:["",""];return`${e}${a} in [${lr(l).map(e=>u||Oo(e,r)?`${ir(e)}`:`"${Fo(e,n)}"`).join(", ")}]${t}`}case"between":case"notbetween":{const e=lr(l);if(e.length>=2&&!pr(e[0])&&!pr(e[1])){const[t,i]=e,l=!(!1===r),s=Oo(t,l)?uo(t,{parseNumbers:l}):NaN,d=Oo(i,l)?uo(i,{parseNumbers:l}):NaN;let f=Number.isNaN(s)?u?`${t}`:`"${Fo(t,n)}"`:s,p=Number.isNaN(d)?u?`${i}`:`"${Fo(i,n)}"`:d;if(!o&&f===s&&p===d&&d= ${f} && ${a} <= ${p})`:`(${a} < ${f} || ${a} > ${p})`}return""}}return""},jo={$and:[{$expr:!0}]},qo=(e,t,n)=>{const{context:r,fields:o,getParseNumberBoolean:a,placeholderFieldName:i,placeholderOperatorName:l,placeholderValueName:s,ruleProcessor:u,validateRule:c,validationMap:d}=t,{inExpressionContext:f}=r??{},p=(e,r)=>{if(!go(e,d[e.id??/* v8 ignore start -- @preserve */""]))return!!r&&jo;const h=`$${cr(e.combinator)}`;let m=!1;const g=e.rules.map(e=>{if(hr(e)){const t=p(e);return!!t&&(m=!0,t)}const[r,d]=c(e);if(!go(e,r,d)||e.field===i||e.operator===l||void 0!==s&&e.value===s)return!1;const f=Qr(o,e.field);return u(e,{...t,parseNumbers:a(f?.inputType),fieldData:f},n)}).filter(Boolean),v=g.length>0?1!==g.length||m?{[h]:g}:g[0]:jo;return e.not?f?{$not:v}:{$nor:[v]}:v};return p(Or(e),!0)},Bo=(e,t,n=!1)=>Oo(e,n||"bigint"==typeof e)?Number(uo(e,{parseNumbers:"strict"})):t,Vo=(e,t={})=>{const{field:n,operator:r,value:o,valueSource:a}=e,{parseNumbers:i,preserveValueOrder:l,context:s}=t,u="field"===a,{avoidFieldsAsKeys:c}=s??{},d=xo(e);if(!1===d)return;if(d){const{mode:e,threshold:r}=d,a={$size:{$ifNull:[`$${n}`,[]]}},i=qo(ho(o,{ruleProcessor:e=>({...e,field:e.field?`${n}.${e.field}`:n})}),{...t,ruleProcessor:Vo,context:{...t.context,avoidFieldsAsKeys:!1}}),l=qo(ho(o,{ruleProcessor:e=>({...e,field:e.field?`$item.${e.field}`:"$item"})}),{...t,ruleProcessor:Vo,context:{...t.context,avoidFieldsAsKeys:!0,inExpressionContext:!0}}),s={$size:{$ifNull:[{$filter:{input:`$${n}`,as:"item",cond:{$and:[l]}}},[]]}};switch(e){case"all":return{$expr:{$eq:[s,a]}};case"none":return{$nor:[i]};case"some":return i;case"atleast":case"atmost":case"exactly":{const t="atleast"===e?yo[">="]:"atmost"===e?yo["<="]:yo["="];return r>0&&r<1?{$expr:{[t]:[s,{$multiply:[a,r]}]}}:{$expr:{[t]:[s,r]}}}}}if("="===r&&!u)return c?{$eq:[`$${n}`,Bo(o,o,i)]}:{[n]:Bo(o,o,i)};const f=cr(r);switch(f){case"<":case"<=":case"=":case"!=":case">":case">=":{const e=yo[f];return u?{[e]:[`$${n}`,`$${o}`]}:c?{$and:[{$ne:[`$${n}`,null]},{[e]:[`$${n}`,Bo(o,o,i)]}]}:{[n]:{[e]:Bo(o,o,i)}}}case"contains":return u?{$where:`this.${n}.includes(this.${o})`}:c?{$regexMatch:{input:`$${n}`,regex:o}}:{[n]:{$regex:o}};case"beginswith":return u?{$where:`this.${n}.startsWith(this.${o})`}:c?{$regexMatch:{input:`$${n}`,regex:`^${o}`}}:{[n]:{$regex:`^${o}`}};case"endswith":return u?{$where:`this.${n}.endsWith(this.${o})`}:c?{$regexMatch:{input:`$${n}`,regex:`${o}$`}}:{[n]:{$regex:`${o}$`}};case"doesnotcontain":return u?{$where:`!this.${n}.includes(this.${o})`}:c?{$not:{$regexMatch:{input:`$${n}`,regex:o}}}:{[n]:{$not:{$regex:o}}};case"doesnotbeginwith":return u?{$where:`!this.${n}.startsWith(this.${o})`}:c?{$not:{$regexMatch:{input:`$${n}`,regex:`^${o}`}}}:{[n]:{$not:{$regex:`^${o}`}}};case"doesnotendwith":return u?{$where:`!this.${n}.endsWith(this.${o})`}:c?{$not:{$regexMatch:{input:`$${n}`,regex:`${o}$`}}}:{[n]:{$not:{$regex:`${o}$`}}};case"null":return c?{$eq:[`$${n}`,null]}:{[n]:null};case"notnull":return c?{$ne:[`$${n}`,null]}:{[n]:{$ne:null}};case"in":case"notin":{const e=lr(o);return u?{$where:`${"notin"===f?"!":""}[${e.map(e=>`this.${e}`).join(",")}].includes(this.${n})`}:c?"notin"===f?{$not:{[yo.in]:[`$${n}`,e.map(e=>Bo(e,e,i))]}}:{[yo[f]]:[`$${n}`,e.map(e=>Bo(e,e,i))]}:{[n]:{[yo[f]]:e.map(e=>Bo(e,e,i))}}}case"between":case"notbetween":{const e=lr(o);if(e.length>=2&&Eo(e[0])&&Eo(e[1])){const[t,r]=e,o=Bo(t,NaN,!0),a=Bo(r,NaN,!0);let i=u||Number.isNaN(o)?t:o,s=u||Number.isNaN(a)?r:a;if(!l&&i===o&&s===a&&a{const n=Vo(e,t);return n?JSON.stringify(n):""},Uo=(e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,validateRule:u,validationMap:c}=t,d=(e,f)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return f?r:"";const p=[];let h="",m=!0;for(const r of e.rules){if("string"==typeof r){h=r;continue}if(hr(r)){const e=d(r);e&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(e));continue}const[e,c]=u(r);if(!go(r,e,c)||r.field===a||r.operator===i||void 0!==l&&r.value===l)continue;const f=Qr(n,r.field),g=s(r,{...t,parseNumbers:o(f?.inputType),escapeQuotes:"value"===(r.valueSource??"value"),fieldData:f});g&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(g))}const g=p.join(mr(e)?` ${e.combinator} `:" "),[v,b]=e.not||!f?[(e.not?"!":"")+"(",")"]:["",""];return g?`${v}${g}${b}`:r};return d(e,!0)},Wo=e=>e.startsWith("not")||e.startsWith("doesnot"),Qo=(e,t)=>t?`!(${e})`:e,Ko=(e,t)=>"string"==typeof e&&t?e.replaceAll("'","\\'"):`${e}`,Xo=(e,t={})=>{const{field:n,operator:r,value:o,valueSource:a}=e,{escapeQuotes:i,parseNumbers:l,preserveValueOrder:s}=t,u="field"===a||"parameter"===a,c=cr("="===r?"==":r),d="number"==typeof o||"boolean"==typeof o||"bigint"==typeof o||Oo(o,l),f=xo(e);if(!1===f)return"";if(f){const{mode:r,threshold:o}=f,a=Uo(ho(e.value,{ruleProcessor:e=>({...e,field:e.field||"#this"})}),t),i=`${n}.size()`,l=`${n}.?[${a}].size()`;switch(r){case"all":return`${l} == ${i}`;case"none":return`${l} == 0`;case"some":return`${l} >= 1`;case"atleast":case"atmost":case"exactly":{const e="atleast"===r?">=":"atmost"===r?"<=":"==";return o>0&&o<1?`${l} ${e} (${i} * ${o})`:`${l} ${e} ${o}`}}}switch(c){case"<":case"<=":case"==":case"!=":case">":case">=":return`${n} ${c} ${u||d?ir(o):`'${Ko(o,i)}'`}`;case"contains":case"doesnotcontain":{const e=u?`'.*'.concat(${ir(o)}).concat('.*')`:`'.*${Ko(o,i)}.*'`;return Qo(`${n} matches ${e}`,Wo(c))}case"beginswith":case"doesnotbeginwith":{const e=u?`'^'.concat(${ir(o)}).concat('.*')`:`'${"string"==typeof o&&!o.startsWith("^")||d?"^":""}${Ko(o,i)}.*'`;return Qo(`${n} matches ${e}`,Wo(c))}case"endswith":case"doesnotendwith":{const e=u?`'.*'.concat(${ir(o)}).concat('$')`:`'.*${Ko(o,i)}${"string"==typeof o&&!o.endsWith("$")||d?"$":""}'`;return Qo(`${n} matches ${e}`,Wo(c))}case"null":return`${n} == null`;case"notnull":return`${n} != null`;case"in":case"notin":{const e=Wo(c)?"!":"",t=lr(o);return t.length>0?`${e}(${t.map(e=>`${n} == ${u||Oo(e,l)?`${ir(e)}`:`'${Ko(e,i)}'`}`).join(" or ")})`:""}case"between":case"notbetween":{const e=lr(o);if(e.length>=2&&!pr(e[0])&&!pr(e[1])){const[t,r]=e,o=!(!1===l),a=Oo(t,o)?uo(t,{parseNumbers:o}):NaN,d=Oo(r,o)?uo(r,{parseNumbers:o}):NaN;let f=Number.isNaN(a)?u?`${t}`:`'${Ko(t,i)}'`:a,p=Number.isNaN(d)?u?`${r}`:`'${Ko(r,i)}'`:d;if(!s&&f===a&&p===d&&d= ${f} and ${n} <= ${p})`:`(${n} < ${f} or ${n} > ${p})`}return""}}return""},Yo=({operator:e,value:t,valueSource:n},{escapeQuotes:r,parseNumbers:o,preserveValueOrder:a,quoteFieldNamesWith:i,quoteValuesWith:l,concatOperator:s="||",fieldIdentifierSeparator:u,paramPrefix:c,wrapValueWith:d=["",""],translations:f}={})=>{if("parameter"===n){const n=cr(e);if("between"===n||"notbetween"===n){const e=lr(t,{retainEmptyStrings:!0});if(e.length<2||!Eo(e[0])||!Eo(e[1]))return"";const[n,r]=e;return[Ao(n,c),Ao(r,c)].join(` ${f?.betweenAnd??f?.and??"and"} `)}if("in"===n||"notin"===n){const e=lr(t);return 0===e.length?"":`(${e.map(e=>Ao(e,c)).join(", ")})`}const r=Ao(t,c);switch(n){case"contains":case"doesnotcontain":case"beginswith":case"doesnotbeginwith":case"endswith":case"doesnotendwith":return bo(r,n,{concatOperator:s,quoteValuesWith:l,wrapValueWith:d})}return r}const p="field"===n,h=cr(e),m=l||"'",g=e=>`${d[0]}${m}${e}${m}${d[1]}`,v=e=>((e,t,n)=>n&&"string"==typeof e?e.replaceAll(`${t}`,`${t}${t}`):e)(e,m,r),b=e=>g(v(e)),y=e=>Co(e,{quoteFieldNamesWith:i,fieldIdentifierSeparator:u}),w={concatOperator:s,quoteValuesWith:l,wrapValueWith:d};switch(h){case"null":case"notnull":return"";case"in":case"notin":{const e=lr(t);return e.length>0?`(${e.map(e=>p?y(e):Oo(e,o)?`${ir(e)}`:`${b(e)}`).join(", ")})`:""}case"between":case"notbetween":{const e=lr(t,{retainEmptyStrings:!0});if(e.length<2||!Eo(e[0])||!Eo(e[1]))return"";const[n,r]=e,i=Oo(n,o)?uo(n,{parseNumbers:"strict"}):NaN,l=Oo(r,o)?uo(r,{parseNumbers:"strict"}):NaN,s=Number.isNaN(i)?p?`${n}`:n:i,u=Number.isNaN(l)?p?`${r}`:r:l,c=[s,u];return!a&&s===i&&u===l&&ly(e)):c.every(e=>Oo(e,o))?c.map(e=>uo(e,{parseNumbers:"strict"})):c.map(e=>b(e))).join(` ${f?.betweenAnd??f?.and??"and"} `)}case"contains":case"doesnotcontain":return p?bo(y(t),h,w):g(`%${v(t)}%`);case"beginswith":case"doesnotbeginwith":return p?bo(y(t),h,w):g(`${v(t)}%`);case"endswith":case"doesnotendwith":return p?bo(y(t),h,w):g(`%${v(t)}`)}return"boolean"==typeof t?t?"TRUE":"FALSE":p?y(t):Oo(t,o)?`${ir(t)}`:`${b(t)}`},Jo={and:"AND",or:"OR"},Zo=(e,t,n)=>(n,r)=>{const{fields:o,getParseNumberBoolean:a,placeholderFieldName:i,placeholderOperatorName:l,placeholderValueName:s,validateRule:u,validationMap:c,ruleProcessor:d}=t;if(!n||!r)return;const{and:f,not:p,or:h}=r,m=(e,g)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return;const v=e.rules.map(e=>{if(hr(e))return m(e);const[c,f]=u(e);if(!go(e,c,f)||e.field===i||e.operator===l||void 0!==s&&e.value===s)return;const p=Qr(o,e.field);return d(e,{...t,parseNumbers:a(p?.inputType),fieldData:p,context:{...t.context,columns:n,drizzleOperators:r}})}).filter(Boolean);if(0===v.length)return;const b="or"===e.combinator?h(...v):f(...v);return e.not?p(b):b};return m(Or(e),!0)},ea=(e,t)=>{const{fields:n,getParseNumberBoolean:r,placeholderFieldName:o,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:l,validateRule:s,validationMap:u}=t,c=e=>{if(!go(e,u[e.id??/* v8 ignore start -- @preserve */""]))return!1;const d=e.rules.map(e=>{if(hr(e))return c(e);const[u,d]=s(e);if(!go(e,u,d)||e.field===o||e.operator===a||void 0!==i&&e.value===i)return!1;const f=Qr(n,e.field);return l(e,{...t,parseNumbers:r(f?.inputType),fieldData:f})}).filter(Boolean);return 0!==d.length&&{bool:e.not?{must_not:/^or$/i.test(e.combinator)?{bool:{should:d}}:d}:{[/^or$/i.test(e.combinator)?"should":"must"]:d}}},d=c(Or(e));return!1===d?{}:d},ta=(e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,validateRule:u,validationMap:c}=t,d=(e,f)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return f?r:"";const p=[];let h="",m=!0;for(const r of e.rules){if("string"==typeof r){h=r;continue}if(hr(r)){const e=d(r);e&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(e));continue}const[e,c]=u(r);if(!go(r,e,c)||r.field===a||r.operator===i||void 0!==l&&r.value===l)continue;const f=Qr(n,r.field),g=s(r,{...t,parseNumbers:o(f?.inputType),escapeQuotes:"value"===(r.valueSource??"value"),fieldData:f});g&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(g))}const g=p.join(mr(e)?` ${e.combinator} `:" "),[v,b]=e.not||!f?[(e.not?"$not":"")+"(",")"]:["",""];return g?`${v}${g}${b}`:r};return d(e,!0)},na=(e,t)=>{const{fields:n,getParseNumberBoolean:r,placeholderFieldName:o,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:l,validateRule:s,validationMap:u}=t,c=Or(e),d=(e,c)=>{if(!go(e,u[e.id??/* v8 ignore start -- @preserve */""]))return!1;const f=e.rules.map(e=>{if(hr(e))return d(e);const[u,c]=s(e);if(!go(e,u,c)||e.field===o||e.operator===a||void 0!==i&&e.value===i)return!1;const f=Qr(n,e.field);return l(e,{...t,parseNumbers:r(f?.inputType),fieldData:f})}).filter(Boolean);if(0===f.length)return!1;const p={[e.combinator]:f};return e.not?{"!":p}:p};return d(c,!0)},ra=e=>e.startsWith("{")&&e.endsWith("}"),oa=(e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,translations:u,validateRule:c,validationMap:d}=t,f=(e,p)=>{if(!go(e,d[e.id??/* v8 ignore start -- @preserve */""]))return p?r:"";const h=gr(e)&&e.rules.some(e=>"string"==typeof e&&"xor"===cr(e))?Or(e):e,m=[];let g="",v=!0;for(const e of h.rules){if("string"==typeof e){g=`${u.ruleSeparator??", "}${u[e]??e} `;continue}if(hr(e)){const t=f(e,1===h.rules.length&&!(h.not||/^xor$/i.test(h.combinator?? +/* v8 ignore next -- @preserve */"",xo=e=>{const{mode:t,threshold:n}=e.match??{};if(!t)return null;if(!hr(e.value))return!1;const r=cr(t),o="atleast"===r&&1===n?"some":"atmost"===r&&0===n?"none":r;return("atleast"!==o&&"atmost"!==o&&"exactly"!==o||!("number"!=typeof n||n<0))&&{mode:o,threshold:n}},Io="elem_alias",Po=(e=0)=>e>0?`${Io}_${e}`:Io,_o=(e,t)=>"bigint"==typeof t?{$bigint:t.toString()}:t,Lo=(e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,validateRule:u,validationMap:c}=t,d=(e,f)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return f?r:"";const p=[];let h="",m=!0;for(const r of e.rules){if("string"==typeof r){h=So[r];continue}if(hr(r)){const e=d(r);e&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(e));continue}const[e,c]=u(r);if(!go(r,e,c)||r.field===a||r.operator===i||void 0!==l&&r.value===l)continue;const f=Qr(n,r.field),g=s(r,{...t,parseNumbers:o(f?.inputType),escapeQuotes:"value"===(r.valueSource??"value"),fieldData:f});g&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(g))}const g=p.join(mr(e)?` ${So[e.combinator]} `:" "),[v,b]=e.not||!f?[(e.not?"!":"")+"(",")"]:["",""];return g?`${v}${g}${b}`:r};return d(e,!0)},Go=e=>e.startsWith("not")||e.startsWith("doesnot"),Fo=(e,t)=>"string"==typeof e&&t?e.replaceAll('"','\\"'):`${e}`,zo=(e,t={})=>{const{escapeQuotes:n,parseNumbers:r,preserveValueOrder:o}=t,{field:a,operator:i,value:l,valueSource:s}=e,u="field"===s||"parameter"===s,c=cr("="===i?"==":i),d="number"==typeof l||"boolean"==typeof l||"bigint"==typeof l||Oo(l,r),f=xo(e);if(!1===f)return"";if(f){const{mode:n,threshold:r}=f,o=t.subqueryDepth??0,i=Po(o),l=ho(e.value,{ruleProcessor:e=>({...e,field:`${i}${e.field?`.${e.field}`:""}`})}),s=Lo(l,{...t,subqueryDepth:o+1});switch(n){case"all":return`${a}.all(${i}, ${s})`;case"none":case"some":return`${"none"===n?"!":""}${a}.exists(${i}, ${s})`;case"atleast":case"atmost":case"exactly":{const e=`${a}.filter(${i}, ${s}).size()`,t="atleast"===n?">=":"atmost"===n?"<=":"==";return r>0&&r<1?`double(${e}) ${t} (${`double(${a}.size())`} * ${r})`:`${e} ${t} ${r}`}}}switch(c){case"<":case"<=":case"==":case"!=":case">":case">=":return`${a} ${c} ${u||d?ir(l):`"${Fo(l,n)}"`}`;case"contains":case"doesnotcontain":return`${Go(c)?"!":""}${a}.contains(${u?ir(l):`"${Fo(l,n)}"`})`;case"beginswith":case"doesnotbeginwith":return`${Go(c)?"!":""}${a}.startsWith(${u?ir(l):`"${Fo(l,n)}"`})`;case"endswith":case"doesnotendwith":return`${Go(c)?"!":""}${a}.endsWith(${u?ir(l):`"${Fo(l,n)}"`})`;case"null":return`${a} == null`;case"notnull":return`${a} != null`;case"in":case"notin":{const[e,t]=Go(c)?["!(",")"]:["",""];return`${e}${a} in [${lr(l).map(e=>u||Oo(e,r)?`${ir(e)}`:`"${Fo(e,n)}"`).join(", ")}]${t}`}case"between":case"notbetween":{const e=lr(l);if(e.length>=2&&!pr(e[0])&&!pr(e[1])){const[t,i]=e,l=!(!1===r),s=Oo(t,l)?uo(t,{parseNumbers:l}):NaN,d=Oo(i,l)?uo(i,{parseNumbers:l}):NaN;let f=Number.isNaN(s)?u?`${t}`:`"${Fo(t,n)}"`:s,p=Number.isNaN(d)?u?`${i}`:`"${Fo(i,n)}"`:d;if(!o&&f===s&&p===d&&d= ${f} && ${a} <= ${p})`:`(${a} < ${f} || ${a} > ${p})`}return""}}return""},jo={$and:[{$expr:!0}]},Vo=(e,t,n)=>{const{context:r,fields:o,getParseNumberBoolean:a,placeholderFieldName:i,placeholderOperatorName:l,placeholderValueName:s,ruleProcessor:u,validateRule:c,validationMap:d}=t,{inExpressionContext:f}=r??{},p=(e,r)=>{if(!go(e,d[e.id??/* v8 ignore start -- @preserve */""]))return!!r&&jo;const h=`$${cr(e.combinator)}`;let m=!1;const g=e.rules.map(e=>{if(hr(e)){const t=p(e);return!!t&&(m=!0,t)}const[r,d]=c(e);if(!go(e,r,d)||e.field===i||e.operator===l||void 0!==s&&e.value===s)return!1;const f=Qr(o,e.field);return u(e,{...t,parseNumbers:a(f?.inputType),fieldData:f},n)}).filter(Boolean),v=g.length>0?1!==g.length||m?{[h]:g}:g[0]:jo;return e.not?f?{$not:v}:{$nor:[v]}:v};return p(Or(e),!0)},qo=(e,t,n=!1)=>Oo(e,n||"bigint"==typeof e)?Number(uo(e,{parseNumbers:"strict"})):t,Bo=(e,t={})=>{const{field:n,operator:r,value:o,valueSource:a}=e,{parseNumbers:i,preserveValueOrder:l,context:s}=t,u="field"===a,{avoidFieldsAsKeys:c}=s??{},d=xo(e);if(!1===d)return;if(d){const{mode:e,threshold:r}=d,a={$size:{$ifNull:[`$${n}`,[]]}},i=Vo(ho(o,{ruleProcessor:e=>({...e,field:e.field?`${n}.${e.field}`:n})}),{...t,ruleProcessor:Bo,context:{...t.context,avoidFieldsAsKeys:!1}}),l=Vo(ho(o,{ruleProcessor:e=>({...e,field:e.field?`$item.${e.field}`:"$item"})}),{...t,ruleProcessor:Bo,context:{...t.context,avoidFieldsAsKeys:!0,inExpressionContext:!0}}),s={$size:{$ifNull:[{$filter:{input:`$${n}`,as:"item",cond:{$and:[l]}}},[]]}};switch(e){case"all":return{$expr:{$eq:[s,a]}};case"none":return{$nor:[i]};case"some":return i;case"atleast":case"atmost":case"exactly":{const t="atleast"===e?yo[">="]:"atmost"===e?yo["<="]:yo["="];return r>0&&r<1?{$expr:{[t]:[s,{$multiply:[a,r]}]}}:{$expr:{[t]:[s,r]}}}}}if("="===r&&!u)return c?{$eq:[`$${n}`,qo(o,o,i)]}:{[n]:qo(o,o,i)};const f=cr(r);switch(f){case"<":case"<=":case"=":case"!=":case">":case">=":{const e=yo[f];return u?{[e]:[`$${n}`,`$${o}`]}:c?{$and:[{$ne:[`$${n}`,null]},{[e]:[`$${n}`,qo(o,o,i)]}]}:{[n]:{[e]:qo(o,o,i)}}}case"contains":return u?{$where:`this.${n}.includes(this.${o})`}:c?{$regexMatch:{input:`$${n}`,regex:o}}:{[n]:{$regex:o}};case"beginswith":return u?{$where:`this.${n}.startsWith(this.${o})`}:c?{$regexMatch:{input:`$${n}`,regex:`^${o}`}}:{[n]:{$regex:`^${o}`}};case"endswith":return u?{$where:`this.${n}.endsWith(this.${o})`}:c?{$regexMatch:{input:`$${n}`,regex:`${o}$`}}:{[n]:{$regex:`${o}$`}};case"doesnotcontain":return u?{$where:`!this.${n}.includes(this.${o})`}:c?{$not:{$regexMatch:{input:`$${n}`,regex:o}}}:{[n]:{$not:{$regex:o}}};case"doesnotbeginwith":return u?{$where:`!this.${n}.startsWith(this.${o})`}:c?{$not:{$regexMatch:{input:`$${n}`,regex:`^${o}`}}}:{[n]:{$not:{$regex:`^${o}`}}};case"doesnotendwith":return u?{$where:`!this.${n}.endsWith(this.${o})`}:c?{$not:{$regexMatch:{input:`$${n}`,regex:`${o}$`}}}:{[n]:{$not:{$regex:`${o}$`}}};case"null":return c?{$eq:[`$${n}`,null]}:{[n]:null};case"notnull":return c?{$ne:[`$${n}`,null]}:{[n]:{$ne:null}};case"in":case"notin":{const e=lr(o);return u?{$where:`${"notin"===f?"!":""}[${e.map(e=>`this.${e}`).join(",")}].includes(this.${n})`}:c?"notin"===f?{$not:{[yo.in]:[`$${n}`,e.map(e=>qo(e,e,i))]}}:{[yo[f]]:[`$${n}`,e.map(e=>qo(e,e,i))]}:{[n]:{[yo[f]]:e.map(e=>qo(e,e,i))}}}case"between":case"notbetween":{const e=lr(o);if(e.length>=2&&Eo(e[0])&&Eo(e[1])){const[t,r]=e,o=qo(t,NaN,!0),a=qo(r,NaN,!0);let i=u||Number.isNaN(o)?t:o,s=u||Number.isNaN(a)?r:a;if(!l&&i===o&&s===a&&a{const n=Bo(e,t);return n?JSON.stringify(n):""},Uo=(e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,validateRule:u,validationMap:c}=t,d=(e,f)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return f?r:"";const p=[];let h="",m=!0;for(const r of e.rules){if("string"==typeof r){h=r;continue}if(hr(r)){const e=d(r);e&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(e));continue}const[e,c]=u(r);if(!go(r,e,c)||r.field===a||r.operator===i||void 0!==l&&r.value===l)continue;const f=Qr(n,r.field),g=s(r,{...t,parseNumbers:o(f?.inputType),escapeQuotes:"value"===(r.valueSource??"value"),fieldData:f});g&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(g))}const g=p.join(mr(e)?` ${e.combinator} `:" "),[v,b]=e.not||!f?[(e.not?"!":"")+"(",")"]:["",""];return g?`${v}${g}${b}`:r};return d(e,!0)},Wo=e=>e.startsWith("not")||e.startsWith("doesnot"),Qo=(e,t)=>t?`!(${e})`:e,Ko=(e,t)=>"string"==typeof e&&t?e.replaceAll("'","\\'"):`${e}`,Xo=(e,t={})=>{const{field:n,operator:r,value:o,valueSource:a}=e,{escapeQuotes:i,parseNumbers:l,preserveValueOrder:s}=t,u="field"===a||"parameter"===a,c=cr("="===r?"==":r),d="number"==typeof o||"boolean"==typeof o||"bigint"==typeof o||Oo(o,l),f=xo(e);if(!1===f)return"";if(f){const{mode:r,threshold:o}=f,a=Uo(ho(e.value,{ruleProcessor:e=>({...e,field:e.field||"#this"})}),t),i=`${n}.size()`,l=`${n}.?[${a}].size()`;switch(r){case"all":return`${l} == ${i}`;case"none":return`${l} == 0`;case"some":return`${l} >= 1`;case"atleast":case"atmost":case"exactly":{const e="atleast"===r?">=":"atmost"===r?"<=":"==";return o>0&&o<1?`${l} ${e} (${i} * ${o})`:`${l} ${e} ${o}`}}}switch(c){case"<":case"<=":case"==":case"!=":case">":case">=":return`${n} ${c} ${u||d?ir(o):`'${Ko(o,i)}'`}`;case"contains":case"doesnotcontain":{const e=u?`'.*'.concat(${ir(o)}).concat('.*')`:`'.*${Ko(o,i)}.*'`;return Qo(`${n} matches ${e}`,Wo(c))}case"beginswith":case"doesnotbeginwith":{const e=u?`'^'.concat(${ir(o)}).concat('.*')`:`'${"string"==typeof o&&!o.startsWith("^")||d?"^":""}${Ko(o,i)}.*'`;return Qo(`${n} matches ${e}`,Wo(c))}case"endswith":case"doesnotendwith":{const e=u?`'.*'.concat(${ir(o)}).concat('$')`:`'.*${Ko(o,i)}${"string"==typeof o&&!o.endsWith("$")||d?"$":""}'`;return Qo(`${n} matches ${e}`,Wo(c))}case"null":return`${n} == null`;case"notnull":return`${n} != null`;case"in":case"notin":{const e=Wo(c)?"!":"",t=lr(o);return t.length>0?`${e}(${t.map(e=>`${n} == ${u||Oo(e,l)?`${ir(e)}`:`'${Ko(e,i)}'`}`).join(" or ")})`:""}case"between":case"notbetween":{const e=lr(o);if(e.length>=2&&!pr(e[0])&&!pr(e[1])){const[t,r]=e,o=!(!1===l),a=Oo(t,o)?uo(t,{parseNumbers:o}):NaN,d=Oo(r,o)?uo(r,{parseNumbers:o}):NaN;let f=Number.isNaN(a)?u?`${t}`:`'${Ko(t,i)}'`:a,p=Number.isNaN(d)?u?`${r}`:`'${Ko(r,i)}'`:d;if(!s&&f===a&&p===d&&d= ${f} and ${n} <= ${p})`:`(${n} < ${f} or ${n} > ${p})`}return""}}return""},Yo=({operator:e,value:t,valueSource:n},{escapeQuotes:r,parseNumbers:o,preserveValueOrder:a,quoteFieldNamesWith:i,quoteValuesWith:l,concatOperator:s="||",fieldIdentifierSeparator:u,paramPrefix:c,wrapValueWith:d=["",""],translations:f}={})=>{if("parameter"===n){const n=cr(e);if("between"===n||"notbetween"===n){const e=lr(t,{retainEmptyStrings:!0});if(e.length<2||!Eo(e[0])||!Eo(e[1]))return"";const[n,r]=e;return[Ao(n,c),Ao(r,c)].join(` ${f?.betweenAnd??f?.and??"and"} `)}if("in"===n||"notin"===n){const e=lr(t);return 0===e.length?"":`(${e.map(e=>Ao(e,c)).join(", ")})`}const r=Ao(t,c);switch(n){case"contains":case"doesnotcontain":case"beginswith":case"doesnotbeginwith":case"endswith":case"doesnotendwith":return bo(r,n,{concatOperator:s,quoteValuesWith:l,wrapValueWith:d})}return r}const p="field"===n,h=cr(e),m=l||"'",g=e=>`${d[0]}${m}${e}${m}${d[1]}`,v=e=>((e,t,n)=>n&&"string"==typeof e?e.replaceAll(`${t}`,`${t}${t}`):e)(e,m,r),b=e=>g(v(e)),y=e=>Co(e,{quoteFieldNamesWith:i,fieldIdentifierSeparator:u}),w={concatOperator:s,quoteValuesWith:l,wrapValueWith:d};switch(h){case"null":case"notnull":return"";case"in":case"notin":{const e=lr(t);return e.length>0?`(${e.map(e=>p?y(e):Oo(e,o)?`${ir(e)}`:`${b(e)}`).join(", ")})`:""}case"between":case"notbetween":{const e=lr(t,{retainEmptyStrings:!0});if(e.length<2||!Eo(e[0])||!Eo(e[1]))return"";const[n,r]=e,i=Oo(n,o)?uo(n,{parseNumbers:"strict"}):NaN,l=Oo(r,o)?uo(r,{parseNumbers:"strict"}):NaN,s=Number.isNaN(i)?p?`${n}`:n:i,u=Number.isNaN(l)?p?`${r}`:r:l,c=[s,u];return!a&&s===i&&u===l&&ly(e)):c.every(e=>Oo(e,o))?c.map(e=>uo(e,{parseNumbers:"strict"})):c.map(e=>b(e))).join(` ${f?.betweenAnd??f?.and??"and"} `)}case"contains":case"doesnotcontain":return p?bo(y(t),h,w):g(`%${v(t)}%`);case"beginswith":case"doesnotbeginwith":return p?bo(y(t),h,w):g(`${v(t)}%`);case"endswith":case"doesnotendwith":return p?bo(y(t),h,w):g(`%${v(t)}`)}return"boolean"==typeof t?t?"TRUE":"FALSE":p?y(t):Oo(t,o)?`${ir(t)}`:`${b(t)}`},Jo={and:"AND",or:"OR"},Zo=(e,t,n)=>(n,r)=>{const{fields:o,getParseNumberBoolean:a,placeholderFieldName:i,placeholderOperatorName:l,placeholderValueName:s,validateRule:u,validationMap:c,ruleProcessor:d}=t;if(!n||!r)return;const{and:f,not:p,or:h}=r,m=(e,g)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return;const v=e.rules.map(e=>{if(hr(e))return m(e);const[c,f]=u(e);if(!go(e,c,f)||e.field===i||e.operator===l||void 0!==s&&e.value===s)return;const p=Qr(o,e.field);return d(e,{...t,parseNumbers:a(p?.inputType),fieldData:p,context:{...t.context,columns:n,drizzleOperators:r}})}).filter(Boolean);if(0===v.length)return;const b="or"===e.combinator?h(...v):f(...v);return e.not?p(b):b};return m(Or(e),!0)},ea=(e,t)=>{const{fields:n,getParseNumberBoolean:r,placeholderFieldName:o,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:l,validateRule:s,validationMap:u}=t,c=e=>{if(!go(e,u[e.id??/* v8 ignore start -- @preserve */""]))return!1;const d=e.rules.map(e=>{if(hr(e))return c(e);const[u,d]=s(e);if(!go(e,u,d)||e.field===o||e.operator===a||void 0!==i&&e.value===i)return!1;const f=Qr(n,e.field);return l(e,{...t,parseNumbers:r(f?.inputType),fieldData:f})}).filter(Boolean);return 0!==d.length&&{bool:e.not?{must_not:/^or$/i.test(e.combinator)?{bool:{should:d}}:d}:{[/^or$/i.test(e.combinator)?"should":"must"]:d}}},d=c(Or(e));return!1===d?{}:d},ta=(e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,validateRule:u,validationMap:c}=t,d=(e,f)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return f?r:"";const p=[];let h="",m=!0;for(const r of e.rules){if("string"==typeof r){h=r;continue}if(hr(r)){const e=d(r);e&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(e));continue}const[e,c]=u(r);if(!go(r,e,c)||r.field===a||r.operator===i||void 0!==l&&r.value===l)continue;const f=Qr(n,r.field),g=s(r,{...t,parseNumbers:o(f?.inputType),escapeQuotes:"value"===(r.valueSource??"value"),fieldData:f});g&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(g))}const g=p.join(mr(e)?` ${e.combinator} `:" "),[v,b]=e.not||!f?[(e.not?"$not":"")+"(",")"]:["",""];return g?`${v}${g}${b}`:r};return d(e,!0)},na=(e,t)=>{const{fields:n,getParseNumberBoolean:r,placeholderFieldName:o,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:l,validateRule:s,validationMap:u}=t,c=Or(e),d=(e,c)=>{if(!go(e,u[e.id??/* v8 ignore start -- @preserve */""]))return!1;const f=e.rules.map(e=>{if(hr(e))return d(e);const[u,c]=s(e);if(!go(e,u,c)||e.field===o||e.operator===a||void 0!==i&&e.value===i)return!1;const f=Qr(n,e.field);return l(e,{...t,parseNumbers:r(f?.inputType),fieldData:f})}).filter(Boolean);if(0===f.length)return!1;const p={[e.combinator]:f};return e.not?{"!":p}:p};return d(c,!0)},ra=e=>e.startsWith("{")&&e.endsWith("}"),oa=(e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,translations:u,validateRule:c,validationMap:d}=t,f=(e,p)=>{if(!go(e,d[e.id??/* v8 ignore start -- @preserve */""]))return p?r:"";const h=gr(e)&&e.rules.some(e=>"string"==typeof e&&"xor"===cr(e))?Or(e):e,m=[];let g="",v=!0;for(const e of h.rules){if("string"==typeof e){g=`${u.ruleSeparator??", "}${u[e]??e} `;continue}if(hr(e)){const t=f(e,1===h.rules.length&&!(h.not||/^xor$/i.test(h.combinator?? /* v8 ignore start -- @preserve */"")));t&&(!v&&g&&(m.push(g),g=""),v=!1,m.push(t));continue}const[r,d]=c(e);if(!go(e,r,d)||e.field===a||e.operator===i||void 0!==l&&e.value===l)continue;const p="value"===(e.valueSource??"value"),b=Qr(n,e.field),y=s(e,{...t,parseNumbers:o(b?.inputType),escapeQuotes:p,fieldData:b});y&&(!v&&g&&(m.push(g),g=""),v=!1,m.push(y))}if(0===m.length)return r;const b="xor"===cr(h.combinator??""),y=b?h.combinator.slice(1):h.combinator,w=h.not||!p||b&&m.length>1,[S,k]=["groupPrefix","groupSuffix"].map(e=>h.not?Ro(e,u,b?["not","xor"]:["not"]):b?Ro(e,u,["xor"]):Ro(e,u)),E=w?`${S} (`.trim():"",O=w?`) ${k}`.trim():"",N=u.ruleSeparator??", ";return`${E}${m.join(mr(h)?`${N}${u[y]??y} `:"")}${O}`};return f(e,!0)},aa=(e,t)=>{const{format:n,fields:r,fallbackExpression:o,getParseNumberBoolean:a,placeholderFieldName:i,placeholderOperatorName:l,placeholderValueName:s,ruleProcessor:u,validateRule:c,validationMap:d}=t,f="parameterized"===n,p=[],h={},m=new Map,g=e=>{m.has(e)||m.set(e,new Set);const t=`${e}_${m.get(e).size+1}`;return m.get(e).add(t),t},v=e=>{const[o,d]=c(e);if(!go(e,o,d)||e.field===i||e.operator===l||void 0!==s&&e.value===s)return"";const f=Qr(r,e.field),v=Object.fromEntries([...m.entries()].map(([e,t])=>[e,[...t]])),b=u(e,{...t,parseNumbers:a(f?.inputType),getNextNamedParam:g,fieldParamNames:v,fieldData:f},{processedParams:p});if(!fr(b))return"";const{sql:y,params:w}=b;if("string"!=typeof y||!y)return"";if("parameterized"===n&&Array.isArray(w))p.push(...w);else if("parameterized_named"===n&&fr(w)){Object.assign(h,w);for(const t of Object.keys(w))m.get(e.field)?.add(t)}return y},b=(e,t)=>{if(!go(e,d[e.id??/* v8 ignore start -- @preserve */""]))return t?o:"";const n=[];let r="",a=!0;for(const t of e.rules){if("string"==typeof t){r=t;continue}if(hr(t)){const o=b(t,1===e.rules.length);o&&(!a&&r&&(n.push(r),r=""),a=!1,n.push(o));continue}const o=v(t);o&&(!a&&r&&(n.push(r),r=""),a=!1,n.push(o))}return 0===n.length?o:`${e.not?"NOT ":""}(${n.join(mr(e)?` ${e.combinator} `:" ")})`};return f?{sql:b(e,!0),params:p}:{sql:b(e,!0),params:h}},ia={},la=(e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,validateRule:u,validationMap:c}=t,d=(e,f)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return f?r:"";const p=[];let h="",m=!0;for(const r of e.rules){if("string"==typeof r){h=r;continue}if(hr(r)){const t=d(r,1===e.rules.length);t&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(t));continue}const[c,f]=u(r);if(!go(r,c,f)||r.field===a||r.operator===i||void 0!==l&&r.value===l)continue;const g="value"===(r.valueSource??"value"),v=Qr(n,r.field),b=s(r,{...t,parseNumbers:o(v?.inputType),escapeQuotes:g,fieldData:v});b&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(b))}return 0===p.length?r:`${e.not?"NOT ":""}(${p.join(mr(e)?` ${e.combinator} `:" ")})`};return d(e,!0)},sa=new Set(["number","range","bigint"]),ua=/^\d{4}-\d{2}-\d{2}$/,ca=/^\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/,da=/^\d{4}-\d{2}$/,fa=/^\d{4}-W\d{2}$/,pa=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,ha=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ma=(e,t,n)=>{const r=new Date(Date.UTC(e,t-1,n));return r.getUTCFullYear()===e&&r.getUTCMonth()===t-1&&r.getUTCDate()===n},ga=e=>{const t=e.split(":"),n=Number(t[0]),r=Number(t[1]),o=t[2]?Number.parseFloat(t[2]):0;return n>=0&&n<=23&&r>=0&&r<=59&&o>=0&&o<60},va=(e,t,n,r,o,a,i,l,s,u,c)=>{const d=e.id??"";if(e.muted&&a.push({id:d,path:t,code:"MUTED",message:"Rule is muted",source:"muted"}),e.field===i&&a.push({id:d,path:t,code:"PLACEHOLDER_FIELD",message:"Rule has a placeholder field",source:"placeholder"}),e.operator===l&&a.push({id:d,path:t,code:"PLACEHOLDER_OPERATOR",message:"Rule has a placeholder operator",source:"placeholder"}),void 0!==s&&e.value===s&&a.push({id:d,path:t,code:"PLACEHOLDER_VALUE",message:"Rule has a placeholder value",source:"placeholder"}),!e.muted&&e.field!==i&&e.operator!==l&&(void 0===s||e.value!==s))if("boolean"!=typeof n||n){if("boolean"!=typeof n&&mo(n)&&!n.valid){const e=n.reasons;a.push({id:d,path:t,code:"CUSTOM_VALIDATOR",message:e?`Invalid: ${e.join(", ")}`:"Rule failed validation",source:"query-validator"})}else if(!o&&"function"==typeof r){const n=r(e),o="boolean"!=typeof n&&mo(n)&&!n.valid?n.reasons:void 0;a.push({id:d,path:t,code:"CUSTOM_VALIDATOR",message:o?`Invalid: ${o.join(", ")}`:"Rule failed field validation",source:"field-validator"})}}else a.push({id:d,path:t,code:"CUSTOM_VALIDATOR",message:"Rule failed validation",source:"query-validator"});if(u&&!c.has(e.field)&&e.field!==i&&a.push({id:d,path:t,code:"UNDEFINED_FIELD",message:`Field "${e.field}" is not defined in the fields config`,source:"field-check"}),u){const n=c.get(e.field);if(n?.inputType){const r=((e,t)=>{if(null!=e&&""!==e){if(sa.has(t)){const t="string"==typeof e?e.trim():e;if("number"==typeof t||"bigint"==typeof t)return;if("string"==typeof t&&dr.test(t))return;return"VALUE_TYPE_MISMATCH"}if("date"===t){if("string"!=typeof e)return"VALUE_TYPE_MISMATCH";const t=e.trim();if(!ua.test(t))return"VALUE_TYPE_MISMATCH";const[n,r,o]=t.split("-").map(Number);return ma(n,r,o)?void 0:"VALUE_TYPE_MISMATCH"}if("datetime-local"===t){if("string"!=typeof e)return"VALUE_TYPE_MISMATCH";const t=e.trim().replace(/(Z|[+-]\d{2}:?\d{2}|[+-]\d{2})$/,""),n=t.indexOf("T");if(-1===n)return"VALUE_TYPE_MISMATCH";const r=t.slice(0,n),o=t.slice(n+1);if(!ua.test(r)||!ca.test(o))return"VALUE_TYPE_MISMATCH";const[a,i,l]=r.split("-").map(Number);return ma(a,i,l)&&ga(o)?void 0:"VALUE_TYPE_MISMATCH"}if("time"===t){if("string"!=typeof e)return"VALUE_TYPE_MISMATCH";const t=e.trim();return ca.test(t)&&ga(t)?void 0:"VALUE_TYPE_MISMATCH"}if("month"===t){if("string"!=typeof e)return"VALUE_TYPE_MISMATCH";const t=e.trim();if(!da.test(t))return"VALUE_TYPE_MISMATCH";const n=Number(t.slice(5));return n>=1&&n<=12?void 0:"VALUE_TYPE_MISMATCH"}if("week"===t){if("string"!=typeof e)return"VALUE_TYPE_MISMATCH";const t=e.trim();if(!fa.test(t))return"VALUE_TYPE_MISMATCH";const n=Number(t.slice(6));return n>=1&&n<=53?void 0:"VALUE_TYPE_MISMATCH"}if("color"===t)return"string"!=typeof e?"VALUE_TYPE_MISMATCH":pa.test(e.trim())?void 0:"VALUE_TYPE_MISMATCH";if("url"===t){if("string"!=typeof e)return"VALUE_TYPE_MISMATCH";try{return void new URL(e.trim())}catch{return"VALUE_TYPE_MISMATCH"}}return"email"===t?"string"!=typeof e?"VALUE_TYPE_MISMATCH":ha.test(e.trim())?void 0:"VALUE_TYPE_MISMATCH":void 0}})(e.value,n.inputType);r&&a.push({id:d,path:t,code:r,message:`Value "${e.value}" is not compatible with input type "${n.inputType}"`,source:"type-check"})}}},ba=e=>{if("boolean"!=typeof e&&mo(e)&&!e.valid&&e.reasons)return e.reasons},ya=(e,t)=>{if("function"==typeof t){const n=t(e);if("boolean"!=typeof n&&mo(n)&&!n.valid&&n.reasons)return n.reasons}},wa=(e,t={})=>{const{escapeQuotes:n,parseNumbers:r}=t,{field:o,operator:a,value:i,valueSource:l}=e,s="field"===l,u=a.toLowerCase(),c=e=>null==e?"null":"boolean"==typeof e||"bigint"==typeof e?String(e):s||"number"==typeof e||Oo(e,r)?ir(e):`'${((e,t)=>"string"==typeof e&&t?e.replaceAll("'","\\'"):`${e}`)(e,n)}'`;switch(u){case"=":return`${o} = ${c(i)}`;case"!=":case"<>":return`${o} <> ${c(i)}`;case"<":case">":case"<=":case">=":return`${o} ${u} ${c(i)}`;case"contains":return`${o} CONTAINS ${c(i)}`;case"doesnotcontain":return`NOT ${o} CONTAINS ${c(i)}`;case"beginswith":return`${o} STARTS WITH ${c(i)}`;case"doesnotbeginwith":return`NOT ${o} STARTS WITH ${c(i)}`;case"endswith":return`${o} ENDS WITH ${c(i)}`;case"doesnotendwith":return`NOT ${o} ENDS WITH ${c(i)}`;case"null":return`${o} IS NULL`;case"notnull":return`${o} IS NOT NULL`;case"in":case"notin":{const e=lr(i).map(c);return e.length?`${"notin"===u?"NOT ":""}${o} IN [${e.join(", ")}]`:""}case"between":case"notbetween":{const e=lr(i);if(e.length<2)return"";const[t,n]=[c(e[0]),c(e[1])],r=`${t} <= ${o} AND ${o} <= ${n}`;return"notbetween"===u?`NOT (${r})`:r}default:return`${o} ${a} ${c(i)}`}},Sa={"<":"lt","<=":"lte",">":"gt",">=":"gte"},ka=(e,t)=>e.startsWith("not")||e.startsWith("doesnot")?{bool:{must_not:t}}:t,Ea=e=>e?.replace(/('|\\)/g,"\\$1"),Oa={beginswith:"startsWith",doesnotbeginwith:"startsWith",doesnotcontain:"contains",doesnotendwith:"endsWith",endswith:"endsWith"},Na=(e,t,n)=>{const r=`doc['${e}'].value.${Oa[t]??t}(doc['${n}'].value)`;return t.startsWith("d")?`!${r}`:r},Ca=(e,t)=>"boolean"==typeof e?e:Oo(e,t)?uo(e,{parseNumbers:t}):e,Da=e=>e.startsWith("not")||e.startsWith("doesnot"),Aa=(e,t)=>`"${"string"==typeof e&&t?e.replaceAll('"','\\"'):`${e}`}"`,Ta=(e,t)=>t?`$not(${e})`:e,$a=e=>`${e}`.replaceAll(/[/$()*+.?[\\\]^{|}]/g,String.raw`\$&`).replaceAll("-",String.raw`\x2d`),Ma=e=>e.replace(/^(=)$/,"$1=").replace(/^notnull$/i,"!=").replace(/^null$/i,"=="),Ra=(e,t)=>e.startsWith("not")||e.startsWith("doesnot")?{"!":t}:t,xa=(e,t={})=>{const{field:n,operator:r,value:o,valueSource:a}=e,{parseNumbers:i,preserveValueOrder:l}=t,s="field"===a,u={var:n},c=e=>s?{var:`${e}`}:Oo(e,i)?uo(e,{parseNumbers:i}):e,d=xo(e);if(!1===d)return!1;if(d){const{mode:e,threshold:r}=d;switch(e){case"all":case"none":case"some":return{[e]:[{var:n},1!==o.rules.length||hr(o.rules[0])?na(o,t):xa(o.rules[0],t)]};case"atleast":case"atmost":case"exactly":{const a="atleast"===e?">=":"atmost"===e?"<=":"==",i={reduce:[{filter:[{var:n},1!==o.rules.length||hr(o.rules[0])?na(o,t):xa(o.rules[0],t)]},{"+":[1,{var:"accumulator"}]},0]};if(r>0&&r<1){const e={reduce:[{var:n},{"+":[1,{var:"accumulator"}]},0]};return{[a]:[i,{"*":[e,r]}]}}return{[a]:[i,r]}}}}const f=cr(r);switch(f){case"<":case"<=":case"=":case"!=":case">":case">=":return{[Ma(f)]:[u,c(o)]};case"null":case"notnull":return{[("notnull"===f?"!":"=")+"="]:[u,null]};case"in":case"notin":{const e=lr(o).map(e=>c(e));return Ra(f,{in:[u,e]})}case"between":case"notbetween":{const e=lr(o);if(e.length>=2&&Eo(e[0])&&Eo(e[1])){let[t,n]=e;const r=!(!1===i);if(!s&&Oo(t,r)&&Oo(n,r)){const e=uo(t,{parseNumbers:r}),o=uo(n,{parseNumbers:r});if(!l&&ot?`(!${e})`:`${e}`,Pa=e=>`${ir(e)}`.replaceAll(/[()&|=<>~*\\/]/g,e=>`\\${e.codePointAt(0).toString(16)}`),_a=(e,t={})=>{const{escapeQuotes:n,fields:r,parseNumbers:o,quoteFieldNamesWith:a,quoteValuesWith:i,fieldIdentifierSeparator:l,translations:s}=t,u="field"===e.valueSource,c=cr(e.operator),d=i||/* v8 ignore start -- @preserve */"'",f=e=>(e=>`${d}${e}${d}`)((e=>((e,t,n)=>n&&"string"==typeof e?e.replaceAll(`${t}`,`${t}${t}`):/* v8 ignore next -- @preserve */e)(e,d,n))(e)),p=e=>Co(e,{quoteFieldNamesWith:a,fieldIdentifierSeparator:l}),h=s??/* v8 ignore start -- @preserve */{},m=h.or??"or",g=h.true??"true",v=h.false??"false",b=h.listSeparator??", ",y=!h.listSeparator;switch(c){case"null":case"notnull":return"";case"between":case"notbetween":{if(!u)return Yo(e,t);const n=lr(e.value,{retainEmptyStrings:!0}).slice(0,2).map(e=>p(Qr(r?? /* v8 ignore start -- @preserve */[],e)?.label??e));return n.length<2||!Eo(n[0])||!Eo(n[1])?"":Yo({...e,value:n},t)}case"in":case"notin":{const t=lr(e.value);if(0===t.length)return"";const n=t.map(e=>u?p(Qr(r?? /* v8 ignore start -- @preserve */[],e)?.label??e):Oo(e,o)?`${ir(e)}`:`${f(e)}`);if(1===n.length)return n[0];const a=y&&n.length>2?",":"";return`(${n.slice(0,-1).join(b)}${a} ${m} ${n.at(-1)})`}}return"boolean"==typeof e.value?e.value?g:v:u?p(Qr(r?? -/* v8 ignore start -- @preserve */[],e.value)?.label??e.value):Oo(e.value,o)?`${ir(e.value)}`:`${f(e.value)}`},La={"=":["is","is the same as the value in"],"!=":["is not","is not the same as the value in"],"<":["is less than","is less than the value in"],">":["is greater than","is greater than the value in"],"<=":["is less than or equal to","is less than or equal to the value in"],">=":["is greater than or equal to","is greater than or equal to the value in"],contains:["contains","contains the value in"],beginswith:["starts with","starts with the value in"],endswith:["ends with","ends with the value in"],doesnotcontain:["does not contain","does not contain the value in"],doesnotbeginwith:["does not start with","does not start with the value in"],doesnotendwith:["does not end with","does not end with the value in"],null:"is null",notnull:"is not null",in:["is one of the values","is the same as a value in"],notin:["is not one of the values","is not the same as any value in"],between:["is between","is between the values in"],notbetween:["is not between","is not between the values in"]},Ga=()=>[],Fa=(e,t={})=>{const{field:n,operator:r,valueSource:o="value"}=e,{getOperators:a=Ga,operatorMap:i=La}=t,l=new Map(Object.entries(La));for(const[e,t]of Object.entries(i))l.set(cr(e),t);const s=Object.fromEntries(l),u=cr(r);var c=r;const d=1===lr(e.value).length;"in"===u&&d?c="=":"notin"===u&&d&&(c="!=");const{value:f,label:p}=Qr(qr(a(n,{fieldData:t.fieldData??{name:n,value:n,label:n}})??/* v8 ignore start -- @preserve */[]),c)??{name:c,value:c,label:c},h=s[f]??s[cr(f)]??[p,p];return"string"==typeof h?h:h["field"===o?1:0]},za=e=>cr((e=>{switch(cr(e)){case"null":return"is null";case"notnull":return"is not null";case"notin":return"not in";case"notbetween":return"not between";case"contains":case"beginswith":case"endswith":return"like";case"doesnotcontain":case"doesnotbeginwith":case"doesnotendwith":return"not like";default:return e}})(e.operator)),ja=(e,t={})=>{const{quoteFieldNamesWith:n=["",""],fieldIdentifierSeparator:r="",quoteValuesWith:o="'",operatorProcessor:a=za,valueProcessor:i=Yo,concatOperator:l="||"}=t,s=e=>Co(e,{quoteFieldNamesWith:n,fieldIdentifierSeparator:r}),u=s(e.field),c=xo(e);if(!1===c)return;if(c){if("postgresql"!==t?.preset)return"";const{mode:n,threshold:r}=c,o=t.subqueryDepth??0,a=Po(o),i=la(ho(e.value,{ruleProcessor:e=>({...e,field:a})}),{...t,subqueryDepth:o+1});switch(n){case"all":return`(select count(*) from unnest(${u}) as ${s(a)} where ${i}) = array_length(${u}, 1)`;case"none":return`not exists (select 1 from unnest(${u}) as ${s(a)} where ${i})`;case"some":return`exists (select 1 from unnest(${u}) as ${s(a)} where ${i})`;case"atleast":case"atmost":case"exactly":{const e="atleast"===n?">=":"atmost"===n?"<=":"=";return`(select count(*)${r>0&&r<1?`::float / array_length(${u}, 1)`:""} from unnest(${u}) as ${s(a)} where ${i}) ${e} ${r}`}}}const d=i(e,{...t,quoteFieldNamesWith:n,fieldIdentifierSeparator:r,quoteValuesWith:o,concatOperator:l}),f=a(e,t),p=cr(f);return"in"!==p&&"not in"!==p&&"between"!==p&&"not between"!==p||d?`${u} ${f} ${d}`.trim():""},qa=(e,t,n)=>{const{fieldData:r,format:o,getNextNamedParam:a,parseNumbers:i,paramPrefix:l,paramsKeepPrefix:s,numberedParams:u,quoteFieldNamesWith:c=["",""],fieldIdentifierSeparator:d,concatOperator:f,operatorProcessor:p=za,valueProcessor:h=Yo}=t??{},{processedParams:m=[]}=n??{},g="parameterized"===o,v=[],b={},y=e=>g?{sql:e,params:v}:{sql:e,params:b},w=e=>Co(e,{quoteFieldNamesWith:c,fieldIdentifierSeparator:d}),S=w(e.field),k=xo(e); +/* v8 ignore start -- @preserve */[],e.value)?.label??e.value):Oo(e.value,o)?`${ir(e.value)}`:`${f(e.value)}`},La={"=":["is","is the same as the value in"],"!=":["is not","is not the same as the value in"],"<":["is less than","is less than the value in"],">":["is greater than","is greater than the value in"],"<=":["is less than or equal to","is less than or equal to the value in"],">=":["is greater than or equal to","is greater than or equal to the value in"],contains:["contains","contains the value in"],beginswith:["starts with","starts with the value in"],endswith:["ends with","ends with the value in"],doesnotcontain:["does not contain","does not contain the value in"],doesnotbeginwith:["does not start with","does not start with the value in"],doesnotendwith:["does not end with","does not end with the value in"],null:"is null",notnull:"is not null",in:["is one of the values","is the same as a value in"],notin:["is not one of the values","is not the same as any value in"],between:["is between","is between the values in"],notbetween:["is not between","is not between the values in"]},Ga=()=>[],Fa=(e,t={})=>{const{field:n,operator:r,valueSource:o="value"}=e,{getOperators:a=Ga,operatorMap:i=La}=t,l=new Map(Object.entries(La));for(const[e,t]of Object.entries(i))l.set(cr(e),t);const s=Object.fromEntries(l),u=cr(r);var c=r;const d=1===lr(e.value).length;"in"===u&&d?c="=":"notin"===u&&d&&(c="!=");const{value:f,label:p}=Qr(Vr(a(n,{fieldData:t.fieldData??{name:n,value:n,label:n}})??/* v8 ignore start -- @preserve */[]),c)??{name:c,value:c,label:c},h=s[f]??s[cr(f)]??[p,p];return"string"==typeof h?h:h["field"===o?1:0]},za=e=>cr((e=>{switch(cr(e)){case"null":return"is null";case"notnull":return"is not null";case"notin":return"not in";case"notbetween":return"not between";case"contains":case"beginswith":case"endswith":return"like";case"doesnotcontain":case"doesnotbeginwith":case"doesnotendwith":return"not like";default:return e}})(e.operator)),ja=(e,t={})=>{const{quoteFieldNamesWith:n=["",""],fieldIdentifierSeparator:r="",quoteValuesWith:o="'",operatorProcessor:a=za,valueProcessor:i=Yo,concatOperator:l="||"}=t,s=e=>Co(e,{quoteFieldNamesWith:n,fieldIdentifierSeparator:r}),u=s(e.field),c=xo(e);if(!1===c)return;if(c){if("postgresql"!==t?.preset)return"";const{mode:n,threshold:r}=c,o=t.subqueryDepth??0,a=Po(o),i=la(ho(e.value,{ruleProcessor:e=>({...e,field:a})}),{...t,subqueryDepth:o+1});switch(n){case"all":return`(select count(*) from unnest(${u}) as ${s(a)} where ${i}) = array_length(${u}, 1)`;case"none":return`not exists (select 1 from unnest(${u}) as ${s(a)} where ${i})`;case"some":return`exists (select 1 from unnest(${u}) as ${s(a)} where ${i})`;case"atleast":case"atmost":case"exactly":{const e="atleast"===n?">=":"atmost"===n?"<=":"=";return`(select count(*)${r>0&&r<1?`::float / array_length(${u}, 1)`:""} from unnest(${u}) as ${s(a)} where ${i}) ${e} ${r}`}}}const d=i(e,{...t,quoteFieldNamesWith:n,fieldIdentifierSeparator:r,quoteValuesWith:o,concatOperator:l}),f=a(e,t),p=cr(f);return"in"!==p&&"not in"!==p&&"between"!==p&&"not between"!==p||d?`${u} ${f} ${d}`.trim():""},Va=(e,t,n)=>{const{fieldData:r,format:o,getNextNamedParam:a,parseNumbers:i,paramPrefix:l,paramsKeepPrefix:s,numberedParams:u,quoteFieldNamesWith:c=["",""],fieldIdentifierSeparator:d,concatOperator:f,operatorProcessor:p=za,valueProcessor:h=Yo}=t??{},{processedParams:m=[]}=n??{},g="parameterized"===o,v=[],b={},y=e=>g?{sql:e,params:v}:{sql:e,params:b},w=e=>Co(e,{quoteFieldNamesWith:c,fieldIdentifierSeparator:d}),S=w(e.field),k=xo(e); /* v8 ignore start -- @preserve */ if(!1===k)return; -/* v8 ignore stop -- @preserve */if(k){if("postgresql"!==t?.preset)return y("");const{mode:n,threshold:r}=k,o=t.subqueryDepth??0,a=Po(o),{sql:i,params:l}=aa(ho(e.value,{ruleProcessor:e=>({...e,field:a})}),{...t,fields:[],subqueryDepth:o+1});switch(Array.isArray(l)?v.push(...l):Object.assign(b,l),n){case"all":return y(`(select count(*) from unnest(${S}) as ${w(a)} where ${i}) = array_length(${S}, 1)`);case"none":return y(`not exists (select 1 from unnest(${S}) as ${w(a)} where ${i})`);case"some":return y(`exists (select 1 from unnest(${S}) as ${w(a)} where ${i})`);case"atleast":case"atmost":case"exactly":{const e="atleast"===n?">=":"atmost"===n?"<=":"=";return y(`(select count(*)${r>0&&r<1?`::float / array_length(${S}, 1)`:""} from unnest(${S}) as ${w(a)} where ${i}) ${e} ${r}`)}}}const E=h(e,{parseNumbers:i,quoteFieldNamesWith:c,concatOperator:f,fieldData:r,format:o}),O=p(e,t),N=cr(O),[C,D]=c;if(!("in"!==N&&"not in"!==N&&"between"!==N&&"not between"!==N||E))return y("");if("is null"===N||"is not null"===N)return y(`${C}${e.field}${D} ${O}`);if("parameter"===e.valueSource){const t=e=>{const t=Ao(e,l);return g||(b[s?t:To(e,l)]=null),t};if("between"===N||"not between"===N){const[n,r]=lr(e.value,{retainEmptyStrings:!0}).slice(0,2);return y(`${C}${e.field}${D} ${O} ${t(n)} and ${t(r)}`.trim())}if("in"===N||"not in"===N){const n=lr(e.value);return y(`${C}${e.field}${D} ${O} (${n.map(e=>t(e)).join(", ")})`)}return y(`${C}${e.field}${D} ${O} ${bo(t(e.value),cr(e.operator),{concatOperator:f})}`.trim())}if("field"===e.valueSource)return y(`${C}${e.field}${D} ${O} ${E}`.trim());if("in"===N||"not in"===N){const t=lr(e.value);if(g){for(const e of t)v.push(Oo(e,i)?uo(e,{parseNumbers:i}):e);return y(`${C}${e.field}${D} ${O} (${t.map((e,n)=>u?`${l}${m.length+1+t.length-(t.length-n)}`:"?").join(", ")})`)}const n=[];for(const r of t){const t=a(e.field);n.push(`${l}${t}`),b[`${s?l:""}${t}`]=Oo(r,i)?uo(r,{parseNumbers:i}):r}return y(`${C}${e.field}${D} ${O} (${n.join(", ")})`)}if("between"===N||"not between"===N){const[t,n]=lr(e.value,{retainEmptyStrings:!0}).slice(0,2).map(e=>Oo(e,i)?uo(e,{parseNumbers:i}):e);if(g)return v.push(t,n),y(`${C}${e.field}${D} ${O} ${u?`${l}${m.length+1}`:"?"} and ${u?`${l}${m.length+2}`:"?"}`);const r=a(e.field),o=a(e.field);return b[`${s?l:""}${r}`]=t,b[`${s?l:""}${o}`]=n,y(`${C}${e.field}${D} ${O} ${l}${r} and ${l}${o}`)}let A=e.value;"string"==typeof e.value&&(A=Oo(e.value,i)?uo(e.value,{parseNumbers:i}):/^'.*'$/g.test(E)?E.replaceAll(/(^'|'$)/g,""):/* v8 ignore next -- @preserve */E);let T="";return g?v.push(A):(T=a(e.field),b[`${s?l:""}${T}`]=A),y(`${C}${e.field}${D} ${O} ${g?u?`${l}${m.length+1}`:"?":`${l}${T}`}`.trim())},Ba=(e,t,n)=>Oo(e,!!n||"bigint"==typeof e)?Number(uo(e,{parseNumbers:!!n})):t,Va=e=>/^[?<]/.test(e)||e.includes(":")?e:`?${e}`,Ha={ansi:{},sqlite:{paramsKeepPrefix:!0},oracle:{},mssql:{concatOperator:"+",quoteFieldNamesWith:["[","]"],fieldIdentifierSeparator:".",paramPrefix:"@"},mysql:{concatOperator:"CONCAT"},postgresql:{quoteFieldNamesWith:'"',numberedParams:!0,paramPrefix:"$"}},Ua={cel:zo,drizzle:(e,t)=>{const n=t??/* v8 ignore start -- @preserve */{},{parseNumbers:r,preserveValueOrder:o,context:a={}}=n,{columns:i,drizzleOperators:l,useRawFields:s}=a;if(!i||!l)return;const{between:u,eq:c,gt:d,gte:f,inArray:p,isNotNull:h,isNull:m,like:g,lt:v,lte:b,ne:y,notBetween:w,notInArray:S,notLike:k,sql:E}=l,{field:O,operator:N,value:C,valueSource:D}=e,A=s&&/^[a-z_][a-z0-9_.]*$/i.test(O)?E.raw(O):i[O],T=cr(N),$="field"===D,M=e=>$?i[e]:e,R=e=>$||!r?M(e):Oo(e,!0)?uo(e,{parseNumbers:!0}):e;if(!A)return;const x=xo(e);if(!1!==x){if(x){if("postgresql"!==n.preset)return;const{mode:t,threshold:r}=x,o=n.subqueryDepth??0,a=Po(o),i=ho(e.value,{ruleProcessor:e=>({...e,field:a})}),s=Zo(i,{...n,context:{...n.context,useRawFields:!0},subqueryDepth:o+1});switch(t){case"all":return E`(select count(*) from unnest(${A}) as ${E.raw(a)} where ${s({},l)}) = array_length(${A}, 1)`;case"none":return E`not exists (select 1 from unnest(${A}) as ${E.raw(a)} where ${s({},l)})`;case"some":return E`exists (select 1 from unnest(${A}) as ${E.raw(a)} where ${s({},l)})`;case"atleast":case"atmost":case"exactly":{const e="atleast"===t?">=":"atmost"===t?"<=":"=";return r>0&&r<1?E`(select count(*)::float / array_length(${A}, 1) from unnest(${A}) as ${E.raw(a)} where ${s({},l)}) ${E.raw(`${e} ${r}`)}`:E`(select count(*) from unnest(${A}) as ${E.raw(a)} where ${s({},l)}) ${E.raw(`${e} ${r}`)}`}}}switch(T){case"=":return c(A,R(C));case"!=":return y(A,R(C));case">":return d(A,R(C));case"<":return v(A,R(C));case">=":return f(A,R(C));case"<=":return b(A,R(C));case"beginswith":case"doesnotbeginwith":return("doesnotbeginwith"===T?k:g)(A,$?E`${M(C)} || '%'`:`${C}%`);case"contains":case"doesnotcontain":return("doesnotcontain"===T?k:g)(A,$?E`'%' || ${M(C)} || '%'`:`%${C}%`);case"endswith":case"doesnotendwith":return("doesnotendwith"===T?k:g)(A,$?E`'%' || ${M(C)}`:`%${C}`);case"null":return m(A);case"notnull":return h(A);case"in":case"notin":{const e=lr(C).map(e=>R(e));return"notin"===T?S(A,e):p(A,e)}case"between":case"notbetween":{const e=lr(C);if(e.length>=2&&Eo(e[0])&&Eo(e[1])){let[t,n]=e;const a=!(!1===r);if(!$&&Oo(t,a)&&Oo(n,a)){const e=uo(t,{parseNumbers:a}),r=uo(n,{parseNumbers:a});if(!o&&r{const{field:n,operator:r,value:o,valueSource:a}=e,{parseNumbers:i,preserveValueOrder:l}=t,s=cr(r),u=xo(e);if(!1===u)return!1;if(u){const{mode:r}=u,o=ea(ho(e.value,{ruleProcessor:e=>({...e,field:e.field?`${n}.${e.field}`:n})}),t);if(0===Object.keys(o).length)return!1;switch(r){case"some":return{nested:{path:n,query:o}};case"none":return{bool:{must_not:{nested:{path:n,query:o}}}};case"all":case"atleast":case"atmost":case"exactly":return!1}}if("field"===a){if(lr(o).some(e=>"string"!=typeof e))return!1;const e=Ea(n);switch(s){case"=":case"!=":case">":case">=":case"<":case"<=":{const t="="===s?"==":s,n=Ea(o);return!!n&&{bool:{filter:{script:{script:`doc['${e}'].value ${t} doc['${n}'].value`}}}}}case"in":case"notin":{const t=lr(o);if(t.length>0){const n=t.map(t=>({bool:{filter:{script:{script:`doc['${e}'].value == doc['${t}'].value`}}}}));return{bool:"in"===s?{should:n}:{must_not:n}}}return!1}case"between":case"notbetween":{const t=lr(o);if(t.length>=2&&t[0]&&t[1]){const n=`doc['${e}'].value >= doc['${t[0]}'].value && doc['${e}'].value <= doc['${t[1]}'].value`;return{bool:{filter:{script:{script:"notbetween"===s?`!(${n})`:n}}}}}return!1}case"contains":case"doesnotcontain":case"beginswith":case"doesnotbeginwith":case"endswith":case"doesnotendwith":{const t=Ea(o);return!!t&&{bool:{filter:{script:{script:Na(e,s,t)}}}}}}}switch(s){case"<":case"<=":case">":case">=":return{range:{[n]:{[Sa[s]]:Ca(o,i)}}};case"=":return{term:{[n]:Ca(o,i)}};case"!=":return{bool:{must_not:{term:{[n]:Ca(o,i)}}}};case"null":return{bool:{must_not:{exists:{field:n}}}};case"notnull":return{exists:{field:n}};case"in":case"notin":{const e=lr(o).map(e=>Ca(e,i));if(e.length>0){const t=e.map(e=>({term:{[n]:Ca(e,i)}}));return{bool:"in"===s?{should:t}:{must_not:t}}}return!1}case"between":case"notbetween":{const e=lr(o);if(e.length>=2&&Eo(e[0])&&Eo(e[1])){let[t,r]=e;const o=!(!1===i);if(Oo(t,o)&&Oo(r,o)){const e=uo(t,{parseNumbers:o}),n=uo(r,{parseNumbers:o});if(!l&&n{const{field:n,operator:r,value:o,valueSource:a}=e,{escapeQuotes:i,parseNumbers:l,preserveValueOrder:s,quoteFieldNamesWith:u=["",""],fieldIdentifierSeparator:c=""}=t,d="field"===a,f="number"==typeof o||"boolean"==typeof o||"bigint"==typeof o||Oo(o,l),p=e=>Co(e,{quoteFieldNamesWith:u,fieldIdentifierSeparator:c}),h=xo(e);if(!1===h)return;if(h){const{mode:e,threshold:r}=h,a=`$count(${p(n)})`,i=`$count($filter(${p(n)}, function($v) {${ta(ho(o,{ruleProcessor:e=>({...e,field:e.field?`$v.${e.field}`:"$v"})}),t)}}))`;switch(e){case"all":return`${i} = ${a}`;case"none":return`${i} = 0`;case"some":return`${i} > 0`;case"atleast":case"atmost":case"exactly":{const t="atleast"===e?">=":"atmost"===e?"<=":"=";return r>0&&r<1?`${i} ${t} (${a} * ${r})`:`${i} ${t} ${r}`}}}const m=cr(r);switch(m){case"<":case"<=":case"=":case"!=":case">":case">=":return`${p(n)} ${m} ${d?p(ir(o)):f?ir(o):Aa(o,i)}`;case"contains":case"doesnotcontain":return Ta(`$contains(${p(n)}, ${d?p(ir(o)):Aa(o,i)})`,Da(m));case"beginswith":case"doesnotbeginwith":return Ta(d?`$substring(${p(n)}, 0, $length(${p(ir(o))})) = ${p(ir(o))}`:`$contains(${p(n)}, /^${$a(o)}/)`,Da(m));case"endswith":case"doesnotendwith":return Ta(d?`$substring(${p(n)}, $length(${p(n)}) - $length(${p(ir(o))})) = ${p(ir(o))}`:`$contains(${p(n)}, /${$a(o)}$/)`,Da(m));case"null":return`${p(n)} = null`;case"notnull":return`${p(n)} != null`;case"in":case"notin":{const e=lr(o);return Ta(`${p(n)} in [${e.map(e=>d?`${p(ir(e))}`:Oo(e,l)?`${ir(e)}`:Aa(e,i)).join(", ")}]`,Da(m))}case"between":case"notbetween":{const e=lr(o);if(e.length<2||pr(e[0])||pr(e[1]))return"";const[t,r]=e,a=!(!1===l),u=Oo(t,a)?uo(t,{parseNumbers:a}):NaN,c=Oo(r,a)?uo(r,{parseNumbers:a}):NaN;let f=Number.isNaN(u)?d?`${t}`:t:u,h=Number.isNaN(c)?d?`${r}`:r:c;if(!s&&f===u&&h===c&&cd?p(e):g?t:Aa(t,i),b=`${p(n)} >= ${v(t,f)} and ${p(n)} <= ${v(r,h)}`;return"between"===m?`(${b})`:Ta(b,!0)}}return""},jsonlogic:xa,ldap:(e,t={})=>{const{field:n,operator:r,value:o,valueSource:a}=e,{preserveValueOrder:i}=t,l=cr(r);if("field"===a||pr(o)&&"null"!==l&&"notnull"!==l||xo(e))return"";switch(l){case"=":case"!=":return Ia(`(${n}=${Pa(o)})`,"!="===l);case">":case">=":return`(${n}>=${Pa(o)})`;case"<":case"<=":return`(${n}<=${Pa(o)})`;case"contains":case"doesnotcontain":return Ia(`(${n}=*${Pa(o)}*)`,"doesnotcontain"===l);case"beginswith":case"doesnotbeginwith":return Ia(`(${n}=${Pa(o)}*)`,"doesnotbeginwith"===l);case"endswith":case"doesnotendwith":return Ia(`(${n}=*${Pa(o)})`,"doesnotendwith"===l);case"null":case"notnull":return Ia(`(${n}=*)`,"notnull"===l);case"in":case"notin":{const e=lr(o);return Ia(`(|${e.map(e=>`(${n}=${Pa(e)})`).join("")})`,"notin"===l)}case"between":case"notbetween":{const e=lr(o);if(e.length<2||pr(e[0])||pr(e[1]))return"";const[t,r]=e,a=Oo(t,!0)?uo(t,{parseNumbers:!0}):NaN,s=Oo(r,!0)?uo(r,{parseNumbers:!0}):NaN;let u=Number.isNaN(a)?t:a,c=Number.isNaN(s)?r:s;if(!i&&u===a&&c===s&&s=${Pa(u)})(${n}<=${Pa(c)}))`,"notbetween"===l)}}return""},mongodb_query:Vo,mongodb:Ho,natural_language:(e,t)=>{const{field:n,operator:r}=e,{fieldData:o,quoteFieldNamesWith:a=["",""],fieldIdentifierSeparator:i="",quoteValuesWith:l="'",operatorProcessor:s=Fa,valueProcessor:u=_a,concatOperator:c="||",wordOrder:d="SVO"}=t??/* v8 ignore start -- @preserve */{},f=Co(o?.label??n,{quoteFieldNamesWith:a,fieldIdentifierSeparator:i}),p=xo(e);if(!1===p)return"";if(p){const{mode:n,threshold:r}=p,a=oa(e.value,{...t,fields:qr(o?.subproperties??[])}),i=(o?.subproperties?.length??0)>0;switch(n){case"all":return`(${i?"for ":""}every item in ${f}${i?",":""} ${a})`;case"none":return`(${i?"for ":""}no item in ${f}${i?",":""} ${a})`;case"some":return`(${i?"for ":""}at least one item in ${f}${i?",":""} ${a})`;case"atleast":case"atmost":case"exactly":{const e=n.replace("at","at ");return r>0&&r<1?`(${i?"for ":""}${e} ${100*r}% of the items in ${f}${i?",":""} ${a})`:`(${i?"for ":""}${e} ${r} of the items in ${f}${i?",":""} ${a})`}}}const h=u(e,{...t,quoteFieldNamesWith:a,fieldIdentifierSeparator:i,quoteValuesWith:l,concatOperator:c}),m=cr(r);if(("in"===m||"notin"===m||"between"===m||"notbetween"===m)&&!h)return"";const g={S:f,V:s(e,t),O:h},v=t?.translations??{},b={S:v.afterSubject??" ",V:v.afterVerb??" ",O:v.afterObject??" "},y=(e=>{const t=[],n=new Set(Do);for(const r of e.toUpperCase())if(n.has(r)&&(t.push(r),n.delete(r),0===n.size))break;for(const e of Do)n.has(e)&&t.push(e);return t})(d).filter(e=>""!==g[e]);return y.map((e,t)=>`${g[e]}${t{const{field:n,operator:r,value:o,valueSource:a}=e,{parseNumbers:i,preserveValueOrder:l}=t;if("field"===a||xo(e))return;const s=cr(r);switch(s){case"=":return{[n]:Ba(o,o,i)};case"!=":case"<":case"<=":case">":case">=":{const e=wo[s];return{[n]:{[e]:Ba(o,o,i)}}}case"contains":return{[n]:{contains:o}};case"beginswith":return{[n]:{startsWith:o}};case"endswith":return{[n]:{endsWith:o}};case"doesnotcontain":return{NOT:{[n]:{contains:o}}};case"doesnotbeginwith":return{NOT:{[n]:{startsWith:o}}};case"doesnotendwith":return{NOT:{[n]:{endsWith:o}}};case"null":return{[n]:null};case"notnull":return{[n]:{not:null}};case"in":case"notin":{const e=lr(o);return{[n]:{[wo[s]]:e.map(e=>Ba(e,e,i))}}}case"between":case"notbetween":{const e=lr(o);if(e.length>=2&&Eo(e[0])&&Eo(e[1])){const[t,r]=e,o=!(!1===i),a=Oo(t,o)?uo(t,{parseNumbers:i}):NaN,u=Oo(r,o)?uo(r,{parseNumbers:i}):NaN;let c=Number.isNaN(a)?t:a,d=Number.isNaN(u)?r:u;if(!l&&c===a&&d===u&&u{const{sequelizeOperators:o,sequelizeCol:a,sequelizeFn:i}=r;if(xo(e))return;const{field:l,operator:s,value:u,valueSource:c}=e,d="field"===c,f=cr(s);if(o&&(!d||a&&(i||!["contains","doesnotcontain","beginswith","doesnotbeginwith","endswith","doesnotendwith"].includes(f))))switch(f){case"=":case"!=":case"<":case"<=":case">":case">=":{const e={"=":o.eq,"!=":o.ne,"<":o.lt,"<=":o.lte,">":o.gt,">=":o.gte}[f];return{[l]:d&&"="===f?{[o.col]:u}:{[e]:d?a(u):Oo(u,t)?uo(u,{parseNumbers:"strict"}):u}}}case"contains":return{[l]:{[d?o.like:o.substring]:d?i("CONCAT","%",a(u),"%"):`${u}`}};case"beginswith":return{[l]:{[d?o.like:o.startsWith]:d?i("CONCAT",a(u),"%"):`${u}`}};case"endswith":return{[l]:{[d?o.like:o.endsWith]:d?i("CONCAT","%",a(u)):`${u}`}};case"doesnotcontain":return{[l]:{[o.notLike]:d?i("CONCAT","%",a(u),"%"):`%${u}%`}};case"doesnotbeginwith":return{[l]:{[o.notLike]:d?i("CONCAT",a(u),"%"):`${u}%`}};case"doesnotendwith":return{[l]:{[o.notLike]:d?i("CONCAT","%",a(u)):`%${u}`}};case"null":return{[l]:{[o.is]:null}};case"notnull":return{[l]:{[o.not]:null}};case"in":case"notin":{const e=lr(u);return{[l]:{["in"===f?o.in:o.notIn]:e.map(e=>d?a(e):Oo(e,t)?uo(e,{parseNumbers:"strict"}):e)}}}case"between":case"notbetween":{const e=lr(u,{retainEmptyStrings:!0});if(e.length<2||!Eo(e[0])||!Eo(e[1]))return;const[r,i]=e,s=Oo(r,t)?uo(r,{parseNumbers:"strict"}):NaN,c=Oo(i,t)?uo(i,{parseNumbers:"strict"}):NaN,p=Number.isNaN(s)?r:s,h=Number.isNaN(c)?i:c,m=[p,h];return!n&&p===s&&h===c&&ca(e)):m.every(e=>Oo(e,t))?m.map(e=>uo(e,{parseNumbers:"strict"})):m}}}}},spel:Xo,sql:ja,tanstack_db:(e,t)=>{const{parseNumbers:n,preserveValueOrder:r,context:o={}}=t??/* v8 ignore start -- @preserve */{},a=o.tanStackDbOperators,i=o._tanstackDbRefs,l=o._tanstackDbPrimaryRef;if(!a||!i||!l)return;const{and:s,eq:u,gt:c,gte:d,inArray:f,isNull:p,like:h,lt:m,lte:g,not:v}=a,b=e=>{const t=e.indexOf(".");if(t>0){const n=e.slice(0,t),r=e.slice(t+1);if(i[n])return i[n][r]}return i[l][e]},{field:y,operator:w,value:S,valueSource:k}=e,E=b(y),O=cr(w),N="field"===k,C=e=>N?b(e):e,D=e=>N||!n?C(e):Oo(e,!0)?uo(e,{parseNumbers:!0}):e;switch(O){case"=":return u(E,D(S));case"!=":return v(u(E,D(S)));case">":return c(E,D(S));case"<":return m(E,D(S));case">=":return d(E,D(S));case"<=":return g(E,D(S));case"beginswith":case"doesnotbeginwith":{const e=h(E,N?void 0:`${S}%`);return"doesnotbeginwith"===O?v(e):e}case"contains":case"doesnotcontain":{const e=h(E,N?void 0:`%${S}%`);return"doesnotcontain"===O?v(e):e}case"endswith":case"doesnotendwith":{const e=h(E,N?void 0:`%${S}`);return"doesnotendwith"===O?v(e):e}case"null":return p(E);case"notnull":return v(p(E));case"in":case"notin":{const e=f(E,lr(S).map(e=>D(e)));return"notin"===O?v(e):e}case"between":case"notbetween":{const e=lr(S);if(e.length>=2&&Eo(e[0])&&Eo(e[1])){let[t,o]=e;const a=!(!1===n);if(!N&&Oo(t,a)&&Oo(o,a)){const e=uo(t,{parseNumbers:a}),n=uo(o,{parseNumbers:a});if(!r&&n{const{escapeQuotes:n,parseNumbers:r}=t,{field:o,operator:a,value:i,valueSource:l}=e,s="field"===l,u=a.toLowerCase(),c=Va(o),d=e=>{if(null==e)return'""';if("boolean"==typeof e)return`"${e}"^^xsd:boolean`;if("bigint"==typeof e)return String(e);if(s)return Va(ir(e));if("number"==typeof e||Oo(e,r))return ir(e); +/* v8 ignore stop -- @preserve */if(k){if("postgresql"!==t?.preset)return y("");const{mode:n,threshold:r}=k,o=t.subqueryDepth??0,a=Po(o),{sql:i,params:l}=aa(ho(e.value,{ruleProcessor:e=>({...e,field:a})}),{...t,fields:[],subqueryDepth:o+1});switch(Array.isArray(l)?v.push(...l):Object.assign(b,l),n){case"all":return y(`(select count(*) from unnest(${S}) as ${w(a)} where ${i}) = array_length(${S}, 1)`);case"none":return y(`not exists (select 1 from unnest(${S}) as ${w(a)} where ${i})`);case"some":return y(`exists (select 1 from unnest(${S}) as ${w(a)} where ${i})`);case"atleast":case"atmost":case"exactly":{const e="atleast"===n?">=":"atmost"===n?"<=":"=";return y(`(select count(*)${r>0&&r<1?`::float / array_length(${S}, 1)`:""} from unnest(${S}) as ${w(a)} where ${i}) ${e} ${r}`)}}}const E=h(e,{parseNumbers:i,quoteFieldNamesWith:c,concatOperator:f,fieldData:r,format:o}),O=p(e,t),N=cr(O),[C,D]=c;if(!("in"!==N&&"not in"!==N&&"between"!==N&&"not between"!==N||E))return y("");if("is null"===N||"is not null"===N)return y(`${C}${e.field}${D} ${O}`);if("parameter"===e.valueSource){const t=e=>{const t=Ao(e,l);return g||(b[s?t:To(e,l)]=null),t};if("between"===N||"not between"===N){const[n,r]=lr(e.value,{retainEmptyStrings:!0}).slice(0,2);return y(`${C}${e.field}${D} ${O} ${t(n)} and ${t(r)}`.trim())}if("in"===N||"not in"===N){const n=lr(e.value);return y(`${C}${e.field}${D} ${O} (${n.map(e=>t(e)).join(", ")})`)}return y(`${C}${e.field}${D} ${O} ${bo(t(e.value),cr(e.operator),{concatOperator:f})}`.trim())}if("field"===e.valueSource)return y(`${C}${e.field}${D} ${O} ${E}`.trim());if("in"===N||"not in"===N){const t=lr(e.value);if(g){for(const e of t)v.push(Oo(e,i)?uo(e,{parseNumbers:i}):e);return y(`${C}${e.field}${D} ${O} (${t.map((e,n)=>u?`${l}${m.length+1+t.length-(t.length-n)}`:"?").join(", ")})`)}const n=[];for(const r of t){const t=a(e.field);n.push(`${l}${t}`),b[`${s?l:""}${t}`]=Oo(r,i)?uo(r,{parseNumbers:i}):r}return y(`${C}${e.field}${D} ${O} (${n.join(", ")})`)}if("between"===N||"not between"===N){const[t,n]=lr(e.value,{retainEmptyStrings:!0}).slice(0,2).map(e=>Oo(e,i)?uo(e,{parseNumbers:i}):e);if(g)return v.push(t,n),y(`${C}${e.field}${D} ${O} ${u?`${l}${m.length+1}`:"?"} and ${u?`${l}${m.length+2}`:"?"}`);const r=a(e.field),o=a(e.field);return b[`${s?l:""}${r}`]=t,b[`${s?l:""}${o}`]=n,y(`${C}${e.field}${D} ${O} ${l}${r} and ${l}${o}`)}let A=e.value;"string"==typeof e.value&&(A=Oo(e.value,i)?uo(e.value,{parseNumbers:i}):/^'.*'$/g.test(E)?E.replaceAll(/(^'|'$)/g,""):/* v8 ignore next -- @preserve */E);let T="";return g?v.push(A):(T=a(e.field),b[`${s?l:""}${T}`]=A),y(`${C}${e.field}${D} ${O} ${g?u?`${l}${m.length+1}`:"?":`${l}${T}`}`.trim())},qa=(e,t,n)=>Oo(e,!!n||"bigint"==typeof e)?Number(uo(e,{parseNumbers:!!n})):t,Ba=e=>/^[?<]/.test(e)||e.includes(":")?e:`?${e}`,Ha={ansi:{},sqlite:{paramsKeepPrefix:!0},oracle:{},mssql:{concatOperator:"+",quoteFieldNamesWith:["[","]"],fieldIdentifierSeparator:".",paramPrefix:"@"},mysql:{concatOperator:"CONCAT"},postgresql:{quoteFieldNamesWith:'"',numberedParams:!0,paramPrefix:"$"}},Ua={cel:zo,drizzle:(e,t)=>{const n=t??/* v8 ignore start -- @preserve */{},{parseNumbers:r,preserveValueOrder:o,context:a={}}=n,{columns:i,drizzleOperators:l,useRawFields:s}=a;if(!i||!l)return;const{between:u,eq:c,gt:d,gte:f,inArray:p,isNotNull:h,isNull:m,like:g,lt:v,lte:b,ne:y,notBetween:w,notInArray:S,notLike:k,sql:E}=l,{field:O,operator:N,value:C,valueSource:D}=e,A=s&&/^[a-z_][a-z0-9_.]*$/i.test(O)?E.raw(O):i[O],T=cr(N),$="field"===D,M=e=>$?i[e]:e,R=e=>$||!r?M(e):Oo(e,!0)?uo(e,{parseNumbers:!0}):e;if(!A)return;const x=xo(e);if(!1!==x){if(x){if("postgresql"!==n.preset)return;const{mode:t,threshold:r}=x,o=n.subqueryDepth??0,a=Po(o),i=ho(e.value,{ruleProcessor:e=>({...e,field:a})}),s=Zo(i,{...n,context:{...n.context,useRawFields:!0},subqueryDepth:o+1});switch(t){case"all":return E`(select count(*) from unnest(${A}) as ${E.raw(a)} where ${s({},l)}) = array_length(${A}, 1)`;case"none":return E`not exists (select 1 from unnest(${A}) as ${E.raw(a)} where ${s({},l)})`;case"some":return E`exists (select 1 from unnest(${A}) as ${E.raw(a)} where ${s({},l)})`;case"atleast":case"atmost":case"exactly":{const e="atleast"===t?">=":"atmost"===t?"<=":"=";return r>0&&r<1?E`(select count(*)::float / array_length(${A}, 1) from unnest(${A}) as ${E.raw(a)} where ${s({},l)}) ${E.raw(`${e} ${r}`)}`:E`(select count(*) from unnest(${A}) as ${E.raw(a)} where ${s({},l)}) ${E.raw(`${e} ${r}`)}`}}}switch(T){case"=":return c(A,R(C));case"!=":return y(A,R(C));case">":return d(A,R(C));case"<":return v(A,R(C));case">=":return f(A,R(C));case"<=":return b(A,R(C));case"beginswith":case"doesnotbeginwith":return("doesnotbeginwith"===T?k:g)(A,$?E`${M(C)} || '%'`:`${C}%`);case"contains":case"doesnotcontain":return("doesnotcontain"===T?k:g)(A,$?E`'%' || ${M(C)} || '%'`:`%${C}%`);case"endswith":case"doesnotendwith":return("doesnotendwith"===T?k:g)(A,$?E`'%' || ${M(C)}`:`%${C}`);case"null":return m(A);case"notnull":return h(A);case"in":case"notin":{const e=lr(C).map(e=>R(e));return"notin"===T?S(A,e):p(A,e)}case"between":case"notbetween":{const e=lr(C);if(e.length>=2&&Eo(e[0])&&Eo(e[1])){let[t,n]=e;const a=!(!1===r);if(!$&&Oo(t,a)&&Oo(n,a)){const e=uo(t,{parseNumbers:a}),r=uo(n,{parseNumbers:a});if(!o&&r{const{field:n,operator:r,value:o,valueSource:a}=e,{parseNumbers:i,preserveValueOrder:l}=t,s=cr(r),u=xo(e);if(!1===u)return!1;if(u){const{mode:r}=u,o=ea(ho(e.value,{ruleProcessor:e=>({...e,field:e.field?`${n}.${e.field}`:n})}),t);if(0===Object.keys(o).length)return!1;switch(r){case"some":return{nested:{path:n,query:o}};case"none":return{bool:{must_not:{nested:{path:n,query:o}}}};case"all":case"atleast":case"atmost":case"exactly":return!1}}if("field"===a){if(lr(o).some(e=>"string"!=typeof e))return!1;const e=Ea(n);switch(s){case"=":case"!=":case">":case">=":case"<":case"<=":{const t="="===s?"==":s,n=Ea(o);return!!n&&{bool:{filter:{script:{script:`doc['${e}'].value ${t} doc['${n}'].value`}}}}}case"in":case"notin":{const t=lr(o);if(t.length>0){const n=t.map(t=>({bool:{filter:{script:{script:`doc['${e}'].value == doc['${t}'].value`}}}}));return{bool:"in"===s?{should:n}:{must_not:n}}}return!1}case"between":case"notbetween":{const t=lr(o);if(t.length>=2&&t[0]&&t[1]){const n=`doc['${e}'].value >= doc['${t[0]}'].value && doc['${e}'].value <= doc['${t[1]}'].value`;return{bool:{filter:{script:{script:"notbetween"===s?`!(${n})`:n}}}}}return!1}case"contains":case"doesnotcontain":case"beginswith":case"doesnotbeginwith":case"endswith":case"doesnotendwith":{const t=Ea(o);return!!t&&{bool:{filter:{script:{script:Na(e,s,t)}}}}}}}switch(s){case"<":case"<=":case">":case">=":return{range:{[n]:{[Sa[s]]:Ca(o,i)}}};case"=":return{term:{[n]:Ca(o,i)}};case"!=":return{bool:{must_not:{term:{[n]:Ca(o,i)}}}};case"null":return{bool:{must_not:{exists:{field:n}}}};case"notnull":return{exists:{field:n}};case"in":case"notin":{const e=lr(o).map(e=>Ca(e,i));if(e.length>0){const t=e.map(e=>({term:{[n]:Ca(e,i)}}));return{bool:"in"===s?{should:t}:{must_not:t}}}return!1}case"between":case"notbetween":{const e=lr(o);if(e.length>=2&&Eo(e[0])&&Eo(e[1])){let[t,r]=e;const o=!(!1===i);if(Oo(t,o)&&Oo(r,o)){const e=uo(t,{parseNumbers:o}),n=uo(r,{parseNumbers:o});if(!l&&n{const{field:n,operator:r,value:o,valueSource:a}=e,{escapeQuotes:i,parseNumbers:l,preserveValueOrder:s,quoteFieldNamesWith:u=["",""],fieldIdentifierSeparator:c=""}=t,d="field"===a,f="number"==typeof o||"boolean"==typeof o||"bigint"==typeof o||Oo(o,l),p=e=>Co(e,{quoteFieldNamesWith:u,fieldIdentifierSeparator:c}),h=xo(e);if(!1===h)return;if(h){const{mode:e,threshold:r}=h,a=`$count(${p(n)})`,i=`$count($filter(${p(n)}, function($v) {${ta(ho(o,{ruleProcessor:e=>({...e,field:e.field?`$v.${e.field}`:"$v"})}),t)}}))`;switch(e){case"all":return`${i} = ${a}`;case"none":return`${i} = 0`;case"some":return`${i} > 0`;case"atleast":case"atmost":case"exactly":{const t="atleast"===e?">=":"atmost"===e?"<=":"=";return r>0&&r<1?`${i} ${t} (${a} * ${r})`:`${i} ${t} ${r}`}}}const m=cr(r);switch(m){case"<":case"<=":case"=":case"!=":case">":case">=":return`${p(n)} ${m} ${d?p(ir(o)):f?ir(o):Aa(o,i)}`;case"contains":case"doesnotcontain":return Ta(`$contains(${p(n)}, ${d?p(ir(o)):Aa(o,i)})`,Da(m));case"beginswith":case"doesnotbeginwith":return Ta(d?`$substring(${p(n)}, 0, $length(${p(ir(o))})) = ${p(ir(o))}`:`$contains(${p(n)}, /^${$a(o)}/)`,Da(m));case"endswith":case"doesnotendwith":return Ta(d?`$substring(${p(n)}, $length(${p(n)}) - $length(${p(ir(o))})) = ${p(ir(o))}`:`$contains(${p(n)}, /${$a(o)}$/)`,Da(m));case"null":return`${p(n)} = null`;case"notnull":return`${p(n)} != null`;case"in":case"notin":{const e=lr(o);return Ta(`${p(n)} in [${e.map(e=>d?`${p(ir(e))}`:Oo(e,l)?`${ir(e)}`:Aa(e,i)).join(", ")}]`,Da(m))}case"between":case"notbetween":{const e=lr(o);if(e.length<2||pr(e[0])||pr(e[1]))return"";const[t,r]=e,a=!(!1===l),u=Oo(t,a)?uo(t,{parseNumbers:a}):NaN,c=Oo(r,a)?uo(r,{parseNumbers:a}):NaN;let f=Number.isNaN(u)?d?`${t}`:t:u,h=Number.isNaN(c)?d?`${r}`:r:c;if(!s&&f===u&&h===c&&cd?p(e):g?t:Aa(t,i),b=`${p(n)} >= ${v(t,f)} and ${p(n)} <= ${v(r,h)}`;return"between"===m?`(${b})`:Ta(b,!0)}}return""},jsonlogic:xa,ldap:(e,t={})=>{const{field:n,operator:r,value:o,valueSource:a}=e,{preserveValueOrder:i}=t,l=cr(r);if("field"===a||pr(o)&&"null"!==l&&"notnull"!==l||xo(e))return"";switch(l){case"=":case"!=":return Ia(`(${n}=${Pa(o)})`,"!="===l);case">":case">=":return`(${n}>=${Pa(o)})`;case"<":case"<=":return`(${n}<=${Pa(o)})`;case"contains":case"doesnotcontain":return Ia(`(${n}=*${Pa(o)}*)`,"doesnotcontain"===l);case"beginswith":case"doesnotbeginwith":return Ia(`(${n}=${Pa(o)}*)`,"doesnotbeginwith"===l);case"endswith":case"doesnotendwith":return Ia(`(${n}=*${Pa(o)})`,"doesnotendwith"===l);case"null":case"notnull":return Ia(`(${n}=*)`,"notnull"===l);case"in":case"notin":{const e=lr(o);return Ia(`(|${e.map(e=>`(${n}=${Pa(e)})`).join("")})`,"notin"===l)}case"between":case"notbetween":{const e=lr(o);if(e.length<2||pr(e[0])||pr(e[1]))return"";const[t,r]=e,a=Oo(t,!0)?uo(t,{parseNumbers:!0}):NaN,s=Oo(r,!0)?uo(r,{parseNumbers:!0}):NaN;let u=Number.isNaN(a)?t:a,c=Number.isNaN(s)?r:s;if(!i&&u===a&&c===s&&s=${Pa(u)})(${n}<=${Pa(c)}))`,"notbetween"===l)}}return""},mongodb_query:Bo,mongodb:Ho,natural_language:(e,t)=>{const{field:n,operator:r}=e,{fieldData:o,quoteFieldNamesWith:a=["",""],fieldIdentifierSeparator:i="",quoteValuesWith:l="'",operatorProcessor:s=Fa,valueProcessor:u=_a,concatOperator:c="||",wordOrder:d="SVO"}=t??/* v8 ignore start -- @preserve */{},f=Co(o?.label??n,{quoteFieldNamesWith:a,fieldIdentifierSeparator:i}),p=xo(e);if(!1===p)return"";if(p){const{mode:n,threshold:r}=p,a=oa(e.value,{...t,fields:Vr(o?.subproperties??[])}),i=(o?.subproperties?.length??0)>0;switch(n){case"all":return`(${i?"for ":""}every item in ${f}${i?",":""} ${a})`;case"none":return`(${i?"for ":""}no item in ${f}${i?",":""} ${a})`;case"some":return`(${i?"for ":""}at least one item in ${f}${i?",":""} ${a})`;case"atleast":case"atmost":case"exactly":{const e=n.replace("at","at ");return r>0&&r<1?`(${i?"for ":""}${e} ${100*r}% of the items in ${f}${i?",":""} ${a})`:`(${i?"for ":""}${e} ${r} of the items in ${f}${i?",":""} ${a})`}}}const h=u(e,{...t,quoteFieldNamesWith:a,fieldIdentifierSeparator:i,quoteValuesWith:l,concatOperator:c}),m=cr(r);if(("in"===m||"notin"===m||"between"===m||"notbetween"===m)&&!h)return"";const g={S:f,V:s(e,t),O:h},v=t?.translations??{},b={S:v.afterSubject??" ",V:v.afterVerb??" ",O:v.afterObject??" "},y=(e=>{const t=[],n=new Set(Do);for(const r of e.toUpperCase())if(n.has(r)&&(t.push(r),n.delete(r),0===n.size))break;for(const e of Do)n.has(e)&&t.push(e);return t})(d).filter(e=>""!==g[e]);return y.map((e,t)=>`${g[e]}${t{const{field:n,operator:r,value:o,valueSource:a}=e,{parseNumbers:i,preserveValueOrder:l}=t;if("field"===a||xo(e))return;const s=cr(r);switch(s){case"=":return{[n]:qa(o,o,i)};case"!=":case"<":case"<=":case">":case">=":{const e=wo[s];return{[n]:{[e]:qa(o,o,i)}}}case"contains":return{[n]:{contains:o}};case"beginswith":return{[n]:{startsWith:o}};case"endswith":return{[n]:{endsWith:o}};case"doesnotcontain":return{NOT:{[n]:{contains:o}}};case"doesnotbeginwith":return{NOT:{[n]:{startsWith:o}}};case"doesnotendwith":return{NOT:{[n]:{endsWith:o}}};case"null":return{[n]:null};case"notnull":return{[n]:{not:null}};case"in":case"notin":{const e=lr(o);return{[n]:{[wo[s]]:e.map(e=>qa(e,e,i))}}}case"between":case"notbetween":{const e=lr(o);if(e.length>=2&&Eo(e[0])&&Eo(e[1])){const[t,r]=e,o=!(!1===i),a=Oo(t,o)?uo(t,{parseNumbers:i}):NaN,u=Oo(r,o)?uo(r,{parseNumbers:i}):NaN;let c=Number.isNaN(a)?t:a,d=Number.isNaN(u)?r:u;if(!l&&c===a&&d===u&&u{const{sequelizeOperators:o,sequelizeCol:a,sequelizeFn:i}=r;if(xo(e))return;const{field:l,operator:s,value:u,valueSource:c}=e,d="field"===c,f=cr(s);if(o&&(!d||a&&(i||!["contains","doesnotcontain","beginswith","doesnotbeginwith","endswith","doesnotendwith"].includes(f))))switch(f){case"=":case"!=":case"<":case"<=":case">":case">=":{const e={"=":o.eq,"!=":o.ne,"<":o.lt,"<=":o.lte,">":o.gt,">=":o.gte}[f];return{[l]:d&&"="===f?{[o.col]:u}:{[e]:d?a(u):Oo(u,t)?uo(u,{parseNumbers:"strict"}):u}}}case"contains":return{[l]:{[d?o.like:o.substring]:d?i("CONCAT","%",a(u),"%"):`${u}`}};case"beginswith":return{[l]:{[d?o.like:o.startsWith]:d?i("CONCAT",a(u),"%"):`${u}`}};case"endswith":return{[l]:{[d?o.like:o.endsWith]:d?i("CONCAT","%",a(u)):`${u}`}};case"doesnotcontain":return{[l]:{[o.notLike]:d?i("CONCAT","%",a(u),"%"):`%${u}%`}};case"doesnotbeginwith":return{[l]:{[o.notLike]:d?i("CONCAT",a(u),"%"):`${u}%`}};case"doesnotendwith":return{[l]:{[o.notLike]:d?i("CONCAT","%",a(u)):`%${u}`}};case"null":return{[l]:{[o.is]:null}};case"notnull":return{[l]:{[o.not]:null}};case"in":case"notin":{const e=lr(u);return{[l]:{["in"===f?o.in:o.notIn]:e.map(e=>d?a(e):Oo(e,t)?uo(e,{parseNumbers:"strict"}):e)}}}case"between":case"notbetween":{const e=lr(u,{retainEmptyStrings:!0});if(e.length<2||!Eo(e[0])||!Eo(e[1]))return;const[r,i]=e,s=Oo(r,t)?uo(r,{parseNumbers:"strict"}):NaN,c=Oo(i,t)?uo(i,{parseNumbers:"strict"}):NaN,p=Number.isNaN(s)?r:s,h=Number.isNaN(c)?i:c,m=[p,h];return!n&&p===s&&h===c&&ca(e)):m.every(e=>Oo(e,t))?m.map(e=>uo(e,{parseNumbers:"strict"})):m}}}}},spel:Xo,sql:ja,tanstack_db:(e,t)=>{const{parseNumbers:n,preserveValueOrder:r,context:o={}}=t??/* v8 ignore start -- @preserve */{},a=o.tanStackDbOperators,i=o._tanstackDbRefs,l=o._tanstackDbPrimaryRef;if(!a||!i||!l)return;const{and:s,eq:u,gt:c,gte:d,inArray:f,isNull:p,like:h,lt:m,lte:g,not:v}=a,b=e=>{const t=e.indexOf(".");if(t>0){const n=e.slice(0,t),r=e.slice(t+1);if(i[n])return i[n][r]}return i[l][e]},{field:y,operator:w,value:S,valueSource:k}=e,E=b(y),O=cr(w),N="field"===k,C=e=>N?b(e):e,D=e=>N||!n?C(e):Oo(e,!0)?uo(e,{parseNumbers:!0}):e;switch(O){case"=":return u(E,D(S));case"!=":return v(u(E,D(S)));case">":return c(E,D(S));case"<":return m(E,D(S));case">=":return d(E,D(S));case"<=":return g(E,D(S));case"beginswith":case"doesnotbeginwith":{const e=h(E,N?void 0:`${S}%`);return"doesnotbeginwith"===O?v(e):e}case"contains":case"doesnotcontain":{const e=h(E,N?void 0:`%${S}%`);return"doesnotcontain"===O?v(e):e}case"endswith":case"doesnotendwith":{const e=h(E,N?void 0:`%${S}`);return"doesnotendwith"===O?v(e):e}case"null":return p(E);case"notnull":return v(p(E));case"in":case"notin":{const e=f(E,lr(S).map(e=>D(e)));return"notin"===O?v(e):e}case"between":case"notbetween":{const e=lr(S);if(e.length>=2&&Eo(e[0])&&Eo(e[1])){let[t,o]=e;const a=!(!1===n);if(!N&&Oo(t,a)&&Oo(o,a)){const e=uo(t,{parseNumbers:a}),n=uo(o,{parseNumbers:a});if(!r&&n{const{escapeQuotes:n,parseNumbers:r}=t,{field:o,operator:a,value:i,valueSource:l}=e,s="field"===l,u=a.toLowerCase(),c=Ba(o),d=e=>{if(null==e)return'""';if("boolean"==typeof e)return`"${e}"^^xsd:boolean`;if("bigint"==typeof e)return String(e);if(s)return Ba(ir(e));if("number"==typeof e||Oo(e,r))return ir(e); /* v8 ignore start -- @preserve */const t="string"==typeof e?e:JSON.stringify(e)??""; -/* v8 ignore stop -- @preserve */return t.startsWith("?")||t.startsWith("<")||t.includes(":")?t:`"${((e,t)=>"string"==typeof e&&t?e.replaceAll('"','\\"'):`${e}`)(t,n)}"`};switch(u){case"=":case"!=":case"<":case">":case"<=":case">=":return`${c} ${u} ${d(i)}`;case"<>":return`${c} != ${d(i)}`;case"contains":return`CONTAINS(${c}, ${d(i)})`;case"doesnotcontain":return`!CONTAINS(${c}, ${d(i)})`;case"beginswith":return`STRSTARTS(${c}, ${d(i)})`;case"doesnotbeginwith":return`!STRSTARTS(${c}, ${d(i)})`;case"endswith":return`STRENDS(${c}, ${d(i)})`;case"doesnotendwith":return`!STRENDS(${c}, ${d(i)})`;case"null":return`!BOUND(${c})`;case"notnull":return`BOUND(${c})`;case"in":{const e=lr(i).map(d);return e.length?`${c} IN (${e.join(", ")})`:""}case"notin":{const e=lr(i).map(d);return e.length?`${c} NOT IN (${e.join(", ")})`:""}case"between":{const e=lr(i);return e.length<2?"":`${c} >= ${d(e[0])} && ${c} <= ${d(e[1])}`}case"notbetween":{const e=lr(i);return e.length<2?"":`(${c} < ${d(e[0])} || ${c} > ${d(e[1])})`}default:return`${c} ${a} ${d(i)}`}},gremlin:(e,t={})=>{const{escapeQuotes:n,parseNumbers:r}=t,{field:o,operator:a,value:i,valueSource:l}=e,s="field"===l,u=a.toLowerCase(),c=o.includes(".")?o.split(".").pop():o,d=e=>null==e?"null":"boolean"==typeof e||"bigint"==typeof e?String(e):s||"number"==typeof e||Oo(e,r)?ir(e):`'${((e,t)=>"string"==typeof e&&t?e.replaceAll("'","\\'"):`${e}`)(e,n)}'`;switch(u){case"=":default:return`.has('${c}', ${d(i)})`;case"!=":case"<>":return`.has('${c}', neq(${d(i)}))`;case"<":return`.has('${c}', lt(${d(i)}))`;case">":return`.has('${c}', gt(${d(i)}))`;case"<=":return`.has('${c}', lte(${d(i)}))`;case">=":return`.has('${c}', gte(${d(i)}))`;case"contains":return`.has('${c}', containing(${d(i)}))`;case"doesnotcontain":return`.has('${c}', notContaining(${d(i)}))`;case"beginswith":return`.has('${c}', startingWith(${d(i)}))`;case"doesnotbeginwith":return`.has('${c}', notStartingWith(${d(i)}))`;case"endswith":return`.has('${c}', endingWith(${d(i)}))`;case"doesnotendwith":return`.has('${c}', notEndingWith(${d(i)}))`;case"null":return`.hasNot('${c}')`;case"notnull":return`.has('${c}')`;case"in":{const e=lr(i).map(d);return e.length?`.has('${c}', within(${e.join(", ")}))`:""}case"notin":{const e=lr(i).map(d);return e.length?`.has('${c}', without(${e.join(", ")}))`:""}case"between":{const e=lr(i);return e.length<2?"":`.has('${c}', between(${d(e[0])}, ${d(e[1])}))`}case"notbetween":{const e=lr(i);return e.length<2?"":`.has('${c}', outside(${d(e[0])}, ${d(e[1])}))`}}},diagnostics:ja},Wa=e=>e.operator,Qa={cel:Wa,drizzle:Wa,elasticsearch:Wa,json_without_ids:Wa,json:Wa,jsonata:Wa,jsonlogic:Wa,ldap:Wa,mongodb_query:Wa,mongodb:Wa,natural_language:Fa,parameterized_named:za,parameterized:za,prisma:Wa,sequelize:Wa,spel:Wa,sql:za,tanstack_db:Wa,cypher:Wa,gql:Wa,sparql:Wa,gremlin:Wa,diagnostics:Wa},Ka={cel:"1 == 1",ldap:"",mongodb:'"$and":[{"$expr":true}]',natural_language:"1 is 1",sparql:"1 = 1",gremlin:"",spel:"1 == 1",sql:"(1 = 1)"},Xa={format:"json",fields:[],quoteFieldNamesWith:["",""],fieldIdentifierSeparator:"",getOperators:()=>[],paramPrefix:":",paramsKeepPrefix:!1,numberedParams:!1,preserveValueOrder:!1,placeholderFieldName:"~",placeholderOperatorName:"~",quoteValuesWith:"'",concatOperator:"||",preset:"ansi",wordOrder:"SVO",translations:{},operatorMap:{}},Ya=new Set(["cel","drizzle","elasticsearch","jsonata","jsonlogic","ldap","mongodb_query","mongodb","prisma","sequelize","spel","tanstack_db"]),Ja=new Set(["sql","parameterized","parameterized_named","drizzle","prisma","sequelize"]);function Za(e,t={}){const n="string"==typeof t?{format:cr(t)}:t,r={...Xa,...!n.format||Ja.has(n.format)?Ha[n.preset??"ansi"]??null:null,...n,...!n.format&&(Object.keys(Ha).includes(n.preset??"")?{format:"sql"}:null)},o=cr(r.format),{fallbackExpression:a,getOperators:i,operatorProcessor:l,parseNumbers:s,quoteFieldNamesWith:u,ruleGroupProcessor:c,ruleProcessor:d,validator:f,valueProcessor:p,context:h}=r,m="function"==typeof l?l:Qa[o]??Wa,g="function"==typeof p?(e=>e.length>=3)(p)?e=>p(e.field,e.operator,e.value,e.valueSource):p:"natural_language"===o?_a:Ya.has(o)?d??Ua[o]:Yo,v=("function"==typeof d?d:null)??(Ya.has(o)&&"function"!=typeof d&&p?g:null)??Ua[o]??ja,b=No(u),y=qr(r.fields),w=a??Ka[o]??Ka.sql;let S={};if("function"==typeof f){const t=f(e);if("boolean"==typeof t){if(!t&&"diagnostics"!==o)return"parameterized"===o?{sql:w,params:[]}:"parameterized_named"===o?{sql:w,params:{}}:"mongodb"===o?`{${w}}`:"mongodb_query"===o?jo:"prisma"===o?ia:"jsonlogic"!==o&&("elasticsearch"===o?{}:"drizzle"===o||"sequelize"===o||"tanstack_db"===o?void 0:w)}else S=t}const k={},E=Xr(y);for(const e of E)"function"==typeof e.validator&&(k[e.value??/* v8 ignore start -- @preserve */e.name]=e.validator);const O={...r,fallbackExpression:w,fields:y,format:o,getOperators:(e,t)=>qr(i(e,t)?? -/* v8 ignore start -- @preserve */[]),getParseNumberBoolean:e=>"string"==typeof vo({parseNumbers:s,inputType:e})||("boolean"==typeof s?s:void 0),quoteFieldNamesWith:b,operatorProcessor:m,ruleProcessor:v,valueProcessor:g,validateRule:e=>{let t,n;if(e.id&&(t=S[e.id]),E.length>0){const t=E.filter(t=>t.name===e.field);if(t.length>0){const e=t[0];"function"==typeof e.validator&&(n=e.validator)}}if("parameter"===e.valueSource&&"function"==typeof r.getParameters){const n=Qr(y,e.field);new Set(Xr(qr(r.getParameters(e.field,e.operator,{fieldData:n}))).map(e=>To(e.value,r.paramPrefix))).has(To(e.value,r.paramPrefix))||(t=!1)}return[t,n]},validationMap:S,context:h};if("function"==typeof c)return c(e,O);switch(o){case"json":case"json_without_ids":{const t=s?ko(e,O):e;return"json_without_ids"===o?JSON.stringify(t,(e,t)=>"id"===e||"path"===e?void 0:_o(0,t)):JSON.stringify(t,_o,2)}case"sql":return la(e,O);case"parameterized":case"parameterized_named":return aa(e,O);case"mongodb":return((e,t,n)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:a,placeholderFieldName:i,placeholderOperatorName:l,placeholderValueName:s,ruleProcessor:u,validateRule:c,validationMap:d}=t,f=(e,p)=>{if(!go(e,d[e.id??/* v8 ignore start -- @preserve */""]))return p?o:"";const h=`"$${cr(e.combinator)}"`;let m=!1;const g=e.rules.map(e=>{if(hr(e)){const t=f(e);return t?(m=!0,ra(t)?t:`{${t}}`):""}const[o,d]=c(e);if(!go(e,o,d)||e.field===i||e.operator===l||void 0!==s&&e.value===s)return"";const p=Qr(r,e.field);return u(e,{...t,parseNumbers:a(p?.inputType),fieldData:p},n)}).filter(Boolean),v=g.length>0?1!==g.length||m?`${h}:[${g.join(",")}]`:g[0]:o;return e.not?`"$nor":[${ra(v)?v:`{${v}}`}]`:v},p=f(Or(e),!0);return ra(p)?p:`{${p}}`})(e,O);case"mongodb_query":return qo(e,O);case"cel":return Lo(e,O);case"spel":return Uo(e,O);case"jsonata":return ta(e,O);case"jsonlogic":return na(e,O);case"elasticsearch":return ea(e,O);case"natural_language":return oa(e,O);case"ldap":return((e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,validateRule:u,validationMap:c}=t,d=(e,f)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return f?r:"";const p=e.rules.map(e=>{if(hr(e))return d(e);const[r,c]=u(e);if(!go(e,r,c)||e.field===a||e.operator===i||void 0!==l&&e.value===l)return"";const f=Qr(n,e.field);return s(e,{...t,parseNumbers:o(f?.inputType),escapeQuotes:"value"===(e.valueSource??"value"),fieldData:f})}).filter(Boolean),h=p.join(""),[m,g]=e.not?["(!",")"]:["",""],[v,b]=p.length>1?[`${m}(${"or"===e.combinator?"|":"&"}`,`)${g}`]:[m,g];return h?`${v}${h}${b}`:r};return d(Or(e),!0)})(e,O);case"prisma":return((e,t)=>{const{fields:n,getParseNumberBoolean:r,placeholderFieldName:o,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:l,validateRule:s,validationMap:u}=t,c=(e,d)=>{if(!go(e,u[e.id??/* v8 ignore start -- @preserve */""]))return d?ia:void 0;const f=e.combinator.toUpperCase();let p=!1;const h=e.rules.map(e=>{if(hr(e)){const t=c(e);return t?(p=!0,t):void 0}const[u,d]=s(e);if(!go(e,u,d)||e.field===o||e.operator===a||void 0!==i&&e.value===i)return;const f=Qr(n,e.field);return l(e,{...t,parseNumbers:r(f?.inputType),fieldData:f})}).filter(Boolean);return h.length>0?1!==h.length||p?{[f]:h}:h[0]:ia},d=c(Or(e),!0);return e.not?{NOT:d}:d})(e,O);case"drizzle":return Zo(e,O);case"tanstack_db":return((e,t)=>n=>{const{fields:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,validateRule:s,validationMap:u,context:c={},ruleProcessor:d}=t,f=c.tanStackDbOperators;if(!f)return;const{and:p,eq:h,not:m,or:g}=f,v=h(1,1),b=Object.keys(n); +/* v8 ignore stop -- @preserve */return t.startsWith("?")||t.startsWith("<")||t.includes(":")?t:`"${((e,t)=>"string"==typeof e&&t?e.replaceAll('"','\\"'):`${e}`)(t,n)}"`};switch(u){case"=":case"!=":case"<":case">":case"<=":case">=":return`${c} ${u} ${d(i)}`;case"<>":return`${c} != ${d(i)}`;case"contains":return`CONTAINS(${c}, ${d(i)})`;case"doesnotcontain":return`!CONTAINS(${c}, ${d(i)})`;case"beginswith":return`STRSTARTS(${c}, ${d(i)})`;case"doesnotbeginwith":return`!STRSTARTS(${c}, ${d(i)})`;case"endswith":return`STRENDS(${c}, ${d(i)})`;case"doesnotendwith":return`!STRENDS(${c}, ${d(i)})`;case"null":return`!BOUND(${c})`;case"notnull":return`BOUND(${c})`;case"in":{const e=lr(i).map(d);return e.length?`${c} IN (${e.join(", ")})`:""}case"notin":{const e=lr(i).map(d);return e.length?`${c} NOT IN (${e.join(", ")})`:""}case"between":{const e=lr(i);return e.length<2?"":`${c} >= ${d(e[0])} && ${c} <= ${d(e[1])}`}case"notbetween":{const e=lr(i);return e.length<2?"":`(${c} < ${d(e[0])} || ${c} > ${d(e[1])})`}default:return`${c} ${a} ${d(i)}`}},gremlin:(e,t={})=>{const{escapeQuotes:n,parseNumbers:r}=t,{field:o,operator:a,value:i,valueSource:l}=e,s="field"===l,u=a.toLowerCase(),c=o.includes(".")?o.split(".").pop():o,d=e=>null==e?"null":"boolean"==typeof e||"bigint"==typeof e?String(e):s||"number"==typeof e||Oo(e,r)?ir(e):`'${((e,t)=>"string"==typeof e&&t?e.replaceAll("'","\\'"):`${e}`)(e,n)}'`;switch(u){case"=":default:return`.has('${c}', ${d(i)})`;case"!=":case"<>":return`.has('${c}', neq(${d(i)}))`;case"<":return`.has('${c}', lt(${d(i)}))`;case">":return`.has('${c}', gt(${d(i)}))`;case"<=":return`.has('${c}', lte(${d(i)}))`;case">=":return`.has('${c}', gte(${d(i)}))`;case"contains":return`.has('${c}', containing(${d(i)}))`;case"doesnotcontain":return`.has('${c}', notContaining(${d(i)}))`;case"beginswith":return`.has('${c}', startingWith(${d(i)}))`;case"doesnotbeginwith":return`.has('${c}', notStartingWith(${d(i)}))`;case"endswith":return`.has('${c}', endingWith(${d(i)}))`;case"doesnotendwith":return`.has('${c}', notEndingWith(${d(i)}))`;case"null":return`.hasNot('${c}')`;case"notnull":return`.has('${c}')`;case"in":{const e=lr(i).map(d);return e.length?`.has('${c}', within(${e.join(", ")}))`:""}case"notin":{const e=lr(i).map(d);return e.length?`.has('${c}', without(${e.join(", ")}))`:""}case"between":{const e=lr(i);return e.length<2?"":`.has('${c}', between(${d(e[0])}, ${d(e[1])}))`}case"notbetween":{const e=lr(i);return e.length<2?"":`.has('${c}', outside(${d(e[0])}, ${d(e[1])}))`}}},diagnostics:ja},Wa=e=>e.operator,Qa={cel:Wa,drizzle:Wa,elasticsearch:Wa,json_without_ids:Wa,json:Wa,jsonata:Wa,jsonlogic:Wa,ldap:Wa,mongodb_query:Wa,mongodb:Wa,natural_language:Fa,parameterized_named:za,parameterized:za,prisma:Wa,sequelize:Wa,spel:Wa,sql:za,tanstack_db:Wa,cypher:Wa,gql:Wa,sparql:Wa,gremlin:Wa,diagnostics:Wa},Ka={cel:"1 == 1",ldap:"",mongodb:'"$and":[{"$expr":true}]',natural_language:"1 is 1",sparql:"1 = 1",gremlin:"",spel:"1 == 1",sql:"(1 = 1)"},Xa={format:"json",fields:[],quoteFieldNamesWith:["",""],fieldIdentifierSeparator:"",getOperators:()=>[],paramPrefix:":",paramsKeepPrefix:!1,numberedParams:!1,preserveValueOrder:!1,placeholderFieldName:"~",placeholderOperatorName:"~",quoteValuesWith:"'",concatOperator:"||",preset:"ansi",wordOrder:"SVO",translations:{},operatorMap:{}},Ya=new Set(["cel","drizzle","elasticsearch","jsonata","jsonlogic","ldap","mongodb_query","mongodb","prisma","sequelize","spel","tanstack_db"]),Ja=new Set(["sql","parameterized","parameterized_named","drizzle","prisma","sequelize"]);function Za(e,t={}){const n="string"==typeof t?{format:cr(t)}:t,r={...Xa,...!n.format||Ja.has(n.format)?Ha[n.preset??"ansi"]??null:null,...n,...!n.format&&(Object.keys(Ha).includes(n.preset??"")?{format:"sql"}:null)},o=cr(r.format),{fallbackExpression:a,getOperators:i,operatorProcessor:l,parseNumbers:s,quoteFieldNamesWith:u,ruleGroupProcessor:c,ruleProcessor:d,validator:f,valueProcessor:p,context:h}=r,m="function"==typeof l?l:Qa[o]??Wa,g="function"==typeof p?(e=>e.length>=3)(p)?e=>p(e.field,e.operator,e.value,e.valueSource):p:"natural_language"===o?_a:Ya.has(o)?d??Ua[o]:Yo,v=("function"==typeof d?d:null)??(Ya.has(o)&&"function"!=typeof d&&p?g:null)??Ua[o]??ja,b=No(u),y=Vr(r.fields),w=a??Ka[o]??Ka.sql;let S={};if("function"==typeof f){const t=f(e);if("boolean"==typeof t){if(!t&&"diagnostics"!==o)return"parameterized"===o?{sql:w,params:[]}:"parameterized_named"===o?{sql:w,params:{}}:"mongodb"===o?`{${w}}`:"mongodb_query"===o?jo:"prisma"===o?ia:"jsonlogic"!==o&&("elasticsearch"===o?{}:"drizzle"===o||"sequelize"===o||"tanstack_db"===o?void 0:w)}else S=t}const k={},E=Xr(y);for(const e of E)"function"==typeof e.validator&&(k[e.value??/* v8 ignore start -- @preserve */e.name]=e.validator);const O={...r,fallbackExpression:w,fields:y,format:o,getOperators:(e,t)=>Vr(i(e,t)?? +/* v8 ignore start -- @preserve */[]),getParseNumberBoolean:e=>"string"==typeof vo({parseNumbers:s,inputType:e})||("boolean"==typeof s?s:void 0),quoteFieldNamesWith:b,operatorProcessor:m,ruleProcessor:v,valueProcessor:g,validateRule:e=>{let t,n;if(e.id&&(t=S[e.id]),E.length>0){const t=E.filter(t=>t.name===e.field);if(t.length>0){const e=t[0];"function"==typeof e.validator&&(n=e.validator)}}if("parameter"===e.valueSource&&"function"==typeof r.getParameters){const n=Qr(y,e.field);new Set(Xr(Vr(r.getParameters(e.field,e.operator,{fieldData:n}))).map(e=>To(e.value,r.paramPrefix))).has(To(e.value,r.paramPrefix))||(t=!1)}return[t,n]},validationMap:S,context:h};if("function"==typeof c)return c(e,O);switch(o){case"json":case"json_without_ids":{const t=s?ko(e,O):e;return"json_without_ids"===o?JSON.stringify(t,(e,t)=>"id"===e||"path"===e?void 0:_o(0,t)):JSON.stringify(t,_o,2)}case"sql":return la(e,O);case"parameterized":case"parameterized_named":return aa(e,O);case"mongodb":return((e,t,n)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:a,placeholderFieldName:i,placeholderOperatorName:l,placeholderValueName:s,ruleProcessor:u,validateRule:c,validationMap:d}=t,f=(e,p)=>{if(!go(e,d[e.id??/* v8 ignore start -- @preserve */""]))return p?o:"";const h=`"$${cr(e.combinator)}"`;let m=!1;const g=e.rules.map(e=>{if(hr(e)){const t=f(e);return t?(m=!0,ra(t)?t:`{${t}}`):""}const[o,d]=c(e);if(!go(e,o,d)||e.field===i||e.operator===l||void 0!==s&&e.value===s)return"";const p=Qr(r,e.field);return u(e,{...t,parseNumbers:a(p?.inputType),fieldData:p},n)}).filter(Boolean),v=g.length>0?1!==g.length||m?`${h}:[${g.join(",")}]`:g[0]:o;return e.not?`"$nor":[${ra(v)?v:`{${v}}`}]`:v},p=f(Or(e),!0);return ra(p)?p:`{${p}}`})(e,O);case"mongodb_query":return Vo(e,O);case"cel":return Lo(e,O);case"spel":return Uo(e,O);case"jsonata":return ta(e,O);case"jsonlogic":return na(e,O);case"elasticsearch":return ea(e,O);case"natural_language":return oa(e,O);case"ldap":return((e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,validateRule:u,validationMap:c}=t,d=(e,f)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return f?r:"";const p=e.rules.map(e=>{if(hr(e))return d(e);const[r,c]=u(e);if(!go(e,r,c)||e.field===a||e.operator===i||void 0!==l&&e.value===l)return"";const f=Qr(n,e.field);return s(e,{...t,parseNumbers:o(f?.inputType),escapeQuotes:"value"===(e.valueSource??"value"),fieldData:f})}).filter(Boolean),h=p.join(""),[m,g]=e.not?["(!",")"]:["",""],[v,b]=p.length>1?[`${m}(${"or"===e.combinator?"|":"&"}`,`)${g}`]:[m,g];return h?`${v}${h}${b}`:r};return d(Or(e),!0)})(e,O);case"prisma":return((e,t)=>{const{fields:n,getParseNumberBoolean:r,placeholderFieldName:o,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:l,validateRule:s,validationMap:u}=t,c=(e,d)=>{if(!go(e,u[e.id??/* v8 ignore start -- @preserve */""]))return d?ia:void 0;const f=e.combinator.toUpperCase();let p=!1;const h=e.rules.map(e=>{if(hr(e)){const t=c(e);return t?(p=!0,t):void 0}const[u,d]=s(e);if(!go(e,u,d)||e.field===o||e.operator===a||void 0!==i&&e.value===i)return;const f=Qr(n,e.field);return l(e,{...t,parseNumbers:r(f?.inputType),fieldData:f})}).filter(Boolean);return h.length>0?1!==h.length||p?{[f]:h}:h[0]:ia},d=c(Or(e),!0);return e.not?{NOT:d}:d})(e,O);case"drizzle":return Zo(e,O);case"tanstack_db":return((e,t)=>n=>{const{fields:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,validateRule:s,validationMap:u,context:c={},ruleProcessor:d}=t,f=c.tanStackDbOperators;if(!f)return;const{and:p,eq:h,not:m,or:g}=f,v=h(1,1),b=Object.keys(n); /* v8 ignore next -- @preserve */ if(0===b.length)return v;const y=e=>{if(!go(e,u[e.id??/* v8 ignore start -- @preserve */""]))return;const f=e.rules.map(e=>{if(hr(e))return y(e);const[u,f]=s(e);if(!go(e,u,f)||e.field===a||e.operator===i||void 0!==l&&e.value===l)return;const p=Qr(r,e.field);return d(e,{...t,parseNumbers:o(p?.inputType),fieldData:p,context:{...c,_tanstackDbRefs:n,_tanstackDbPrimaryRef:b[0]}})}).filter(Boolean);if(0===f.length)return v;const h=1===f.length?f[0]:"or"===e.combinator?g(...f):p(...f);return e.not?m(h):h};return y(Or(e))??v})(e,O);case"sequelize":return((e,t)=>{const{fields:n,getParseNumberBoolean:r,placeholderFieldName:o,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:l,validateRule:s,validationMap:u,context:c={}}=t,{sequelizeOperators:d}=c;if(!d)return;const f=(e,c)=>{if(!go(e,u[e.id??/* v8 ignore start -- @preserve */""]))return;const p=e.combinator.toUpperCase();let h=!1;const m=e.rules.map(e=>{if(hr(e)){const t=f(e);return t?(h=!0,t):void 0}const[u,c]=s(e);if(!go(e,u,c)||e.field===o||e.operator===a||void 0!==i&&e.value===i)return;const d=Qr(n,e.field);return l(e,{...t,parseNumbers:r(d?.inputType),fieldData:d})}).filter(Boolean);if(0===m.length)return;const g=1!==m.length||h?{["or"===cr(p)?d.or:d.and]:m}:m[0];return e.not?{[d.not]:g}:g};return f(Or(e),!0)})(e,O);case"cypher":case"gql":return((e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,validateRule:u,validationMap:c}=t,d=(e,f)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return f?r:"";const p=[];let h="",m=!0;for(const r of e.rules){if("string"==typeof r){h=Jo[r];continue}if(hr(r)){const e=d(r);e&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(e));continue}const[e,c]=u(r);if(!go(r,e,c)||r.field===a||r.operator===i||void 0!==l&&r.value===l)continue;const f=Qr(n,r.field),g=s(r,{...t,parseNumbers:o(f?.inputType),escapeQuotes:"value"===(r.valueSource??"value"),fieldData:f});g&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(g))}const g=p.join(mr(e)?` ${Jo[e.combinator]} `:" "),[v,b]=e.not||!f?[(e.not?"NOT ":"")+"(",")"]:["",""];return g?`${v}${g}${b}`:r};return d(e,!0)})(e,O);case"sparql":return((e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,validateRule:u,validationMap:c}=t,d=(e,f)=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return f?r:"";const p=[];let h="",m=!0;for(const r of e.rules){if("string"==typeof r){h=So[r];continue}if(hr(r)){const e=d(r);e&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(e));continue}const[e,c]=u(r);if(!go(r,e,c)||r.field===a||r.operator===i||void 0!==l&&r.value===l)continue;const f=Qr(n,r.field),g=s(r,{...t,parseNumbers:o(f?.inputType),escapeQuotes:"value"===(r.valueSource??"value"),fieldData:f});g&&(!m&&h&&(p.push(h),h=""),m=!1,p.push(g))}const g=p.join(mr(e)?` ${So[e.combinator]} `:" "),[v,b]=e.not||!f?[(e.not?"!":"")+"(",")"]:["",""];return g?`${v}${g}${b}`:r};return d(e,!0)})(e,O);case"gremlin":return((e,t)=>{const{fields:n,fallbackExpression:r,getParseNumberBoolean:o,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:l,ruleProcessor:s,validateRule:u,validationMap:c}=t,d=e=>{ // v8 ignore next -- @preserve if("string"==typeof e||hr(e))return;const[r,c]=u(e);if(!go(e,r,c)|| /* v8 ignore next 2 -- @preserve */ -e.field===a||e.operator===i||void 0!==l&&e.value===l)return;const d=Qr(n,e.field);return s(e,{...t,parseNumbers:o(d?.inputType),escapeQuotes:"value"===(e.valueSource??"value"),fieldData:d})},f=e=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return"";const t=[];for(const n of e.rules){if("string"==typeof n)continue;if(hr(n)){const e=f(n);e&&t.push(e);continue}const e=d(n);e&&t.push(e)}if(0===t.length)return"";const n=e.combinator??"and",r=e.not?"not":n;return 1!==t.length||e.not?`.${r}(${t.map(e=>e.startsWith(".")?`__${e}`:e).join(", ")})`:t[0]};if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return r;const p=[];for(const t of e.rules){if("string"==typeof t)continue;if(hr(t)){const e=f(t);e&&p.push(e);continue}const e=d(t);e&&p.push(e)}return 0===p.length?r:p.join("")})(e,O);case"diagnostics":return((e,t)=>{const{fields:n,placeholderFieldName:r,placeholderOperatorName:o,placeholderValueName:a,validateRule:i,validationMap:l}=t,s=[],u={totalRules:0,totalGroups:0,validRules:0,invalidRules:0,validGroups:0,invalidGroups:0},c={},d=Xr(n),f=new Map;for(const e of d)f.set(e.name,e);const p=f.size>0,h=(e,t)=>{u.totalGroups++;const n=t.length,d=l[e.id??""],m=go(e,d),g=ba(d);e.muted?s.push({id:e.id??"",path:t,code:"MUTED",message:"Group is muted",source:"muted"}):m||void 0===d||s.push({id:e.id??"",path:t,code:"CUSTOM_VALIDATOR",message:g?`Invalid: ${g.join(", ")}`:"Group failed validation",source:"query-validator"});let v=!0,b=0;const y=[];for(const n of e.rules){if("string"==typeof n){y.push(n),b++;continue}const e=[...t,b];if(hr(n)){const t=h(n,e);t.valid||(v=!1),y.push(t),b++;continue}u.totalRules++;const l=e.length,[d,m]=i(n),g=go(n,d,m)&&n.field!==r&&n.operator!==o&&!(void 0!==a&&n.value===a);va(n,e,d,m,g,s,r,o,a,p,f),g?u.validRules++:(v=!1,u.invalidRules++);const w=n.field;c[w]||(c[w]={ruleCount:0,invalidCount:0}),c[w].ruleCount++,g||c[w].invalidCount++;const S=ba(d)??ya(n,m),k={...n,valid:g,...S?{reasons:S}:null,path:e,level:l};y.push(k),b++}const w=m&&v;return w?u.validGroups++:u.invalidGroups++,mr(e),{...e,valid:w,...g?{reasons:g}:null,path:t,level:n,rules:y}},m=h(e,[]);if(p){const e=new Set(Object.keys(c));for(const[t]of f)e.has(t)||s.push({id:"",path:[],code:"UNREFERENCED_FIELD",message:`Field "${t}" is defined in the fields config but not used in the query`,source:"field-check"})}return{query:m,diagnostics:s,stats:u,fieldSummary:c}})(e,O);default:return""}}const ei=e=>(t,n,r,o)=>e({field:t,operator:n,value:r,valueSource:o},{parseNumbers:!1}),ti=(ei(Yo),ei(Ho),ei(zo),ei(Xo),(e,t)=>{let n=t,r=0;for(;r{if(t.id===e)return t;for(const n of t.rules)if("string"!=typeof n){if(n.id===e)return n;if(hr(n)){const t=ni(e,n);if(t)return t}}return null},ri=(e,t)=>{if(t.id===e)return[];const n=t.rules.findIndex(t=>!("string"==typeof t)&&t.id===e);if(n>=0)return[n];for(const[n,r]of Object.entries(t.rules))if(hr(r)){const t=ri(e,r);if(Array.isArray(t))return[Number.parseInt(n),...t]}return null},oi=e=>e.slice(0,-1),ai=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n{if(e.length>=t.length)return!1;for(let n=0;n{const n=[],r=oi(e),o=oi(t);let a=0;for(;a{let n=!!t.disabled,r=t,o=0;for(;oai([],e.path)?"Query builder":`Rule group at path ${e.path.join("-")}`,ci=globalThis.crypto;let di=()=>"00-0-4-2-000".replaceAll(/[^-]/g,e=>(65536*(Math.random()+Math.trunc(e))>>Number.parseInt(e)).toString(16).padStart(4,"0"));if(ci)if("function"==typeof ci.randomUUID)di=()=>ci.randomUUID();else if("function"==typeof ci.getRandomValues){const e="89ab",t=new Uint32Array(32);di=()=>{ci.getRandomValues(t);let n=(t[0]%16).toString(16);for(let r=1;r<32;r++)n=12===r?`${n}4`:16===r?`${n}${e[t[17]%4]}`:`${n}${(t[r]%16).toString(16)}`,7!==r&&11!==r&&15!==r&&19!==r||(n=`${n}-`);return n}}const fi=new en({autoFreeze:!1}),pi=(e=!0)=>e?an:fi.produce,hi={name:"name",value:"name",matchModes:null,label:"label"},mi=(e,t)=>{const n=e?jr(e):/* v8 ignore next -- @preserve */hi;let r=n.matchModes??!1;return!r&&t&&(r=t(n.value,{fieldData:n})),!0===r?pn:!1===r?[]:Ur(r)?qr(r):r?.map(e=>pn.find(t=>t.value===cr(e))??{name:e,value:e,label:e})??[]},gi=(e,t,n)=>{const r=Kr(e);if("between"===t.operator||"notBetween"===t.operator){const e=[r,r];return n?e:ar(e.map(e=>e??/* v8 ignore start -- @preserve */""),",")}return r},vi=(e,t)=>{const{fieldData:n,fields:r,getValueEditorType:o,getValues:a,getDefaultValue:i,getParameters:l,listsAsArrays:s}=t;if(void 0!==n?.defaultValue&&null!==n.defaultValue)return n.defaultValue;if(i)return i(e,{fieldData:n});let u="";const c=a(e.field,e.operator,{fieldData:n});if("field"===e.valueSource){const t=eo(n,r,e.operator);u=t.length>0?gi(t,e,s):""}else if("parameter"===e.valueSource){const t=l?l(e.field,e.operator,{fieldData:n}):null;u=t&&t.length>0?Kr(t):""}else if(c.length>0){const t=o(e.field,e.operator,{fieldData:n});"multiselect"===t?u=s?[]:"":"select"!==t&&"radio"!==t||(u=gi(c,e,s))}else"checkbox"===o(e.field,e.operator,{fieldData:n})&&(u=!1);return u},bi=e=>{const t="boolean"==typeof e?e:"object"==typeof e&&null!==e?e.valid:null;return"boolean"==typeof t?t?hn.valid:hn.invalid:""},yi=[{name:"value",value:"value",label:"value"}],wi={name:"name",value:"name",valueSources:null,label:"label"},Si=(e,t,n)=>{const r=e?jr(e):wi;let o=r.valueSources??!1;return"function"==typeof o&&(o=o(t)),!o&&n&&(o=n(r.value,t,{fieldData:r})),o?Ur(o)?qr(o):o.map(e=>yi.find(t=>t.value===cr(e))??{name:e,value:e,label:e}):yi},ki=(e,t,n)=>{if(Gr(e))return;const r=Lr(t).map(([t,[r,o]])=>[t,r??o??n?.[e]?.[t]]).filter(e=>!Gr(e[0])&&!!e[1]);if(r.length>0||n){const t=n?.[e]??{},o=Object.assign({},t,Object.fromEntries(r));return{[e]:o}}},Ei=(e,t)=>{let n="";for(let r=0;rJr({optionList:t?.operators??n?.(e,{fieldData:t})??r,placeholder:o,baseOption:a,labelMap:un,autoSelectOption:i}).optionList,Ni=({field:e,fieldData:t,getDefaultOperator:n,getOperators:r})=>t?.defaultOperator?t.defaultOperator:n?"function"==typeof n?n(e,{fieldData:t}):n:Kr(r(e,{fieldData:t}))??"",Ci=({field:e,operator:t,fieldData:n,getValueEditorType:r})=>n?.valueEditorType?"function"==typeof n.valueEditorType?n.valueEditorType(t):n.valueEditorType:r?.(e,t,{fieldData:n})??"text",Di=({field:e,operator:t,fieldData:n,getValues:r,placeholder:o,baseOption:a,autoSelectOption:i})=>Jr({optionList:n?.values??r?.(e,t,{fieldData:n})??[],placeholder:o,baseOption:a,autoSelectOption:i}).optionList,Ai=(e,t)=>{if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>Ai(e,t[n]));if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)||!(e=>{const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype})(e))return!1;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Ai(e[n],t[n]))},Ti=(e,t,n,r)=>r?t??n:e?((e,t)=>!(!1===e||!e&&!1===t))(t,n):((e,t)=>!!e||!1!==e&&!!t)(t,n),$i=(e,t,n)=>void 0!==t&&null!=t?t:void 0!==n&&null!=n?n:e,Mi=(e,{idGenerator:t=di}={})=>{const n=!e.id,r=xo(e);return n||r?{...e,...n&&{id:t()},...r&&{value:Ri(e.value,{idGenerator:t})}}:e},Ri=(e,{idGenerator:t=di}={})=>{const n=!e.id;let r=!1;const o=[];for(let n=0;nhr(e)?Ri(e,{idGenerator:t}):Mi(e,{idGenerator:t}),Ii=(e,{idGenerator:t=di}={})=>{if(!fr(e))return e;if(!hr(e))return structuredClone({...e,id:t()});const n={...e,id:t()};return Array.isArray(n.rules)&&(n.rules=e.rules.map(e=>"string"==typeof e?e:hr(e)?Ii(e,{idGenerator:t}):((e,{idGenerator:t=di}={})=>structuredClone({...e,id:t()}))(e,{idGenerator:t}))),n},Pi=(e,t,n={},{asParent:r=!1}={})=>{if(n.queryDisabled)return r?"parent-disabled":"target-disabled";if(!n.respectDisabled||void 0===t)return null;const o=Array.isArray(t)?t:ri(t,e);return o&&(si(o,e)||((e,t=[])=>t.some(t=>ai(t,e)||ii(t,e)))(o,n.disabledPaths))?r?"parent-disabled":"target-disabled":null},_i=(e,{maxLevels:t=1/0}={})=>!!e&&e.length>=t,Li=(e,t,n,r={})=>pi(r.freeze)(e,e=>Gi(e,t,n,r)),Gi=(e,t,n,r={})=>{const{combinators:o=fn,combinatorPreceding:a,idGenerator:i=di,onAbort:l}=r,s=Array.isArray(n)?ti(n,e):ni(n,e);if(!s)return l?.({reason:"parent-not-found",operation:"add",pathOrID:n}),e;if(!hr(s))return l?.({reason:"parent-not-a-group",operation:"add",pathOrID:n}),e;const u=Array.isArray(n)?n:ri(n,e),c=Pi(e,u,r,{asParent:!0});if(c)return l?.({reason:c,operation:"add",pathOrID:n}),e;if(hr(t)&&_i(u,r))return l?.({reason:"max-levels-exceeded",operation:"add",pathOrID:n}),e;if(gr(s)&&s.rules.length>0){const e=s.rules.at(-2);s.rules.push(a??("string"==typeof e?e:Kr(o)))}return s.rules.push(xi(t,{idGenerator:i})),e},Fi={field:0,operator:1,valueSource:2,value:4},zi=e=>e.toSorted((e,t)=>(Fi[e[0]]??3)-(Fi[t[0]]??3)),ji=(e,t,n,r,o)=>{const{entries:a,pathOrID:i,options:l}=((e,t,n,r)=>{if("string"==typeof e)return{entries:[[e,t]],pathOrID:n,options:r??{}};if(Array.isArray(e)){const o=t;return{entries:zi(e.map((e,t)=>[e,o[t]])),pathOrID:n,options:r??{}}}return{entries:zi(Object.entries(e)),pathOrID:t,options:n??{}}})(t,n,r,o);for(const[t,n]of a)Bi(e,t,n,i,l);return e},qi=(e,t,n,r,o)=>pi(((e,t,n,r)=>("string"==typeof e||Array.isArray(e)?r:n)??{})(t,0,r,o).freeze)(e,e=>{ji(e,t,n,r,o)}),Bi=(e,t,n,r,o={})=>{const{resetOnFieldChange:a=!0,resetOnOperatorChange:i=!1,getRuleDefaultOperator:l=()=>"=",getValueSources:s=()=>["value"],getRuleDefaultValue:u=()=>"",getMatchModes:c=()=>[],onAbort:d}=o;let f=a;const p=Array.isArray(r)?r:ri(r,e);if(!p)return d?.({reason:"target-not-found",operation:"update",pathOrID:r}),e;const h="disabled"===t?{queryDisabled:o.queryDisabled}:o,m=Pi(e,p,h);if(m)return d?.({reason:m,operation:"update",pathOrID:r}),e;if("combinator"===t&&!mr(e)){const t=ti(oi(p),e);if(!t||!hr(t))return d?.({reason:"target-not-found",operation:"update",pathOrID:r}),e;const o=t.rules;return p.at(-1)%2==1?o[p.at(-1)]===n?d?.({reason:"no-change",operation:"update",pathOrID:r}):o[p.at(-1)]=n:d?.({reason:"not-a-combinator-slot",operation:"update",pathOrID:r}),e}const g=ti(p,e);if(!g)return d?.({reason:"target-not-found",operation:"update",pathOrID:r}),e;const v=hr(g);if(g[t]===n)return d?.({reason:"no-change",operation:"update",pathOrID:r}),e;if("valueSource"!==t&&(g[t]=n),v)return e;let b=!1,y=!1;if("field"===t){const e=c(g.field),t=c(n);if(0===t.length)delete g.match;else{const e=g.match?.mode&&Qr(t,g.match.mode)?null:Kr(t);e&&(g.match={mode:e,threshold:1})}(e.length>0||t.length>0)&&(f=!0)}f&&"field"===t&&(g.operator=l(n),b=!0,y=!0),i&&"operator"===t&&(b=!0,y=!0);const w=Kr(Si({name:g.field,value:g.field,label:""},g.operator,s));return(b&&g.valueSource&&w!==g.valueSource||"valueSource"===t&&n!==g.valueSource)&&(y=!!g.valueSource||!g.valueSource&&n!==w,g.valueSource=b?w:n),y&&(g.value=u(g)),e},Vi=(e,t,n={})=>pi(n.freeze)(e,e=>Hi(e,t,n)),Hi=(e,t,n={})=>{const{onAbort:r}=n,o=Array.isArray(t)?t:ri(t,e);if(!o)return r?.({reason:"target-not-found",operation:"remove",pathOrID:t}),e;if(0===o.length)return r?.({reason:"root-not-allowed",operation:"remove",pathOrID:t}),e;const a=Pi(e,o,n);if(a)return r?.({reason:a,operation:"remove",pathOrID:t}),e;if(!ti(o,e))return r?.({reason:"target-not-found",operation:"remove",pathOrID:t}),e;const i=o.at(-1),l=ti(oi(o),e);if(!mr(l)&&l.rules.length>1){const e=0===i?0:i-1;l.rules.splice(e,2)}else l.rules.splice(i,1);return e},Ui=(e,t,n)=>{if(Array.isArray(n))return n;const r=gr(e);if("up"===n){if(ai(t,[0]))return t;if(0===t.at(-1)){const e=oi(t);return[...oi(e),Math.max(0,e.at(-1)-(r?1:0))]}{const n=[...oi(t),Math.max(0,t.at(-1)-(r?2:1))],o=ti(n,e);return hr(o)?[...n,o.rules.length]:[...oi(t),Math.max(0,t.at(-1)-(r?3:1))]}}if("down"===n){if(ai([e.rules.length-1],t))return t;if(t.at(-1)===ti(oi(t),e).rules.length-1){const e=oi(t);return[...oi(e),e.at(-1)+1]}{const n=[...oi(t),t.at(-1)+(r?2:1)],o=ti(n,e);return hr(o)?[...n,0]:[...oi(t),t.at(-1)+(r?3:2)]}}return t},Wi=(e,t,n,r={})=>pi(r.freeze)(e,e=>Qi(e,t,n,r)),Qi=(e,t,n,r={})=>{const{clone:o=!1,combinators:a=fn,idGenerator:i=di,onAbort:l}=r,s=Array.isArray(t)?t:ri(t,e);if(!s)return l?.({reason:"target-not-found",operation:"move",pathOrID:t}),e;const u=ti(s,e);if(!u)return l?.({reason:"target-not-found",operation:"move",pathOrID:t}),e;const c=Ui(e,s,n);if(0===s.length)return l?.({reason:"root-not-allowed",operation:"move",pathOrID:t}),e;const d=Pi(e,s,r);if(d)return l?.({reason:d,operation:"move",pathOrID:t}),e;if(ai(s,c))return l?.({reason:"same-location",operation:"move",pathOrID:t}),e;if(!ti(oi(c),e))return l?.({reason:"destination-not-found",operation:"move",pathOrID:n}),e;if(!o&&ii(s,c))return l?.({reason:"destination-not-found",operation:"move",pathOrID:n}),e;const f=o?Ii(ot(u)?nn(u):u,{idGenerator:i}):u,p=gr(e),h=ti(oi(s),e),m=s.at(-1),g=p&&m>0?h.rules[m-1]:null,v=p&&ms[y.length]&&(b[y.length]-=p?2:1);const w=oi(b),S=ti(w,e),k=b.at(-1),E=p&&k>0?k-1:k,O=(...e)=>S.rules.splice(E,0,...e);return 0!==S.rules.length&&p?0===k?O(f,0===m&&v?v:S.rules[1]??g??Kr(a)):O(g||(S.rules[E-2]??v??Kr(a)),f):O(f),e},Ki=(e,t,n,r={})=>pi(r.freeze)(e,e=>Xi(e,t,n,r)),Xi=(e,t,n,r={})=>{const{combinators:o=fn,combinatorPreceding:a,combinatorSucceeding:i,idGenerator:l=di,replace:s=!1,onAbort:u}=r,c=ti(oi(n),e);if(!c)return u?.({reason:"parent-not-found",operation:"insert",pathOrID:n}),e;if(!hr(c))return u?.({reason:"parent-not-a-group",operation:"insert",pathOrID:n}),e;const d=oi(n),f=Pi(e,d,r,{asParent:!0});if(f)return u?.({reason:f,operation:"insert",pathOrID:n}),e;if(hr(t)&&_i(d,r))return u?.({reason:"max-levels-exceeded",operation:"insert",pathOrID:n}),e;const p=Ii(t,{idGenerator:l}),h=gr(e),m=n.at(-1),g=(e,...t)=>c.rules.splice(e,s?t.length:0,...t);if(0!==c.rules.length&&h)if(s&&h)g(m+m%2,p);else if(0===m)0===p.path?.at(-1)&&i?g(m,p,i):g(m,p,c.rules[1]??a??Kr(o));else{const e=m%2==0?m-1:m;g(e,a||(c.rules[e-2]??i??Kr(o)),p)}else g(m,p);return e},Yi=(e,t,n,r={})=>pi(r.freeze)(e,e=>Ji(e,t,n,r)),Ji=(e,t,n,r={})=>{const{clone:o=!1,combinators:a=fn,idGenerator:i=di,onAbort:l}=r,s=Array.isArray(t)?t:ri(t,e),u=Array.isArray(n)?n:ri(n,e);if(!s)return l?.({reason:"target-not-found",operation:"group",pathOrID:t}),e;if(!u)return l?.({reason:"target-not-found",operation:"group",pathOrID:n}),e;const c=Ui(e,s,u);if(0===s.length)return l?.({reason:"root-not-allowed",operation:"group",pathOrID:t}),e;const d=Pi(e,s,r);if(d)return l?.({reason:d,operation:"group",pathOrID:t}),e;if(ai(s,c))return l?.({reason:"same-location",operation:"group",pathOrID:t}),e;if(!ti(oi(c),e))return l?.({reason:"destination-not-found",operation:"group",pathOrID:n}),e;if(!o&&ii(s,c))return l?.({reason:"destination-not-found",operation:"group",pathOrID:n}),e;const f=ti(s,e),p=ti(u,e);if(!f)return l?.({reason:"target-not-found",operation:"group",pathOrID:t}),e;if(!p)return l?.({reason:"target-not-found",operation:"group",pathOrID:n}),e;const h=o?Ii(ot(f)?nn(f):f,{idGenerator:i}):f,m=gr(e),g=ti(oi(s),e),v=s.at(-1);if(!o){const e=m?Math.max(0,v-1):v,t=m?2:1;g.rules.splice(e,t)}const b=[...c],y=li(s,c);!o&&s.length===y.length+1&&c[y.length]>s[y.length]&&(b[y.length]-=m?2:1);const w=oi(b),S=ti(w,e),k=b.at(-1);return S.rules.splice(k,1,xi(m?{rules:[p,Kr(a),h]}:{combinator:Kr(a),rules:[p,h]},{idGenerator:i})),e},Zi=({fields:e,getDefaultField:t,getRuleDefaultOperator:n,getValueSources:r,getMatchModes:o,getRuleDefaultValue:a,idGenerator:i=di})=>{let l=Kr(e)??"";if(t)if("function"==typeof t){const n=t(e);n&&(l=n)}else l=t;const s=Qr(e,l),u=n(l),c=Kr(r(l,u,{fieldData:s}))??"value",d=Kr(o(l,{fieldData:s})),f={id:i(),field:l,operator:u,valueSource:c,value:"",...d?{match:{mode:d,threshold:1}}:null};return{...f,value:a(f)}},el=({combinators:e,addRuleToNewGroups:t,createRule:n,idGenerator:r=di},o)=>{const a=r(),i=t?[n()]:[];return o?{id:a,rules:i,not:!1}:{id:a,rules:i,combinator:Kr(e)??"",not:!1}};var tl=class e extends Error{code;info;constructor(t){super(`QueryManager: "${t.operation}" aborted (${t.reason})${void 0===t.pathOrID?"":` for target ${JSON.stringify(t.pathOrID)}`}.`),this.name="QueryManagerError",this.code=t.reason,this.info=t,Object.setPrototypeOf(this,e.prototype)}};const nl=Symbol("QueryManager.state"),rl=Et({query:!0,config:!1}),ol=Et({query:!1,config:!0}),al=Et({query:!0,config:!0}),il=()=>{const e={listeners:new Set,configVersion:0,past:[],future:[],lastAt:0,batchDepth:0,historyBypassed:!1,pendingConfigNotify:!1};return Object.defineProperty(e,"__v_skip",{value:!0,enumerable:!1}),e};Symbol.iterator; +e.field===a||e.operator===i||void 0!==l&&e.value===l)return;const d=Qr(n,e.field);return s(e,{...t,parseNumbers:o(d?.inputType),escapeQuotes:"value"===(e.valueSource??"value"),fieldData:d})},f=e=>{if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return"";const t=[];for(const n of e.rules){if("string"==typeof n)continue;if(hr(n)){const e=f(n);e&&t.push(e);continue}const e=d(n);e&&t.push(e)}if(0===t.length)return"";const n=e.combinator??"and",r=e.not?"not":n;return 1!==t.length||e.not?`.${r}(${t.map(e=>e.startsWith(".")?`__${e}`:e).join(", ")})`:t[0]};if(!go(e,c[e.id??/* v8 ignore start -- @preserve */""]))return r;const p=[];for(const t of e.rules){if("string"==typeof t)continue;if(hr(t)){const e=f(t);e&&p.push(e);continue}const e=d(t);e&&p.push(e)}return 0===p.length?r:p.join("")})(e,O);case"diagnostics":return((e,t)=>{const{fields:n,placeholderFieldName:r,placeholderOperatorName:o,placeholderValueName:a,validateRule:i,validationMap:l}=t,s=[],u={totalRules:0,totalGroups:0,validRules:0,invalidRules:0,validGroups:0,invalidGroups:0},c={},d=Xr(n),f=new Map;for(const e of d)f.set(e.name,e);const p=f.size>0,h=(e,t)=>{u.totalGroups++;const n=t.length,d=l[e.id??""],m=go(e,d),g=ba(d);e.muted?s.push({id:e.id??"",path:t,code:"MUTED",message:"Group is muted",source:"muted"}):m||void 0===d||s.push({id:e.id??"",path:t,code:"CUSTOM_VALIDATOR",message:g?`Invalid: ${g.join(", ")}`:"Group failed validation",source:"query-validator"});let v=!0,b=0;const y=[];for(const n of e.rules){if("string"==typeof n){y.push(n),b++;continue}const e=[...t,b];if(hr(n)){const t=h(n,e);t.valid||(v=!1),y.push(t),b++;continue}u.totalRules++;const l=e.length,[d,m]=i(n),g=go(n,d,m)&&n.field!==r&&n.operator!==o&&!(void 0!==a&&n.value===a);va(n,e,d,m,g,s,r,o,a,p,f),g?u.validRules++:(v=!1,u.invalidRules++);const w=n.field;c[w]||(c[w]={ruleCount:0,invalidCount:0}),c[w].ruleCount++,g||c[w].invalidCount++;const S=ba(d)??ya(n,m),k={...n,valid:g,...S?{reasons:S}:null,path:e,level:l};y.push(k),b++}const w=m&&v;return w?u.validGroups++:u.invalidGroups++,mr(e),{...e,valid:w,...g?{reasons:g}:null,path:t,level:n,rules:y}},m=h(e,[]);if(p){const e=new Set(Object.keys(c));for(const[t]of f)e.has(t)||s.push({id:"",path:[],code:"UNREFERENCED_FIELD",message:`Field "${t}" is defined in the fields config but not used in the query`,source:"field-check"})}return{query:m,diagnostics:s,stats:u,fieldSummary:c}})(e,O);default:return""}}const ei=e=>(t,n,r,o)=>e({field:t,operator:n,value:r,valueSource:o},{parseNumbers:!1}),ti=(ei(Yo),ei(Ho),ei(zo),ei(Xo),(e,t)=>{let n=t,r=0;for(;r{if(t.id===e)return t;for(const n of t.rules)if("string"!=typeof n){if(n.id===e)return n;if(hr(n)){const t=ni(e,n);if(t)return t}}return null},ri=(e,t)=>{if(t.id===e)return[];const n=t.rules.findIndex(t=>!("string"==typeof t)&&t.id===e);if(n>=0)return[n];for(const[n,r]of Object.entries(t.rules))if(hr(r)){const t=ri(e,r);if(Array.isArray(t))return[Number.parseInt(n),...t]}return null},oi=e=>e.slice(0,-1),ai=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n{if(e.length>=t.length)return!1;for(let n=0;n{const n=[],r=oi(e),o=oi(t);let a=0;for(;a{let n=!!t.disabled,r=t,o=0;for(;oai([],e.path)?"Query builder":`Rule group at path ${e.path.join("-")}`,ci=globalThis.crypto;let di=()=>"00-0-4-2-000".replaceAll(/[^-]/g,e=>(65536*(Math.random()+Math.trunc(e))>>Number.parseInt(e)).toString(16).padStart(4,"0"));if(ci)if("function"==typeof ci.randomUUID)di=()=>ci.randomUUID();else if("function"==typeof ci.getRandomValues){const e="89ab",t=new Uint32Array(32);di=()=>{ci.getRandomValues(t);let n=(t[0]%16).toString(16);for(let r=1;r<32;r++)n=12===r?`${n}4`:16===r?`${n}${e[t[17]%4]}`:`${n}${(t[r]%16).toString(16)}`,7!==r&&11!==r&&15!==r&&19!==r||(n=`${n}-`);return n}}const fi=new en({autoFreeze:!1}),pi=(e=!0)=>e?an:fi.produce,hi={name:"name",value:"name",matchModes:null,label:"label"},mi=(e,t)=>{const n=e?jr(e):/* v8 ignore next -- @preserve */hi;let r=n.matchModes??!1;return!r&&t&&(r=t(n.value,{fieldData:n})),!0===r?pn:!1===r?[]:Ur(r)?Vr(r):r?.map(e=>pn.find(t=>t.value===cr(e))??{name:e,value:e,label:e})??[]},gi=(e,t,n)=>{const r=Kr(e);if("between"===t.operator||"notBetween"===t.operator){const e=[r,r];return n?e:ar(e.map(e=>e??/* v8 ignore start -- @preserve */""),",")}return r},vi=(e,t)=>{const{fieldData:n,fields:r,getValueEditorType:o,getValues:a,getDefaultValue:i,getParameters:l,listsAsArrays:s}=t;if(void 0!==n?.defaultValue&&null!==n.defaultValue)return n.defaultValue;if(i)return i(e,{fieldData:n});let u="";const c=a(e.field,e.operator,{fieldData:n});if("field"===e.valueSource){const t=eo(n,r,e.operator);u=t.length>0?gi(t,e,s):""}else if("parameter"===e.valueSource){const t=l?l(e.field,e.operator,{fieldData:n}):null;u=t&&t.length>0?Kr(t):""}else if(c.length>0){const t=o(e.field,e.operator,{fieldData:n});"multiselect"===t?u=s?[]:"":"select"!==t&&"radio"!==t||(u=gi(c,e,s))}else"checkbox"===o(e.field,e.operator,{fieldData:n})&&(u=!1);return u},bi=e=>{const t="boolean"==typeof e?e:"object"==typeof e&&null!==e?e.valid:null;return"boolean"==typeof t?t?hn.valid:hn.invalid:""},yi=[{name:"value",value:"value",label:"value"}],wi={name:"name",value:"name",valueSources:null,label:"label"},Si=(e,t,n)=>{const r=e?jr(e):wi;let o=r.valueSources??!1;return"function"==typeof o&&(o=o(t)),!o&&n&&(o=n(r.value,t,{fieldData:r})),o?Ur(o)?Vr(o):o.map(e=>yi.find(t=>t.value===cr(e))??{name:e,value:e,label:e}):yi},ki=(e,t,n)=>{if(Gr(e))return;const r=Lr(t).map(([t,[r,o]])=>[t,r??o??n?.[e]?.[t]]).filter(e=>!Gr(e[0])&&!!e[1]);if(r.length>0||n){const t=n?.[e]??{},o=Object.assign({},t,Object.fromEntries(r));return{[e]:o}}},Ei=(e,t)=>{let n="";for(let r=0;rJr({optionList:t?.operators??n?.(e,{fieldData:t})??r,placeholder:o,baseOption:a,labelMap:un,autoSelectOption:i}).optionList,Ni=({field:e,fieldData:t,getDefaultOperator:n,getOperators:r})=>t?.defaultOperator?t.defaultOperator:n?"function"==typeof n?n(e,{fieldData:t}):n:Kr(r(e,{fieldData:t}))??"",Ci=({field:e,operator:t,fieldData:n,getValueEditorType:r})=>n?.valueEditorType?"function"==typeof n.valueEditorType?n.valueEditorType(t):n.valueEditorType:r?.(e,t,{fieldData:n})??"text",Di=({field:e,operator:t,fieldData:n,getValues:r,placeholder:o,baseOption:a,autoSelectOption:i})=>Jr({optionList:n?.values??r?.(e,t,{fieldData:n})??[],placeholder:o,baseOption:a,autoSelectOption:i}).optionList,Ai=(e,t)=>{if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>Ai(e,t[n]));if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)||!(e=>{const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype})(e))return!1;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Ai(e[n],t[n]))},Ti=(e,t,n,r)=>r?t??n:e?((e,t)=>!(!1===e||!e&&!1===t))(t,n):((e,t)=>!!e||!1!==e&&!!t)(t,n),$i=(e,t,n)=>void 0!==t&&null!=t?t:void 0!==n&&null!=n?n:e,Mi=(e,{idGenerator:t=di}={})=>{const n=!e.id,r=xo(e);return n||r?{...e,...n&&{id:t()},...r&&{value:Ri(e.value,{idGenerator:t})}}:e},Ri=(e,{idGenerator:t=di}={})=>{const n=!e.id;let r=!1;const o=[];for(let n=0;nhr(e)?Ri(e,{idGenerator:t}):Mi(e,{idGenerator:t}),Ii=(e,{idGenerator:t=di}={})=>{if(!fr(e))return e;if(!hr(e))return structuredClone({...e,id:t()});const n={...e,id:t()};return Array.isArray(n.rules)&&(n.rules=e.rules.map(e=>"string"==typeof e?e:hr(e)?Ii(e,{idGenerator:t}):((e,{idGenerator:t=di}={})=>structuredClone({...e,id:t()}))(e,{idGenerator:t}))),n},Pi=(e,t,n={},{asParent:r=!1}={})=>{if(n.queryDisabled)return r?"parent-disabled":"target-disabled";if(!n.respectDisabled||void 0===t)return null;const o=Array.isArray(t)?t:ri(t,e);return o&&(si(o,e)||((e,t=[])=>t.some(t=>ai(t,e)||ii(t,e)))(o,n.disabledPaths))?r?"parent-disabled":"target-disabled":null},_i=(e,{maxLevels:t=1/0}={})=>!!e&&e.length>=t,Li=(e,t,n,r={})=>pi(r.freeze)(e,e=>Gi(e,t,n,r)),Gi=(e,t,n,r={})=>{const{combinators:o=fn,combinatorPreceding:a,idGenerator:i=di,onAbort:l}=r,s=Array.isArray(n)?ti(n,e):ni(n,e);if(!s)return l?.({reason:"parent-not-found",operation:"add",pathOrID:n}),e;if(!hr(s))return l?.({reason:"parent-not-a-group",operation:"add",pathOrID:n}),e;const u=Array.isArray(n)?n:ri(n,e),c=Pi(e,u,r,{asParent:!0});if(c)return l?.({reason:c,operation:"add",pathOrID:n}),e;if(hr(t)&&_i(u,r))return l?.({reason:"max-levels-exceeded",operation:"add",pathOrID:n}),e;if(gr(s)&&s.rules.length>0){const e=s.rules.at(-2);s.rules.push(a??("string"==typeof e?e:Kr(o)))}return s.rules.push(xi(t,{idGenerator:i})),e},Fi={field:0,operator:1,valueSource:2,value:4},zi=e=>e.toSorted((e,t)=>(Fi[e[0]]??3)-(Fi[t[0]]??3)),ji=(e,t,n,r,o)=>{const{entries:a,pathOrID:i,options:l}=((e,t,n,r)=>{if("string"==typeof e)return{entries:[[e,t]],pathOrID:n,options:r??{}};if(Array.isArray(e)){const o=t;return{entries:zi(e.map((e,t)=>[e,o[t]])),pathOrID:n,options:r??{}}}return{entries:zi(Object.entries(e)),pathOrID:t,options:n??{}}})(t,n,r,o);for(const[t,n]of a)qi(e,t,n,i,l);return e},Vi=(e,t,n,r,o)=>pi(((e,t,n,r)=>("string"==typeof e||Array.isArray(e)?r:n)??{})(t,0,r,o).freeze)(e,e=>{ji(e,t,n,r,o)}),qi=(e,t,n,r,o={})=>{const{resetOnFieldChange:a=!0,resetOnOperatorChange:i=!1,getRuleDefaultOperator:l=()=>"=",getValueSources:s=()=>["value"],getRuleDefaultValue:u=()=>"",getMatchModes:c=()=>[],onAbort:d}=o;let f=a;const p=Array.isArray(r)?r:ri(r,e);if(!p)return d?.({reason:"target-not-found",operation:"update",pathOrID:r}),e;const h="disabled"===t?{queryDisabled:o.queryDisabled}:o,m=Pi(e,p,h);if(m)return d?.({reason:m,operation:"update",pathOrID:r}),e;if("combinator"===t&&!mr(e)){const t=ti(oi(p),e);if(!t||!hr(t))return d?.({reason:"target-not-found",operation:"update",pathOrID:r}),e;const o=t.rules;return p.at(-1)%2==1?o[p.at(-1)]===n?d?.({reason:"no-change",operation:"update",pathOrID:r}):o[p.at(-1)]=n:d?.({reason:"not-a-combinator-slot",operation:"update",pathOrID:r}),e}const g=ti(p,e);if(!g)return d?.({reason:"target-not-found",operation:"update",pathOrID:r}),e;const v=hr(g);if(g[t]===n)return d?.({reason:"no-change",operation:"update",pathOrID:r}),e;if("valueSource"!==t&&(g[t]=n),v)return e;let b=!1,y=!1;if("field"===t){const e=c(g.field),t=c(n);if(0===t.length)delete g.match;else{const e=g.match?.mode&&Qr(t,g.match.mode)?null:Kr(t);e&&(g.match={mode:e,threshold:1})}(e.length>0||t.length>0)&&(f=!0)}f&&"field"===t&&(g.operator=l(n),b=!0,y=!0),i&&"operator"===t&&(b=!0,y=!0);const w=Kr(Si({name:g.field,value:g.field,label:""},g.operator,s));return(b&&g.valueSource&&w!==g.valueSource||"valueSource"===t&&n!==g.valueSource)&&(y=!!g.valueSource||!g.valueSource&&n!==w,g.valueSource=b?w:n),y&&(g.value=u(g)),e},Bi=(e,t,n={})=>pi(n.freeze)(e,e=>Hi(e,t,n)),Hi=(e,t,n={})=>{const{onAbort:r}=n,o=Array.isArray(t)?t:ri(t,e);if(!o)return r?.({reason:"target-not-found",operation:"remove",pathOrID:t}),e;if(0===o.length)return r?.({reason:"root-not-allowed",operation:"remove",pathOrID:t}),e;const a=Pi(e,o,n);if(a)return r?.({reason:a,operation:"remove",pathOrID:t}),e;if(!ti(o,e))return r?.({reason:"target-not-found",operation:"remove",pathOrID:t}),e;const i=o.at(-1),l=ti(oi(o),e);if(!mr(l)&&l.rules.length>1){const e=0===i?0:i-1;l.rules.splice(e,2)}else l.rules.splice(i,1);return e},Ui=(e,t,n)=>{if(Array.isArray(n))return n;const r=gr(e);if("up"===n){if(ai(t,[0]))return t;if(0===t.at(-1)){const e=oi(t);return[...oi(e),Math.max(0,e.at(-1)-(r?1:0))]}{const n=[...oi(t),Math.max(0,t.at(-1)-(r?2:1))],o=ti(n,e);return hr(o)?[...n,o.rules.length]:[...oi(t),Math.max(0,t.at(-1)-(r?3:1))]}}if("down"===n){if(ai([e.rules.length-1],t))return t;if(t.at(-1)===ti(oi(t),e).rules.length-1){const e=oi(t);return[...oi(e),e.at(-1)+1]}{const n=[...oi(t),t.at(-1)+(r?2:1)],o=ti(n,e);return hr(o)?[...n,0]:[...oi(t),t.at(-1)+(r?3:2)]}}return t},Wi=(e,t,n,r={})=>pi(r.freeze)(e,e=>Qi(e,t,n,r)),Qi=(e,t,n,r={})=>{const{clone:o=!1,combinators:a=fn,idGenerator:i=di,onAbort:l}=r,s=Array.isArray(t)?t:ri(t,e);if(!s)return l?.({reason:"target-not-found",operation:"move",pathOrID:t}),e;const u=ti(s,e);if(!u)return l?.({reason:"target-not-found",operation:"move",pathOrID:t}),e;const c=Ui(e,s,n);if(0===s.length)return l?.({reason:"root-not-allowed",operation:"move",pathOrID:t}),e;const d=Pi(e,s,r);if(d)return l?.({reason:d,operation:"move",pathOrID:t}),e;if(ai(s,c))return l?.({reason:"same-location",operation:"move",pathOrID:t}),e;if(!ti(oi(c),e))return l?.({reason:"destination-not-found",operation:"move",pathOrID:n}),e;if(!o&&ii(s,c))return l?.({reason:"destination-not-found",operation:"move",pathOrID:n}),e;const f=o?Ii(ot(u)?nn(u):u,{idGenerator:i}):u,p=gr(e),h=ti(oi(s),e),m=s.at(-1),g=p&&m>0?h.rules[m-1]:null,v=p&&ms[y.length]&&(b[y.length]-=p?2:1);const w=oi(b),S=ti(w,e),k=b.at(-1),E=p&&k>0?k-1:k,O=(...e)=>S.rules.splice(E,0,...e);return 0!==S.rules.length&&p?0===k?O(f,0===m&&v?v:S.rules[1]??g??Kr(a)):O(g||(S.rules[E-2]??v??Kr(a)),f):O(f),e},Ki=(e,t,n,r={})=>pi(r.freeze)(e,e=>Xi(e,t,n,r)),Xi=(e,t,n,r={})=>{const{combinators:o=fn,combinatorPreceding:a,combinatorSucceeding:i,idGenerator:l=di,replace:s=!1,onAbort:u}=r,c=ti(oi(n),e);if(!c)return u?.({reason:"parent-not-found",operation:"insert",pathOrID:n}),e;if(!hr(c))return u?.({reason:"parent-not-a-group",operation:"insert",pathOrID:n}),e;const d=oi(n),f=Pi(e,d,r,{asParent:!0});if(f)return u?.({reason:f,operation:"insert",pathOrID:n}),e;if(hr(t)&&_i(d,r))return u?.({reason:"max-levels-exceeded",operation:"insert",pathOrID:n}),e;const p=Ii(t,{idGenerator:l}),h=gr(e),m=n.at(-1),g=(e,...t)=>c.rules.splice(e,s?t.length:0,...t);if(0!==c.rules.length&&h)if(s&&h)g(m+m%2,p);else if(0===m)0===p.path?.at(-1)&&i?g(m,p,i):g(m,p,c.rules[1]??a??Kr(o));else{const e=m%2==0?m-1:m;g(e,a||(c.rules[e-2]??i??Kr(o)),p)}else g(m,p);return e},Yi=(e,t,n,r={})=>pi(r.freeze)(e,e=>Ji(e,t,n,r)),Ji=(e,t,n,r={})=>{const{clone:o=!1,combinators:a=fn,idGenerator:i=di,onAbort:l}=r,s=Array.isArray(t)?t:ri(t,e),u=Array.isArray(n)?n:ri(n,e);if(!s)return l?.({reason:"target-not-found",operation:"group",pathOrID:t}),e;if(!u)return l?.({reason:"target-not-found",operation:"group",pathOrID:n}),e;const c=Ui(e,s,u);if(0===s.length)return l?.({reason:"root-not-allowed",operation:"group",pathOrID:t}),e;const d=Pi(e,s,r);if(d)return l?.({reason:d,operation:"group",pathOrID:t}),e;if(ai(s,c))return l?.({reason:"same-location",operation:"group",pathOrID:t}),e;if(!ti(oi(c),e))return l?.({reason:"destination-not-found",operation:"group",pathOrID:n}),e;if(!o&&ii(s,c))return l?.({reason:"destination-not-found",operation:"group",pathOrID:n}),e;const f=ti(s,e),p=ti(u,e);if(!f)return l?.({reason:"target-not-found",operation:"group",pathOrID:t}),e;if(!p)return l?.({reason:"target-not-found",operation:"group",pathOrID:n}),e;const h=o?Ii(ot(f)?nn(f):f,{idGenerator:i}):f,m=gr(e),g=ti(oi(s),e),v=s.at(-1);if(!o){const e=m?Math.max(0,v-1):v,t=m?2:1;g.rules.splice(e,t)}const b=[...c],y=li(s,c);!o&&s.length===y.length+1&&c[y.length]>s[y.length]&&(b[y.length]-=m?2:1);const w=oi(b),S=ti(w,e),k=b.at(-1);return S.rules.splice(k,1,xi(m?{rules:[p,Kr(a),h]}:{combinator:Kr(a),rules:[p,h]},{idGenerator:i})),e},Zi=({fields:e,getDefaultField:t,getRuleDefaultOperator:n,getValueSources:r,getMatchModes:o,getRuleDefaultValue:a,idGenerator:i=di})=>{let l=Kr(e)??"";if(t)if("function"==typeof t){const n=t(e);n&&(l=n)}else l=t;const s=Qr(e,l),u=n(l),c=Kr(r(l,u,{fieldData:s}))??"value",d=Kr(o(l,{fieldData:s})),f={id:i(),field:l,operator:u,valueSource:c,value:"",...d?{match:{mode:d,threshold:1}}:null};return{...f,value:a(f)}},el=({combinators:e,addRuleToNewGroups:t,createRule:n,idGenerator:r=di},o)=>{const a=r(),i=t?[n()]:[];return o?{id:a,rules:i,not:!1}:{id:a,rules:i,combinator:Kr(e)??"",not:!1}};var tl=class e extends Error{code;info;constructor(t){super(`QueryManager: "${t.operation}" aborted (${t.reason})${void 0===t.pathOrID?"":` for target ${JSON.stringify(t.pathOrID)}`}.`),this.name="QueryManagerError",this.code=t.reason,this.info=t,Object.setPrototypeOf(this,e.prototype)}};const nl=Symbol("QueryManager.state"),rl=Et({query:!0,config:!1}),ol=Et({query:!1,config:!0}),al=Et({query:!0,config:!0}),il=()=>{const e={listeners:new Set,configVersion:0,past:[],future:[],lastAt:0,batchDepth:0,historyBypassed:!1,pendingConfigNotify:!1};return Object.defineProperty(e,"__v_skip",{value:!0,enumerable:!1}),e};Symbol.iterator; /* v8 ignore file -- @preserve */ const ll=new Set(["shift","alt","meta","mod","ctrl"]),sl={esc:"escape",return:"enter",".":"period",",":"comma","-":"slash"," ":"space","`":"backquote","#":"backslash","+":"bracketright",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"},ul=e=>cr((e&&sl[e]||e||"").trim()).replace(/key|digit|numpad|arrow/,""),cl=e=>ll.has(e),dl={"⌘":"meta",cmd:"meta",command:"meta","⊞":"meta",win:"meta",windows:"meta","⇧":"shift","⌥":"alt","⌃":"ctrl",control:"ctrl"};"undefined"!=typeof document&&(document.addEventListener("keydown",e=>{void 0!==e.key&&hl([ul(e.key),ul(e.code)])}),document.addEventListener("keyup",e=>{void 0!==e.key&&ml([ul(e.key),ul(e.code)])})),"undefined"!=typeof window&&window.addEventListener("blur",()=>{fl.clear()});const fl=new Set,pl=(e,t=",")=>{return(n=e,Array.isArray(n)?e:e.split(t)).every(e=>{const t=cr(e.trim());return fl.has(dl[t]??t)});var n},hl=e=>{const t=Array.isArray(e)?e:[e];if(fl.has("meta"))for(const e of fl)cl(e)||fl.delete(cr(e));for(const e of t)fl.add(cr(e))},ml=e=>{const t=Array.isArray(e)?e:[e];if("meta"===e)fl.clear();else for(const e of t)fl.delete(cr(e))},gl=({type:e,path:t,schema:n,copyModeModifierKey:r,groupModeModifierKey:o,copyModeOverride:a,groupModeOverride:i})=>{const{qbId:l,getQuery:s,dispatchQuery:u}=n;return{type:e,path:t,qbId:l,getQuery:s,dispatchQuery:u,groupItems:i||pl(o),dropEffect:a||pl(r)?"copy":"move"}},vl=({item:e,dropResult:t,schema:n,actions:r,copyModeModifierKey:o,groupModeModifierKey:a,copyModeOverride:i,groupModeOverride:l,onRuleDrop:s})=>{if(!t)return;const u=i||pl(o)?"copy":"move",c=l||pl(a),d=((e,t)=>{const n=oi(e.path),r=e.path.at(-1);return t?e.path:"ruleGroup"===e.type?[...e.path,0]:"inlineCombinator"===e.type?[...n,r]:[...n,r+1]})(t,c),f=n.qbId!==t.qbId;if(f){const n=t.getQuery();n&&(c?t.dispatchQuery(Yi(Li(n,e,[]),[n.rules.length],d,{clone:!1})):t.dispatchQuery(Ki(n,e,d)),"copy"!==u&&r.onRuleRemove(e.path))}else c?r.groupRule(e.path,d,"copy"===u):r.moveRule(e.path,d,"copy"===u);s?.({draggedItem:e,sourceQbId:n.qbId,targetQbId:t.qbId,sourcePath:e.path,targetPath:d,dropEffect:u,groupItems:c,isCrossBuilder:f})},bl=()=>"undefined"!=typeof window&&"ontouchstart"in window||"undefined"!=typeof navigator&&navigator.maxTouchPoints>0;let yl;const wl=()=>(yl||(yl=new Image,yl.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),yl),Sl=["rule","ruleGroup"],kl=(e,t,n)=>n(()=>({type:t,item:()=>({...ti(e.path,e.schema.getQuery()),path:e.path,qbId:e.schema.qbId}),canDrag:!e.disabled,previewOptions:{captureDraggingState:!!e.hideDefaultDragPreview},collect:t=>({isDragging:!e.disabled&&t.isDragging(),dragMonitorId:t.getHandlerId()??""}),end:(t,n)=>{vl({item:t,dropResult:n.getDropResult(),schema:e.schema,actions:e.actions,copyModeModifierKey:e.copyModeModifierKey,groupModeModifierKey:e.groupModeModifierKey,onRuleDrop:e.onRuleDrop})}}),[e.actions.groupRule,e.actions.moveRule,e.disabled,e.path]),El=e=>{const{useDrag:t,useDrop:n,DndProvider:r,DndContext:o}=e;let a=e.ReactDndBackend;a||(a=bl()?e.TouchBackend??e.HTML5Backend:e.HTML5Backend??e.TouchBackend);return{DndProvider:({debugMode:e,children:t})=>l().createElement(r,{backend:a,debugMode:e},l().createElement(o.Consumer,null,()=>l().createElement(l().Fragment,null,t))),useRuleDnD:e=>{const r=(0,l().useRef)(null),o=(0,l().useRef)(null),[{isDragging:a,dragMonitorId:i},s,u]=kl(e,"rule",t),[{isOver:c,dropMonitorId:d,dropEffect:f,groupItems:p,dropNotAllowed:h},m]=n(()=>({accept:Sl,canDrop:t=>(({dragging:e,path:t,schema:n,canDrop:r,groupModeModifierKey:o,disabled:a,rule:i})=>{if(pl(o)&&a||e&&"function"==typeof r&&!r({dragging:e,hovering:{...i,path:t,qbId:n.qbId}}))return!1;if(n.qbId!==e.qbId)return!0;const l=oi(t),s=oi(e.path),u=t.at(-1),c=e.path.at(-1);return!(ii(e.path,t)||ai(t,e.path)||!pl(o)&&ai(l,s)&&(u===c-1||n.independentCombinators&&u===c-2))})({dragging:t,path:e.path,schema:e.schema,canDrop:e.canDrop,groupModeModifierKey:e.groupModeModifierKey,disabled:e.disabled,rule:e.rule}),collect:t=>({dropNotAllowed:t.isOver()&&!t.canDrop(),isOver:t.canDrop()&&t.isOver(),dropMonitorId:t.getHandlerId()??"",dropEffect:pl(e.copyModeModifierKey)?"copy":"move",groupItems:pl(e.groupModeModifierKey)}),drop:()=>gl({type:"rule",path:e.path,schema:e.schema,copyModeModifierKey:e.copyModeModifierKey,groupModeModifierKey:e.groupModeModifierKey})}),[e.disabled,e.actions.moveRule,e.path,e.canDrop,e.rule,e.schema]);return l().useEffect(()=>{s(o),m(r),u(e.hideDefaultDragPreview?wl():r)},[s,m,e.hideDefaultDragPreview,u]),{isDragging:a,dragMonitorId:i,isOver:c,dropMonitorId:d,dndRef:r,dragRef:o,dropEffect:f,groupItems:p,dropNotAllowed:h}},useRuleGroupDnD:e=>{const r=(0,l().useRef)(null),o=(0,l().useRef)(null),a=(0,l().useRef)(null),[{isDragging:i,dragMonitorId:s},u,c]=kl(e,"ruleGroup",t),[{isOver:d,dropMonitorId:f,dropEffect:p,groupItems:h,dropNotAllowed:m},g]=n(()=>({accept:Sl,canDrop:t=>(({dragging:e,path:t,schema:n,canDrop:r,disabled:o,ruleGroup:a})=>{if(o||e&&"function"==typeof r&&!r({dragging:e,hovering:{...a,path:t,qbId:n.qbId}}))return!1;if(n.qbId!==e.qbId)return!0;const i=oi(e.path),l=e.path.at(-1);return!(ii(e.path,t)||ai(t,i)&&0===l||ai(t,e.path))})({dragging:t,path:e.path,schema:e.schema,canDrop:e.canDrop,disabled:e.disabled,ruleGroup:e.ruleGroup}),collect:t=>({dropNotAllowed:t.isOver()&&!t.canDrop(),isOver:t.canDrop()&&t.isOver(),dropMonitorId:t.getHandlerId()??"",dropEffect:pl(e.copyModeModifierKey)?"copy":"move",groupItems:pl(e.groupModeModifierKey)}),drop:()=>gl({type:"ruleGroup",path:e.path,schema:e.schema,copyModeModifierKey:e.copyModeModifierKey,groupModeModifierKey:e.groupModeModifierKey})}),[e.disabled,e.actions.groupRule,e.actions.moveRule,e.path,e.canDrop,e.ruleGroup,e.schema]);return l().useEffect(()=>{e.path.length>0&&(u(o),c(e.hideDefaultDragPreview?wl():r)),g(a)},[u,g,e.hideDefaultDragPreview,e.path.length,c]),{isDragging:i,dragMonitorId:s,isOver:d,dropMonitorId:f,previewRef:r,dragRef:o,dropRef:a,dropEffect:p,groupItems:h,dropNotAllowed:m}},useInlineCombinatorDnD:e=>{const t=(0,l().useRef)(null),r=(e.rules?? -/* v8 ignore start -- @preserve */[])[e.path.at(-1)-1],[{isOver:o,dropMonitorId:a,dropEffect:i,dropNotAllowed:s},u]=n(()=>({accept:["rule","ruleGroup"],canDrop:t=>(({dragging:e,path:t,schema:n,canDrop:r,groupModeModifierKey:o,hoveringItem:a})=>{const{path:i}=e;if(pl(o)||e&&"function"==typeof r&&!r({dragging:e,hovering:{...a,path:t,qbId:n.qbId}}))return!1;const l=oi(t),s=oi(i),u=t.at(-1),c=i.at(-1);return!(ii(i,t)||ai(i,t)||ai(l,s)&&u-1===c||n.independentCombinators&&ai(l,s)&&u===c-1)})({dragging:t,path:e.path,schema:e.schema,canDrop:e.canDrop,groupModeModifierKey:e.groupModeModifierKey,hoveringItem:r}),collect:t=>({dropNotAllowed:t.isOver()&&!t.canDrop(),isOver:t.canDrop()&&t.isOver(),dropMonitorId:t.getHandlerId()??"",dropEffect:pl(e.copyModeModifierKey)?"copy":"move",groupItems:pl(e.groupModeModifierKey)}),drop:()=>gl({type:"inlineCombinator",path:e.path,schema:e.schema,copyModeModifierKey:e.copyModeModifierKey,groupModeModifierKey:e.groupModeModifierKey})}),[e.canDrop,r,e.path,e.schema]);return l().useEffect(()=>{u(t)},[u]),{dropRef:t,dropMonitorId:a,isOver:o,dropEffect:i,dropNotAllowed:s}}}};function Ol(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Nl=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),Cl=()=>Math.random().toString(36).substring(7).split("").join("."),Dl={INIT:`@@redux/INIT${Cl()}`,REPLACE:`@@redux/REPLACE${Cl()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Cl()}`};function Al(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function Tl(e,t,n){if("function"!=typeof e)throw new Error(Ol(2));if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(Ol(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(Ol(1));return n(Tl)(e,t)}let r=e,o=t,a=new Map,i=a,l=0,s=!1;function u(){i===a&&(i=new Map,a.forEach((e,t)=>{i.set(t,e)}))}function c(){if(s)throw new Error(Ol(3));return o}function d(e){if("function"!=typeof e)throw new Error(Ol(4));if(s)throw new Error(Ol(5));let t=!0;u();const n=l++;return i.set(n,e),function(){if(t){if(s)throw new Error(Ol(6));t=!1,u(),i.delete(n),a=null}}}function f(e){if(!Al(e))throw new Error(Ol(7));if(void 0===e.type)throw new Error(Ol(8));if("string"!=typeof e.type)throw new Error(Ol(17));if(s)throw new Error(Ol(9));try{s=!0,o=r(o,e)}finally{s=!1}return(a=i).forEach(e=>{e()}),e}f({type:Dl.INIT});return{dispatch:f,subscribe:d,getState:c,replaceReducer:function(e){if("function"!=typeof e)throw new Error(Ol(10));r=e,f({type:Dl.REPLACE})},[Nl]:function(){const e=d;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(Ol(11));function n(){const e=t;e.next&&e.next(c())}n();return{unsubscribe:e(n)}},[Nl](){return this}}}}}function $l(e){const t=Object.keys(e),n={};for(let r=0;r{const n=e[t];if(void 0===n(void 0,{type:Dl.INIT}))throw new Error(Ol(12));if(void 0===n(void 0,{type:Dl.PROBE_UNKNOWN_ACTION()}))throw new Error(Ol(13))})}(n)}catch(e){o=e}return function(e={},t){if(o)throw o;let a=!1;const i={};for(let o=0;oe:1===e.length?e[0]:e.reduce((e,t)=>(...n)=>e(t(...n)))}function Rl(e){return({dispatch:t,getState:n})=>r=>o=>"function"==typeof o?o(t,n,e):r(o)}var xl=Rl(),Il=Rl,Pl="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Ml:Ml.apply(null,arguments)};"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;function _l(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw new Error(os(0));return{type:e,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>function(e){return Al(e)&&"type"in e&&"string"==typeof e.type}(t)&&t.type===e,n}var Ll=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Gl(e){return at(e)?an(e,()=>{}):e}function Fl(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}var zl="RTK_autoBatch",jl=e=>t=>{setTimeout(t,e)},ql=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let o=!0,a=!1,i=!1;const l=new Set,s="tick"===e.type?queueMicrotask:"raf"===e.type?"undefined"!=typeof window&&window.requestAnimationFrame?(u=window.requestAnimationFrame,c=100,e=>{let t=!1;const n=()=>{t||(t=!0,cancelAnimationFrame(r),clearTimeout(o),e())},r=u(n),o=setTimeout(n,c)}):jl(10):"callback"===e.type?e.queueNotification:jl(e.timeout);var u,c;const d=()=>{i=!1,a&&(a=!1,l.forEach(e=>e()))};return Object.assign({},r,{subscribe(e){const t=r.subscribe(()=>o&&e());return l.add(e),()=>{t(),l.delete(e)}},dispatch(e){try{return o=!e?.meta?.[zl],a=!o,a&&(i||(i=!0,s(d))),r.dispatch(e)}finally{o=!0}}})};function Bl(e){const t=function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:o=!0}=e??{};let a=new Ll;return t&&("boolean"==typeof t?a.push(xl):a.push(Il(t.extraArgument))),a},{reducer:n,middleware:r,devTools:o=!0,duplicateMiddlewareCheck:a=!0,preloadedState:i,enhancers:l}=e||{};let s,u;if("function"==typeof n)s=n;else{if(!Al(n))throw new Error(os(1));s=$l(n)}u="function"==typeof r?r(t):t();let c=Ml;o&&(c=Pl({trace:!1,..."object"==typeof o&&o}));const d=function(...e){return t=>(n,r)=>{const o=t(n,r);let a=()=>{throw new Error(Ol(15))};const i={getState:o.getState,dispatch:(e,...t)=>a(e,...t)},l=e.map(e=>e(i));return a=Ml(...l)(o.dispatch),{...o,dispatch:a}}}(...u),f=(e=>function(t){const{autoBatch:n=!0}=t??{};let r=new Ll(e);return n&&r.push(ql("object"==typeof n?n:void 0)),r})(d);return Tl(s,i,c(..."function"==typeof l?l(f):f()))}function Vl(e){const t={},n=[];let r;const o={addCase(e,n){const r="string"==typeof e?e:e.type;if(!r)throw new Error(os(28));if(r in t)throw new Error(os(29));return t[r]=n,o},addAsyncThunk:(e,r)=>(r.pending&&(t[e.pending.type]=r.pending),r.rejected&&(t[e.rejected.type]=r.rejected),r.fulfilled&&(t[e.fulfilled.type]=r.fulfilled),r.settled&&n.push({matcher:e.settled,reducer:r.settled}),o),addMatcher:(e,t)=>(n.push({matcher:e,reducer:t}),o),addDefaultCase:e=>(r=e,o)};return e(o),[t,n,r]}var Hl=(e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t};var Ul=Symbol.for("rtk-slice-createasyncthunk");function Wl(e,t){return`${e}/${t}`}function Ql({creators:e}={}){const t=e?.asyncThunk?.[Ul];return function(e){const{name:n,reducerPath:r=n}=e;if(!n)throw new Error(os(11));const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},a=Object.keys(o),i={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},l={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error(os(12));if(n in i.sliceCaseReducersByType)throw new Error(os(13));return i.sliceCaseReducersByType[n]=t,l},addMatcher:(e,t)=>(i.sliceMatchers.push({matcher:e,reducer:t}),l),exposeAction:(e,t)=>(i.actionCreators[e]=t,l),exposeCaseReducer:(e,t)=>(i.sliceCaseReducersByName[e]=t,l)};function s(){const[t={},n=[],r]="function"==typeof e.extraReducers?Vl(e.extraReducers):[e.extraReducers],o={...t,...i.sliceCaseReducersByType};return function(e,t){let n,[r,o,a]=Vl(t);if("function"==typeof e)n=()=>Gl(e());else{const t=Gl(e);n=()=>t}function i(e=n(),t){let i=[r[t.type],...o.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];return 0===i.filter(e=>!!e).length&&(i=[a]),i.reduce((e,n)=>{if(n){if(ot(e)){const r=n(e,t);return void 0===r?e:r}if(at(e))return an(e,e=>n(e,t));{const r=n(e,t);if(void 0===r){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return r}}return e},e)}return i.getInitialState=n,i}(e.initialState,e=>{for(let t in o)e.addCase(t,o[t]);for(let t of i.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)})}a.forEach(r=>{const a=o[r],i={reducerName:r,type:Wl(n,r),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(a)?function({type:e,reducerName:t,createNotation:n},r,o){let a,i;if("reducer"in r){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(r))throw new Error(os(17));a=r.reducer,i=r.prepare}else a=r;o.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,i?_l(e,i):_l(e))}(i,a,l):function({type:e,reducerName:t},n,r,o){if(!o)throw new Error(os(18));const{payloadCreator:a,fulfilled:i,pending:l,rejected:s,settled:u,options:c}=n,d=o(e,a,c);r.exposeAction(t,d),i&&r.addCase(d.fulfilled,i);l&&r.addCase(d.pending,l);s&&r.addCase(d.rejected,s);u&&r.addMatcher(d.settled,u);r.exposeCaseReducer(t,{fulfilled:i||Yl,pending:l||Yl,rejected:s||Yl,settled:u||Yl})}(i,a,l,t)});const u=e=>e,c=new Map,d=new WeakMap;let f;function p(e,t){return f||(f=s()),f(e,t)}function h(){return f||(f=s()),f.getInitialState()}function m(t,n=!1){function r(e){let o=e[t];return void 0===o&&n&&(o=Fl(d,r,h)),o}function o(t=u){const r=Fl(c,n,()=>new WeakMap);return Fl(r,t,()=>{const r={};for(const[o,a]of Object.entries(e.selectors??{}))r[o]=Kl(a,t,()=>Fl(d,t,h),n);return r})}return{reducerPath:t,getSelectors:o,get selectors(){return o(r)},selectSlice:r}}const g={name:n,reducer:p,actions:i.actionCreators,caseReducers:i.sliceCaseReducersByName,getInitialState:h,...m(r),injectInto(e,{reducerPath:t,...n}={}){const o=t??r;return e.inject({reducerPath:o,reducer:p},n),{...g,...m(o,!0)}}};return g}}function Kl(e,t,n,r){function o(o,...a){let i=t(o);return void 0===i&&r&&(i=n()),e(i,...a)}return o.unwrapped=e,o}var Xl=Ql();function Yl(){}var{assign:Jl}=Object,Zl=Symbol.for("rtk-state-proxy-original"),es=new WeakMap,ts=e=>{if(!(t=e)||!t[Zl])throw new Error(os(25));var t;return e[Zl]},ns={},rs=(e=ns)=>e;function os(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}p();function as(e){e()}var is={notify(){},get:()=>[]};function ls(e,t){let n,r=is,o=0,a=!1;function i(){u.onStateChange&&u.onStateChange()}function l(){o++,n||(n=t?t.addNestedSub(i):e.subscribe(i),r=function(){let e=null,t=null;return{clear(){e=null,t=null},notify(){as(()=>{let t=e;for(;t;)t.callback(),t=t.next})},get(){const t=[];let n=e;for(;n;)t.push(n),n=n.next;return t},subscribe(n){let r=!0;const o=t={callback:n,next:null,prev:t};return o.prev?o.prev.next=o:e=o,function(){r&&null!==e&&(r=!1,o.next?o.next.prev=o.prev:t=o.prev,o.prev?o.prev.next=o.next:e=o.next)}}}}())}function s(){o--,n&&0===o&&(n(),n=void 0,r.clear(),r=is)}const u={addNestedSub:function(e){l();const t=r.subscribe(e);let n=!1;return()=>{n||(n=!0,t(),s())}},notifyNestedSubs:function(){r.notify()},handleChangeWrapper:i,isSubscribed:function(){return a},trySubscribe:function(){a||(a=!0,l())},tryUnsubscribe:function(){a&&(a=!1,s())},getListeners:()=>r};return u}var ss=(()=>!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement))(),us=(()=>"undefined"!=typeof navigator&&"ReactNative"===navigator.product)(),cs=(()=>ss||us?l().useLayoutEffect:l().useEffect)();Object.defineProperty,Object.getOwnPropertyNames,Object.getOwnPropertySymbols,Object.getOwnPropertyDescriptor,Object.getPrototypeOf,Object.prototype;var ds=Symbol.for("react-redux-context"),fs="undefined"!=typeof globalThis?globalThis:{};function ps(){if(!l().createContext)return{};const e=fs[ds]??=new Map;let t=e.get(l().createContext);return t||(t=l().createContext(null),e.set(l().createContext,t)),t}var hs=ps();var ms=function(e){const{children:t,context:n,serverState:r,store:o}=e,a=l().useMemo(()=>{const e=ls(o);return{store:o,subscription:e,getServerState:r?()=>r:void 0}},[o,r]),i=l().useMemo(()=>o.getState(),[o]);cs(()=>{const{subscription:e}=a;return e.onStateChange=e.notifyNestedSubs,e.trySubscribe(),i!==o.getState()&&e.notifyNestedSubs(),()=>{e.tryUnsubscribe(),e.onStateChange=void 0}},[a,i]);const s=n||hs;return l().createElement(s.Provider,{value:a},t)};function gs(e=hs){return function(){return l().useContext(e)}}var vs=gs();function bs(e=hs){const t=e===hs?vs:gs(e),n=()=>{const{store:e}=t();return e};return Object.assign(n,{withTypes:()=>n}),n}var ys=bs();function ws(e=hs){const t=e===hs?ys:bs(e),n=()=>t().dispatch;return Object.assign(n,{withTypes:()=>n}),n}var Ss=(e,t)=>e===t;function ks(e=hs){const t=e===hs?vs:gs(e),n=(e,n={})=>{const{equalityFn:r=Ss}="function"==typeof n?{equalityFn:n}:n;const o=t(),{store:a,subscription:i,getServerState:s}=o,u=(l().useRef(!0),l().useCallback({[e.name]:t=>e(t)}[e.name],[e])),c=(0,f().useSyncExternalStoreWithSelector)(i.addNestedSub,a.getState,s||a.getState,u,r);return l().useDebugValue(c),c};return Object.assign(n,{withTypes:()=>n}),n}const Es=e=>l().createElement("button",{type:"button","data-testid":e.testID,disabled:e.disabled&&!e.disabledTranslation,className:e.className,title:e.disabledTranslation&&e.disabled?e.disabledTranslation.title:e.title,onClick:t=>e.handleOnClick(t)},e.disabledTranslation&&e.disabled?e.disabledTranslation.label:e.label),Os=(0,l().forwardRef)((e,t)=>l().createElement("span",{...e.dragHandleAttributes,"data-testid":e.testID,ref:t,className:e.className,title:e.title},e.label)),Ns={name:"",value:"",label:""},Cs=e=>["atleast","atmost","exactly"].includes(cr(e)??""),Ds=[],As=e=>{const{match:t,handleOnChange:n}=e,r=l().useMemo(()=>"number"==typeof t.threshold?Math.max(0,t.threshold):1,[t.threshold]);return{thresholdNum:r,thresholdRule:l().useMemo(()=>({field:"",operator:"=",value:r}),[r]),thresholdSchema:l().useMemo(()=>({...e.schema,parseNumbers:!0}),[e.schema]),handleChangeMode:(0,l().useCallback)(e=>{Cs(e)&&"number"!=typeof t.threshold?n({...t,mode:e,threshold:1}):n({...t,mode:e})},[n,t]),handleChangeThreshold:(0,l().useCallback)(e=>{n({...t,threshold:uo(e,{parseNumbers:!0})})},[n,t])}},Ts="QueryBuilder was rendered with a truthy independentCombinators prop. This prop is deprecated and unnecessary. Furthermore, the initial query/defaultQuery prop was of type RuleGroupType instead of type RuleGroupIC. More info: https://react-querybuilder.js.org/docs/components/querybuilder#independent-combinators",$s="QueryBuilder was rendered with the deprecated and unnecessary independentCombinators prop. To use independent combinators, make sure the query/defaultQuery prop is of type RuleGroupIC when the component mounts. More info: https://react-querybuilder.js.org/docs/components/querybuilder#independent-combinators",Ms="A custom RuleGroup component has rendered a standard RuleGroup component with deprecated props. The combinator, not, and rules props should not be used. Instead, the full group object should be passed as the ruleGroup prop.",Rs="A custom RuleGroup component has rendered a standard Rule component with deprecated props. The field, operator, value, and valueSource props should not be used. Instead, the full rule object should be passed as the rule prop.",xs="QueryBuilder was rendered with both query and defaultQuery props. QueryBuilder must be either controlled or uncontrolled (specify either the query prop, or the defaultQuery prop, but not both). Decide between using a controlled or uncontrolled query builder and remove one of these props. More info: https://reactjs.org/link/controlled-components",Is="QueryBuilder is changing from an uncontrolled component to be controlled. This is likely caused by the query changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled query builder for the lifetime of the component. More info: https://reactjs.org/link/controlled-components",Ps="QueryBuilder is changing from a controlled component to be uncontrolled. This is likely caused by the query changing from defined to undefined, which should not happen. Decide between using a controlled or uncontrolled query builder for the lifetime of the component. More info: https://reactjs.org/link/controlled-components",_s="QueryBuilder was rendered with the enableDragAndDrop prop set to true, but either react-dnd was not detected or one of react-dnd-html5-backend or react-dnd-touch-backend was not detected. To enable drag-and-drop functionality, install react-dnd and one of the backend packages and wrap QueryBuilder in QueryBuilderDnD from @react-querybuilder/dnd.",Ls="Importing from react-querybuilder/debug is deprecated. To enable Redux DevTools for React Query Builder's internal store, set globalThis.__RQB_DEVTOOLS__ = true.",Gs="QueryBuilder was rendered with a qbId prop that is already in use by another mounted QueryBuilder. Each mounted query builder must have a unique qbId, so this query builder has fallen back to an automatically generated identifier. A qbId may be reused after the previous query builder has unmounted (see the preserveQueryStateOnUnmount prop), but not while it is still mounted.",Fs="QueryBuilder was rendered with the showUndoRedo prop set to true, but no undo/redo controls were available. To enable undo/redo, wrap QueryBuilder in the QueryBuilderHistory component from react-querybuilder/history, or provide your own controlElements.undoRedoActions component.",zs="QueryBuilder was rendered with a qbId prop that is different than the qbId it was mounted with. The qbId prop is only evaluated when the component mounts, so the new value has been ignored. To render a query builder with a different qbId, unmount the existing one first, e.g. by giving it a different React key.",js=Xl({name:"queries",initialState:{},reducers:{setQueryState:{prepare:(e,t)=>({payload:e,meta:{timestamp:t?.timestamp??Date.now(),fromHistory:!!t?.fromHistory}}),reducer:(e,{payload:{qbId:t,query:n}})=>{e[t]=n}},unsetQueryState:(e,{payload:{qbId:t}})=>{delete e[t]}},selectors:{getQuerySelectorById:(e,t)=>e[t]}}),qs=l().createContext(null),Bs=Xl({name:"warnings",initialState:{[Ts]:!1,[$s]:!1,[Ms]:!1,[Rs]:!1,[xs]:!1,[Is]:!1,[Ps]:!1,[_s]:!1,[Ls]:!1,[Gs]:!1,[zs]:!1,[Fs]:!1},reducers:{rqbWarn:(e,{payload:t})=>{e[t]||(console.error(t),e[t]=!0)}}}),Vs=function(...e){const t=Object.fromEntries((e=>e.flatMap(e=>{return"reducerPath"in(t=e)&&"string"==typeof t.reducerPath?[[e.reducerPath,e.reducer]]:Object.entries(e);var t}))(e)),n=()=>Object.keys(t).length?$l(t):rs;let r=n();function o(e,t){return r(e,t)}o.withLazyLoadedSlices=()=>o;const a={},i=Object.assign(function(e,n){return function(r,...o){return e(((e,t,n)=>Fl(es,e,()=>new Proxy(e,{get:(e,r,o)=>{if(r===Zl)return e;const a=Reflect.get(e,r,o);if(void 0===a){const e=n[r];if(void 0!==e)return e;const o=t[r];if(o){const e=o(void 0,{type:Hl()});if(void 0===e)throw new Error(os(24));return n[r]=e,e}}return a}})))(n?n(r,...o):r,t,a),...o)}},{original:ts});return Object.assign(o,{inject:(e,i={})=>{const{reducerPath:l,reducer:s}=e,u=t[l];return!i.overrideExisting&&u&&u!==s||(i.overrideExisting&&u!==s&&delete a[l],t[l]=s,r=n()),o},selector:i})}(js,Bs).withLazyLoadedSlices(),Hs=e=>ws(e),Us=e=>bs(e),Ws=e=>ks(e),Qs=new Map,Ks=e=>{const t=(Qs.get(e)??0)-1;return t>0?(Qs.set(e,t),t):(Qs.delete(e),0)},Xs=new Map,Ys=({payload:e,onQueryChange:t,options:n})=>r=>{r(js.actions.setQueryState(e,n)),"function"==typeof t&&t(e.query)},Js={useRQB_INTERNAL_QueryBuilderDispatch:Hs(Zs=qs),useRQB_INTERNAL_QueryBuilderStore:Us(Zs),useRQB_INTERNAL_QueryBuilderSelector:Ws(Zs)};var Zs;const eu=Js.useRQB_INTERNAL_QueryBuilderDispatch,tu=Js.useRQB_INTERNAL_QueryBuilderStore,nu=Js.useRQB_INTERNAL_QueryBuilderSelector,{rqbWarn:ru}=Bs.actions,ou={reducer:Vs,preloadedState:{queries:js.getInitialState(),warnings:Bs.getInitialState()},middleware:e=>e({serializableCheck:{ignoredActions:[js.actions.setQueryState.type],ignoredPaths:[/^queries\b.*\.rules\.\d+\.value$/]}})},au=e=>{eu();const{defaultQuery:t,queryProp:n}=e;(e=>{const[t,n]=(0,l().useState)(e),[r,o]=(0,l().useState)(null);e!==t&&(o(t),n(e))})(!!n)};function iu(e,t,n){eu()}const lu=e=>{const{optionList:t,optionsMap:n,defaultOption:r}=(0,l().useMemo)(()=>Jr({placeholder:e.translations.fields,optionList:e.fields,autoSelectOption:e.autoSelectField,baseOption:e.baseField}),[e.autoSelectField,e.baseField,e.fields,e.translations.fields]);return{fields:t,fieldMap:n,defaultField:r}};let su=null;function uu(e){if(!su){const t=e||globalThis?.__RQB_DEVTOOLS__;su=(e=>{const t=Bl({...ou,devTools:!!e&&/* v8 ignore next -- @preserve */{name:"React Query Builder"}});return t.addSlice=e=>{Vs.inject(e),t.dispatch({type:crypto.randomUUID().slice(0,8),meta:`Initializing state for slice "${e.name}"`})},t})(t)}return su}const cu=e=>t=>js.selectors.getQuerySelectorById({queries:t.queries},e),du={},fu={},pu=[],hu={},mu=()=>null,gu=()=>"",vu=()=>!0,bu=()=>{},yu=(...e)=>{console.log(...e)};function wu(e,t){const{query:n,defaultQuery:r,getValueEditorSeparator:o=mu,getRuleClassname:a=gu,getRuleGroupClassname:i=gu,onAddRule:s=vu,onAddGroup:u=vu,onMoveRule:c=vu,onMoveGroup:d=vu,onGroupRule:f=vu,onGroupGroup:p=vu,onRemove:h=vu,onQueryChange:m,showCombinatorsBetweenRules:g=!1,showNotToggle:v=!1,showShiftActions:b=!1,showCloneButtons:y=!1,showLockButtons:w=!1,showMuteButtons:S=!1,suppressStandardClassnames:k=!1,preserveQueryStateOnUnmount:E=!1,resetOnFieldChange:O=!0,resetOnOperatorChange:N=!1,autoSelectField:C=!0,autoSelectOperator:D=!0,autoSelectValue:A=!0,addRuleToNewGroups:T=!1,listsAsArrays:$=!1,parseNumbers:M=!1,disabled:R=!1,validator:x,onLog:I=yu,idGenerator:P,accessibleDescriptionGenerator:_=ui}=e,{qbId:L,resolveQbIdCollision:G,rqbContext:F,fields:z,fieldMap:j,combinators:q,getParameters:B,getOperatorsMain:V,getMatchModesMain:H,getRuleDefaultOperator:U,getSubQueryBuilderPropsMain:W,getValueEditorTypeMain:Q,getValueSourcesMain:K,getValuesMain:X,getRuleDefaultValue:Y,getInputTypeMain:J,createRule:Z,createRuleGroup:ee}=t,{controlClassnames:te,controlElements:ne,debugMode:re,enableDragAndDrop:oe,enableMountQueryChange:ae,showUndoRedo:ie,translations:le}=F,se=!!g,ue=!!v,ce=!!b,de=!!ie,fe=!!y,pe=!!w,he=!!S,me=!!O,ge=!!N,ve=!!C,be=!!D,ye=!!A,we=!!T,Se=!!$,ke=!!k,Ee=!!E,Oe=(e.maxLevels??0)>0?Number(e.maxLevels):1/0,Ne=(0,l().useCallback)((...e)=>{re&&I(...e)},[re,I]);qu(de,!!ne.undoRedoActions),au({defaultQuery:r,queryProp:n});const Ce=tu(),De=eu(),Ae=(0,l().useMemo)(()=>cu(L),[L]),Te=((e,t)=>{const n=l().useContext(ku);return nu(e,t)??n?.initialQuery})(Ae),$e=(0,l().useCallback)(()=>Ae(Ce.getState()),[Ce,Ae]),Me=(0,l().useMemo)(()=>ee(),[ee]),Re=((e,t)=>{const n=e.query??e.storeQuery??e.defaultQuery??e.fallbackQuery;return n.id?n:Ri(n,t)})({query:n,storeQuery:Te,defaultQuery:r,fallbackQuery:Me},{idGenerator:P}),[xe]=(0,l().useState)(Re),Ie=(0,l().useMemo)(()=>({...F,initialQuery:xe}),[F,xe]);(0,l().useEffect)(()=>{n&&!Object.is(n,Te)&&De(Ys({payload:{qbId:L,query:n},onQueryChange:void 0}))},[n,L,Te,De]);const Pe=(0,l().useMemo)(()=>gr(Re),[Re]),_e=!!e.independentCombinators&&!Pe;iu(0,_e||!_e&&e.independentCombinators);const Le=(0,l().useRef)(!1);(0,l().useEffect)(()=>{Le.current||(Le.current=!0,De(Ys({payload:{qbId:L,query:Re},onQueryChange:ae&&"function"==typeof m?m:void 0})))},[ae,m,L,De,Re]);const Ge=(0,l().useRef)(Re);(0,l().useEffect)(()=>{Ge.current=Re},[Re]);const Fe=(0,l().useRef)(Ee);(0,l().useEffect)(()=>{Fe.current=Ee},[Ee]),(0,l().useEffect)(()=>(e=>{const t=(Qs.get(e)??0)+1;return Qs.set(e,t),t})(L)>1?(Ks(L),G(),bu):(Ae(Ce.getState())||De(Ys({payload:{qbId:L,query:Ge.current},onQueryChange:void 0})),()=>{0!==Ks(L)||Fe.current||De(js.actions.unsetQueryState({qbId:L}))}),[L,De,Ce,Ae,G]);const ze=(0,l().useCallback)((e,t)=>{De(Ys({payload:{qbId:L,query:e},onQueryChange:m,options:t}))},[m,L,De]),je=(0,l().useRef)(ze);(0,l().useEffect)(()=>{je.current=ze},[ze]),(0,l().useEffect)(()=>(((e,t)=>{Xs.set(e,t)})(L,(e,t)=>je.current(e,t)),()=>(e=>{Xs.delete(e)})(L)),[L]);const qe=Array.isArray(R)&&R||pu,Be=!0===R,Ve=Re.disabled||qe.some(e=>0===e.length),He=(0,l().useMemo)(()=>((e={})=>{const{qbId:t,combinators:n,idGenerator:r,maxLevels:o=1/0,queryDisabled:a,respectDisabled:i=!0,disabledPaths:l,resetOnFieldChange:s,resetOnOperatorChange:u,getRuleDefaultOperator:c,getValueSources:d,getRuleDefaultValue:f,getMatchModes:p,freeze:h,onAddRule:m,onAddGroup:g,onRemove:v,onMoveRule:b,onMoveGroup:y,onGroupRule:w,onGroupGroup:S,onLog:k}=e,E=e=>k?.({qbId:t,...e}),O={respectDisabled:i,queryDisabled:a,disabledPaths:l},N=(e,t,n=!1)=>!!Pi(e,t,O,{asParent:n});return{addRule:(e,t,o,a)=>{if(N(e,o,!0))return void E({type:jn,rule:t,parentPath:o,query:e});const i=!m||m(t,o,e,a);if(!i)return void E({type:Bn,rule:t,parentPath:o,query:e});const l=!0===i?t:i,s=Li(e,l,o,{combinators:n,combinatorPreceding:l.combinatorPreceding,idGenerator:r,freeze:h});return E({type:Xn,query:e,newQuery:s,newRule:l,parentPath:o}),s},addGroup:(e,t,a,i)=>{if(a.length>=o)return;if(N(e,a,!0))return void E({type:jn,ruleGroup:t,parentPath:a,query:e});const l=!g||g(t,a,e,i);if(!l)return void E({type:Vn,ruleGroup:t,parentPath:a,query:e});const s=!0===l?t:l,u=Li(e,s,a,{combinators:n,combinatorPreceding:s.combinatorPreceding??void 0,idGenerator:r,freeze:h});return E({type:Xn,query:e,newQuery:u,newGroup:s,parentPath:a}),u},propChange:(e,t,n,r)=>{if(Pi(e,r,"disabled"===t?{queryDisabled:a}:O))return void E({type:qn,path:r,prop:t,value:n,query:e});const o=qi(e,t,n,r,{resetOnFieldChange:s,resetOnOperatorChange:u,getRuleDefaultOperator:c,getValueSources:d,getRuleDefaultValue:f,getMatchModes:p,freeze:h});return E({type:Jn,query:e,newQuery:o,prop:t,value:n,path:r}),o},removeRuleOrGroup:(e,t,n)=>{if(N(e,t))return void E({type:qn,path:t,query:e});const r=ti(t,e); -/* v8 ignore next -- @preserve */if(!r)return;if(v&&!v(r,t,e,n))return void E({type:Kn,ruleOrGroup:r,path:t,query:e});const o=Vi(e,t,{freeze:h});return E({type:Yn,query:e,newQuery:o,path:t,ruleOrGroup:r}),o},moveRule:(e,t,o,a,i)=>{if(N(e,t))return void E({type:qn,oldPath:t,newPath:o,query:e});const l=ti(t,e);if(!l)return;const s=Wi(e,t,o,{clone:a,combinators:n,idGenerator:r,freeze:h}),u=hr(l),c=u?y:b,d=!c||c(l,t,o,e,s,{clone:a,combinators:n},i);if(!d)return void E({type:u?Qn:Wn,ruleOrGroup:l,oldPath:t,newPath:o,clone:a,query:e,nextQuery:s});const f=hr(d)?d:s;return E({type:Zn,query:e,newQuery:f,oldPath:t,newPath:o,clone:a}),f},groupRule:(e,t,o,a,i)=>{if(N(e,t))return void E({type:qn,sourcePath:t,targetPath:o,query:e});const l=ti(t,e);if(!l)return;const s=Yi(e,t,o,{clone:a,combinators:n,idGenerator:r,freeze:h}),u=hr(l),c=u?S:w,d=!c||c(l,t,o,e,s,{clone:a,combinators:n},i);if(!d)return void E({type:u?Un:Hn,ruleOrGroup:l,sourcePath:t,targetPath:o,clone:a,query:e,nextQuery:s});const f=hr(d)?d:s;return E({type:er,query:e,newQuery:f,sourcePath:t,targetPath:o,clone:a}),f}}})({qbId:L,combinators:q,idGenerator:P,maxLevels:Oe,queryDisabled:Be,disabledPaths:qe,resetOnFieldChange:me,resetOnOperatorChange:ge,getRuleDefaultOperator:U,getValueSources:K,getRuleDefaultValue:Y,getMatchModes:H,onAddRule:s,onAddGroup:u,onRemove:h,onMoveRule:c,onMoveGroup:d,onGroupRule:f,onGroupGroup:p,onLog:Ne}),[q,H,U,Y,K,P,Ne,Oe,u,s,p,f,d,c,h,L,Be,qe,me,ge]),Ue=(0,l().useCallback)(e=>{const t=cu(L)(Ce.getState());if(!t)return;const n=e(t);n&&ze(n)},[ze,L,Ce]),We=(0,l().useCallback)((e,t,n)=>{Ue(r=>He.addRule(r,e,t,n))},[He,Ue]),Qe=(0,l().useCallback)((e,t,n)=>{Ue(r=>He.addGroup(r,e,t,n))},[He,Ue]),Ke=(0,l().useCallback)((e,t,n)=>{Ue(r=>He.propChange(r,e,t,n))},[He,Ue]),Xe=(0,l().useCallback)((e,t)=>{Ue(n=>He.removeRuleOrGroup(n,e,t))},[He,Ue]),Ye=(0,l().useCallback)((e,t,n,r)=>{Ue(o=>He.moveRule(o,e,t,n,r))},[He,Ue]),Je=(0,l().useCallback)((e,t,n,r)=>{Ue(o=>He.groupRule(o,e,t,n,r))},[He,Ue]),{validationResult:Ze,validationMap:et}=(0,l().useMemo)(()=>{const e="function"==typeof x&&Re?x(Re):du;return{validationResult:e,validationMap:"boolean"==typeof e?fu:e}},[Re,x]),tt=oe?"enabled":"disabled",nt=Pe||se?"enabled":"disabled",rt=(0,l().useMemo)(()=>"string"==typeof Re.combinator?{combinator:Re.combinator}:hu,[Re.combinator]),ot=(0,l().useMemo)(()=>Ir("queryBuilder",$r,{classNames:te,suppressStandardClassnames:ke,disabled:Be,validationResult:Ze}),[te,Be,ke,Ze]),at=(0,l().useCallback)(e=>ee(e??Pe),[ee,Pe]),it=(0,l().useMemo)(()=>({addRuleToNewGroups:we,accessibleDescriptionGenerator:_,autoSelectField:ve,autoSelectOperator:be,autoSelectValue:ye,classNames:te,combinators:q,getParameters:B,controls:ne,createRule:Z,createRuleGroup:at,disabledPaths:qe,enableDragAndDrop:oe,fieldMap:j,fields:z,dispatchQuery:ze,getQuery:$e,getInputType:J,getOperators:V,getMatchModes:H,getRuleClassname:a,getRuleDefaultOperator:U,getRuleDefaultValue:Y,getRuleGroupClassname:i,getSubQueryBuilderProps:W,getValueEditorSeparator:o,getValueEditorType:Q,getValues:X,getValueSources:K,independentCombinators:Pe,listsAsArrays:Se,maxLevels:Oe,parseNumbers:M,qbId:L,resetOnFieldChange:me,resetOnOperatorChange:ge,showCloneButtons:fe,showCombinatorsBetweenRules:se,showLockButtons:pe,showMuteButtons:he,showNotToggle:ue,showShiftActions:ce,showUndoRedo:de,suppressStandardClassnames:ke,validationMap:et}),[_,we,ve,be,ye,q,te,ne,Z,at,qe,ze,oe,j,z,J,V,H,$e,a,U,Y,i,W,o,Q,X,K,B,Pe,Se,Oe,M,L,me,ge,fe,se,pe,he,ue,ce,de,ke,et]);return{actions:(0,l().useMemo)(()=>({moveRule:Ye,onGroupAdd:Qe,onGroupRemove:Xe,onPropChange:Ke,onRuleAdd:We,onRuleRemove:Xe,groupRule:Je}),[Je,Ye,Qe,Ke,We,Xe]),rootGroup:Re,rootGroupDisabled:Ve,queryDisabled:Be,rqbContext:Ie,schema:it,translations:le,wrapperClassName:ot,dndEnabledAttr:tt,inlineCombinatorsAttr:nt,combinatorPropObject:rt}}const Su=e=>wu(e,(e=>{const{qbId:t,resolveQbIdCollision:n}=Fu(e.qbId),{fields:r,baseField:o,operators:a,baseOperator:i,combinators:s,baseCombinator:u,getParameters:c,translations:d,enableMountQueryChange:f=!0,controlClassnames:p,controlElements:h,getDefaultField:m,getDefaultOperator:g,getDefaultValue:v,getMatchModes:b,getOperators:y,getSubQueryBuilderProps:w,getValueEditorType:S,getValueSources:k,getInputType:E,getValues:O,autoSelectField:N=!0,autoSelectOperator:C=!0,autoSelectValue:D=!0,addRuleToNewGroups:A=!1,enableDragAndDrop:T,showUndoRedo:$,listsAsArrays:M=!1,debugMode:R=!1,idGenerator:x=di}=e,[I]=(0,l().useState)(e.query??e.defaultQuery),P=Lu({controlClassnames:p,controlElements:h,debugMode:R,enableDragAndDrop:T,enableMountQueryChange:f,showUndoRedo:$,translations:d,initialQuery:I,qbId:t,finalize:!0}),{translations:_}=P,{fields:L,fieldMap:G}=lu({fields:r,baseField:o,autoSelectField:N,translations:_}),{optionList:F}=(0,l().useMemo)(()=>Jr({optionList:s??fn,labelMap:cn,baseOption:u,autoSelectOption:!0}),[u,s]),z=(0,l().useCallback)((e,t,n)=>Jr({optionList:c?.(e,t,n)??[],autoSelectOption:!0}).optionList,[c]),{optionList:j}=(0,l().useMemo)(()=>Jr({optionList:a??dn,placeholder:_.operators,labelMap:un,baseOption:i,autoSelectOption:C}),[C,i,a,_.operators]),q=(0,l().useCallback)((e,{fieldData:t})=>Oi({field:e,fieldData:t,getOperators:y,operators:j,placeholder:_.operators,baseOption:i,autoSelectOption:C}),[C,i,y,j,_.operators]),B=(0,l().useCallback)(e=>Ni({field:e,fieldData:G[e],getDefaultOperator:g,getOperators:(e,t)=>q(e,t)}),[G,g,q]),V=(0,l().useCallback)((e,t,{fieldData:n})=>Ci({field:e,operator:t,fieldData:n,getValueEditorType:S}),[S]),H=(0,l().useCallback)((e,t,n)=>Si(G[e],t,k),[G,k]),U=(0,l().useCallback)((e,t)=>mi(G[e],b),[G,b]),W=(0,l().useCallback)((e,t)=>w?.(e,t)??{},[w]),Q=(0,l().useCallback)((e,t,{fieldData:n})=>Di({field:e,operator:t,fieldData:n,getValues:O,placeholder:_.values,autoSelectOption:D}),[D,O,_.values]),K=(0,l().useCallback)(e=>vi(e,{fieldData:G[e.field]??{},fields:L,getParameters:(e,t,n)=>z(e,t,n),listsAsArrays:M,getValueEditorType:(e,t,n)=>V(e,t,n),getValues:(e,t,n)=>Q(e,t,n),getDefaultValue:v&&((e,t)=>v(e,t))}),[G,L,v,V,Q,M,z]),X=(0,l().useCallback)((e,t,{fieldData:n})=>{if(E){const r=E(e,t,{fieldData:n});if(r)return r}return"text"},[E]),Y=(0,l().useCallback)(()=>Zi({fields:L,getDefaultField:m,getRuleDefaultOperator:e=>B(e),getValueSources:(e,t,n)=>H(e,t,n),getMatchModes:(e,t)=>U(e,t),getRuleDefaultValue:e=>K(e),idGenerator:x}),[L,m,U,B,K,H,x]);return{qbId:t,resolveQbIdCollision:n,rqbContext:P,fields:L,fieldMap:G,combinators:F,getParameters:z,getMatchModesMain:U,getOperatorsMain:q,getRuleDefaultOperator:B,getSubQueryBuilderPropsMain:W,getValueEditorTypeMain:V,getValueSourcesMain:H,getValuesMain:Q,getRuleDefaultValue:K,getInputTypeMain:X,createRule:Y,createRuleGroup:(0,l().useCallback)(e=>el({combinators:F,addRuleToNewGroups:A,createRule:Y,idGenerator:x},e),[A,F,Y,x])}})(e)),ku=(0,l().createContext)({}),Eu=l().memo(function(e){const t=Cu(e),{previewRef:n,dropRef:r,schema:{controls:{ruleGroupBodyElements:o,ruleGroupHeaderElements:a}}}=t,i=ju(t.addRule),s=ju(t.addGroup),u=ju(t.cloneGroup),c=ju(t.toggleLockGroup),d=ju(t.toggleMuteGroup),f=ju(t.removeGroup),p=ju(t.shiftGroupUp),h=ju(t.shiftGroupDown),m=(0,l().useMemo)(()=>({addRule:i,addGroup:s,cloneGroup:u,toggleLockGroup:c,toggleMuteGroup:d,removeGroup:f,shiftGroupUp:p,shiftGroupDown:h}),[i,s,u,c,d,f,p,h]);return l().createElement("div",{ref:n,title:t.accessibleDescription,className:t.outerClassName,"data-testid":yn,"data-not":t.ruleGroup.not?"true":void 0,"data-dragmonitorid":t.dragMonitorId,"data-dropmonitorid":t.dropMonitorId,"data-rule-group-id":t.id,"data-level":t.path.length,"data-path":JSON.stringify(t.path)},l().createElement("div",{ref:r,className:t.classNames.header},l().createElement(a,{...t,...m})),l().createElement("div",{className:t.classNames.body},l().createElement(o,{...t,...m})))}),Ou=l().memo(function(e){const{dragRef:t,schema:{controls:{shiftActions:n,undoRedoActions:r,dragHandle:o,combinatorSelector:a,notToggle:i,addRuleAction:s,addGroupAction:u,cloneGroupAction:c,lockGroupAction:d,muteGroupAction:f,removeGroupAction:p}}}=e,h=(0,l().useMemo)(()=>({level:e.path.length,path:e.path,disabled:e.disabled,context:e.context,validation:e.validationResult,schema:e.schema}),[e.path,e.disabled,e.context,e.validationResult,e.schema]),m=(0,l().useMemo)(()=>e.schema.showShiftActions?{shiftUp:e.translations.shiftActionUp.title,shiftDown:e.translations.shiftActionDown.title}:void 0,[e.schema.showShiftActions,e.translations]),g=(0,l().useMemo)(()=>e.schema.showShiftActions?{shiftUp:e.translations.shiftActionUp.label,shiftDown:e.translations.shiftActionDown.label}:void 0,[e.schema.showShiftActions,e.translations]),v=(0,l().useMemo)(()=>e.schema.showUndoRedo?{undo:e.translations.undo.title,redo:e.translations.redo.title}:void 0,[e.schema.showUndoRedo,e.translations]),b=(0,l().useMemo)(()=>e.schema.showUndoRedo?{undo:e.classNames.undoAction,redo:e.classNames.redoAction}:void 0,[e.classNames.redoAction,e.classNames.undoAction,e.schema.showUndoRedo]),y=(0,l().useMemo)(()=>e.schema.showUndoRedo?{undo:e.translations.undo.label,redo:e.translations.redo.label}:void 0,[e.schema.showUndoRedo,e.translations]);return l().createElement(l().Fragment,null,e.schema.showShiftActions&&e.path.length>0&&l().createElement(n,{key:Rn,...h,testID:Rn,titles:m,labels:g,className:e.classNames.shiftActions,shiftUp:e.shiftGroupUp,shiftDown:e.shiftGroupDown,shiftUpDisabled:e.shiftUpDisabled,shiftDownDisabled:e.shiftDownDisabled,ruleOrGroup:e.ruleGroup}),e.path.length>0&&e.schema.enableDragAndDrop&&l().createElement(o,{key:In,...h,testID:In,ref:t,title:e.translations.dragHandle.title,label:e.translations.dragHandle.label,className:e.classNames.dragHandle,dragHandleAttributes:e.dragHandleAttributes,ruleOrGroup:e.ruleGroup}),!e.schema.showCombinatorsBetweenRules&&!e.schema.independentCombinators&&l().createElement(a,{key:Dn,...h,testID:Dn,options:e.schema.combinators,value:e.combinator,title:e.translations.combinators.title,className:e.classNames.combinators,handleOnChange:e.onCombinatorChange,rules:e.ruleGroup.rules,ruleGroup:e.ruleGroup}),e.schema.showNotToggle&&l().createElement(i,{key:Mn,...h,testID:Mn,className:e.classNames.notToggle,title:e.translations.notToggle.title,label:e.translations.notToggle.label,checked:e.ruleGroup.not,handleOnChange:e.onNotToggleChange,ruleGroup:e.ruleGroup}),l().createElement(s,{key:Nn,...h,testID:Nn,label:e.translations.addRule.label,title:e.translations.addRule.title,className:e.classNames.addRule,handleOnClick:e.addRule,rules:e.ruleGroup.rules,ruleOrGroup:e.ruleGroup}),e.schema.maxLevels>e.path.length&&l().createElement(u,{key:Sn,...h,testID:Sn,label:e.translations.addGroup.label,title:e.translations.addGroup.title,className:e.classNames.addGroup,handleOnClick:e.addGroup,rules:e.ruleGroup.rules,ruleOrGroup:e.ruleGroup}),e.schema.showCloneButtons&&e.path.length>0&&l().createElement(c,{key:En,...h,testID:En,label:e.translations.cloneRuleGroup.label,title:e.translations.cloneRuleGroup.title,className:e.classNames.cloneGroup,handleOnClick:e.cloneGroup,rules:e.ruleGroup.rules,ruleOrGroup:e.ruleGroup}),e.schema.showLockButtons&&l().createElement(d,{key:_n,...h,testID:_n,label:e.translations.lockGroup.label,title:e.translations.lockGroup.title,className:e.classNames.lockGroup,handleOnClick:e.toggleLockGroup,rules:e.ruleGroup.rules,disabledTranslation:e.parentDisabled?void 0:e.translations.lockGroupDisabled,ruleOrGroup:e.ruleGroup}),e.schema.showMuteButtons&&l().createElement(f,{key:Gn,...h,testID:Gn,label:e.ruleGroup.muted?e.translations.unmuteGroup.label:e.translations.muteGroup.label,title:e.ruleGroup.muted?e.translations.unmuteGroup.title:e.translations.muteGroup.title,className:e.classNames.muteGroup,handleOnClick:e.toggleMuteGroup,rules:e.ruleGroup.rules,ruleOrGroup:e.ruleGroup}),e.schema.showUndoRedo&&0===e.path.length&&r&&l().createElement(r,{key:xn,...h,testID:xn,titles:v,labels:y,className:e.classNames.undoRedoActions,classNames:b,ruleOrGroup:e.ruleGroup}),e.path.length>0&&l().createElement(p,{key:kn,...h,testID:kn,label:e.translations.removeGroup.label,title:e.translations.removeGroup.title,className:e.classNames.removeGroup,handleOnClick:e.removeGroup,rules:e.ruleGroup.rules,ruleOrGroup:e.ruleGroup}))}),Nu=l().memo(function(e){const{schema:{controls:{combinatorSelector:t,inlineCombinator:n,ruleGroup:r,rule:o}}}=e;return l().createElement(l().Fragment,null,e.ruleGroup.rules.map((a,i,{length:s})=>{const u=e.pathsMemo[i],c=u.path,d=u.disabled||"string"!=typeof a&&a.disabled,f=0===e.path.length&&0===i,p=0===e.path.length&&i===s-1,h="string"==typeof a?[...c,a].join("-"):a.id;return l().createElement(l().Fragment,{key:h},i>0&&!e.schema.independentCombinators&&e.schema.showCombinatorsBetweenRules&&l().createElement(n,{key:wn,options:e.schema.combinators,value:e.combinator,title:e.translations.combinators.title,className:e.classNames.combinators,handleOnChange:e.onCombinatorChange,rules:e.ruleGroup.rules,level:e.path.length,context:e.context,validation:e.validationResult,component:t,path:c,disabled:e.disabled,schema:e.schema,ruleGroup:e.ruleGroup}),"string"==typeof a?l().createElement(n,{key:`${wn}-independent`,options:e.schema.combinators,value:a,title:e.translations.combinators.title,className:e.classNames.combinators,handleOnChange:t=>e.onIndependentCombinatorChange(t,i),rules:e.ruleGroup.rules,level:e.path.length,context:e.context,validation:e.validationResult,component:t,path:c,disabled:d,schema:e.schema,ruleGroup:e.ruleGroup}):hr(a)?l().createElement(r,{key:yn,id:a.id,schema:e.schema,actions:e.actions,path:c,translations:e.translations,ruleGroup:a,rules:a.rules,combinator:mr(a)?a.combinator:void 0,not:!!a.not,disabled:d,parentDisabled:e.parentDisabled||e.disabled,parentMuted:e.parentMuted||e.muted,shiftUpDisabled:f,shiftDownDisabled:p,context:e.context}):l().createElement(o,{key:bn,id:a.id,rule:a,field:a.field,operator:a.operator,value:a.value,valueSource:a.valueSource,schema:e.schema,actions:e.actions,path:c,disabled:d,parentDisabled:e.parentDisabled||e.disabled,parentMuted:e.parentMuted||e.muted,translations:e.translations,shiftUpDisabled:f,shiftDownDisabled:p,context:e.context}))}))}),Cu=e=>{const{id:t,path:n,ruleGroup:r,schema:{qbId:o,accessibleDescriptionGenerator:a,classNames:i,combinators:s,createRule:u,createRuleGroup:c,disabledPaths:d,independentCombinators:f,validationMap:p,enableDragAndDrop:h,getRuleGroupClassname:m,suppressStandardClassnames:g},actions:{onGroupAdd:v,onGroupRemove:b,onPropChange:y,onRuleAdd:w,moveRule:S},disabled:k,parentDisabled:E,parentMuted:O,shiftUpDisabled:N,shiftDownDisabled:C,combinator:D,rules:A,not:T,dropEffect:$="move",groupItems:M=!1,dragMonitorId:R="",dropMonitorId:x="",previewRef:I=null,dragRef:P=null,dropRef:_=null,isDragging:L=!1,isOver:G=!1,dropNotAllowed:F=!1}=e;iu(),zu(h,!!(R||x||I||P||_));const z=!!E||!!k,j=!!O||!!r?.muted,q=(0,l().useMemo)(()=>r?so(r,s):D??Kr(s),[D,s,r]),B=(0,l().useMemo)(()=>{if(r){if(r.combinator===q||f)return r;const e=structuredClone(r);return e.combinator=q,e}return{rules:A,not:T}},[q,f,T,r,A]),V=(0,l().useMemo)(()=>{return xr(Dr,e={classNames:i,suppressStandardClassnames:g,isOver:G,dropEffect:$,dropNotAllowed:F},e);var e},[i,$,F,G,g]),H=(0,l().useCallback)(e=>{z||y("combinator",e,n)},[z,y,n]),U=(0,l().useCallback)((e,t,r)=>{z||y("combinator",e,[...n,t])},[z,y,n]),W=(0,l().useCallback)((e,t)=>{z||y("not",e,n)},[z,y,n]),Q=(0,l().useCallback)((e,t)=>{if(!z){const e=u();w(e,n,t)}},[u,z,w,n]),K=(0,l().useCallback)((e,t)=>{if(!z){const e=c();v(e,n,t)}},[c,z,v,n]),X=(0,l().useCallback)(()=>{if(!z){const e=[...oi(n),n.at(-1)+1];S(n,e,!0)}},[z,S,n]),Y=(0,l().useCallback)((e,t)=>{z||N||S(n,"up",e?.altKey)},[z,S,n,N]),J=(0,l().useCallback)((e,t)=>{z||C||S(n,"down",e?.altKey)},[z,S,n,C]),Z=(0,l().useCallback)(()=>{y("disabled",!z,n)},[z,y,n]),ee=(0,l().useCallback)(()=>{y("muted",!B.muted,n)},[B.muted,y,n]),te=(0,l().useCallback)(()=>{z||b(n)},[z,b,n]),ne=p[t??/* v8 ignore start -- @preserve */""],re=(0,l().useMemo)(()=>bi(ne),[ne]),oe=(0,l().useMemo)(()=>f?null:Qr(s,q)?.className??"",[q,s,f]),ae=(0,l().useMemo)(()=>m(B),[m,B]),ie=(0,l().useMemo)(()=>Ir("ruleGroup",Tr,{classNames:i,suppressStandardClassnames:g,leadingClassNames:[ae,oe],disabled:z,muted:j,isDragging:L,isOver:G,groupItems:M,validationClassName:re}),[i,oe,z,j,M,L,G,ae,g,re]),le=Gu({disabled:z,disabledPaths:d,path:n,nestedArray:B.rules}),se=(0,l().useMemo)(()=>a({path:n,qbId:o}),[a,n,o]);return{...e,addGroup:K,addRule:Q,accessibleDescription:se,classNames:V,cloneGroup:X,combinator:q,disabled:z,dragMonitorId:R,dragRef:P,dropMonitorId:x,dropRef:_,isDragging:L,isOver:G,muted:j,onCombinatorChange:H,onGroupAdd:v,onIndependentCombinatorChange:U,onNotToggleChange:W,outerClassName:ie,parentDisabled:E,pathsMemo:le,previewRef:I,removeGroup:te,ruleGroup:B,shiftGroupUp:Y,shiftGroupDown:J,toggleLockGroup:Z,toggleMuteGroup:ee,validationClassName:re,validationResult:ne}},Du=({name:e,disabled:t,checked:n,label:r,handleOnChange:o})=>{const a=l().useId();return l().createElement("label",{htmlFor:a},l().createElement("input",{id:a,type:"radio",value:e,disabled:t,checked:n,onChange:e=>o(e.target.value)}),r)},Au=e=>{const{operator:t,value:n,handleOnChange:r,title:o,className:a,type:i="text",inputType:s,values:u=[],listsAsArrays:c,fieldData:d,disabled:f,separator:p=null,testID:h,selectorComponent:m=e.schema.controls.valueSelector,parseNumbers:g,skipHook:v,valueSource:b,...y}=e,{valueAsArray:w,multiValueHandler:S,bigIntValueHandler:k,parseNumberMethod:E,valueListItemClassName:O,inputTypeCoerced:N}=Tu(e);if("null"===t||"notNull"===t)return null;const C=d?.placeholder??"";if(!("between"!==t&&"notBetween"!==t||"select"!==i&&"text"!==i)){const t=["from","to"].map((t,n)=>"text"===i?l().createElement("input",{key:t,type:N,placeholder:C,value:w[n]??"",title:o,className:O,disabled:f,onChange:e=>S(e.target.value,n)}):l().createElement(m,{key:t,...y,schema:e.schema,title:o,className:O,handleOnChange:e=>S(e,n),disabled:f,value:w[n]??Kr(u),options:u,listsAsArrays:c}));return l().createElement("span",{"data-testid":h,className:a,title:o},t[0],p,t[1])}switch(i){case"select":case"multiselect":return l().createElement(m,{...y,schema:e.schema,testID:h,className:a,title:o,handleOnChange:r,disabled:f,value:n,options:u,multiple:"multiselect"===i,listsAsArrays:c});case"textarea":return l().createElement("textarea",{"data-testid":h,placeholder:C,value:n,title:o,className:a,disabled:f,onChange:e=>r(e.target.value)});case"switch":case"checkbox":return l().createElement("input",{"data-testid":h,type:"checkbox",className:a,title:o,onChange:e=>r(e.target.checked),checked:!!n,disabled:f});case"radio":return l().createElement("span",{"data-testid":h,className:a,title:o},u.map(e=>l().createElement(Du,{key:e.name,name:e.name,disabled:f,checked:n===e.name,handleOnChange:r,label:e.label})))}return"bigint"===s?l().createElement("input",{"data-testid":h,type:N,placeholder:C,value:`${n}`,title:o,className:a,disabled:f,onChange:e=>k(e.target.value)}):l().createElement("input",{"data-testid":h,type:N,placeholder:C,value:n,title:o,className:a,disabled:f,onChange:e=>r(uo(e.target.value,{parseNumbers:E}))})},Tu=e=>{const{handleOnChange:t,inputType:n,operator:r,value:o,listsAsArrays:a,parseNumbers:i,values:s,type:u,skipHook:c,schema:{classNames:d,suppressStandardClassnames:f}}=e;(0,l().useEffect)(()=>{const{reset:e,value:a}=(({skipHook:e,type:t,operator:n,value:r,inputType:o})=>e||"multiselect"===t||co.has(n)||!(Array.isArray(r)||"number"===o&&"string"==typeof r&&r.includes(","))?{reset:!1,value:r}:{reset:!0,value:lr(r,{retainEmptyStrings:!0})[0]??""})({skipHook:c,type:u??void 0,operator:r,value:o,inputType:n});e&&t(a)},[t,n,r,c,u,o]);const p=(0,l().useMemo)(()=>lr(o,{retainEmptyStrings:!0}),[o]),h=(0,l().useMemo)(()=>vo({parseNumbers:i,inputType:n}),[n,i]);return{valueAsArray:p,multiValueHandler:(0,l().useCallback)((e,n)=>{t((({value:e,index:t,valueAsArray:n,operator:r,values:o,listsAsArrays:a,parseNumberMethod:i})=>{const l=uo(e,{parseNumbers:i}),s=0===t&&(e=>"between"===e||"notBetween"===e)(r)&&(n.length<2||void 0===n[1]);if(n[t]===l&&!s)return a?n:ar(n,",");const u=[...n];return u[t]=l,s&&(u[1]=Kr(o)??""),a?u:ar(u,",")})({value:e,index:n,valueAsArray:p,operator:r,values:s,listsAsArrays:a,parseNumberMethod:h}))},[t,a,r,h,p,s]),bigIntValueHandler:(0,l().useCallback)(e=>{t(((e,t)=>{const n=uo(e,{parseNumbers:t,bigIntOnOverflow:!0});try{return BigInt(n)}catch{return n}})(e,h))},[t,h]),parseNumberMethod:h,valueListItemClassName:(m="valueListItem",g={classNames:d,suppressStandardClassnames:f},Rr(m,Cr[m],{},g)),inputTypeCoerced:fo(n,r)};var m,g},$u=e=>{const t=Lu(e);return l().createElement(ku.Provider,{value:t},e.children)},Mu=e=>{const{onChange:t,val:n}=Ru(e),r=(e=>{const{multiple:t,onChange:n}=e;return(0,l().useMemo)(()=>t?e=>n(Array.from(e.target.selectedOptions).map(e=>e.value)):e=>n(e.target.value),[t,n])})({multiple:e.multiple,onChange:t});return l().createElement("select",{"data-testid":e.testID,className:e.className,value:n,title:e.title,disabled:e.disabled,multiple:!!e.multiple,onChange:r},(o=e.options,Hr(o)?o.map(e=>l().createElement("optgroup",{key:e.label,label:e.label},e.options.map(e=>l().createElement("option",{key:e.name,value:e.name,disabled:e.disabled},e.label)))):Array.isArray(o)?o.map(e=>l().createElement("option",{key:e.name,value:e.name,disabled:e.disabled},e.label)):null));var o},Ru=e=>{const{handleOnChange:t,listsAsArrays:n=!1,multiple:r=!1,value:o}=e;return{onChange:(0,l().useCallback)(e=>{t(((e,{multiple:t,listsAsArrays:n}={})=>{if(!t)return e;const r=lr(e);return n?r:ar(r,",")})(e,{multiple:r,listsAsArrays:n}))},[t,n,r]),val:(0,l().useMemo)(()=>((e,t)=>t?lr(e).map(String):e)(o,r),[r,o])}},xu=({props:e})=>{const t=Su(e),n=t.schema.controls.ruleGroup,r=ku;return l().createElement(r.Provider,{key:t.dndEnabledAttr,value:t.rqbContext},l().createElement("div",{role:"form",className:t.wrapperClassName,"data-dnd":t.dndEnabledAttr,"data-inlinecombinators":t.inlineCombinatorsAttr},l().createElement(n,{translations:t.translations,ruleGroup:t.rootGroup,rules:t.rootGroup.rules,...t.combinatorPropObject,not:!!t.rootGroup.not,schema:t.schema,actions:t.actions,id:t.rootGroup.id,path:tr,disabled:t.rootGroupDisabled,shiftUpDisabled:!0,shiftDownDisabled:!0,parentDisabled:t.queryDisabled,context:e.context})))},Iu=()=>null,Pu=(0,l().forwardRef)(Iu),_u={},Lu=({finalize:e,...t})=>{const n=(0,l().useContext)(ku),r=(0,l().useMemo)(()=>((e={},t={},n)=>Lr(nr).reduce((r,[o,a])=>(r[o]=Ti(a,e[o],t[o],!n),r),{}))(t,n,e),[t,n,e]),o=e?!1!==n.enableDragAndDrop&&Ti(!1,t.enableDragAndDrop,n.enableDragAndDrop):t.enableDragAndDrop??n.enableDragAndDrop,a=(0,l().useMemo)(()=>((...e)=>({queryBuilder:Ei("queryBuilder",e),ruleGroup:Ei("ruleGroup",e),header:Ei("header",e),body:Ei("body",e),combinators:Ei("combinators",e),addRule:Ei("addRule",e),addGroup:Ei("addGroup",e),cloneRule:Ei("cloneRule",e),cloneGroup:Ei("cloneGroup",e),removeGroup:Ei("removeGroup",e),rule:Ei("rule",e),fields:Ei("fields",e),operators:Ei("operators",e),value:Ei("value",e),removeRule:Ei("removeRule",e),notToggle:Ei("notToggle",e),shiftActions:Ei("shiftActions",e),undoRedoActions:Ei("undoRedoActions",e),undoAction:Ei("undoAction",e),redoAction:Ei("redoAction",e),dragHandle:Ei("dragHandle",e),lockRule:Ei("lockRule",e),lockGroup:Ei("lockGroup",e),muteRule:Ei("muteRule",e),muteGroup:Ei("muteGroup",e),muted:Ei("muted",e),valueSource:Ei("valueSource",e),actionElement:Ei("actionElement",e),valueSelector:Ei("valueSelector",e),betweenRules:Ei("betweenRules",e),valid:Ei("valid",e),invalid:Ei("invalid",e),dndDragging:Ei("dndDragging",e),dndOver:Ei("dndOver",e),dndCopy:Ei("dndCopy",e),dndGroup:Ei("dndGroup",e),dndDropNotAllowed:Ei("dndDropNotAllowed",e),dndPreviewPosition:Ei("dndPreviewPosition",e),dndHidden:Ei("dndHidden",e),disabled:Ei("disabled",e),valueListItem:Ei("valueListItem",e),matchMode:Ei("matchMode",e),matchThreshold:Ei("matchThreshold",e),branches:Ei("branches",e),hasSubQuery:Ei("hasSubQuery",e),loading:Ei("loading",e),valueDateTimeRelative:Ei("valueDateTimeRelative",e)}))(n.controlClassnames,t.controlClassnames),[n.controlClassnames,t.controlClassnames]),i=(0,l().useMemo)(()=>({actionElement:a.actionElement,addGroup:a.addGroup,addRule:a.addRule,body:a.body,cloneGroup:a.cloneGroup,cloneRule:a.cloneRule,combinators:a.combinators,dragHandle:a.dragHandle,fields:a.fields,header:a.header,lockGroup:a.lockGroup,lockRule:a.lockRule,muteGroup:a.muteGroup,muteRule:a.muteRule,muted:a.muted,notToggle:a.notToggle,operators:a.operators,queryBuilder:a.queryBuilder,removeGroup:a.removeGroup,removeRule:a.removeRule,rule:a.rule,ruleGroup:a.ruleGroup,shiftActions:a.shiftActions,undoRedoActions:a.undoRedoActions,undoAction:a.undoAction,redoAction:a.redoAction,value:a.value,valueSelector:a.valueSelector,valueSource:a.valueSource,betweenRules:a.betweenRules,valid:a.valid,invalid:a.invalid,dndDragging:a.dndDragging,dndOver:a.dndOver,dndCopy:a.dndCopy,dndGroup:a.dndGroup,dndDropNotAllowed:a.dndDropNotAllowed,dndPreviewPosition:a.dndPreviewPosition,dndHidden:a.dndHidden,disabled:a.disabled,valueListItem:a.valueListItem,matchMode:a.matchMode,matchThreshold:a.matchThreshold,branches:a.branches,hasSubQuery:a.hasSubQuery,loading:a.loading,valueDateTimeRelative:a.valueDateTimeRelative}),[a.actionElement,a.addGroup,a.addRule,a.betweenRules,a.body,a.branches,a.cloneGroup,a.cloneRule,a.combinators,a.disabled,a.dndCopy,a.dndDropNotAllowed,a.dndPreviewPosition,a.dndHidden,a.dndGroup,a.dndDragging,a.dndOver,a.dragHandle,a.fields,a.hasSubQuery,a.header,a.invalid,a.loading,a.lockGroup,a.lockRule,a.muteGroup,a.muteRule,a.muted,a.matchMode,a.matchThreshold,a.notToggle,a.operators,a.queryBuilder,a.removeGroup,a.removeRule,a.rule,a.ruleGroup,a.shiftActions,a.undoRedoActions,a.undoAction,a.redoAction,a.valid,a.value,a.valueDateTimeRelative,a.valueListItem,a.valueSelector,a.valueSource]),s=n.controlElements??_u,u=t.controlElements??_u,c=(0,l().useCallback)((t,n,r)=>{const o="dragHandle"===t?Pu:Iu,a=(t.endsWith("Action")&&u.actionElement?u.actionElement:void 0)??(t.endsWith("Selector")&&u.valueSelector?u.valueSelector:void 0),i=(t.endsWith("Action")&&s.actionElement?s.actionElement:void 0)??(t.endsWith("Selector")&&s.valueSelector?s.valueSelector:void 0),l=null===n?o:n??(e?a:void 0)??(null===r?o:r??(e?i:void 0));return l?{[t]:l}:e?{[t]:Xu[t]}:_u},[s.actionElement,s.valueSelector,e,u.actionElement,u.valueSelector]),d=(0,l().useMemo)(()=>Object.assign({},c("addGroupAction",u.addGroupAction,s.addGroupAction),c("addRuleAction",u.addRuleAction,s.addRuleAction),c("cloneGroupAction",u.cloneGroupAction,s.cloneGroupAction),c("cloneRuleAction",u.cloneRuleAction,s.cloneRuleAction),c("combinatorSelector",u.combinatorSelector,s.combinatorSelector),c("dragHandle",u.dragHandle,s.dragHandle),c("fieldSelector",u.fieldSelector,s.fieldSelector),c("inlineCombinator",u.inlineCombinator,s.inlineCombinator),c("lockGroupAction",u.lockGroupAction,s.lockGroupAction),c("lockRuleAction",u.lockRuleAction,s.lockRuleAction),c("muteGroupAction",u.muteGroupAction,s.muteGroupAction),c("muteRuleAction",u.muteRuleAction,s.muteRuleAction),c("notToggle",u.notToggle,s.notToggle),c("operatorSelector",u.operatorSelector,s.operatorSelector),c("removeGroupAction",u.removeGroupAction,s.removeGroupAction),c("removeRuleAction",u.removeRuleAction,s.removeRuleAction),c("shiftActions",u.shiftActions,s.shiftActions),c("undoRedoActions",u.undoRedoActions,s.undoRedoActions),{valueEditor:null===u.valueEditor?Iu:u.valueEditor??(null===s.valueEditor?Iu:s.valueEditor)??Xu.valueEditor},c("valueSourceSelector",u.valueSourceSelector,s.valueSourceSelector),c("matchModeEditor",u.matchModeEditor,s.matchModeEditor),c("rule",u.rule,s.rule),c("ruleGroup",u.ruleGroup,s.ruleGroup),c("ruleGroupBodyElements",u.ruleGroupBodyElements,s.ruleGroupBodyElements),c("ruleGroupHeaderElements",u.ruleGroupHeaderElements,s.ruleGroupHeaderElements),{actionElement:u.actionElement??s.actionElement??(e?Xu.actionElement:void 0)},{valueSelector:u.valueSelector??s.valueSelector??(e?Xu.valueSelector:void 0)}),[s.actionElement,s.addGroupAction,s.addRuleAction,s.cloneGroupAction,s.cloneRuleAction,s.combinatorSelector,s.dragHandle,s.fieldSelector,s.inlineCombinator,s.lockGroupAction,s.lockRuleAction,s.muteGroupAction,s.muteRuleAction,s.matchModeEditor,s.notToggle,s.operatorSelector,s.removeGroupAction,s.removeRuleAction,s.rule,s.ruleGroup,s.ruleGroupBodyElements,s.ruleGroupHeaderElements,s.shiftActions,s.undoRedoActions,s.valueEditor,s.valueSelector,s.valueSourceSelector,c,e,u.actionElement,u.addGroupAction,u.addRuleAction,u.cloneGroupAction,u.cloneRuleAction,u.combinatorSelector,u.dragHandle,u.fieldSelector,u.inlineCombinator,u.lockGroupAction,u.lockRuleAction,u.muteGroupAction,u.muteRuleAction,u.matchModeEditor,u.notToggle,u.operatorSelector,u.removeGroupAction,u.removeRuleAction,u.rule,u.ruleGroup,u.ruleGroupBodyElements,u.ruleGroupHeaderElements,u.shiftActions,u.undoRedoActions,u.valueEditor,u.valueSelector,u.valueSourceSelector]),f=t.translations??_u,p=n.translations??_u;return{...r,controlClassnames:i,controlElements:d,enableDragAndDrop:o,translations:(0,l().useMemo)(()=>Object.assign({},ki("addGroup",{label:[f.addGroup?.label,p.addGroup?.label],title:[f.addGroup?.title,p.addGroup?.title]},e?sn:void 0),ki("addRule",{label:[f.addRule?.label,p.addRule?.label],title:[f.addRule?.title,p.addRule?.title]},e?sn:void 0),ki("cloneRule",{label:[f.cloneRule?.label,p.cloneRule?.label],title:[f.cloneRule?.title,p.cloneRule?.title]},e?sn:void 0),ki("cloneRuleGroup",{label:[f.cloneRuleGroup?.label,p.cloneRuleGroup?.label],title:[f.cloneRuleGroup?.title,p.cloneRuleGroup?.title]},e?sn:void 0),ki("combinators",{title:[f.combinators?.title,p.combinators?.title]},e?sn:void 0),ki("dragHandle",{label:[f.dragHandle?.label,p.dragHandle?.label],title:[f.dragHandle?.title,p.dragHandle?.title]},e?sn:void 0),ki("fields",{placeholderGroupLabel:[f.fields?.placeholderGroupLabel,p.fields?.placeholderGroupLabel],placeholderLabel:[f.fields?.placeholderLabel,p.fields?.placeholderLabel],placeholderName:[f.fields?.placeholderName,p.fields?.placeholderName],title:[f.fields?.title,p.fields?.title]},e?sn:void 0),ki("lockGroup",{label:[f.lockGroup?.label,p.lockGroup?.label],title:[f.lockGroup?.title,p.lockGroup?.title]},e?sn:void 0),ki("lockGroupDisabled",{label:[f.lockGroupDisabled?.label,p.lockGroupDisabled?.label],title:[f.lockGroupDisabled?.title,p.lockGroupDisabled?.title]},e?sn:void 0),ki("lockRule",{label:[f.lockRule?.label,p.lockRule?.label],title:[f.lockRule?.title,p.lockRule?.title]},e?sn:void 0),ki("lockRuleDisabled",{label:[f.lockRuleDisabled?.label,p.lockRuleDisabled?.label],title:[f.lockRuleDisabled?.title,p.lockRuleDisabled?.title]},e?sn:void 0),ki("muteGroup",{label:[f.muteGroup?.label,p.muteGroup?.label],title:[f.muteGroup?.title,p.muteGroup?.title]},e?sn:void 0),ki("unmuteGroup",{label:[f.unmuteGroup?.label,p.unmuteGroup?.label],title:[f.unmuteGroup?.title,p.unmuteGroup?.title]},e?sn:void 0),ki("muteRule",{label:[f.muteRule?.label,p.muteRule?.label],title:[f.muteRule?.title,p.muteRule?.title]},e?sn:void 0),ki("unmuteRule",{label:[f.unmuteRule?.label,p.unmuteRule?.label],title:[f.unmuteRule?.title,p.unmuteRule?.title]},e?sn:void 0),ki("notToggle",{label:[f.notToggle?.label,p.notToggle?.label],title:[f.notToggle?.title,p.notToggle?.title]},e?sn:void 0),ki("operators",{placeholderGroupLabel:[f.operators?.placeholderGroupLabel,p.operators?.placeholderGroupLabel],placeholderLabel:[f.operators?.placeholderLabel,p.operators?.placeholderLabel],placeholderName:[f.operators?.placeholderName,p.operators?.placeholderName],title:[f.operators?.title,p.operators?.title]},e?sn:void 0),ki("values",{placeholderGroupLabel:[f.values?.placeholderGroupLabel,p.values?.placeholderGroupLabel],placeholderLabel:[f.values?.placeholderLabel,p.values?.placeholderLabel],placeholderName:[f.values?.placeholderName,p.values?.placeholderName],title:[f.values?.title,p.values?.title]},e?sn:void 0),ki("removeGroup",{label:[f.removeGroup?.label,p.removeGroup?.label],title:[f.removeGroup?.title,p.removeGroup?.title]},e?sn:void 0),ki("removeRule",{label:[f.removeRule?.label,p.removeRule?.label],title:[f.removeRule?.title,p.removeRule?.title]},e?sn:void 0),ki("shiftActionDown",{label:[f.shiftActionDown?.label,p.shiftActionDown?.label],title:[f.shiftActionDown?.title,p.shiftActionDown?.title]},e?sn:void 0),ki("shiftActionUp",{label:[f.shiftActionUp?.label,p.shiftActionUp?.label],title:[f.shiftActionUp?.title,p.shiftActionUp?.title]},e?sn:void 0),ki("undo",{label:[f.undo?.label,p.undo?.label],title:[f.undo?.title,p.undo?.title]},e?sn:void 0),ki("redo",{label:[f.redo?.label,p.redo?.label],title:[f.redo?.title,p.redo?.title]},e?sn:void 0),ki("matchMode",{title:[f.matchMode?.title,p.matchMode?.title]},e?sn:void 0),ki("matchThreshold",{title:[f.matchThreshold?.title,p.matchThreshold?.title],placeholderName:[f.matchThreshold?.placeholderName,p.matchThreshold?.placeholderName]},e?sn:void 0),ki("value",{title:[f.value?.title,p.value?.title]},e?sn:void 0),ki("valueSourceSelector",{title:[f.valueSourceSelector?.title,p.valueSourceSelector?.title]},e?sn:void 0)),[p.addGroup?.label,p.addGroup?.title,p.addRule?.label,p.addRule?.title,p.cloneRule?.label,p.cloneRule?.title,p.cloneRuleGroup?.label,p.cloneRuleGroup?.title,p.combinators?.title,p.dragHandle?.label,p.dragHandle?.title,p.fields?.placeholderGroupLabel,p.fields?.placeholderLabel,p.fields?.placeholderName,p.fields?.title,p.lockGroup?.label,p.lockGroup?.title,p.lockGroupDisabled?.label,p.lockGroupDisabled?.title,p.lockRule?.label,p.lockRule?.title,p.lockRuleDisabled?.label,p.lockRuleDisabled?.title,p.muteGroup?.label,p.muteGroup?.title,p.unmuteGroup?.label,p.unmuteGroup?.title,p.muteRule?.label,p.muteRule?.title,p.unmuteRule?.label,p.unmuteRule?.title,p.matchMode?.title,p.matchThreshold?.title,p.matchThreshold?.placeholderName,p.notToggle?.label,p.notToggle?.title,p.operators?.placeholderGroupLabel,p.operators?.placeholderLabel,p.operators?.placeholderName,p.operators?.title,p.removeGroup?.label,p.removeGroup?.title,p.removeRule?.label,p.removeRule?.title,p.shiftActionDown?.label,p.shiftActionDown?.title,p.shiftActionUp?.label,p.shiftActionUp?.title,p.undo?.label,p.undo?.title,p.redo?.label,p.redo?.title,p.value?.title,p.values?.placeholderGroupLabel,p.values?.placeholderLabel,p.values?.placeholderName,p.values?.title,p.valueSourceSelector?.title,e,f.addGroup?.label,f.addGroup?.title,f.addRule?.label,f.addRule?.title,f.cloneRule?.label,f.cloneRule?.title,f.cloneRuleGroup?.label,f.cloneRuleGroup?.title,f.combinators?.title,f.dragHandle?.label,f.dragHandle?.title,f.fields?.placeholderGroupLabel,f.fields?.placeholderLabel,f.fields?.placeholderName,f.fields?.title,f.lockGroup?.label,f.lockGroup?.title,f.lockGroupDisabled?.label,f.lockGroupDisabled?.title,f.lockRule?.label,f.lockRule?.title,f.lockRuleDisabled?.label,f.lockRuleDisabled?.title,f.muteGroup?.label,f.muteGroup?.title,f.unmuteGroup?.label,f.unmuteGroup?.title,f.muteRule?.label,f.muteRule?.title,f.unmuteRule?.label,f.unmuteRule?.title,f.matchMode?.title,f.matchThreshold?.title,f.matchThreshold?.placeholderName,f.notToggle?.label,f.notToggle?.title,f.operators?.placeholderGroupLabel,f.operators?.placeholderLabel,f.operators?.placeholderName,f.operators?.title,f.removeGroup?.label,f.removeGroup?.title,f.removeRule?.label,f.removeRule?.title,f.shiftActionDown?.label,f.shiftActionDown?.title,f.shiftActionUp?.label,f.shiftActionUp?.title,f.undo?.label,f.undo?.title,f.redo?.label,f.redo?.title,f.value?.title,f.values?.placeholderGroupLabel,f.values?.placeholderLabel,f.values?.placeholderName,f.values?.title,f.valueSourceSelector?.title]),initialQuery:t.initialQuery,qbId:t.qbId}},Gu=({disabled:e,path:t,nestedArray:n,disabledPaths:r})=>{const o=n.length;return(0,l().useMemo)(()=>((e,t,{disabled:n=!1,disabledPaths:r=[]}={})=>{const o=[];for(let a=0;aai(t,e))}}return o})(t,o,{disabled:e,disabledPaths:r}),[e,t,o,r])},Fu=e=>{const t=eu(),[n,r]=(0,l().useState)(()=>e??di()),[o]=(0,l().useState)(e);return{qbId:n,resolveQbIdCollision:(0,l().useCallback)(()=>{r(di())},[t])}};const zu=(e,t)=>{0},ju=e=>(0,l().useCallback)((t,n)=>{t?.preventDefault(),t?.stopPropagation(),e(t,n)},[e]);const qu=(e,t)=>{0},Bu={mode:"all"},Vu=[{name:"",value:"",label:""}],Hu=l().memo(function(e){const t=Ku(e),{dndRef:n}=t,r=ju(t.cloneRule),o=ju(t.toggleLockRule),a=ju(t.toggleMuteRule),i=ju(t.removeRule),s=ju(t.shiftRuleUp),u=ju(t.shiftRuleDown),c=(0,l().useMemo)(()=>({cloneRule:r,toggleLockRule:o,toggleMuteRule:a,removeRule:i,shiftRuleUp:s,shiftRuleDown:u}),[r,i,u,s,o,a]);return l().createElement("div",{ref:n,"data-testid":bn,"data-dragmonitorid":t.dragMonitorId,"data-dropmonitorid":t.dropMonitorId,className:t.outerClassName,"data-rule-id":t.id,"data-level":t.path.length,"data-path":JSON.stringify(t.path)},t.matchModes.length>0?l().createElement(Qu,{...t,...c}):l().createElement(Uu,{...t,...c}))}),Uu=l().memo(function(e){const{dragRef:t,schema:{controls:{shiftActions:n,dragHandle:r,fieldSelector:o,matchModeEditor:a,operatorSelector:i,valueSourceSelector:s,valueEditor:u,cloneRuleAction:c,lockRuleAction:d,muteRuleAction:f,removeRuleAction:p,ruleGroupBodyElements:h,ruleGroupHeaderElements:m}},groupComponentsWrapper:g=l().Fragment}=e,v=(0,l().useMemo)(()=>({level:e.path.length,path:e.path,disabled:e.disabled,context:e.context,validation:e.validationResult,schema:e.schema,rule:e.rule}),[e.path,e.disabled,e.context,e.validationResult,e.schema,e.rule]),b=(0,l().useMemo)(()=>!(1===e.schema.fields.length&&fr(e.schema.fields[0])&&"value"in e.schema.fields[0]&&""===e.schema.fields[0].value),[e.schema.fields]),y=(0,l().useMemo)(()=>e.schema.showShiftActions?{shiftUp:e.translations.shiftActionUp.title,shiftDown:e.translations.shiftActionDown.title}:void 0,[e.schema.showShiftActions,e.translations]),w=(0,l().useMemo)(()=>e.schema.showShiftActions?{shiftUp:e.translations.shiftActionUp.label,shiftDown:e.translations.shiftActionDown.label}:void 0,[e.schema.showShiftActions,e.translations]);return l().createElement(l().Fragment,null,e.schema.showShiftActions&&l().createElement(n,{key:Rn,...v,testID:Rn,titles:y,labels:w,className:e.classNames.shiftActions,ruleOrGroup:e.rule,shiftUp:e.shiftRuleUp,shiftDown:e.shiftRuleDown,shiftUpDisabled:e.shiftUpDisabled,shiftDownDisabled:e.shiftDownDisabled}),e.schema.enableDragAndDrop&&l().createElement(r,{key:In,...v,testID:In,ref:t,title:e.translations.dragHandle.title,label:e.translations.dragHandle.label,className:e.classNames.dragHandle,dragHandleAttributes:e.dragHandleAttributes,ruleOrGroup:e.rule}),b&&l().createElement(o,{key:An,...v,testID:An,options:e.schema.fields,title:e.translations.fields.title,value:e.rule.field,operator:e.rule.operator,className:e.classNames.fields,handleOnChange:e.onChangeField}),(e.schema.autoSelectField||e.rule.field!==e.translations.fields.placeholderName)&&(e.subQuery?l().createElement(a,{key:zn,...v,testID:zn,field:e.rule.field,fieldData:e.fieldData,title:e.translations.matchMode.title,options:e.matchModes,thresholdPlaceholder:e.translations.matchThreshold.placeholderName,match:e.rule.match??/* v8 ignore start -- @preserve */Bu,className:e.classNames.matchMode,classNames:e.classNames,handleOnChange:e.onChangeMatchMode}):l().createElement(l().Fragment,null,l().createElement(i,{key:Tn,...v,testID:Tn,field:e.rule.field,fieldData:e.fieldData,title:e.translations.operators.title,options:e.operators,value:e.rule.operator,className:e.classNames.operators,handleOnChange:e.onChangeOperator}),(e.schema.autoSelectOperator||e.rule.operator!==e.translations.operators.placeholderName)&&!e.hideValueControls&&l().createElement(l().Fragment,null,!["null","notnull"].includes(cr(`${e.rule.operator}`))&&e.valueSources.length>1&&l().createElement(s,{key:Fn,...v,testID:Fn,field:e.rule.field,fieldData:e.fieldData,title:e.translations.valueSourceSelector.title,options:e.valueSourceOptions,value:e.rule.valueSource??"value",className:e.classNames.valueSource,handleOnChange:e.onChangeValueSource}),l().createElement(u,{key:$n,...v,testID:$n,field:e.rule.field,fieldData:e.fieldData,title:e.translations.value.title,operator:e.rule.operator,value:e.rule.value,valueSource:e.rule.valueSource??"value",type:e.valueEditorType,inputType:e.inputType,values:e.values,listsAsArrays:e.schema.listsAsArrays,parseNumbers:e.schema.parseNumbers,separator:e.valueEditorSeparator,className:e.classNames.value,handleOnChange:e.onChangeValue})))),e.subQuery&&l().createElement(g,{className:e.subQuery.classNames.header},l().createElement(m,e.subQuery)),e.schema.showCloneButtons&&l().createElement(c,{key:On,...v,testID:On,label:e.translations.cloneRule.label,title:e.translations.cloneRule.title,className:e.classNames.cloneRule,ruleOrGroup:e.rule,handleOnClick:e.cloneRule}),e.schema.showLockButtons&&l().createElement(d,{key:Pn,...v,testID:Pn,label:e.translations.lockRule.label,title:e.translations.lockRule.title,className:e.classNames.lockRule,ruleOrGroup:e.rule,handleOnClick:e.toggleLockRule,disabledTranslation:e.parentDisabled?void 0:e.translations.lockRuleDisabled}),e.schema.showMuteButtons&&l().createElement(f,{key:Ln,...v,testID:Ln,label:e.rule.muted?e.translations.unmuteRule.label:e.translations.muteRule.label,title:e.rule.muted?e.translations.unmuteRule.title:e.translations.muteRule.title,className:e.classNames.muteRule,ruleOrGroup:e.rule,handleOnClick:e.toggleMuteRule}),l().createElement(p,{key:Cn,...v,testID:Cn,label:e.translations.removeRule.label,title:e.translations.removeRule.title,className:e.classNames.removeRule,ruleOrGroup:e.rule,handleOnClick:e.removeRule}),e.subQuery&&l().createElement(g,{className:e.subQuery.classNames.body},l().createElement(h,e.subQuery)))}),Wu=e=>l().createElement("div",e),Qu=l().memo(function(e){const t=(0,l().useMemo)(()=>e.schema.createRuleGroup(),[e.schema]),n=Su({...e.subQueryBuilderProps,enableDragAndDrop:!1,disabled:e.disabled,fields:e.subproperties.fields,enableMountQueryChange:!hr(e.rule.value)||!e.rule.value.id,query:hr(e.rule.value)?e.rule.value:t,onQueryChange:e.onChangeValue}),r=Cu({...n,ruleGroup:n.rootGroup,path:tr,disabled:e.disabled,parentDisabled:n.queryDisabled,id:n.rootGroup.id,shiftUpDisabled:!0,shiftDownDisabled:!0}),o=ju(r.addRule),a=ju(r.addGroup),i=ju(r.cloneGroup),s=ju(r.toggleLockGroup),u=ju(r.removeGroup),c=ju(r.shiftGroupUp),d=ju(r.shiftGroupDown),f=(0,l().useMemo)(()=>({...r,addGroup:a,addRule:o,cloneGroup:i,removeGroup:u,shiftGroupDown:d,shiftGroupUp:c,toggleLockGroup:s}),[a,o,i,u,d,c,r,s]);return l().createElement(Uu,{...e,groupComponentsWrapper:e.groupComponentsWrapper??Wu,subQuery:f})}),Ku=e=>{const{id:t,path:n,rule:r,schema:{classNames:o,fields:a,fieldMap:i,getParameters:s,getInputType:u,getMatchModes:c,getOperators:d,getSubQueryBuilderProps:f,getValueEditorType:p,getValueEditorSeparator:h,getValueSources:m,getValues:g,validationMap:v,enableDragAndDrop:b,getRuleClassname:y,suppressStandardClassnames:w},actions:{moveRule:S,onPropChange:k,onRuleRemove:E},disabled:O,parentDisabled:N,parentMuted:C,shiftUpDisabled:D,shiftDownDisabled:A,field:T,operator:$,value:M,valueSource:R,dropEffect:x="move",groupItems:I=!1,dragMonitorId:P="",dropMonitorId:_="",dndRef:L=null,dragRef:G=null,isDragging:F=!1,isOver:z=!1,dropNotAllowed:j=!1}=e;iu(),zu(b,!!(P||_||L||G));const q=!!N||!!O,B=!!C||!!r?.muted,V=(0,l().useMemo)(()=>r??{id:t,field:T??/* v8 ignore start -- @preserve */"",operator:$??/* v8 ignore start -- @preserve */"",value:M,valueSource:R},[T,t,$,r,M,R]),H=(0,l().useMemo)(()=>xr(Cr,{},{classNames:o,suppressStandardClassnames:w}),[o,w]),U=(0,l().useCallback)(e=>(t,r)=>{q||k(e,t,n,r)},[q,k,n]),W=(0,l().useMemo)(()=>U("field"),[U]),Q=(0,l().useMemo)(()=>U("operator"),[U]),K=(0,l().useMemo)(()=>U("match"),[U]),X=(0,l().useMemo)(()=>U("valueSource"),[U]),Y=(0,l().useMemo)(()=>U("value"),[U]),J=(0,l().useCallback)((e,t)=>{if(!q){const e=[...oi(n),n.at(-1)+1];S(n,e,!0,t)}},[q,S,n]),Z=(0,l().useCallback)((e,t)=>k("disabled",!q,n,t),[q,k,n]),ee=(0,l().useCallback)((e,t)=>k("muted",!V.muted,n,t),[V.muted,k,n]),te=(0,l().useCallback)((e,t)=>{q||E(n)},[q,E,n]),ne=(0,l().useCallback)((e,t)=>{q||D||S(n,"up",e?.altKey,t)},[q,S,n,D]),re=(0,l().useCallback)((e,t)=>{q||A||S(n,"down",e?.altKey,t)},[q,S,n,A]),oe=(0,l().useMemo)(()=>to(V.field,i),[i,V.field]),ae=(0,l().useMemo)(()=>((e,t,n,r)=>n.inputType??r(e,t,{fieldData:n}))(V.field,V.operator,oe,u),[oe,u,V.field,V.operator]),ie=(0,l().useMemo)(()=>c(V.field,{fieldData:oe}),[oe,c,V.field]),le=(0,l().useMemo)(()=>d(V.field,{fieldData:oe}),[oe,d,V.field]),se=(0,l().useMemo)(()=>Qr(le,V.operator),[le,V.operator]),ue=no(se),ce=(0,l().useMemo)(()=>ro({field:V.field,operator:V.operator,valueSource:V.valueSource},oe,m),[oe,m,V.field,V.operator,V.valueSource]),de=(0,l().useMemo)(()=>ce.map(({value:e})=>e),[ce]),fe=(0,l().useMemo)(()=>s(V.field,V.operator,{fieldData:oe}),[oe,s,V.field,V.operator]),pe=(0,l().useMemo)(()=>oo(fe),[fe]),he=(0,l().useMemo)(()=>ao({field:V.field,operator:V.operator,valueSource:V.valueSource},oe,pe,p),[oe,p,pe,V.field,V.operator,V.valueSource]),me=(0,l().useMemo)(()=>h(V.field,V.operator,{fieldData:oe}),[oe,h,V.field,V.operator]),ge=(0,l().useMemo)(()=>io({field:V.field,operator:V.operator,valueSource:V.valueSource},oe,a,pe,g),[oe,a,g,pe,V.field,V.operator,V.valueSource]),ve=(0,l().useMemo)(()=>f(V.field,{fieldData:oe}),[oe,f,V.field]),be=lu({translations:e.translations,fields:oe.subproperties??ve.fields??Vu,autoSelectField:e.schema.autoSelectField||!!oe.subproperties}),ye=(0,l().useMemo)(()=>lo(V,oe,v,t??/* v8 ignore start -- @preserve */""),[oe,t,V,v]),we=(0,l().useMemo)(()=>bi(ye),[ye]),Se=oe?.className??"",ke=se?.className??"",Ee=ie.length>0,Oe=(0,l().useMemo)(()=>{return e={classNames:o,suppressStandardClassnames:w,leadingClassNames:[y(V,{fieldData:oe}),Se,ke],disabled:q,muted:B,isDragging:F,isOver:z,dropEffect:x,groupItems:I,dropNotAllowed:j,hasSubQuery:Ee,validationClassName:we},Ir("rule",Ar,e);var e},[o,q,x,j,B,Se,oe,y,I,Ee,F,z,ke,V,w,we]);return{...e,classNames:H,cloneRule:J,disabled:q,dndRef:L,dragMonitorId:P,dragRef:G,dropMonitorId:_,fieldData:oe,generateOnChangeHandler:U,onChangeField:W,onChangeMatchMode:K,onChangeOperator:Q,onChangeValueSource:X,onChangeValue:Y,hideValueControls:ue,inputType:ae,matchModes:ie,muted:B,operators:le,outerClassName:Oe,removeRule:te,rule:V,shiftRuleUp:ne,shiftRuleDown:re,subproperties:be,subQueryBuilderProps:ve,toggleLockRule:Z,toggleMuteRule:ee,validationResult:ye,valueEditorSeparator:me,valueEditorType:he,values:ge,valueSourceOptions:ce,valueSources:de}},Xu={actionElement:Es,addGroupAction:Es,addRuleAction:Es,cloneGroupAction:Es,cloneRuleAction:Es,combinatorSelector:Mu,dragHandle:Os,fieldSelector:Mu,inlineCombinator:e=>{const{component:t,...n}=e,r=ur(n.schema.suppressStandardClassnames||hn.betweenRules,n.schema.classNames.betweenRules);return l().createElement("div",{className:r,"data-testid":wn},l().createElement(t,{...n,testID:Dn}))},lockGroupAction:Es,lockRuleAction:Es,matchModeEditor:e=>{const{match:t,options:n,title:r,className:o,disabled:a,testID:i,schema:s,thresholdPlaceholder:u,selectorComponent:c=e.schema.controls.valueSelector,numericEditorComponent:d=e.schema.controls.valueEditor}=e,{thresholdNum:f,thresholdRule:p,thresholdSchema:h,handleChangeMode:m,handleChangeThreshold:g}=As(e),v=(0,l().useMemo)(()=>u?{...Ns,placeholder:u}:Ns,[u]);return l().createElement(l().Fragment,null,l().createElement(c,{schema:s,testID:i,className:o,title:r,handleOnChange:m,disabled:a,value:t.mode,options:n,multiple:!1,listsAsArrays:!1,path:Ds,level:0}),Cs(t.mode)&&l().createElement(d,{skipHook:!0,testID:i,inputType:"number",title:r,className:o,disabled:a,handleOnChange:g,field:"",operator:"",value:f,valueSource:"value",fieldData:v,schema:h,path:Ds,level:0,rule:p}))},muteGroupAction:Es,muteRuleAction:Es,notToggle:e=>{const t=l().useId();return l().createElement("label",{"data-testid":e.testID,className:e.className,title:e.title,htmlFor:t},l().createElement("input",{id:t,type:"checkbox",onChange:t=>e.handleOnChange(t.target.checked),checked:!!e.checked,disabled:e.disabled}),e.label)},operatorSelector:Mu,removeGroupAction:Es,removeRuleAction:Es,rule:Hu,ruleGroup:Eu,ruleGroupBodyElements:Nu,ruleGroupHeaderElements:Ou,shiftActions:e=>l().createElement("div",{"data-testid":e.testID,className:e.className},l().createElement("button",{type:"button",disabled:e.disabled||e.shiftUpDisabled,onClick:e.shiftUp,title:e.titles?.shiftUp},e.labels?.shiftUp),l().createElement("button",{type:"button",disabled:e.disabled||e.shiftDownDisabled,onClick:e.shiftDown,title:e.titles?.shiftDown},e.labels?.shiftDown)),undoRedoActions:null,valueEditor:Au,valueSelector:Mu,valueSourceSelector:Mu};const Yu=e=>"object"==typeof e&&null!==e&&"DndProvider"in e&&"useRuleDnD"in e&&"useRuleGroupDnD"in e&&"useInlineCombinatorDnD"in e,{rule:Ju,ruleGroup:Zu,combinatorSelector:ec}=Xu,tc=(0,l().createContext)({baseControls:{rule:Ju,ruleGroup:Zu,combinatorSelector:ec}}),nc=({component:e,...t})=>{const{adapter:n,canDrop:r,copyModeModifierKey:o,copyModeAfterHoverMs:a,groupModeModifierKey:i,groupModeAfterHoverMs:s}=(0,l().useContext)(tc),{dragPreviewState:u}=(0,l().useContext)(Ce),c=null!==u,{dropRef:d,dropMonitorId:f,isOver:p}=n.useInlineCombinatorDnD({path:t.path,schema:t.schema,rules:t.rules,canDrop:r,copyModeModifierKey:o??"alt",copyModeAfterHoverMs:a,groupModeModifierKey:i??"ctrl",groupModeAfterHoverMs:s}),h=!c&&p,m=[t.schema.suppressStandardClassnames||hn.betweenRules,h&&!t.schema.classNames.dndOver||!1,h&&!t.schema.suppressStandardClassnames&&hn.dndOver||!1].filter(e=>"string"==typeof e).join(" ");return l().createElement("div",{key:"dnd",ref:d,className:m,"data-dropmonitorid":f,"data-testid":wn},l().createElement(e,{...t,testID:Dn}))},rc=e=>{const t=(0,l().useContext)(tc),{dragPreviewState:n}=(0,l().useContext)(Ce),{adapter:r,canDrop:o,copyModeModifierKey:a,copyModeAfterHoverMs:i,groupModeModifierKey:s,groupModeAfterHoverMs:u,hideDefaultDragPreview:c,onRuleDrop:d}=t,f=!!e.parentDisabled||!!e.disabled,p=r.useRuleDnD({path:e.path,disabled:f,schema:e.schema,actions:e.actions,rule:e.rule,canDrop:o,copyModeModifierKey:a??"alt",copyModeAfterHoverMs:i,groupModeModifierKey:s??"ctrl",groupModeAfterHoverMs:u,hideDefaultDragPreview:c,onRuleDrop:d}),h=n?{...p,isDragging:!1,isOver:!1,dropNotAllowed:!1}:p,{rule:m}=t.baseControls;return l().createElement(tc.Provider,{value:t},l().createElement(m,{...e,...h}))},oc=e=>{const t=(0,l().useContext)(tc),{dragPreviewState:n}=(0,l().useContext)(Ce),{adapter:r,canDrop:o,baseControls:{ruleGroup:a},copyModeModifierKey:i,copyModeAfterHoverMs:s,groupModeModifierKey:u,groupModeAfterHoverMs:c,hideDefaultDragPreview:d,onRuleDrop:f}=t,p=(0,l().useMemo)(()=>{if(0===e.path.length&&n){const t=n.shadowQuery;return{...e,ruleGroup:t,rules:t.rules}}return e},[e,n]),h=r.useRuleGroupDnD({disabled:!!p.parentDisabled||!!p.disabled,path:p.path,schema:p.schema,actions:p.actions,ruleGroup:p.ruleGroup,canDrop:o,copyModeModifierKey:i??"alt",copyModeAfterHoverMs:s,groupModeModifierKey:u??"ctrl",groupModeAfterHoverMs:c,hideDefaultDragPreview:d,onRuleDrop:f}),m=n?{...h,isDragging:!1,isOver:!1,dropNotAllowed:!1}:h;return l().createElement(a,{...p,...m})},ac=e=>{const{controlClassnames:t,controlElements:n,debugMode:r,enableDragAndDrop:o,enableMountQueryChange:a,translations:i}=e,s=Lu({controlClassnames:t,controlElements:n,debugMode:r,enableDragAndDrop:o??!0,enableMountQueryChange:a,translations:i??{}}),{enableDragAndDrop:u}=s,c=lc(e.dnd),d=u&&c?"dnd":"no-dnd",f=(0,l().useMemo)(()=>({...s,enableDragAndDrop:!1,debugMode:r}),[s,r]),p=(0,l().useMemo)(()=>({...s,enableDragAndDrop:u,debugMode:r}),[s,r,u]);if(!u||!c)return l().createElement(ku.Provider,{key:d,value:f},e.children);const{DndProvider:h}=c;return l().createElement(h,{key:d,debugMode:r,updateWhileDragging:e.updateWhileDragging,copyModeAfterHoverMs:e.copyModeAfterHoverMs,groupModeAfterHoverMs:e.groupModeAfterHoverMs},l().createElement(ku.Provider,{key:d,value:p},l().createElement(ic,{dnd:c,canDrop:e.canDrop,copyModeModifierKey:e.copyModeModifierKey,copyModeAfterHoverMs:e.copyModeAfterHoverMs,groupModeModifierKey:e.groupModeModifierKey,groupModeAfterHoverMs:e.groupModeAfterHoverMs,hideDefaultDragPreview:e.hideDefaultDragPreview,updateWhileDragging:e.updateWhileDragging,onDragMove:e.onDragMove,onRuleDrop:e.onRuleDrop},e.children)))},ic=e=>{const t=(0,l().useContext)(ku),n=(0,l().useContext)(tc),r=lc(e.dnd)??n.adapter,o=$i(void 0,e.copyModeModifierKey,n.copyModeModifierKey),a=$i(void 0,e.groupModeModifierKey,n.groupModeModifierKey),i=$i(void 0,e.copyModeAfterHoverMs,n.copyModeAfterHoverMs),s=$i(void 0,e.groupModeAfterHoverMs,n.groupModeAfterHoverMs),u=Ti(!0,e.enableDragAndDrop,t.enableDragAndDrop),c=Ti(!1,e.debugMode,t.debugMode),d=Ti(!1,e.hideDefaultDragPreview,n.hideDefaultDragPreview),f=$i(void 0,e.canDrop,n.canDrop),p=Ti(!1,e.updateWhileDragging,n.updateWhileDragging),h=$i(void 0,e.onDragMove,n.onDragMove),m=$i(void 0,e.onRuleDrop,n.onRuleDrop),g=u&&r?"dnd":"no-dnd",v=(0,l().useMemo)(()=>({rule:e.controlElements?.rule??t.controlElements?.rule??n.baseControls.rule,ruleGroup:e.controlElements?.ruleGroup??t.controlElements?.ruleGroup??n.baseControls.ruleGroup,combinatorSelector:e.controlElements?.combinatorSelector??t.controlElements?.combinatorSelector??n.baseControls.combinatorSelector}),[e.controlElements?.combinatorSelector,e.controlElements?.rule,e.controlElements?.ruleGroup,t.controlElements?.combinatorSelector,t.controlElements?.rule,t.controlElements?.ruleGroup,n.baseControls.combinatorSelector,n.baseControls.rule,n.baseControls.ruleGroup]),b=(0,l().useMemo)(()=>({...t,enableDragAndDrop:u,debugMode:c,controlElements:{...t.controlElements,ruleGroup:oc,rule:rc,inlineCombinator:nc}}),[c,u,t]),y=(0,l().useMemo)(()=>({baseControls:v,canDrop:f,copyModeModifierKey:o,copyModeAfterHoverMs:i,groupModeModifierKey:a,groupModeAfterHoverMs:s,hideDefaultDragPreview:d,updateWhileDragging:p,onDragMove:h,onRuleDrop:m,adapter:r}),[v,f,o,i,a,s,d,p,h,m,r]),w=(0,l().useMemo)(()=>({...t,enableDragAndDrop:!1,debugMode:c}),[t,c]);return u&&r?l().createElement(ku.Provider,{key:g,value:b},l().createElement(tc.Provider,{value:y},e.children)):l().createElement(ku.Provider,{key:g,value:w},e.children)};const lc=e=>{const t=e&&Yu(e)?e:null,n=(0,l().useMemo)(()=>e&&!Yu(e)?El(e):null,[e]),r=sc(null!==t||null!==n);return t??n??r},sc=e=>{const[t,r]=(0,l().useState)(null);return(0,l().useEffect)(()=>{if(e)return;let o=!1;return t||(async()=>{const[e,t,a]=await Promise.all(["","-html5-backend","-touch-backend"].map(e=>n(290)(`react-dnd${e}`).catch( +/* v8 ignore start -- @preserve */[])[e.path.at(-1)-1],[{isOver:o,dropMonitorId:a,dropEffect:i,dropNotAllowed:s},u]=n(()=>({accept:["rule","ruleGroup"],canDrop:t=>(({dragging:e,path:t,schema:n,canDrop:r,groupModeModifierKey:o,hoveringItem:a})=>{const{path:i}=e;if(pl(o)||e&&"function"==typeof r&&!r({dragging:e,hovering:{...a,path:t,qbId:n.qbId}}))return!1;const l=oi(t),s=oi(i),u=t.at(-1),c=i.at(-1);return!(ii(i,t)||ai(i,t)||ai(l,s)&&u-1===c||n.independentCombinators&&ai(l,s)&&u===c-1)})({dragging:t,path:e.path,schema:e.schema,canDrop:e.canDrop,groupModeModifierKey:e.groupModeModifierKey,hoveringItem:r}),collect:t=>({dropNotAllowed:t.isOver()&&!t.canDrop(),isOver:t.canDrop()&&t.isOver(),dropMonitorId:t.getHandlerId()??"",dropEffect:pl(e.copyModeModifierKey)?"copy":"move",groupItems:pl(e.groupModeModifierKey)}),drop:()=>gl({type:"inlineCombinator",path:e.path,schema:e.schema,copyModeModifierKey:e.copyModeModifierKey,groupModeModifierKey:e.groupModeModifierKey})}),[e.canDrop,r,e.path,e.schema]);return l().useEffect(()=>{u(t)},[u]),{dropRef:t,dropMonitorId:a,isOver:o,dropEffect:i,dropNotAllowed:s}}}};function Ol(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Nl=(()=>"function"==typeof Symbol&&Symbol.observable||"@@observable")(),Cl=()=>Math.random().toString(36).substring(7).split("").join("."),Dl={INIT:`@@redux/INIT${Cl()}`,REPLACE:`@@redux/REPLACE${Cl()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Cl()}`};function Al(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}function Tl(e,t,n){if("function"!=typeof e)throw new Error(Ol(2));if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(Ol(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(Ol(1));return n(Tl)(e,t)}let r=e,o=t,a=new Map,i=a,l=0,s=!1;function u(){i===a&&(i=new Map,a.forEach((e,t)=>{i.set(t,e)}))}function c(){if(s)throw new Error(Ol(3));return o}function d(e){if("function"!=typeof e)throw new Error(Ol(4));if(s)throw new Error(Ol(5));let t=!0;u();const n=l++;return i.set(n,e),function(){if(t){if(s)throw new Error(Ol(6));t=!1,u(),i.delete(n),a=null}}}function f(e){if(!Al(e))throw new Error(Ol(7));if(void 0===e.type)throw new Error(Ol(8));if("string"!=typeof e.type)throw new Error(Ol(17));if(s)throw new Error(Ol(9));try{s=!0,o=r(o,e)}finally{s=!1}return(a=i).forEach(e=>{e()}),e}f({type:Dl.INIT});return{dispatch:f,subscribe:d,getState:c,replaceReducer:function(e){if("function"!=typeof e)throw new Error(Ol(10));r=e,f({type:Dl.REPLACE})},[Nl]:function(){const e=d;return{subscribe(t){if("object"!=typeof t||null===t)throw new Error(Ol(11));function n(){const e=t;e.next&&e.next(c())}n();return{unsubscribe:e(n)}},[Nl](){return this}}}}}function $l(e){const t=Object.keys(e),n={};for(let r=0;r{const n=e[t];if(void 0===n(void 0,{type:Dl.INIT}))throw new Error(Ol(12));if(void 0===n(void 0,{type:Dl.PROBE_UNKNOWN_ACTION()}))throw new Error(Ol(13))})}(n)}catch(e){o=e}return function(e={},t){if(o)throw o;let a=!1;const i={};for(let o=0;oe:1===e.length?e[0]:e.reduce((e,t)=>(...n)=>e(t(...n)))}function Rl(e){return({dispatch:t,getState:n})=>r=>o=>"function"==typeof o?o(t,n,e):r(o)}var xl=Rl(),Il=Rl,Pl="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?Ml:Ml.apply(null,arguments)};"undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;function _l(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw new Error(os(0));return{type:e,payload:r.payload,..."meta"in r&&{meta:r.meta},..."error"in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>function(e){return Al(e)&&"type"in e&&"string"==typeof e.type}(t)&&t.type===e,n}var Ll=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return 1===t.length&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function Gl(e){return at(e)?an(e,()=>{}):e}function Fl(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}var zl="RTK_autoBatch",jl=e=>t=>{setTimeout(t,e)},Vl=(e={type:"raf"})=>t=>(...n)=>{const r=t(...n);let o=!0,a=!1,i=!1;const l=new Set,s="tick"===e.type?queueMicrotask:"raf"===e.type?"undefined"!=typeof window&&window.requestAnimationFrame?(u=window.requestAnimationFrame,c=100,e=>{let t=!1;const n=()=>{t||(t=!0,cancelAnimationFrame(r),clearTimeout(o),e())},r=u(n),o=setTimeout(n,c)}):jl(10):"callback"===e.type?e.queueNotification:jl(e.timeout);var u,c;const d=()=>{i=!1,a&&(a=!1,l.forEach(e=>e()))};return Object.assign({},r,{subscribe(e){const t=r.subscribe(()=>o&&e());return l.add(e),()=>{t(),l.delete(e)}},dispatch(e){try{return o=!e?.meta?.[zl],a=!o,a&&(i||(i=!0,s(d))),r.dispatch(e)}finally{o=!0}}})};function ql(e){const t=function(e){const{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:o=!0}=e??{};let a=new Ll;return t&&("boolean"==typeof t?a.push(xl):a.push(Il(t.extraArgument))),a},{reducer:n,middleware:r,devTools:o=!0,duplicateMiddlewareCheck:a=!0,preloadedState:i,enhancers:l}=e||{};let s,u;if("function"==typeof n)s=n;else{if(!Al(n))throw new Error(os(1));s=$l(n)}u="function"==typeof r?r(t):t();let c=Ml;o&&(c=Pl({trace:!1,..."object"==typeof o&&o}));const d=function(...e){return t=>(n,r)=>{const o=t(n,r);let a=()=>{throw new Error(Ol(15))};const i={getState:o.getState,dispatch:(e,...t)=>a(e,...t)},l=e.map(e=>e(i));return a=Ml(...l)(o.dispatch),{...o,dispatch:a}}}(...u),f=(e=>function(t){const{autoBatch:n=!0}=t??{};let r=new Ll(e);return n&&r.push(Vl("object"==typeof n?n:void 0)),r})(d);return Tl(s,i,c(..."function"==typeof l?l(f):f()))}function Bl(e){const t={},n=[];let r;const o={addCase(e,n){const r="string"==typeof e?e:e.type;if(!r)throw new Error(os(28));if(r in t)throw new Error(os(29));return t[r]=n,o},addAsyncThunk:(e,r)=>(r.pending&&(t[e.pending.type]=r.pending),r.rejected&&(t[e.rejected.type]=r.rejected),r.fulfilled&&(t[e.fulfilled.type]=r.fulfilled),r.settled&&n.push({matcher:e.settled,reducer:r.settled}),o),addMatcher:(e,t)=>(n.push({matcher:e,reducer:t}),o),addDefaultCase:e=>(r=e,o)};return e(o),[t,n,r]}var Hl=(e=21)=>{let t="",n=e;for(;n--;)t+="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"[64*Math.random()|0];return t};var Ul=Symbol.for("rtk-slice-createasyncthunk");function Wl(e,t){return`${e}/${t}`}function Ql({creators:e}={}){const t=e?.asyncThunk?.[Ul];return function(e){const{name:n,reducerPath:r=n}=e;if(!n)throw new Error(os(11));const o=("function"==typeof e.reducers?e.reducers(function(){function e(e,t){return{_reducerDefinitionType:"asyncThunk",payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer:e=>Object.assign({[e.name]:(...t)=>e(...t)}[e.name],{_reducerDefinitionType:"reducer"}),preparedReducer:(e,t)=>({_reducerDefinitionType:"reducerWithPrepare",prepare:e,reducer:t}),asyncThunk:e}}()):e.reducers)||{},a=Object.keys(o),i={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},l={addCase(e,t){const n="string"==typeof e?e:e.type;if(!n)throw new Error(os(12));if(n in i.sliceCaseReducersByType)throw new Error(os(13));return i.sliceCaseReducersByType[n]=t,l},addMatcher:(e,t)=>(i.sliceMatchers.push({matcher:e,reducer:t}),l),exposeAction:(e,t)=>(i.actionCreators[e]=t,l),exposeCaseReducer:(e,t)=>(i.sliceCaseReducersByName[e]=t,l)};function s(){const[t={},n=[],r]="function"==typeof e.extraReducers?Bl(e.extraReducers):[e.extraReducers],o={...t,...i.sliceCaseReducersByType};return function(e,t){let n,[r,o,a]=Bl(t);if("function"==typeof e)n=()=>Gl(e());else{const t=Gl(e);n=()=>t}function i(e=n(),t){let i=[r[t.type],...o.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];return 0===i.filter(e=>!!e).length&&(i=[a]),i.reduce((e,n)=>{if(n){if(ot(e)){const r=n(e,t);return void 0===r?e:r}if(at(e))return an(e,e=>n(e,t));{const r=n(e,t);if(void 0===r){if(null===e)return e;throw Error("A case reducer on a non-draftable value must not return undefined")}return r}}return e},e)}return i.getInitialState=n,i}(e.initialState,e=>{for(let t in o)e.addCase(t,o[t]);for(let t of i.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)})}a.forEach(r=>{const a=o[r],i={reducerName:r,type:Wl(n,r),createNotation:"function"==typeof e.reducers};!function(e){return"asyncThunk"===e._reducerDefinitionType}(a)?function({type:e,reducerName:t,createNotation:n},r,o){let a,i;if("reducer"in r){if(n&&!function(e){return"reducerWithPrepare"===e._reducerDefinitionType}(r))throw new Error(os(17));a=r.reducer,i=r.prepare}else a=r;o.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,i?_l(e,i):_l(e))}(i,a,l):function({type:e,reducerName:t},n,r,o){if(!o)throw new Error(os(18));const{payloadCreator:a,fulfilled:i,pending:l,rejected:s,settled:u,options:c}=n,d=o(e,a,c);r.exposeAction(t,d),i&&r.addCase(d.fulfilled,i);l&&r.addCase(d.pending,l);s&&r.addCase(d.rejected,s);u&&r.addMatcher(d.settled,u);r.exposeCaseReducer(t,{fulfilled:i||Yl,pending:l||Yl,rejected:s||Yl,settled:u||Yl})}(i,a,l,t)});const u=e=>e,c=new Map,d=new WeakMap;let f;function p(e,t){return f||(f=s()),f(e,t)}function h(){return f||(f=s()),f.getInitialState()}function m(t,n=!1){function r(e){let o=e[t];return void 0===o&&n&&(o=Fl(d,r,h)),o}function o(t=u){const r=Fl(c,n,()=>new WeakMap);return Fl(r,t,()=>{const r={};for(const[o,a]of Object.entries(e.selectors??{}))r[o]=Kl(a,t,()=>Fl(d,t,h),n);return r})}return{reducerPath:t,getSelectors:o,get selectors(){return o(r)},selectSlice:r}}const g={name:n,reducer:p,actions:i.actionCreators,caseReducers:i.sliceCaseReducersByName,getInitialState:h,...m(r),injectInto(e,{reducerPath:t,...n}={}){const o=t??r;return e.inject({reducerPath:o,reducer:p},n),{...g,...m(o,!0)}}};return g}}function Kl(e,t,n,r){function o(o,...a){let i=t(o);return void 0===i&&r&&(i=n()),e(i,...a)}return o.unwrapped=e,o}var Xl=Ql();function Yl(){}var{assign:Jl}=Object,Zl=Symbol.for("rtk-state-proxy-original"),es=new WeakMap,ts=e=>{if(!(t=e)||!t[Zl])throw new Error(os(25));var t;return e[Zl]},ns={},rs=(e=ns)=>e;function os(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}p();function as(e){e()}var is={notify(){},get:()=>[]};function ls(e,t){let n,r=is,o=0,a=!1;function i(){u.onStateChange&&u.onStateChange()}function l(){o++,n||(n=t?t.addNestedSub(i):e.subscribe(i),r=function(){let e=null,t=null;return{clear(){e=null,t=null},notify(){as(()=>{let t=e;for(;t;)t.callback(),t=t.next})},get(){const t=[];let n=e;for(;n;)t.push(n),n=n.next;return t},subscribe(n){let r=!0;const o=t={callback:n,next:null,prev:t};return o.prev?o.prev.next=o:e=o,function(){r&&null!==e&&(r=!1,o.next?o.next.prev=o.prev:t=o.prev,o.prev?o.prev.next=o.next:e=o.next)}}}}())}function s(){o--,n&&0===o&&(n(),n=void 0,r.clear(),r=is)}const u={addNestedSub:function(e){l();const t=r.subscribe(e);let n=!1;return()=>{n||(n=!0,t(),s())}},notifyNestedSubs:function(){r.notify()},handleChangeWrapper:i,isSubscribed:function(){return a},trySubscribe:function(){a||(a=!0,l())},tryUnsubscribe:function(){a&&(a=!1,s())},getListeners:()=>r};return u}var ss=(()=>!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement))(),us=(()=>"undefined"!=typeof navigator&&"ReactNative"===navigator.product)(),cs=(()=>ss||us?l().useLayoutEffect:l().useEffect)();Object.defineProperty,Object.getOwnPropertyNames,Object.getOwnPropertySymbols,Object.getOwnPropertyDescriptor,Object.getPrototypeOf,Object.prototype;var ds=Symbol.for("react-redux-context"),fs="undefined"!=typeof globalThis?globalThis:{};function ps(){if(!l().createContext)return{};const e=fs[ds]??=new Map;let t=e.get(l().createContext);return t||(t=l().createContext(null),e.set(l().createContext,t)),t}var hs=ps();var ms=function(e){const{children:t,context:n,serverState:r,store:o}=e,a=l().useMemo(()=>{const e=ls(o);return{store:o,subscription:e,getServerState:r?()=>r:void 0}},[o,r]),i=l().useMemo(()=>o.getState(),[o]);cs(()=>{const{subscription:e}=a;return e.onStateChange=e.notifyNestedSubs,e.trySubscribe(),i!==o.getState()&&e.notifyNestedSubs(),()=>{e.tryUnsubscribe(),e.onStateChange=void 0}},[a,i]);const s=n||hs;return l().createElement(s.Provider,{value:a},t)};function gs(e=hs){return function(){return l().useContext(e)}}var vs=gs();function bs(e=hs){const t=e===hs?vs:gs(e),n=()=>{const{store:e}=t();return e};return Object.assign(n,{withTypes:()=>n}),n}var ys=bs();function ws(e=hs){const t=e===hs?ys:bs(e),n=()=>t().dispatch;return Object.assign(n,{withTypes:()=>n}),n}var Ss=(e,t)=>e===t;function ks(e=hs){const t=e===hs?vs:gs(e),n=(e,n={})=>{const{equalityFn:r=Ss}="function"==typeof n?{equalityFn:n}:n;const o=t(),{store:a,subscription:i,getServerState:s}=o,u=(l().useRef(!0),l().useCallback({[e.name]:t=>e(t)}[e.name],[e])),c=(0,f().useSyncExternalStoreWithSelector)(i.addNestedSub,a.getState,s||a.getState,u,r);return l().useDebugValue(c),c};return Object.assign(n,{withTypes:()=>n}),n}const Es=e=>l().createElement("button",{type:"button","data-testid":e.testID,disabled:e.disabled&&!e.disabledTranslation,className:e.className,title:e.disabledTranslation&&e.disabled?e.disabledTranslation.title:e.title,onClick:t=>e.handleOnClick(t)},e.disabledTranslation&&e.disabled?e.disabledTranslation.label:e.label),Os=(0,l().forwardRef)((e,t)=>l().createElement("span",{...e.dragHandleAttributes,"data-testid":e.testID,ref:t,className:e.className,title:e.title},e.label)),Ns={name:"",value:"",label:""},Cs=e=>["atleast","atmost","exactly"].includes(cr(e)??""),Ds=[],As=e=>{const{match:t,handleOnChange:n}=e,r=l().useMemo(()=>"number"==typeof t.threshold?Math.max(0,t.threshold):1,[t.threshold]);return{thresholdNum:r,thresholdRule:l().useMemo(()=>({field:"",operator:"=",value:r}),[r]),thresholdSchema:l().useMemo(()=>({...e.schema,parseNumbers:!0}),[e.schema]),handleChangeMode:(0,l().useCallback)(e=>{Cs(e)&&"number"!=typeof t.threshold?n({...t,mode:e,threshold:1}):n({...t,mode:e})},[n,t]),handleChangeThreshold:(0,l().useCallback)(e=>{n({...t,threshold:uo(e,{parseNumbers:!0})})},[n,t])}},Ts="QueryBuilder was rendered with a truthy independentCombinators prop. This prop is deprecated and unnecessary. Furthermore, the initial query/defaultQuery prop was of type RuleGroupType instead of type RuleGroupIC. More info: https://react-querybuilder.js.org/docs/components/querybuilder#independent-combinators",$s="QueryBuilder was rendered with the deprecated and unnecessary independentCombinators prop. To use independent combinators, make sure the query/defaultQuery prop is of type RuleGroupIC when the component mounts. More info: https://react-querybuilder.js.org/docs/components/querybuilder#independent-combinators",Ms="A custom RuleGroup component has rendered a standard RuleGroup component with deprecated props. The combinator, not, and rules props should not be used. Instead, the full group object should be passed as the ruleGroup prop.",Rs="A custom RuleGroup component has rendered a standard Rule component with deprecated props. The field, operator, value, and valueSource props should not be used. Instead, the full rule object should be passed as the rule prop.",xs="QueryBuilder was rendered with both query and defaultQuery props. QueryBuilder must be either controlled or uncontrolled (specify either the query prop, or the defaultQuery prop, but not both). Decide between using a controlled or uncontrolled query builder and remove one of these props. More info: https://reactjs.org/link/controlled-components",Is="QueryBuilder is changing from an uncontrolled component to be controlled. This is likely caused by the query changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled query builder for the lifetime of the component. More info: https://reactjs.org/link/controlled-components",Ps="QueryBuilder is changing from a controlled component to be uncontrolled. This is likely caused by the query changing from defined to undefined, which should not happen. Decide between using a controlled or uncontrolled query builder for the lifetime of the component. More info: https://reactjs.org/link/controlled-components",_s="QueryBuilder was rendered with the enableDragAndDrop prop set to true, but either react-dnd was not detected or one of react-dnd-html5-backend or react-dnd-touch-backend was not detected. To enable drag-and-drop functionality, install react-dnd and one of the backend packages and wrap QueryBuilder in QueryBuilderDnD from @react-querybuilder/dnd.",Ls="Importing from react-querybuilder/debug is deprecated. To enable Redux DevTools for React Query Builder's internal store, set globalThis.__RQB_DEVTOOLS__ = true.",Gs="QueryBuilder was rendered with a qbId prop that is already in use by another mounted QueryBuilder. Each mounted query builder must have a unique qbId, so this query builder has fallen back to an automatically generated identifier. A qbId may be reused after the previous query builder has unmounted (see the preserveQueryStateOnUnmount prop), but not while it is still mounted.",Fs="QueryBuilder was rendered with the showUndoRedo prop set to true, but no undo/redo controls were available. To enable undo/redo, wrap QueryBuilder in the QueryBuilderHistory component from react-querybuilder/history, or provide your own controlElements.undoRedoActions component.",zs="QueryBuilder was rendered with a qbId prop that is different than the qbId it was mounted with. The qbId prop is only evaluated when the component mounts, so the new value has been ignored. To render a query builder with a different qbId, unmount the existing one first, e.g. by giving it a different React key.",js=Xl({name:"queries",initialState:{},reducers:{setQueryState:{prepare:(e,t)=>({payload:e,meta:{timestamp:t?.timestamp??Date.now(),fromHistory:!!t?.fromHistory}}),reducer:(e,{payload:{qbId:t,query:n}})=>{e[t]=n}},unsetQueryState:(e,{payload:{qbId:t}})=>{delete e[t]}},selectors:{getQuerySelectorById:(e,t)=>e[t]}}),Vs=l().createContext(null),qs=Xl({name:"warnings",initialState:{[Ts]:!1,[$s]:!1,[Ms]:!1,[Rs]:!1,[xs]:!1,[Is]:!1,[Ps]:!1,[_s]:!1,[Ls]:!1,[Gs]:!1,[zs]:!1,[Fs]:!1},reducers:{rqbWarn:(e,{payload:t})=>{e[t]||(console.error(t),e[t]=!0)}}}),Bs=function(...e){const t=Object.fromEntries((e=>e.flatMap(e=>{return"reducerPath"in(t=e)&&"string"==typeof t.reducerPath?[[e.reducerPath,e.reducer]]:Object.entries(e);var t}))(e)),n=()=>Object.keys(t).length?$l(t):rs;let r=n();function o(e,t){return r(e,t)}o.withLazyLoadedSlices=()=>o;const a={},i=Object.assign(function(e,n){return function(r,...o){return e(((e,t,n)=>Fl(es,e,()=>new Proxy(e,{get:(e,r,o)=>{if(r===Zl)return e;const a=Reflect.get(e,r,o);if(void 0===a){const e=n[r];if(void 0!==e)return e;const o=t[r];if(o){const e=o(void 0,{type:Hl()});if(void 0===e)throw new Error(os(24));return n[r]=e,e}}return a}})))(n?n(r,...o):r,t,a),...o)}},{original:ts});return Object.assign(o,{inject:(e,i={})=>{const{reducerPath:l,reducer:s}=e,u=t[l];return!i.overrideExisting&&u&&u!==s||(i.overrideExisting&&u!==s&&delete a[l],t[l]=s,r=n()),o},selector:i})}(js,qs).withLazyLoadedSlices(),Hs=e=>ws(e),Us=e=>bs(e),Ws=e=>ks(e),Qs=new Map,Ks=e=>{const t=(Qs.get(e)??0)-1;return t>0?(Qs.set(e,t),t):(Qs.delete(e),0)},Xs=new Map,Ys=({payload:e,onQueryChange:t,options:n})=>r=>{r(js.actions.setQueryState(e,n)),"function"==typeof t&&t(e.query)},Js={useRQB_INTERNAL_QueryBuilderDispatch:Hs(Zs=Vs),useRQB_INTERNAL_QueryBuilderStore:Us(Zs),useRQB_INTERNAL_QueryBuilderSelector:Ws(Zs)};var Zs;const eu=Js.useRQB_INTERNAL_QueryBuilderDispatch,tu=Js.useRQB_INTERNAL_QueryBuilderStore,nu=Js.useRQB_INTERNAL_QueryBuilderSelector,{rqbWarn:ru}=qs.actions,ou={reducer:Bs,preloadedState:{queries:js.getInitialState(),warnings:qs.getInitialState()},middleware:e=>e({serializableCheck:{ignoredActions:[js.actions.setQueryState.type],ignoredPaths:[/^queries\b.*\.rules\.\d+\.value$/]}})},au=e=>{eu();const{defaultQuery:t,queryProp:n}=e;(e=>{const[t,n]=(0,l().useState)(e),[r,o]=(0,l().useState)(null);e!==t&&(o(t),n(e))})(!!n)};function iu(e,t,n){eu()}const lu=e=>{const{optionList:t,optionsMap:n,defaultOption:r}=(0,l().useMemo)(()=>Jr({placeholder:e.translations.fields,optionList:e.fields,autoSelectOption:e.autoSelectField,baseOption:e.baseField}),[e.autoSelectField,e.baseField,e.fields,e.translations.fields]);return{fields:t,fieldMap:n,defaultField:r}};let su=null;function uu(e){if(!su){const t=e||globalThis?.__RQB_DEVTOOLS__;su=(e=>{const t=ql({...ou,devTools:!!e&&/* v8 ignore next -- @preserve */{name:"React Query Builder"}});return t.addSlice=e=>{Bs.inject(e),t.dispatch({type:crypto.randomUUID().slice(0,8),meta:`Initializing state for slice "${e.name}"`})},t})(t)}return su}const cu=e=>t=>js.selectors.getQuerySelectorById({queries:t.queries},e),du={},fu={},pu=[],hu={},mu=()=>null,gu=()=>"",vu=()=>!0,bu=()=>{},yu=(...e)=>{console.log(...e)};function wu(e,t){const{query:n,defaultQuery:r,getValueEditorSeparator:o=mu,getRuleClassname:a=gu,getRuleGroupClassname:i=gu,onAddRule:s=vu,onAddGroup:u=vu,onMoveRule:c=vu,onMoveGroup:d=vu,onGroupRule:f=vu,onGroupGroup:p=vu,onRemove:h=vu,onQueryChange:m,showCombinatorsBetweenRules:g=!1,showNotToggle:v=!1,showShiftActions:b=!1,showCloneButtons:y=!1,showLockButtons:w=!1,showMuteButtons:S=!1,suppressStandardClassnames:k=!1,preserveQueryStateOnUnmount:E=!1,resetOnFieldChange:O=!0,resetOnOperatorChange:N=!1,autoSelectField:C=!0,autoSelectOperator:D=!0,autoSelectValue:A=!0,addRuleToNewGroups:T=!1,listsAsArrays:$=!1,parseNumbers:M=!1,disabled:R=!1,validator:x,onLog:I=yu,idGenerator:P,accessibleDescriptionGenerator:_=ui}=e,{qbId:L,resolveQbIdCollision:G,rqbContext:F,fields:z,fieldMap:j,combinators:V,getParameters:q,getOperatorsMain:B,getMatchModesMain:H,getRuleDefaultOperator:U,getSubQueryBuilderPropsMain:W,getValueEditorTypeMain:Q,getValueSourcesMain:K,getValuesMain:X,getRuleDefaultValue:Y,getInputTypeMain:J,createRule:Z,createRuleGroup:ee}=t,{controlClassnames:te,controlElements:ne,debugMode:re,enableDragAndDrop:oe,enableMountQueryChange:ae,showUndoRedo:ie,translations:le}=F,se=!!g,ue=!!v,ce=!!b,de=!!ie,fe=!!y,pe=!!w,he=!!S,me=!!O,ge=!!N,ve=!!C,be=!!D,ye=!!A,we=!!T,Se=!!$,ke=!!k,Ee=!!E,Oe=(e.maxLevels??0)>0?Number(e.maxLevels):1/0,Ne=(0,l().useCallback)((...e)=>{re&&I(...e)},[re,I]);Vu(de,!!ne.undoRedoActions),au({defaultQuery:r,queryProp:n});const Ce=tu(),De=eu(),Ae=(0,l().useMemo)(()=>cu(L),[L]),Te=((e,t)=>{const n=l().useContext(ku);return nu(e,t)??n?.initialQuery})(Ae),$e=(0,l().useCallback)(()=>Ae(Ce.getState()),[Ce,Ae]),Me=(0,l().useMemo)(()=>ee(),[ee]),Re=((e,t)=>{const n=e.query??e.storeQuery??e.defaultQuery??e.fallbackQuery;return n.id?n:Ri(n,t)})({query:n,storeQuery:Te,defaultQuery:r,fallbackQuery:Me},{idGenerator:P}),[xe]=(0,l().useState)(Re),Ie=(0,l().useMemo)(()=>({...F,initialQuery:xe}),[F,xe]);(0,l().useEffect)(()=>{n&&!Object.is(n,Te)&&De(Ys({payload:{qbId:L,query:n},onQueryChange:void 0}))},[n,L,Te,De]);const Pe=(0,l().useMemo)(()=>gr(Re),[Re]),_e=!!e.independentCombinators&&!Pe;iu(0,_e||!_e&&e.independentCombinators);const Le=(0,l().useRef)(!1);(0,l().useEffect)(()=>{Le.current||(Le.current=!0,De(Ys({payload:{qbId:L,query:Re},onQueryChange:ae&&"function"==typeof m?m:void 0})))},[ae,m,L,De,Re]);const Ge=(0,l().useRef)(Re);(0,l().useEffect)(()=>{Ge.current=Re},[Re]);const Fe=(0,l().useRef)(Ee);(0,l().useEffect)(()=>{Fe.current=Ee},[Ee]),(0,l().useEffect)(()=>(e=>{const t=(Qs.get(e)??0)+1;return Qs.set(e,t),t})(L)>1?(Ks(L),G(),bu):(Ae(Ce.getState())||De(Ys({payload:{qbId:L,query:Ge.current},onQueryChange:void 0})),()=>{0!==Ks(L)||Fe.current||De(js.actions.unsetQueryState({qbId:L}))}),[L,De,Ce,Ae,G]);const ze=(0,l().useCallback)((e,t)=>{De(Ys({payload:{qbId:L,query:e},onQueryChange:m,options:t}))},[m,L,De]),je=(0,l().useRef)(ze);(0,l().useEffect)(()=>{je.current=ze},[ze]),(0,l().useEffect)(()=>(((e,t)=>{Xs.set(e,t)})(L,(e,t)=>je.current(e,t)),()=>(e=>{Xs.delete(e)})(L)),[L]);const Ve=Array.isArray(R)&&R||pu,qe=!0===R,Be=Re.disabled||Ve.some(e=>0===e.length),He=(0,l().useMemo)(()=>((e={})=>{const{qbId:t,combinators:n,idGenerator:r,maxLevels:o=1/0,queryDisabled:a,respectDisabled:i=!0,disabledPaths:l,resetOnFieldChange:s,resetOnOperatorChange:u,getRuleDefaultOperator:c,getValueSources:d,getRuleDefaultValue:f,getMatchModes:p,freeze:h,onAddRule:m,onAddGroup:g,onRemove:v,onMoveRule:b,onMoveGroup:y,onGroupRule:w,onGroupGroup:S,onLog:k}=e,E=e=>k?.({qbId:t,...e}),O={respectDisabled:i,queryDisabled:a,disabledPaths:l},N=(e,t,n=!1)=>!!Pi(e,t,O,{asParent:n});return{addRule:(e,t,o,a)=>{if(N(e,o,!0))return void E({type:jn,rule:t,parentPath:o,query:e});const i=!m||m(t,o,e,a);if(!i)return void E({type:qn,rule:t,parentPath:o,query:e});const l=!0===i?t:i,s=Li(e,l,o,{combinators:n,combinatorPreceding:l.combinatorPreceding,idGenerator:r,freeze:h});return E({type:Xn,query:e,newQuery:s,newRule:l,parentPath:o}),s},addGroup:(e,t,a,i)=>{if(a.length>=o)return;if(N(e,a,!0))return void E({type:jn,ruleGroup:t,parentPath:a,query:e});const l=!g||g(t,a,e,i);if(!l)return void E({type:Bn,ruleGroup:t,parentPath:a,query:e});const s=!0===l?t:l,u=Li(e,s,a,{combinators:n,combinatorPreceding:s.combinatorPreceding??void 0,idGenerator:r,freeze:h});return E({type:Xn,query:e,newQuery:u,newGroup:s,parentPath:a}),u},propChange:(e,t,n,r)=>{if(Pi(e,r,"disabled"===t?{queryDisabled:a}:O))return void E({type:Vn,path:r,prop:t,value:n,query:e});const o=Vi(e,t,n,r,{resetOnFieldChange:s,resetOnOperatorChange:u,getRuleDefaultOperator:c,getValueSources:d,getRuleDefaultValue:f,getMatchModes:p,freeze:h});return E({type:Jn,query:e,newQuery:o,prop:t,value:n,path:r}),o},removeRuleOrGroup:(e,t,n)=>{if(N(e,t))return void E({type:Vn,path:t,query:e});const r=ti(t,e); +/* v8 ignore next -- @preserve */if(!r)return;if(v&&!v(r,t,e,n))return void E({type:Kn,ruleOrGroup:r,path:t,query:e});const o=Bi(e,t,{freeze:h});return E({type:Yn,query:e,newQuery:o,path:t,ruleOrGroup:r}),o},moveRule:(e,t,o,a,i)=>{if(N(e,t))return void E({type:Vn,oldPath:t,newPath:o,query:e});const l=ti(t,e);if(!l)return;const s=Wi(e,t,o,{clone:a,combinators:n,idGenerator:r,freeze:h}),u=hr(l),c=u?y:b,d=!c||c(l,t,o,e,s,{clone:a,combinators:n},i);if(!d)return void E({type:u?Qn:Wn,ruleOrGroup:l,oldPath:t,newPath:o,clone:a,query:e,nextQuery:s});const f=hr(d)?d:s;return E({type:Zn,query:e,newQuery:f,oldPath:t,newPath:o,clone:a}),f},groupRule:(e,t,o,a,i)=>{if(N(e,t))return void E({type:Vn,sourcePath:t,targetPath:o,query:e});const l=ti(t,e);if(!l)return;const s=Yi(e,t,o,{clone:a,combinators:n,idGenerator:r,freeze:h}),u=hr(l),c=u?S:w,d=!c||c(l,t,o,e,s,{clone:a,combinators:n},i);if(!d)return void E({type:u?Un:Hn,ruleOrGroup:l,sourcePath:t,targetPath:o,clone:a,query:e,nextQuery:s});const f=hr(d)?d:s;return E({type:er,query:e,newQuery:f,sourcePath:t,targetPath:o,clone:a}),f}}})({qbId:L,combinators:V,idGenerator:P,maxLevels:Oe,queryDisabled:qe,disabledPaths:Ve,resetOnFieldChange:me,resetOnOperatorChange:ge,getRuleDefaultOperator:U,getValueSources:K,getRuleDefaultValue:Y,getMatchModes:H,onAddRule:s,onAddGroup:u,onRemove:h,onMoveRule:c,onMoveGroup:d,onGroupRule:f,onGroupGroup:p,onLog:Ne}),[V,H,U,Y,K,P,Ne,Oe,u,s,p,f,d,c,h,L,qe,Ve,me,ge]),Ue=(0,l().useCallback)(e=>{const t=cu(L)(Ce.getState());if(!t)return;const n=e(t);n&&ze(n)},[ze,L,Ce]),We=(0,l().useCallback)((e,t,n)=>{Ue(r=>He.addRule(r,e,t,n))},[He,Ue]),Qe=(0,l().useCallback)((e,t,n)=>{Ue(r=>He.addGroup(r,e,t,n))},[He,Ue]),Ke=(0,l().useCallback)((e,t,n)=>{Ue(r=>He.propChange(r,e,t,n))},[He,Ue]),Xe=(0,l().useCallback)((e,t)=>{Ue(n=>He.removeRuleOrGroup(n,e,t))},[He,Ue]),Ye=(0,l().useCallback)((e,t,n,r)=>{Ue(o=>He.moveRule(o,e,t,n,r))},[He,Ue]),Je=(0,l().useCallback)((e,t,n,r)=>{Ue(o=>He.groupRule(o,e,t,n,r))},[He,Ue]),{validationResult:Ze,validationMap:et}=(0,l().useMemo)(()=>{const e="function"==typeof x&&Re?x(Re):du;return{validationResult:e,validationMap:"boolean"==typeof e?fu:e}},[Re,x]),tt=oe?"enabled":"disabled",nt=Pe||se?"enabled":"disabled",rt=(0,l().useMemo)(()=>"string"==typeof Re.combinator?{combinator:Re.combinator}:hu,[Re.combinator]),ot=(0,l().useMemo)(()=>Ir("queryBuilder",$r,{classNames:te,suppressStandardClassnames:ke,disabled:qe,validationResult:Ze}),[te,qe,ke,Ze]),at=(0,l().useCallback)(e=>ee(e??Pe),[ee,Pe]),it=(0,l().useMemo)(()=>({addRuleToNewGroups:we,accessibleDescriptionGenerator:_,autoSelectField:ve,autoSelectOperator:be,autoSelectValue:ye,classNames:te,combinators:V,getParameters:q,controls:ne,createRule:Z,createRuleGroup:at,disabledPaths:Ve,enableDragAndDrop:oe,fieldMap:j,fields:z,dispatchQuery:ze,getQuery:$e,getInputType:J,getOperators:B,getMatchModes:H,getRuleClassname:a,getRuleDefaultOperator:U,getRuleDefaultValue:Y,getRuleGroupClassname:i,getSubQueryBuilderProps:W,getValueEditorSeparator:o,getValueEditorType:Q,getValues:X,getValueSources:K,independentCombinators:Pe,listsAsArrays:Se,maxLevels:Oe,parseNumbers:M,qbId:L,resetOnFieldChange:me,resetOnOperatorChange:ge,showCloneButtons:fe,showCombinatorsBetweenRules:se,showLockButtons:pe,showMuteButtons:he,showNotToggle:ue,showShiftActions:ce,showUndoRedo:de,suppressStandardClassnames:ke,validationMap:et}),[_,we,ve,be,ye,V,te,ne,Z,at,Ve,ze,oe,j,z,J,B,H,$e,a,U,Y,i,W,o,Q,X,K,q,Pe,Se,Oe,M,L,me,ge,fe,se,pe,he,ue,ce,de,ke,et]);return{actions:(0,l().useMemo)(()=>({moveRule:Ye,onGroupAdd:Qe,onGroupRemove:Xe,onPropChange:Ke,onRuleAdd:We,onRuleRemove:Xe,groupRule:Je}),[Je,Ye,Qe,Ke,We,Xe]),rootGroup:Re,rootGroupDisabled:Be,queryDisabled:qe,rqbContext:Ie,schema:it,translations:le,wrapperClassName:ot,dndEnabledAttr:tt,inlineCombinatorsAttr:nt,combinatorPropObject:rt}}const Su=e=>wu(e,(e=>{const{qbId:t,resolveQbIdCollision:n}=Fu(e.qbId),{fields:r,baseField:o,operators:a,baseOperator:i,combinators:s,baseCombinator:u,getParameters:c,translations:d,enableMountQueryChange:f=!0,controlClassnames:p,controlElements:h,getDefaultField:m,getDefaultOperator:g,getDefaultValue:v,getMatchModes:b,getOperators:y,getSubQueryBuilderProps:w,getValueEditorType:S,getValueSources:k,getInputType:E,getValues:O,autoSelectField:N=!0,autoSelectOperator:C=!0,autoSelectValue:D=!0,addRuleToNewGroups:A=!1,enableDragAndDrop:T,showUndoRedo:$,listsAsArrays:M=!1,debugMode:R=!1,idGenerator:x=di}=e,[I]=(0,l().useState)(e.query??e.defaultQuery),P=Lu({controlClassnames:p,controlElements:h,debugMode:R,enableDragAndDrop:T,enableMountQueryChange:f,showUndoRedo:$,translations:d,initialQuery:I,qbId:t,finalize:!0}),{translations:_}=P,{fields:L,fieldMap:G}=lu({fields:r,baseField:o,autoSelectField:N,translations:_}),{optionList:F}=(0,l().useMemo)(()=>Jr({optionList:s??fn,labelMap:cn,baseOption:u,autoSelectOption:!0}),[u,s]),z=(0,l().useCallback)((e,t,n)=>Jr({optionList:c?.(e,t,n)??[],autoSelectOption:!0}).optionList,[c]),{optionList:j}=(0,l().useMemo)(()=>Jr({optionList:a??dn,placeholder:_.operators,labelMap:un,baseOption:i,autoSelectOption:C}),[C,i,a,_.operators]),V=(0,l().useCallback)((e,{fieldData:t})=>Oi({field:e,fieldData:t,getOperators:y,operators:j,placeholder:_.operators,baseOption:i,autoSelectOption:C}),[C,i,y,j,_.operators]),q=(0,l().useCallback)(e=>Ni({field:e,fieldData:G[e],getDefaultOperator:g,getOperators:(e,t)=>V(e,t)}),[G,g,V]),B=(0,l().useCallback)((e,t,{fieldData:n})=>Ci({field:e,operator:t,fieldData:n,getValueEditorType:S}),[S]),H=(0,l().useCallback)((e,t,n)=>Si(G[e],t,k),[G,k]),U=(0,l().useCallback)((e,t)=>mi(G[e],b),[G,b]),W=(0,l().useCallback)((e,t)=>w?.(e,t)??{},[w]),Q=(0,l().useCallback)((e,t,{fieldData:n})=>Di({field:e,operator:t,fieldData:n,getValues:O,placeholder:_.values,autoSelectOption:D}),[D,O,_.values]),K=(0,l().useCallback)(e=>vi(e,{fieldData:G[e.field]??{},fields:L,getParameters:(e,t,n)=>z(e,t,n),listsAsArrays:M,getValueEditorType:(e,t,n)=>B(e,t,n),getValues:(e,t,n)=>Q(e,t,n),getDefaultValue:v&&((e,t)=>v(e,t))}),[G,L,v,B,Q,M,z]),X=(0,l().useCallback)((e,t,{fieldData:n})=>{if(E){const r=E(e,t,{fieldData:n});if(r)return r}return"text"},[E]),Y=(0,l().useCallback)(()=>Zi({fields:L,getDefaultField:m,getRuleDefaultOperator:e=>q(e),getValueSources:(e,t,n)=>H(e,t,n),getMatchModes:(e,t)=>U(e,t),getRuleDefaultValue:e=>K(e),idGenerator:x}),[L,m,U,q,K,H,x]);return{qbId:t,resolveQbIdCollision:n,rqbContext:P,fields:L,fieldMap:G,combinators:F,getParameters:z,getMatchModesMain:U,getOperatorsMain:V,getRuleDefaultOperator:q,getSubQueryBuilderPropsMain:W,getValueEditorTypeMain:B,getValueSourcesMain:H,getValuesMain:Q,getRuleDefaultValue:K,getInputTypeMain:X,createRule:Y,createRuleGroup:(0,l().useCallback)(e=>el({combinators:F,addRuleToNewGroups:A,createRule:Y,idGenerator:x},e),[A,F,Y,x])}})(e)),ku=(0,l().createContext)({}),Eu=l().memo(function(e){const t=Cu(e),{previewRef:n,dropRef:r,schema:{controls:{ruleGroupBodyElements:o,ruleGroupHeaderElements:a}}}=t,i=ju(t.addRule),s=ju(t.addGroup),u=ju(t.cloneGroup),c=ju(t.toggleLockGroup),d=ju(t.toggleMuteGroup),f=ju(t.removeGroup),p=ju(t.shiftGroupUp),h=ju(t.shiftGroupDown),m=(0,l().useMemo)(()=>({addRule:i,addGroup:s,cloneGroup:u,toggleLockGroup:c,toggleMuteGroup:d,removeGroup:f,shiftGroupUp:p,shiftGroupDown:h}),[i,s,u,c,d,f,p,h]);return l().createElement("div",{ref:n,title:t.accessibleDescription,className:t.outerClassName,"data-testid":yn,"data-not":t.ruleGroup.not?"true":void 0,"data-dragmonitorid":t.dragMonitorId,"data-dropmonitorid":t.dropMonitorId,"data-rule-group-id":t.id,"data-level":t.path.length,"data-path":JSON.stringify(t.path)},l().createElement("div",{ref:r,className:t.classNames.header},l().createElement(a,{...t,...m})),l().createElement("div",{className:t.classNames.body},l().createElement(o,{...t,...m})))}),Ou=l().memo(function(e){const{dragRef:t,schema:{controls:{shiftActions:n,undoRedoActions:r,dragHandle:o,combinatorSelector:a,notToggle:i,addRuleAction:s,addGroupAction:u,cloneGroupAction:c,lockGroupAction:d,muteGroupAction:f,removeGroupAction:p}}}=e,h=(0,l().useMemo)(()=>({level:e.path.length,path:e.path,disabled:e.disabled,context:e.context,validation:e.validationResult,schema:e.schema}),[e.path,e.disabled,e.context,e.validationResult,e.schema]),m=(0,l().useMemo)(()=>e.schema.showShiftActions?{shiftUp:e.translations.shiftActionUp.title,shiftDown:e.translations.shiftActionDown.title}:void 0,[e.schema.showShiftActions,e.translations]),g=(0,l().useMemo)(()=>e.schema.showShiftActions?{shiftUp:e.translations.shiftActionUp.label,shiftDown:e.translations.shiftActionDown.label}:void 0,[e.schema.showShiftActions,e.translations]),v=(0,l().useMemo)(()=>e.schema.showUndoRedo?{undo:e.translations.undo.title,redo:e.translations.redo.title}:void 0,[e.schema.showUndoRedo,e.translations]),b=(0,l().useMemo)(()=>e.schema.showUndoRedo?{undo:e.classNames.undoAction,redo:e.classNames.redoAction}:void 0,[e.classNames.redoAction,e.classNames.undoAction,e.schema.showUndoRedo]),y=(0,l().useMemo)(()=>e.schema.showUndoRedo?{undo:e.translations.undo.label,redo:e.translations.redo.label}:void 0,[e.schema.showUndoRedo,e.translations]);return l().createElement(l().Fragment,null,e.schema.showShiftActions&&e.path.length>0&&l().createElement(n,{key:Rn,...h,testID:Rn,titles:m,labels:g,className:e.classNames.shiftActions,shiftUp:e.shiftGroupUp,shiftDown:e.shiftGroupDown,shiftUpDisabled:e.shiftUpDisabled,shiftDownDisabled:e.shiftDownDisabled,ruleOrGroup:e.ruleGroup}),e.path.length>0&&e.schema.enableDragAndDrop&&l().createElement(o,{key:In,...h,testID:In,ref:t,title:e.translations.dragHandle.title,label:e.translations.dragHandle.label,className:e.classNames.dragHandle,dragHandleAttributes:e.dragHandleAttributes,ruleOrGroup:e.ruleGroup}),!e.schema.showCombinatorsBetweenRules&&!e.schema.independentCombinators&&l().createElement(a,{key:Dn,...h,testID:Dn,options:e.schema.combinators,value:e.combinator,title:e.translations.combinators.title,className:e.classNames.combinators,handleOnChange:e.onCombinatorChange,rules:e.ruleGroup.rules,ruleGroup:e.ruleGroup}),e.schema.showNotToggle&&l().createElement(i,{key:Mn,...h,testID:Mn,className:e.classNames.notToggle,title:e.translations.notToggle.title,label:e.translations.notToggle.label,checked:e.ruleGroup.not,handleOnChange:e.onNotToggleChange,ruleGroup:e.ruleGroup}),l().createElement(s,{key:Nn,...h,testID:Nn,label:e.translations.addRule.label,title:e.translations.addRule.title,className:e.classNames.addRule,handleOnClick:e.addRule,rules:e.ruleGroup.rules,ruleOrGroup:e.ruleGroup}),e.schema.maxLevels>e.path.length&&l().createElement(u,{key:Sn,...h,testID:Sn,label:e.translations.addGroup.label,title:e.translations.addGroup.title,className:e.classNames.addGroup,handleOnClick:e.addGroup,rules:e.ruleGroup.rules,ruleOrGroup:e.ruleGroup}),e.schema.showCloneButtons&&e.path.length>0&&l().createElement(c,{key:En,...h,testID:En,label:e.translations.cloneRuleGroup.label,title:e.translations.cloneRuleGroup.title,className:e.classNames.cloneGroup,handleOnClick:e.cloneGroup,rules:e.ruleGroup.rules,ruleOrGroup:e.ruleGroup}),e.schema.showLockButtons&&l().createElement(d,{key:_n,...h,testID:_n,label:e.translations.lockGroup.label,title:e.translations.lockGroup.title,className:e.classNames.lockGroup,handleOnClick:e.toggleLockGroup,rules:e.ruleGroup.rules,disabledTranslation:e.parentDisabled?void 0:e.translations.lockGroupDisabled,ruleOrGroup:e.ruleGroup}),e.schema.showMuteButtons&&l().createElement(f,{key:Gn,...h,testID:Gn,label:e.ruleGroup.muted?e.translations.unmuteGroup.label:e.translations.muteGroup.label,title:e.ruleGroup.muted?e.translations.unmuteGroup.title:e.translations.muteGroup.title,className:e.classNames.muteGroup,handleOnClick:e.toggleMuteGroup,rules:e.ruleGroup.rules,ruleOrGroup:e.ruleGroup}),e.schema.showUndoRedo&&0===e.path.length&&r&&l().createElement(r,{key:xn,...h,testID:xn,titles:v,labels:y,className:e.classNames.undoRedoActions,classNames:b,ruleOrGroup:e.ruleGroup}),e.path.length>0&&l().createElement(p,{key:kn,...h,testID:kn,label:e.translations.removeGroup.label,title:e.translations.removeGroup.title,className:e.classNames.removeGroup,handleOnClick:e.removeGroup,rules:e.ruleGroup.rules,ruleOrGroup:e.ruleGroup}))}),Nu=l().memo(function(e){const{schema:{controls:{combinatorSelector:t,inlineCombinator:n,ruleGroup:r,rule:o}}}=e;return l().createElement(l().Fragment,null,e.ruleGroup.rules.map((a,i,{length:s})=>{const u=e.pathsMemo[i],c=u.path,d=u.disabled||"string"!=typeof a&&a.disabled,f=0===e.path.length&&0===i,p=0===e.path.length&&i===s-1,h="string"==typeof a?[...c,a].join("-"):a.id;return l().createElement(l().Fragment,{key:h},i>0&&!e.schema.independentCombinators&&e.schema.showCombinatorsBetweenRules&&l().createElement(n,{key:wn,options:e.schema.combinators,value:e.combinator,title:e.translations.combinators.title,className:e.classNames.combinators,handleOnChange:e.onCombinatorChange,rules:e.ruleGroup.rules,level:e.path.length,context:e.context,validation:e.validationResult,component:t,path:c,disabled:e.disabled,schema:e.schema,ruleGroup:e.ruleGroup}),"string"==typeof a?l().createElement(n,{key:`${wn}-independent`,options:e.schema.combinators,value:a,title:e.translations.combinators.title,className:e.classNames.combinators,handleOnChange:t=>e.onIndependentCombinatorChange(t,i),rules:e.ruleGroup.rules,level:e.path.length,context:e.context,validation:e.validationResult,component:t,path:c,disabled:d,schema:e.schema,ruleGroup:e.ruleGroup}):hr(a)?l().createElement(r,{key:yn,id:a.id,schema:e.schema,actions:e.actions,path:c,translations:e.translations,ruleGroup:a,rules:a.rules,combinator:mr(a)?a.combinator:void 0,not:!!a.not,disabled:d,parentDisabled:e.parentDisabled||e.disabled,parentMuted:e.parentMuted||e.muted,shiftUpDisabled:f,shiftDownDisabled:p,context:e.context}):l().createElement(o,{key:bn,id:a.id,rule:a,field:a.field,operator:a.operator,value:a.value,valueSource:a.valueSource,schema:e.schema,actions:e.actions,path:c,disabled:d,parentDisabled:e.parentDisabled||e.disabled,parentMuted:e.parentMuted||e.muted,translations:e.translations,shiftUpDisabled:f,shiftDownDisabled:p,context:e.context}))}))}),Cu=e=>{const{id:t,path:n,ruleGroup:r,schema:{qbId:o,accessibleDescriptionGenerator:a,classNames:i,combinators:s,createRule:u,createRuleGroup:c,disabledPaths:d,independentCombinators:f,validationMap:p,enableDragAndDrop:h,getRuleGroupClassname:m,suppressStandardClassnames:g},actions:{onGroupAdd:v,onGroupRemove:b,onPropChange:y,onRuleAdd:w,moveRule:S},disabled:k,parentDisabled:E,parentMuted:O,shiftUpDisabled:N,shiftDownDisabled:C,combinator:D,rules:A,not:T,dropEffect:$="move",groupItems:M=!1,dragMonitorId:R="",dropMonitorId:x="",previewRef:I=null,dragRef:P=null,dropRef:_=null,isDragging:L=!1,isOver:G=!1,dropNotAllowed:F=!1}=e;iu(),zu(h,!!(R||x||I||P||_));const z=!!E||!!k,j=!!O||!!r?.muted,V=(0,l().useMemo)(()=>r?so(r,s):D??Kr(s),[D,s,r]),q=(0,l().useMemo)(()=>{if(r){if(r.combinator===V||f)return r;const e=structuredClone(r);return e.combinator=V,e}return{rules:A,not:T}},[V,f,T,r,A]),B=(0,l().useMemo)(()=>{return xr(Dr,e={classNames:i,suppressStandardClassnames:g,isOver:G,dropEffect:$,dropNotAllowed:F},e);var e},[i,$,F,G,g]),H=(0,l().useCallback)(e=>{z||y("combinator",e,n)},[z,y,n]),U=(0,l().useCallback)((e,t,r)=>{z||y("combinator",e,[...n,t])},[z,y,n]),W=(0,l().useCallback)((e,t)=>{z||y("not",e,n)},[z,y,n]),Q=(0,l().useCallback)((e,t)=>{if(!z){const e=u();w(e,n,t)}},[u,z,w,n]),K=(0,l().useCallback)((e,t)=>{if(!z){const e=c();v(e,n,t)}},[c,z,v,n]),X=(0,l().useCallback)(()=>{if(!z){const e=[...oi(n),n.at(-1)+1];S(n,e,!0)}},[z,S,n]),Y=(0,l().useCallback)((e,t)=>{z||N||S(n,"up",e?.altKey)},[z,S,n,N]),J=(0,l().useCallback)((e,t)=>{z||C||S(n,"down",e?.altKey)},[z,S,n,C]),Z=(0,l().useCallback)(()=>{y("disabled",!z,n)},[z,y,n]),ee=(0,l().useCallback)(()=>{y("muted",!q.muted,n)},[q.muted,y,n]),te=(0,l().useCallback)(()=>{z||b(n)},[z,b,n]),ne=p[t??/* v8 ignore start -- @preserve */""],re=(0,l().useMemo)(()=>bi(ne),[ne]),oe=(0,l().useMemo)(()=>f?null:Qr(s,V)?.className??"",[V,s,f]),ae=(0,l().useMemo)(()=>m(q),[m,q]),ie=(0,l().useMemo)(()=>Ir("ruleGroup",Tr,{classNames:i,suppressStandardClassnames:g,leadingClassNames:[ae,oe],disabled:z,muted:j,isDragging:L,isOver:G,groupItems:M,validationClassName:re}),[i,oe,z,j,M,L,G,ae,g,re]),le=Gu({disabled:z,disabledPaths:d,path:n,nestedArray:q.rules}),se=(0,l().useMemo)(()=>a({path:n,qbId:o}),[a,n,o]);return{...e,addGroup:K,addRule:Q,accessibleDescription:se,classNames:B,cloneGroup:X,combinator:V,disabled:z,dragMonitorId:R,dragRef:P,dropMonitorId:x,dropRef:_,isDragging:L,isOver:G,muted:j,onCombinatorChange:H,onGroupAdd:v,onIndependentCombinatorChange:U,onNotToggleChange:W,outerClassName:ie,parentDisabled:E,pathsMemo:le,previewRef:I,removeGroup:te,ruleGroup:q,shiftGroupUp:Y,shiftGroupDown:J,toggleLockGroup:Z,toggleMuteGroup:ee,validationClassName:re,validationResult:ne}},Du=({name:e,disabled:t,checked:n,label:r,handleOnChange:o})=>{const a=l().useId();return l().createElement("label",{htmlFor:a},l().createElement("input",{id:a,type:"radio",value:e,disabled:t,checked:n,onChange:e=>o(e.target.value)}),r)},Au=e=>{const{operator:t,value:n,handleOnChange:r,title:o,className:a,type:i="text",inputType:s,values:u=[],listsAsArrays:c,fieldData:d,disabled:f,separator:p=null,testID:h,selectorComponent:m=e.schema.controls.valueSelector,parseNumbers:g,skipHook:v,valueSource:b,...y}=e,{valueAsArray:w,multiValueHandler:S,bigIntValueHandler:k,parseNumberMethod:E,valueListItemClassName:O,inputTypeCoerced:N}=Tu(e);if("null"===t||"notNull"===t)return null;const C=d?.placeholder??"";if(!("between"!==t&&"notBetween"!==t||"select"!==i&&"text"!==i)){const t=["from","to"].map((t,n)=>"text"===i?l().createElement("input",{key:t,type:N,placeholder:C,value:w[n]??"",title:o,className:O,disabled:f,onChange:e=>S(e.target.value,n)}):l().createElement(m,{key:t,...y,schema:e.schema,title:o,className:O,handleOnChange:e=>S(e,n),disabled:f,value:w[n]??Kr(u),options:u,listsAsArrays:c}));return l().createElement("span",{"data-testid":h,className:a,title:o},t[0],p,t[1])}switch(i){case"select":case"multiselect":return l().createElement(m,{...y,schema:e.schema,testID:h,className:a,title:o,handleOnChange:r,disabled:f,value:n,options:u,multiple:"multiselect"===i,listsAsArrays:c});case"textarea":return l().createElement("textarea",{"data-testid":h,placeholder:C,value:n,title:o,className:a,disabled:f,onChange:e=>r(e.target.value)});case"switch":case"checkbox":return l().createElement("input",{"data-testid":h,type:"checkbox",className:a,title:o,onChange:e=>r(e.target.checked),checked:!!n,disabled:f});case"radio":return l().createElement("span",{"data-testid":h,className:a,title:o},u.map(e=>l().createElement(Du,{key:e.name,name:e.name,disabled:f,checked:n===e.name,handleOnChange:r,label:e.label})))}return"bigint"===s?l().createElement("input",{"data-testid":h,type:N,placeholder:C,value:`${n}`,title:o,className:a,disabled:f,onChange:e=>k(e.target.value)}):l().createElement("input",{"data-testid":h,type:N,placeholder:C,value:n,title:o,className:a,disabled:f,onChange:e=>r(uo(e.target.value,{parseNumbers:E}))})},Tu=e=>{const{handleOnChange:t,inputType:n,operator:r,value:o,listsAsArrays:a,parseNumbers:i,values:s,type:u,skipHook:c,schema:{classNames:d,suppressStandardClassnames:f}}=e;(0,l().useEffect)(()=>{const{reset:e,value:a}=(({skipHook:e,type:t,operator:n,value:r,inputType:o})=>e||"multiselect"===t||co.has(n)||!(Array.isArray(r)||"number"===o&&"string"==typeof r&&r.includes(","))?{reset:!1,value:r}:{reset:!0,value:lr(r,{retainEmptyStrings:!0})[0]??""})({skipHook:c,type:u??void 0,operator:r,value:o,inputType:n});e&&t(a)},[t,n,r,c,u,o]);const p=(0,l().useMemo)(()=>lr(o,{retainEmptyStrings:!0}),[o]),h=(0,l().useMemo)(()=>vo({parseNumbers:i,inputType:n}),[n,i]);return{valueAsArray:p,multiValueHandler:(0,l().useCallback)((e,n)=>{t((({value:e,index:t,valueAsArray:n,operator:r,values:o,listsAsArrays:a,parseNumberMethod:i})=>{const l=uo(e,{parseNumbers:i}),s=0===t&&(e=>"between"===e||"notBetween"===e)(r)&&(n.length<2||void 0===n[1]);if(n[t]===l&&!s)return a?n:ar(n,",");const u=[...n];return u[t]=l,s&&(u[1]=Kr(o)??""),a?u:ar(u,",")})({value:e,index:n,valueAsArray:p,operator:r,values:s,listsAsArrays:a,parseNumberMethod:h}))},[t,a,r,h,p,s]),bigIntValueHandler:(0,l().useCallback)(e=>{t(((e,t)=>{const n=uo(e,{parseNumbers:t,bigIntOnOverflow:!0});try{return BigInt(n)}catch{return n}})(e,h))},[t,h]),parseNumberMethod:h,valueListItemClassName:(m="valueListItem",g={classNames:d,suppressStandardClassnames:f},Rr(m,Cr[m],{},g)),inputTypeCoerced:fo(n,r)};var m,g},$u=e=>{const t=Lu(e);return l().createElement(ku.Provider,{value:t},e.children)},Mu=e=>{const{onChange:t,val:n}=Ru(e),r=(e=>{const{multiple:t,onChange:n}=e;return(0,l().useMemo)(()=>t?e=>n(Array.from(e.target.selectedOptions).map(e=>e.value)):e=>n(e.target.value),[t,n])})({multiple:e.multiple,onChange:t});return l().createElement("select",{"data-testid":e.testID,className:e.className,value:n,title:e.title,disabled:e.disabled,multiple:!!e.multiple,onChange:r},(o=e.options,Hr(o)?o.map(e=>l().createElement("optgroup",{key:e.label,label:e.label},e.options.map(e=>l().createElement("option",{key:e.name,value:e.name,disabled:e.disabled},e.label)))):Array.isArray(o)?o.map(e=>l().createElement("option",{key:e.name,value:e.name,disabled:e.disabled},e.label)):null));var o},Ru=e=>{const{handleOnChange:t,listsAsArrays:n=!1,multiple:r=!1,value:o}=e;return{onChange:(0,l().useCallback)(e=>{t(((e,{multiple:t,listsAsArrays:n}={})=>{if(!t)return e;const r=lr(e);return n?r:ar(r,",")})(e,{multiple:r,listsAsArrays:n}))},[t,n,r]),val:(0,l().useMemo)(()=>((e,t)=>t?lr(e).map(String):e)(o,r),[r,o])}},xu=({props:e})=>{const t=Su(e),n=t.schema.controls.ruleGroup,r=ku;return l().createElement(r.Provider,{key:t.dndEnabledAttr,value:t.rqbContext},l().createElement("div",{role:"form",className:t.wrapperClassName,"data-dnd":t.dndEnabledAttr,"data-inlinecombinators":t.inlineCombinatorsAttr},l().createElement(n,{translations:t.translations,ruleGroup:t.rootGroup,rules:t.rootGroup.rules,...t.combinatorPropObject,not:!!t.rootGroup.not,schema:t.schema,actions:t.actions,id:t.rootGroup.id,path:tr,disabled:t.rootGroupDisabled,shiftUpDisabled:!0,shiftDownDisabled:!0,parentDisabled:t.queryDisabled,context:e.context})))},Iu=()=>null,Pu=(0,l().forwardRef)(Iu),_u={},Lu=({finalize:e,...t})=>{const n=(0,l().useContext)(ku),r=(0,l().useMemo)(()=>((e={},t={},n)=>Lr(nr).reduce((r,[o,a])=>(r[o]=Ti(a,e[o],t[o],!n),r),{}))(t,n,e),[t,n,e]),o=e?!1!==n.enableDragAndDrop&&Ti(!1,t.enableDragAndDrop,n.enableDragAndDrop):t.enableDragAndDrop??n.enableDragAndDrop,a=(0,l().useMemo)(()=>((...e)=>({queryBuilder:Ei("queryBuilder",e),ruleGroup:Ei("ruleGroup",e),header:Ei("header",e),body:Ei("body",e),combinators:Ei("combinators",e),addRule:Ei("addRule",e),addGroup:Ei("addGroup",e),cloneRule:Ei("cloneRule",e),cloneGroup:Ei("cloneGroup",e),removeGroup:Ei("removeGroup",e),rule:Ei("rule",e),fields:Ei("fields",e),operators:Ei("operators",e),value:Ei("value",e),removeRule:Ei("removeRule",e),notToggle:Ei("notToggle",e),shiftActions:Ei("shiftActions",e),undoRedoActions:Ei("undoRedoActions",e),undoAction:Ei("undoAction",e),redoAction:Ei("redoAction",e),dragHandle:Ei("dragHandle",e),lockRule:Ei("lockRule",e),lockGroup:Ei("lockGroup",e),muteRule:Ei("muteRule",e),muteGroup:Ei("muteGroup",e),muted:Ei("muted",e),valueSource:Ei("valueSource",e),actionElement:Ei("actionElement",e),valueSelector:Ei("valueSelector",e),betweenRules:Ei("betweenRules",e),valid:Ei("valid",e),invalid:Ei("invalid",e),dndDragging:Ei("dndDragging",e),dndOver:Ei("dndOver",e),dndCopy:Ei("dndCopy",e),dndGroup:Ei("dndGroup",e),dndDropNotAllowed:Ei("dndDropNotAllowed",e),dndPreviewPosition:Ei("dndPreviewPosition",e),dndHidden:Ei("dndHidden",e),disabled:Ei("disabled",e),valueListItem:Ei("valueListItem",e),matchMode:Ei("matchMode",e),matchThreshold:Ei("matchThreshold",e),branches:Ei("branches",e),hasSubQuery:Ei("hasSubQuery",e),loading:Ei("loading",e),valueDateTimeRelative:Ei("valueDateTimeRelative",e)}))(n.controlClassnames,t.controlClassnames),[n.controlClassnames,t.controlClassnames]),i=(0,l().useMemo)(()=>({actionElement:a.actionElement,addGroup:a.addGroup,addRule:a.addRule,body:a.body,cloneGroup:a.cloneGroup,cloneRule:a.cloneRule,combinators:a.combinators,dragHandle:a.dragHandle,fields:a.fields,header:a.header,lockGroup:a.lockGroup,lockRule:a.lockRule,muteGroup:a.muteGroup,muteRule:a.muteRule,muted:a.muted,notToggle:a.notToggle,operators:a.operators,queryBuilder:a.queryBuilder,removeGroup:a.removeGroup,removeRule:a.removeRule,rule:a.rule,ruleGroup:a.ruleGroup,shiftActions:a.shiftActions,undoRedoActions:a.undoRedoActions,undoAction:a.undoAction,redoAction:a.redoAction,value:a.value,valueSelector:a.valueSelector,valueSource:a.valueSource,betweenRules:a.betweenRules,valid:a.valid,invalid:a.invalid,dndDragging:a.dndDragging,dndOver:a.dndOver,dndCopy:a.dndCopy,dndGroup:a.dndGroup,dndDropNotAllowed:a.dndDropNotAllowed,dndPreviewPosition:a.dndPreviewPosition,dndHidden:a.dndHidden,disabled:a.disabled,valueListItem:a.valueListItem,matchMode:a.matchMode,matchThreshold:a.matchThreshold,branches:a.branches,hasSubQuery:a.hasSubQuery,loading:a.loading,valueDateTimeRelative:a.valueDateTimeRelative}),[a.actionElement,a.addGroup,a.addRule,a.betweenRules,a.body,a.branches,a.cloneGroup,a.cloneRule,a.combinators,a.disabled,a.dndCopy,a.dndDropNotAllowed,a.dndPreviewPosition,a.dndHidden,a.dndGroup,a.dndDragging,a.dndOver,a.dragHandle,a.fields,a.hasSubQuery,a.header,a.invalid,a.loading,a.lockGroup,a.lockRule,a.muteGroup,a.muteRule,a.muted,a.matchMode,a.matchThreshold,a.notToggle,a.operators,a.queryBuilder,a.removeGroup,a.removeRule,a.rule,a.ruleGroup,a.shiftActions,a.undoRedoActions,a.undoAction,a.redoAction,a.valid,a.value,a.valueDateTimeRelative,a.valueListItem,a.valueSelector,a.valueSource]),s=n.controlElements??_u,u=t.controlElements??_u,c=(0,l().useCallback)((t,n,r)=>{const o="dragHandle"===t?Pu:Iu,a=(t.endsWith("Action")&&u.actionElement?u.actionElement:void 0)??(t.endsWith("Selector")&&u.valueSelector?u.valueSelector:void 0),i=(t.endsWith("Action")&&s.actionElement?s.actionElement:void 0)??(t.endsWith("Selector")&&s.valueSelector?s.valueSelector:void 0),l=null===n?o:n??(e?a:void 0)??(null===r?o:r??(e?i:void 0));return l?{[t]:l}:e?{[t]:Xu[t]}:_u},[s.actionElement,s.valueSelector,e,u.actionElement,u.valueSelector]),d=(0,l().useMemo)(()=>Object.assign({},c("addGroupAction",u.addGroupAction,s.addGroupAction),c("addRuleAction",u.addRuleAction,s.addRuleAction),c("cloneGroupAction",u.cloneGroupAction,s.cloneGroupAction),c("cloneRuleAction",u.cloneRuleAction,s.cloneRuleAction),c("combinatorSelector",u.combinatorSelector,s.combinatorSelector),c("dragHandle",u.dragHandle,s.dragHandle),c("fieldSelector",u.fieldSelector,s.fieldSelector),c("inlineCombinator",u.inlineCombinator,s.inlineCombinator),c("lockGroupAction",u.lockGroupAction,s.lockGroupAction),c("lockRuleAction",u.lockRuleAction,s.lockRuleAction),c("muteGroupAction",u.muteGroupAction,s.muteGroupAction),c("muteRuleAction",u.muteRuleAction,s.muteRuleAction),c("notToggle",u.notToggle,s.notToggle),c("operatorSelector",u.operatorSelector,s.operatorSelector),c("removeGroupAction",u.removeGroupAction,s.removeGroupAction),c("removeRuleAction",u.removeRuleAction,s.removeRuleAction),c("shiftActions",u.shiftActions,s.shiftActions),c("undoRedoActions",u.undoRedoActions,s.undoRedoActions),{valueEditor:null===u.valueEditor?Iu:u.valueEditor??(null===s.valueEditor?Iu:s.valueEditor)??Xu.valueEditor},c("valueSourceSelector",u.valueSourceSelector,s.valueSourceSelector),c("matchModeEditor",u.matchModeEditor,s.matchModeEditor),c("rule",u.rule,s.rule),c("ruleGroup",u.ruleGroup,s.ruleGroup),c("ruleGroupBodyElements",u.ruleGroupBodyElements,s.ruleGroupBodyElements),c("ruleGroupHeaderElements",u.ruleGroupHeaderElements,s.ruleGroupHeaderElements),{actionElement:u.actionElement??s.actionElement??(e?Xu.actionElement:void 0)},{valueSelector:u.valueSelector??s.valueSelector??(e?Xu.valueSelector:void 0)}),[s.actionElement,s.addGroupAction,s.addRuleAction,s.cloneGroupAction,s.cloneRuleAction,s.combinatorSelector,s.dragHandle,s.fieldSelector,s.inlineCombinator,s.lockGroupAction,s.lockRuleAction,s.muteGroupAction,s.muteRuleAction,s.matchModeEditor,s.notToggle,s.operatorSelector,s.removeGroupAction,s.removeRuleAction,s.rule,s.ruleGroup,s.ruleGroupBodyElements,s.ruleGroupHeaderElements,s.shiftActions,s.undoRedoActions,s.valueEditor,s.valueSelector,s.valueSourceSelector,c,e,u.actionElement,u.addGroupAction,u.addRuleAction,u.cloneGroupAction,u.cloneRuleAction,u.combinatorSelector,u.dragHandle,u.fieldSelector,u.inlineCombinator,u.lockGroupAction,u.lockRuleAction,u.muteGroupAction,u.muteRuleAction,u.matchModeEditor,u.notToggle,u.operatorSelector,u.removeGroupAction,u.removeRuleAction,u.rule,u.ruleGroup,u.ruleGroupBodyElements,u.ruleGroupHeaderElements,u.shiftActions,u.undoRedoActions,u.valueEditor,u.valueSelector,u.valueSourceSelector]),f=t.translations??_u,p=n.translations??_u;return{...r,controlClassnames:i,controlElements:d,enableDragAndDrop:o,translations:(0,l().useMemo)(()=>Object.assign({},ki("addGroup",{label:[f.addGroup?.label,p.addGroup?.label],title:[f.addGroup?.title,p.addGroup?.title]},e?sn:void 0),ki("addRule",{label:[f.addRule?.label,p.addRule?.label],title:[f.addRule?.title,p.addRule?.title]},e?sn:void 0),ki("cloneRule",{label:[f.cloneRule?.label,p.cloneRule?.label],title:[f.cloneRule?.title,p.cloneRule?.title]},e?sn:void 0),ki("cloneRuleGroup",{label:[f.cloneRuleGroup?.label,p.cloneRuleGroup?.label],title:[f.cloneRuleGroup?.title,p.cloneRuleGroup?.title]},e?sn:void 0),ki("combinators",{title:[f.combinators?.title,p.combinators?.title]},e?sn:void 0),ki("dragHandle",{label:[f.dragHandle?.label,p.dragHandle?.label],title:[f.dragHandle?.title,p.dragHandle?.title]},e?sn:void 0),ki("fields",{placeholderGroupLabel:[f.fields?.placeholderGroupLabel,p.fields?.placeholderGroupLabel],placeholderLabel:[f.fields?.placeholderLabel,p.fields?.placeholderLabel],placeholderName:[f.fields?.placeholderName,p.fields?.placeholderName],title:[f.fields?.title,p.fields?.title]},e?sn:void 0),ki("lockGroup",{label:[f.lockGroup?.label,p.lockGroup?.label],title:[f.lockGroup?.title,p.lockGroup?.title]},e?sn:void 0),ki("lockGroupDisabled",{label:[f.lockGroupDisabled?.label,p.lockGroupDisabled?.label],title:[f.lockGroupDisabled?.title,p.lockGroupDisabled?.title]},e?sn:void 0),ki("lockRule",{label:[f.lockRule?.label,p.lockRule?.label],title:[f.lockRule?.title,p.lockRule?.title]},e?sn:void 0),ki("lockRuleDisabled",{label:[f.lockRuleDisabled?.label,p.lockRuleDisabled?.label],title:[f.lockRuleDisabled?.title,p.lockRuleDisabled?.title]},e?sn:void 0),ki("muteGroup",{label:[f.muteGroup?.label,p.muteGroup?.label],title:[f.muteGroup?.title,p.muteGroup?.title]},e?sn:void 0),ki("unmuteGroup",{label:[f.unmuteGroup?.label,p.unmuteGroup?.label],title:[f.unmuteGroup?.title,p.unmuteGroup?.title]},e?sn:void 0),ki("muteRule",{label:[f.muteRule?.label,p.muteRule?.label],title:[f.muteRule?.title,p.muteRule?.title]},e?sn:void 0),ki("unmuteRule",{label:[f.unmuteRule?.label,p.unmuteRule?.label],title:[f.unmuteRule?.title,p.unmuteRule?.title]},e?sn:void 0),ki("notToggle",{label:[f.notToggle?.label,p.notToggle?.label],title:[f.notToggle?.title,p.notToggle?.title]},e?sn:void 0),ki("operators",{placeholderGroupLabel:[f.operators?.placeholderGroupLabel,p.operators?.placeholderGroupLabel],placeholderLabel:[f.operators?.placeholderLabel,p.operators?.placeholderLabel],placeholderName:[f.operators?.placeholderName,p.operators?.placeholderName],title:[f.operators?.title,p.operators?.title]},e?sn:void 0),ki("values",{placeholderGroupLabel:[f.values?.placeholderGroupLabel,p.values?.placeholderGroupLabel],placeholderLabel:[f.values?.placeholderLabel,p.values?.placeholderLabel],placeholderName:[f.values?.placeholderName,p.values?.placeholderName],title:[f.values?.title,p.values?.title]},e?sn:void 0),ki("removeGroup",{label:[f.removeGroup?.label,p.removeGroup?.label],title:[f.removeGroup?.title,p.removeGroup?.title]},e?sn:void 0),ki("removeRule",{label:[f.removeRule?.label,p.removeRule?.label],title:[f.removeRule?.title,p.removeRule?.title]},e?sn:void 0),ki("shiftActionDown",{label:[f.shiftActionDown?.label,p.shiftActionDown?.label],title:[f.shiftActionDown?.title,p.shiftActionDown?.title]},e?sn:void 0),ki("shiftActionUp",{label:[f.shiftActionUp?.label,p.shiftActionUp?.label],title:[f.shiftActionUp?.title,p.shiftActionUp?.title]},e?sn:void 0),ki("undo",{label:[f.undo?.label,p.undo?.label],title:[f.undo?.title,p.undo?.title]},e?sn:void 0),ki("redo",{label:[f.redo?.label,p.redo?.label],title:[f.redo?.title,p.redo?.title]},e?sn:void 0),ki("matchMode",{title:[f.matchMode?.title,p.matchMode?.title]},e?sn:void 0),ki("matchThreshold",{title:[f.matchThreshold?.title,p.matchThreshold?.title],placeholderName:[f.matchThreshold?.placeholderName,p.matchThreshold?.placeholderName]},e?sn:void 0),ki("value",{title:[f.value?.title,p.value?.title]},e?sn:void 0),ki("valueSourceSelector",{title:[f.valueSourceSelector?.title,p.valueSourceSelector?.title]},e?sn:void 0)),[p.addGroup?.label,p.addGroup?.title,p.addRule?.label,p.addRule?.title,p.cloneRule?.label,p.cloneRule?.title,p.cloneRuleGroup?.label,p.cloneRuleGroup?.title,p.combinators?.title,p.dragHandle?.label,p.dragHandle?.title,p.fields?.placeholderGroupLabel,p.fields?.placeholderLabel,p.fields?.placeholderName,p.fields?.title,p.lockGroup?.label,p.lockGroup?.title,p.lockGroupDisabled?.label,p.lockGroupDisabled?.title,p.lockRule?.label,p.lockRule?.title,p.lockRuleDisabled?.label,p.lockRuleDisabled?.title,p.muteGroup?.label,p.muteGroup?.title,p.unmuteGroup?.label,p.unmuteGroup?.title,p.muteRule?.label,p.muteRule?.title,p.unmuteRule?.label,p.unmuteRule?.title,p.matchMode?.title,p.matchThreshold?.title,p.matchThreshold?.placeholderName,p.notToggle?.label,p.notToggle?.title,p.operators?.placeholderGroupLabel,p.operators?.placeholderLabel,p.operators?.placeholderName,p.operators?.title,p.removeGroup?.label,p.removeGroup?.title,p.removeRule?.label,p.removeRule?.title,p.shiftActionDown?.label,p.shiftActionDown?.title,p.shiftActionUp?.label,p.shiftActionUp?.title,p.undo?.label,p.undo?.title,p.redo?.label,p.redo?.title,p.value?.title,p.values?.placeholderGroupLabel,p.values?.placeholderLabel,p.values?.placeholderName,p.values?.title,p.valueSourceSelector?.title,e,f.addGroup?.label,f.addGroup?.title,f.addRule?.label,f.addRule?.title,f.cloneRule?.label,f.cloneRule?.title,f.cloneRuleGroup?.label,f.cloneRuleGroup?.title,f.combinators?.title,f.dragHandle?.label,f.dragHandle?.title,f.fields?.placeholderGroupLabel,f.fields?.placeholderLabel,f.fields?.placeholderName,f.fields?.title,f.lockGroup?.label,f.lockGroup?.title,f.lockGroupDisabled?.label,f.lockGroupDisabled?.title,f.lockRule?.label,f.lockRule?.title,f.lockRuleDisabled?.label,f.lockRuleDisabled?.title,f.muteGroup?.label,f.muteGroup?.title,f.unmuteGroup?.label,f.unmuteGroup?.title,f.muteRule?.label,f.muteRule?.title,f.unmuteRule?.label,f.unmuteRule?.title,f.matchMode?.title,f.matchThreshold?.title,f.matchThreshold?.placeholderName,f.notToggle?.label,f.notToggle?.title,f.operators?.placeholderGroupLabel,f.operators?.placeholderLabel,f.operators?.placeholderName,f.operators?.title,f.removeGroup?.label,f.removeGroup?.title,f.removeRule?.label,f.removeRule?.title,f.shiftActionDown?.label,f.shiftActionDown?.title,f.shiftActionUp?.label,f.shiftActionUp?.title,f.undo?.label,f.undo?.title,f.redo?.label,f.redo?.title,f.value?.title,f.values?.placeholderGroupLabel,f.values?.placeholderLabel,f.values?.placeholderName,f.values?.title,f.valueSourceSelector?.title]),initialQuery:t.initialQuery,qbId:t.qbId}},Gu=({disabled:e,path:t,nestedArray:n,disabledPaths:r})=>{const o=n.length;return(0,l().useMemo)(()=>((e,t,{disabled:n=!1,disabledPaths:r=[]}={})=>{const o=[];for(let a=0;aai(t,e))}}return o})(t,o,{disabled:e,disabledPaths:r}),[e,t,o,r])},Fu=e=>{const t=eu(),[n,r]=(0,l().useState)(()=>e??di()),[o]=(0,l().useState)(e);return{qbId:n,resolveQbIdCollision:(0,l().useCallback)(()=>{r(di())},[t])}};const zu=(e,t)=>{0},ju=e=>(0,l().useCallback)((t,n)=>{t?.preventDefault(),t?.stopPropagation(),e(t,n)},[e]);const Vu=(e,t)=>{0},qu={mode:"all"},Bu=[{name:"",value:"",label:""}],Hu=l().memo(function(e){const t=Ku(e),{dndRef:n}=t,r=ju(t.cloneRule),o=ju(t.toggleLockRule),a=ju(t.toggleMuteRule),i=ju(t.removeRule),s=ju(t.shiftRuleUp),u=ju(t.shiftRuleDown),c=(0,l().useMemo)(()=>({cloneRule:r,toggleLockRule:o,toggleMuteRule:a,removeRule:i,shiftRuleUp:s,shiftRuleDown:u}),[r,i,u,s,o,a]);return l().createElement("div",{ref:n,"data-testid":bn,"data-dragmonitorid":t.dragMonitorId,"data-dropmonitorid":t.dropMonitorId,className:t.outerClassName,"data-rule-id":t.id,"data-level":t.path.length,"data-path":JSON.stringify(t.path)},t.matchModes.length>0?l().createElement(Qu,{...t,...c}):l().createElement(Uu,{...t,...c}))}),Uu=l().memo(function(e){const{dragRef:t,schema:{controls:{shiftActions:n,dragHandle:r,fieldSelector:o,matchModeEditor:a,operatorSelector:i,valueSourceSelector:s,valueEditor:u,cloneRuleAction:c,lockRuleAction:d,muteRuleAction:f,removeRuleAction:p,ruleGroupBodyElements:h,ruleGroupHeaderElements:m}},groupComponentsWrapper:g=l().Fragment}=e,v=(0,l().useMemo)(()=>({level:e.path.length,path:e.path,disabled:e.disabled,context:e.context,validation:e.validationResult,schema:e.schema,rule:e.rule}),[e.path,e.disabled,e.context,e.validationResult,e.schema,e.rule]),b=(0,l().useMemo)(()=>!(1===e.schema.fields.length&&fr(e.schema.fields[0])&&"value"in e.schema.fields[0]&&""===e.schema.fields[0].value),[e.schema.fields]),y=(0,l().useMemo)(()=>e.schema.showShiftActions?{shiftUp:e.translations.shiftActionUp.title,shiftDown:e.translations.shiftActionDown.title}:void 0,[e.schema.showShiftActions,e.translations]),w=(0,l().useMemo)(()=>e.schema.showShiftActions?{shiftUp:e.translations.shiftActionUp.label,shiftDown:e.translations.shiftActionDown.label}:void 0,[e.schema.showShiftActions,e.translations]);return l().createElement(l().Fragment,null,e.schema.showShiftActions&&l().createElement(n,{key:Rn,...v,testID:Rn,titles:y,labels:w,className:e.classNames.shiftActions,ruleOrGroup:e.rule,shiftUp:e.shiftRuleUp,shiftDown:e.shiftRuleDown,shiftUpDisabled:e.shiftUpDisabled,shiftDownDisabled:e.shiftDownDisabled}),e.schema.enableDragAndDrop&&l().createElement(r,{key:In,...v,testID:In,ref:t,title:e.translations.dragHandle.title,label:e.translations.dragHandle.label,className:e.classNames.dragHandle,dragHandleAttributes:e.dragHandleAttributes,ruleOrGroup:e.rule}),b&&l().createElement(o,{key:An,...v,testID:An,options:e.schema.fields,title:e.translations.fields.title,value:e.rule.field,operator:e.rule.operator,className:e.classNames.fields,handleOnChange:e.onChangeField}),(e.schema.autoSelectField||e.rule.field!==e.translations.fields.placeholderName)&&(e.subQuery?l().createElement(a,{key:zn,...v,testID:zn,field:e.rule.field,fieldData:e.fieldData,title:e.translations.matchMode.title,options:e.matchModes,thresholdPlaceholder:e.translations.matchThreshold.placeholderName,match:e.rule.match??/* v8 ignore start -- @preserve */qu,className:e.classNames.matchMode,classNames:e.classNames,handleOnChange:e.onChangeMatchMode}):l().createElement(l().Fragment,null,l().createElement(i,{key:Tn,...v,testID:Tn,field:e.rule.field,fieldData:e.fieldData,title:e.translations.operators.title,options:e.operators,value:e.rule.operator,className:e.classNames.operators,handleOnChange:e.onChangeOperator}),(e.schema.autoSelectOperator||e.rule.operator!==e.translations.operators.placeholderName)&&!e.hideValueControls&&l().createElement(l().Fragment,null,!["null","notnull"].includes(cr(`${e.rule.operator}`))&&e.valueSources.length>1&&l().createElement(s,{key:Fn,...v,testID:Fn,field:e.rule.field,fieldData:e.fieldData,title:e.translations.valueSourceSelector.title,options:e.valueSourceOptions,value:e.rule.valueSource??"value",className:e.classNames.valueSource,handleOnChange:e.onChangeValueSource}),l().createElement(u,{key:$n,...v,testID:$n,field:e.rule.field,fieldData:e.fieldData,title:e.translations.value.title,operator:e.rule.operator,value:e.rule.value,valueSource:e.rule.valueSource??"value",type:e.valueEditorType,inputType:e.inputType,values:e.values,listsAsArrays:e.schema.listsAsArrays,parseNumbers:e.schema.parseNumbers,separator:e.valueEditorSeparator,className:e.classNames.value,handleOnChange:e.onChangeValue})))),e.subQuery&&l().createElement(g,{className:e.subQuery.classNames.header},l().createElement(m,e.subQuery)),e.schema.showCloneButtons&&l().createElement(c,{key:On,...v,testID:On,label:e.translations.cloneRule.label,title:e.translations.cloneRule.title,className:e.classNames.cloneRule,ruleOrGroup:e.rule,handleOnClick:e.cloneRule}),e.schema.showLockButtons&&l().createElement(d,{key:Pn,...v,testID:Pn,label:e.translations.lockRule.label,title:e.translations.lockRule.title,className:e.classNames.lockRule,ruleOrGroup:e.rule,handleOnClick:e.toggleLockRule,disabledTranslation:e.parentDisabled?void 0:e.translations.lockRuleDisabled}),e.schema.showMuteButtons&&l().createElement(f,{key:Ln,...v,testID:Ln,label:e.rule.muted?e.translations.unmuteRule.label:e.translations.muteRule.label,title:e.rule.muted?e.translations.unmuteRule.title:e.translations.muteRule.title,className:e.classNames.muteRule,ruleOrGroup:e.rule,handleOnClick:e.toggleMuteRule}),l().createElement(p,{key:Cn,...v,testID:Cn,label:e.translations.removeRule.label,title:e.translations.removeRule.title,className:e.classNames.removeRule,ruleOrGroup:e.rule,handleOnClick:e.removeRule}),e.subQuery&&l().createElement(g,{className:e.subQuery.classNames.body},l().createElement(h,e.subQuery)))}),Wu=e=>l().createElement("div",e),Qu=l().memo(function(e){const t=(0,l().useMemo)(()=>e.schema.createRuleGroup(),[e.schema]),n=Su({...e.subQueryBuilderProps,enableDragAndDrop:!1,disabled:e.disabled,fields:e.subproperties.fields,enableMountQueryChange:!hr(e.rule.value)||!e.rule.value.id,query:hr(e.rule.value)?e.rule.value:t,onQueryChange:e.onChangeValue}),r=Cu({...n,ruleGroup:n.rootGroup,path:tr,disabled:e.disabled,parentDisabled:n.queryDisabled,id:n.rootGroup.id,shiftUpDisabled:!0,shiftDownDisabled:!0}),o=ju(r.addRule),a=ju(r.addGroup),i=ju(r.cloneGroup),s=ju(r.toggleLockGroup),u=ju(r.removeGroup),c=ju(r.shiftGroupUp),d=ju(r.shiftGroupDown),f=(0,l().useMemo)(()=>({...r,addGroup:a,addRule:o,cloneGroup:i,removeGroup:u,shiftGroupDown:d,shiftGroupUp:c,toggleLockGroup:s}),[a,o,i,u,d,c,r,s]);return l().createElement(Uu,{...e,groupComponentsWrapper:e.groupComponentsWrapper??Wu,subQuery:f})}),Ku=e=>{const{id:t,path:n,rule:r,schema:{classNames:o,fields:a,fieldMap:i,getParameters:s,getInputType:u,getMatchModes:c,getOperators:d,getSubQueryBuilderProps:f,getValueEditorType:p,getValueEditorSeparator:h,getValueSources:m,getValues:g,validationMap:v,enableDragAndDrop:b,getRuleClassname:y,suppressStandardClassnames:w},actions:{moveRule:S,onPropChange:k,onRuleRemove:E},disabled:O,parentDisabled:N,parentMuted:C,shiftUpDisabled:D,shiftDownDisabled:A,field:T,operator:$,value:M,valueSource:R,dropEffect:x="move",groupItems:I=!1,dragMonitorId:P="",dropMonitorId:_="",dndRef:L=null,dragRef:G=null,isDragging:F=!1,isOver:z=!1,dropNotAllowed:j=!1}=e;iu(),zu(b,!!(P||_||L||G));const V=!!N||!!O,q=!!C||!!r?.muted,B=(0,l().useMemo)(()=>r??{id:t,field:T??/* v8 ignore start -- @preserve */"",operator:$??/* v8 ignore start -- @preserve */"",value:M,valueSource:R},[T,t,$,r,M,R]),H=(0,l().useMemo)(()=>xr(Cr,{},{classNames:o,suppressStandardClassnames:w}),[o,w]),U=(0,l().useCallback)(e=>(t,r)=>{V||k(e,t,n,r)},[V,k,n]),W=(0,l().useMemo)(()=>U("field"),[U]),Q=(0,l().useMemo)(()=>U("operator"),[U]),K=(0,l().useMemo)(()=>U("match"),[U]),X=(0,l().useMemo)(()=>U("valueSource"),[U]),Y=(0,l().useMemo)(()=>U("value"),[U]),J=(0,l().useCallback)((e,t)=>{if(!V){const e=[...oi(n),n.at(-1)+1];S(n,e,!0,t)}},[V,S,n]),Z=(0,l().useCallback)((e,t)=>k("disabled",!V,n,t),[V,k,n]),ee=(0,l().useCallback)((e,t)=>k("muted",!B.muted,n,t),[B.muted,k,n]),te=(0,l().useCallback)((e,t)=>{V||E(n)},[V,E,n]),ne=(0,l().useCallback)((e,t)=>{V||D||S(n,"up",e?.altKey,t)},[V,S,n,D]),re=(0,l().useCallback)((e,t)=>{V||A||S(n,"down",e?.altKey,t)},[V,S,n,A]),oe=(0,l().useMemo)(()=>to(B.field,i),[i,B.field]),ae=(0,l().useMemo)(()=>((e,t,n,r)=>n.inputType??r(e,t,{fieldData:n}))(B.field,B.operator,oe,u),[oe,u,B.field,B.operator]),ie=(0,l().useMemo)(()=>c(B.field,{fieldData:oe}),[oe,c,B.field]),le=(0,l().useMemo)(()=>d(B.field,{fieldData:oe}),[oe,d,B.field]),se=(0,l().useMemo)(()=>Qr(le,B.operator),[le,B.operator]),ue=no(se),ce=(0,l().useMemo)(()=>ro({field:B.field,operator:B.operator,valueSource:B.valueSource},oe,m),[oe,m,B.field,B.operator,B.valueSource]),de=(0,l().useMemo)(()=>ce.map(({value:e})=>e),[ce]),fe=(0,l().useMemo)(()=>s(B.field,B.operator,{fieldData:oe}),[oe,s,B.field,B.operator]),pe=(0,l().useMemo)(()=>oo(fe),[fe]),he=(0,l().useMemo)(()=>ao({field:B.field,operator:B.operator,valueSource:B.valueSource},oe,pe,p),[oe,p,pe,B.field,B.operator,B.valueSource]),me=(0,l().useMemo)(()=>h(B.field,B.operator,{fieldData:oe}),[oe,h,B.field,B.operator]),ge=(0,l().useMemo)(()=>io({field:B.field,operator:B.operator,valueSource:B.valueSource},oe,a,pe,g),[oe,a,g,pe,B.field,B.operator,B.valueSource]),ve=(0,l().useMemo)(()=>f(B.field,{fieldData:oe}),[oe,f,B.field]),be=lu({translations:e.translations,fields:oe.subproperties??ve.fields??Bu,autoSelectField:e.schema.autoSelectField||!!oe.subproperties}),ye=(0,l().useMemo)(()=>lo(B,oe,v,t??/* v8 ignore start -- @preserve */""),[oe,t,B,v]),we=(0,l().useMemo)(()=>bi(ye),[ye]),Se=oe?.className??"",ke=se?.className??"",Ee=ie.length>0,Oe=(0,l().useMemo)(()=>{return e={classNames:o,suppressStandardClassnames:w,leadingClassNames:[y(B,{fieldData:oe}),Se,ke],disabled:V,muted:q,isDragging:F,isOver:z,dropEffect:x,groupItems:I,dropNotAllowed:j,hasSubQuery:Ee,validationClassName:we},Ir("rule",Ar,e);var e},[o,V,x,j,q,Se,oe,y,I,Ee,F,z,ke,B,w,we]);return{...e,classNames:H,cloneRule:J,disabled:V,dndRef:L,dragMonitorId:P,dragRef:G,dropMonitorId:_,fieldData:oe,generateOnChangeHandler:U,onChangeField:W,onChangeMatchMode:K,onChangeOperator:Q,onChangeValueSource:X,onChangeValue:Y,hideValueControls:ue,inputType:ae,matchModes:ie,muted:q,operators:le,outerClassName:Oe,removeRule:te,rule:B,shiftRuleUp:ne,shiftRuleDown:re,subproperties:be,subQueryBuilderProps:ve,toggleLockRule:Z,toggleMuteRule:ee,validationResult:ye,valueEditorSeparator:me,valueEditorType:he,values:ge,valueSourceOptions:ce,valueSources:de}},Xu={actionElement:Es,addGroupAction:Es,addRuleAction:Es,cloneGroupAction:Es,cloneRuleAction:Es,combinatorSelector:Mu,dragHandle:Os,fieldSelector:Mu,inlineCombinator:e=>{const{component:t,...n}=e,r=ur(n.schema.suppressStandardClassnames||hn.betweenRules,n.schema.classNames.betweenRules);return l().createElement("div",{className:r,"data-testid":wn},l().createElement(t,{...n,testID:Dn}))},lockGroupAction:Es,lockRuleAction:Es,matchModeEditor:e=>{const{match:t,options:n,title:r,className:o,disabled:a,testID:i,schema:s,thresholdPlaceholder:u,selectorComponent:c=e.schema.controls.valueSelector,numericEditorComponent:d=e.schema.controls.valueEditor}=e,{thresholdNum:f,thresholdRule:p,thresholdSchema:h,handleChangeMode:m,handleChangeThreshold:g}=As(e),v=(0,l().useMemo)(()=>u?{...Ns,placeholder:u}:Ns,[u]);return l().createElement(l().Fragment,null,l().createElement(c,{schema:s,testID:i,className:o,title:r,handleOnChange:m,disabled:a,value:t.mode,options:n,multiple:!1,listsAsArrays:!1,path:Ds,level:0}),Cs(t.mode)&&l().createElement(d,{skipHook:!0,testID:i,inputType:"number",title:r,className:o,disabled:a,handleOnChange:g,field:"",operator:"",value:f,valueSource:"value",fieldData:v,schema:h,path:Ds,level:0,rule:p}))},muteGroupAction:Es,muteRuleAction:Es,notToggle:e=>{const t=l().useId();return l().createElement("label",{"data-testid":e.testID,className:e.className,title:e.title,htmlFor:t},l().createElement("input",{id:t,type:"checkbox",onChange:t=>e.handleOnChange(t.target.checked),checked:!!e.checked,disabled:e.disabled}),e.label)},operatorSelector:Mu,removeGroupAction:Es,removeRuleAction:Es,rule:Hu,ruleGroup:Eu,ruleGroupBodyElements:Nu,ruleGroupHeaderElements:Ou,shiftActions:e=>l().createElement("div",{"data-testid":e.testID,className:e.className},l().createElement("button",{type:"button",disabled:e.disabled||e.shiftUpDisabled,onClick:e.shiftUp,title:e.titles?.shiftUp},e.labels?.shiftUp),l().createElement("button",{type:"button",disabled:e.disabled||e.shiftDownDisabled,onClick:e.shiftDown,title:e.titles?.shiftDown},e.labels?.shiftDown)),undoRedoActions:null,valueEditor:Au,valueSelector:Mu,valueSourceSelector:Mu};const Yu=e=>"object"==typeof e&&null!==e&&"DndProvider"in e&&"useRuleDnD"in e&&"useRuleGroupDnD"in e&&"useInlineCombinatorDnD"in e,{rule:Ju,ruleGroup:Zu,combinatorSelector:ec}=Xu,tc=(0,l().createContext)({baseControls:{rule:Ju,ruleGroup:Zu,combinatorSelector:ec}}),nc=({component:e,...t})=>{const{adapter:n,canDrop:r,copyModeModifierKey:o,copyModeAfterHoverMs:a,groupModeModifierKey:i,groupModeAfterHoverMs:s}=(0,l().useContext)(tc),{dragPreviewState:u}=(0,l().useContext)(Ce),c=null!==u,{dropRef:d,dropMonitorId:f,isOver:p}=n.useInlineCombinatorDnD({path:t.path,schema:t.schema,rules:t.rules,canDrop:r,copyModeModifierKey:o??"alt",copyModeAfterHoverMs:a,groupModeModifierKey:i??"ctrl",groupModeAfterHoverMs:s}),h=!c&&p,m=[t.schema.suppressStandardClassnames||hn.betweenRules,h&&!t.schema.classNames.dndOver||!1,h&&!t.schema.suppressStandardClassnames&&hn.dndOver||!1].filter(e=>"string"==typeof e).join(" ");return l().createElement("div",{key:"dnd",ref:d,className:m,"data-dropmonitorid":f,"data-testid":wn},l().createElement(e,{...t,testID:Dn}))},rc=e=>{const t=(0,l().useContext)(tc),{dragPreviewState:n}=(0,l().useContext)(Ce),{adapter:r,canDrop:o,copyModeModifierKey:a,copyModeAfterHoverMs:i,groupModeModifierKey:s,groupModeAfterHoverMs:u,hideDefaultDragPreview:c,onRuleDrop:d}=t,f=!!e.parentDisabled||!!e.disabled,p=r.useRuleDnD({path:e.path,disabled:f,schema:e.schema,actions:e.actions,rule:e.rule,canDrop:o,copyModeModifierKey:a??"alt",copyModeAfterHoverMs:i,groupModeModifierKey:s??"ctrl",groupModeAfterHoverMs:u,hideDefaultDragPreview:c,onRuleDrop:d}),h=n?{...p,isDragging:!1,isOver:!1,dropNotAllowed:!1}:p,{rule:m}=t.baseControls;return l().createElement(tc.Provider,{value:t},l().createElement(m,{...e,...h}))},oc=e=>{const t=(0,l().useContext)(tc),{dragPreviewState:n}=(0,l().useContext)(Ce),{adapter:r,canDrop:o,baseControls:{ruleGroup:a},copyModeModifierKey:i,copyModeAfterHoverMs:s,groupModeModifierKey:u,groupModeAfterHoverMs:c,hideDefaultDragPreview:d,onRuleDrop:f}=t,p=(0,l().useMemo)(()=>{if(0===e.path.length&&n){const t=n.shadowQuery;return{...e,ruleGroup:t,rules:t.rules}}return e},[e,n]),h=r.useRuleGroupDnD({disabled:!!p.parentDisabled||!!p.disabled,path:p.path,schema:p.schema,actions:p.actions,ruleGroup:p.ruleGroup,canDrop:o,copyModeModifierKey:i??"alt",copyModeAfterHoverMs:s,groupModeModifierKey:u??"ctrl",groupModeAfterHoverMs:c,hideDefaultDragPreview:d,onRuleDrop:f}),m=n?{...h,isDragging:!1,isOver:!1,dropNotAllowed:!1}:h;return l().createElement(a,{...p,...m})},ac=e=>{const{controlClassnames:t,controlElements:n,debugMode:r,enableDragAndDrop:o,enableMountQueryChange:a,translations:i}=e,s=Lu({controlClassnames:t,controlElements:n,debugMode:r,enableDragAndDrop:o??!0,enableMountQueryChange:a,translations:i??{}}),{enableDragAndDrop:u}=s,c=lc(e.dnd),d=u&&c?"dnd":"no-dnd",f=(0,l().useMemo)(()=>({...s,enableDragAndDrop:!1,debugMode:r}),[s,r]),p=(0,l().useMemo)(()=>({...s,enableDragAndDrop:u,debugMode:r}),[s,r,u]);if(!u||!c)return l().createElement(ku.Provider,{key:d,value:f},e.children);const{DndProvider:h}=c;return l().createElement(h,{key:d,debugMode:r,updateWhileDragging:e.updateWhileDragging,copyModeAfterHoverMs:e.copyModeAfterHoverMs,groupModeAfterHoverMs:e.groupModeAfterHoverMs},l().createElement(ku.Provider,{key:d,value:p},l().createElement(ic,{dnd:c,canDrop:e.canDrop,copyModeModifierKey:e.copyModeModifierKey,copyModeAfterHoverMs:e.copyModeAfterHoverMs,groupModeModifierKey:e.groupModeModifierKey,groupModeAfterHoverMs:e.groupModeAfterHoverMs,hideDefaultDragPreview:e.hideDefaultDragPreview,updateWhileDragging:e.updateWhileDragging,onDragMove:e.onDragMove,onRuleDrop:e.onRuleDrop},e.children)))},ic=e=>{const t=(0,l().useContext)(ku),n=(0,l().useContext)(tc),r=lc(e.dnd)??n.adapter,o=$i(void 0,e.copyModeModifierKey,n.copyModeModifierKey),a=$i(void 0,e.groupModeModifierKey,n.groupModeModifierKey),i=$i(void 0,e.copyModeAfterHoverMs,n.copyModeAfterHoverMs),s=$i(void 0,e.groupModeAfterHoverMs,n.groupModeAfterHoverMs),u=Ti(!0,e.enableDragAndDrop,t.enableDragAndDrop),c=Ti(!1,e.debugMode,t.debugMode),d=Ti(!1,e.hideDefaultDragPreview,n.hideDefaultDragPreview),f=$i(void 0,e.canDrop,n.canDrop),p=Ti(!1,e.updateWhileDragging,n.updateWhileDragging),h=$i(void 0,e.onDragMove,n.onDragMove),m=$i(void 0,e.onRuleDrop,n.onRuleDrop),g=u&&r?"dnd":"no-dnd",v=(0,l().useMemo)(()=>({rule:e.controlElements?.rule??t.controlElements?.rule??n.baseControls.rule,ruleGroup:e.controlElements?.ruleGroup??t.controlElements?.ruleGroup??n.baseControls.ruleGroup,combinatorSelector:e.controlElements?.combinatorSelector??t.controlElements?.combinatorSelector??n.baseControls.combinatorSelector}),[e.controlElements?.combinatorSelector,e.controlElements?.rule,e.controlElements?.ruleGroup,t.controlElements?.combinatorSelector,t.controlElements?.rule,t.controlElements?.ruleGroup,n.baseControls.combinatorSelector,n.baseControls.rule,n.baseControls.ruleGroup]),b=(0,l().useMemo)(()=>({...t,enableDragAndDrop:u,debugMode:c,controlElements:{...t.controlElements,ruleGroup:oc,rule:rc,inlineCombinator:nc}}),[c,u,t]),y=(0,l().useMemo)(()=>({baseControls:v,canDrop:f,copyModeModifierKey:o,copyModeAfterHoverMs:i,groupModeModifierKey:a,groupModeAfterHoverMs:s,hideDefaultDragPreview:d,updateWhileDragging:p,onDragMove:h,onRuleDrop:m,adapter:r}),[v,f,o,i,a,s,d,p,h,m,r]),w=(0,l().useMemo)(()=>({...t,enableDragAndDrop:!1,debugMode:c}),[t,c]);return u&&r?l().createElement(ku.Provider,{key:g,value:b},l().createElement(tc.Provider,{value:y},e.children)):l().createElement(ku.Provider,{key:g,value:w},e.children)};const lc=e=>{const t=e&&Yu(e)?e:null,n=(0,l().useMemo)(()=>e&&!Yu(e)?El(e):null,[e]),r=sc(null!==t||null!==n);return t??n??r},sc=e=>{const[t,r]=(0,l().useState)(null);return(0,l().useEffect)(()=>{if(e)return;let o=!1;return t||(async()=>{const[e,t,a]=await Promise.all(["","-html5-backend","-touch-backend"].map(e=>n(290)(`react-dnd${e}`).catch( /* v8 ignore next -- @preserve */ -()=>null)));if(!o)if(e){let n;if(t&&(!a||a&&!bl()))n={...e,...t,...a,ReactDndBackend:t.HTML5Backend};else{if(!a)return;n={...e,...a,...t,ReactDndBackend:a.TouchBackend}}r(()=>El(n))}else 0})(),()=>{o=!0}},[t,e]),e?null:t},uc=(0,l().createContext)({dragDropManager:void 0});function cc(e,t,...n){if("undefined"!=typeof process&&void 0===t)throw new Error("invariant requires an error message argument");if(!e){let e;if(void 0===t)e=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{let r=0;e=new Error(t.replace(/%s/g,function(){return n[r++]})),e.name="Invariant Violation"}throw e.framesToPop=1,e}}function dc(e){return"object"==typeof e}u();const fc="dnd-core/INIT_COORDS",pc="dnd-core/BEGIN_DRAG",hc="dnd-core/PUBLISH_DRAG_SOURCE",mc="dnd-core/HOVER",gc="dnd-core/DROP",vc="dnd-core/END_DRAG";function bc(e,t){return{type:fc,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}const yc={type:fc,payload:{clientOffset:null,sourceClientOffset:null}};function wc(e){return function(t=[],n={publishSource:!0}){const{publishSource:r=!0,clientOffset:o,getSourceClientOffset:a}=n,i=e.getMonitor(),l=e.getRegistry();e.dispatch(bc(o)),function(e,t,n){cc(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach(function(e){cc(n.getSource(e),"Expected sourceIds to be registered.")})}(t,i,l);const s=function(e,t){let n=null;for(let r=e.length-1;r>=0;r--)if(t.canDragSource(e[r])){n=e[r];break}return n}(t,i);if(null==s)return void e.dispatch(yc);let u=null;if(o){if(!a)throw new Error("getSourceClientOffset must be defined");!function(e){cc("function"==typeof e,"When clientOffset is provided, getSourceClientOffset must be a function.")}(a),u=a(s)}e.dispatch(bc(o,u));const c=l.getSource(s).beginDrag(i,s);if(null==c)return;!function(e){cc(dc(e),"Item must be an object.")}(c),l.pinSource(s);const d=l.getSourceType(s);return{type:pc,payload:{itemType:d,item:c,sourceId:s,clientOffset:o||null,sourceClientOffset:u||null,isSourcePublic:!!r}}}}function Sc(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kc(e){for(var t=1;t{const i=function(e,t,n,r){const o=n.getTarget(e);let a=o?o.drop(r,e):void 0;(function(e){cc(void 0===e||dc(e),"Drop result must either be an object or undefined.")})(a),void 0===a&&(a=0===t?{}:r.getDropResult());return a}(o,a,r,n),l={type:gc,payload:{dropResult:kc({},t,i)}};e.dispatch(l)})}}function Oc(e){return function(){const t=e.getMonitor(),n=e.getRegistry();!function(e){cc(e.isDragging(),"Cannot call endDrag while not dragging.")}(t);const r=t.getSourceId();if(null!=r){n.getSource(r,!0).endDrag(t,r),n.unpinSource()}return{type:vc}}}function Nc(e,t){return null===t?null===e:Array.isArray(e)?e.some(e=>e===t):e===t}function Cc(e){return function(t,{clientOffset:n}={}){!function(e){cc(Array.isArray(e),"Expected targetIds to be an array.")}(t);const r=t.slice(0),o=e.getMonitor(),a=e.getRegistry();return function(e,t,n){for(let r=e.length-1;r>=0;r--){const o=e[r];Nc(t.getTargetType(o),n)||e.splice(r,1)}}(r,a,o.getItemType()),function(e,t,n){cc(t.isDragging(),"Cannot call hover while not dragging."),cc(!t.didDrop(),"Cannot call hover after drop.");for(let t=0;t{const a=n[o];var i;return r[o]=(i=a,(...n)=>{const r=i.apply(e,n);void 0!==r&&t(r)}),r},{})}dispatch(e){this.store.dispatch(e)}constructor(e,t){this.isSetUp=!1,this.handleRefCountChange=()=>{const e=this.store.getState().refCount>0;this.backend&&(e&&!this.isSetUp?(this.backend.setup(),this.isSetUp=!0):!e&&this.isSetUp&&(this.backend.teardown(),this.isSetUp=!1))},this.store=e,this.monitor=t,e.subscribe(this.handleRefCountChange)}}function Tc(e,t){return{x:e.x-t.x,y:e.y-t.y}}const $c=[],Mc=[];$c.__IS_NONE__=!0,Mc.__IS_ALL__=!0;class Rc{subscribeToStateChange(e,t={}){const{handlerIds:n}=t;cc("function"==typeof e,"listener must be a function."),cc(void 0===n||Array.isArray(n),"handlerIds, when specified, must be an array of strings.");let r=this.store.getState().stateId;return this.store.subscribe(()=>{const t=this.store.getState(),o=t.stateId;try{const a=o===r||o===r+1&&!function(e,t){return e!==$c&&(e===Mc||void 0===t||(n=e,t.filter(e=>n.indexOf(e)>-1)).length>0);var n}(t.dirtyHandlerIds,n);a||e()}finally{r=o}})}subscribeToOffsetChange(e){cc("function"==typeof e,"listener must be a function.");let t=this.store.getState().dragOffset;return this.store.subscribe(()=>{const n=this.store.getState().dragOffset;n!==t&&(t=n,e())})}canDragSource(e){if(!e)return!1;const t=this.registry.getSource(e);return cc(t,`Expected to find a valid source. sourceId=${e}`),!this.isDragging()&&t.canDrag(this,e)}canDropOnTarget(e){if(!e)return!1;const t=this.registry.getTarget(e);if(cc(t,`Expected to find a valid target. targetId=${e}`),!this.isDragging()||this.didDrop())return!1;return Nc(this.registry.getTargetType(e),this.getItemType())&&t.canDrop(this,e)}isDragging(){return Boolean(this.getItemType())}isDraggingSource(e){if(!e)return!1;const t=this.registry.getSource(e,!0);if(cc(t,`Expected to find a valid source. sourceId=${e}`),!this.isDragging()||!this.isSourcePublic())return!1;return this.registry.getSourceType(e)===this.getItemType()&&t.isDragging(this,e)}isOverTarget(e,t={shallow:!1}){if(!e)return!1;const{shallow:n}=t;if(!this.isDragging())return!1;const r=this.registry.getTargetType(e),o=this.getItemType();if(o&&!Nc(r,o))return!1;const a=this.getTargetIds();if(!a.length)return!1;const i=a.indexOf(e);return n?i===a.length-1:i>-1}getItemType(){return this.store.getState().dragOperation.itemType}getItem(){return this.store.getState().dragOperation.item}getSourceId(){return this.store.getState().dragOperation.sourceId}getTargetIds(){return this.store.getState().dragOperation.targetIds}getDropResult(){return this.store.getState().dragOperation.dropResult}didDrop(){return this.store.getState().dragOperation.didDrop}isSourcePublic(){return Boolean(this.store.getState().dragOperation.isSourcePublic)}getInitialClientOffset(){return this.store.getState().dragOffset.initialClientOffset}getInitialSourceClientOffset(){return this.store.getState().dragOffset.initialSourceClientOffset}getClientOffset(){return this.store.getState().dragOffset.clientOffset}getSourceClientOffset(){return function(e){const{clientOffset:t,initialClientOffset:n,initialSourceClientOffset:r}=e;return t&&n&&r?Tc((a=r,{x:(o=t).x+a.x,y:o.y+a.y}),n):null;var o,a}(this.store.getState().dragOffset)}getDifferenceFromInitialOffset(){return function(e){const{clientOffset:t,initialClientOffset:n}=e;return t&&n?Tc(t,n):null}(this.store.getState().dragOffset)}constructor(e,t){this.store=e,this.registry=t}}const xc=void 0!==n.g?n.g:self,Ic=xc.MutationObserver||xc.WebKitMutationObserver;function Pc(e){return function(){const t=setTimeout(r,0),n=setInterval(r,50);function r(){clearTimeout(t),clearInterval(n),e()}}}const _c="function"==typeof Ic?function(e){let t=1;const n=new Ic(e),r=document.createTextNode("");return n.observe(r,{characterData:!0}),function(){t=-t,r.data=t}}:Pc;class Lc{call(){try{this.task&&this.task()}catch(e){this.onError(e)}finally{this.task=null,this.release(this)}}constructor(e,t){this.onError=e,this.release=t,this.task=null}}const Gc=new class{enqueueTask(e){const{queue:t,requestFlush:n}=this;t.length||(n(),this.flushing=!0),t[t.length]=e}constructor(){this.queue=[],this.pendingErrors=[],this.flushing=!1,this.index=0,this.capacity=1024,this.flush=()=>{const{queue:e}=this;for(;this.indexthis.capacity){for(let t=0,n=e.length-this.index;t{this.pendingErrors.push(e),this.requestErrorThrow()},this.requestFlush=_c(this.flush),this.requestErrorThrow=Pc(()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()})}},Fc=new class{create(e){const t=this.freeTasks,n=t.length?t.pop():new Lc(this.onError,e=>t[t.length]=e);return n.task=e,n}constructor(e){this.onError=e,this.freeTasks=[]}}(Gc.registerPendingError);const zc="dnd-core/ADD_SOURCE",jc="dnd-core/ADD_TARGET",qc="dnd-core/REMOVE_SOURCE",Bc="dnd-core/REMOVE_TARGET";function Vc(e,t){t&&Array.isArray(e)?e.forEach(e=>Vc(e,!1)):cc("string"==typeof e||"symbol"==typeof e,t?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}var Hc;!function(e){e.SOURCE="SOURCE",e.TARGET="TARGET"}(Hc||(Hc={}));let Uc=0;function Wc(e){const t=(Uc++).toString();switch(e){case Hc.SOURCE:return`S${t}`;case Hc.TARGET:return`T${t}`;default:throw new Error(`Unknown Handler Role: ${e}`)}}function Qc(e){switch(e[0]){case"S":return Hc.SOURCE;case"T":return Hc.TARGET;default:throw new Error(`Cannot parse handler ID: ${e}`)}}function Kc(e,t){const n=e.entries();let r=!1;do{const{done:e,value:[,o]}=n.next();if(o===t)return!0;r=!!e}while(!r);return!1}class Xc{addSource(e,t){Vc(e),function(e){cc("function"==typeof e.canDrag,"Expected canDrag to be a function."),cc("function"==typeof e.beginDrag,"Expected beginDrag to be a function."),cc("function"==typeof e.endDrag,"Expected endDrag to be a function.")}(t);const n=this.addHandler(Hc.SOURCE,e,t);return this.store.dispatch(function(e){return{type:zc,payload:{sourceId:e}}}(n)),n}addTarget(e,t){Vc(e,!0),function(e){cc("function"==typeof e.canDrop,"Expected canDrop to be a function."),cc("function"==typeof e.hover,"Expected hover to be a function."),cc("function"==typeof e.drop,"Expected beginDrag to be a function.")}(t);const n=this.addHandler(Hc.TARGET,e,t);return this.store.dispatch(function(e){return{type:jc,payload:{targetId:e}}}(n)),n}containsHandler(e){return Kc(this.dragSources,e)||Kc(this.dropTargets,e)}getSource(e,t=!1){cc(this.isSourceId(e),"Expected a valid source ID.");return t&&e===this.pinnedSourceId?this.pinnedSource:this.dragSources.get(e)}getTarget(e){return cc(this.isTargetId(e),"Expected a valid target ID."),this.dropTargets.get(e)}getSourceType(e){return cc(this.isSourceId(e),"Expected a valid source ID."),this.types.get(e)}getTargetType(e){return cc(this.isTargetId(e),"Expected a valid target ID."),this.types.get(e)}isSourceId(e){return Qc(e)===Hc.SOURCE}isTargetId(e){return Qc(e)===Hc.TARGET}removeSource(e){var t;cc(this.getSource(e),"Expected an existing source."),this.store.dispatch(function(e){return{type:qc,payload:{sourceId:e}}}(e)),t=()=>{this.dragSources.delete(e),this.types.delete(e)},Gc.enqueueTask(Fc.create(t))}removeTarget(e){cc(this.getTarget(e),"Expected an existing target."),this.store.dispatch(function(e){return{type:Bc,payload:{targetId:e}}}(e)),this.dropTargets.delete(e),this.types.delete(e)}pinSource(e){const t=this.getSource(e);cc(t,"Expected an existing source."),this.pinnedSourceId=e,this.pinnedSource=t}unpinSource(){cc(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}addHandler(e,t,n){const r=Wc(e);return this.types.set(r,t),e===Hc.SOURCE?this.dragSources.set(r,n):e===Hc.TARGET&&this.dropTargets.set(r,n),r}constructor(e){this.types=new Map,this.dragSources=new Map,this.dropTargets=new Map,this.pinnedSourceId=null,this.pinnedSource=null,this.store=e}}const Yc=(e,t)=>e===t;function Jc(e=$c,t){switch(t.type){case mc:break;case zc:case jc:case Bc:case qc:return $c;default:return Mc}const{targetIds:n=[],prevTargetIds:r=[]}=t.payload,o=function(e,t){const n=new Map,r=e=>{n.set(e,n.has(e)?n.get(e)+1:1)};e.forEach(r),t.forEach(r);const o=[];return n.forEach((e,t)=>{1===e&&o.push(t)}),o}(n,r);if(!(o.length>0||!function(e,t,n=Yc){if(e.length!==t.length)return!1;for(let r=0;re!==o))});case gc:return rd({},e,{dropResult:n.dropResult,didDrop:!0,targetIds:[]});case vc:return rd({},e,{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return e}var r,o}function id(e=0,t){switch(t.type){case zc:case jc:return e+1;case qc:case Bc:return e-1;default:return e}}function ld(e=0){return e+1}function sd(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ud(e){for(var t=1;te&&e[t]?e[t]:o||null,n))})}),dragOffset:td(e.dragOffset,t),refCount:id(e.refCount,t),dragOperation:ad(e.dragOperation,t),stateId:ld(e.stateId)};var n,r,o}function dd(e,t=void 0,n={},r=!1){const o=function(e){const t="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__;return Tl(cd,e&&t&&t({name:"dnd-core",instanceId:"dnd-core"}))}(r),a=new Rc(o,new Xc(o)),i=new Ac(o,a),l=e(i,t,n);return i.receiveBackend(l),i}function fd(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}let pd=0;const hd=Symbol.for("__REACT_DND_CONTEXT_INSTANCE__");var md=(0,l().memo)(function(e){var{children:t}=e,n=fd(e,["children"]);const[r,o]=function(e){if("manager"in e){return[{dragDropManager:e.manager},!1]}const t=function(e,t=gd(),n,r){const o=t;o[hd]||(o[hd]={dragDropManager:dd(e,t,n,r)});return o[hd]}(e.backend,e.context,e.options,e.debugMode),n=!e.context;return[t,n]}(n);return(0,l().useEffect)(()=>{if(o){const e=gd();return++pd,()=>{0===--pd&&(e[hd]=null)}}},[]),(0,i().jsx)(uc.Provider,{value:r,children:t})});function gd(){return void 0!==n.g?n.g:window}const vd=(0,l().memo)(function({connect:e,src:t}){return(0,l().useEffect)(()=>{if("undefined"==typeof Image)return;let n=!1;const r=new Image;return r.src=t,r.onload=()=>{e(r),n=!0},()=>{n&&e(null)}}),null});e();const bd="undefined"!=typeof window?l().useLayoutEffect:l().useEffect;function yd(t,n,r){const[o,a]=(0,l().useState)(()=>n(t)),i=(0,l().useCallback)(()=>{const i=n(t);e()(o,i)||(a(i),r&&r())},[o,t,r]);return bd(i),[o,i]}function wd(e,t,n){return function(e,t,n){const[r,o]=yd(e,t,n);return bd(function(){const t=e.getHandlerId();if(null!=t)return e.subscribeToStateChange(o,{handlerIds:[t]})},[e,o]),r}(t,e||(()=>({})),()=>n.reconnect())}function Sd(e,t){const n=[...t||[]];return null==t&&"function"!=typeof e&&n.push(e),(0,l().useMemo)(()=>"function"==typeof e?e():e,n)}function kd(e){return(0,l().useMemo)(()=>e.hooks.dragSource(),[e])}function Ed(e){return(0,l().useMemo)(()=>e.hooks.dragPreview(),[e])}function Od(e,t,n,r){let o=n?n.call(r,e,t):void 0;if(void 0!==o)return!!o;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;const a=Object.keys(e),i=Object.keys(t);if(a.length!==i.length)return!1;const l=Object.prototype.hasOwnProperty.bind(t);for(let i=0;i{if(!(0,l().isValidElement)(t)){const r=t;return e(r,n),r}const r=t;!function(e){if("string"==typeof e.type)return;const t=e.type.displayName||e.type.name||"the component";throw new Error(`Only native element nodes can now be passed to React DnD connectors.You can either wrap ${t} into a
, or turn it into a drag source or a drop target itself.`)}(r);return function(e,t){const n=e.ref;return cc("string"!=typeof n,"Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a or
. Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs"),n?(0,l().cloneElement)(e,{ref:e=>{Ad(n,e),Ad(t,e)}}):(0,l().cloneElement)(e,{ref:t})}(r,n?t=>e(t,n):e)}}function Dd(e){const t={};return Object.keys(e).forEach(n=>{const r=e[n];if(n.endsWith("Ref"))t[n]=e[n];else{const e=Cd(r);t[n]=()=>e}}),t}function Ad(e,t){"function"==typeof e?e(t):e.current=t}class Td{receiveHandlerId(e){this.handlerId!==e&&(this.handlerId=e,this.reconnect())}get connectTarget(){return this.dragSource}get dragSourceOptions(){return this.dragSourceOptionsInternal}set dragSourceOptions(e){this.dragSourceOptionsInternal=e}get dragPreviewOptions(){return this.dragPreviewOptionsInternal}set dragPreviewOptions(e){this.dragPreviewOptionsInternal=e}reconnect(){const e=this.reconnectDragSource();this.reconnectDragPreview(e)}reconnectDragSource(){const e=this.dragSource,t=this.didHandlerIdChange()||this.didConnectedDragSourceChange()||this.didDragSourceOptionsChange();return t&&this.disconnectDragSource(),this.handlerId?e?(t&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragSource=e,this.lastConnectedDragSourceOptions=this.dragSourceOptions,this.dragSourceUnsubscribe=this.backend.connectDragSource(this.handlerId,e,this.dragSourceOptions)),t):(this.lastConnectedDragSource=e,t):t}reconnectDragPreview(e=!1){const t=this.dragPreview,n=e||this.didHandlerIdChange()||this.didConnectedDragPreviewChange()||this.didDragPreviewOptionsChange();n&&this.disconnectDragPreview(),this.handlerId&&(t?n&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragPreview=t,this.lastConnectedDragPreviewOptions=this.dragPreviewOptions,this.dragPreviewUnsubscribe=this.backend.connectDragPreview(this.handlerId,t,this.dragPreviewOptions)):this.lastConnectedDragPreview=t)}didHandlerIdChange(){return this.lastConnectedHandlerId!==this.handlerId}didConnectedDragSourceChange(){return this.lastConnectedDragSource!==this.dragSource}didConnectedDragPreviewChange(){return this.lastConnectedDragPreview!==this.dragPreview}didDragSourceOptionsChange(){return!Od(this.lastConnectedDragSourceOptions,this.dragSourceOptions)}didDragPreviewOptionsChange(){return!Od(this.lastConnectedDragPreviewOptions,this.dragPreviewOptions)}disconnectDragSource(){this.dragSourceUnsubscribe&&(this.dragSourceUnsubscribe(),this.dragSourceUnsubscribe=void 0)}disconnectDragPreview(){this.dragPreviewUnsubscribe&&(this.dragPreviewUnsubscribe(),this.dragPreviewUnsubscribe=void 0,this.dragPreviewNode=null,this.dragPreviewRef=null)}get dragSource(){return this.dragSourceNode||this.dragSourceRef&&this.dragSourceRef.current}get dragPreview(){return this.dragPreviewNode||this.dragPreviewRef&&this.dragPreviewRef.current}clearDragSource(){this.dragSourceNode=null,this.dragSourceRef=null}clearDragPreview(){this.dragPreviewNode=null,this.dragPreviewRef=null}constructor(e){this.hooks=Dd({dragSource:(e,t)=>{this.clearDragSource(),this.dragSourceOptions=t||null,Nd(e)?this.dragSourceRef=e:this.dragSourceNode=e,this.reconnectDragSource()},dragPreview:(e,t)=>{this.clearDragPreview(),this.dragPreviewOptions=t||null,Nd(e)?this.dragPreviewRef=e:this.dragPreviewNode=e,this.reconnectDragPreview()}}),this.handlerId=null,this.dragSourceRef=null,this.dragSourceOptionsInternal=null,this.dragPreviewRef=null,this.dragPreviewOptionsInternal=null,this.lastConnectedHandlerId=null,this.lastConnectedDragSource=null,this.lastConnectedDragSourceOptions=null,this.lastConnectedDragPreview=null,this.lastConnectedDragPreviewOptions=null,this.backend=e}}function $d(){const{dragDropManager:e}=(0,l().useContext)(uc);return cc(null!=e,"Expected drag drop context"),e}let Md=!1,Rd=!1;class xd{receiveHandlerId(e){this.sourceId=e}getHandlerId(){return this.sourceId}canDrag(){cc(!Md,"You may not call monitor.canDrag() inside your canDrag() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return Md=!0,this.internalMonitor.canDragSource(this.sourceId)}finally{Md=!1}}isDragging(){if(!this.sourceId)return!1;cc(!Rd,"You may not call monitor.isDragging() inside your isDragging() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return Rd=!0,this.internalMonitor.isDraggingSource(this.sourceId)}finally{Rd=!1}}subscribeToStateChange(e,t){return this.internalMonitor.subscribeToStateChange(e,t)}isDraggingSource(e){return this.internalMonitor.isDraggingSource(e)}isOverTarget(e,t){return this.internalMonitor.isOverTarget(e,t)}getTargetIds(){return this.internalMonitor.getTargetIds()}isSourcePublic(){return this.internalMonitor.isSourcePublic()}getSourceId(){return this.internalMonitor.getSourceId()}subscribeToOffsetChange(e){return this.internalMonitor.subscribeToOffsetChange(e)}canDragSource(e){return this.internalMonitor.canDragSource(e)}canDropOnTarget(e){return this.internalMonitor.canDropOnTarget(e)}getItemType(){return this.internalMonitor.getItemType()}getItem(){return this.internalMonitor.getItem()}getDropResult(){return this.internalMonitor.getDropResult()}didDrop(){return this.internalMonitor.didDrop()}getInitialClientOffset(){return this.internalMonitor.getInitialClientOffset()}getInitialSourceClientOffset(){return this.internalMonitor.getInitialSourceClientOffset()}getSourceClientOffset(){return this.internalMonitor.getSourceClientOffset()}getClientOffset(){return this.internalMonitor.getClientOffset()}getDifferenceFromInitialOffset(){return this.internalMonitor.getDifferenceFromInitialOffset()}constructor(e){this.sourceId=null,this.internalMonitor=e.getMonitor()}}class Id{beginDrag(){const e=this.spec,t=this.monitor;let n=null;return n="object"==typeof e.item?e.item:"function"==typeof e.item?e.item(t):{},null!=n?n:null}canDrag(){const e=this.spec,t=this.monitor;return"boolean"==typeof e.canDrag?e.canDrag:"function"!=typeof e.canDrag||e.canDrag(t)}isDragging(e,t){const n=this.spec,r=this.monitor,{isDragging:o}=n;return o?o(r):t===e.getSourceId()}endDrag(){const e=this.spec,t=this.monitor,n=this.connector,{end:r}=e;r&&r(t.getItem(),t),n.reconnect()}constructor(e,t,n){this.spec=e,this.monitor=t,this.connector=n}}function Pd(e,t,n){const r=$d(),o=function(e,t,n){const r=(0,l().useMemo)(()=>new Id(e,t,n),[t,n]);return(0,l().useEffect)(()=>{r.spec=e},[e]),r}(e,t,n),a=function(e){return(0,l().useMemo)(()=>{const t=e.type;return cc(null!=t,"spec.type must be defined"),t},[e])}(e);bd(function(){if(null!=a){const[e,i]=function(e,t,n){const r=n.getRegistry(),o=r.addSource(e,t);return[o,()=>r.removeSource(o)]}(a,o,r);return t.receiveHandlerId(e),n.receiveHandlerId(e),i}},[r,t,n,o,a])}function _d(e,t){const n=Sd(e,t);cc(!n.begin,"useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)");const r=function(){const e=$d();return(0,l().useMemo)(()=>new xd(e),[e])}(),o=function(e,t){const n=$d(),r=(0,l().useMemo)(()=>new Td(n.getBackend()),[n]);return bd(()=>(r.dragSourceOptions=e||null,r.reconnect(),()=>r.disconnectDragSource()),[r,e]),bd(()=>(r.dragPreviewOptions=t||null,r.reconnect(),()=>r.disconnectDragPreview()),[r,t]),r}(n.options,n.previewOptions);return Pd(n,r,o),[wd(n.collect,r,o),kd(o),Ed(o)]}function Ld(e){const t=$d().getMonitor(),[n,r]=yd(t,e);return(0,l().useEffect)(()=>t.subscribeToOffsetChange(r)),(0,l().useEffect)(()=>t.subscribeToStateChange(r)),n}function Gd(e){return(0,l().useMemo)(()=>e.hooks.dropTarget(),[e])}class Fd{get connectTarget(){return this.dropTarget}reconnect(){const e=this.didHandlerIdChange()||this.didDropTargetChange()||this.didOptionsChange();e&&this.disconnectDropTarget();const t=this.dropTarget;this.handlerId&&(t?e&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDropTarget=t,this.lastConnectedDropTargetOptions=this.dropTargetOptions,this.unsubscribeDropTarget=this.backend.connectDropTarget(this.handlerId,t,this.dropTargetOptions)):this.lastConnectedDropTarget=t)}receiveHandlerId(e){e!==this.handlerId&&(this.handlerId=e,this.reconnect())}get dropTargetOptions(){return this.dropTargetOptionsInternal}set dropTargetOptions(e){this.dropTargetOptionsInternal=e}didHandlerIdChange(){return this.lastConnectedHandlerId!==this.handlerId}didDropTargetChange(){return this.lastConnectedDropTarget!==this.dropTarget}didOptionsChange(){return!Od(this.lastConnectedDropTargetOptions,this.dropTargetOptions)}disconnectDropTarget(){this.unsubscribeDropTarget&&(this.unsubscribeDropTarget(),this.unsubscribeDropTarget=void 0)}get dropTarget(){return this.dropTargetNode||this.dropTargetRef&&this.dropTargetRef.current}clearDropTarget(){this.dropTargetRef=null,this.dropTargetNode=null}constructor(e){this.hooks=Dd({dropTarget:(e,t)=>{this.clearDropTarget(),this.dropTargetOptions=t,Nd(e)?this.dropTargetRef=e:this.dropTargetNode=e,this.reconnect()}}),this.handlerId=null,this.dropTargetRef=null,this.dropTargetOptionsInternal=null,this.lastConnectedHandlerId=null,this.lastConnectedDropTarget=null,this.lastConnectedDropTargetOptions=null,this.backend=e}}let zd=!1;class jd{receiveHandlerId(e){this.targetId=e}getHandlerId(){return this.targetId}subscribeToStateChange(e,t){return this.internalMonitor.subscribeToStateChange(e,t)}canDrop(){if(!this.targetId)return!1;cc(!zd,"You may not call monitor.canDrop() inside your canDrop() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor");try{return zd=!0,this.internalMonitor.canDropOnTarget(this.targetId)}finally{zd=!1}}isOver(e){return!!this.targetId&&this.internalMonitor.isOverTarget(this.targetId,e)}getItemType(){return this.internalMonitor.getItemType()}getItem(){return this.internalMonitor.getItem()}getDropResult(){return this.internalMonitor.getDropResult()}didDrop(){return this.internalMonitor.didDrop()}getInitialClientOffset(){return this.internalMonitor.getInitialClientOffset()}getInitialSourceClientOffset(){return this.internalMonitor.getInitialSourceClientOffset()}getSourceClientOffset(){return this.internalMonitor.getSourceClientOffset()}getClientOffset(){return this.internalMonitor.getClientOffset()}getDifferenceFromInitialOffset(){return this.internalMonitor.getDifferenceFromInitialOffset()}constructor(e){this.targetId=null,this.internalMonitor=e.getMonitor()}}class qd{canDrop(){const e=this.spec,t=this.monitor;return!e.canDrop||e.canDrop(t.getItem(),t)}hover(){const e=this.spec,t=this.monitor;e.hover&&e.hover(t.getItem(),t)}drop(){const e=this.spec,t=this.monitor;if(e.drop)return e.drop(t.getItem(),t)}constructor(e,t){this.spec=e,this.monitor=t}}function Bd(e,t,n){const r=$d(),o=function(e,t){const n=(0,l().useMemo)(()=>new qd(e,t),[t]);return(0,l().useEffect)(()=>{n.spec=e},[e]),n}(e,t),a=function(e){const{accept:t}=e;return(0,l().useMemo)(()=>(cc(null!=e.accept,"accept must be defined"),Array.isArray(t)?t:[t]),[t])}(e);bd(function(){const[e,i]=function(e,t,n){const r=n.getRegistry(),o=r.addTarget(e,t);return[o,()=>r.removeTarget(o)]}(a,o,r);return t.receiveHandlerId(e),n.receiveHandlerId(e),i},[r,t,o,n,a.map(e=>e.toString()).join("|")])}function Vd(e,t){const n=Sd(e,t),r=function(){const e=$d();return(0,l().useMemo)(()=>new jd(e),[e])}(),o=function(e){const t=$d(),n=(0,l().useMemo)(()=>new Fd(t.getBackend()),[t]);return bd(()=>(n.dropTargetOptions=e||null,n.reconnect(),()=>n.disconnectDropTarget()),[e]),n}(n.options);return Bd(n,r,o),[wd(n.collect,r,o),Gd(o)]}function Hd(e){let t=null;return()=>(null==t&&(t=e()),t)}class Ud{enter(e){const t=this.entered.length;return this.entered=function(e,t){const n=new Set,r=e=>n.add(e);e.forEach(r),t.forEach(r);const o=[];return n.forEach(e=>o.push(e)),o}(this.entered.filter(t=>this.isNodeInDocument(t)&&(!t.contains||t.contains(e))),[e]),0===t&&this.entered.length>0}leave(e){const t=this.entered.length;var n,r;return this.entered=(n=this.entered.filter(this.isNodeInDocument),r=e,n.filter(e=>e!==r)),t>0&&0===this.entered.length}reset(){this.entered=[]}constructor(e){this.entered=[],this.isNodeInDocument=e}}class Wd{initializeExposedProperties(){Object.keys(this.config.exposeProperties).forEach(e=>{Object.defineProperty(this.item,e,{configurable:!0,enumerable:!0,get:()=>(console.warn(`Browser doesn't allow reading "${e}" until the drop event.`),null)})})}loadDataTransfer(e){if(e){const t={};Object.keys(this.config.exposeProperties).forEach(n=>{const r=this.config.exposeProperties[n];null!=r&&(t[n]={value:r(e,this.config.matchesTypes),configurable:!0,enumerable:!0})}),Object.defineProperties(this.item,t)}}canDrag(){return!0}beginDrag(){return this.item}isDragging(e,t){return t===e.getSourceId()}endDrag(){}constructor(e){this.config=e,this.item={},this.initializeExposedProperties()}}const Qd="__NATIVE_FILE__",Kd="__NATIVE_URL__",Xd="__NATIVE_TEXT__",Yd="__NATIVE_HTML__";function Jd(e,t,n){const r=t.reduce((t,n)=>t||e.getData(n),"");return null!=r?r:n}const Zd={[Qd]:{exposeProperties:{files:e=>Array.prototype.slice.call(e.files),items:e=>e.items,dataTransfer:e=>e},matchesTypes:["Files"]},[Yd]:{exposeProperties:{html:(e,t)=>Jd(e,t,""),dataTransfer:e=>e},matchesTypes:["Html","text/html"]},[Kd]:{exposeProperties:{urls:(e,t)=>Jd(e,t,"").split("\n"),dataTransfer:e=>e},matchesTypes:["Url","text/uri-list"]},[Xd]:{exposeProperties:{text:(e,t)=>Jd(e,t,""),dataTransfer:e=>e},matchesTypes:["Text","text/plain"]}};function ef(e){if(!e)return null;const t=Array.prototype.slice.call(e.types||[]);return Object.keys(Zd).filter(e=>{const n=Zd[e];return!!(null==n?void 0:n.matchesTypes)&&n.matchesTypes.some(e=>t.indexOf(e)>-1)})[0]||null}const tf=Hd(()=>/firefox/i.test(navigator.userAgent)),nf=Hd(()=>Boolean(window.safari));class rf{interpolate(e){const{xs:t,ys:n,c1s:r,c2s:o,c3s:a}=this;let i=t.length-1;if(e===t[i])return n[i];let l,s=0,u=a.length-1;for(;s<=u;){l=Math.floor(.5*(s+u));const r=t[l];if(re))return n[l];u=l-1}}i=Math.max(0,u);const c=e-t[i],d=c*c;return n[i]+r[i]*c+o[i]*d+a[i]*c*d}constructor(e,t){const{length:n}=e,r=[];for(let e=0;ee[t]{let e=new rf([0,.5,1],[u.y,u.y/d*m,u.y+m-d]).interpolate(p);return nf()&&a&&(e+=(window.devicePixelRatio-1)*m),e})()}}class sf{get window(){return this.globalContext?this.globalContext:"undefined"!=typeof window?window:void 0}get document(){var e;return(null===(e=this.globalContext)||void 0===e?void 0:e.document)?this.globalContext.document:this.window?this.window.document:void 0}get rootElement(){var e;return(null===(e=this.optionsArgs)||void 0===e?void 0:e.rootElement)||this.window}constructor(e,t){this.ownerDocument=null,this.globalContext=e,this.optionsArgs=t}}function uf(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cf(e){for(var t=1;t{this.sourcePreviewNodes.delete(e),this.sourcePreviewNodeOptions.delete(e)}}connectDragSource(e,t,n){this.sourceNodes.set(e,t),this.sourceNodeOptions.set(e,n);const r=t=>this.handleDragStart(t,e),o=e=>this.handleSelectStart(e);return t.setAttribute("draggable","true"),t.addEventListener("dragstart",r),t.addEventListener("selectstart",o),()=>{this.sourceNodes.delete(e),this.sourceNodeOptions.delete(e),t.removeEventListener("dragstart",r),t.removeEventListener("selectstart",o),t.setAttribute("draggable","false")}}connectDropTarget(e,t){const n=t=>this.handleDragEnter(t,e),r=t=>this.handleDragOver(t,e),o=t=>this.handleDrop(t,e);return t.addEventListener("dragenter",n),t.addEventListener("dragover",r),t.addEventListener("drop",o),()=>{t.removeEventListener("dragenter",n),t.removeEventListener("dragover",r),t.removeEventListener("drop",o)}}addEventListeners(e){e.addEventListener&&(e.addEventListener("dragstart",this.handleTopDragStart),e.addEventListener("dragstart",this.handleTopDragStartCapture,!0),e.addEventListener("dragend",this.handleTopDragEndCapture,!0),e.addEventListener("dragenter",this.handleTopDragEnter),e.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.addEventListener("dragover",this.handleTopDragOver),e.addEventListener("dragover",this.handleTopDragOverCapture,!0),e.addEventListener("drop",this.handleTopDrop),e.addEventListener("drop",this.handleTopDropCapture,!0))}removeEventListeners(e){e.removeEventListener&&(e.removeEventListener("dragstart",this.handleTopDragStart),e.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),e.removeEventListener("dragend",this.handleTopDragEndCapture,!0),e.removeEventListener("dragenter",this.handleTopDragEnter),e.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.removeEventListener("dragover",this.handleTopDragOver),e.removeEventListener("dragover",this.handleTopDragOverCapture,!0),e.removeEventListener("drop",this.handleTopDrop),e.removeEventListener("drop",this.handleTopDropCapture,!0))}getCurrentSourceNodeOptions(){const e=this.monitor.getSourceId(),t=this.sourceNodeOptions.get(e);return cf({dropEffect:this.altKeyPressed?"copy":"move"},t||{})}getCurrentDropEffect(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}getCurrentSourcePreviewNodeOptions(){const e=this.monitor.getSourceId();return cf({anchorX:.5,anchorY:.5,captureDraggingState:!1},this.sourcePreviewNodeOptions.get(e)||{})}isDraggingNativeItem(){const e=this.monitor.getItemType();return Object.keys(g).some(t=>g[t]===e)}beginDragNativeItem(e,t){this.clearCurrentDragSourceNode(),this.currentNativeSource=function(e,t){const n=Zd[e];if(!n)throw new Error(`native type ${e} has no configuration`);const r=new Wd(n);return r.loadDataTransfer(t),r}(e,t),this.currentNativeHandle=this.registry.addSource(e,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}setCurrentDragSourceNode(e){this.clearCurrentDragSourceNode(),this.currentDragSourceNode=e;this.mouseMoveTimeoutTimer=setTimeout(()=>{var e;return null===(e=this.rootElement)||void 0===e?void 0:e.addEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)},1e3)}clearCurrentDragSourceNode(){if(this.currentDragSourceNode){var e;if(this.currentDragSourceNode=null,this.rootElement)null===(e=this.window)||void 0===e||e.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0);return this.mouseMoveTimeoutTimer=null,!0}return!1}handleDragStart(e,t){e.defaultPrevented||(this.dragStartSourceIds||(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(t))}handleDragEnter(e,t){this.dragEnterTargetIds.unshift(t)}handleDragOver(e,t){null===this.dragOverTargetIds&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(t)}handleDrop(e,t){this.dropTargetIds.unshift(t)}constructor(e,t,n){this.sourcePreviewNodes=new Map,this.sourcePreviewNodeOptions=new Map,this.sourceNodes=new Map,this.sourceNodeOptions=new Map,this.dragStartSourceIds=null,this.dropTargetIds=[],this.dragEnterTargetIds=[],this.currentNativeSource=null,this.currentNativeHandle=null,this.currentDragSourceNode=null,this.altKeyPressed=!1,this.mouseMoveTimeoutTimer=null,this.asyncEndDragFrameId=null,this.dragOverTargetIds=null,this.lastClientOffset=null,this.hoverRafId=null,this.getSourceClientOffset=e=>{const t=this.sourceNodes.get(e);return t&&of(t)||null},this.endDragNativeItem=()=>{this.isDraggingNativeItem()&&(this.actions.endDrag(),this.currentNativeHandle&&this.registry.removeSource(this.currentNativeHandle),this.currentNativeHandle=null,this.currentNativeSource=null)},this.isNodeInDocument=e=>Boolean(e&&this.document&&this.document.body&&this.document.body.contains(e)),this.endDragIfSourceWasRemovedFromDOM=()=>{const e=this.currentDragSourceNode;null==e||this.isNodeInDocument(e)||(this.clearCurrentDragSourceNode()&&this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover())},this.scheduleHover=e=>{null===this.hoverRafId&&"undefined"!=typeof requestAnimationFrame&&(this.hoverRafId=requestAnimationFrame(()=>{this.monitor.isDragging()&&this.actions.hover(e||[],{clientOffset:this.lastClientOffset}),this.hoverRafId=null}))},this.cancelHover=()=>{null!==this.hoverRafId&&"undefined"!=typeof cancelAnimationFrame&&(cancelAnimationFrame(this.hoverRafId),this.hoverRafId=null)},this.handleTopDragStartCapture=()=>{this.clearCurrentDragSourceNode(),this.dragStartSourceIds=[]},this.handleTopDragStart=e=>{if(e.defaultPrevented)return;const{dragStartSourceIds:t}=this;this.dragStartSourceIds=null;const n=af(e);this.monitor.isDragging()&&(this.actions.endDrag(),this.cancelHover()),this.actions.beginDrag(t||[],{publishSource:!1,getSourceClientOffset:this.getSourceClientOffset,clientOffset:n});const{dataTransfer:r}=e,o=ef(r);if(this.monitor.isDragging()){if(r&&"function"==typeof r.setDragImage){const e=this.monitor.getSourceId(),t=this.sourceNodes.get(e),o=this.sourcePreviewNodes.get(e)||t;if(o){const{anchorX:e,anchorY:a,offsetX:i,offsetY:l}=this.getCurrentSourcePreviewNodeOptions(),s=lf(t,o,n,{anchorX:e,anchorY:a},{offsetX:i,offsetY:l});r.setDragImage(o,s.x,s.y)}}try{null==r||r.setData("application/json",{})}catch(e){}this.setCurrentDragSourceNode(e.target);const{captureDraggingState:t}=this.getCurrentSourcePreviewNodeOptions();t?this.actions.publishDragSource():setTimeout(()=>this.actions.publishDragSource(),0)}else if(o)this.beginDragNativeItem(o);else{if(r&&!r.types&&(e.target&&!e.target.hasAttribute||!e.target.hasAttribute("draggable")))return;e.preventDefault()}},this.handleTopDragEndCapture=()=>{this.clearCurrentDragSourceNode()&&this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover()},this.handleTopDragEnterCapture=e=>{var t;(this.dragEnterTargetIds=[],this.isDraggingNativeItem())&&(null===(t=this.currentNativeSource)||void 0===t||t.loadDataTransfer(e.dataTransfer));if(!this.enterLeaveCounter.enter(e.target)||this.monitor.isDragging())return;const{dataTransfer:n}=e,r=ef(n);r&&this.beginDragNativeItem(r,n)},this.handleTopDragEnter=e=>{const{dragEnterTargetIds:t}=this;if(this.dragEnterTargetIds=[],!this.monitor.isDragging())return;this.altKeyPressed=e.altKey,t.length>0&&this.actions.hover(t,{clientOffset:af(e)});t.some(e=>this.monitor.canDropOnTarget(e))&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=this.getCurrentDropEffect()))},this.handleTopDragOverCapture=e=>{var t;(this.dragOverTargetIds=[],this.isDraggingNativeItem())&&(null===(t=this.currentNativeSource)||void 0===t||t.loadDataTransfer(e.dataTransfer))},this.handleTopDragOver=e=>{const{dragOverTargetIds:t}=this;if(this.dragOverTargetIds=[],!this.monitor.isDragging())return e.preventDefault(),void(e.dataTransfer&&(e.dataTransfer.dropEffect="none"));this.altKeyPressed=e.altKey,this.lastClientOffset=af(e),this.scheduleHover(t);(t||[]).some(e=>this.monitor.canDropOnTarget(e))?(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=this.getCurrentDropEffect())):this.isDraggingNativeItem()?e.preventDefault():(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="none"))},this.handleTopDragLeaveCapture=e=>{this.isDraggingNativeItem()&&e.preventDefault();this.enterLeaveCounter.leave(e.target)&&(this.isDraggingNativeItem()&&setTimeout(()=>this.endDragNativeItem(),0),this.cancelHover())},this.handleTopDropCapture=e=>{var t;(this.dropTargetIds=[],this.isDraggingNativeItem())?(e.preventDefault(),null===(t=this.currentNativeSource)||void 0===t||t.loadDataTransfer(e.dataTransfer)):ef(e.dataTransfer)&&e.preventDefault();this.enterLeaveCounter.reset()},this.handleTopDrop=e=>{const{dropTargetIds:t}=this;this.dropTargetIds=[],this.actions.hover(t,{clientOffset:af(e)}),this.actions.drop({dropEffect:this.getCurrentDropEffect()}),this.isDraggingNativeItem()?this.endDragNativeItem():this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover()},this.handleSelectStart=e=>{const t=e.target;"function"==typeof t.dragDrop&&("INPUT"===t.tagName||"SELECT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable||(e.preventDefault(),t.dragDrop()))},this.options=new sf(t,n),this.actions=e.getActions(),this.monitor=e.getMonitor(),this.registry=e.getRegistry(),this.enterLeaveCounter=new Ud(this.isNodeInDocument)}}let ff;function pf(){return ff||(ff=new Image,ff.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),ff}const hf=function(e,t,n){return new df(e,t,n)};var mf;!function(e){e.mouse="mouse",e.touch="touch",e.keyboard="keyboard"}(mf||(mf={}));class gf{get delay(){var e;return null!==(e=this.args.delay)&&void 0!==e?e:0}get scrollAngleRanges(){return this.args.scrollAngleRanges}get getDropTargetElementsAtPoint(){return this.args.getDropTargetElementsAtPoint}get ignoreContextMenu(){var e;return null!==(e=this.args.ignoreContextMenu)&&void 0!==e&&e}get enableHoverOutsideTarget(){var e;return null!==(e=this.args.enableHoverOutsideTarget)&&void 0!==e&&e}get enableKeyboardEvents(){var e;return null!==(e=this.args.enableKeyboardEvents)&&void 0!==e&&e}get enableMouseEvents(){var e;return null!==(e=this.args.enableMouseEvents)&&void 0!==e&&e}get enableTouchEvents(){var e;return null===(e=this.args.enableTouchEvents)||void 0===e||e}get touchSlop(){return this.args.touchSlop||0}get delayTouchStart(){var e,t,n,r;return null!==(r=null!==(n=null===(e=this.args)||void 0===e?void 0:e.delayTouchStart)&&void 0!==n?n:null===(t=this.args)||void 0===t?void 0:t.delay)&&void 0!==r?r:0}get delayMouseStart(){var e,t,n,r;return null!==(r=null!==(n=null===(e=this.args)||void 0===e?void 0:e.delayMouseStart)&&void 0!==n?n:null===(t=this.args)||void 0===t?void 0:t.delay)&&void 0!==r?r:0}get window(){return this.context&&this.context.window?this.context.window:"undefined"!=typeof window?window:void 0}get document(){var e;return(null===(e=this.context)||void 0===e?void 0:e.document)?this.context.document:this.window?this.window.document:void 0}get rootElement(){var e;return(null===(e=this.args)||void 0===e?void 0:e.rootElement)||this.document}constructor(e,t){this.args=e,this.context=t}}const vf=1,bf=0;function yf(e){return void 0===e.button||e.button===bf}function wf(e){return!!e.targetTouches}function Sf(e,t){return wf(e)?function(e,t){return 1===e.targetTouches.length?Sf(e.targetTouches[0]):t&&1===e.touches.length&&e.touches[0].target===t.target?Sf(e.touches[0]):void 0}(e,t):{x:e.clientX,y:e.clientY}}const kf=(()=>{let e=!1;try{addEventListener("test",()=>{},Object.defineProperty({},"passive",{get:()=>(e=!0,!0)}))}catch(e){}return e})(),Ef={[mf.mouse]:{start:"mousedown",move:"mousemove",end:"mouseup",contextmenu:"contextmenu"},[mf.touch]:{start:"touchstart",move:"touchmove",end:"touchend"},[mf.keyboard]:{keydown:"keydown"}};class Of{profile(){var e;return{sourceNodes:this.sourceNodes.size,sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,targetNodes:this.targetNodes.size,dragOverTargetIds:(null===(e=this.dragOverTargetIds)||void 0===e?void 0:e.length)||0}}get document(){return this.options.document}setup(){const e=this.options.rootElement;e&&(cc(!Of.isSetUp,"Cannot have two Touch backends at the same time."),Of.isSetUp=!0,this.addEventListener(e,"start",this.getTopMoveStartHandler()),this.addEventListener(e,"start",this.handleTopMoveStartCapture,!0),this.addEventListener(e,"move",this.handleTopMove),this.addEventListener(e,"move",this.handleTopMoveCapture,!0),this.addEventListener(e,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.addEventListener(e,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.addEventListener(e,"keydown",this.handleCancelOnEscape,!0))}teardown(){const e=this.options.rootElement;e&&(Of.isSetUp=!1,this._mouseClientOffset={},this.removeEventListener(e,"start",this.handleTopMoveStartCapture,!0),this.removeEventListener(e,"start",this.handleTopMoveStart),this.removeEventListener(e,"move",this.handleTopMoveCapture,!0),this.removeEventListener(e,"move",this.handleTopMove),this.removeEventListener(e,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.removeEventListener(e,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.removeEventListener(e,"keydown",this.handleCancelOnEscape,!0),this.uninstallSourceNodeRemovalObserver())}addEventListener(e,t,n,r=!1){const o=kf?{capture:r,passive:!1}:r;this.listenerTypes.forEach(function(r){const a=Ef[r][t];a&&e.addEventListener(a,n,o)})}removeEventListener(e,t,n,r=!1){const o=kf?{capture:r,passive:!1}:r;this.listenerTypes.forEach(function(r){const a=Ef[r][t];a&&e.removeEventListener(a,n,o)})}connectDragSource(e,t){const n=this.handleMoveStart.bind(this,e);return this.sourceNodes.set(e,t),this.addEventListener(t,"start",n),()=>{this.sourceNodes.delete(e),this.removeEventListener(t,"start",n)}}connectDragPreview(e,t,n){return this.sourcePreviewNodeOptions.set(e,n),this.sourcePreviewNodes.set(e,t),()=>{this.sourcePreviewNodes.delete(e),this.sourcePreviewNodeOptions.delete(e)}}connectDropTarget(e,t){const n=this.options.rootElement;if(!this.document||!n)return()=>{};const r=r=>{if(!this.document||!n||!this.monitor.isDragging())return;let o;switch(r.type){case Ef.mouse.move:o={x:r.clientX,y:r.clientY};break;case Ef.touch.move:var a,i;o={x:(null===(a=r.touches[0])||void 0===a?void 0:a.clientX)||0,y:(null===(i=r.touches[0])||void 0===i?void 0:i.clientY)||0}}const l=null!=o?this.document.elementFromPoint(o.x,o.y):void 0,s=l&&t.contains(l);return l===t||s?this.handleMove(r,e):void 0};return this.addEventListener(this.document.body,"move",r),this.targetNodes.set(e,t),()=>{this.document&&(this.targetNodes.delete(e),this.removeEventListener(this.document.body,"move",r))}}getTopMoveStartHandler(){return this.options.delayTouchStart||this.options.delayMouseStart?this.handleTopMoveStartDelay:this.handleTopMoveStart}installSourceNodeRemovalObserver(e){this.uninstallSourceNodeRemovalObserver(),this.draggedSourceNode=e,this.draggedSourceNodeRemovalObserver=new MutationObserver(()=>{e&&!e.parentElement&&(this.resurrectSourceNode(),this.uninstallSourceNodeRemovalObserver())}),e&&e.parentElement&&this.draggedSourceNodeRemovalObserver.observe(e.parentElement,{childList:!0})}resurrectSourceNode(){this.document&&this.draggedSourceNode&&(this.draggedSourceNode.style.display="none",this.draggedSourceNode.removeAttribute("data-reactid"),this.document.body.appendChild(this.draggedSourceNode))}uninstallSourceNodeRemovalObserver(){this.draggedSourceNodeRemovalObserver&&this.draggedSourceNodeRemovalObserver.disconnect(),this.draggedSourceNodeRemovalObserver=void 0,this.draggedSourceNode=void 0}constructor(e,t,n){this.getSourceClientOffset=e=>{const t=this.sourceNodes.get(e);return t&&function(e){const t=1===e.nodeType?e:e.parentElement;if(!t)return;const{top:n,left:r}=t.getBoundingClientRect();return{x:r,y:n}}(t)},this.handleTopMoveStartCapture=e=>{yf(e)&&(this.moveStartSourceIds=[])},this.handleMoveStart=e=>{Array.isArray(this.moveStartSourceIds)&&this.moveStartSourceIds.unshift(e)},this.handleTopMoveStart=e=>{if(!yf(e))return;const t=Sf(e);t&&(wf(e)&&(this.lastTargetTouchFallback=e.targetTouches[0]),this._mouseClientOffset=t),this.waitingForDelay=!1},this.handleTopMoveStartDelay=e=>{if(!yf(e))return;const t=e.type===Ef.touch.start?this.options.delayTouchStart:this.options.delayMouseStart;this.timeout=setTimeout(this.handleTopMoveStart.bind(this,e),t),this.waitingForDelay=!0},this.handleTopMoveCapture=()=>{this.dragOverTargetIds=[]},this.handleMove=(e,t)=>{this.dragOverTargetIds&&this.dragOverTargetIds.unshift(t)},this.handleTopMove=e=>{if(this.timeout&&clearTimeout(this.timeout),!this.document||this.waitingForDelay)return;const{moveStartSourceIds:t,dragOverTargetIds:n}=this,r=this.options.enableHoverOutsideTarget,o=Sf(e,this.lastTargetTouchFallback);if(!o)return;if(this._isScrolling||!this.monitor.isDragging()&&function(e,t,n,r,o){if(!o)return!1;const a=180*Math.atan2(r-t,n-e)/Math.PI+180;for(let e=0;e=t.start)&&(null==t.end||a<=t.end))return!0}return!1}(this._mouseClientOffset.x||0,this._mouseClientOffset.y||0,o.x,o.y,this.options.scrollAngleRanges))return void(this._isScrolling=!0);var a,i,l,s;if(!this.monitor.isDragging()&&this._mouseClientOffset.hasOwnProperty("x")&&t&&(a=this._mouseClientOffset.x||0,i=this._mouseClientOffset.y||0,l=o.x,s=o.y,Math.sqrt(Math.pow(Math.abs(l-a),2)+Math.pow(Math.abs(s-i),2))>(this.options.touchSlop?this.options.touchSlop:0))&&(this.moveStartSourceIds=void 0,this.actions.beginDrag(t,{clientOffset:this._mouseClientOffset,getSourceClientOffset:this.getSourceClientOffset,publishSource:!1})),!this.monitor.isDragging())return;const u=this.sourceNodes.get(this.monitor.getSourceId());this.installSourceNodeRemovalObserver(u),this.actions.publishDragSource(),e.cancelable&&e.preventDefault();const c=(n||[]).map(e=>this.targetNodes.get(e)).filter(e=>!!e),d=this.options.getDropTargetElementsAtPoint?this.options.getDropTargetElementsAtPoint(o.x,o.y,c):this.document.elementsFromPoint(o.x,o.y),f=[];for(const e in d){if(!d.hasOwnProperty(e))continue;let t=d[e];for(null!=t&&f.push(t);t;)t=t.parentElement,t&&-1===f.indexOf(t)&&f.push(t)}const p=f.filter(e=>c.indexOf(e)>-1).map(e=>this._getDropTargetId(e)).filter(e=>!!e).filter((e,t,n)=>n.indexOf(e)===t);if(r)for(const e in this.targetNodes){const t=this.targetNodes.get(e);if(u&&t&&t.contains(u)&&-1===p.indexOf(e)){p.unshift(e);break}}p.reverse(),this.actions.hover(p,{clientOffset:o})},this._getDropTargetId=e=>{const t=this.targetNodes.keys();let n=t.next();for(;!1===n.done;){const r=n.value;if(e===this.targetNodes.get(r))return r;n=t.next()}},this.handleTopMoveEndCapture=e=>{this._isScrolling=!1,this.lastTargetTouchFallback=void 0,function(e){return void 0===e.buttons||0===(e.buttons&vf)}(e)&&(this.monitor.isDragging()&&!this.monitor.didDrop()?(e.cancelable&&e.preventDefault(),this._mouseClientOffset={},this.uninstallSourceNodeRemovalObserver(),this.actions.drop(),this.actions.endDrag()):this.moveStartSourceIds=void 0)},this.handleCancelOnEscape=e=>{"Escape"===e.key&&this.monitor.isDragging()&&(this._mouseClientOffset={},this.uninstallSourceNodeRemovalObserver(),this.actions.endDrag())},this.options=new gf(n,t),this.actions=e.getActions(),this.monitor=e.getMonitor(),this.sourceNodes=new Map,this.sourcePreviewNodes=new Map,this.sourcePreviewNodeOptions=new Map,this.targetNodes=new Map,this.listenerTypes=[],this._mouseClientOffset={},this._isScrolling=!1,this.options.enableMouseEvents&&this.listenerTypes.push(mf.mouse),this.options.enableTouchEvents&&this.listenerTypes.push(mf.touch),this.options.enableKeyboardEvents&&this.listenerTypes.push(mf.keyboard)}}const Nf=function(e,t={},n={}){return new Of(e,t,n)},Cf=(uu(),e=>l().createElement(ms,{context:qs,store:uu()},e.children)),Df=e=>l().createElement(Cf,null,l().createElement(xu,{props:e})),Af=e=>{const t=l().useId();return l().createElement("div",{className:"form-check form-check-inline"},l().createElement("input",{className:"form-check-input",type:"radio",id:t,value:e.name,checked:e.checked,disabled:e.disabled,onChange:t=>e.handleOnChange(t.target.value)}),l().createElement("label",{className:"form-check-label",htmlFor:t},e.label))},Tf=(e=>{const t=t=>{const n=Lu(e);return l().createElement(ku.Provider,{value:n},t.children)};return e=>l().createElement(t,null,l().createElement($u,e,e.children))})({controlClassnames:{actionElement:"btn btn-sm",addGroup:"btn-secondary",addRule:"btn-primary",cloneGroup:"btn-secondary",cloneRule:"btn-secondary",lockGroup:"btn-secondary",lockRule:"btn-secondary",removeGroup:"btn-danger",removeRule:"btn-danger",undoAction:"btn-secondary",redoAction:"btn-secondary",valueSelector:"form-select form-select-sm"},controlElements:{notToggle:({className:e,handleOnChange:t,title:n,label:r,checked:o,disabled:a})=>{const i=(0,l().useId)();return l().createElement("div",{className:`form-check-inline form-switch ${e}`},l().createElement("input",{id:i,className:"form-check-input",type:"checkbox",onChange:e=>t(e.target.checked),checked:!!o,disabled:a}),l().createElement("label",{title:n,htmlFor:i,className:"form-check-label"},r))},valueEditor:e=>{const{valueListItemClassName:t}=Tu(e);if("null"===e.operator||"notNull"===e.operator)return null;if(!("between"!==e.operator&&"notBetween"!==e.operator||"select"!==e.type&&"text"!==e.type)){const n="text"===e.type?"form-control form-control-sm":"form-select form-select-sm";return l().createElement(Au,{...e,skipHook:!0,schema:{...e.schema,classNames:{...e.schema.classNames,valueListItem:`${t} ${n}`}}})}switch(e.type){case"select":case"multiselect":return l().createElement(Au,{...e,skipHook:!0,className:`${e.className} form-select form-select-sm`});case"switch":return l().createElement("span",{className:`${e.className} custom-control custom-switch`},l().createElement("input",{type:"checkbox",className:"form-check-input custom-control-input",title:e.title,disabled:e.disabled,onChange:t=>e.handleOnChange(t.target.checked),checked:!!e.value}));case"checkbox":return l().createElement(Au,{...e,skipHook:!0,className:`${e.className} form-check-input`});case"radio":return l().createElement("span",{title:e.title,className:hn.value},e.values?.map(t=>l().createElement(Af,{key:t.name,name:t.name,disabled:e.disabled,checked:e.value===t.name,handleOnChange:e.handleOnChange,label:t.label})))}return l().createElement(Au,{...e,skipHook:!0,className:`${e.className} form-control form-control-sm`})}},translations:{removeGroup:{label:l().createElement("i",{className:"bi bi-x"})},removeRule:{label:l().createElement("i",{className:"bi bi-x"})},cloneRule:{label:l().createElement("i",{className:"bi bi-copy"})},cloneRuleGroup:{label:l().createElement("i",{className:"bi bi-copy"})},dragHandle:{label:l().createElement("i",{className:"bi bi-grip-vertical"})},lockGroup:{label:l().createElement("i",{className:"bi bi-unlock"})},lockRule:{label:l().createElement("i",{className:"bi bi-unlock"})},lockGroupDisabled:{label:l().createElement("i",{className:"bi bi-lock"})},lockRuleDisabled:{label:l().createElement("i",{className:"bi bi-lock"})},shiftActionUp:{label:l().createElement("i",{className:"bi bi-chevron-compact-up"})},shiftActionDown:{label:l().createElement("i",{className:"bi bi-chevron-compact-down"})},undo:{label:l().createElement("i",{className:"bi bi-arrow-counterclockwise"})},redo:{label:l().createElement("i",{className:"bi bi-arrow-clockwise"})}}}),$f=e=>"string"==typeof e?e.toLowerCase():e,Mf=(new RegExp(Me.source.replace(/^\^/,String.raw`^\s*`).replace(/\$$/,String.raw`\s*$`)),e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype),Rf=e=>Mf(e)&&Array.isArray(e.rules),xf=e=>Rf(e)&&"string"==typeof e.combinator,If=Object.keys;Object.entries;const Pf={"=":"!=","!=":"=","<":">=","<=":">",">":"<=",">=":"<",beginsWith:"doesNotBeginWith",doesNotBeginWith:"beginsWith",endsWith:"doesNotEndWith",doesNotEndWith:"endsWith",contains:"doesNotContain",doesNotContain:"contains",between:"notBetween",notBetween:"between",in:"notIn",notIn:"in",notNull:"null",null:"notNull"},_f=(e,t=",")=>e.map(e=>`${e??""}`.replaceAll(t[0],`\\${t[0]}`)).join(t),Lf=e=>Mf(e)&&"name"in e&&"string"==typeof e.name,Gf=e=>Mf(e)&&"value"in e&&"string"==typeof e.value;function Ff(e,t,n){if("string"==typeof e)return{...t,name:e,value:e,label:n?.[e]??e};const r={};let o=!!t;return Lf(e)&&!Gf(e)?(r.value=e.name,o=!0):!Lf(e)&&Gf(e)&&(r.name=e.value,o=!0),o?Object.assign({},t,e,r):e}function zf(e,t,n){if(!Array.isArray(e))return[];const r=e;return Bf(r)?r.map(e=>({...e,options:e.options.map(e=>Ff(e,t,n))})):r.map(e=>Ff(e,t,n))}const jf=e=>{const t=new Set,n=[];for(const r of e)t.has(r.value??r.name)||(t.add(r.value??r.name),n.push(r));return e.length===n.length?e:n},qf=e=>{let t=!1;if(Array.isArray(e))for(const n of e){if(!Lf(n)&&!Gf(n))return!1;t=!0}return t},Bf=(e,{allowEmpty:t=!1}={})=>{let n=!1;if(Array.isArray(e))for(const r of e){if(!(Mf(r)&&"options"in r&&(qf(r.options)||t&&Array.isArray(r.options)&&0===r.options.length)))return!1;n=!0}return n};const Vf=e=>jf((e=>Array.isArray(e)&&e.length>0&&Mf(e[0])&&"options"in e[0]&&Array.isArray(e[0].options))(e)?e.flatMap(e=>e.options):e);const Hf=e=>{if((e=>Rf(e)&&void 0===e.combinator)(e))return e;const{combinator:t,...n}=e,r=[],{length:o}=e.rules;for(let n=0;n{const r=Ff(e),o=Ff(n);return r.value!==o.value&&("string"==typeof r.comparator?r[r.comparator]===o[r.comparator]:r.comparator?.(o,t)?? -/* v8 ignore start -- @preserve */!1)},Wf=globalThis.crypto;let Qf=()=>"00-0-4-2-000".replaceAll(/[^-]/g,e=>(65536*(Math.random()+Math.trunc(e))>>Number.parseInt(e)).toString(16).padStart(4,"0"));if(Wf)if("function"==typeof Wf.randomUUID)Qf=()=>Wf.randomUUID();else if("function"==typeof Wf.getRandomValues){const e="89ab",t=new Uint32Array(32);Qf=()=>{Wf.getRandomValues(t);let n=(t[0]%16).toString(16);for(let r=1;r<32;r++)n=12===r?`${n}4`:16===r?`${n}${e[t[17]%4]}`:`${n}${(t[r]%16).toString(16)}`,7!==r&&11!==r&&15!==r&&19!==r||(n=`${n}-`);return n}}const Kf=[{name:"value",value:"value",label:"value"}],Xf={name:"name",value:"name",valueSources:null,label:"label"},Yf=(e,{idGenerator:t=Qf}={})=>{const n=!e.id,r=(e=>{const{mode:t,threshold:n}=e.match??{};if(!t)return null;if(!Rf(e.value))return!1;const r=$f(t),o="atleast"===r&&1===n?"some":"atmost"===r&&0===n?"none":r;return("atleast"!==o&&"atmost"!==o&&"exactly"!==o||!("number"!=typeof n||n<0))&&{mode:o,threshold:n}})(e);return n||r?{...e,...n&&{id:t()},...r&&{value:Jf(e.value,{idGenerator:t})}}:e},Jf=(e,{idGenerator:t=Qf}={})=>{const n=!e.id;let r=!1;const o=[];for(let n=0;n{const t=((e,t,n)=>{const r=e?Ff(e):Xf;let o=r.valueSources??!1;return"function"==typeof o&&(o=o(t)),!o&&n&&(o=n(r.value,t,{fieldData:r})),o?qf(o)?zf(o):o.map(e=>Kf.find(t=>t.value===$f(e))??{name:e,value:e,label:e}):Kf})(s,r,a);return qf(t)&&t.some(t=>t.value===e||t.name===e)};if(0===t.length)return!0;let l=!1;const s=Ff(t.find(e=>e.name===n));return s&&(l=!(!o&&"notNull"!==r&&"null"!==r&&!i("value")),l&&o&&(i("field")&&n!==o&&((e,t,n)=>{if(!e.comparator){const n=t=>(t.value??/* v8 ignore start -- @preserve */t.name)!==(e.value?? -/* v8 ignore start -- @preserve */e.name);return Bf(t)?t.map(e=>({...e,options:e.options.filter(e=>n(e))})):t.filter(e=>n(e))}return Bf(t)?t.map(t=>({...t,options:t.options.filter(t=>Uf(e,n,t))})).filter(e=>e.options.length>0):t.filter(t=>Uf(e,n,t))})(s,t,r).some(e=>e.name===o)||(l=!1))),l}const ep=e=>(e=>Mf(e)&&"var"in e)(e)&&"string"==typeof e.var,tp=e=>Mf(e)&&"=="in e,np=e=>Mf(e)&&"==="in e,rp=e=>Mf(e)&&"!="in e,op=e=>Mf(e)&&"!=="in e,ap=e=>Mf(e)&&">"in e,ip=e=>Mf(e)&&">="in e,lp=e=>Mf(e)&&"<"in e&&2===e["<"].length,sp=e=>Mf(e)&&"<="in e&&2===e["<="].length,up=e=>Mf(e)&&"in"in e&&!Array.isArray(e.in[1]),cp=e=>Mf(e)&&"none"in e,dp=e=>Mf(e)&&"some"in e,fp=e=>Mf(e)&&"<"in e&&Array.isArray(e["<"])&&3===e["<"].length,pp=e=>Mf(e)&&"startsWith"in e,hp=e=>Mf(e)&&"endsWith"in e,mp=e=>Mf(e)&&!ep(e),gp={combinator:"and",rules:[]};function vp(e,t={}){const n=(e=>{const t=e?Array.isArray(e)?e:Object.keys(e).map(t=>Object.assign({},e[t],{name:t})).sort((e,t)=>e.label.localeCompare(t.label)):[];return Vf(t)})(t.fields),{getValueSources:r,listsAsArrays:o,jsonLogicOperations:a,getExpression:i}=t,l=(e,t,o)=>Zf({fieldName:e,fieldsFlat:n,operator:t,subordinateFieldName:o,getValueSources:r}),s={fieldExists:e=>0===n.length||n.some(t=>t.name===e)};const u=t.generateIDs?Jf:e=>e;let c=e;if("string"==typeof e)try{c=JSON.parse(e)}catch{return u(gp)}const d=function e(t,n,r){if(n&&!Mf(t))return!1;const[u,c]=Object.entries(t||{})?.[0]??[];if(a&&If(a).includes(u)){const e=a[u](c);return!!e&&(n&&!Rf(e)?{combinator:"and",rules:[e]}:e)}if((e=>Mf(e)&&"and"in e)(t))return{combinator:"and",rules:t.and.map(t=>e(t,!1,r)).filter(Boolean)};if((e=>Mf(e)&&"or"in e)(t))return{combinator:"or",rules:t.or.map(t=>e(t,!1,r)).filter(Boolean)};if((e=>Mf(e)&&"!"in e)(t)){const o=e(t["!"],!1,r);if(o){if(!(xf(o)||"between"!==o.operator&&"in"!==o.operator&&"contains"!==o.operator&&"beginsWith"!==o.operator&&"endsWith"!==o.operator)){const e={...o,operator:Pf[o.operator]};return n?{combinator:"and",rules:[e]}:e}return fp(t["!"])||xf(o)?{...o,not:!0}:{combinator:"and",rules:[o],not:!0}}return!1}if((e=>Mf(e)&&"!!"in e)(t))return e(t["!!"],!1,r)||!1;let d,f=!1,p="",h="=",m="";if(tp(t)||np(t)||rp(t)||op(t)||ap(t)||ip(t)||lp(t)||sp(t)||up(t)||pp(t)||hp(t)){const[e,o]=c,a=tp(t)||np(t)||rp(t)||op(t)||ap(t)||ip(t)||lp(t)||sp(t),g=mp(e),v=mp(o);if(i&&a&&(g||v)){const a=tp(t)||np(t)?"=":rp(t)||op(t)?"!=":u;if(g&&v){const t=i(e,s),n=i(o,s);t&&n&&(f={field:"",operator:a,lhs:t,value:n,valueSource:"expression"})}else if(g&&!Mf(o)){const t=i(e,s);t&&(f={field:"",operator:a,lhs:t,value:o})}else if(ep(e)&&v){const t=i(o,s);t&&(r||l(e.var,a))&&(f={field:e.var,operator:a,value:t,valueSource:"expression"})}return!!f&&(n?{combinator:"and",rules:[f]}:f)}if(ep(e)&&!Mf(o))p=e.var,m=o;else if(!Mf(e)&&ep(o))p=o.var,m=e;else{if(!ep(e)||!ep(o))return!1;p=e.var,m=o.var,d="field"}h=tp(t)||np(t)?null===m?"null":"=":rp(t)||op(t)?null===m?"notNull":"!=":up(t)?"contains":pp(t)?"beginsWith":hp(t)?"endsWith":u,(r||l(p,h,"field"===d?m:void 0))&&(f={field:p,operator:h,value:m,valueSource:d})}else if((e=>Mf(e)&&"all"in e)(t)&&ep(t.all[0])||cp(t)&&ep(t.none[0])||dp(t)&&ep(t.some[0])){const n={mode:cp(t)?"none":dp(t)?"some":"all"},[{var:r},o]=t[n.mode],a=e(o,!1,!0);if(!a)return!1;f={field:r,operator:"=",match:n,value:Rf(a)?a:{combinator:"and",rules:[a]}}}else if(fp(t)&&ep(t["<"][1])){p=t["<"][1].var;const n=[t["<"][0],t["<"][2]];if(n.every(e=>ep(e))||n.every(e=>"string"==typeof e)||n.every(e=>"number"==typeof e)||n.every(e=>"boolean"==typeof e))return e({and:[{">":[{var:p},n[0]]},{"<":[{var:p},n[1]]}]})||/* v8 ignore start -- @preserve */!1}else if((e=>Mf(e)&&"<="in e&&Array.isArray(e["<="])&&3===e["<="].length)(t)&&ep(t["<="][1])){p=t["<="][1].var,h="between";const e=[t["<="][0],t["<="][2]];if(i&&(mp(e[0])||mp(e[1]))){const t=i(e[0],s),r=i(e[1],s);return t&&r&&l(p,h)&&(f={field:p,operator:h,value:[t,r],valueSource:"expression"}),!!f&&(n?{combinator:"and",rules:[f]}:f)}if(t["<="].every(e=>ep(e))){d="field";const t=e.map(e=>e.var).filter(e=>l(p,h,e));m=o?t:_f(t,",")}else(e.every(e=>"string"==typeof e)||e.every(e=>"number"==typeof e)||e.every(e=>"boolean"==typeof e))&&(m=o?e:_f(e.map(e=>`${e}`),","));l(p,h)&&m.length>=2&&(f={field:p,operator:h,value:m,valueSource:d})}else if((e=>Mf(e)&&"in"in e&&Array.isArray(e.in[1]))(t)&&ep(c[0])){if(p=c[0].var,h="in",t.in[1].every(e=>ep(e))){d="field";const e=t.in[1].map(e=>e.var).filter(e=>l(p,h,e));m=o?e:_f(e,",")}else(t.in[1].every(e=>"string"==typeof e)||t.in[1].every(e=>"number"==typeof e)||t.in[1].every(e=>"boolean"==typeof e))&&(m=o?t.in[1]:_f(t.in[1].map(e=>`${e}`),","));m.length>0&&(f={field:p,operator:h,value:m,valueSource:d})}return!!f&&(n?{combinator:"and",rules:[f]}:f)}(c,!0)||gp;return u(t.independentCombinators?Hf(d):d)}Promise.resolve().then(()=>n(236));const bp=["=","null","contains","doesNotContain","beginsWith","endsWith",">",">=","<","<=","in"],yp=class extends Oe{#e;#t=[];#n=[];#r={};#o={};#a=bp;#i=!1;#l="en";#s={en:{fields:{title:"Fields"},operators:{title:"Operators","=":"is equal to","!=":"is not equal to","<":"is less than",">":"is greater than","<=":"is less than or equal to",">=":"is greater than or equal to",between:"between",notBetween:"not between",contains:"contains",doesNotContain:"does not contain",beginsWith:"begins with",endsWith:"ends with",in:"in",notIn:"not in",null:"is empty",notNull:"is not empty",regex:"matches the regular expression",notRegex:"does not match the regular expression","<=ndays":"is less than or equal to N day(s)",">=ndays":"is greater than or equal to N day(s)",valuesList:"List of values"},value:{title:"Value"},addRule:{label:"+ Rule",title:"Add a rule"},removeRule:{label:"⨯",title:"Remove the rule"},addGroup:{label:"+ Group",title:"Add a group"},removeGroup:{label:"⨯",title:"Remove the group"},and:"AND",or:"OR",not:"NOT",validationError:"This rule is incomplete"},fr:{fields:{title:"Champs"},operators:{title:"Opérateurs","=":"est égal à","!=":"n'est pas égal à","<":"est inférieur à",">":"est supérieur à","<=":"est inférieur ou égal à",">=":"est supérieur ou égal à",between:"entre",notBetween:"n'est pas entre",contains:"contient",doesNotContain:"ne contient pas",beginsWith:"commence par",endsWith:"se termine par",in:"dans",notIn:"pas dans",null:"est vide",notNull:"n'est pas vide",regex:"correspond à l'expression régulière",notRegex:"ne correspond pas à l'expression régulière","<=ndays":"est inférieure ou égale à N jour(s)",">=ndays":"est supérieure ou égale à N jour(s)",valuesList:"Liste de valeurs"},value:{title:"Valeur"},addRule:{label:"+ Règle",title:"Ajouter une règle"},removeRule:{label:"⨯",title:"Supprimer la règle"},addGroup:{label:"+ Groupe",title:"Ajouter un groupe"},removeGroup:{label:"⨯",title:"Supprimer le groupe"},and:"ET",or:"OU",not:"NON",validationError:"Cette règle est incomplète"}};static values={conditions:Object,fields:Array,operators:Array,processor:String,lang:{type:String,default:"fr"}};static targets=["queryBuilder","input"];#u=null;#c=null;#d=null;connect(){const e=this.#f();this.#d=this.processorValue,this.#u=this.#p(),this.#h(e,this.#u)}disconnect(){this.#e?.unmount(),this.#e=null}fieldsValueChanged(){this.#m()}operatorsValueChanged(){this.#m()}langValueChanged(){this.#m()}processorValueChanged(){this.#e&&this.processorValue!==this.#d&&(this.#d=this.processorValue,this.#g(this.#u))}#m(){if(!this.#e||this.#v()===this.#c)return;const e=this.#f(),t=this.#b(this.#u,this.#y(e));this.#e.unmount(),this.#h(e,t),this.#g(t)}#v(){return JSON.stringify([this.fieldsValue,this.operatorsValue,this.langValue])}#f(){this.#w();const e=this.#S();return this.#c=this.#v(),e}#w(){this.#i=this.operatorsValue.length>0,this.#a=this.#i?this.operatorsValue:bp}#S(){this.#t=[],this.#n=[],this.#r={},this.#o={};const e=[];for(const t of this.fieldsValue)this.#k(t),e.push({name:t.name,label:this.#E(t),...this.#O(t),...this.#N(t)});return e.sort((e,t)=>e.label.localeCompare(t.label,this.langValue)),e}#y(e){const t=this.#C();return new Map(e.map(e=>[e.name,new Set(t(e.name,{fieldData:e}).map(e=>e.name))]))}#b(e,t){const n=[];for(const r of e.rules??[]){if(r&&Array.isArray(r.rules)){const e=this.#b(r,t);e.rules.length&&n.push(e);continue}if(!r||"object"!=typeof r||"~"===r.field){n.push(r);continue}const e=t.get(r.field);if(e){if("valuesList"===r.operator){const t=null!=r.value&&""!==r.value&&"~"!==r.value;!e.has("valuesList")||t&&!(this.#r[r.field]??[]).includes(r.value)?e.has("=")&&n.push({...r,operator:"=",value:t?r.value:""}):n.push(r);continue}("~"===r.operator||e.has(r.operator))&&n.push(r)}}return{...e,rules:n}}#h(e,n){const r=l().createElement(Df,{fields:e,onQueryChange:e=>this.#g(e),defaultQuery:n,combinators:this.#D(),getOperators:this.#C(),getValueEditorType:this.#A(),getInputType:this.#T(),translations:this.#$(),autoSelectField:!1,autoSelectValue:!1,listsAsArrays:!1,enableDragAndDrop:!0,enableMountQueryChange:!1,controlClassnames:{queryBuilder:"queryBuilder-branches"}});this.#e=(0,t().createRoot)(this.queryBuilderTarget),this.#e.render(l().createElement(ac,{dnd:{...h,...v,...b},children:[l().createElement(Tf,{},r)]}))}#g(e){if(this.#u=e,"native"===this.processorValue){const t=this.#M(e);return void this.#R(JSON.stringify(t.rules.length?t:{}))}let t=this.#x();const n=Za(e,{format:"jsonlogic",ruleProcessor:t});if("jsonLogic"===this.processorValue&&this.#R(JSON.stringify(!1===n?{}:n)),"parameterized"===this.processorValue){t=this.#I();const r=Za(e,{format:"parameterized",ruleProcessor:t});if(!1===n)return void this.#R(JSON.stringify({}));const o={conditionTree:n,parameterizedSql:r};this.#R(JSON.stringify(o))}}#R(e){this.inputTarget.value!==e&&(this.inputTarget.value=e,this.inputTarget.dispatchEvent(new Event("input",{bubbles:!0})),this.inputTarget.dispatchEvent(new Event("change",{bubbles:!0})))}#E(e){let t=e.label??e.name;return e.labelInformation&&(t+=`     (${e.labelInformation})`),t}#O(e){switch("date"===e.type&&this.#t.push(e.name),"number"===e.type&&this.#n.push(e.name),e.type){case"date":return this.#P();case"number":return this.#_();case"boolean":return this.#L();default:return this.#G()}}#G(){return{inputType:"text",datatype:"string"}}#P(){return{datatype:"date"}}#_(){return{inputType:"number",datatype:"number"}}#L(){return{inputType:"boolean",datatype:"boolean",valueEditorType:"checkbox",defaultValue:!1}}#N(e){if(!e.values?.length)return{};const t=e.values.map(e=>({name:e.value??e.name,label:e.label??e.name}));return this.#r[e.name]=t.map(e=>e.name),{values:t}}#k(e){e.operators?.length&&(this.#o[e.name]=e.operators)}#D(){return fn.map(e=>"and"===e.name?{...e,label:this.#F("and")}:"or"===e.name?{...e,label:this.#F("or")}:e)}#C(){return(e,{fieldData:t})=>{if(this.#o[e])return this.#z(this.#o[e],t);let n=dn.filter(e=>this.#a.includes(e.name));return n.sort((e,t)=>this.#a.indexOf(e.name)-this.#a.indexOf(t.name)),n=n.map(e=>({...e,label:this.#j(e.name,e.label)})),["number","date"].includes(t.datatype)||(n=n.filter(e=>![">",">=","<","<="].includes(e.name))),"string"!==t.datatype&&(n=n.filter(e=>!["contains","doesNotContain","beginsWith","endsWith","in"].includes(e.name))),"text"===t.inputType&&(this.#q("regex")&&n.push({name:"regex",label:this.#j("regex"),value:"regex"}),this.#q("notRegex")&&n.push({name:"notRegex",label:this.#j("notRegex"),value:"notRegex"})),"date"===t.datatype&&(this.#q("<=ndays")&&n.push({name:"<=ndays",label:this.#j("<=ndays"),value:"<=ndays"}),this.#q(">=ndays")&&n.push({name:">=ndays",label:this.#j(">=ndays"),value:">=ndays"})),e&&t.values?.length&&this.#q("valuesList")&&n.push({name:"valuesList",label:this.#j("valuesList"),value:"valuesList"}),this.#i&&n.sort((e,t)=>this.#a.indexOf(e.name)-this.#a.indexOf(t.name)),n}}#z(e,t){const n=[];for(const r of e){if("valuesList"===r&&!t.values?.length)continue;const e=dn.find(e=>e.name===r);n.push(e?{...e,label:this.#j(r,e.label)}:{name:r,label:this.#j(r),value:r})}return n}#q(e,t=null){return t&&this.#o[t]?this.#o[t].includes(e):!this.#i||this.#a.includes(e)}#j(e,t=null){return`${this.#F("operators")[e]||t||e}   ( ${e} )`}#A(){return(e,t)=>{switch(t){case"valuesList":return"select";case"in":case"notIn":return"textarea";default:return"text"}}}#T(){return(e,t,{fieldData:n})=>n.datatype&&"date"===n.datatype?["<=ndays",">=ndays"].includes(t)?"number":"date":n.inputType||"text"}#x(){return(e,t)=>{if("valuesList"===e.operator)return{"==":[{var:e.field},e.value]};if(["regex","notRegex"].includes(e.operator))return{[e.operator]:[{var:e.field},this.#B(e.value)]};if(["<=ndays",">=ndays"].includes(e.operator)){const t=isNaN(e.value)?"":e.value;return{[e.operator]:[{var:e.field},t]}}return this.#t.includes(e.field)&&(e={...e,value:this.#V(e)}),["in","notIn"].includes(e.operator)&&"string"==typeof e.value&&(e={...e,value:e.value.replaceAll(/\n/g,",")}),"null"===e.operator&&this.#n.includes(e.field)&&(e={...e,operator:"in",value:[null,0]}),"notNull"===e.operator&&this.#n.includes(e.field)?{notNull:[{var:e.field},[null,0]]}:xa(e,t)}}#V(e){const t=e=>/^\d{4}-\d{2}-\d{2}$/.test(e);if(["between","notBetween"].includes(e.operator)){const n=String(e.value).split(",");return 2===n.length&&n.every(t)?e.value:""}return t(e.value)?e.value:""}#I(){return(e,t)=>{if("null"===e.operator&&this.#n.includes(e.field))return{sql:"( "+e.field+" is null or "+e.field+" = ? )",params:[0]};if("notNull"===e.operator&&this.#n.includes(e.field))return{sql:"( "+e.field+" is not null and "+e.field+" <> ? )",params:[0]};if("null"===e.operator)return{sql:"( "+e.field+" is null )",operator:"",params:null};if("valuesList"===e.operator)return{sql:"( "+e.field+" = ? )",params:[e.value]};if("regex"===e.operator)return{sql:"( lower("+e.field+") regexp lower(?) )",params:[e.value]};if("notRegex"===e.operator)return{sql:"( lower("+e.field+") not regexp lower(?) )",params:[e.value]};if(["<=ndays",">=ndays"].includes(e.operator)&&(e={...e,field:"datediff( curdate(), "+e.field+" )",operator:e.operator.replace("ndays","")}),["in","notIn"].includes(e.operator)&&"string"==typeof e.value&&(e={...e,value:e.value.replaceAll(/\n/g,",")}),["contains","doesNotContain"].includes(e.operator)){const t="contains"===e.operator?"like":"not like";return{sql:"( "+e.field+" "+t+" ? )",params:[`%${e.value}%`]}}const n=qa(e,t);return n&&n.sql?{sql:"( "+n.sql+" )",params:n.params}:n}}#M(e){const t=[];for(const n of e.rules??[])if(n&&"object"==typeof n){if(Array.isArray(n.rules)){const e=this.#M(n);e.rules.length&&t.push(e);continue}"~"!==n.field&&"~"!==n.operator&&t.push(this.#H(n))}return{combinator:e.combinator,...e.not?{not:!0}:{},rules:t}}#H(e){if("valuesList"===e.operator)return{field:e.field,operator:"=",value:e.value};let t=e.value;return["<=ndays",">=ndays"].includes(e.operator)?t=isNaN(t)?"":t:this.#t.includes(e.field)&&(t=this.#V(e)),["in","notIn"].includes(e.operator)&&"string"==typeof t&&(t=t.replaceAll(/\n/g,",")),{field:e.field,operator:e.operator,value:t}}#p(){const e=e=>Array.isArray(e)&&2===e.length&&[null,0].every(t=>e.includes(t)),t=e=>e[1].var&&"string"==typeof e[0]?e[1].var:e[0].var,n=function(t){return t[1].var&&"string"==typeof t[0]?"contains":e(t[1])?"null":"in"},r=function(t){return t[1].var&&"string"==typeof t[0]?t[0]:e(t[1])?null:o(t[1])},o=e=>Array.isArray(e)?e.join("\n"):e,a=null!==this.conditionsValue&&"object"==typeof this.conditionsValue?this.conditionsValue:{},i="conditionTree"in a?a.conditionTree:a;return null!==i&&"object"==typeof i&&Array.isArray(i.rules)?this.#U(i):this.#U(vp(i,{jsonLogicOperations:{in:e=>({field:t(e),operator:n(e),value:r(e)}),notIn:e=>({field:e[0].var,operator:"notIn",value:o(e[1])}),notNull:e=>({field:e[0].var,operator:"notNull",value:""}),regex:e=>({field:e[0].var,operator:"regex",value:this.#W(e[1])}),notRegex:e=>({field:e[0].var,operator:"notRegex",value:this.#W(e[1])}),"<=ndays":e=>({field:e[0].var,operator:"<=ndays",value:e[1]}),">=ndays":e=>({field:e[0].var,operator:">=ndays",value:e[1]})}}))}#B(e){const t="string"==typeof e?e:String(e??"");if(/^\/(?:\\.|[^\\/])*\/[iums]*$/s.test(t))return t;return`/${t.replace(/\\.|\/|\\$/gs,e=>"/"===e?"\\/":"\\"===e?"\\\\":e)}/iu`}#W(e){if("string"!=typeof e)return e;const t=/^\/(.*)\/iu$/s.exec(e);return null===t?e:t[1].replace(/\\./gs,e=>"\\/"===e?"/":e)}#U(e){return e&&Array.isArray(e.rules)?{...e,rules:e.rules.map(e=>e&&Array.isArray(e.rules)?this.#U(e):e&&["in","notIn"].includes(e.operator)&&"string"==typeof e.value?{...e,value:e.value.replaceAll(",","\n")}:e&&"="===e.operator&&this.#q("valuesList",e.field)&&(this.#r[e.field]??[]).includes(e.value)?{...e,operator:"valuesList"}:e)}:e}#$(){return{...sn,...this.#Q(["fields","operators","value","addRule","removeRule","addGroup","removeGroup"])}}#Q(e=null){const t=this.#s[this.langValue]??this.#s[this.#l];if(!e)return t;let n={};return e.forEach(e=>{n[e]=t[e]||e}),n}#F(e){return this.#Q([e])[e]||e}};n.dn(yp);const wp={combinator:"and",rules:[]},Sp=["in","notIn","between","notBetween"],kp=["null","notNull"];function Ep(e){if(!e||"null"===e)return wp;try{const t=JSON.parse(e);return t&&"object"==typeof t&&Array.isArray(t.rules)?t:wp}catch{return wp}}function Op(e){return e&&Array.isArray(e.rules)?e.rules.reduce((e,t)=>e+(t&&Array.isArray(t.rules)?Op(t):t&&t.field?1:0),0):0}function Np(e,t,n){const r=document.createElement(e);return t&&(r.className=t),void 0!==n&&(r.textContent=n),r}function Cp(e,t,n){const r=Array.isArray(e?.values)?e.values:[],o=n.values||{};return function(e){const t=e.value;return Array.isArray(t)?t:Sp.includes(e.operator)&&"string"==typeof t?t.split(",").map(e=>e.trim()).filter(e=>""!==e):null==t?[]:[t]}(t).map(e=>{if(!0===e||"true"===e)return o.true||"true";if(!1===e||"false"===e)return o.false||"false";const t=r.find(t=>String(t.value??t.name)===String(e));return t?t.label??t.name:String(e)})}function Dp(e,t,n){const r=t.find(t=>t.name===e.field),o=(n.operators||{})[e.operator]||e.operator,a=n.values||{},i=Np("li","qb-summary-rule"),l=Np("span",r?"qb-summary-field":"qb-summary-field qb-summary-field-unknown",r?r.label:e.field);if(r||(l.title=a.unknownField||""),i.appendChild(l),i.appendChild(Np("span","qb-summary-operator",o)),kp.includes(e.operator))return i;const s=Cp(r,e,n).filter(e=>""!==e);if(0===s.length)return i.appendChild(Np("span","qb-summary-missing",a.missing||"")),i;const u="between"===e.operator||"notBetween"===e.operator,c=n.join||{};return s.forEach((e,t)=>{t>0&&i.appendChild(Np("span","qb-summary-join",u?c.and||"and":c.or||"or")),i.appendChild(Np("span","qb-summary-value",e))}),i}function Ap(e,t,n,r){const o=Array.isArray(e.rules)?e.rules:[],a="or"===e.combinator?"or":"and",i=Np("div",`qb-summary-group qb-summary-depth-${Math.min(r,3)}`),l=n.groups||{},s=n.combinators||{};if(o.length>1||r>0||e.not){const t=Np("div","qb-summary-heading");t.appendChild(Np("span",`qb-summary-combinator qb-summary-combinator-${a}`,s[a]||a.toUpperCase())),t.appendChild(Np("span","qb-summary-heading-text",l[e.not?`${a}Not`:a]||"")),i.appendChild(t)}const u=Np("ul","qb-summary-list");for(const e of o)if(e&&"object"==typeof e){if(Array.isArray(e.rules)){const o=Np("li","qb-summary-nested");o.appendChild(Ap(e,t,n,r+1)),u.appendChild(o);continue}e.field&&u.appendChild(Dp(e,t,n))}return i.appendChild(u),i}const Tp=class extends Oe{static targets=["context","contextHelp","hookChoice","hookCount","hookEmpty","counter","summary","summaryText","emptyHint"];static values={fieldsByContext:Object,labels:Object};connect(){this.editor=this.element.querySelector('[data-controller~="query-builder"]'),this.input=this.element.querySelector('[data-query-builder-target="input"]'),this.onInputChange=()=>this.refreshFeedback(),this.input?.addEventListener("change",this.onInputChange),this.previousContext=this.hasContextTarget?this.contextTarget.value:null,this.syncContextHelp(),this.refreshHooks(),this.refreshFeedback()}disconnect(){this.input?.removeEventListener("change",this.onInputChange)}changeContext(){const e=this.contextTarget.value,t=this.labelsValue.confirmContextChange;Op(this.currentQuery())>0&&t&&!window.confirm(t)?this.contextTarget.value=this.previousContext:(this.previousContext=e,this.editor&&(this.editor.dataset.queryBuilderFieldsValue=JSON.stringify(this.currentFields())),this.syncContextHelp(),this.refreshHooks(),this.refreshFeedback())}syncContextHelp(){if(!this.hasContextTarget||!this.hasContextHelpTarget)return;const e=this.contextTarget.options[this.contextTarget.selectedIndex];this.contextHelpTarget.textContent=e&&e.dataset.description||""}currentContext(){return this.hasContextTarget?this.contextTarget.value:Object.keys(this.fieldsByContextValue)[0]??null}currentFields(){return this.fieldsByContextValue[this.currentContext()]||[]}refreshHooks(){const e=this.currentContext(),t=[];for(const n of this.hookChoiceTargets){const r=n.dataset.context===e;n.hidden=!r;const o=n.querySelector('input[type="checkbox"]');o&&(r?t.push(o):o.checked=!1,n.classList.toggle("qb-hook-checked",r&&o.checked))}if(this.hasHookCountTarget){const e=t.filter(e=>e.checked).length;this.hookCountTarget.textContent=(this.labelsValue.hooks?.count||"%checked% / %total%").replace("%checked%",String(e)).replace("%total%",String(t.length))}this.hasHookEmptyTarget&&(this.hookEmptyTarget.hidden=t.length>0)}checkAllHooks(e){e.preventDefault(),this.setVisibleHooks(!0)}uncheckAllHooks(e){e.preventDefault(),this.setVisibleHooks(!1)}setVisibleHooks(e){for(const t of this.hookChoiceTargets){if(t.hidden)continue;const n=t.querySelector('input[type="checkbox"]');n&&(n.checked=e)}this.refreshHooks()}currentQuery(){return Ep(this.input?.value)}refreshFeedback(){const e=this.currentQuery(),t=Op(e),n=this.labelsValue;if(this.hasCounterTarget){const e=n.counter||{};this.counterTarget.textContent=0===t?e.none||"":1===t?e.one||"1":(e.many||"%count%").replace("%count%",String(t))}if(this.hasEmptyHintTarget&&this.emptyHintTarget.classList.toggle("qb-empty-hint-visible",0===t),this.hasSummaryTarget){this.summaryTarget.classList.toggle("qb-summary-visible",t>0);const r=this.hasSummaryTextTarget?this.summaryTextTarget:this.summaryTarget;r.replaceChildren(),t>0&&r.appendChild(Ap(e,this.currentFields(),n,0))}}};n.dn(Tp);const $p=class extends Oe{static targets=["code","displayParams","discountParams","cartDiscountParams","treeGroup"];static values={discountCode:String,cartDiscountCode:String};connect(){this.sync()}sync(){const e=this.codeTarget.value,t=e===this.discountCodeValue,n=e===this.cartDiscountCodeValue;this.displayParamsTarget.hidden=n,this.discountParamsTarget.hidden=!t,this.cartDiscountParamsTarget.hidden=!n,this.treeGroupTarget.hidden=n}};n.dn($p);const Mp=class extends Oe{static targets=["trigger"];static values={fields:Array,labels:Object,title:String,emptyHint:String};connect(){const e=window.bootstrap?.Popover;this.popovers=[];for(const t of this.triggerTargets){const n="tree"in t.dataset,r=Ep(t.dataset.tree),o=Rp(t.dataset.details),a=(!n||0===Op(r))&&0===o.length;t.classList.toggle("qb-action-summary-trigger-empty",a),e&&this.popovers.push(new e(t,{html:!0,sanitize:!1,title:this.titleValue,content:this.buildContent(n?r:null,o),trigger:"hover focus",placement:"right",container:"body",customClass:"qb-action-summary-popover"}))}}disconnect(){this.popovers.forEach(e=>e.dispose()),this.popovers=[]}buildContent(e,t){const n=document.createElement("div");if(n.className="qb-action-summary",null!==e)if(0===Op(e)){const e=document.createElement("p");e.className="qb-action-summary-empty mb-0",e.textContent=this.emptyHintValue,n.appendChild(e)}else n.appendChild(Ap(e,this.fieldsValue,this.labelsValue,0));if(t.length>0){const e=document.createElement("ul");e.className="qb-action-summary-details";for(const n of t){const t=document.createElement("li");t.textContent=n,e.appendChild(t)}n.appendChild(e)}return n}};function Rp(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>"string"==typeof e&&""!==e):[]}catch{return[]}}n.dn(Mp);const xp=class{constructor(e=document.documentElement,t=pe){this.logger=console,this.debug=!1,this.logDebugActivity=(e,t,n={})=>{this.debug&&this.logFormattedMessage(e,t,n)},this.element=e,this.schema=t,this.dispatcher=new w(this),this.router=new fe(this),this.actionDescriptorFilters=Object.assign({},S)}static start(e,t){const n=new this(e,t);return n.start(),n}async start(){await new Promise(e=>{"loading"==document.readyState?document.addEventListener("DOMContentLoaded",()=>e()):e()}),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(e,t){this.load({identifier:e,controllerConstructor:t})}registerActionOption(e,t){this.actionDescriptorFilters[e]=t}load(e,...t){(Array.isArray(e)?e:[e,...t]).forEach(e=>{e.controllerConstructor.shouldLoad&&this.router.loadDefinition(e)})}unload(e,...t){(Array.isArray(e)?e:[e,...t]).forEach(e=>this.router.unloadIdentifier(e))}get controllers(){return this.router.contexts.map(e=>e.controller)}getControllerForElementAndIdentifier(e,t){const n=this.router.getContextForElementAndIdentifier(e,t);return n?n.controller:null}handleError(e,t,n){var r;this.logger.error("%s\n\n%o\n\n%o",t,e,n),null===(r=window.onerror)||void 0===r||r.call(window,t,"",0,0,e)}logFormattedMessage(e,t,n={}){n=Object.assign({application:this},n),this.logger.groupCollapsed(`${e} #${t}`),this.logger.log("details:",Object.assign({},n)),this.logger.groupEnd()}}.start();xp.register("query-builder",yp),xp.register("qb-editor",Tp),xp.register("qb-action-form",$p),xp.register("qb-action-summary",Mp)})()})(); \ No newline at end of file +()=>null)));if(!o)if(e){let n;if(t&&(!a||a&&!bl()))n={...e,...t,...a,ReactDndBackend:t.HTML5Backend};else{if(!a)return;n={...e,...a,...t,ReactDndBackend:a.TouchBackend}}r(()=>El(n))}else 0})(),()=>{o=!0}},[t,e]),e?null:t},uc=(0,l().createContext)({dragDropManager:void 0});function cc(e,t,...n){if("undefined"!=typeof process&&void 0===t)throw new Error("invariant requires an error message argument");if(!e){let e;if(void 0===t)e=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{let r=0;e=new Error(t.replace(/%s/g,function(){return n[r++]})),e.name="Invariant Violation"}throw e.framesToPop=1,e}}function dc(e){return"object"==typeof e}u();const fc="dnd-core/INIT_COORDS",pc="dnd-core/BEGIN_DRAG",hc="dnd-core/PUBLISH_DRAG_SOURCE",mc="dnd-core/HOVER",gc="dnd-core/DROP",vc="dnd-core/END_DRAG";function bc(e,t){return{type:fc,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}const yc={type:fc,payload:{clientOffset:null,sourceClientOffset:null}};function wc(e){return function(t=[],n={publishSource:!0}){const{publishSource:r=!0,clientOffset:o,getSourceClientOffset:a}=n,i=e.getMonitor(),l=e.getRegistry();e.dispatch(bc(o)),function(e,t,n){cc(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach(function(e){cc(n.getSource(e),"Expected sourceIds to be registered.")})}(t,i,l);const s=function(e,t){let n=null;for(let r=e.length-1;r>=0;r--)if(t.canDragSource(e[r])){n=e[r];break}return n}(t,i);if(null==s)return void e.dispatch(yc);let u=null;if(o){if(!a)throw new Error("getSourceClientOffset must be defined");!function(e){cc("function"==typeof e,"When clientOffset is provided, getSourceClientOffset must be a function.")}(a),u=a(s)}e.dispatch(bc(o,u));const c=l.getSource(s).beginDrag(i,s);if(null==c)return;!function(e){cc(dc(e),"Item must be an object.")}(c),l.pinSource(s);const d=l.getSourceType(s);return{type:pc,payload:{itemType:d,item:c,sourceId:s,clientOffset:o||null,sourceClientOffset:u||null,isSourcePublic:!!r}}}}function Sc(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kc(e){for(var t=1;t{const i=function(e,t,n,r){const o=n.getTarget(e);let a=o?o.drop(r,e):void 0;(function(e){cc(void 0===e||dc(e),"Drop result must either be an object or undefined.")})(a),void 0===a&&(a=0===t?{}:r.getDropResult());return a}(o,a,r,n),l={type:gc,payload:{dropResult:kc({},t,i)}};e.dispatch(l)})}}function Oc(e){return function(){const t=e.getMonitor(),n=e.getRegistry();!function(e){cc(e.isDragging(),"Cannot call endDrag while not dragging.")}(t);const r=t.getSourceId();if(null!=r){n.getSource(r,!0).endDrag(t,r),n.unpinSource()}return{type:vc}}}function Nc(e,t){return null===t?null===e:Array.isArray(e)?e.some(e=>e===t):e===t}function Cc(e){return function(t,{clientOffset:n}={}){!function(e){cc(Array.isArray(e),"Expected targetIds to be an array.")}(t);const r=t.slice(0),o=e.getMonitor(),a=e.getRegistry();return function(e,t,n){for(let r=e.length-1;r>=0;r--){const o=e[r];Nc(t.getTargetType(o),n)||e.splice(r,1)}}(r,a,o.getItemType()),function(e,t,n){cc(t.isDragging(),"Cannot call hover while not dragging."),cc(!t.didDrop(),"Cannot call hover after drop.");for(let t=0;t{const a=n[o];var i;return r[o]=(i=a,(...n)=>{const r=i.apply(e,n);void 0!==r&&t(r)}),r},{})}dispatch(e){this.store.dispatch(e)}constructor(e,t){this.isSetUp=!1,this.handleRefCountChange=()=>{const e=this.store.getState().refCount>0;this.backend&&(e&&!this.isSetUp?(this.backend.setup(),this.isSetUp=!0):!e&&this.isSetUp&&(this.backend.teardown(),this.isSetUp=!1))},this.store=e,this.monitor=t,e.subscribe(this.handleRefCountChange)}}function Tc(e,t){return{x:e.x-t.x,y:e.y-t.y}}const $c=[],Mc=[];$c.__IS_NONE__=!0,Mc.__IS_ALL__=!0;class Rc{subscribeToStateChange(e,t={}){const{handlerIds:n}=t;cc("function"==typeof e,"listener must be a function."),cc(void 0===n||Array.isArray(n),"handlerIds, when specified, must be an array of strings.");let r=this.store.getState().stateId;return this.store.subscribe(()=>{const t=this.store.getState(),o=t.stateId;try{const a=o===r||o===r+1&&!function(e,t){return e!==$c&&(e===Mc||void 0===t||(n=e,t.filter(e=>n.indexOf(e)>-1)).length>0);var n}(t.dirtyHandlerIds,n);a||e()}finally{r=o}})}subscribeToOffsetChange(e){cc("function"==typeof e,"listener must be a function.");let t=this.store.getState().dragOffset;return this.store.subscribe(()=>{const n=this.store.getState().dragOffset;n!==t&&(t=n,e())})}canDragSource(e){if(!e)return!1;const t=this.registry.getSource(e);return cc(t,`Expected to find a valid source. sourceId=${e}`),!this.isDragging()&&t.canDrag(this,e)}canDropOnTarget(e){if(!e)return!1;const t=this.registry.getTarget(e);if(cc(t,`Expected to find a valid target. targetId=${e}`),!this.isDragging()||this.didDrop())return!1;return Nc(this.registry.getTargetType(e),this.getItemType())&&t.canDrop(this,e)}isDragging(){return Boolean(this.getItemType())}isDraggingSource(e){if(!e)return!1;const t=this.registry.getSource(e,!0);if(cc(t,`Expected to find a valid source. sourceId=${e}`),!this.isDragging()||!this.isSourcePublic())return!1;return this.registry.getSourceType(e)===this.getItemType()&&t.isDragging(this,e)}isOverTarget(e,t={shallow:!1}){if(!e)return!1;const{shallow:n}=t;if(!this.isDragging())return!1;const r=this.registry.getTargetType(e),o=this.getItemType();if(o&&!Nc(r,o))return!1;const a=this.getTargetIds();if(!a.length)return!1;const i=a.indexOf(e);return n?i===a.length-1:i>-1}getItemType(){return this.store.getState().dragOperation.itemType}getItem(){return this.store.getState().dragOperation.item}getSourceId(){return this.store.getState().dragOperation.sourceId}getTargetIds(){return this.store.getState().dragOperation.targetIds}getDropResult(){return this.store.getState().dragOperation.dropResult}didDrop(){return this.store.getState().dragOperation.didDrop}isSourcePublic(){return Boolean(this.store.getState().dragOperation.isSourcePublic)}getInitialClientOffset(){return this.store.getState().dragOffset.initialClientOffset}getInitialSourceClientOffset(){return this.store.getState().dragOffset.initialSourceClientOffset}getClientOffset(){return this.store.getState().dragOffset.clientOffset}getSourceClientOffset(){return function(e){const{clientOffset:t,initialClientOffset:n,initialSourceClientOffset:r}=e;return t&&n&&r?Tc((a=r,{x:(o=t).x+a.x,y:o.y+a.y}),n):null;var o,a}(this.store.getState().dragOffset)}getDifferenceFromInitialOffset(){return function(e){const{clientOffset:t,initialClientOffset:n}=e;return t&&n?Tc(t,n):null}(this.store.getState().dragOffset)}constructor(e,t){this.store=e,this.registry=t}}const xc=void 0!==n.g?n.g:self,Ic=xc.MutationObserver||xc.WebKitMutationObserver;function Pc(e){return function(){const t=setTimeout(r,0),n=setInterval(r,50);function r(){clearTimeout(t),clearInterval(n),e()}}}const _c="function"==typeof Ic?function(e){let t=1;const n=new Ic(e),r=document.createTextNode("");return n.observe(r,{characterData:!0}),function(){t=-t,r.data=t}}:Pc;class Lc{call(){try{this.task&&this.task()}catch(e){this.onError(e)}finally{this.task=null,this.release(this)}}constructor(e,t){this.onError=e,this.release=t,this.task=null}}const Gc=new class{enqueueTask(e){const{queue:t,requestFlush:n}=this;t.length||(n(),this.flushing=!0),t[t.length]=e}constructor(){this.queue=[],this.pendingErrors=[],this.flushing=!1,this.index=0,this.capacity=1024,this.flush=()=>{const{queue:e}=this;for(;this.indexthis.capacity){for(let t=0,n=e.length-this.index;t{this.pendingErrors.push(e),this.requestErrorThrow()},this.requestFlush=_c(this.flush),this.requestErrorThrow=Pc(()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()})}},Fc=new class{create(e){const t=this.freeTasks,n=t.length?t.pop():new Lc(this.onError,e=>t[t.length]=e);return n.task=e,n}constructor(e){this.onError=e,this.freeTasks=[]}}(Gc.registerPendingError);const zc="dnd-core/ADD_SOURCE",jc="dnd-core/ADD_TARGET",Vc="dnd-core/REMOVE_SOURCE",qc="dnd-core/REMOVE_TARGET";function Bc(e,t){t&&Array.isArray(e)?e.forEach(e=>Bc(e,!1)):cc("string"==typeof e||"symbol"==typeof e,t?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}var Hc;!function(e){e.SOURCE="SOURCE",e.TARGET="TARGET"}(Hc||(Hc={}));let Uc=0;function Wc(e){const t=(Uc++).toString();switch(e){case Hc.SOURCE:return`S${t}`;case Hc.TARGET:return`T${t}`;default:throw new Error(`Unknown Handler Role: ${e}`)}}function Qc(e){switch(e[0]){case"S":return Hc.SOURCE;case"T":return Hc.TARGET;default:throw new Error(`Cannot parse handler ID: ${e}`)}}function Kc(e,t){const n=e.entries();let r=!1;do{const{done:e,value:[,o]}=n.next();if(o===t)return!0;r=!!e}while(!r);return!1}class Xc{addSource(e,t){Bc(e),function(e){cc("function"==typeof e.canDrag,"Expected canDrag to be a function."),cc("function"==typeof e.beginDrag,"Expected beginDrag to be a function."),cc("function"==typeof e.endDrag,"Expected endDrag to be a function.")}(t);const n=this.addHandler(Hc.SOURCE,e,t);return this.store.dispatch(function(e){return{type:zc,payload:{sourceId:e}}}(n)),n}addTarget(e,t){Bc(e,!0),function(e){cc("function"==typeof e.canDrop,"Expected canDrop to be a function."),cc("function"==typeof e.hover,"Expected hover to be a function."),cc("function"==typeof e.drop,"Expected beginDrag to be a function.")}(t);const n=this.addHandler(Hc.TARGET,e,t);return this.store.dispatch(function(e){return{type:jc,payload:{targetId:e}}}(n)),n}containsHandler(e){return Kc(this.dragSources,e)||Kc(this.dropTargets,e)}getSource(e,t=!1){cc(this.isSourceId(e),"Expected a valid source ID.");return t&&e===this.pinnedSourceId?this.pinnedSource:this.dragSources.get(e)}getTarget(e){return cc(this.isTargetId(e),"Expected a valid target ID."),this.dropTargets.get(e)}getSourceType(e){return cc(this.isSourceId(e),"Expected a valid source ID."),this.types.get(e)}getTargetType(e){return cc(this.isTargetId(e),"Expected a valid target ID."),this.types.get(e)}isSourceId(e){return Qc(e)===Hc.SOURCE}isTargetId(e){return Qc(e)===Hc.TARGET}removeSource(e){var t;cc(this.getSource(e),"Expected an existing source."),this.store.dispatch(function(e){return{type:Vc,payload:{sourceId:e}}}(e)),t=()=>{this.dragSources.delete(e),this.types.delete(e)},Gc.enqueueTask(Fc.create(t))}removeTarget(e){cc(this.getTarget(e),"Expected an existing target."),this.store.dispatch(function(e){return{type:qc,payload:{targetId:e}}}(e)),this.dropTargets.delete(e),this.types.delete(e)}pinSource(e){const t=this.getSource(e);cc(t,"Expected an existing source."),this.pinnedSourceId=e,this.pinnedSource=t}unpinSource(){cc(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}addHandler(e,t,n){const r=Wc(e);return this.types.set(r,t),e===Hc.SOURCE?this.dragSources.set(r,n):e===Hc.TARGET&&this.dropTargets.set(r,n),r}constructor(e){this.types=new Map,this.dragSources=new Map,this.dropTargets=new Map,this.pinnedSourceId=null,this.pinnedSource=null,this.store=e}}const Yc=(e,t)=>e===t;function Jc(e=$c,t){switch(t.type){case mc:break;case zc:case jc:case qc:case Vc:return $c;default:return Mc}const{targetIds:n=[],prevTargetIds:r=[]}=t.payload,o=function(e,t){const n=new Map,r=e=>{n.set(e,n.has(e)?n.get(e)+1:1)};e.forEach(r),t.forEach(r);const o=[];return n.forEach((e,t)=>{1===e&&o.push(t)}),o}(n,r);if(!(o.length>0||!function(e,t,n=Yc){if(e.length!==t.length)return!1;for(let r=0;re!==o))});case gc:return rd({},e,{dropResult:n.dropResult,didDrop:!0,targetIds:[]});case vc:return rd({},e,{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return e}var r,o}function id(e=0,t){switch(t.type){case zc:case jc:return e+1;case Vc:case qc:return e-1;default:return e}}function ld(e=0){return e+1}function sd(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ud(e){for(var t=1;te&&e[t]?e[t]:o||null,n))})}),dragOffset:td(e.dragOffset,t),refCount:id(e.refCount,t),dragOperation:ad(e.dragOperation,t),stateId:ld(e.stateId)};var n,r,o}function dd(e,t=void 0,n={},r=!1){const o=function(e){const t="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__;return Tl(cd,e&&t&&t({name:"dnd-core",instanceId:"dnd-core"}))}(r),a=new Rc(o,new Xc(o)),i=new Ac(o,a),l=e(i,t,n);return i.receiveBackend(l),i}function fd(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}let pd=0;const hd=Symbol.for("__REACT_DND_CONTEXT_INSTANCE__");var md=(0,l().memo)(function(e){var{children:t}=e,n=fd(e,["children"]);const[r,o]=function(e){if("manager"in e){return[{dragDropManager:e.manager},!1]}const t=function(e,t=gd(),n,r){const o=t;o[hd]||(o[hd]={dragDropManager:dd(e,t,n,r)});return o[hd]}(e.backend,e.context,e.options,e.debugMode),n=!e.context;return[t,n]}(n);return(0,l().useEffect)(()=>{if(o){const e=gd();return++pd,()=>{0===--pd&&(e[hd]=null)}}},[]),(0,i().jsx)(uc.Provider,{value:r,children:t})});function gd(){return void 0!==n.g?n.g:window}const vd=(0,l().memo)(function({connect:e,src:t}){return(0,l().useEffect)(()=>{if("undefined"==typeof Image)return;let n=!1;const r=new Image;return r.src=t,r.onload=()=>{e(r),n=!0},()=>{n&&e(null)}}),null});e();const bd="undefined"!=typeof window?l().useLayoutEffect:l().useEffect;function yd(t,n,r){const[o,a]=(0,l().useState)(()=>n(t)),i=(0,l().useCallback)(()=>{const i=n(t);e()(o,i)||(a(i),r&&r())},[o,t,r]);return bd(i),[o,i]}function wd(e,t,n){return function(e,t,n){const[r,o]=yd(e,t,n);return bd(function(){const t=e.getHandlerId();if(null!=t)return e.subscribeToStateChange(o,{handlerIds:[t]})},[e,o]),r}(t,e||(()=>({})),()=>n.reconnect())}function Sd(e,t){const n=[...t||[]];return null==t&&"function"!=typeof e&&n.push(e),(0,l().useMemo)(()=>"function"==typeof e?e():e,n)}function kd(e){return(0,l().useMemo)(()=>e.hooks.dragSource(),[e])}function Ed(e){return(0,l().useMemo)(()=>e.hooks.dragPreview(),[e])}function Od(e,t,n,r){let o=n?n.call(r,e,t):void 0;if(void 0!==o)return!!o;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;const a=Object.keys(e),i=Object.keys(t);if(a.length!==i.length)return!1;const l=Object.prototype.hasOwnProperty.bind(t);for(let i=0;i{if(!(0,l().isValidElement)(t)){const r=t;return e(r,n),r}const r=t;!function(e){if("string"==typeof e.type)return;const t=e.type.displayName||e.type.name||"the component";throw new Error(`Only native element nodes can now be passed to React DnD connectors.You can either wrap ${t} into a
, or turn it into a drag source or a drop target itself.`)}(r);return function(e,t){const n=e.ref;return cc("string"!=typeof n,"Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a or
. Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs"),n?(0,l().cloneElement)(e,{ref:e=>{Ad(n,e),Ad(t,e)}}):(0,l().cloneElement)(e,{ref:t})}(r,n?t=>e(t,n):e)}}function Dd(e){const t={};return Object.keys(e).forEach(n=>{const r=e[n];if(n.endsWith("Ref"))t[n]=e[n];else{const e=Cd(r);t[n]=()=>e}}),t}function Ad(e,t){"function"==typeof e?e(t):e.current=t}class Td{receiveHandlerId(e){this.handlerId!==e&&(this.handlerId=e,this.reconnect())}get connectTarget(){return this.dragSource}get dragSourceOptions(){return this.dragSourceOptionsInternal}set dragSourceOptions(e){this.dragSourceOptionsInternal=e}get dragPreviewOptions(){return this.dragPreviewOptionsInternal}set dragPreviewOptions(e){this.dragPreviewOptionsInternal=e}reconnect(){const e=this.reconnectDragSource();this.reconnectDragPreview(e)}reconnectDragSource(){const e=this.dragSource,t=this.didHandlerIdChange()||this.didConnectedDragSourceChange()||this.didDragSourceOptionsChange();return t&&this.disconnectDragSource(),this.handlerId?e?(t&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragSource=e,this.lastConnectedDragSourceOptions=this.dragSourceOptions,this.dragSourceUnsubscribe=this.backend.connectDragSource(this.handlerId,e,this.dragSourceOptions)),t):(this.lastConnectedDragSource=e,t):t}reconnectDragPreview(e=!1){const t=this.dragPreview,n=e||this.didHandlerIdChange()||this.didConnectedDragPreviewChange()||this.didDragPreviewOptionsChange();n&&this.disconnectDragPreview(),this.handlerId&&(t?n&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragPreview=t,this.lastConnectedDragPreviewOptions=this.dragPreviewOptions,this.dragPreviewUnsubscribe=this.backend.connectDragPreview(this.handlerId,t,this.dragPreviewOptions)):this.lastConnectedDragPreview=t)}didHandlerIdChange(){return this.lastConnectedHandlerId!==this.handlerId}didConnectedDragSourceChange(){return this.lastConnectedDragSource!==this.dragSource}didConnectedDragPreviewChange(){return this.lastConnectedDragPreview!==this.dragPreview}didDragSourceOptionsChange(){return!Od(this.lastConnectedDragSourceOptions,this.dragSourceOptions)}didDragPreviewOptionsChange(){return!Od(this.lastConnectedDragPreviewOptions,this.dragPreviewOptions)}disconnectDragSource(){this.dragSourceUnsubscribe&&(this.dragSourceUnsubscribe(),this.dragSourceUnsubscribe=void 0)}disconnectDragPreview(){this.dragPreviewUnsubscribe&&(this.dragPreviewUnsubscribe(),this.dragPreviewUnsubscribe=void 0,this.dragPreviewNode=null,this.dragPreviewRef=null)}get dragSource(){return this.dragSourceNode||this.dragSourceRef&&this.dragSourceRef.current}get dragPreview(){return this.dragPreviewNode||this.dragPreviewRef&&this.dragPreviewRef.current}clearDragSource(){this.dragSourceNode=null,this.dragSourceRef=null}clearDragPreview(){this.dragPreviewNode=null,this.dragPreviewRef=null}constructor(e){this.hooks=Dd({dragSource:(e,t)=>{this.clearDragSource(),this.dragSourceOptions=t||null,Nd(e)?this.dragSourceRef=e:this.dragSourceNode=e,this.reconnectDragSource()},dragPreview:(e,t)=>{this.clearDragPreview(),this.dragPreviewOptions=t||null,Nd(e)?this.dragPreviewRef=e:this.dragPreviewNode=e,this.reconnectDragPreview()}}),this.handlerId=null,this.dragSourceRef=null,this.dragSourceOptionsInternal=null,this.dragPreviewRef=null,this.dragPreviewOptionsInternal=null,this.lastConnectedHandlerId=null,this.lastConnectedDragSource=null,this.lastConnectedDragSourceOptions=null,this.lastConnectedDragPreview=null,this.lastConnectedDragPreviewOptions=null,this.backend=e}}function $d(){const{dragDropManager:e}=(0,l().useContext)(uc);return cc(null!=e,"Expected drag drop context"),e}let Md=!1,Rd=!1;class xd{receiveHandlerId(e){this.sourceId=e}getHandlerId(){return this.sourceId}canDrag(){cc(!Md,"You may not call monitor.canDrag() inside your canDrag() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return Md=!0,this.internalMonitor.canDragSource(this.sourceId)}finally{Md=!1}}isDragging(){if(!this.sourceId)return!1;cc(!Rd,"You may not call monitor.isDragging() inside your isDragging() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return Rd=!0,this.internalMonitor.isDraggingSource(this.sourceId)}finally{Rd=!1}}subscribeToStateChange(e,t){return this.internalMonitor.subscribeToStateChange(e,t)}isDraggingSource(e){return this.internalMonitor.isDraggingSource(e)}isOverTarget(e,t){return this.internalMonitor.isOverTarget(e,t)}getTargetIds(){return this.internalMonitor.getTargetIds()}isSourcePublic(){return this.internalMonitor.isSourcePublic()}getSourceId(){return this.internalMonitor.getSourceId()}subscribeToOffsetChange(e){return this.internalMonitor.subscribeToOffsetChange(e)}canDragSource(e){return this.internalMonitor.canDragSource(e)}canDropOnTarget(e){return this.internalMonitor.canDropOnTarget(e)}getItemType(){return this.internalMonitor.getItemType()}getItem(){return this.internalMonitor.getItem()}getDropResult(){return this.internalMonitor.getDropResult()}didDrop(){return this.internalMonitor.didDrop()}getInitialClientOffset(){return this.internalMonitor.getInitialClientOffset()}getInitialSourceClientOffset(){return this.internalMonitor.getInitialSourceClientOffset()}getSourceClientOffset(){return this.internalMonitor.getSourceClientOffset()}getClientOffset(){return this.internalMonitor.getClientOffset()}getDifferenceFromInitialOffset(){return this.internalMonitor.getDifferenceFromInitialOffset()}constructor(e){this.sourceId=null,this.internalMonitor=e.getMonitor()}}class Id{beginDrag(){const e=this.spec,t=this.monitor;let n=null;return n="object"==typeof e.item?e.item:"function"==typeof e.item?e.item(t):{},null!=n?n:null}canDrag(){const e=this.spec,t=this.monitor;return"boolean"==typeof e.canDrag?e.canDrag:"function"!=typeof e.canDrag||e.canDrag(t)}isDragging(e,t){const n=this.spec,r=this.monitor,{isDragging:o}=n;return o?o(r):t===e.getSourceId()}endDrag(){const e=this.spec,t=this.monitor,n=this.connector,{end:r}=e;r&&r(t.getItem(),t),n.reconnect()}constructor(e,t,n){this.spec=e,this.monitor=t,this.connector=n}}function Pd(e,t,n){const r=$d(),o=function(e,t,n){const r=(0,l().useMemo)(()=>new Id(e,t,n),[t,n]);return(0,l().useEffect)(()=>{r.spec=e},[e]),r}(e,t,n),a=function(e){return(0,l().useMemo)(()=>{const t=e.type;return cc(null!=t,"spec.type must be defined"),t},[e])}(e);bd(function(){if(null!=a){const[e,i]=function(e,t,n){const r=n.getRegistry(),o=r.addSource(e,t);return[o,()=>r.removeSource(o)]}(a,o,r);return t.receiveHandlerId(e),n.receiveHandlerId(e),i}},[r,t,n,o,a])}function _d(e,t){const n=Sd(e,t);cc(!n.begin,"useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)");const r=function(){const e=$d();return(0,l().useMemo)(()=>new xd(e),[e])}(),o=function(e,t){const n=$d(),r=(0,l().useMemo)(()=>new Td(n.getBackend()),[n]);return bd(()=>(r.dragSourceOptions=e||null,r.reconnect(),()=>r.disconnectDragSource()),[r,e]),bd(()=>(r.dragPreviewOptions=t||null,r.reconnect(),()=>r.disconnectDragPreview()),[r,t]),r}(n.options,n.previewOptions);return Pd(n,r,o),[wd(n.collect,r,o),kd(o),Ed(o)]}function Ld(e){const t=$d().getMonitor(),[n,r]=yd(t,e);return(0,l().useEffect)(()=>t.subscribeToOffsetChange(r)),(0,l().useEffect)(()=>t.subscribeToStateChange(r)),n}function Gd(e){return(0,l().useMemo)(()=>e.hooks.dropTarget(),[e])}class Fd{get connectTarget(){return this.dropTarget}reconnect(){const e=this.didHandlerIdChange()||this.didDropTargetChange()||this.didOptionsChange();e&&this.disconnectDropTarget();const t=this.dropTarget;this.handlerId&&(t?e&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDropTarget=t,this.lastConnectedDropTargetOptions=this.dropTargetOptions,this.unsubscribeDropTarget=this.backend.connectDropTarget(this.handlerId,t,this.dropTargetOptions)):this.lastConnectedDropTarget=t)}receiveHandlerId(e){e!==this.handlerId&&(this.handlerId=e,this.reconnect())}get dropTargetOptions(){return this.dropTargetOptionsInternal}set dropTargetOptions(e){this.dropTargetOptionsInternal=e}didHandlerIdChange(){return this.lastConnectedHandlerId!==this.handlerId}didDropTargetChange(){return this.lastConnectedDropTarget!==this.dropTarget}didOptionsChange(){return!Od(this.lastConnectedDropTargetOptions,this.dropTargetOptions)}disconnectDropTarget(){this.unsubscribeDropTarget&&(this.unsubscribeDropTarget(),this.unsubscribeDropTarget=void 0)}get dropTarget(){return this.dropTargetNode||this.dropTargetRef&&this.dropTargetRef.current}clearDropTarget(){this.dropTargetRef=null,this.dropTargetNode=null}constructor(e){this.hooks=Dd({dropTarget:(e,t)=>{this.clearDropTarget(),this.dropTargetOptions=t,Nd(e)?this.dropTargetRef=e:this.dropTargetNode=e,this.reconnect()}}),this.handlerId=null,this.dropTargetRef=null,this.dropTargetOptionsInternal=null,this.lastConnectedHandlerId=null,this.lastConnectedDropTarget=null,this.lastConnectedDropTargetOptions=null,this.backend=e}}let zd=!1;class jd{receiveHandlerId(e){this.targetId=e}getHandlerId(){return this.targetId}subscribeToStateChange(e,t){return this.internalMonitor.subscribeToStateChange(e,t)}canDrop(){if(!this.targetId)return!1;cc(!zd,"You may not call monitor.canDrop() inside your canDrop() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor");try{return zd=!0,this.internalMonitor.canDropOnTarget(this.targetId)}finally{zd=!1}}isOver(e){return!!this.targetId&&this.internalMonitor.isOverTarget(this.targetId,e)}getItemType(){return this.internalMonitor.getItemType()}getItem(){return this.internalMonitor.getItem()}getDropResult(){return this.internalMonitor.getDropResult()}didDrop(){return this.internalMonitor.didDrop()}getInitialClientOffset(){return this.internalMonitor.getInitialClientOffset()}getInitialSourceClientOffset(){return this.internalMonitor.getInitialSourceClientOffset()}getSourceClientOffset(){return this.internalMonitor.getSourceClientOffset()}getClientOffset(){return this.internalMonitor.getClientOffset()}getDifferenceFromInitialOffset(){return this.internalMonitor.getDifferenceFromInitialOffset()}constructor(e){this.targetId=null,this.internalMonitor=e.getMonitor()}}class Vd{canDrop(){const e=this.spec,t=this.monitor;return!e.canDrop||e.canDrop(t.getItem(),t)}hover(){const e=this.spec,t=this.monitor;e.hover&&e.hover(t.getItem(),t)}drop(){const e=this.spec,t=this.monitor;if(e.drop)return e.drop(t.getItem(),t)}constructor(e,t){this.spec=e,this.monitor=t}}function qd(e,t,n){const r=$d(),o=function(e,t){const n=(0,l().useMemo)(()=>new Vd(e,t),[t]);return(0,l().useEffect)(()=>{n.spec=e},[e]),n}(e,t),a=function(e){const{accept:t}=e;return(0,l().useMemo)(()=>(cc(null!=e.accept,"accept must be defined"),Array.isArray(t)?t:[t]),[t])}(e);bd(function(){const[e,i]=function(e,t,n){const r=n.getRegistry(),o=r.addTarget(e,t);return[o,()=>r.removeTarget(o)]}(a,o,r);return t.receiveHandlerId(e),n.receiveHandlerId(e),i},[r,t,o,n,a.map(e=>e.toString()).join("|")])}function Bd(e,t){const n=Sd(e,t),r=function(){const e=$d();return(0,l().useMemo)(()=>new jd(e),[e])}(),o=function(e){const t=$d(),n=(0,l().useMemo)(()=>new Fd(t.getBackend()),[t]);return bd(()=>(n.dropTargetOptions=e||null,n.reconnect(),()=>n.disconnectDropTarget()),[e]),n}(n.options);return qd(n,r,o),[wd(n.collect,r,o),Gd(o)]}function Hd(e){let t=null;return()=>(null==t&&(t=e()),t)}class Ud{enter(e){const t=this.entered.length;return this.entered=function(e,t){const n=new Set,r=e=>n.add(e);e.forEach(r),t.forEach(r);const o=[];return n.forEach(e=>o.push(e)),o}(this.entered.filter(t=>this.isNodeInDocument(t)&&(!t.contains||t.contains(e))),[e]),0===t&&this.entered.length>0}leave(e){const t=this.entered.length;var n,r;return this.entered=(n=this.entered.filter(this.isNodeInDocument),r=e,n.filter(e=>e!==r)),t>0&&0===this.entered.length}reset(){this.entered=[]}constructor(e){this.entered=[],this.isNodeInDocument=e}}class Wd{initializeExposedProperties(){Object.keys(this.config.exposeProperties).forEach(e=>{Object.defineProperty(this.item,e,{configurable:!0,enumerable:!0,get:()=>(console.warn(`Browser doesn't allow reading "${e}" until the drop event.`),null)})})}loadDataTransfer(e){if(e){const t={};Object.keys(this.config.exposeProperties).forEach(n=>{const r=this.config.exposeProperties[n];null!=r&&(t[n]={value:r(e,this.config.matchesTypes),configurable:!0,enumerable:!0})}),Object.defineProperties(this.item,t)}}canDrag(){return!0}beginDrag(){return this.item}isDragging(e,t){return t===e.getSourceId()}endDrag(){}constructor(e){this.config=e,this.item={},this.initializeExposedProperties()}}const Qd="__NATIVE_FILE__",Kd="__NATIVE_URL__",Xd="__NATIVE_TEXT__",Yd="__NATIVE_HTML__";function Jd(e,t,n){const r=t.reduce((t,n)=>t||e.getData(n),"");return null!=r?r:n}const Zd={[Qd]:{exposeProperties:{files:e=>Array.prototype.slice.call(e.files),items:e=>e.items,dataTransfer:e=>e},matchesTypes:["Files"]},[Yd]:{exposeProperties:{html:(e,t)=>Jd(e,t,""),dataTransfer:e=>e},matchesTypes:["Html","text/html"]},[Kd]:{exposeProperties:{urls:(e,t)=>Jd(e,t,"").split("\n"),dataTransfer:e=>e},matchesTypes:["Url","text/uri-list"]},[Xd]:{exposeProperties:{text:(e,t)=>Jd(e,t,""),dataTransfer:e=>e},matchesTypes:["Text","text/plain"]}};function ef(e){if(!e)return null;const t=Array.prototype.slice.call(e.types||[]);return Object.keys(Zd).filter(e=>{const n=Zd[e];return!!(null==n?void 0:n.matchesTypes)&&n.matchesTypes.some(e=>t.indexOf(e)>-1)})[0]||null}const tf=Hd(()=>/firefox/i.test(navigator.userAgent)),nf=Hd(()=>Boolean(window.safari));class rf{interpolate(e){const{xs:t,ys:n,c1s:r,c2s:o,c3s:a}=this;let i=t.length-1;if(e===t[i])return n[i];let l,s=0,u=a.length-1;for(;s<=u;){l=Math.floor(.5*(s+u));const r=t[l];if(re))return n[l];u=l-1}}i=Math.max(0,u);const c=e-t[i],d=c*c;return n[i]+r[i]*c+o[i]*d+a[i]*c*d}constructor(e,t){const{length:n}=e,r=[];for(let e=0;ee[t]{let e=new rf([0,.5,1],[u.y,u.y/d*m,u.y+m-d]).interpolate(p);return nf()&&a&&(e+=(window.devicePixelRatio-1)*m),e})()}}class sf{get window(){return this.globalContext?this.globalContext:"undefined"!=typeof window?window:void 0}get document(){var e;return(null===(e=this.globalContext)||void 0===e?void 0:e.document)?this.globalContext.document:this.window?this.window.document:void 0}get rootElement(){var e;return(null===(e=this.optionsArgs)||void 0===e?void 0:e.rootElement)||this.window}constructor(e,t){this.ownerDocument=null,this.globalContext=e,this.optionsArgs=t}}function uf(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cf(e){for(var t=1;t{this.sourcePreviewNodes.delete(e),this.sourcePreviewNodeOptions.delete(e)}}connectDragSource(e,t,n){this.sourceNodes.set(e,t),this.sourceNodeOptions.set(e,n);const r=t=>this.handleDragStart(t,e),o=e=>this.handleSelectStart(e);return t.setAttribute("draggable","true"),t.addEventListener("dragstart",r),t.addEventListener("selectstart",o),()=>{this.sourceNodes.delete(e),this.sourceNodeOptions.delete(e),t.removeEventListener("dragstart",r),t.removeEventListener("selectstart",o),t.setAttribute("draggable","false")}}connectDropTarget(e,t){const n=t=>this.handleDragEnter(t,e),r=t=>this.handleDragOver(t,e),o=t=>this.handleDrop(t,e);return t.addEventListener("dragenter",n),t.addEventListener("dragover",r),t.addEventListener("drop",o),()=>{t.removeEventListener("dragenter",n),t.removeEventListener("dragover",r),t.removeEventListener("drop",o)}}addEventListeners(e){e.addEventListener&&(e.addEventListener("dragstart",this.handleTopDragStart),e.addEventListener("dragstart",this.handleTopDragStartCapture,!0),e.addEventListener("dragend",this.handleTopDragEndCapture,!0),e.addEventListener("dragenter",this.handleTopDragEnter),e.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.addEventListener("dragover",this.handleTopDragOver),e.addEventListener("dragover",this.handleTopDragOverCapture,!0),e.addEventListener("drop",this.handleTopDrop),e.addEventListener("drop",this.handleTopDropCapture,!0))}removeEventListeners(e){e.removeEventListener&&(e.removeEventListener("dragstart",this.handleTopDragStart),e.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),e.removeEventListener("dragend",this.handleTopDragEndCapture,!0),e.removeEventListener("dragenter",this.handleTopDragEnter),e.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.removeEventListener("dragover",this.handleTopDragOver),e.removeEventListener("dragover",this.handleTopDragOverCapture,!0),e.removeEventListener("drop",this.handleTopDrop),e.removeEventListener("drop",this.handleTopDropCapture,!0))}getCurrentSourceNodeOptions(){const e=this.monitor.getSourceId(),t=this.sourceNodeOptions.get(e);return cf({dropEffect:this.altKeyPressed?"copy":"move"},t||{})}getCurrentDropEffect(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}getCurrentSourcePreviewNodeOptions(){const e=this.monitor.getSourceId();return cf({anchorX:.5,anchorY:.5,captureDraggingState:!1},this.sourcePreviewNodeOptions.get(e)||{})}isDraggingNativeItem(){const e=this.monitor.getItemType();return Object.keys(g).some(t=>g[t]===e)}beginDragNativeItem(e,t){this.clearCurrentDragSourceNode(),this.currentNativeSource=function(e,t){const n=Zd[e];if(!n)throw new Error(`native type ${e} has no configuration`);const r=new Wd(n);return r.loadDataTransfer(t),r}(e,t),this.currentNativeHandle=this.registry.addSource(e,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}setCurrentDragSourceNode(e){this.clearCurrentDragSourceNode(),this.currentDragSourceNode=e;this.mouseMoveTimeoutTimer=setTimeout(()=>{var e;return null===(e=this.rootElement)||void 0===e?void 0:e.addEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)},1e3)}clearCurrentDragSourceNode(){if(this.currentDragSourceNode){var e;if(this.currentDragSourceNode=null,this.rootElement)null===(e=this.window)||void 0===e||e.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0);return this.mouseMoveTimeoutTimer=null,!0}return!1}handleDragStart(e,t){e.defaultPrevented||(this.dragStartSourceIds||(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(t))}handleDragEnter(e,t){this.dragEnterTargetIds.unshift(t)}handleDragOver(e,t){null===this.dragOverTargetIds&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(t)}handleDrop(e,t){this.dropTargetIds.unshift(t)}constructor(e,t,n){this.sourcePreviewNodes=new Map,this.sourcePreviewNodeOptions=new Map,this.sourceNodes=new Map,this.sourceNodeOptions=new Map,this.dragStartSourceIds=null,this.dropTargetIds=[],this.dragEnterTargetIds=[],this.currentNativeSource=null,this.currentNativeHandle=null,this.currentDragSourceNode=null,this.altKeyPressed=!1,this.mouseMoveTimeoutTimer=null,this.asyncEndDragFrameId=null,this.dragOverTargetIds=null,this.lastClientOffset=null,this.hoverRafId=null,this.getSourceClientOffset=e=>{const t=this.sourceNodes.get(e);return t&&of(t)||null},this.endDragNativeItem=()=>{this.isDraggingNativeItem()&&(this.actions.endDrag(),this.currentNativeHandle&&this.registry.removeSource(this.currentNativeHandle),this.currentNativeHandle=null,this.currentNativeSource=null)},this.isNodeInDocument=e=>Boolean(e&&this.document&&this.document.body&&this.document.body.contains(e)),this.endDragIfSourceWasRemovedFromDOM=()=>{const e=this.currentDragSourceNode;null==e||this.isNodeInDocument(e)||(this.clearCurrentDragSourceNode()&&this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover())},this.scheduleHover=e=>{null===this.hoverRafId&&"undefined"!=typeof requestAnimationFrame&&(this.hoverRafId=requestAnimationFrame(()=>{this.monitor.isDragging()&&this.actions.hover(e||[],{clientOffset:this.lastClientOffset}),this.hoverRafId=null}))},this.cancelHover=()=>{null!==this.hoverRafId&&"undefined"!=typeof cancelAnimationFrame&&(cancelAnimationFrame(this.hoverRafId),this.hoverRafId=null)},this.handleTopDragStartCapture=()=>{this.clearCurrentDragSourceNode(),this.dragStartSourceIds=[]},this.handleTopDragStart=e=>{if(e.defaultPrevented)return;const{dragStartSourceIds:t}=this;this.dragStartSourceIds=null;const n=af(e);this.monitor.isDragging()&&(this.actions.endDrag(),this.cancelHover()),this.actions.beginDrag(t||[],{publishSource:!1,getSourceClientOffset:this.getSourceClientOffset,clientOffset:n});const{dataTransfer:r}=e,o=ef(r);if(this.monitor.isDragging()){if(r&&"function"==typeof r.setDragImage){const e=this.monitor.getSourceId(),t=this.sourceNodes.get(e),o=this.sourcePreviewNodes.get(e)||t;if(o){const{anchorX:e,anchorY:a,offsetX:i,offsetY:l}=this.getCurrentSourcePreviewNodeOptions(),s=lf(t,o,n,{anchorX:e,anchorY:a},{offsetX:i,offsetY:l});r.setDragImage(o,s.x,s.y)}}try{null==r||r.setData("application/json",{})}catch(e){}this.setCurrentDragSourceNode(e.target);const{captureDraggingState:t}=this.getCurrentSourcePreviewNodeOptions();t?this.actions.publishDragSource():setTimeout(()=>this.actions.publishDragSource(),0)}else if(o)this.beginDragNativeItem(o);else{if(r&&!r.types&&(e.target&&!e.target.hasAttribute||!e.target.hasAttribute("draggable")))return;e.preventDefault()}},this.handleTopDragEndCapture=()=>{this.clearCurrentDragSourceNode()&&this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover()},this.handleTopDragEnterCapture=e=>{var t;(this.dragEnterTargetIds=[],this.isDraggingNativeItem())&&(null===(t=this.currentNativeSource)||void 0===t||t.loadDataTransfer(e.dataTransfer));if(!this.enterLeaveCounter.enter(e.target)||this.monitor.isDragging())return;const{dataTransfer:n}=e,r=ef(n);r&&this.beginDragNativeItem(r,n)},this.handleTopDragEnter=e=>{const{dragEnterTargetIds:t}=this;if(this.dragEnterTargetIds=[],!this.monitor.isDragging())return;this.altKeyPressed=e.altKey,t.length>0&&this.actions.hover(t,{clientOffset:af(e)});t.some(e=>this.monitor.canDropOnTarget(e))&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=this.getCurrentDropEffect()))},this.handleTopDragOverCapture=e=>{var t;(this.dragOverTargetIds=[],this.isDraggingNativeItem())&&(null===(t=this.currentNativeSource)||void 0===t||t.loadDataTransfer(e.dataTransfer))},this.handleTopDragOver=e=>{const{dragOverTargetIds:t}=this;if(this.dragOverTargetIds=[],!this.monitor.isDragging())return e.preventDefault(),void(e.dataTransfer&&(e.dataTransfer.dropEffect="none"));this.altKeyPressed=e.altKey,this.lastClientOffset=af(e),this.scheduleHover(t);(t||[]).some(e=>this.monitor.canDropOnTarget(e))?(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=this.getCurrentDropEffect())):this.isDraggingNativeItem()?e.preventDefault():(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="none"))},this.handleTopDragLeaveCapture=e=>{this.isDraggingNativeItem()&&e.preventDefault();this.enterLeaveCounter.leave(e.target)&&(this.isDraggingNativeItem()&&setTimeout(()=>this.endDragNativeItem(),0),this.cancelHover())},this.handleTopDropCapture=e=>{var t;(this.dropTargetIds=[],this.isDraggingNativeItem())?(e.preventDefault(),null===(t=this.currentNativeSource)||void 0===t||t.loadDataTransfer(e.dataTransfer)):ef(e.dataTransfer)&&e.preventDefault();this.enterLeaveCounter.reset()},this.handleTopDrop=e=>{const{dropTargetIds:t}=this;this.dropTargetIds=[],this.actions.hover(t,{clientOffset:af(e)}),this.actions.drop({dropEffect:this.getCurrentDropEffect()}),this.isDraggingNativeItem()?this.endDragNativeItem():this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover()},this.handleSelectStart=e=>{const t=e.target;"function"==typeof t.dragDrop&&("INPUT"===t.tagName||"SELECT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable||(e.preventDefault(),t.dragDrop()))},this.options=new sf(t,n),this.actions=e.getActions(),this.monitor=e.getMonitor(),this.registry=e.getRegistry(),this.enterLeaveCounter=new Ud(this.isNodeInDocument)}}let ff;function pf(){return ff||(ff=new Image,ff.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),ff}const hf=function(e,t,n){return new df(e,t,n)};var mf;!function(e){e.mouse="mouse",e.touch="touch",e.keyboard="keyboard"}(mf||(mf={}));class gf{get delay(){var e;return null!==(e=this.args.delay)&&void 0!==e?e:0}get scrollAngleRanges(){return this.args.scrollAngleRanges}get getDropTargetElementsAtPoint(){return this.args.getDropTargetElementsAtPoint}get ignoreContextMenu(){var e;return null!==(e=this.args.ignoreContextMenu)&&void 0!==e&&e}get enableHoverOutsideTarget(){var e;return null!==(e=this.args.enableHoverOutsideTarget)&&void 0!==e&&e}get enableKeyboardEvents(){var e;return null!==(e=this.args.enableKeyboardEvents)&&void 0!==e&&e}get enableMouseEvents(){var e;return null!==(e=this.args.enableMouseEvents)&&void 0!==e&&e}get enableTouchEvents(){var e;return null===(e=this.args.enableTouchEvents)||void 0===e||e}get touchSlop(){return this.args.touchSlop||0}get delayTouchStart(){var e,t,n,r;return null!==(r=null!==(n=null===(e=this.args)||void 0===e?void 0:e.delayTouchStart)&&void 0!==n?n:null===(t=this.args)||void 0===t?void 0:t.delay)&&void 0!==r?r:0}get delayMouseStart(){var e,t,n,r;return null!==(r=null!==(n=null===(e=this.args)||void 0===e?void 0:e.delayMouseStart)&&void 0!==n?n:null===(t=this.args)||void 0===t?void 0:t.delay)&&void 0!==r?r:0}get window(){return this.context&&this.context.window?this.context.window:"undefined"!=typeof window?window:void 0}get document(){var e;return(null===(e=this.context)||void 0===e?void 0:e.document)?this.context.document:this.window?this.window.document:void 0}get rootElement(){var e;return(null===(e=this.args)||void 0===e?void 0:e.rootElement)||this.document}constructor(e,t){this.args=e,this.context=t}}const vf=1,bf=0;function yf(e){return void 0===e.button||e.button===bf}function wf(e){return!!e.targetTouches}function Sf(e,t){return wf(e)?function(e,t){return 1===e.targetTouches.length?Sf(e.targetTouches[0]):t&&1===e.touches.length&&e.touches[0].target===t.target?Sf(e.touches[0]):void 0}(e,t):{x:e.clientX,y:e.clientY}}const kf=(()=>{let e=!1;try{addEventListener("test",()=>{},Object.defineProperty({},"passive",{get:()=>(e=!0,!0)}))}catch(e){}return e})(),Ef={[mf.mouse]:{start:"mousedown",move:"mousemove",end:"mouseup",contextmenu:"contextmenu"},[mf.touch]:{start:"touchstart",move:"touchmove",end:"touchend"},[mf.keyboard]:{keydown:"keydown"}};class Of{profile(){var e;return{sourceNodes:this.sourceNodes.size,sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,targetNodes:this.targetNodes.size,dragOverTargetIds:(null===(e=this.dragOverTargetIds)||void 0===e?void 0:e.length)||0}}get document(){return this.options.document}setup(){const e=this.options.rootElement;e&&(cc(!Of.isSetUp,"Cannot have two Touch backends at the same time."),Of.isSetUp=!0,this.addEventListener(e,"start",this.getTopMoveStartHandler()),this.addEventListener(e,"start",this.handleTopMoveStartCapture,!0),this.addEventListener(e,"move",this.handleTopMove),this.addEventListener(e,"move",this.handleTopMoveCapture,!0),this.addEventListener(e,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.addEventListener(e,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.addEventListener(e,"keydown",this.handleCancelOnEscape,!0))}teardown(){const e=this.options.rootElement;e&&(Of.isSetUp=!1,this._mouseClientOffset={},this.removeEventListener(e,"start",this.handleTopMoveStartCapture,!0),this.removeEventListener(e,"start",this.handleTopMoveStart),this.removeEventListener(e,"move",this.handleTopMoveCapture,!0),this.removeEventListener(e,"move",this.handleTopMove),this.removeEventListener(e,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.removeEventListener(e,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.removeEventListener(e,"keydown",this.handleCancelOnEscape,!0),this.uninstallSourceNodeRemovalObserver())}addEventListener(e,t,n,r=!1){const o=kf?{capture:r,passive:!1}:r;this.listenerTypes.forEach(function(r){const a=Ef[r][t];a&&e.addEventListener(a,n,o)})}removeEventListener(e,t,n,r=!1){const o=kf?{capture:r,passive:!1}:r;this.listenerTypes.forEach(function(r){const a=Ef[r][t];a&&e.removeEventListener(a,n,o)})}connectDragSource(e,t){const n=this.handleMoveStart.bind(this,e);return this.sourceNodes.set(e,t),this.addEventListener(t,"start",n),()=>{this.sourceNodes.delete(e),this.removeEventListener(t,"start",n)}}connectDragPreview(e,t,n){return this.sourcePreviewNodeOptions.set(e,n),this.sourcePreviewNodes.set(e,t),()=>{this.sourcePreviewNodes.delete(e),this.sourcePreviewNodeOptions.delete(e)}}connectDropTarget(e,t){const n=this.options.rootElement;if(!this.document||!n)return()=>{};const r=r=>{if(!this.document||!n||!this.monitor.isDragging())return;let o;switch(r.type){case Ef.mouse.move:o={x:r.clientX,y:r.clientY};break;case Ef.touch.move:var a,i;o={x:(null===(a=r.touches[0])||void 0===a?void 0:a.clientX)||0,y:(null===(i=r.touches[0])||void 0===i?void 0:i.clientY)||0}}const l=null!=o?this.document.elementFromPoint(o.x,o.y):void 0,s=l&&t.contains(l);return l===t||s?this.handleMove(r,e):void 0};return this.addEventListener(this.document.body,"move",r),this.targetNodes.set(e,t),()=>{this.document&&(this.targetNodes.delete(e),this.removeEventListener(this.document.body,"move",r))}}getTopMoveStartHandler(){return this.options.delayTouchStart||this.options.delayMouseStart?this.handleTopMoveStartDelay:this.handleTopMoveStart}installSourceNodeRemovalObserver(e){this.uninstallSourceNodeRemovalObserver(),this.draggedSourceNode=e,this.draggedSourceNodeRemovalObserver=new MutationObserver(()=>{e&&!e.parentElement&&(this.resurrectSourceNode(),this.uninstallSourceNodeRemovalObserver())}),e&&e.parentElement&&this.draggedSourceNodeRemovalObserver.observe(e.parentElement,{childList:!0})}resurrectSourceNode(){this.document&&this.draggedSourceNode&&(this.draggedSourceNode.style.display="none",this.draggedSourceNode.removeAttribute("data-reactid"),this.document.body.appendChild(this.draggedSourceNode))}uninstallSourceNodeRemovalObserver(){this.draggedSourceNodeRemovalObserver&&this.draggedSourceNodeRemovalObserver.disconnect(),this.draggedSourceNodeRemovalObserver=void 0,this.draggedSourceNode=void 0}constructor(e,t,n){this.getSourceClientOffset=e=>{const t=this.sourceNodes.get(e);return t&&function(e){const t=1===e.nodeType?e:e.parentElement;if(!t)return;const{top:n,left:r}=t.getBoundingClientRect();return{x:r,y:n}}(t)},this.handleTopMoveStartCapture=e=>{yf(e)&&(this.moveStartSourceIds=[])},this.handleMoveStart=e=>{Array.isArray(this.moveStartSourceIds)&&this.moveStartSourceIds.unshift(e)},this.handleTopMoveStart=e=>{if(!yf(e))return;const t=Sf(e);t&&(wf(e)&&(this.lastTargetTouchFallback=e.targetTouches[0]),this._mouseClientOffset=t),this.waitingForDelay=!1},this.handleTopMoveStartDelay=e=>{if(!yf(e))return;const t=e.type===Ef.touch.start?this.options.delayTouchStart:this.options.delayMouseStart;this.timeout=setTimeout(this.handleTopMoveStart.bind(this,e),t),this.waitingForDelay=!0},this.handleTopMoveCapture=()=>{this.dragOverTargetIds=[]},this.handleMove=(e,t)=>{this.dragOverTargetIds&&this.dragOverTargetIds.unshift(t)},this.handleTopMove=e=>{if(this.timeout&&clearTimeout(this.timeout),!this.document||this.waitingForDelay)return;const{moveStartSourceIds:t,dragOverTargetIds:n}=this,r=this.options.enableHoverOutsideTarget,o=Sf(e,this.lastTargetTouchFallback);if(!o)return;if(this._isScrolling||!this.monitor.isDragging()&&function(e,t,n,r,o){if(!o)return!1;const a=180*Math.atan2(r-t,n-e)/Math.PI+180;for(let e=0;e=t.start)&&(null==t.end||a<=t.end))return!0}return!1}(this._mouseClientOffset.x||0,this._mouseClientOffset.y||0,o.x,o.y,this.options.scrollAngleRanges))return void(this._isScrolling=!0);var a,i,l,s;if(!this.monitor.isDragging()&&this._mouseClientOffset.hasOwnProperty("x")&&t&&(a=this._mouseClientOffset.x||0,i=this._mouseClientOffset.y||0,l=o.x,s=o.y,Math.sqrt(Math.pow(Math.abs(l-a),2)+Math.pow(Math.abs(s-i),2))>(this.options.touchSlop?this.options.touchSlop:0))&&(this.moveStartSourceIds=void 0,this.actions.beginDrag(t,{clientOffset:this._mouseClientOffset,getSourceClientOffset:this.getSourceClientOffset,publishSource:!1})),!this.monitor.isDragging())return;const u=this.sourceNodes.get(this.monitor.getSourceId());this.installSourceNodeRemovalObserver(u),this.actions.publishDragSource(),e.cancelable&&e.preventDefault();const c=(n||[]).map(e=>this.targetNodes.get(e)).filter(e=>!!e),d=this.options.getDropTargetElementsAtPoint?this.options.getDropTargetElementsAtPoint(o.x,o.y,c):this.document.elementsFromPoint(o.x,o.y),f=[];for(const e in d){if(!d.hasOwnProperty(e))continue;let t=d[e];for(null!=t&&f.push(t);t;)t=t.parentElement,t&&-1===f.indexOf(t)&&f.push(t)}const p=f.filter(e=>c.indexOf(e)>-1).map(e=>this._getDropTargetId(e)).filter(e=>!!e).filter((e,t,n)=>n.indexOf(e)===t);if(r)for(const e in this.targetNodes){const t=this.targetNodes.get(e);if(u&&t&&t.contains(u)&&-1===p.indexOf(e)){p.unshift(e);break}}p.reverse(),this.actions.hover(p,{clientOffset:o})},this._getDropTargetId=e=>{const t=this.targetNodes.keys();let n=t.next();for(;!1===n.done;){const r=n.value;if(e===this.targetNodes.get(r))return r;n=t.next()}},this.handleTopMoveEndCapture=e=>{this._isScrolling=!1,this.lastTargetTouchFallback=void 0,function(e){return void 0===e.buttons||0===(e.buttons&vf)}(e)&&(this.monitor.isDragging()&&!this.monitor.didDrop()?(e.cancelable&&e.preventDefault(),this._mouseClientOffset={},this.uninstallSourceNodeRemovalObserver(),this.actions.drop(),this.actions.endDrag()):this.moveStartSourceIds=void 0)},this.handleCancelOnEscape=e=>{"Escape"===e.key&&this.monitor.isDragging()&&(this._mouseClientOffset={},this.uninstallSourceNodeRemovalObserver(),this.actions.endDrag())},this.options=new gf(n,t),this.actions=e.getActions(),this.monitor=e.getMonitor(),this.sourceNodes=new Map,this.sourcePreviewNodes=new Map,this.sourcePreviewNodeOptions=new Map,this.targetNodes=new Map,this.listenerTypes=[],this._mouseClientOffset={},this._isScrolling=!1,this.options.enableMouseEvents&&this.listenerTypes.push(mf.mouse),this.options.enableTouchEvents&&this.listenerTypes.push(mf.touch),this.options.enableKeyboardEvents&&this.listenerTypes.push(mf.keyboard)}}const Nf=function(e,t={},n={}){return new Of(e,t,n)},Cf=(uu(),e=>l().createElement(ms,{context:Vs,store:uu()},e.children)),Df=e=>l().createElement(Cf,null,l().createElement(xu,{props:e})),Af=e=>{const t=l().useId();return l().createElement("div",{className:"form-check form-check-inline"},l().createElement("input",{className:"form-check-input",type:"radio",id:t,value:e.name,checked:e.checked,disabled:e.disabled,onChange:t=>e.handleOnChange(t.target.value)}),l().createElement("label",{className:"form-check-label",htmlFor:t},e.label))},Tf=(e=>{const t=t=>{const n=Lu(e);return l().createElement(ku.Provider,{value:n},t.children)};return e=>l().createElement(t,null,l().createElement($u,e,e.children))})({controlClassnames:{actionElement:"btn btn-sm",addGroup:"btn-secondary",addRule:"btn-primary",cloneGroup:"btn-secondary",cloneRule:"btn-secondary",lockGroup:"btn-secondary",lockRule:"btn-secondary",removeGroup:"btn-danger",removeRule:"btn-danger",undoAction:"btn-secondary",redoAction:"btn-secondary",valueSelector:"form-select form-select-sm"},controlElements:{notToggle:({className:e,handleOnChange:t,title:n,label:r,checked:o,disabled:a})=>{const i=(0,l().useId)();return l().createElement("div",{className:`form-check-inline form-switch ${e}`},l().createElement("input",{id:i,className:"form-check-input",type:"checkbox",onChange:e=>t(e.target.checked),checked:!!o,disabled:a}),l().createElement("label",{title:n,htmlFor:i,className:"form-check-label"},r))},valueEditor:e=>{const{valueListItemClassName:t}=Tu(e);if("null"===e.operator||"notNull"===e.operator)return null;if(!("between"!==e.operator&&"notBetween"!==e.operator||"select"!==e.type&&"text"!==e.type)){const n="text"===e.type?"form-control form-control-sm":"form-select form-select-sm";return l().createElement(Au,{...e,skipHook:!0,schema:{...e.schema,classNames:{...e.schema.classNames,valueListItem:`${t} ${n}`}}})}switch(e.type){case"select":case"multiselect":return l().createElement(Au,{...e,skipHook:!0,className:`${e.className} form-select form-select-sm`});case"switch":return l().createElement("span",{className:`${e.className} custom-control custom-switch`},l().createElement("input",{type:"checkbox",className:"form-check-input custom-control-input",title:e.title,disabled:e.disabled,onChange:t=>e.handleOnChange(t.target.checked),checked:!!e.value}));case"checkbox":return l().createElement(Au,{...e,skipHook:!0,className:`${e.className} form-check-input`});case"radio":return l().createElement("span",{title:e.title,className:hn.value},e.values?.map(t=>l().createElement(Af,{key:t.name,name:t.name,disabled:e.disabled,checked:e.value===t.name,handleOnChange:e.handleOnChange,label:t.label})))}return l().createElement(Au,{...e,skipHook:!0,className:`${e.className} form-control form-control-sm`})}},translations:{removeGroup:{label:l().createElement("i",{className:"bi bi-x"})},removeRule:{label:l().createElement("i",{className:"bi bi-x"})},cloneRule:{label:l().createElement("i",{className:"bi bi-copy"})},cloneRuleGroup:{label:l().createElement("i",{className:"bi bi-copy"})},dragHandle:{label:l().createElement("i",{className:"bi bi-grip-vertical"})},lockGroup:{label:l().createElement("i",{className:"bi bi-unlock"})},lockRule:{label:l().createElement("i",{className:"bi bi-unlock"})},lockGroupDisabled:{label:l().createElement("i",{className:"bi bi-lock"})},lockRuleDisabled:{label:l().createElement("i",{className:"bi bi-lock"})},shiftActionUp:{label:l().createElement("i",{className:"bi bi-chevron-compact-up"})},shiftActionDown:{label:l().createElement("i",{className:"bi bi-chevron-compact-down"})},undo:{label:l().createElement("i",{className:"bi bi-arrow-counterclockwise"})},redo:{label:l().createElement("i",{className:"bi bi-arrow-clockwise"})}}}),$f=e=>"string"==typeof e?e.toLowerCase():e,Mf=(new RegExp(Me.source.replace(/^\^/,String.raw`^\s*`).replace(/\$$/,String.raw`\s*$`)),e=>null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype),Rf=e=>Mf(e)&&Array.isArray(e.rules),xf=e=>Rf(e)&&"string"==typeof e.combinator,If=Object.keys;Object.entries;const Pf={"=":"!=","!=":"=","<":">=","<=":">",">":"<=",">=":"<",beginsWith:"doesNotBeginWith",doesNotBeginWith:"beginsWith",endsWith:"doesNotEndWith",doesNotEndWith:"endsWith",contains:"doesNotContain",doesNotContain:"contains",between:"notBetween",notBetween:"between",in:"notIn",notIn:"in",notNull:"null",null:"notNull"},_f=(e,t=",")=>e.map(e=>`${e??""}`.replaceAll(t[0],`\\${t[0]}`)).join(t),Lf=e=>Mf(e)&&"name"in e&&"string"==typeof e.name,Gf=e=>Mf(e)&&"value"in e&&"string"==typeof e.value;function Ff(e,t,n){if("string"==typeof e)return{...t,name:e,value:e,label:n?.[e]??e};const r={};let o=!!t;return Lf(e)&&!Gf(e)?(r.value=e.name,o=!0):!Lf(e)&&Gf(e)&&(r.name=e.value,o=!0),o?Object.assign({},t,e,r):e}function zf(e,t,n){if(!Array.isArray(e))return[];const r=e;return qf(r)?r.map(e=>({...e,options:e.options.map(e=>Ff(e,t,n))})):r.map(e=>Ff(e,t,n))}const jf=e=>{const t=new Set,n=[];for(const r of e)t.has(r.value??r.name)||(t.add(r.value??r.name),n.push(r));return e.length===n.length?e:n},Vf=e=>{let t=!1;if(Array.isArray(e))for(const n of e){if(!Lf(n)&&!Gf(n))return!1;t=!0}return t},qf=(e,{allowEmpty:t=!1}={})=>{let n=!1;if(Array.isArray(e))for(const r of e){if(!(Mf(r)&&"options"in r&&(Vf(r.options)||t&&Array.isArray(r.options)&&0===r.options.length)))return!1;n=!0}return n};const Bf=e=>jf((e=>Array.isArray(e)&&e.length>0&&Mf(e[0])&&"options"in e[0]&&Array.isArray(e[0].options))(e)?e.flatMap(e=>e.options):e);const Hf=e=>{if((e=>Rf(e)&&void 0===e.combinator)(e))return e;const{combinator:t,...n}=e,r=[],{length:o}=e.rules;for(let n=0;n{const r=Ff(e),o=Ff(n);return r.value!==o.value&&("string"==typeof r.comparator?r[r.comparator]===o[r.comparator]:r.comparator?.(o,t)?? +/* v8 ignore start -- @preserve */!1)},Wf=globalThis.crypto;let Qf=()=>"00-0-4-2-000".replaceAll(/[^-]/g,e=>(65536*(Math.random()+Math.trunc(e))>>Number.parseInt(e)).toString(16).padStart(4,"0"));if(Wf)if("function"==typeof Wf.randomUUID)Qf=()=>Wf.randomUUID();else if("function"==typeof Wf.getRandomValues){const e="89ab",t=new Uint32Array(32);Qf=()=>{Wf.getRandomValues(t);let n=(t[0]%16).toString(16);for(let r=1;r<32;r++)n=12===r?`${n}4`:16===r?`${n}${e[t[17]%4]}`:`${n}${(t[r]%16).toString(16)}`,7!==r&&11!==r&&15!==r&&19!==r||(n=`${n}-`);return n}}const Kf=[{name:"value",value:"value",label:"value"}],Xf={name:"name",value:"name",valueSources:null,label:"label"},Yf=(e,{idGenerator:t=Qf}={})=>{const n=!e.id,r=(e=>{const{mode:t,threshold:n}=e.match??{};if(!t)return null;if(!Rf(e.value))return!1;const r=$f(t),o="atleast"===r&&1===n?"some":"atmost"===r&&0===n?"none":r;return("atleast"!==o&&"atmost"!==o&&"exactly"!==o||!("number"!=typeof n||n<0))&&{mode:o,threshold:n}})(e);return n||r?{...e,...n&&{id:t()},...r&&{value:Jf(e.value,{idGenerator:t})}}:e},Jf=(e,{idGenerator:t=Qf}={})=>{const n=!e.id;let r=!1;const o=[];for(let n=0;n{const t=((e,t,n)=>{const r=e?Ff(e):Xf;let o=r.valueSources??!1;return"function"==typeof o&&(o=o(t)),!o&&n&&(o=n(r.value,t,{fieldData:r})),o?Vf(o)?zf(o):o.map(e=>Kf.find(t=>t.value===$f(e))??{name:e,value:e,label:e}):Kf})(s,r,a);return Vf(t)&&t.some(t=>t.value===e||t.name===e)};if(0===t.length)return!0;let l=!1;const s=Ff(t.find(e=>e.name===n));return s&&(l=!(!o&&"notNull"!==r&&"null"!==r&&!i("value")),l&&o&&(i("field")&&n!==o&&((e,t,n)=>{if(!e.comparator){const n=t=>(t.value??/* v8 ignore start -- @preserve */t.name)!==(e.value?? +/* v8 ignore start -- @preserve */e.name);return qf(t)?t.map(e=>({...e,options:e.options.filter(e=>n(e))})):t.filter(e=>n(e))}return qf(t)?t.map(t=>({...t,options:t.options.filter(t=>Uf(e,n,t))})).filter(e=>e.options.length>0):t.filter(t=>Uf(e,n,t))})(s,t,r).some(e=>e.name===o)||(l=!1))),l}const ep=e=>(e=>Mf(e)&&"var"in e)(e)&&"string"==typeof e.var,tp=e=>Mf(e)&&"=="in e,np=e=>Mf(e)&&"==="in e,rp=e=>Mf(e)&&"!="in e,op=e=>Mf(e)&&"!=="in e,ap=e=>Mf(e)&&">"in e,ip=e=>Mf(e)&&">="in e,lp=e=>Mf(e)&&"<"in e&&2===e["<"].length,sp=e=>Mf(e)&&"<="in e&&2===e["<="].length,up=e=>Mf(e)&&"in"in e&&!Array.isArray(e.in[1]),cp=e=>Mf(e)&&"none"in e,dp=e=>Mf(e)&&"some"in e,fp=e=>Mf(e)&&"<"in e&&Array.isArray(e["<"])&&3===e["<"].length,pp=e=>Mf(e)&&"startsWith"in e,hp=e=>Mf(e)&&"endsWith"in e,mp=e=>Mf(e)&&!ep(e),gp={combinator:"and",rules:[]};function vp(e,t={}){const n=(e=>{const t=e?Array.isArray(e)?e:Object.keys(e).map(t=>Object.assign({},e[t],{name:t})).sort((e,t)=>e.label.localeCompare(t.label)):[];return Bf(t)})(t.fields),{getValueSources:r,listsAsArrays:o,jsonLogicOperations:a,getExpression:i}=t,l=(e,t,o)=>Zf({fieldName:e,fieldsFlat:n,operator:t,subordinateFieldName:o,getValueSources:r}),s={fieldExists:e=>0===n.length||n.some(t=>t.name===e)};const u=t.generateIDs?Jf:e=>e;let c=e;if("string"==typeof e)try{c=JSON.parse(e)}catch{return u(gp)}const d=function e(t,n,r){if(n&&!Mf(t))return!1;const[u,c]=Object.entries(t||{})?.[0]??[];if(a&&If(a).includes(u)){const e=a[u](c);return!!e&&(n&&!Rf(e)?{combinator:"and",rules:[e]}:e)}if((e=>Mf(e)&&"and"in e)(t))return{combinator:"and",rules:t.and.map(t=>e(t,!1,r)).filter(Boolean)};if((e=>Mf(e)&&"or"in e)(t))return{combinator:"or",rules:t.or.map(t=>e(t,!1,r)).filter(Boolean)};if((e=>Mf(e)&&"!"in e)(t)){const o=e(t["!"],!1,r);if(o){if(!(xf(o)||"between"!==o.operator&&"in"!==o.operator&&"contains"!==o.operator&&"beginsWith"!==o.operator&&"endsWith"!==o.operator)){const e={...o,operator:Pf[o.operator]};return n?{combinator:"and",rules:[e]}:e}return fp(t["!"])||xf(o)?{...o,not:!0}:{combinator:"and",rules:[o],not:!0}}return!1}if((e=>Mf(e)&&"!!"in e)(t))return e(t["!!"],!1,r)||!1;let d,f=!1,p="",h="=",m="";if(tp(t)||np(t)||rp(t)||op(t)||ap(t)||ip(t)||lp(t)||sp(t)||up(t)||pp(t)||hp(t)){const[e,o]=c,a=tp(t)||np(t)||rp(t)||op(t)||ap(t)||ip(t)||lp(t)||sp(t),g=mp(e),v=mp(o);if(i&&a&&(g||v)){const a=tp(t)||np(t)?"=":rp(t)||op(t)?"!=":u;if(g&&v){const t=i(e,s),n=i(o,s);t&&n&&(f={field:"",operator:a,lhs:t,value:n,valueSource:"expression"})}else if(g&&!Mf(o)){const t=i(e,s);t&&(f={field:"",operator:a,lhs:t,value:o})}else if(ep(e)&&v){const t=i(o,s);t&&(r||l(e.var,a))&&(f={field:e.var,operator:a,value:t,valueSource:"expression"})}return!!f&&(n?{combinator:"and",rules:[f]}:f)}if(ep(e)&&!Mf(o))p=e.var,m=o;else if(!Mf(e)&&ep(o))p=o.var,m=e;else{if(!ep(e)||!ep(o))return!1;p=e.var,m=o.var,d="field"}h=tp(t)||np(t)?null===m?"null":"=":rp(t)||op(t)?null===m?"notNull":"!=":up(t)?"contains":pp(t)?"beginsWith":hp(t)?"endsWith":u,(r||l(p,h,"field"===d?m:void 0))&&(f={field:p,operator:h,value:m,valueSource:d})}else if((e=>Mf(e)&&"all"in e)(t)&&ep(t.all[0])||cp(t)&&ep(t.none[0])||dp(t)&&ep(t.some[0])){const n={mode:cp(t)?"none":dp(t)?"some":"all"},[{var:r},o]=t[n.mode],a=e(o,!1,!0);if(!a)return!1;f={field:r,operator:"=",match:n,value:Rf(a)?a:{combinator:"and",rules:[a]}}}else if(fp(t)&&ep(t["<"][1])){p=t["<"][1].var;const n=[t["<"][0],t["<"][2]];if(n.every(e=>ep(e))||n.every(e=>"string"==typeof e)||n.every(e=>"number"==typeof e)||n.every(e=>"boolean"==typeof e))return e({and:[{">":[{var:p},n[0]]},{"<":[{var:p},n[1]]}]})||/* v8 ignore start -- @preserve */!1}else if((e=>Mf(e)&&"<="in e&&Array.isArray(e["<="])&&3===e["<="].length)(t)&&ep(t["<="][1])){p=t["<="][1].var,h="between";const e=[t["<="][0],t["<="][2]];if(i&&(mp(e[0])||mp(e[1]))){const t=i(e[0],s),r=i(e[1],s);return t&&r&&l(p,h)&&(f={field:p,operator:h,value:[t,r],valueSource:"expression"}),!!f&&(n?{combinator:"and",rules:[f]}:f)}if(t["<="].every(e=>ep(e))){d="field";const t=e.map(e=>e.var).filter(e=>l(p,h,e));m=o?t:_f(t,",")}else(e.every(e=>"string"==typeof e)||e.every(e=>"number"==typeof e)||e.every(e=>"boolean"==typeof e))&&(m=o?e:_f(e.map(e=>`${e}`),","));l(p,h)&&m.length>=2&&(f={field:p,operator:h,value:m,valueSource:d})}else if((e=>Mf(e)&&"in"in e&&Array.isArray(e.in[1]))(t)&&ep(c[0])){if(p=c[0].var,h="in",t.in[1].every(e=>ep(e))){d="field";const e=t.in[1].map(e=>e.var).filter(e=>l(p,h,e));m=o?e:_f(e,",")}else(t.in[1].every(e=>"string"==typeof e)||t.in[1].every(e=>"number"==typeof e)||t.in[1].every(e=>"boolean"==typeof e))&&(m=o?t.in[1]:_f(t.in[1].map(e=>`${e}`),","));m.length>0&&(f={field:p,operator:h,value:m,valueSource:d})}return!!f&&(n?{combinator:"and",rules:[f]}:f)}(c,!0)||gp;return u(t.independentCombinators?Hf(d):d)}Promise.resolve().then(()=>n(236));const bp=["=","null","contains","doesNotContain","beginsWith","endsWith",">",">=","<","<=","in"],yp=class extends Oe{#e;#t=[];#n=[];#r={};#o={};#a=bp;#i=!1;#l="en";#s={en:{fields:{title:"Fields"},operators:{title:"Operators","=":"is equal to","!=":"is not equal to","<":"is less than",">":"is greater than","<=":"is less than or equal to",">=":"is greater than or equal to",between:"between",notBetween:"not between",contains:"contains",doesNotContain:"does not contain",beginsWith:"begins with",endsWith:"ends with",in:"in",notIn:"not in",null:"is empty",notNull:"is not empty",regex:"matches the regular expression",notRegex:"does not match the regular expression","<=ndays":"is less than or equal to N day(s)",">=ndays":"is greater than or equal to N day(s)",valuesList:"List of values"},value:{title:"Value"},addRule:{label:"+ Rule",title:"Add a rule"},removeRule:{label:"⨯",title:"Remove the rule"},addGroup:{label:"+ Group",title:"Add a group"},removeGroup:{label:"⨯",title:"Remove the group"},and:"AND",or:"OR",not:"NOT",validationError:"This rule is incomplete"},fr:{fields:{title:"Champs"},operators:{title:"Opérateurs","=":"est égal à","!=":"n'est pas égal à","<":"est inférieur à",">":"est supérieur à","<=":"est inférieur ou égal à",">=":"est supérieur ou égal à",between:"entre",notBetween:"n'est pas entre",contains:"contient",doesNotContain:"ne contient pas",beginsWith:"commence par",endsWith:"se termine par",in:"dans",notIn:"pas dans",null:"est vide",notNull:"n'est pas vide",regex:"correspond à l'expression régulière",notRegex:"ne correspond pas à l'expression régulière","<=ndays":"est inférieure ou égale à N jour(s)",">=ndays":"est supérieure ou égale à N jour(s)",valuesList:"Liste de valeurs"},value:{title:"Valeur"},addRule:{label:"+ Règle",title:"Ajouter une règle"},removeRule:{label:"⨯",title:"Supprimer la règle"},addGroup:{label:"+ Groupe",title:"Ajouter un groupe"},removeGroup:{label:"⨯",title:"Supprimer le groupe"},and:"ET",or:"OU",not:"NON",validationError:"Cette règle est incomplète"}};static values={conditions:Object,fields:Array,operators:Array,processor:String,lang:{type:String,default:"fr"}};static targets=["queryBuilder","input"];#u=null;#c=null;#d=null;connect(){const e=this.#f();this.#d=this.processorValue,this.#u=this.#p(),this.#h(e,this.#u)}disconnect(){this.#e?.unmount(),this.#e=null}fieldsValueChanged(){this.#m()}operatorsValueChanged(){this.#m()}langValueChanged(){this.#m()}processorValueChanged(){this.#e&&this.processorValue!==this.#d&&(this.#d=this.processorValue,this.#g(this.#u))}#m(){if(!this.#e||this.#v()===this.#c)return;const e=this.#f(),t=this.#b(this.#u,this.#y(e));this.#e.unmount(),this.#h(e,t),this.#g(t)}#v(){return JSON.stringify([this.fieldsValue,this.operatorsValue,this.langValue])}#f(){this.#w();const e=this.#S();return this.#c=this.#v(),e}#w(){this.#i=this.operatorsValue.length>0,this.#a=this.#i?this.operatorsValue:bp}#S(){this.#t=[],this.#n=[],this.#r={},this.#o={};const e=[];for(const t of this.fieldsValue)this.#k(t),e.push({name:t.name,label:this.#E(t),...this.#O(t),...this.#N(t)});return e.sort((e,t)=>e.label.localeCompare(t.label,this.langValue)),e}#y(e){const t=this.#C();return new Map(e.map(e=>[e.name,new Set(t(e.name,{fieldData:e}).map(e=>e.name))]))}#b(e,t){const n=[];for(const r of e.rules??[]){if(r&&Array.isArray(r.rules)){const e=this.#b(r,t);e.rules.length&&n.push(e);continue}if(!r||"object"!=typeof r||"~"===r.field){n.push(r);continue}const e=t.get(r.field);if(e){if("valuesList"===r.operator){const t=null!=r.value&&""!==r.value&&"~"!==r.value;!e.has("valuesList")||t&&!(this.#r[r.field]??[]).includes(r.value)?e.has("=")&&n.push({...r,operator:"=",value:t?r.value:""}):n.push(r);continue}("~"===r.operator||e.has(r.operator))&&n.push(r)}}return{...e,rules:n}}#h(e,n){const r=l().createElement(Df,{fields:e,onQueryChange:e=>this.#g(e),defaultQuery:n,combinators:this.#D(),getOperators:this.#C(),getValueEditorType:this.#A(),getInputType:this.#T(),translations:this.#$(),autoSelectField:!1,autoSelectValue:!1,listsAsArrays:!0,enableDragAndDrop:!0,enableMountQueryChange:!1,controlClassnames:{queryBuilder:"queryBuilder-branches"}});this.#e=(0,t().createRoot)(this.queryBuilderTarget),this.#e.render(l().createElement(ac,{dnd:{...h,...v,...b},children:[l().createElement(Tf,{},r)]}))}#g(e){if(this.#u=e,"native"===this.processorValue){const t=this.#M(e);return void this.#R(JSON.stringify(t.rules.length?t:{}))}let t=this.#x();const n=Za(e,{format:"jsonlogic",ruleProcessor:t});if("jsonLogic"===this.processorValue&&this.#R(JSON.stringify(!1===n?{}:n)),"parameterized"===this.processorValue){t=this.#I();const r=Za(e,{format:"parameterized",ruleProcessor:t});if(!1===n)return void this.#R(JSON.stringify({}));const o={conditionTree:n,parameterizedSql:r};this.#R(JSON.stringify(o))}}#R(e){this.inputTarget.value!==e&&(this.inputTarget.value=e,this.inputTarget.dispatchEvent(new Event("input",{bubbles:!0})),this.inputTarget.dispatchEvent(new Event("change",{bubbles:!0})))}#E(e){let t=e.label??e.name;return e.labelInformation&&(t+=`     (${e.labelInformation})`),t}#O(e){switch("date"===e.type&&this.#t.push(e.name),"number"===e.type&&this.#n.push(e.name),e.type){case"date":return this.#P();case"number":return this.#_();case"boolean":return this.#L();default:return this.#G()}}#G(){return{inputType:"text",datatype:"string"}}#P(){return{datatype:"date"}}#_(){return{inputType:"number",datatype:"number"}}#L(){return{inputType:"boolean",datatype:"boolean",valueEditorType:"checkbox",defaultValue:!1}}#N(e){if(!e.values?.length)return{};const t=e.values.map(e=>({name:e.value??e.name,label:e.label??e.name}));return this.#r[e.name]=t.map(e=>e.name),{values:t}}#F(e){return(this.#r[e]??[]).length>0}#z(e){return Array.isArray(e)?e.map(String):null==e?[]:String(e).split(/[\n,]/).map(e=>e.trim()).filter(e=>""!==e)}#k(e){e.operators?.length&&(this.#o[e.name]=e.operators)}#D(){return fn.map(e=>"and"===e.name?{...e,label:this.#j("and")}:"or"===e.name?{...e,label:this.#j("or")}:e)}#C(){return(e,{fieldData:t})=>{if(this.#o[e])return this.#V(this.#o[e],t);let n=dn.filter(e=>this.#a.includes(e.name));return n.sort((e,t)=>this.#a.indexOf(e.name)-this.#a.indexOf(t.name)),n=n.map(e=>({...e,label:this.#q(e.name,e.label)})),["number","date"].includes(t.datatype)||(n=n.filter(e=>![">",">=","<","<="].includes(e.name))),"string"!==t.datatype&&(n=n.filter(e=>!["contains","doesNotContain","beginsWith","endsWith","in"].includes(e.name))),"text"===t.inputType&&(this.#B("regex")&&n.push({name:"regex",label:this.#q("regex"),value:"regex"}),this.#B("notRegex")&&n.push({name:"notRegex",label:this.#q("notRegex"),value:"notRegex"})),"date"===t.datatype&&(this.#B("<=ndays")&&n.push({name:"<=ndays",label:this.#q("<=ndays"),value:"<=ndays"}),this.#B(">=ndays")&&n.push({name:">=ndays",label:this.#q(">=ndays"),value:">=ndays"})),e&&t.values?.length&&this.#B("valuesList")&&n.push({name:"valuesList",label:this.#q("valuesList"),value:"valuesList"}),this.#i&&n.sort((e,t)=>this.#a.indexOf(e.name)-this.#a.indexOf(t.name)),n}}#V(e,t){const n=[];for(const r of e){if("valuesList"===r&&!t.values?.length)continue;const e=dn.find(e=>e.name===r);n.push(e?{...e,label:this.#q(r,e.label)}:{name:r,label:this.#q(r),value:r})}return n}#B(e,t=null){return t&&this.#o[t]?this.#o[t].includes(e):!this.#i||this.#a.includes(e)}#q(e,t=null){return`${this.#j("operators")[e]||t||e}   ( ${e} )`}#A(){return(e,t)=>{switch(t){case"valuesList":return"select";case"in":case"notIn":return this.#F(e)?"multiselect":"textarea";default:return"text"}}}#T(){return(e,t,{fieldData:n})=>n.datatype&&"date"===n.datatype?["<=ndays",">=ndays"].includes(t)?"number":"date":n.inputType||"text"}#x(){return(e,t)=>{if("valuesList"===e.operator)return{"==":[{var:e.field},e.value]};if(["regex","notRegex"].includes(e.operator))return{[e.operator]:[{var:e.field},this.#H(e.value)]};if(["<=ndays",">=ndays"].includes(e.operator)){const t=isNaN(e.value)?"":e.value;return{[e.operator]:[{var:e.field},t]}}return this.#t.includes(e.field)&&(e={...e,value:this.#U(e)}),["in","notIn"].includes(e.operator)&&"string"==typeof e.value&&(e={...e,value:e.value.replaceAll(/\n/g,",")}),"null"===e.operator&&this.#n.includes(e.field)&&(e={...e,operator:"in",value:[null,0]}),"notNull"===e.operator&&this.#n.includes(e.field)?{notNull:[{var:e.field},[null,0]]}:xa(e,t)}}#U(e){const t=e=>/^\d{4}-\d{2}-\d{2}$/.test(e);if(["between","notBetween"].includes(e.operator)){const n=String(e.value).split(",");return 2===n.length&&n.every(t)?e.value:""}return t(e.value)?e.value:""}#I(){return(e,t)=>{if("null"===e.operator&&this.#n.includes(e.field))return{sql:"( "+e.field+" is null or "+e.field+" = ? )",params:[0]};if("notNull"===e.operator&&this.#n.includes(e.field))return{sql:"( "+e.field+" is not null and "+e.field+" <> ? )",params:[0]};if("null"===e.operator)return{sql:"( "+e.field+" is null )",operator:"",params:null};if("valuesList"===e.operator)return{sql:"( "+e.field+" = ? )",params:[e.value]};if("regex"===e.operator)return{sql:"( lower("+e.field+") regexp lower(?) )",params:[e.value]};if("notRegex"===e.operator)return{sql:"( lower("+e.field+") not regexp lower(?) )",params:[e.value]};if(["<=ndays",">=ndays"].includes(e.operator)&&(e={...e,field:"datediff( curdate(), "+e.field+" )",operator:e.operator.replace("ndays","")}),["in","notIn"].includes(e.operator)&&"string"==typeof e.value&&(e={...e,value:e.value.replaceAll(/\n/g,",")}),["contains","doesNotContain"].includes(e.operator)){const t="contains"===e.operator?"like":"not like";return{sql:"( "+e.field+" "+t+" ? )",params:[`%${e.value}%`]}}const n=Va(e,t);return n&&n.sql?{sql:"( "+n.sql+" )",params:n.params}:n}}#M(e){const t=[];for(const n of e.rules??[])if(n&&"object"==typeof n){if(Array.isArray(n.rules)){const e=this.#M(n);e.rules.length&&t.push(e);continue}"~"!==n.field&&"~"!==n.operator&&t.push(this.#W(n))}return{combinator:e.combinator,...e.not?{not:!0}:{},rules:t}}#W(e){if("valuesList"===e.operator)return{field:e.field,operator:"=",value:e.value};let t=e.value;return["<=ndays",">=ndays"].includes(e.operator)?t=isNaN(t)?"":t:this.#t.includes(e.field)&&(t=this.#U(e)),["in","notIn"].includes(e.operator)&&"string"==typeof t&&(t=t.replaceAll(/\n/g,",")),{field:e.field,operator:e.operator,value:t}}#p(){const e=e=>Array.isArray(e)&&2===e.length&&[null,0].every(t=>e.includes(t)),t=e=>e[1].var&&"string"==typeof e[0]?e[1].var:e[0].var,n=function(t){return t[1].var&&"string"==typeof t[0]?"contains":e(t[1])?"null":"in"},r=function(n){return n[1].var&&"string"==typeof n[0]?n[0]:e(n[1])?null:o(n[1],t(n))},o=(e,t)=>!Array.isArray(e)||this.#F(t)?e:e.join("\n"),a=null!==this.conditionsValue&&"object"==typeof this.conditionsValue?this.conditionsValue:{},i="conditionTree"in a?a.conditionTree:a;return null!==i&&"object"==typeof i&&Array.isArray(i.rules)?this.#Q(i):this.#Q(vp(i,{jsonLogicOperations:{in:e=>({field:t(e),operator:n(e),value:r(e)}),notIn:e=>({field:e[0].var,operator:"notIn",value:o(e[1],e[0].var)}),notNull:e=>({field:e[0].var,operator:"notNull",value:""}),regex:e=>({field:e[0].var,operator:"regex",value:this.#K(e[1])}),notRegex:e=>({field:e[0].var,operator:"notRegex",value:this.#K(e[1])}),"<=ndays":e=>({field:e[0].var,operator:"<=ndays",value:e[1]}),">=ndays":e=>({field:e[0].var,operator:">=ndays",value:e[1]})}}))}#H(e){const t="string"==typeof e?e:String(e??"");if(/^\/(?:\\.|[^\\/])*\/[iums]*$/s.test(t))return t;return`/${t.replace(/\\.|\/|\\$/gs,e=>"/"===e?"\\/":"\\"===e?"\\\\":e)}/iu`}#K(e){if("string"!=typeof e)return e;const t=/^\/(.*)\/iu$/s.exec(e);return null===t?e:t[1].replace(/\\./gs,e=>"\\/"===e?"/":e)}#Q(e){return e&&Array.isArray(e.rules)?{...e,rules:e.rules.map(e=>e&&Array.isArray(e.rules)?this.#Q(e):e&&["in","notIn"].includes(e.operator)&&this.#F(e.field)?{...e,value:this.#z(e.value)}:e&&["in","notIn"].includes(e.operator)&&"string"==typeof e.value?{...e,value:e.value.replaceAll(",","\n")}:e&&"="===e.operator&&this.#B("valuesList",e.field)&&(this.#r[e.field]??[]).includes(e.value)?{...e,operator:"valuesList"}:e)}:e}#$(){return{...sn,...this.#X(["fields","operators","value","addRule","removeRule","addGroup","removeGroup"])}}#X(e=null){const t=this.#s[this.langValue]??this.#s[this.#l];if(!e)return t;let n={};return e.forEach(e=>{n[e]=t[e]||e}),n}#j(e){return this.#X([e])[e]||e}};n.dn(yp);const wp={combinator:"and",rules:[]},Sp=["in","notIn","between","notBetween"],kp=["null","notNull"];function Ep(e){if(!e||"null"===e)return wp;try{const t=JSON.parse(e);return t&&"object"==typeof t&&Array.isArray(t.rules)?t:wp}catch{return wp}}function Op(e){return e&&Array.isArray(e.rules)?e.rules.reduce((e,t)=>e+(t&&Array.isArray(t.rules)?Op(t):t&&t.field?1:0),0):0}function Np(e,t,n){const r=document.createElement(e);return t&&(r.className=t),void 0!==n&&(r.textContent=n),r}function Cp(e,t,n){const r=Array.isArray(e?.values)?e.values:[],o=n.values||{};return function(e){const t=e.value;return Array.isArray(t)?t:Sp.includes(e.operator)&&"string"==typeof t?t.split(",").map(e=>e.trim()).filter(e=>""!==e):null==t?[]:[t]}(t).map(e=>{if(!0===e||"true"===e)return o.true||"true";if(!1===e||"false"===e)return o.false||"false";const t=r.find(t=>String(t.value??t.name)===String(e));return t?t.label??t.name:String(e)})}function Dp(e,t,n){const r=t.find(t=>t.name===e.field),o=(n.operators||{})[e.operator]||e.operator,a=n.values||{},i=Np("li","qb-summary-rule"),l=Np("span",r?"qb-summary-field":"qb-summary-field qb-summary-field-unknown",r?r.label:e.field);if(r||(l.title=a.unknownField||""),i.appendChild(l),i.appendChild(Np("span","qb-summary-operator",o)),kp.includes(e.operator))return i;const s=Cp(r,e,n).filter(e=>""!==e);if(0===s.length)return i.appendChild(Np("span","qb-summary-missing",a.missing||"")),i;const u="between"===e.operator||"notBetween"===e.operator,c=n.join||{};return s.forEach((e,t)=>{t>0&&i.appendChild(Np("span","qb-summary-join",u?c.and||"and":c.or||"or")),i.appendChild(Np("span","qb-summary-value",e))}),i}function Ap(e,t,n,r){const o=Array.isArray(e.rules)?e.rules:[],a="or"===e.combinator?"or":"and",i=Np("div",`qb-summary-group qb-summary-depth-${Math.min(r,3)}`),l=n.groups||{},s=n.combinators||{};if(o.length>1||r>0||e.not){const t=Np("div","qb-summary-heading");t.appendChild(Np("span",`qb-summary-combinator qb-summary-combinator-${a}`,s[a]||a.toUpperCase())),t.appendChild(Np("span","qb-summary-heading-text",l[e.not?`${a}Not`:a]||"")),i.appendChild(t)}const u=Np("ul","qb-summary-list");for(const e of o)if(e&&"object"==typeof e){if(Array.isArray(e.rules)){const o=Np("li","qb-summary-nested");o.appendChild(Ap(e,t,n,r+1)),u.appendChild(o);continue}e.field&&u.appendChild(Dp(e,t,n))}return i.appendChild(u),i}const Tp=class extends Oe{static targets=["context","contextHelp","hookChoice","hookCount","hookEmpty","counter","summary","summaryText","emptyHint"];static values={fieldsByContext:Object,labels:Object};connect(){this.editor=this.element.querySelector('[data-controller~="query-builder"]'),this.input=this.element.querySelector('[data-query-builder-target="input"]'),this.onInputChange=()=>this.refreshFeedback(),this.input?.addEventListener("change",this.onInputChange),this.previousContext=this.hasContextTarget?this.contextTarget.value:null,this.syncContextHelp(),this.refreshHooks(),this.refreshFeedback()}disconnect(){this.input?.removeEventListener("change",this.onInputChange)}changeContext(){const e=this.contextTarget.value,t=this.labelsValue.confirmContextChange;Op(this.currentQuery())>0&&t&&!window.confirm(t)?this.contextTarget.value=this.previousContext:(this.previousContext=e,this.editor&&(this.editor.dataset.queryBuilderFieldsValue=JSON.stringify(this.currentFields())),this.syncContextHelp(),this.refreshHooks(),this.refreshFeedback())}syncContextHelp(){if(!this.hasContextTarget||!this.hasContextHelpTarget)return;const e=this.contextTarget.options[this.contextTarget.selectedIndex];this.contextHelpTarget.textContent=e&&e.dataset.description||""}currentContext(){return this.hasContextTarget?this.contextTarget.value:Object.keys(this.fieldsByContextValue)[0]??null}currentFields(){return this.fieldsByContextValue[this.currentContext()]||[]}refreshHooks(){const e=this.currentContext(),t=[];for(const n of this.hookChoiceTargets){const r=n.dataset.context===e;n.hidden=!r;const o=n.querySelector('input[type="checkbox"]');o&&(r?t.push(o):o.checked=!1,n.classList.toggle("qb-hook-checked",r&&o.checked))}if(this.hasHookCountTarget){const e=t.filter(e=>e.checked).length;this.hookCountTarget.textContent=(this.labelsValue.hooks?.count||"%checked% / %total%").replace("%checked%",String(e)).replace("%total%",String(t.length))}this.hasHookEmptyTarget&&(this.hookEmptyTarget.hidden=t.length>0)}checkAllHooks(e){e.preventDefault(),this.setVisibleHooks(!0)}uncheckAllHooks(e){e.preventDefault(),this.setVisibleHooks(!1)}setVisibleHooks(e){for(const t of this.hookChoiceTargets){if(t.hidden)continue;const n=t.querySelector('input[type="checkbox"]');n&&(n.checked=e)}this.refreshHooks()}currentQuery(){return Ep(this.input?.value)}refreshFeedback(){const e=this.currentQuery(),t=Op(e),n=this.labelsValue;if(this.hasCounterTarget){const e=n.counter||{};this.counterTarget.textContent=0===t?e.none||"":1===t?e.one||"1":(e.many||"%count%").replace("%count%",String(t))}if(this.hasEmptyHintTarget&&this.emptyHintTarget.classList.toggle("qb-empty-hint-visible",0===t),this.hasSummaryTarget){this.summaryTarget.classList.toggle("qb-summary-visible",t>0);const r=this.hasSummaryTextTarget?this.summaryTextTarget:this.summaryTarget;r.replaceChildren(),t>0&&r.appendChild(Ap(e,this.currentFields(),n,0))}}};n.dn(Tp);const $p=class extends Oe{static targets=["code","displayParams","discountParams","cartDiscountParams","treeGroup"];static values={discountCode:String,cartDiscountCode:String};connect(){this.sync()}sync(){const e=this.codeTarget.value,t=e===this.discountCodeValue,n=e===this.cartDiscountCodeValue;this.displayParamsTarget.hidden=n,this.discountParamsTarget.hidden=!t,this.cartDiscountParamsTarget.hidden=!n,this.treeGroupTarget.hidden=n}};n.dn($p);const Mp=class extends Oe{static targets=["trigger"];static values={fields:Array,labels:Object,title:String,emptyHint:String};connect(){const e=window.bootstrap?.Popover;this.popovers=[];for(const t of this.triggerTargets){const n="tree"in t.dataset,r=Ep(t.dataset.tree),o=Rp(t.dataset.details),a=(!n||0===Op(r))&&0===o.length;t.classList.toggle("qb-action-summary-trigger-empty",a),e&&this.popovers.push(new e(t,{html:!0,sanitize:!1,title:this.titleValue,content:this.buildContent(n?r:null,o),trigger:"hover focus",placement:"right",container:"body",customClass:"qb-action-summary-popover"}))}}disconnect(){this.popovers.forEach(e=>e.dispose()),this.popovers=[]}buildContent(e,t){const n=document.createElement("div");if(n.className="qb-action-summary",null!==e)if(0===Op(e)){const e=document.createElement("p");e.className="qb-action-summary-empty mb-0",e.textContent=this.emptyHintValue,n.appendChild(e)}else n.appendChild(Ap(e,this.fieldsValue,this.labelsValue,0));if(t.length>0){const e=document.createElement("ul");e.className="qb-action-summary-details";for(const n of t){const t=document.createElement("li");t.textContent=n,e.appendChild(t)}n.appendChild(e)}return n}};function Rp(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>"string"==typeof e&&""!==e):[]}catch{return[]}}n.dn(Mp);const xp=class{constructor(e=document.documentElement,t=pe){this.logger=console,this.debug=!1,this.logDebugActivity=(e,t,n={})=>{this.debug&&this.logFormattedMessage(e,t,n)},this.element=e,this.schema=t,this.dispatcher=new w(this),this.router=new fe(this),this.actionDescriptorFilters=Object.assign({},S)}static start(e,t){const n=new this(e,t);return n.start(),n}async start(){await new Promise(e=>{"loading"==document.readyState?document.addEventListener("DOMContentLoaded",()=>e()):e()}),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(e,t){this.load({identifier:e,controllerConstructor:t})}registerActionOption(e,t){this.actionDescriptorFilters[e]=t}load(e,...t){(Array.isArray(e)?e:[e,...t]).forEach(e=>{e.controllerConstructor.shouldLoad&&this.router.loadDefinition(e)})}unload(e,...t){(Array.isArray(e)?e:[e,...t]).forEach(e=>this.router.unloadIdentifier(e))}get controllers(){return this.router.contexts.map(e=>e.controller)}getControllerForElementAndIdentifier(e,t){const n=this.router.getContextForElementAndIdentifier(e,t);return n?n.controller:null}handleError(e,t,n){var r;this.logger.error("%s\n\n%o\n\n%o",t,e,n),null===(r=window.onerror)||void 0===r||r.call(window,t,"",0,0,e)}logFormattedMessage(e,t,n={}){n=Object.assign({application:this},n),this.logger.groupCollapsed(`${e} #${t}`),this.logger.log("details:",Object.assign({},n)),this.logger.groupEnd()}}.start();xp.register("query-builder",yp),xp.register("qb-editor",Tp),xp.register("qb-action-form",$p),xp.register("qb-action-summary",Mp)})()})(); \ No newline at end of file