@entrypulse/builder 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,188 +1,193 @@
1
- (function(ee,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],l):(ee=typeof globalThis<"u"?globalThis:ee||self,l(ee.EntryPulse={},ee.jsxRuntime,ee.React,ee.ReactDOM))})(this,(function(ee,l,P,Bs){"use strict";var rI=Object.defineProperty;var ow=ee=>{throw TypeError(ee)};var oI=(ee,l,P)=>l in ee?rI(ee,l,{enumerable:!0,configurable:!0,writable:!0,value:P}):ee[l]=P;var ni=(ee,l,P)=>oI(ee,typeof l!="symbol"?l+"":l,P),nw=(ee,l,P)=>l.has(ee)||ow("Cannot "+P);var Bt=(ee,l,P)=>(nw(ee,l,"read from private field"),P?P.call(ee):l.get(ee)),sw=(ee,l,P)=>l.has(ee)?ow("Cannot add the same private member more than once"):l instanceof WeakSet?l.add(ee):l.set(ee,P),Eu=(ee,l,P,Bs)=>(nw(ee,l,"write to private field"),Bs?Bs.call(ee,P):l.set(ee,P),P);var mt,tr;function _u(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const S=_u(P),Tn=_u(Bs),ku=e=>{let t;const r=new Set,o=(d,p)=>{const u=typeof d=="function"?d(t):d;if(!Object.is(u,t)){const f=t;t=p??(typeof u!="object"||u===null)?u:Object.assign({},t,u),r.forEach(h=>h(t,f))}},n=()=>t,i={setState:o,getState:n,getInitialState:()=>c,subscribe:d=>(r.add(d),()=>r.delete(d))},c=t=e(o,n,i);return i},aw=(e=>e?ku(e):ku),lw=e=>e;function iw(e,t=lw){const r=P.useSyncExternalStore(e.subscribe,P.useCallback(()=>t(e.getState()),[e,t]),P.useCallback(()=>t(e.getInitialState()),[e,t]));return P.useDebugValue(r),r}const Au=e=>{const t=aw(e),r=o=>iw(t,o);return Object.assign(r,t),r},cw=(e=>e?Au(e):Au);var Du=Symbol.for("immer-nothing"),$u=Symbol.for("immer-draftable"),Qt=Symbol.for("immer-state"),dw=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Ht(e,...t){if(process.env.NODE_ENV!=="production"){const r=dw[e],o=typeof r=="function"?r.apply(null,t):r;throw new Error(`[Immer] ${o}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Pn=Object.getPrototypeOf;function rn(e){return!!e&&!!e[Qt]}function _o(e){var t;return e?Pu(e)||Array.isArray(e)||!!e[$u]||!!((t=e.constructor)!=null&&t[$u])||In(e)||Hs(e):!1}var uw=Object.prototype.constructor.toString(),Tu=new WeakMap;function Pu(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(r===Object)return!0;if(typeof r!="function")return!1;let o=Tu.get(r);return o===void 0&&(o=Function.toString.call(r),Tu.set(r,o)),o===uw}function Us(e,t,r=!0){Ws(e)===0?(r?Reflect.ownKeys(e):Object.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((o,n)=>t(n,o,e))}function Ws(e){const t=e[Qt];return t?t.type_:Array.isArray(e)?1:In(e)?2:Hs(e)?3:0}function si(e,t){return Ws(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Iu(e,t,r){const o=Ws(e);o===2?e.set(t,r):o===3?e.add(r):e[t]=r}function fw(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function In(e){return e instanceof Map}function Hs(e){return e instanceof Set}function ko(e){return e.copy_||e.base_}function ai(e,t){if(In(e))return new Map(e);if(Hs(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=Pu(e);if(t===!0||t==="class_only"&&!r){const o=Object.getOwnPropertyDescriptors(e);delete o[Qt];let n=Reflect.ownKeys(o);for(let s=0;s<n.length;s++){const a=n[s],i=o[a];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(o[a]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[a]})}return Object.create(Pn(e),o)}else{const o=Pn(e);if(o!==null&&r)return{...e};const n=Object.create(o);return Object.assign(n,e)}}function li(e,t=!1){return qs(e)||rn(e)||!_o(e)||(Ws(e)>1&&Object.defineProperties(e,{set:js,add:js,clear:js,delete:js}),Object.freeze(e),t&&Object.values(e).forEach(r=>li(r,!0))),e}function pw(){Ht(2)}var js={value:pw};function qs(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var hw={};function Ao(e){const t=hw[e];return t||Ht(0,e),t}var On;function Ou(){return On}function mw(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Mu(e,t){t&&(Ao("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ii(e){ci(e),e.drafts_.forEach(gw),e.drafts_=null}function ci(e){e===On&&(On=e.parent_)}function Lu(e){return On=mw(On,e)}function gw(e){const t=e[Qt];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Fu(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return e!==void 0&&e!==r?(r[Qt].modified_&&(ii(t),Ht(4)),_o(e)&&(e=Ys(t,e),t.parent_||Qs(t,e)),t.patches_&&Ao("Patches").generateReplacementPatches_(r[Qt].base_,e,t.patches_,t.inversePatches_)):e=Ys(t,r,[]),ii(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Du?e:void 0}function Ys(e,t,r){if(qs(t))return t;const o=e.immer_.shouldUseStrictIteration(),n=t[Qt];if(!n)return Us(t,(s,a)=>Vu(e,n,t,s,a,r),o),t;if(n.scope_!==e)return t;if(!n.modified_)return Qs(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const s=n.copy_;let a=s,i=!1;n.type_===3&&(a=new Set(s),s.clear(),i=!0),Us(a,(c,d)=>Vu(e,n,s,c,d,r,i),o),Qs(e,s,!1),r&&e.patches_&&Ao("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function Vu(e,t,r,o,n,s,a){if(n==null||typeof n!="object"&&!a)return;const i=qs(n);if(!(i&&!a)){if(process.env.NODE_ENV!=="production"&&n===r&&Ht(5),rn(n)){const c=s&&t&&t.type_!==3&&!si(t.assigned_,o)?s.concat(o):void 0,d=Ys(e,n,c);if(Iu(r,o,d),rn(d))e.canAutoFreeze_=!1;else return}else a&&r.add(n);if(_o(n)&&!i){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[o]===n&&i)return;Ys(e,n),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&(In(r)?r.has(o):Object.prototype.propertyIsEnumerable.call(r,o))&&Qs(e,n)}}}function Qs(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&li(t,r)}function bw(e,t){const r=Array.isArray(e),o={type_:r?1:0,scope_:t?t.scope_:Ou(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let n=o,s=di;r&&(n=[o],s=Mn);const{revoke:a,proxy:i}=Proxy.revocable(n,s);return o.draft_=i,o.revoke_=a,i}var di={get(e,t){if(t===Qt)return e;const r=ko(e);if(!si(r,t))return yw(e,r,t);const o=r[t];return e.finalized_||!_o(o)?o:o===ui(e.base_,t)?(pi(e),e.copy_[t]=hi(o,e)):o},has(e,t){return t in ko(e)},ownKeys(e){return Reflect.ownKeys(ko(e))},set(e,t,r){const o=Gu(ko(e),t);if(o!=null&&o.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){const n=ui(ko(e),t),s=n==null?void 0:n[Qt];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(fw(r,n)&&(r!==void 0||si(e.base_,t)))return!0;pi(e),fi(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return ui(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,pi(e),fi(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=ko(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:r[t]}},defineProperty(){Ht(11)},getPrototypeOf(e){return Pn(e.base_)},setPrototypeOf(){Ht(12)}},Mn={};Us(di,(e,t)=>{Mn[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),Mn.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Ht(13),Mn.set.call(this,e,t,void 0)},Mn.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Ht(14),di.set.call(this,e[0],t,r,e[0])};function ui(e,t){const r=e[Qt];return(r?ko(r):e)[t]}function yw(e,t,r){var n;const o=Gu(t,r);return o?"value"in o?o.value:(n=o.get)==null?void 0:n.call(e.draft_):void 0}function Gu(e,t){if(!(t in e))return;let r=Pn(e);for(;r;){const o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=Pn(r)}}function fi(e){e.modified_||(e.modified_=!0,e.parent_&&fi(e.parent_))}function pi(e){e.copy_||(e.copy_=ai(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var vw=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(r,o,n)=>{if(typeof r=="function"&&typeof o!="function"){const a=o;o=r;const i=this;return function(d=a,...p){return i.produce(d,u=>o.call(this,u,...p))}}typeof o!="function"&&Ht(6),n!==void 0&&typeof n!="function"&&Ht(7);let s;if(_o(r)){const a=Lu(this),i=hi(r,void 0);let c=!0;try{s=o(i),c=!1}finally{c?ii(a):ci(a)}return Mu(a,n),Fu(s,a)}else if(!r||typeof r!="object"){if(s=o(r),s===void 0&&(s=r),s===Du&&(s=void 0),this.autoFreeze_&&li(s,!0),n){const a=[],i=[];Ao("Patches").generateReplacementPatches_(r,s,a,i),n(a,i)}return s}else Ht(1,r)},this.produceWithPatches=(r,o)=>{if(typeof r=="function")return(i,...c)=>this.produceWithPatches(i,d=>r(d,...c));let n,s;return[this.produce(r,o,(i,c)=>{n=i,s=c}),n,s]},typeof(t==null?void 0:t.autoFreeze)=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof(t==null?void 0:t.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof(t==null?void 0:t.useStrictIteration)=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){_o(t)||Ht(8),rn(t)&&(t=xw(t));const r=Lu(this),o=hi(t,void 0);return o[Qt].isManual_=!0,ci(r),o}finishDraft(t,r){const o=t&&t[Qt];(!o||!o.isManual_)&&Ht(9);const{scope_:n}=o;return Mu(n,r),Fu(void 0,n)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,r){let o;for(o=r.length-1;o>=0;o--){const s=r[o];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}o>-1&&(r=r.slice(o+1));const n=Ao("Patches").applyPatches_;return rn(t)?n(t,r):this.produce(t,s=>n(s,r))}};function hi(e,t){const r=In(e)?Ao("MapSet").proxyMap_(e,t):Hs(e)?Ao("MapSet").proxySet_(e,t):bw(e,t);return(t?t.scope_:Ou()).drafts_.push(r),r}function xw(e){return rn(e)||Ht(10,e),zu(e)}function zu(e){if(!_o(e)||qs(e))return e;const t=e[Qt];let r,o=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=ai(e,t.scope_.immer_.useStrictShallowCopy_),o=t.scope_.immer_.shouldUseStrictIteration()}else r=ai(e,!0);return Us(r,(n,s)=>{Iu(r,n,zu(s))},o),t&&(t.finalized_=!1),r}var ww=new vw,Sw=ww.produce;const Nw=e=>(t,r,o)=>(o.setState=(n,s,...a)=>{const i=typeof n=="function"?Sw(n):n;return t(i,s,...a)},e(o.setState,r,o));function Ks(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return`${e}-${t}`}function mi(e){if(!e)return"";const t=e.trim().replace(/[^a-zA-Z0-9\s]/g,"").split(/\s+/).filter(Boolean);return t.length===0?"":t.map((r,o)=>{const n=r.toLowerCase();return o===0?n:n.charAt(0).toUpperCase()+n.slice(1)}).join("")}function Bu(e,t){const r=t instanceof Set?t:new Set(t),o=mi(e.replace(/([A-Z])/g," $1").trim())||"field";if(!r.has(o))return o;let n=1,s=`${o}${n}`;for(;r.has(s);)n++,s=`${o}${n}`;return s}function gi(e){return new Set(e.map(t=>t.attributes.name).filter(Boolean))}const Cw={shortText:{label:"Short Text",placeholder:"Enter text..."},longText:{label:"Long Text",placeholder:"Enter your text here..."},multiLineInput:{label:"Multi-line Input",placeholder:"Enter your text..."},textEditor:{label:"Text Editor",placeholder:"Start typing..."},number:{label:"Number",placeholder:"Enter a number..."},slider:{label:"Slider",description:"Slide to select a value"},rangeSlider:{label:"Range Slider",description:"Select a range"},email:{label:"Email",placeholder:"Enter your email..."},phone:{label:"Phone",placeholder:"Enter your phone number..."},url:{label:"URL",placeholder:"https://example.com"},location:{label:"Location",placeholder:"Enter address...",description:"Enter your address"},password:{label:"Password",placeholder:"Enter your password..."},signature:{label:"Signature",description:"Draw your signature below"},captcha:{label:"Verification",description:"Please verify you are human"},singleChoice:{label:"Single Choice",description:"Select one option"},multipleChoice:{label:"Multiple Choice",description:"Select all that apply"},dropdown:{label:"Dropdown",placeholder:"Select an option..."},tags:{label:"Tags",placeholder:"Type and press enter...",description:"Add tags"},decisionBox:{label:"I agree to the terms and conditions"},toggleSwitch:{label:"Toggle Switch",description:"Turn on or off"},singleChoiceMatrix:{label:"Single Choice Matrix",description:"Select one option per row"},multipleChoiceMatrix:{label:"Multiple Choice Matrix",description:"Select options per row"},matrixTable:{label:"Matrix Table",description:"Fill in the table"},date:{label:"Date",placeholder:"Select a date..."},time:{label:"Time",placeholder:"Select a time..."},dateTime:{label:"Date & Time",placeholder:"Select date and time..."},multipleDates:{label:"Multiple Dates",placeholder:"Select dates...",description:"Select multiple dates"},dateRange:{label:"Date Range",placeholder:"Select date range...",description:"Select start and end dates"},fileUpload:{label:"File Upload",description:"Upload a file"},imageUpload:{label:"Image Upload",description:"Upload an image"},multiFileUpload:{label:"Multi-File Upload",description:"Upload multiple files"},multiImageUpload:{label:"Multi-Image Upload",description:"Upload multiple images"},paragraph:{label:"Paragraph",content:"Enter your paragraph text here. You can use this to provide instructions or additional information."},image:{label:"Image",alt:"Image description",src:""},link:{label:"Link",href:"https://example.com",content:"Click here",target:"_blank"},formHeading:{label:"Form Title",description:"Form description goes here"},sectionHeading:{label:"Section Title"},subheading:{label:"Subheading"},divider:{},spacer:{},group:{label:"Group",description:"Group description"},grid:{label:"Grid Layout"},table:{label:"Table"},repeatElement:{label:"Repeat Element",description:"Add more items"},repeatGroup:{label:"Repeat Group",description:"Add more groups"},pages:{label:"Form Pages"},submit:{label:"Submit"}},Ew={shortText:{labelPosition:"top",size:"default"},longText:{labelPosition:"top",size:"default"},multiLineInput:{labelPosition:"top",size:"default"},textEditor:{labelPosition:"top",size:"large"},number:{labelPosition:"top",size:"default"},slider:{labelPosition:"top",size:"default"},rangeSlider:{labelPosition:"top",size:"default"},email:{labelPosition:"top",size:"default"},phone:{labelPosition:"top",size:"default"},url:{labelPosition:"top",size:"default"},location:{labelPosition:"top",size:"large"},password:{labelPosition:"top",size:"default"},signature:{labelPosition:"top",size:"large"},captcha:{labelPosition:"hidden",size:"default"},singleChoice:{labelPosition:"top",size:"default"},multipleChoice:{labelPosition:"top",size:"default"},dropdown:{labelPosition:"top",size:"default"},tags:{labelPosition:"top",size:"default"},decisionBox:{labelPosition:"hidden",size:"default"},toggleSwitch:{labelPosition:"left",size:"default"},singleChoiceMatrix:{labelPosition:"top",size:"full"},multipleChoiceMatrix:{labelPosition:"top",size:"full"},matrixTable:{labelPosition:"top",size:"full"},date:{labelPosition:"top",size:"default"},time:{labelPosition:"top",size:"small"},dateTime:{labelPosition:"top",size:"default"},multipleDates:{labelPosition:"top",size:"default"},dateRange:{labelPosition:"top",size:"default"},fileUpload:{labelPosition:"top",size:"default"},imageUpload:{labelPosition:"top",size:"default"},multiFileUpload:{labelPosition:"top",size:"large"},multiImageUpload:{labelPosition:"top",size:"large"},paragraph:{labelPosition:"hidden",size:"default"},image:{labelPosition:"hidden",size:"default"},link:{labelPosition:"hidden",size:"default"},formHeading:{size:"large"},sectionHeading:{size:"medium"},subheading:{size:"small"},divider:{size:"default"},spacer:{size:"default",height:24},group:{size:"default"},grid:{size:"full",columns:2,gap:16},table:{size:"full"},repeatElement:{size:"default"},repeatGroup:{size:"full"},pages:{size:"full"},submit:{size:"default"}},Uu={shortText:{maxLength:255},longText:{maxLength:5e3},multiLineInput:{maxLength:5e3},textEditor:{maxLength:5e4},number:{},slider:{},rangeSlider:{},email:{},phone:{},url:{},location:{},password:{minLength:8},singleChoice:{},multipleChoice:{},dropdown:{},tags:{},decisionBox:{},singleChoiceMatrix:{},multipleChoiceMatrix:{},date:{},time:{},dateTime:{},multipleDates:{},dateRange:{},fileUpload:{},imageUpload:{},multiFileUpload:{maxFiles:10},multiImageUpload:{maxFiles:10}},Wu={longText:{rows:3,autoResize:!1},multiLineInput:{minRows:2,maxRows:10,autoResize:!0},textEditor:{toolbar:["bold","italic","underline","link"],height:200,allowImages:!1,allowLinks:!0},number:{step:1,decimals:0,thousandsSeparator:!1},slider:{min:0,max:100,step:1,showValue:!0,showMarks:!1},rangeSlider:{min:0,max:100,step:1,showValue:!0,minRange:0},phone:{defaultCountry:"US",format:"international"},location:{enableGeolocation:!1,showMap:!1},password:{showStrengthMeter:!0,showToggle:!0,minStrength:"medium"},signature:{strokeWidth:2,strokeColor:"#000000",backgroundColor:"#ffffff",canvasWidth:400,canvasHeight:200},captcha:{provider:"recaptcha",theme:"light"},singleChoice:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],allowOther:!1},multipleChoice:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],allowOther:!1},dropdown:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],allowOther:!1},tags:{options:[{label:"Tag 1",value:"tag1"},{label:"Tag 2",value:"tag2"},{label:"Tag 3",value:"tag3"}],maxTags:10,allowCustomTags:!0},decisionBox:{checkedLabel:"Yes",uncheckedLabel:"No"},toggleSwitch:{onLabel:"On",offLabel:"Off"},singleChoiceMatrix:{matrixRows:[{id:"row1",label:"Row 1"},{id:"row2",label:"Row 2"},{id:"row3",label:"Row 3"}],matrixColumns:[{id:"col1",label:"Column 1"},{id:"col2",label:"Column 2"},{id:"col3",label:"Column 3"}]},multipleChoiceMatrix:{matrixRows:[{id:"row1",label:"Row 1"},{id:"row2",label:"Row 2"},{id:"row3",label:"Row 3"}],matrixColumns:[{id:"col1",label:"Column 1"},{id:"col2",label:"Column 2"},{id:"col3",label:"Column 3"}],allowMultiplePerRow:!0},matrixTable:{matrixRows:[{id:"row1",label:"Row 1"},{id:"row2",label:"Row 2"}],matrixColumns:[{id:"col1",label:"Text",type:"text"},{id:"col2",label:"Number",type:"number"}]},date:{format:"YYYY-MM-DD",showCalendar:!0},time:{timeFormat:"12h",timeInterval:15},dateTime:{format:"YYYY-MM-DD",timeFormat:"12h",timeInterval:15},multipleDates:{format:"YYYY-MM-DD",showCalendar:!0},dateRange:{format:"YYYY-MM-DD",showCalendar:!0,minDays:1},fileUpload:{accept:"*/*",maxSize:10485760,multiple:!1},imageUpload:{accept:"image/*",maxSize:5242880,multiple:!1,allowCrop:!1},multiFileUpload:{accept:"*/*",maxSize:10485760,multiple:!0,maxFiles:10},multiImageUpload:{accept:"image/*",maxSize:5242880,multiple:!0,maxFiles:10,allowCrop:!1},paragraph:{textAlign:"left",fontSize:"medium",fontWeight:"normal"},image:{imageWidth:"100%",objectFit:"contain",borderRadius:0},link:{linkStyle:"text"},formHeading:{level:1,alignment:"left"},sectionHeading:{level:2,alignment:"left"},subheading:{level:3,alignment:"left"},divider:{style:"solid",thickness:1,color:"#e5e7eb"},spacer:{spacerHeight:24},group:{collapsed:!1,collapsible:!1,showBorder:!0,padding:16},grid:{gridColumns:2,gridGap:16,responsiveColumns:{sm:1,md:2,lg:2}},table:{tableColumns:[{id:"col1",header:"Column 1",align:"left"},{id:"col2",header:"Column 2",align:"left"}],showHeader:!0,striped:!0,bordered:!0},repeatElement:{minItems:1,maxItems:10,addButtonText:"Add Item",removeButtonText:"Remove",showItemNumber:!0},repeatGroup:{minItems:1,maxItems:10,addButtonText:"Add Group",removeButtonText:"Remove",itemLabel:"Item",showItemNumber:!0},pages:{showProgressBar:!0,showStepNumbers:!0,allowSkip:!1,validateOnNext:!0,nextButtonLabel:"Next",activeStepId:"step1",steps:[{id:"step1",label:"Step 1",description:""},{id:"step2",label:"Step 2",description:""}]},submit:{buttonText:"Submit",buttonStyle:"primary",buttonSize:"medium",showIcon:!1,loadingText:"Submitting..."}},_w={shortText:"string",longText:"string",multiLineInput:"string",textEditor:"string",number:"number",slider:"number",rangeSlider:"object",email:"string",phone:"string",url:"string",location:"object",password:"string",signature:"string",captcha:"string",singleChoice:"string",multipleChoice:"array",dropdown:"string",tags:"array",decisionBox:"boolean",toggleSwitch:"boolean",singleChoiceMatrix:"object",multipleChoiceMatrix:"object",matrixTable:"object",date:"date",time:"string",dateTime:"date",multipleDates:"array",dateRange:"object",fileUpload:"object",imageUpload:"object",multiFileUpload:"array",multiImageUpload:"array",paragraph:"string",image:"string",link:"string",formHeading:"string",sectionHeading:"string",subheading:"string",divider:"string",spacer:"string",group:"object",grid:"object",table:"object",repeatElement:"array",repeatGroup:"array",pages:"object",submit:"string"};function Hu(e,t,r){const o=Bu(e,t),n={id:Ks(),type:e,order:r,properties:{...Cw[e]},layout:{...Ew[e]},attributes:{name:o,dataType:_w[e]}};return Uu[e]&&(n.validation={...Uu[e]}),Wu[e]&&(n.config=JSON.parse(JSON.stringify(Wu[e]))),n}function ju(){return{id:`form-${Ks()}`,version:"1.0.0",title:"Untitled Form",description:"",metadata:{createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},settings:{showProgressBar:!1,allowSaveDraft:!1,submitButtonText:"Submit",successMessage:"Thank you for your submission!",submitAction:"message"},elements:[]}}function kw(e,t){const r=JSON.parse(JSON.stringify(e));return r.id=Ks(),r.attributes.name=Bu(e.type,t),r}function bi(e){return["paragraph","image","link","formHeading","sectionHeading","subheading","divider","spacer"].includes(e)}function Aw(e){const t=["paragraph","image","link","formHeading","sectionHeading","subheading","divider","spacer","captcha"],r=["singleChoice","dropdown","decisionBox","toggleSwitch","signature","captcha",...t],o=["number","slider","rangeSlider","date","time","dateTime","multipleDates","dateRange","fileUpload","imageUpload","multiFileUpload","multiImageUpload","singleChoice","multipleChoice","dropdown","decisionBox","toggleSwitch","signature","captcha","singleChoiceMatrix","multipleChoiceMatrix","matrixTable",...t];return{supportsRequired:!t.includes(e),supportsMinMax:!r.includes(e),supportsPattern:!o.includes(e)}}const Dw=50;function or(e,t){const r=e.history.slice(0,e.historyIndex+1);r.push(JSON.parse(JSON.stringify(t))),r.length>Dw&&r.shift(),e.history=r,e.historyIndex=r.length-1,e.schema=t}const qu=ju(),$w={schema:qu,selectedElementId:null,mode:"design",history:[JSON.parse(JSON.stringify(qu))],historyIndex:0,hoveredElementId:null,draggedElementType:null},te=cw()(Nw((e,t)=>({...$w,addElement:(r,o)=>{e(n=>{var p;const s=n.schema.elements.some(u=>u.type==="pages");if(r==="pages"&&s){console.warn("Only one wizard can be added to the form");return}if(s&&r!=="pages"){console.warn("When a wizard exists, elements must be added inside wizard steps");return}const a=gi(n.schema.elements),i=o??n.schema.elements.length,c=Hu(r,a,i);(r==="group"||r==="grid"||r==="repeatGroup"||r==="pages")&&(c.children=[]);const d={...n.schema};o!==void 0?d.elements=[...n.schema.elements.slice(0,o),c,...n.schema.elements.slice(o).map(u=>({...u,order:u.order+1}))]:d.elements=[...n.schema.elements,c],d.metadata={...d.metadata,updatedAt:new Date().toISOString(),createdAt:((p=d.metadata)==null?void 0:p.createdAt)||new Date().toISOString()},or(n,d),n.selectedElementId=c.id})},addElementToContainer:(r,o,n)=>{e(s=>{var f;if(r==="pages"){console.warn("Wizard cannot be added inside a container");return}if(s.schema.elements.findIndex(h=>h.id===o)===-1)return;const i=gi(s.schema.elements),d=s.schema.elements.filter(h=>n?h.parentId===`${o}:${n}`:h.parentId===o).length,p=Hu(r,i,d);n?p.parentId=`${o}:${n}`:p.parentId=o,(r==="group"||r==="grid"||r==="repeatGroup")&&(p.children=[]);const u={...s.schema};u.elements=s.schema.elements.map(h=>h.id===o?{...h,children:[...h.children||[],p.id]}:h),u.elements=[...u.elements,p],u.metadata={...u.metadata,updatedAt:new Date().toISOString(),createdAt:((f=u.metadata)==null?void 0:f.createdAt)||new Date().toISOString()},or(s,u),s.selectedElementId=p.id})},updateElement:(r,o)=>{e(n=>{var i;if(n.schema.elements.findIndex(c=>c.id===r)===-1)return;const a={...n.schema};a.elements=n.schema.elements.map(c=>c.id===r?{...c,...o}:c),a.metadata={...a.metadata,updatedAt:new Date().toISOString(),createdAt:((i=a.metadata)==null?void 0:i.createdAt)||new Date().toISOString()},or(n,a)})},deleteElement:r=>{e(o=>{var c;const n=o.schema.elements.find(d=>d.id===r);if(!n)return;const s=new Set([r]),a=d=>{o.schema.elements.forEach(p=>{var u;(p.parentId===d||(u=p.parentId)!=null&&u.startsWith(`${d}:`))&&(s.add(p.id),a(p.id))})};a(r);const i={...o.schema};if(n.parentId){const d=n.parentId.split(":")[0];i.elements=o.schema.elements.map(p=>p.id===d&&p.children?{...p,children:p.children.filter(u=>u!==r)}:p)}i.elements=i.elements.filter(d=>!s.has(d.id)).map((d,p)=>d.parentId?d:{...d,order:p}),i.metadata={...i.metadata,updatedAt:new Date().toISOString(),createdAt:((c=i.metadata)==null?void 0:c.createdAt)||new Date().toISOString()},or(o,i),(o.selectedElementId===r||s.has(o.selectedElementId||""))&&(o.selectedElementId=null)})},duplicateElement:r=>{e(o=>{var d;const n=o.schema.elements.find(p=>p.id===r);if(!n)return;const s=gi(o.schema.elements),a=kw(n,s);a.order=n.order+1;const i={...o.schema},c=n.order+1;i.elements=[...o.schema.elements.slice(0,c),a,...o.schema.elements.slice(c).map(p=>({...p,order:p.order+1}))],i.metadata={...i.metadata,updatedAt:new Date().toISOString(),createdAt:((d=i.metadata)==null?void 0:d.createdAt)||new Date().toISOString()},or(o,i),o.selectedElementId=a.id})},moveElement:(r,o)=>{e(n=>{var d;const s=n.schema.elements.findIndex(p=>p.id===r);if(s===-1||s===o)return;const a=[...n.schema.elements],[i]=a.splice(s,1);a.splice(o,0,i),a.forEach((p,u)=>{p.order=u});const c={...n.schema,elements:a,metadata:{...n.schema.metadata,updatedAt:new Date().toISOString(),createdAt:((d=n.schema.metadata)==null?void 0:d.createdAt)||new Date().toISOString()}};or(n,c)})},reorderElements:(r,o)=>{e(n=>{var c;if(r===o)return;const s=[...n.schema.elements],[a]=s.splice(r,1);s.splice(o,0,a),s.forEach((d,p)=>{d.order=p});const i={...n.schema,elements:s,metadata:{...n.schema.metadata,updatedAt:new Date().toISOString(),createdAt:((c=n.schema.metadata)==null?void 0:c.createdAt)||new Date().toISOString()}};or(n,i)})},selectElement:r=>{e(o=>{o.selectedElementId=r})},undo:()=>{e(r=>{r.historyIndex>0&&(r.historyIndex-=1,r.schema=JSON.parse(JSON.stringify(r.history[r.historyIndex])),r.selectedElementId=null)})},redo:()=>{e(r=>{r.historyIndex<r.history.length-1&&(r.historyIndex+=1,r.schema=JSON.parse(JSON.stringify(r.history[r.historyIndex])),r.selectedElementId=null)})},canUndo:()=>t().historyIndex>0,canRedo:()=>{const r=t();return r.historyIndex<r.history.length-1},setMode:r=>{e(o=>{o.mode=r})},loadSchema:r=>{e(o=>{o.schema=r,o.history=[JSON.parse(JSON.stringify(r))],o.historyIndex=0,o.selectedElementId=null})},exportSchema:()=>JSON.parse(JSON.stringify(t().schema)),resetForm:()=>{e(r=>{const o=ju();r.schema=o,r.history=[JSON.parse(JSON.stringify(o))],r.historyIndex=0,r.selectedElementId=null})},updateFormTitle:r=>{e(o=>{var s;const n={...o.schema,title:r,metadata:{...o.schema.metadata,updatedAt:new Date().toISOString(),createdAt:((s=o.schema.metadata)==null?void 0:s.createdAt)||new Date().toISOString()}};or(o,n)})},updateFormDescription:r=>{e(o=>{var s;const n={...o.schema,description:r,metadata:{...o.schema.metadata,updatedAt:new Date().toISOString(),createdAt:((s=o.schema.metadata)==null?void 0:s.createdAt)||new Date().toISOString()}};or(o,n)})},setHoveredElementId:r=>{e(o=>{o.hoveredElementId=r})},setDraggedElementType:r=>{e(o=>{o.draggedElementType=r})},hasWizard:()=>t().schema.elements.some(r=>r.type==="pages"),addWizardStep:(r,o)=>{e(n=>{var a;const s={...n.schema};s.elements=n.schema.elements.map(i=>{var c,d;if(i.id===r&&i.type==="pages"){const p=((c=i.config)==null?void 0:c.steps)||[];return{...i,config:{...i.config,steps:[...p,o],activeStepId:((d=i.config)==null?void 0:d.activeStepId)||o.id}}}return i}),s.metadata={...s.metadata,updatedAt:new Date().toISOString(),createdAt:((a=s.metadata)==null?void 0:a.createdAt)||new Date().toISOString()},or(n,s)})},updateWizardStep:(r,o,n)=>{e(s=>{var i;const a={...s.schema};a.elements=s.schema.elements.map(c=>{var d;if(c.id===r&&c.type==="pages"){const p=(((d=c.config)==null?void 0:d.steps)||[]).map(u=>u.id===o?{...u,...n}:u);return{...c,config:{...c.config,steps:p}}}return c}),a.metadata={...a.metadata,updatedAt:new Date().toISOString(),createdAt:((i=a.metadata)==null?void 0:i.createdAt)||new Date().toISOString()},or(s,a)})},removeWizardStep:(r,o)=>{e(n=>{var u,f;const s=n.schema.elements.find(h=>h.id===r);if(!s||s.type!=="pages")return;const a=((u=s.config)==null?void 0:u.steps)||[];if(a.length<=1){console.warn("Wizard must have at least one step");return}const i=`${r}:${o}`,c=new Set,d=h=>{n.schema.elements.forEach(g=>{var y;(g.parentId===h||(y=g.parentId)!=null&&y.startsWith(`${h}:`))&&(c.add(g.id),d(g.id))})};d(i);const p={...n.schema};p.elements=n.schema.elements.map(h=>{var g,y,b;if(h.id===r){const v=a.filter(x=>x.id!==o),N=((g=h.config)==null?void 0:g.activeStepId)===o?(y=v[0])==null?void 0:y.id:(b=h.config)==null?void 0:b.activeStepId;return{...h,config:{...h.config,steps:v,activeStepId:N},children:(h.children||[]).filter(x=>!c.has(x))}}return h}),p.elements=p.elements.filter(h=>!c.has(h.id)),p.metadata={...p.metadata,updatedAt:new Date().toISOString(),createdAt:((f=p.metadata)==null?void 0:f.createdAt)||new Date().toISOString()},or(n,p)})},setActiveWizardStep:(r,o)=>{e(n=>{const s={...n.schema};s.elements=n.schema.elements.map(a=>a.id===r&&a.type==="pages"?{...a,config:{...a.config,activeStepId:o}}:a),n.schema=s})},getContainerChildren:(r,o)=>{const n=t(),s=o?`${r}:${o}`:r;return n.schema.elements.filter(a=>a.parentId===s).sort((a,i)=>a.order-i.order)},validateSchema:()=>{const r=t(),o=[],n=r.schema.elements.map(a=>a.attributes.name),s=n.filter((a,i)=>n.indexOf(a)!==i);return s.length>0&&s.forEach(a=>{o.push({type:"error",message:`Duplicate field name: "${a}"`})}),r.schema.elements.forEach(a=>{(!a.attributes.name||a.attributes.name.trim()==="")&&o.push({type:"error",elementId:a.id,message:`Element "${a.properties.label||a.type}" has no field name`})}),r.schema.elements.forEach(a=>{var i;(i=a.validation)!=null&&i.required&&(!a.properties.label||a.properties.label.trim()==="")&&o.push({type:"warning",elementId:a.id,message:"Required element has no label"})}),{valid:o.filter(a=>a.type==="error").length===0,errors:o}}})));function Tw(){const e=t=>{const o=navigator.platform.toUpperCase().indexOf("MAC")>=0?t.metaKey:t.ctrlKey;o&&t.key==="z"&&!t.shiftKey?(t.preventDefault(),te.getState().undo()):(o&&t.shiftKey&&t.key==="z"||o&&t.key==="y")&&(t.preventDefault(),te.getState().redo())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)}const Pw=()=>{const e=te(r=>r.selectedElementId);return te(r=>r.schema.elements).find(r=>r.id===e)};class Iw{constructor(){ni(this,"elements",new Map);ni(this,"customGroups",new Map)}register(t,r={}){const{override:o=!1,group:n}=r;if(this.elements.has(t.type)&&!o){console.warn(`Element type "${t.type}" is already registered. Use { override: true } to replace it.`);return}if(!t.type)throw new Error("Element definition must have a type");if(!t.renderOnCanvas)throw new Error(`Element "${t.type}" must have a renderOnCanvas function`);if(!t.render)throw new Error(`Element "${t.type}" must have a render function`);if(!t.getDefaultValues)throw new Error(`Element "${t.type}" must have a getDefaultValues function`);if(this.elements.set(t.type,t),n){const s=this.customGroups.get(n);s?s.elements.push(t):this.customGroups.set(n,{id:n,label:n,elements:[t]})}}get(t){return this.elements.get(t)}has(t){return this.elements.has(t)}getAll(){return Array.from(this.elements.values())}getByCategory(t){return this.getAll().filter(r=>r.category===t)}getByStructure(t){return this.getAll().filter(r=>r.structure===t)}getByTypeCategory(t){return this.getAll().filter(r=>r.typeCategory===t)}getGroups(){const t=[],r={textInput:{label:"Text Input",order:1},numeric:{label:"Numeric",order:2},contact:{label:"Contact",order:3},security:{label:"Security",order:4},selection:{label:"Selection",order:5},matrix:{label:"Matrix",order:6},dateTime:{label:"Date & Time",order:7},fileUpload:{label:"File Upload",order:8},display:{label:"Display",order:9},product:{label:"Porduct",order:10},payment:{label:"Payment",order:11},orther:{label:"Other",order:12}},o={heading:{label:"Headings",order:10},layout:{label:"Layout",order:11},repeatable:{label:"Repeatable",order:12},special:{label:"Special",order:13}};for(const[n,s]of Object.entries(r)){const a=this.getAll().filter(i=>i.category==="field"&&i.subCategory===n);a.length>0&&t.push({id:n,label:s.label,elements:a,order:s.order})}for(const[n,s]of Object.entries(o)){const a=this.getAll().filter(i=>i.category==="page"&&i.subCategory===n);a.length>0&&t.push({id:n,label:s.label,elements:a,order:s.order})}for(const n of this.customGroups.values())t.push({...n,order:n.order??100});return t.sort((n,s)=>(n.order??0)-(s.order??0))}unregister(t){if(!this.elements.has(t))return!1;this.elements.delete(t);for(const r of this.customGroups.values()){const o=r.elements.findIndex(n=>n.type===t);o!==-1&&r.elements.splice(o,1)}return!0}clear(){this.elements.clear(),this.customGroups.clear()}getIcon(t){const r=this.get(t);return r==null?void 0:r.icon}getLabel(t){const r=this.get(t);return r==null?void 0:r.label}isContainer(t){const r=this.get(t);return(r==null?void 0:r.isContainer)??!1}supportsValidation(t){const r=this.get(t);return(r==null?void 0:r.supportsValidation)??!0}supportsOptions(t){const r=this.get(t);return(r==null?void 0:r.supportsOptions)??!1}getDefaultValues(t){const r=this.get(t);return r?r.getDefaultValues():{properties:{},layout:{},validation:{},config:{}}}}const ut=new Iw;function Ow(e,t){ut.register(e,t)}function Mw(e,t){for(const r of e)ut.register(r,t)}function Lw(e){return ut.unregister(e)}function Fw(e){return ut.get(e)}function Vw(e){return ut.has(e)}function Yu(e){var t,r,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(t=0;t<n;t++)e[t]&&(r=Yu(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}function Qu(){for(var e,t,r=0,o="",n=arguments.length;r<n;r++)(e=arguments[r])&&(t=Yu(e))&&(o&&(o+=" "),o+=t);return o}const Gw=(e,t)=>{const r=new Array(e.length+t.length);for(let o=0;o<e.length;o++)r[o]=e[o];for(let o=0;o<t.length;o++)r[e.length+o]=t[o];return r},zw=(e,t)=>({classGroupId:e,validator:t}),Ku=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Rs="-",Ru=[],Bw="arbitrary..",Uw=e=>{const t=Hw(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return Ww(a);const i=a.split(Rs),c=i[0]===""&&i.length>1?1:0;return Xu(i,c,t)},getConflictingClassGroupIds:(a,i)=>{if(i){const c=o[a],d=r[a];return c?d?Gw(d,c):c:d||Ru}return r[a]||Ru}}},Xu=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const n=e[t],s=r.nextPart.get(n);if(s){const d=Xu(e,t+1,s);if(d)return d}const a=r.validators;if(a===null)return;const i=t===0?e.join(Rs):e.slice(t).join(Rs),c=a.length;for(let d=0;d<c;d++){const p=a[d];if(p.validator(i))return p.classGroupId}},Ww=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),o=t.slice(0,r);return o?Bw+o:void 0})(),Hw=e=>{const{theme:t,classGroups:r}=e;return jw(r,t)},jw=(e,t)=>{const r=Ku();for(const o in e){const n=e[o];yi(n,r,o,t)}return r},yi=(e,t,r,o)=>{const n=e.length;for(let s=0;s<n;s++){const a=e[s];qw(a,t,r,o)}},qw=(e,t,r,o)=>{if(typeof e=="string"){Yw(e,t,r);return}if(typeof e=="function"){Qw(e,t,r,o);return}Kw(e,t,r,o)},Yw=(e,t,r)=>{const o=e===""?t:Ju(t,e);o.classGroupId=r},Qw=(e,t,r,o)=>{if(Rw(e)){yi(e(o),t,r,o);return}t.validators===null&&(t.validators=[]),t.validators.push(zw(r,e))},Kw=(e,t,r,o)=>{const n=Object.entries(e),s=n.length;for(let a=0;a<s;a++){const[i,c]=n[a];yi(c,Ju(t,i),r,o)}},Ju=(e,t)=>{let r=e;const o=t.split(Rs),n=o.length;for(let s=0;s<n;s++){const a=o[s];let i=r.nextPart.get(a);i||(i=Ku(),r.nextPart.set(a,i)),r=i}return r},Rw=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Xw=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),o=Object.create(null);const n=(s,a)=>{r[s]=a,t++,t>e&&(t=0,o=r,r=Object.create(null))};return{get(s){let a=r[s];if(a!==void 0)return a;if((a=o[s])!==void 0)return n(s,a),a},set(s,a){s in r?r[s]=a:n(s,a)}}},vi="!",Zu=":",Jw=[],ef=(e,t,r,o,n)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:o,isExternal:n}),Zw=e=>{const{prefix:t,experimentalParseClassName:r}=e;let o=n=>{const s=[];let a=0,i=0,c=0,d;const p=n.length;for(let y=0;y<p;y++){const b=n[y];if(a===0&&i===0){if(b===Zu){s.push(n.slice(c,y)),c=y+1;continue}if(b==="/"){d=y;continue}}b==="["?a++:b==="]"?a--:b==="("?i++:b===")"&&i--}const u=s.length===0?n:n.slice(c);let f=u,h=!1;u.endsWith(vi)?(f=u.slice(0,-1),h=!0):u.startsWith(vi)&&(f=u.slice(1),h=!0);const g=d&&d>c?d-c:void 0;return ef(s,h,f,g)};if(t){const n=t+Zu,s=o;o=a=>a.startsWith(n)?s(a.slice(n.length)):ef(Jw,!1,a,void 0,!0)}if(r){const n=o;o=s=>r({className:s,parseClassName:n})}return o},e0=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,o)=>{t.set(r,1e6+o)}),r=>{const o=[];let n=[];for(let s=0;s<r.length;s++){const a=r[s],i=a[0]==="[",c=t.has(a);i||c?(n.length>0&&(n.sort(),o.push(...n),n=[]),o.push(a)):n.push(a)}return n.length>0&&(n.sort(),o.push(...n)),o}},t0=e=>({cache:Xw(e.cacheSize),parseClassName:Zw(e),sortModifiers:e0(e),postfixLookupClassGroupIds:r0(e),...Uw(e)}),r0=e=>{const t=Object.create(null),r=e.postfixLookupClassGroups;if(r)for(let o=0;o<r.length;o++)t[r[o]]=!0;return t},o0=/\s+/,n0=(e,t)=>{const{parseClassName:r,getClassGroupId:o,getConflictingClassGroupIds:n,sortModifiers:s,postfixLookupClassGroupIds:a}=t,i=[],c=e.trim().split(o0);let d="";for(let p=c.length-1;p>=0;p-=1){const u=c[p],{isExternal:f,modifiers:h,hasImportantModifier:g,baseClassName:y,maybePostfixModifierPosition:b}=r(u);if(f){d=u+(d.length>0?" "+d:d);continue}let v=!!b,N;if(v){const k=y.substring(0,b);N=o(k);const _=N&&a[N]?o(y):void 0;_&&_!==N&&(N=_,v=!1)}else N=o(y);if(!N){if(!v){d=u+(d.length>0?" "+d:d);continue}if(N=o(y),!N){d=u+(d.length>0?" "+d:d);continue}v=!1}const x=h.length===0?"":h.length===1?h[0]:s(h).join(":"),w=g?x+vi:x,C=w+N;if(i.indexOf(C)>-1)continue;i.push(C);const E=n(N,v);for(let k=0;k<E.length;++k){const _=E[k];i.push(w+_)}d=u+(d.length>0?" "+d:d)}return d},s0=(...e)=>{let t=0,r,o,n="";for(;t<e.length;)(r=e[t++])&&(o=tf(r))&&(n&&(n+=" "),n+=o);return n},tf=e=>{if(typeof e=="string")return e;let t,r="";for(let o=0;o<e.length;o++)e[o]&&(t=tf(e[o]))&&(r&&(r+=" "),r+=t);return r},rf=(e,...t)=>{let r,o,n,s;const a=c=>{const d=t.reduce((p,u)=>u(p),e());return r=t0(d),o=r.cache.get,n=r.cache.set,s=i,i(c)},i=c=>{const d=o(c);if(d)return d;const p=n0(c,r);return n(c,p),p};return s=a,(...c)=>s(s0(...c))},a0=[],gt=e=>{const t=r=>r[e]||a0;return t.isThemeGetter=!0,t},of=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,nf=/^\((?:(\w[\w-]*):)?(.+)\)$/i,l0=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,i0=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,c0=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,d0=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,u0=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,f0=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,uo=e=>l0.test(e),De=e=>!!e&&!Number.isNaN(Number(e)),Ar=e=>!!e&&Number.isInteger(Number(e)),xi=e=>e.endsWith("%")&&De(e.slice(0,-1)),qr=e=>i0.test(e),sf=()=>!0,p0=e=>c0.test(e)&&!d0.test(e),wi=()=>!1,h0=e=>u0.test(e),m0=e=>f0.test(e),g0=e=>!se(e)&&!le(e),b0=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),y0=e=>fo(e,ff,wi),se=e=>of.test(e),Do=e=>fo(e,pf,p0),af=e=>fo(e,_0,De),v0=e=>fo(e,mf,sf),x0=e=>fo(e,hf,wi),lf=e=>fo(e,df,wi),w0=e=>fo(e,uf,m0),Xs=e=>fo(e,gf,h0),le=e=>nf.test(e),Ln=e=>$o(e,pf),S0=e=>$o(e,hf),cf=e=>$o(e,df),N0=e=>$o(e,ff),C0=e=>$o(e,uf),Js=e=>$o(e,gf,!0),E0=e=>$o(e,mf,!0),fo=(e,t,r)=>{const o=of.exec(e);return o?o[1]?t(o[1]):r(o[2]):!1},$o=(e,t,r=!1)=>{const o=nf.exec(e);return o?o[1]?t(o[1]):r:!1},df=e=>e==="position"||e==="percentage",uf=e=>e==="image"||e==="url",ff=e=>e==="length"||e==="size"||e==="bg-size",pf=e=>e==="length",_0=e=>e==="number",hf=e=>e==="family-name",mf=e=>e==="number"||e==="weight",gf=e=>e==="shadow",bf=()=>{const e=gt("color"),t=gt("font"),r=gt("text"),o=gt("font-weight"),n=gt("tracking"),s=gt("leading"),a=gt("breakpoint"),i=gt("container"),c=gt("spacing"),d=gt("radius"),p=gt("shadow"),u=gt("inset-shadow"),f=gt("text-shadow"),h=gt("drop-shadow"),g=gt("blur"),y=gt("perspective"),b=gt("aspect"),v=gt("ease"),N=gt("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],C=()=>[...w(),le,se],E=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto","contain","none"],_=()=>[le,se,c],D=()=>[uo,"full","auto",..._()],A=()=>[Ar,"none","subgrid",le,se],I=()=>["auto",{span:["full",Ar,le,se]},Ar,le,se],T=()=>[Ar,"auto",le,se],L=()=>["auto","min","max","fr",le,se],F=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],B=()=>["start","end","center","stretch","center-safe","end-safe"],G=()=>["auto",..._()],z=()=>[uo,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",..._()],H=()=>[uo,"screen","full","dvw","lvw","svw","min","max","fit",..._()],V=()=>[uo,"screen","full","lh","dvh","lvh","svh","min","max","fit",..._()],W=()=>[e,le,se],pe=()=>[...w(),cf,lf,{position:[le,se]}],U=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Q=()=>["auto","cover","contain",N0,y0,{size:[le,se]}],Ce=()=>[xi,Ln,Do],oe=()=>["","none","full",d,le,se],ye=()=>["",De,Ln,Do],R=()=>["solid","dashed","dotted","double"],ce=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],re=()=>[De,xi,cf,lf],Ae=()=>["","none",g,le,se],we=()=>["none",De,le,se],ue=()=>["none",De,le,se],J=()=>[De,le,se],ne=()=>[uo,"full",..._()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[qr],breakpoint:[qr],color:[sf],container:[qr],"drop-shadow":[qr],ease:["in","out","in-out"],font:[g0],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[qr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[qr],shadow:[qr],spacing:["px",De],text:[qr],"text-shadow":[qr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",uo,se,le,b]}],container:["container"],"container-type":[{"@container":["","normal","size",le,se]}],"container-named":[b0],columns:[{columns:[De,se,le,i]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:C()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:D()}],"inset-x":[{"inset-x":D()}],"inset-y":[{"inset-y":D()}],start:[{"inset-s":D(),start:D()}],end:[{"inset-e":D(),end:D()}],"inset-bs":[{"inset-bs":D()}],"inset-be":[{"inset-be":D()}],top:[{top:D()}],right:[{right:D()}],bottom:[{bottom:D()}],left:[{left:D()}],visibility:["visible","invisible","collapse"],z:[{z:[Ar,"auto",le,se]}],basis:[{basis:[uo,"full","auto",i,..._()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[De,uo,"auto","initial","none",se]}],grow:[{grow:["",De,le,se]}],shrink:[{shrink:["",De,le,se]}],order:[{order:[Ar,"first","last","none",le,se]}],"grid-cols":[{"grid-cols":A()}],"col-start-end":[{col:I()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":A()}],"row-start-end":[{row:I()}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":L()}],"auto-rows":[{"auto-rows":L()}],gap:[{gap:_()}],"gap-x":[{"gap-x":_()}],"gap-y":[{"gap-y":_()}],"justify-content":[{justify:[...F(),"normal"]}],"justify-items":[{"justify-items":[...B(),"normal"]}],"justify-self":[{"justify-self":["auto",...B()]}],"align-content":[{content:["normal",...F()]}],"align-items":[{items:[...B(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...B(),{baseline:["","last"]}]}],"place-content":[{"place-content":F()}],"place-items":[{"place-items":[...B(),"baseline"]}],"place-self":[{"place-self":["auto",...B()]}],p:[{p:_()}],px:[{px:_()}],py:[{py:_()}],ps:[{ps:_()}],pe:[{pe:_()}],pbs:[{pbs:_()}],pbe:[{pbe:_()}],pt:[{pt:_()}],pr:[{pr:_()}],pb:[{pb:_()}],pl:[{pl:_()}],m:[{m:G()}],mx:[{mx:G()}],my:[{my:G()}],ms:[{ms:G()}],me:[{me:G()}],mbs:[{mbs:G()}],mbe:[{mbe:G()}],mt:[{mt:G()}],mr:[{mr:G()}],mb:[{mb:G()}],ml:[{ml:G()}],"space-x":[{"space-x":_()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":_()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],"inline-size":[{inline:["auto",...H()]}],"min-inline-size":[{"min-inline":["auto",...H()]}],"max-inline-size":[{"max-inline":["none",...H()]}],"block-size":[{block:["auto",...V()]}],"min-block-size":[{"min-block":["auto",...V()]}],"max-block-size":[{"max-block":["none",...V()]}],w:[{w:[i,"screen",...z()]}],"min-w":[{"min-w":[i,"screen","none",...z()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[a]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",r,Ln,Do]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,E0,v0]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",xi,se]}],"font-family":[{font:[S0,x0,t]}],"font-features":[{"font-features":[se]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[n,le,se]}],"line-clamp":[{"line-clamp":[De,"none",le,af]}],leading:[{leading:[s,..._()]}],"list-image":[{"list-image":["none",le,se]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",le,se]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:W()}],"text-color":[{text:W()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...R(),"wavy"]}],"text-decoration-thickness":[{decoration:[De,"from-font","auto",le,Do]}],"text-decoration-color":[{decoration:W()}],"underline-offset":[{"underline-offset":[De,"auto",le,se]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"tab-size":[{tab:[Ar,le,se]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",le,se]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",le,se]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:pe()}],"bg-repeat":[{bg:U()}],"bg-size":[{bg:Q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ar,le,se],radial:["",le,se],conic:[Ar,le,se]},C0,w0]}],"bg-color":[{bg:W()}],"gradient-from-pos":[{from:Ce()}],"gradient-via-pos":[{via:Ce()}],"gradient-to-pos":[{to:Ce()}],"gradient-from":[{from:W()}],"gradient-via":[{via:W()}],"gradient-to":[{to:W()}],rounded:[{rounded:oe()}],"rounded-s":[{"rounded-s":oe()}],"rounded-e":[{"rounded-e":oe()}],"rounded-t":[{"rounded-t":oe()}],"rounded-r":[{"rounded-r":oe()}],"rounded-b":[{"rounded-b":oe()}],"rounded-l":[{"rounded-l":oe()}],"rounded-ss":[{"rounded-ss":oe()}],"rounded-se":[{"rounded-se":oe()}],"rounded-ee":[{"rounded-ee":oe()}],"rounded-es":[{"rounded-es":oe()}],"rounded-tl":[{"rounded-tl":oe()}],"rounded-tr":[{"rounded-tr":oe()}],"rounded-br":[{"rounded-br":oe()}],"rounded-bl":[{"rounded-bl":oe()}],"border-w":[{border:ye()}],"border-w-x":[{"border-x":ye()}],"border-w-y":[{"border-y":ye()}],"border-w-s":[{"border-s":ye()}],"border-w-e":[{"border-e":ye()}],"border-w-bs":[{"border-bs":ye()}],"border-w-be":[{"border-be":ye()}],"border-w-t":[{"border-t":ye()}],"border-w-r":[{"border-r":ye()}],"border-w-b":[{"border-b":ye()}],"border-w-l":[{"border-l":ye()}],"divide-x":[{"divide-x":ye()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ye()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...R(),"hidden","none"]}],"divide-style":[{divide:[...R(),"hidden","none"]}],"border-color":[{border:W()}],"border-color-x":[{"border-x":W()}],"border-color-y":[{"border-y":W()}],"border-color-s":[{"border-s":W()}],"border-color-e":[{"border-e":W()}],"border-color-bs":[{"border-bs":W()}],"border-color-be":[{"border-be":W()}],"border-color-t":[{"border-t":W()}],"border-color-r":[{"border-r":W()}],"border-color-b":[{"border-b":W()}],"border-color-l":[{"border-l":W()}],"divide-color":[{divide:W()}],"outline-style":[{outline:[...R(),"none","hidden"]}],"outline-offset":[{"outline-offset":[De,le,se]}],"outline-w":[{outline:["",De,Ln,Do]}],"outline-color":[{outline:W()}],shadow:[{shadow:["","none",p,Js,Xs]}],"shadow-color":[{shadow:W()}],"inset-shadow":[{"inset-shadow":["none",u,Js,Xs]}],"inset-shadow-color":[{"inset-shadow":W()}],"ring-w":[{ring:ye()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:W()}],"ring-offset-w":[{"ring-offset":[De,Do]}],"ring-offset-color":[{"ring-offset":W()}],"inset-ring-w":[{"inset-ring":ye()}],"inset-ring-color":[{"inset-ring":W()}],"text-shadow":[{"text-shadow":["none",f,Js,Xs]}],"text-shadow-color":[{"text-shadow":W()}],opacity:[{opacity:[De,le,se]}],"mix-blend":[{"mix-blend":[...ce(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ce()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[De]}],"mask-image-linear-from-pos":[{"mask-linear-from":re()}],"mask-image-linear-to-pos":[{"mask-linear-to":re()}],"mask-image-linear-from-color":[{"mask-linear-from":W()}],"mask-image-linear-to-color":[{"mask-linear-to":W()}],"mask-image-t-from-pos":[{"mask-t-from":re()}],"mask-image-t-to-pos":[{"mask-t-to":re()}],"mask-image-t-from-color":[{"mask-t-from":W()}],"mask-image-t-to-color":[{"mask-t-to":W()}],"mask-image-r-from-pos":[{"mask-r-from":re()}],"mask-image-r-to-pos":[{"mask-r-to":re()}],"mask-image-r-from-color":[{"mask-r-from":W()}],"mask-image-r-to-color":[{"mask-r-to":W()}],"mask-image-b-from-pos":[{"mask-b-from":re()}],"mask-image-b-to-pos":[{"mask-b-to":re()}],"mask-image-b-from-color":[{"mask-b-from":W()}],"mask-image-b-to-color":[{"mask-b-to":W()}],"mask-image-l-from-pos":[{"mask-l-from":re()}],"mask-image-l-to-pos":[{"mask-l-to":re()}],"mask-image-l-from-color":[{"mask-l-from":W()}],"mask-image-l-to-color":[{"mask-l-to":W()}],"mask-image-x-from-pos":[{"mask-x-from":re()}],"mask-image-x-to-pos":[{"mask-x-to":re()}],"mask-image-x-from-color":[{"mask-x-from":W()}],"mask-image-x-to-color":[{"mask-x-to":W()}],"mask-image-y-from-pos":[{"mask-y-from":re()}],"mask-image-y-to-pos":[{"mask-y-to":re()}],"mask-image-y-from-color":[{"mask-y-from":W()}],"mask-image-y-to-color":[{"mask-y-to":W()}],"mask-image-radial":[{"mask-radial":[le,se]}],"mask-image-radial-from-pos":[{"mask-radial-from":re()}],"mask-image-radial-to-pos":[{"mask-radial-to":re()}],"mask-image-radial-from-color":[{"mask-radial-from":W()}],"mask-image-radial-to-color":[{"mask-radial-to":W()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":w()}],"mask-image-conic-pos":[{"mask-conic":[De]}],"mask-image-conic-from-pos":[{"mask-conic-from":re()}],"mask-image-conic-to-pos":[{"mask-conic-to":re()}],"mask-image-conic-from-color":[{"mask-conic-from":W()}],"mask-image-conic-to-color":[{"mask-conic-to":W()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:pe()}],"mask-repeat":[{mask:U()}],"mask-size":[{mask:Q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",le,se]}],filter:[{filter:["","none",le,se]}],blur:[{blur:Ae()}],brightness:[{brightness:[De,le,se]}],contrast:[{contrast:[De,le,se]}],"drop-shadow":[{"drop-shadow":["","none",h,Js,Xs]}],"drop-shadow-color":[{"drop-shadow":W()}],grayscale:[{grayscale:["",De,le,se]}],"hue-rotate":[{"hue-rotate":[De,le,se]}],invert:[{invert:["",De,le,se]}],saturate:[{saturate:[De,le,se]}],sepia:[{sepia:["",De,le,se]}],"backdrop-filter":[{"backdrop-filter":["","none",le,se]}],"backdrop-blur":[{"backdrop-blur":Ae()}],"backdrop-brightness":[{"backdrop-brightness":[De,le,se]}],"backdrop-contrast":[{"backdrop-contrast":[De,le,se]}],"backdrop-grayscale":[{"backdrop-grayscale":["",De,le,se]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[De,le,se]}],"backdrop-invert":[{"backdrop-invert":["",De,le,se]}],"backdrop-opacity":[{"backdrop-opacity":[De,le,se]}],"backdrop-saturate":[{"backdrop-saturate":[De,le,se]}],"backdrop-sepia":[{"backdrop-sepia":["",De,le,se]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":_()}],"border-spacing-x":[{"border-spacing-x":_()}],"border-spacing-y":[{"border-spacing-y":_()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",le,se]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[De,"initial",le,se]}],ease:[{ease:["linear","initial",v,le,se]}],delay:[{delay:[De,le,se]}],animate:[{animate:["none",N,le,se]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[y,le,se]}],"perspective-origin":[{"perspective-origin":C()}],rotate:[{rotate:we()}],"rotate-x":[{"rotate-x":we()}],"rotate-y":[{"rotate-y":we()}],"rotate-z":[{"rotate-z":we()}],scale:[{scale:ue()}],"scale-x":[{"scale-x":ue()}],"scale-y":[{"scale-y":ue()}],"scale-z":[{"scale-z":ue()}],"scale-3d":["scale-3d"],skew:[{skew:J()}],"skew-x":[{"skew-x":J()}],"skew-y":[{"skew-y":J()}],transform:[{transform:[le,se,"","none","gpu","cpu"]}],"transform-origin":[{origin:C()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ne()}],"translate-x":[{"translate-x":ne()}],"translate-y":[{"translate-y":ne()}],"translate-z":[{"translate-z":ne()}],"translate-none":["translate-none"],zoom:[{zoom:[Ar,le,se]}],accent:[{accent:W()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:W()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",le,se]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":W()}],"scrollbar-track-color":[{"scrollbar-track":W()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mbs":[{"scroll-mbs":_()}],"scroll-mbe":[{"scroll-mbe":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pbs":[{"scroll-pbs":_()}],"scroll-pbe":[{"scroll-pbe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",le,se]}],fill:[{fill:["none",...W()]}],"stroke-w":[{stroke:[De,Ln,Do,af]}],stroke:[{stroke:["none",...W()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},k0=(e,{cacheSize:t,prefix:r,experimentalParseClassName:o,extend:n={},override:s={}})=>(on(e,"cacheSize",t),on(e,"prefix",r),on(e,"experimentalParseClassName",o),Zs(e.theme,s.theme),Zs(e.classGroups,s.classGroups),Zs(e.conflictingClassGroups,s.conflictingClassGroups),Zs(e.conflictingClassGroupModifiers,s.conflictingClassGroupModifiers),on(e,"postfixLookupClassGroups",s.postfixLookupClassGroups),on(e,"orderSensitiveModifiers",s.orderSensitiveModifiers),ea(e.theme,n.theme),ea(e.classGroups,n.classGroups),ea(e.conflictingClassGroups,n.conflictingClassGroups),ea(e.conflictingClassGroupModifiers,n.conflictingClassGroupModifiers),Si(e,n,"postfixLookupClassGroups"),Si(e,n,"orderSensitiveModifiers"),e),on=(e,t,r)=>{r!==void 0&&(e[t]=r)},Zs=(e,t)=>{if(t)for(const r in t)on(e,r,t[r])},ea=(e,t)=>{if(t)for(const r in t)Si(e,t,r)},Si=(e,t,r)=>{const o=t[r];o!==void 0&&(e[r]=e[r]?e[r].concat(o):o)},A0=((e,...t)=>typeof e=="function"?rf(bf,e,...t):rf(()=>k0(bf(),e),...t))({prefix:""});function m(...e){const t=Qu(e);return A0(t)}const ta=({label:e,required:t,htmlFor:r,className:o=""})=>e?l.jsxs("label",{htmlFor:r,className:m("block text-sm font-medium text-gray-700",o),children:[e,t&&l.jsx("span",{className:m("text-red-500 ml-1"),children:"*"})]}):null,ra=({description:e,className:t=""})=>e?l.jsx("p",{className:m("text-xs text-gray-500",t),children:e}):null,Fn=({errors:e,className:t=""})=>!e||e.length===0?null:l.jsx("div",{className:m("space-y-1",t),children:e.map((r,o)=>l.jsx("p",{className:m("text-xs text-red-500"),children:r},o))}),D0=({label:e,description:t,required:r,errors:o,children:n})=>l.jsxs("div",{className:m("space-y-1.5"),children:[l.jsx(ta,{label:e,required:r}),l.jsx(ra,{description:t}),n,l.jsx(Fn,{errors:o})]}),de=({label:e,description:t,required:r,errors:o,labelPosition:n="top",className:s="",children:a})=>n==="hidden"?l.jsxs("div",{className:m("space-y-1.5",s),children:[a,l.jsx(Fn,{errors:o})]}):n==="left"?l.jsxs("div",{className:m("flex items-start gap-4",s),children:[l.jsxs("div",{className:m("w-1/3 pt-2"),children:[l.jsx(ta,{label:e,required:r}),l.jsx(ra,{description:t})]}),l.jsxs("div",{className:m("flex-1 space-y-1.5"),children:[a,l.jsx(Fn,{errors:o})]})]}):l.jsxs("div",{className:m("space-y-1.5",s),children:[l.jsx(ta,{label:e,required:r}),l.jsx(ra,{description:t}),a,l.jsx(Fn,{errors:o})]}),$0=({children:e,className:t=""})=>l.jsx("div",{className:m("pointer-events-none",t),children:e}),T0=({icon:e="📋",message:t,subMessage:r})=>l.jsxs("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg p-6 text-center bg-gray-50"),children:[l.jsx("span",{className:m("text-4xl"),children:e}),l.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:t}),r&&l.jsx("p",{className:m("text-xs text-gray-400"),children:r})]}),To=({icon:e,children:t,iconPosition:r="left"})=>l.jsxs("div",{className:m("relative"),children:[l.jsx("span",{className:m("absolute top-1/2 -translate-y-1/2 text-gray-400",r==="left"?"left-3":"right-3"),children:e}),t]}),Ni=({prefix:e,suffix:t,children:r})=>l.jsxs("div",{className:m("flex"),children:[e&&l.jsx("span",{className:m("inline-flex items-center px-3 border border-r-0 border-gray-300 rounded-l-md bg-gray-100 text-gray-500 text-sm"),children:e}),l.jsx("div",{className:m("flex-1",!e&&"rounded-l-md",!t&&"rounded-r-md"),children:r}),t&&l.jsx("span",{className:m("inline-flex items-center px-3 border border-l-0 border-gray-300 rounded-r-md bg-gray-100 text-gray-500 text-sm"),children:t})]});function Ut(e={}){const{hasError:t=!1,disabled:r=!1,size:o="medium",hasLeftIcon:n=!1,hasRightIcon:s=!1,hasPrefix:a=!1,hasSuffix:i=!1}=e;return m("w-full","border","transition-colors","focus:outline-none","focus:ring-2","focus:ring-offset-0",{small:"px-2 py-1.5 text-sm",medium:"px-3 py-2 text-sm",large:"px-4 py-3 text-base"}[o],!a&&!i&&"rounded-md",a&&!i&&"rounded-r-md",!a&&i&&"rounded-l-md",n&&"pl-10",s&&"pr-10",r&&"bg-gray-50 text-gray-500 cursor-not-allowed border-gray-300",t&&!r&&"border-red-500 focus:ring-red-500 focus:border-red-500",!t&&!r&&"border-gray-300 focus:ring-blue-500 focus:border-blue-500")}function kt(e="medium"){return m("w-full",{small:"px-2 py-1.5 text-sm",medium:"px-3 py-2 text-sm",large:"px-4 py-3 text-base"}[e],"border","border-gray-300","rounded-md","bg-gray-50","text-gray-500")}function P0(e={}){const{variant:t="primary",size:r="medium",disabled:o=!1}=e,n={small:"px-4 py-1.5 text-sm",medium:"px-6 py-2.5 text-base",large:"px-8 py-3 text-lg"},s={primary:"bg-blue-600 text-white hover:bg-blue-700",secondary:"bg-gray-600 text-white hover:bg-gray-700",outline:"border-2 border-blue-600 text-blue-600 bg-transparent hover:bg-blue-50",ghost:"text-blue-600 hover:bg-blue-50"};return m("rounded-md","font-medium","transition-colors","focus:outline-none","focus:ring-2","focus:ring-offset-2",n[r],o&&"opacity-50 cursor-not-allowed",s[t])}function K(e){const{element:t,properties:r,layout:o,validation:n,config:s,mode:a,value:i,onChange:c,errors:d,readOnly:p,disabled:u}=e;return{label:r.label,description:r.description,placeholder:r.placeholder,prefix:r.prefix,suffix:r.suffix,required:(n==null?void 0:n.required)??!1,labelPosition:o.labelPosition??"top",isCanvas:a==="canvas",isDisabled:u||p||a==="canvas",value:i,onChange:c,errors:d,config:s,element:t}}const I0=[{type:"shortText",structure:"field",typeCategory:"Text",label:"Short Text",description:"Single line text input",icon:"📝",category:"field",subCategory:"textInput",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!0,showSuffix:!0},configSection:{title:"Text Input Settings",icon:"📝"},fields:[{key:"showCharacterCount",label:"Show Character Count",type:"checkbox",section:"config",description:"Display remaining character count"},{key:"autoComplete",label:"Autocomplete",type:"select",section:"config",description:"Browser autofill hint",options:[{value:"off",label:"Off"},{value:"on",label:"On"},{value:"name",label:"Full Name"},{value:"given-name",label:"First Name"},{value:"family-name",label:"Last Name"},{value:"email",label:"Email"},{value:"tel",label:"Phone"},{value:"organization",label:"Organization"},{value:"street-address",label:"Street Address"},{value:"address-level2",label:"City"},{value:"address-level1",label:"State / Province"},{value:"postal-code",label:"Postal / Zip Code"},{value:"country",label:"Country"},{value:"username",label:"Username"},{value:"organization-title",label:"Job Title"}]}]},getDefaultValues:()=>({properties:{label:"Short Text",placeholder:"Enter text..."},layout:{labelPosition:"top",size:"full"},validation:{maxLength:255}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,children:l.jsx("input",{type:"text",placeholder:o,disabled:!0,className:kt()})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,value:a,onChange:i,errors:c,isDisabled:d}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,errors:c,children:l.jsx("input",{type:"text",placeholder:o,value:a??"",onChange:p=>i==null?void 0:i(p.target.value),disabled:d,className:Ut({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})})})}},{type:"longText",structure:"field",typeCategory:"Text",label:"Long Text",description:"Multi-line text area",icon:"📄",category:"field",subCategory:"textInput",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Text Area Settings",icon:"📄"},fields:[{key:"rows",label:"Visible Rows",type:"number",section:"config",min:1,max:20,placeholder:"3",description:"Number of visible text lines"},{key:"autoResize",label:"Auto-resize",type:"checkbox",section:"config",description:"Automatically adjust height to content"},{key:"showCharacterCount",label:"Show Character Count",type:"checkbox",section:"config",description:"Display remaining character count"}]},getDefaultValues:()=>({properties:{label:"Long Text",placeholder:"Enter text..."},layout:{labelPosition:"top",size:"full"},config:{rows:3,autoResize:!1},validation:{maxLength:5e3}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,config:a}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,children:l.jsx("textarea",{placeholder:o,disabled:!0,rows:(a==null?void 0:a.rows)||3,className:`${kt()} resize-none`})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,value:a,onChange:i,errors:c,isDisabled:d,config:p}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,errors:c,children:l.jsx("textarea",{placeholder:o,value:a??"",onChange:u=>i==null?void 0:i(u.target.value),disabled:d,rows:(p==null?void 0:p.rows)||3,className:`${Ut({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})} resize-none`})})}},{type:"multiLineInput",structure:"field",typeCategory:"Text",label:"Multi-Line Input",description:"Auto-expanding text area",icon:"📝",category:"field",subCategory:"textInput",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Auto-Resize Settings",icon:"📑"},fields:[{key:"minRows",label:"Min Rows",type:"number",section:"config",min:1,max:20,placeholder:"2",colSpan:1},{key:"maxRows",label:"Max Rows",type:"number",section:"config",min:1,max:50,placeholder:"10",colSpan:1},{key:"autoResize",label:"Auto-resize",type:"checkbox",section:"config",description:"Grow textarea to fit content"},{key:"showCharacterCount",label:"Show Character Count",type:"checkbox",section:"config",description:"Display remaining character count"}]},getDefaultValues:()=>({properties:{label:"Multi-Line Input",placeholder:"Enter text..."},layout:{labelPosition:"top",size:"full"},config:{minRows:2,maxRows:10,autoResize:!0},validation:{maxLength:5e3}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,config:a}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,children:l.jsx("textarea",{placeholder:o,disabled:!0,rows:(a==null?void 0:a.minRows)||2,className:`${kt()} resize-none`})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,value:a,onChange:i,errors:c,isDisabled:d,config:p}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,errors:c,children:l.jsx("textarea",{placeholder:o,value:a??"",onChange:u=>i==null?void 0:i(u.target.value),disabled:d,rows:(p==null?void 0:p.minRows)||2,className:`${Ut({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})} resize-none`})})}},{type:"textEditor",structure:"field",typeCategory:"Text",label:"Rich Text Editor",description:"WYSIWYG text editor",icon:"✏️",category:"field",subCategory:"textInput",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!1},configSection:{title:"Editor Settings",icon:"✏️"},fields:[{key:"toolbarPreset",label:"Toolbar",type:"select",section:"config",description:"Choose which formatting options appear",options:[{value:"basic",label:"Basic (Bold, Italic, Underline)"},{value:"standard",label:"Standard (+ Links, Lists)"},{value:"advanced",label:"Advanced (+ Headings, Blockquote)"},{value:"full",label:"Full (All options)"}]},{key:"height",label:"Height (px)",type:"number",section:"config",min:100,max:800,placeholder:"200",description:"Editor area height in pixels"},{key:"allowImages",label:"Allow Images",type:"checkbox",section:"config",description:"Let users embed images in content"},{key:"allowLinks",label:"Allow Links",type:"checkbox",section:"config",description:"Let users insert hyperlinks"}]},getDefaultValues:()=>({properties:{label:"Rich Text",placeholder:"Start typing..."},layout:{labelPosition:"top",size:"full"},config:{toolbar:["bold","italic","underline","link"],height:200,allowImages:!1,allowLinks:!0},validation:{maxLength:1e4}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,config:a}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,children:l.jsxs("div",{className:m("border border-gray-300 rounded-md bg-gray-50 overflow-hidden"),children:[l.jsxs("div",{className:m("flex items-center gap-1 p-2 border-b border-gray-200 bg-gray-100"),children:[l.jsx("button",{disabled:!0,className:m("p-1.5 rounded hover:bg-gray-200 text-gray-600"),children:l.jsx("strong",{children:"B"})}),l.jsx("button",{disabled:!0,className:m("p-1.5 rounded hover:bg-gray-200 text-gray-600"),children:l.jsx("em",{children:"I"})}),l.jsx("button",{disabled:!0,className:m("p-1.5 rounded hover:bg-gray-200 text-gray-600"),children:l.jsx("u",{children:"U"})}),l.jsx("span",{className:m("w-px h-4 bg-gray-300 mx-1")}),l.jsx("button",{disabled:!0,className:m("p-1.5 rounded hover:bg-gray-200 text-gray-600 text-xs"),children:"🔗"})]}),l.jsx("div",{className:m("p-3 min-h-[120px] text-gray-400 text-sm"),style:{height:(a==null?void 0:a.height)||200},children:o||"Start typing..."})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e);return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsxs("div",{className:`border rounded-md overflow-hidden ${((i==null?void 0:i.length)??0)>0?"border-red-500":"border-gray-300"}`,children:[l.jsxs("div",{className:m("flex items-center gap-1 p-2 border-b border-gray-200 bg-gray-100"),children:[l.jsx("button",{type:"button",disabled:c,className:m("p-1.5 rounded hover:bg-gray-200 text-gray-600 disabled:opacity-50"),children:l.jsx("strong",{children:"B"})}),l.jsx("button",{type:"button",disabled:c,className:m("p-1.5 rounded hover:bg-gray-200 text-gray-600 disabled:opacity-50"),children:l.jsx("em",{children:"I"})}),l.jsx("button",{type:"button",disabled:c,className:m("p-1.5 rounded hover:bg-gray-200 text-gray-600 disabled:opacity-50"),children:l.jsx("u",{children:"U"})}),l.jsx("span",{className:m("w-px h-4 bg-gray-300 mx-1")}),l.jsx("button",{type:"button",disabled:c,className:m("p-1.5 rounded hover:bg-gray-200 text-gray-600 text-xs disabled:opacity-50"),children:"🔗"})]}),l.jsx("div",{contentEditable:!c,suppressContentEditableWarning:!0,onInput:p=>a==null?void 0:a(p.target.innerHTML),dangerouslySetInnerHTML:{__html:s??""},className:m("p-3 min-h-[120px] text-sm focus:outline-none"),style:{height:(d==null?void 0:d.height)||200}})]})})}}],O0=[{type:"number",structure:"field",typeCategory:"Numeric",label:"Number",description:"Numeric input field",icon:"🔢",category:"field",subCategory:"numeric",dataType:"number",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!0,showSuffix:!0},configSection:{title:"Number Settings",icon:"🔢"},fields:[{key:"step",label:"Step",type:"number",section:"config",min:.01,placeholder:"1",description:"Increment/decrement amount",colSpan:1},{key:"decimals",label:"Decimals",type:"number",section:"config",min:0,max:10,placeholder:"0",description:"Decimal places to allow",colSpan:1},{key:"thousandsSeparator",label:"Thousands Separator",type:"checkbox",section:"config",description:"Format numbers with commas (e.g. 1,000)"},{key:"currencySymbol",label:"Currency Symbol",type:"text",section:"config",placeholder:"$, €, £, ¥…",description:"Leave empty for plain numbers"},{key:"numberFormat",label:"Display Format",type:"select",section:"config",options:[{value:"number",label:"Plain Number"},{value:"currency",label:"Currency"},{value:"percent",label:"Percentage"}]},{key:"showStepper",label:"Show Stepper Buttons",type:"checkbox",section:"config",description:"Display +/- spin buttons"}]},getDefaultValues:()=>({properties:{label:"Number",placeholder:"Enter number..."},layout:{labelPosition:"top",size:"full"},config:{step:1,decimals:0,thousandsSeparator:!1}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,prefix:a,suffix:i}=K(e),c=l.jsx("input",{type:"number",placeholder:o,disabled:!0,className:`${kt()} ${a?"":"rounded-l-md"} ${i?"":"rounded-r-md"}`});return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,children:a||i?l.jsx(Ni,{prefix:a,suffix:i,children:c}):c})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,prefix:a,suffix:i,value:c,onChange:d,errors:p,isDisabled:u,config:f}=K(e),h=y=>{const b=y.target.value===""?void 0:Number(y.target.value);d==null||d(b)},g=l.jsx("input",{type:"number",placeholder:o,value:c??"",onChange:h,disabled:u,step:(f==null?void 0:f.step)||1,className:`${Ut({hasError:((p==null?void 0:p.length)??0)>0,disabled:u})} ${a?"rounded-l-none":""} ${i?"rounded-r-none":""}`});return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,errors:p,children:a||i?l.jsx(Ni,{prefix:a,suffix:i,children:g}):g})}},{type:"slider",structure:"field",typeCategory:"Numeric",label:"Slider",description:"Range slider for numeric values",icon:"🎚️",category:"field",subCategory:"numeric",dataType:"number",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Slider Settings",icon:"🎚️"},fields:[{key:"min",label:"Min Value",type:"number",section:"config",placeholder:"0",colSpan:1},{key:"max",label:"Max Value",type:"number",section:"config",placeholder:"100",colSpan:1},{key:"step",label:"Step",type:"number",section:"config",min:1,placeholder:"1",description:"Size of each increment"},{key:"showValue",label:"Show Value Label",type:"checkbox",section:"config",description:"Display the current value beside the slider"},{key:"showMarks",label:"Show Tick Marks",type:"checkbox",section:"config",description:"Display scale marks along the track"},{key:"showTooltip",label:"Show Tooltip on Drag",type:"checkbox",section:"config",description:"Floating tooltip while dragging"},{key:"trackColor",label:"Track Color",type:"select",section:"config",description:"Visual theme of the slider track",options:[{value:"primary",label:"Primary (Blue)"},{value:"success",label:"Success (Green)"},{value:"warning",label:"Warning (Amber)"},{value:"danger",label:"Danger (Red)"},{value:"neutral",label:"Neutral (Gray)"}]}]},getDefaultValues:()=>({properties:{label:"Slider",description:"Drag to select a value"},layout:{labelPosition:"top",size:"full"},config:{min:0,max:100,step:1,showValue:!0,showMarks:!1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e),a=(s==null?void 0:s.min)??0,i=(s==null?void 0:s.max)??100;return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsxs("div",{className:m("flex items-center gap-3"),children:[l.jsx("span",{className:m("text-xs text-gray-500"),children:a}),l.jsx("input",{type:"range",min:a,max:i,disabled:!0,className:m("flex-1 h-2 bg-gray-200 rounded-lg appearance-none cursor-not-allowed")}),l.jsx("span",{className:m("text-xs text-gray-500"),children:i}),(s==null?void 0:s.showValue)&&l.jsx("span",{className:m("text-sm font-medium text-gray-600 min-w-[40px] text-center"),children:Math.round((a+i)/2)})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),p=(d==null?void 0:d.min)??0,u=(d==null?void 0:d.max)??100,f=(d==null?void 0:d.step)??1,h=s??p;return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsxs("div",{className:m("flex items-center gap-3"),children:[l.jsx("span",{className:m("text-xs text-gray-500"),children:p}),l.jsx("input",{type:"range",min:p,max:u,step:f,value:h,onChange:g=>a==null?void 0:a(Number(g.target.value)),disabled:c,className:m("flex-1 h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer disabled:cursor-not-allowed")}),l.jsx("span",{className:m("text-xs text-gray-500"),children:u}),(d==null?void 0:d.showValue)&&l.jsx("span",{className:m("text-sm font-medium text-gray-600 min-w-[40px] text-center"),children:h})]})})}},{type:"rangeSlider",structure:"field",typeCategory:"Numeric",label:"Range Slider",description:"Select a range of values",icon:"↔️",category:"field",subCategory:"numeric",dataType:"object",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Range Slider Settings",icon:"↔️"},fields:[{key:"min",label:"Range Min",type:"number",section:"config",placeholder:"0",colSpan:1},{key:"max",label:"Range Max",type:"number",section:"config",placeholder:"100",colSpan:1},{key:"step",label:"Step",type:"number",section:"config",min:1,placeholder:"1",description:"Size of each increment",colSpan:1},{key:"minRange",label:"Min Gap",type:"number",section:"config",min:0,placeholder:"10",description:"Minimum distance between handles",colSpan:1},{key:"showValue",label:"Show Value Labels",type:"checkbox",section:"config",description:"Display selected range below the slider"},{key:"showTooltip",label:"Show Tooltip on Drag",type:"checkbox",section:"config",description:"Floating tooltip while dragging handles"},{key:"showBarLabels",label:"Show Min/Max Labels",type:"checkbox",section:"config",description:"Show the min/max values at track edges"}]},getDefaultValues:()=>({properties:{label:"Range Slider",description:"Select a range"},layout:{labelPosition:"top",size:"full"},config:{min:0,max:100,step:1,showValue:!0,minRange:10}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e),a=(s==null?void 0:s.min)??0,i=(s==null?void 0:s.max)??100;return l.jsxs(de,{label:t,description:r,required:o,labelPosition:n,children:[l.jsxs("div",{className:m("flex items-center gap-3"),children:[l.jsx("span",{className:m("text-xs text-gray-500"),children:a}),l.jsxs("div",{className:m("flex-1 relative h-2 bg-gray-200 rounded-lg"),children:[l.jsx("div",{className:m("absolute h-full bg-blue-400 rounded-lg left-[20%] right-[30%]")}),l.jsx("div",{className:m("absolute w-4 h-4 bg-white border-2 border-blue-500 rounded-full -top-1 left-[20%] -ml-2")}),l.jsx("div",{className:m("absolute w-4 h-4 bg-white border-2 border-blue-500 rounded-full -top-1 right-[30%] -mr-2")})]}),l.jsx("span",{className:m("text-xs text-gray-500"),children:i})]}),(s==null?void 0:s.showValue)&&l.jsxs("div",{className:m("flex justify-between text-sm text-gray-600 mt-2"),children:[l.jsxs("span",{children:["Min: ",Math.round(a+(i-a)*.2)]}),l.jsxs("span",{children:["Max: ",Math.round(a+(i-a)*.7)]})]})]})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),p=(d==null?void 0:d.min)??0,u=(d==null?void 0:d.max)??100,f=(d==null?void 0:d.step)??1,h=(s==null?void 0:s.min)??Math.round(p+(u-p)*.2),g=(s==null?void 0:s.max)??Math.round(p+(u-p)*.8),y=x=>{const w=Number(x.target.value),C=Math.min(w,g-((d==null?void 0:d.minRange)??0));a==null||a({min:C,max:g})},b=x=>{const w=Number(x.target.value),C=Math.max(w,h+((d==null?void 0:d.minRange)??0));a==null||a({min:h,max:C})},v=(h-p)/(u-p)*100,N=100-(g-p)/(u-p)*100;return l.jsxs(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:[l.jsxs("div",{className:m("flex items-center gap-3"),children:[l.jsx("span",{className:m("text-xs text-gray-500"),children:p}),l.jsxs("div",{className:m("flex-1 relative h-2 bg-gray-200 rounded-lg"),children:[l.jsx("div",{className:m("absolute h-full bg-blue-400 rounded-lg"),style:{left:`${v}%`,right:`${N}%`}}),l.jsx("input",{type:"range",min:p,max:u,step:f,value:h,onChange:y,disabled:c,className:m("absolute w-full h-full appearance-none bg-transparent pointer-events-auto cursor-pointer disabled:cursor-not-allowed"),style:{zIndex:h>u-10?5:3}}),l.jsx("input",{type:"range",min:p,max:u,step:f,value:g,onChange:b,disabled:c,className:m("absolute w-full h-full appearance-none bg-transparent pointer-events-auto cursor-pointer disabled:cursor-not-allowed"),style:{zIndex:4}})]}),l.jsx("span",{className:m("text-xs text-gray-500"),children:u})]}),(d==null?void 0:d.showValue)&&l.jsxs("div",{className:m("flex justify-between text-sm text-gray-600 mt-2"),children:[l.jsxs("span",{children:["Min: ",h]}),l.jsxs("span",{children:["Max: ",g]})]})]})}}],M0=[{type:"singleChoice",structure:"field",typeCategory:"Selection",label:"Single Choice",description:"Radio button selection",icon:"⭕",category:"field",subCategory:"selection",dataType:"string",supportsValidation:!0,supportsOptions:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Choice Settings",icon:"⭕"},fields:[{key:"layoutDirection",label:"Layout",type:"select",section:"config",description:"How options are arranged",options:[{value:"vertical",label:"Vertical (stacked)"},{value:"horizontal",label:"Horizontal (inline)"},{value:"grid",label:"Grid (2 columns)"}]},{key:"allowOther",label:'Allow "Other"',type:"checkbox",section:"config",description:'Add a free-text "Other" option at the end'},{key:"randomizeOptions",label:"Randomize Order",type:"checkbox",section:"config",description:"Shuffle options for each respondent (surveys)"},{key:"showAsButtonGroup",label:"Show as Button Group",type:"checkbox",section:"config",description:"Display options as selectable buttons instead of radios"},{key:"otherLabel",label:'"Other" Label',type:"text",section:"config",placeholder:"Other (please specify)",showWhen:{field:"allowOther",value:!0}}]},getDefaultValues:()=>({properties:{label:"Single Choice",description:"Select one option"},layout:{labelPosition:"top",size:"full"},config:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],allowOther:!1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e),a=(s==null?void 0:s.options)||[];return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsxs("div",{className:m("space-y-2"),children:[a.map((i,c)=>l.jsxs("label",{className:m("flex items-center gap-2"),children:[l.jsx("input",{type:"radio",disabled:!0,className:m("text-blue-600")}),l.jsx("span",{className:m("text-sm text-gray-700"),children:i.label})]},c)),(s==null?void 0:s.allowOther)&&l.jsxs("label",{className:m("flex items-center gap-2"),children:[l.jsx("input",{type:"radio",disabled:!0,className:m("text-blue-600")}),l.jsx("span",{className:m("text-sm text-gray-700"),children:"Other"})]})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),p=(d==null?void 0:d.options)||[];return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsxs("div",{className:m("space-y-2"),children:[p.map((u,f)=>l.jsxs("label",{className:m("flex items-center gap-2 cursor-pointer"),children:[l.jsx("input",{type:"radio",checked:s===u.value,onChange:()=>a==null?void 0:a(u.value),disabled:c,className:m("text-blue-600")}),l.jsx("span",{className:m("text-sm text-gray-700"),children:u.label})]},f)),(d==null?void 0:d.allowOther)&&l.jsxs("label",{className:m("flex items-center gap-2 cursor-pointer"),children:[l.jsx("input",{type:"radio",checked:s==="__other__",onChange:()=>a==null?void 0:a("__other__"),disabled:c,className:m("text-blue-600")}),l.jsx("span",{className:m("text-sm text-gray-700"),children:"Other"})]})]})})}},{type:"multipleChoice",structure:"field",typeCategory:"Selection",label:"Multiple Choice",description:"Checkbox multi-select",icon:"☑️",category:"field",subCategory:"selection",dataType:"array",supportsValidation:!0,supportsOptions:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Choice Settings",icon:"☑️"},fields:[{key:"layoutDirection",label:"Layout",type:"select",section:"config",description:"How options are arranged",options:[{value:"vertical",label:"Vertical (stacked)"},{value:"horizontal",label:"Horizontal (inline)"},{value:"grid",label:"Grid (2 columns)"}]},{key:"allowOther",label:'Allow "Other"',type:"checkbox",section:"config",description:'Add a free-text "Other" option at the end'},{key:"randomizeOptions",label:"Randomize Order",type:"checkbox",section:"config",description:"Shuffle options for each respondent (surveys)"},{key:"showSelectAll",label:'Show "Select All"',type:"checkbox",section:"config",description:"Add a shortcut to check all options at once"},{key:"otherLabel",label:'"Other" Label',type:"text",section:"config",placeholder:"Other (please specify)",showWhen:{field:"allowOther",value:!0}}]},getDefaultValues:()=>({properties:{label:"Multiple Choice",description:"Select all that apply"},layout:{labelPosition:"top",size:"full"},config:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],allowOther:!1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e),a=(s==null?void 0:s.options)||[];return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsxs("div",{className:m("space-y-2"),children:[a.map((i,c)=>l.jsxs("label",{className:m("flex items-center gap-2"),children:[l.jsx("input",{type:"checkbox",disabled:!0,className:m("text-blue-600 rounded")}),l.jsx("span",{className:m("text-sm text-gray-700"),children:i.label})]},c)),(s==null?void 0:s.allowOther)&&l.jsxs("label",{className:m("flex items-center gap-2"),children:[l.jsx("input",{type:"checkbox",disabled:!0,className:m("text-blue-600 rounded")}),l.jsx("span",{className:m("text-sm text-gray-700"),children:"Other"})]})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),p=(d==null?void 0:d.options)||[],u=Array.isArray(s)?s:[],f=h=>{const g=u.includes(h)?u.filter(y=>y!==h):[...u,h];a==null||a(g)};return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsxs("div",{className:m("space-y-2"),children:[p.map((h,g)=>l.jsxs("label",{className:m("flex items-center gap-2 cursor-pointer"),children:[l.jsx("input",{type:"checkbox",checked:u.includes(h.value),onChange:()=>f(h.value),disabled:c,className:m("text-blue-600 rounded")}),l.jsx("span",{className:m("text-sm text-gray-700"),children:h.label})]},g)),(d==null?void 0:d.allowOther)&&l.jsxs("label",{className:m("flex items-center gap-2 cursor-pointer"),children:[l.jsx("input",{type:"checkbox",checked:u.includes("__other__"),onChange:()=>f("__other__"),disabled:c,className:m("text-blue-600 rounded")}),l.jsx("span",{className:m("text-sm text-gray-700"),children:"Other"})]})]})})}},{type:"dropdown",structure:"field",typeCategory:"Selection",label:"Dropdown",description:"Select from a dropdown list",icon:"📋",category:"field",subCategory:"selection",dataType:"string",supportsValidation:!0,supportsOptions:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Dropdown Settings",icon:"📋"},fields:[{key:"allowOther",label:'Allow "Other"',type:"checkbox",section:"config",description:"Let users type a custom value"},{key:"searchable",label:"Searchable",type:"checkbox",section:"config",description:"Enable type-to-search filtering"},{key:"clearable",label:"Clearable",type:"checkbox",section:"config",description:"Show a clear button to deselect"},{key:"otherLabel",label:'"Other" Label',type:"text",section:"config",placeholder:"Other (please specify)",showWhen:{field:"allowOther",value:!0}}]},getDefaultValues:()=>({properties:{label:"Dropdown",placeholder:"Select an option..."},layout:{labelPosition:"top",size:"full"},config:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],allowOther:!1}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,config:a}=K(e),i=(a==null?void 0:a.options)||[];return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,children:l.jsxs("select",{disabled:!0,className:kt(),children:[l.jsx("option",{children:o||"Select an option..."}),i.map((c,d)=>l.jsx("option",{value:c.value,children:c.label},d))]})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,value:a,onChange:i,errors:c,isDisabled:d,config:p}=K(e),u=(p==null?void 0:p.options)||[];return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,errors:c,children:l.jsxs("select",{value:a??"",onChange:f=>i==null?void 0:i(f.target.value||void 0),disabled:d,className:Ut({hasError:((c==null?void 0:c.length)??0)>0,disabled:d}),children:[l.jsx("option",{value:"",children:o||"Select an option..."}),u.map((f,h)=>l.jsx("option",{value:f.value,children:f.label},h))]})})}},{type:"tags",structure:"field",typeCategory:"Selection",label:"Tags",description:"Tag-style multi-select",icon:"🏷️",category:"field",subCategory:"selection",dataType:"array",supportsValidation:!0,supportsOptions:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Tags Settings",icon:"🏷️"},fields:[{key:"maxTags",label:"Max Tags",type:"number",section:"config",min:1,placeholder:"10",description:"Maximum number of tags allowed"},{key:"allowCustomTags",label:"Allow Custom Tags",type:"checkbox",section:"config",description:"Let users type their own tags"},{key:"showSuggestions",label:"Show Suggestions",type:"checkbox",section:"config",description:"Display suggestion dropdown while typing"},{key:"tagColor",label:"Tag Color",type:"select",section:"config",description:"Color theme for selected tags",options:[{value:"primary",label:"Primary (Blue)"},{value:"neutral",label:"Neutral (Gray)"},{value:"success",label:"Success (Green)"},{value:"warning",label:"Warning (Amber)"},{value:"danger",label:"Danger (Red)"}]}]},getDefaultValues:()=>({properties:{label:"Tags",placeholder:"Add tag...",description:"Type and press Enter to add tags"},layout:{labelPosition:"top",size:"full"},config:{options:[{label:"Tag 1",value:"tag1"},{label:"Tag 2",value:"tag2"},{label:"Tag 3",value:"tag3"}],maxTags:10,allowCustomTags:!0}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,children:l.jsxs("div",{className:m("flex flex-wrap gap-2 p-2 border border-gray-300 rounded-md bg-gray-50 min-h-[42px]"),children:[l.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-800 text-sm rounded"),children:["Tag 1",l.jsx("button",{disabled:!0,className:m("text-blue-600 hover:text-blue-800"),children:"×"})]}),l.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-800 text-sm rounded"),children:["Tag 2",l.jsx("button",{disabled:!0,className:m("text-blue-600 hover:text-blue-800"),children:"×"})]}),l.jsx("input",{type:"text",placeholder:o||"Add tag...",disabled:!0,className:m("flex-1 min-w-[100px] border-none bg-transparent text-sm focus:outline-none")})]})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,value:a,onChange:i,errors:c,isDisabled:d,config:p}=K(e),u=Array.isArray(a)?a:[],[f,h]=P.useState(""),g=b=>{b.key==="Enter"&&f.trim()&&(b.preventDefault(),!u.includes(f.trim())&&(!(p!=null&&p.maxTags)||u.length<p.maxTags)&&(i==null||i([...u,f.trim()])),h(""))},y=b=>{i==null||i(u.filter(v=>v!==b))};return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,errors:c,children:l.jsxs("div",{className:`flex flex-wrap gap-2 p-2 border rounded-md min-h-[42px] ${((c==null?void 0:c.length)??0)>0?"border-red-500":"border-gray-300"} ${d?"bg-gray-50":"bg-white"}`,children:[u.map((b,v)=>l.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-800 text-sm rounded"),children:[b,!d&&l.jsx("button",{type:"button",onClick:()=>y(b),className:m("text-blue-600 hover:text-blue-800"),children:"×"})]},v)),!d&&(!(p!=null&&p.maxTags)||u.length<p.maxTags)&&l.jsx("input",{type:"text",placeholder:o||"Add tag...",value:f,onChange:b=>h(b.target.value),onKeyDown:g,disabled:d,className:m("flex-1 min-w-[100px] border-none bg-transparent text-sm focus:outline-none")})]})})}},{type:"decisionBox",structure:"field",typeCategory:"Selection",label:"Decision Box",description:"Yes/No checkbox",icon:"✅",category:"field",subCategory:"selection",dataType:"boolean",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Decision Box Settings",icon:"✅"},fields:[{key:"checkedLabel",label:"Checked Label",type:"text",section:"config",placeholder:"Yes",description:"Label shown when checked",colSpan:1},{key:"uncheckedLabel",label:"Unchecked Label",type:"text",section:"config",placeholder:"No",description:"Label shown when unchecked",colSpan:1},{key:"showAsSwitch",label:"Show as Toggle Switch",type:"checkbox",section:"config",description:"Display as a switch instead of a checkbox"}]},getDefaultValues:()=>({properties:{label:"I agree to the terms and conditions"},layout:{labelPosition:"top",size:"full"},config:{checkedLabel:"Yes",uncheckedLabel:"No"}}),renderOnCanvas:e=>{const{label:t,description:r,required:o}=K(e);return l.jsx("div",{className:m("space-y-1.5"),children:l.jsxs("label",{className:m("flex items-start gap-3 cursor-pointer"),children:[l.jsx("input",{type:"checkbox",disabled:!0,className:m("mt-1 text-blue-600 rounded")}),l.jsxs("div",{children:[l.jsx("span",{className:m("text-sm text-gray-700"),children:t}),o&&l.jsx("span",{className:m("text-red-500 ml-1"),children:"*"}),r&&l.jsx("p",{className:m("text-xs text-gray-500 mt-0.5"),children:r})]})]})})},render:e=>{const{label:t,description:r,required:o,value:n,onChange:s,errors:a,isDisabled:i}=K(e);return l.jsxs("div",{className:m("space-y-1.5"),children:[l.jsxs("label",{className:m("flex items-start gap-3 cursor-pointer"),children:[l.jsx("input",{type:"checkbox",checked:n??!1,onChange:c=>s==null?void 0:s(c.target.checked),disabled:i,className:m("mt-1 text-blue-600 rounded")}),l.jsxs("div",{children:[l.jsx("span",{className:m("text-sm text-gray-700"),children:t}),o&&l.jsx("span",{className:m("text-red-500 ml-1"),children:"*"}),r&&l.jsx("p",{className:m("text-xs text-gray-500 mt-0.5"),children:r})]})]}),a&&a.length>0&&l.jsx("div",{className:m("space-y-1"),children:a.map((c,d)=>l.jsx("p",{className:m("text-xs text-red-500"),children:c},d))})]})}},{type:"toggleSwitch",structure:"field",typeCategory:"Selection",label:"Toggle Switch",description:"On/Off toggle switch",icon:"🔀",category:"field",subCategory:"selection",dataType:"boolean",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Toggle Settings",icon:"🔀"},fields:[{key:"onLabel",label:"On Label",type:"text",section:"config",placeholder:"On",description:"Label for the active state",colSpan:1},{key:"offLabel",label:"Off Label",type:"text",section:"config",placeholder:"Off",description:"Label for the inactive state",colSpan:1},{key:"showLabels",label:"Show State Labels",type:"checkbox",section:"config",description:"Display on/off text next to the switch"},{key:"defaultValue",label:"Default State",type:"select",section:"config",description:"Initial state of the switch",options:[{value:"off",label:"Off (unchecked)"},{value:"on",label:"On (checked)"}]}]},getDefaultValues:()=>({properties:{label:"Toggle Switch",description:"Toggle on or off"},layout:{labelPosition:"top",size:"full"},config:{onLabel:"On",offLabel:"Off"}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e);return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsxs("div",{className:m("flex items-center gap-2"),children:[l.jsx("span",{className:m("text-sm text-gray-500"),children:(s==null?void 0:s.offLabel)||"Off"}),l.jsx("div",{className:m("relative w-11 h-6 bg-gray-300 rounded-full"),children:l.jsx("div",{className:m("absolute left-1 top-1 w-4 h-4 bg-white rounded-full transition-transform")})}),l.jsx("span",{className:m("text-sm text-gray-500"),children:(s==null?void 0:s.onLabel)||"On"})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),p=s??!1;return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsxs("div",{className:m("flex items-center gap-2"),children:[l.jsx("span",{className:m("text-sm text-gray-500"),children:(d==null?void 0:d.offLabel)||"Off"}),l.jsx("button",{type:"button",onClick:()=>!c&&(a==null?void 0:a(!p)),disabled:c,className:`relative w-11 h-6 rounded-full transition-colors ${p?"bg-blue-600":"bg-gray-300"} ${c?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:l.jsx("div",{className:`absolute top-1 w-4 h-4 bg-white rounded-full transition-transform ${p?"translate-x-6":"translate-x-1"}`})}),l.jsx("span",{className:m("text-sm text-gray-500"),children:(d==null?void 0:d.onLabel)||"On"})]})})}}];var L0=Object.defineProperty,F0=(e,t)=>L0(e,"name",{value:t,configurable:!0});function Ci(e,[t,r]){return Math.min(r,Math.max(t,e))}F0(Ci,"clamp");var V0=Object.defineProperty,nn=(e,t)=>V0(e,"name",{value:t,configurable:!0}),yf=!!(typeof window<"u"&&window.document&&window.document.createElement);function Se(e,t,{checkForDefaultPrevented:r=!0}={}){return nn(function(n){if(e==null||e(n),r===!1||!n||!n.defaultPrevented)return t==null?void 0:t(n)},"handleEvent")}nn(Se,"composeEventHandlers");function G0(e){var t;if(!yf)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}nn(G0,"getOwnerWindow");function Ei(e){if(!yf)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}nn(Ei,"getOwnerDocument");function vf(e,t=!1){const{activeElement:r}=Ei(e);if(!(r!=null&&r.nodeName))return null;if(xf(r)&&r.contentDocument)return vf(r.contentDocument.body,t);if(t){const o=r.getAttribute("aria-activedescendant");if(o){const n=Ei(r).getElementById(o);if(n)return n}}return r}nn(vf,"getActiveElement");function xf(e){return e.tagName==="IFRAME"}nn(xf,"isFrame");var z0=Object.defineProperty,nr=(e,t)=>z0(e,"name",{value:t,configurable:!0});function B0(e,t){const r=S.createContext(t);r.displayName=e+"Context";const o=nr(s=>{const{children:a,...i}=s,c=S.useMemo(()=>i,Object.values(i));return l.jsx(r.Provider,{value:c,children:a})},"Provider");o.displayName=e+"Provider";function n(s,a={}){const{optional:i=!1}=a,c=S.useContext(r);if(c)return c;if(t!==void 0)return t;if(!i)throw new Error(`\`${s}\` must be used within \`${e}\``)}return nr(n,"useContext"),[o,n]}nr(B0,"createContext");function sr(e,t=[]){let r=[];function o(s,a){const i=S.createContext(a);i.displayName=s+"Context";const c=r.length;r=[...r,a];const d=nr(u=>{var v;const{scope:f,children:h,...g}=u,y=((v=f==null?void 0:f[e])==null?void 0:v[c])||i,b=S.useMemo(()=>g,Object.values(g));return l.jsx(y.Provider,{value:b,children:h})},"Provider");d.displayName=s+"Provider";function p(u,f,h={}){var v;const{optional:g=!1}=h,y=((v=f==null?void 0:f[e])==null?void 0:v[c])||i,b=S.useContext(y);if(b)return b;if(a!==void 0)return a;if(!g)throw new Error(`\`${u}\` must be used within \`${s}\``)}return nr(p,"useContext"),[d,p]}nr(o,"createContext");const n=nr(()=>{const s=r.map(a=>S.createContext(a));return nr(function(i){const c=(i==null?void 0:i[e])||s;return S.useMemo(()=>({[`__scope${e}`]:{...i,[e]:c}}),[i,c])},"useScope")},"createScope");return n.scopeName=e,[o,wf(n,...t)]}nr(sr,"createContextScope");function wf(...e){const t=e[0];if(e.length===1)return t;const r=nr(()=>{const o=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return nr(function(s){const a=o.reduce((i,{useScope:c,scopeName:d})=>{const u=c(s)[`__scope${d}`];return{...i,...u}},{});return S.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])},"useComposedScopes")},"createScope");return r.scopeName=t.scopeName,r}nr(wf,"composeContextScopes");var U0=Object.defineProperty,_i=(e,t)=>U0(e,"name",{value:t,configurable:!0});function ki(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}_i(ki,"setRef");function Sf(...e){return t=>{let r=!1;const o=e.map(n=>{const s=ki(n,t);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let n=0;n<o.length;n++){const s=o[n];typeof s=="function"?s():ki(e[n],null)}}}}_i(Sf,"composeRefs");function Ue(...e){return S.useCallback(Sf(...e),e)}_i(Ue,"useComposedRefs");var W0=Object.defineProperty,mr=(e,t)=>W0(e,"name",{value:t,configurable:!0});function Yr(e){const t=S.forwardRef((r,o)=>{let{children:n,...s}=r,a=null,i=!1;const c=[];Ai(n)&&typeof oa=="function"&&(n=oa(n._payload)),S.Children.forEach(n,f=>{var h;if(kf(f)){i=!0;const g=f;let y="child"in g.props?g.props.child:g.props.children;Ai(y)&&typeof oa=="function"&&(y=oa(y._payload)),a=j0(g,y),c.push((h=a==null?void 0:a.props)==null?void 0:h.children)}else c.push(f)}),a?a=S.cloneElement(a,void 0,c):!i&&S.Children.count(n)===1&&S.isValidElement(n)&&(a=n);const d=a?_f(a):void 0,p=Ue(o,d);if(!a){if(n||n===0)throw new Error(i?Q0(e):Y0(e));return n}const u=Ef(s,a.props??{});return a.type!==S.Fragment&&(u.ref=o?p:d),S.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}mr(Yr,"createSlot");var H0=Yr("Slot"),Nf=Symbol.for("radix.slottable");function Cf(e){const t=mr(r=>"child"in r?r.children(r.child):r.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=Nf,t}mr(Cf,"createSlottable");var j0=mr((e,t)=>{if("child"in e.props){const r=e.props.child;return S.isValidElement(r)?S.cloneElement(r,void 0,e.props.children(r.props.children)):null}return S.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function Ef(e,t){const r={...t};for(const o in t){const n=e[o],s=t[o];/^on[A-Z]/.test(o)?n&&s?r[o]=(...i)=>{const c=s(...i);return n(...i),c}:n&&(r[o]=n):o==="style"?r[o]={...n,...s}:o==="className"&&(r[o]=[n,s].filter(Boolean).join(" "))}return{...e,...r}}mr(Ef,"mergeProps");function _f(e){var o,n;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(n=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}mr(_f,"getElementRef");function kf(e){return S.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Nf}mr(kf,"isSlottable");var q0=Symbol.for("react.lazy");function Ai(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===q0&&"_payload"in e&&Af(e._payload)}mr(Ai,"isLazyComponent");function Af(e){return typeof e=="object"&&e!==null&&"then"in e}mr(Af,"isPromiseLike");var Y0=mr(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),Q0=mr(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),oa=S[" use ".trim().toString()],K0=Object.defineProperty,xt=(e,t)=>K0(e,"name",{value:t,configurable:!0});function na(e){const t=e+"CollectionProvider",[r,o]=sr(t),[n,s]=r(t,{collectionRef:{current:null},itemMap:new Map}),a=xt(y=>{const{scope:b,children:v}=y,N=S.useRef(null),x=S.useRef(new Map).current;return l.jsx(n,{scope:b,itemMap:x,collectionRef:N,children:v})},"CollectionProvider");a.displayName=t;const i=e+"CollectionSlot",c=Yr(i),d=S.forwardRef((y,b)=>{const{scope:v,children:N}=y,x=s(i,v),w=Ue(b,x.collectionRef);return l.jsx(c,{ref:w,children:N})});d.displayName=i;const p=e+"CollectionItemSlot",u="data-radix-collection-item",f=Yr(p),h=S.forwardRef((y,b)=>{const{scope:v,children:N,...x}=y,w=S.useRef(null),C=Ue(b,w),E=s(p,v);return S.useEffect(()=>(E.itemMap.set(w,{ref:w,...x}),()=>void E.itemMap.delete(w))),l.jsx(f,{[u]:"",ref:C,children:N})});h.displayName=p;function g(y){const b=s(e+"CollectionConsumer",y);return S.useCallback(()=>{const N=b.collectionRef.current;if(!N)return[];const x=Array.from(N.querySelectorAll(`[${u}]`));return Array.from(b.itemMap.values()).sort((E,k)=>x.indexOf(E.ref.current)-x.indexOf(k.ref.current))},[b.collectionRef,b.itemMap])}return xt(g,"useCollection"),[{Provider:a,Slot:d,ItemSlot:h},g,o]}xt(na,"createCollection");var Df=new WeakMap,Di=(tr=class extends Map{constructor(r){super(r);sw(this,mt);Eu(this,mt,[...super.keys()]),Df.set(this,!0)}set(r,o){return Df.get(this)&&(this.has(r)?Bt(this,mt)[Bt(this,mt).indexOf(r)]=r:Bt(this,mt).push(r)),super.set(r,o),this}insert(r,o,n){const s=this.has(o),a=Bt(this,mt).length,i=$i(r);let c=i>=0?i:a+i;const d=c<0||c>=a?-1:c;if(d===this.size||s&&d===this.size-1||d===-1)return this.set(o,n),this;const p=this.size+(s?0:1);i<0&&c++;const u=[...Bt(this,mt)];let f,h=!1;for(let g=c;g<p;g++)if(c===g){let y=u[g];u[g]===o&&(y=u[g+1]),s&&this.delete(o),f=this.get(y),this.set(o,n)}else{!h&&u[g-1]===o&&(h=!0);const y=u[h?g:g-1],b=f;f=this.get(y),this.delete(y),this.set(y,b)}return this}with(r,o,n){const s=new tr(this);return s.insert(r,o,n),s}before(r){const o=Bt(this,mt).indexOf(r)-1;if(!(o<0))return this.entryAt(o)}setBefore(r,o,n){const s=Bt(this,mt).indexOf(r);return s===-1?this:this.insert(s,o,n)}after(r){let o=Bt(this,mt).indexOf(r);if(o=o===-1||o===this.size-1?-1:o+1,o!==-1)return this.entryAt(o)}setAfter(r,o,n){const s=Bt(this,mt).indexOf(r);return s===-1?this:this.insert(s+1,o,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Eu(this,mt,[]),super.clear()}delete(r){const o=super.delete(r);return o&&Bt(this,mt).splice(Bt(this,mt).indexOf(r),1),o}deleteAt(r){const o=this.keyAt(r);return o!==void 0?this.delete(o):!1}at(r){const o=sa(Bt(this,mt),r);if(o!==void 0)return this.get(o)}entryAt(r){const o=sa(Bt(this,mt),r);if(o!==void 0)return[o,this.get(o)]}indexOf(r){return Bt(this,mt).indexOf(r)}keyAt(r){return sa(Bt(this,mt),r)}from(r,o){const n=this.indexOf(r);if(n===-1)return;let s=n+o;return s<0&&(s=0),s>=this.size&&(s=this.size-1),this.at(s)}keyFrom(r,o){const n=this.indexOf(r);if(n===-1)return;let s=n+o;return s<0&&(s=0),s>=this.size&&(s=this.size-1),this.keyAt(s)}find(r,o){let n=0;for(const s of this){if(Reflect.apply(r,o,[s,n,this]))return s;n++}}findIndex(r,o){let n=0;for(const s of this){if(Reflect.apply(r,o,[s,n,this]))return n;n++}return-1}filter(r,o){const n=[];let s=0;for(const a of this)Reflect.apply(r,o,[a,s,this])&&n.push(a),s++;return new tr(n)}map(r,o){const n=[];let s=0;for(const a of this)n.push([a[0],Reflect.apply(r,o,[a,s,this])]),s++;return new tr(n)}reduce(...r){const[o,n]=r;let s=0,a=n??this.at(0);for(const i of this)s===0&&r.length===1?a=i:a=Reflect.apply(o,this,[a,i,s,this]),s++;return a}reduceRight(...r){const[o,n]=r;let s=n??this.at(-1);for(let a=this.size-1;a>=0;a--){const i=this.at(a);a===this.size-1&&r.length===1?s=i:s=Reflect.apply(o,this,[s,i,a,this])}return s}toSorted(r){const o=[...this.entries()].sort(r);return new tr(o)}toReversed(){const r=new tr;for(let o=this.size-1;o>=0;o--){const n=this.keyAt(o),s=this.get(n);r.set(n,s)}return r}toSpliced(...r){const o=[...this.entries()];return o.splice(...r),new tr(o)}slice(r,o){const n=new tr;let s=this.size-1;if(r===void 0)return n;r<0&&(r=r+this.size),o!==void 0&&o>0&&(s=o-1);for(let a=r;a<=s;a++){const i=this.keyAt(a),c=this.get(i);n.set(i,c)}return n}every(r,o){let n=0;for(const s of this){if(!Reflect.apply(r,o,[s,n,this]))return!1;n++}return!0}some(r,o){let n=0;for(const s of this){if(Reflect.apply(r,o,[s,n,this]))return!0;n++}return!1}},mt=new WeakMap,xt(tr,"OrderedDict"),tr);function sa(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const r=$f(e,t);return r===-1?void 0:e[r]}xt(sa,"at");function $f(e,t){const r=e.length,o=$i(t),n=o>=0?o:r+o;return n<0||n>=r?-1:n}xt($f,"toSafeIndex");function $i(e){return e!==e||e===0?0:Math.trunc(e)}xt($i,"toSafeInteger");function R0(e){const t=e+"CollectionProvider",[r,o]=sr(t),[n,s]=r(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Di,setItemMap:xt(()=>{},"setItemMap")}),a=xt(({state:x,...w})=>x?l.jsx(c,{...w,state:x}):l.jsx(i,{...w}),"CollectionProvider");a.displayName=t;const i=xt(x=>{const w=b();return l.jsx(c,{...x,state:w})},"CollectionInit");i.displayName=t+"Init";const c=xt(x=>{const{scope:w,children:C,state:E}=x,k=S.useRef(null),[_,D]=S.useState(null),A=Ue(k,D),[I,T]=E;return S.useEffect(()=>{if(!_)return;const L=If(()=>{});return L.observe(_,{childList:!0,subtree:!0}),()=>{L.disconnect()}},[_]),l.jsx(n,{scope:w,itemMap:I,setItemMap:T,collectionRef:A,collectionRefObject:k,collectionElement:_,children:C})},"CollectionProviderImpl");c.displayName=t+"Impl";const d=e+"CollectionSlot",p=Yr(d),u=S.forwardRef((x,w)=>{const{scope:C,children:E}=x,k=s(d,C),_=Ue(w,k.collectionRef);return l.jsx(p,{ref:_,children:E})});u.displayName=d;const f=e+"CollectionItemSlot",h="data-radix-collection-item",g=Yr(f),y=S.forwardRef((x,w)=>{const{scope:C,children:E,...k}=x,_=S.useRef(null),[D,A]=S.useState(null),I=Ue(w,_,A),T=s(f,C),{setItemMap:L}=T,F=S.useRef(k);Tf(F.current,k)||(F.current=k);const B=F.current;return S.useEffect(()=>{const G=B;return L(z=>D?z.has(D)?z.set(D,{...G,element:D}).toSorted(Ti):(z.set(D,{...G,element:D}),z.toSorted(Ti)):z),()=>{L(z=>!D||!z.has(D)?z:(z.delete(D),new Di(z)))}},[D,B,L]),l.jsx(g,{[h]:"",ref:I,children:E})});y.displayName=f;function b(){return S.useState(new Di)}xt(b,"useInitCollection");function v(x){const{itemMap:w}=s(e+"CollectionConsumer",x);return w}return xt(v,"useCollection"),[{Provider:a,Slot:u,ItemSlot:y},{createCollectionScope:o,useCollection:v,useInitCollection:b}]}xt(R0,"createCollection");function Tf(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(const n of r)if(!Object.prototype.hasOwnProperty.call(t,n)||e[n]!==t[n])return!1;return!0}xt(Tf,"shallowEqual");function Pf(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}xt(Pf,"isElementPreceding");function Ti(e,t){return!e[1].element||!t[1].element?0:Pf(e[1].element,t[1].element)?-1:1}xt(Ti,"sortByDocumentPosition");function If(e){return new MutationObserver(r=>{for(const o of r)if(o.type==="childList"){e();return}})}xt(If,"getChildListObserver");var X0=Object.defineProperty,J0=(e,t)=>X0(e,"name",{value:t,configurable:!0}),Z0=S.createContext(void 0);function Vn(e){const t=S.useContext(Z0);return e||t||"ltr"}J0(Vn,"useDirection");var eS=Object.defineProperty,tS=(e,t)=>eS(e,"name",{value:t,configurable:!0}),rS=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=rS.reduce((e,t)=>{const r=Yr(`Primitive.${t}`),o=S.forwardRef((n,s)=>{const{asChild:a,...i}=n,c=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...i,ref:s})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function Of(e,t){e&&Tn.flushSync(()=>e.dispatchEvent(t))}tS(Of,"dispatchDiscreteCustomEvent");var oS=Object.defineProperty,nS=(e,t)=>oS(e,"name",{value:t,configurable:!0});function gr(e){const t=S.useRef(e);return S.useEffect(()=>{t.current=e}),S.useMemo(()=>((...r)=>{var o;return(o=t.current)==null?void 0:o.call(t,...r)}),[])}nS(gr,"useCallbackRef");var sS=Object.defineProperty,wt=(e,t)=>sS(e,"name",{value:t,configurable:!0}),Pi="dismissableLayer.update",aS="dismissableLayer.pointerDownOutside",lS="dismissableLayer.focusOutside",Mf,Lf=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ii=S.forwardRef(wt(function(t,r){const{disableOutsidePointerEvents:o=!1,deferPointerDownOutside:n=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:c,onDismiss:d,...p}=t,u=S.useContext(Lf),[f,h]=S.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=S.useState({}),b=Ue(r,h),v=Array.from(u.layers),[N]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=N?v.indexOf(N):-1,w=f?v.indexOf(f):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,E=w>=x,k=S.useRef(!1),_=Vf(T=>{a==null||a(T),c==null||c(T),T.defaultPrevented||d==null||d()},{ownerDocument:g,deferPointerDownOutside:n,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:S.useCallback(T=>{if(!(T instanceof Node))return!1;const L=[...u.branches].some(F=>F.contains(T));return E&&!L},[u.branches,E])}),D=Gf(T=>{if(n&&k.current)return;const L=T.target;[...u.branches].some(B=>B.contains(L))||(i==null||i(T),c==null||c(T),T.defaultPrevented||d==null||d())},g),A=f?w===v.length-1:!1,I=gr(T=>{T.key==="Escape"&&(s==null||s(T),!T.defaultPrevented&&d&&(T.preventDefault(),d()))});return S.useEffect(()=>{if(A)return g.addEventListener("keydown",I,{capture:!0}),()=>g.removeEventListener("keydown",I,{capture:!0})},[g,A,I]),S.useEffect(()=>{if(f)return o&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Mf=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Oi(),()=>{o&&(u.layersWithOutsidePointerEventsDisabled.delete(f),u.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=Mf))}},[f,g,o,u]),S.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Oi())},[f,u]),S.useEffect(()=>{const T=wt(()=>y({}),"handleUpdate");return document.addEventListener(Pi,T),()=>document.removeEventListener(Pi,T)},[]),l.jsx(Ie.div,{...p,ref:b,style:{pointerEvents:C?E?"auto":"none":void 0,...t.style},onFocusCapture:Se(t.onFocusCapture,D.onFocusCapture),onBlurCapture:Se(t.onBlurCapture,D.onBlurCapture),onPointerDownCapture:Se(t.onPointerDownCapture,_.onPointerDownCapture)})},"DismissableLayer"));function Ff(){const e=S.useContext(Lf),[t,r]=S.useState(null);return S.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),r}wt(Ff,"useDismissableLayerSurface");var iS=wt(()=>!0,"IS_TRUE");function Vf(e,t){const{ownerDocument:r=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:o=!1,isDeferredPointerDownOutsideRef:n,dismissableSurfaces:s,shouldHandlePointerDownOutside:a=iS}=t,i=gr(e),c=S.useRef(!1),d=S.useRef(!1),p=S.useRef(new Map),u=S.useRef(()=>{});return S.useEffect(()=>{function f(){d.current=!1,n.current=!1,p.current.clear()}wt(f,"resetOutsideInteraction");function h(){return Array.from(p.current.values()).some(Boolean)}wt(h,"isOutsideInteractionIntercepted");function g(x){if(!d.current)return;const w=x.target;w instanceof Node&&[...s].some(E=>E.contains(w))||p.current.set(x.type,!0),x.type==="click"&&window.setTimeout(()=>{d.current&&u.current()},0)}wt(g,"handleInteractionCapture");function y(x){d.current&&p.current.set(x.type,!1)}wt(y,"handleInteractionBubble");const b=wt(x=>{if(x.target&&!c.current){let w=function(){r.removeEventListener("click",u.current);const E=h();f(),E||Mi(aS,i,C,{discrete:!0})};if(wt(w,"handleAndDispatchPointerDownOutsideEvent"),!a(x.target)){r.removeEventListener("click",u.current),f(),c.current=!1;return}const C={originalEvent:x};d.current=!0,n.current=o&&x.button===0,p.current.clear(),!o||x.button!==0?w():(r.removeEventListener("click",u.current),u.current=w,r.addEventListener("click",u.current,{once:!0}))}else r.removeEventListener("click",u.current),f();c.current=!1},"handlePointerDown"),v=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const x of v)r.addEventListener(x,g,!0),r.addEventListener(x,y);const N=window.setTimeout(()=>{r.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(N),r.removeEventListener("pointerdown",b),r.removeEventListener("click",u.current);for(const x of v)r.removeEventListener(x,g,!0),r.removeEventListener(x,y)}},[r,i,o,n,s,a]),{onPointerDownCapture:wt(()=>c.current=!0,"onPointerDownCapture")}}wt(Vf,"usePointerDownOutside");function Gf(e,t=globalThis==null?void 0:globalThis.document){const r=gr(e),o=S.useRef(!1);return S.useEffect(()=>{const n=wt(s=>{s.target&&!o.current&&Mi(lS,r,{originalEvent:s},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",n),()=>t.removeEventListener("focusin",n)},[t,r]),{onFocusCapture:wt(()=>o.current=!0,"onFocusCapture"),onBlurCapture:wt(()=>o.current=!1,"onBlurCapture")}}wt(Gf,"useFocusOutside");function Oi(){const e=new CustomEvent(Pi);document.dispatchEvent(e)}wt(Oi,"dispatchUpdate");function Mi(e,t,r,{discrete:o}){const n=r.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),o?Of(n,s):n.dispatchEvent(s)}wt(Mi,"handleAndDispatchCustomEvent");var cS=Object.defineProperty,Li=(e,t)=>cS(e,"name",{value:t,configurable:!0}),aa=0,Dr=null;function dS(e){return la(),e.children}Li(dS,"FocusGuards");function la(){S.useEffect(()=>{Dr||(Dr={start:Fi(),end:Fi()});const{start:e,end:t}=Dr;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),aa++,()=>{aa===1&&(Dr==null||Dr.start.remove(),Dr==null||Dr.end.remove(),Dr=null),aa=Math.max(0,aa-1)}},[])}Li(la,"useFocusGuards");function Fi(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}Li(Fi,"createFocusGuard");var uS=Object.defineProperty,Wt=(e,t)=>uS(e,"name",{value:t,configurable:!0}),Vi="focusScope.autoFocusOnMount",Gi="focusScope.autoFocusOnUnmount",zf={bubbles:!1,cancelable:!0},Bf=S.forwardRef(Wt(function(t,r){const{loop:o=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=t,[c,d]=S.useState(null),p=gr(s),u=gr(a),f=S.useRef(null),h=Ue(r,d),g=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(n){let b=function(w){if(g.paused||!c)return;const C=w.target;c.contains(C)?f.current=C:Qr(f.current,{select:!0})},v=function(w){if(g.paused||!c)return;const C=w.relatedTarget;C!==null&&(c.contains(C)||Qr(f.current,{select:!0}))},N=function(w){if(document.activeElement===document.body)for(const E of w)E.removedNodes.length>0&&Qr(c)};Wt(b,"handleFocusIn"),Wt(v,"handleFocusOut"),Wt(N,"handleMutations"),document.addEventListener("focusin",b),document.addEventListener("focusout",v);const x=new MutationObserver(N);return c&&x.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",v),x.disconnect()}}},[n,c,g.paused]),S.useEffect(()=>{if(c){qf.add(g);const b=document.activeElement;if(!c.contains(b)){const N=new CustomEvent(Vi,zf);c.addEventListener(Vi,p),c.dispatchEvent(N),N.defaultPrevented||(Uf(Qf(zi(c)),{select:!0}),document.activeElement===b&&Qr(c))}return()=>{c.removeEventListener(Vi,p),setTimeout(()=>{const N=new CustomEvent(Gi,zf);c.addEventListener(Gi,u),c.dispatchEvent(N),N.defaultPrevented||Qr(b??document.body,{select:!0}),c.removeEventListener(Gi,u),qf.remove(g)},0)}}},[c,p,u,g]);const y=S.useCallback(b=>{if(!o&&!n||g.paused)return;const v=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,N=document.activeElement;if(v&&N){const x=b.currentTarget,[w,C]=Wf(x);w&&C?!b.shiftKey&&N===C?(b.preventDefault(),o&&Qr(w,{select:!0})):b.shiftKey&&N===w&&(b.preventDefault(),o&&Qr(C,{select:!0})):N===x&&b.preventDefault()}},[o,n,g.paused]);return l.jsx(Ie.div,{tabIndex:-1,...i,ref:h,onKeyDown:y})},"FocusScope"));function Uf(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(Qr(o,{select:t}),document.activeElement!==r)return}Wt(Uf,"focusFirst");function Wf(e){const t=zi(e),r=Bi(t,e),o=Bi(t.reverse(),e);return[r,o]}Wt(Wf,"getTabbableEdges");function zi(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Wt(o=>{const n=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||n?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;r.nextNode();)t.push(r.currentNode);return t}Wt(zi,"getTabbableCandidates");function Bi(e,t){const r=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const o of e)if(!(r?!o.checkVisibility({checkVisibilityCSS:!0}):Hf(o,{upTo:t})))return o}Wt(Bi,"findVisible");function Hf(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}Wt(Hf,"isHidden");function jf(e){return e instanceof HTMLInputElement&&"select"in e}Wt(jf,"isSelectableInput");function Qr(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&jf(e)&&t&&e.select()}}Wt(Qr,"focus");var qf=Yf();function Yf(){let e=[];return{add(t){const r=e[0];t!==r&&(r==null||r.pause()),e=Ui(e,t),e.unshift(t)},remove(t){var r;e=Ui(e,t),(r=e[0])==null||r.resume()}}}Wt(Yf,"createFocusScopesStack");function Ui(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}Wt(Ui,"arrayRemove");function Qf(e){return e.filter(t=>t.tagName!=="A")}Wt(Qf,"removeLinks");var ot=globalThis!=null&&globalThis.document?S.useLayoutEffect:()=>{},fS=Object.defineProperty,pS=(e,t)=>fS(e,"name",{value:t,configurable:!0}),hS=S[" useId ".trim().toString()]||(()=>{}),mS=0;function br(e){const[t,r]=S.useState(hS());return ot(()=>{e||r(o=>o??String(mS++))},[e]),e||(t?`radix-${t}`:"")}pS(br,"useId");const gS=["top","right","bottom","left"],po=Math.min,Kr=Math.max,ia=Math.round,ca=Math.floor,Rr=e=>({x:e,y:e}),bS={left:"right",right:"left",bottom:"top",top:"bottom"};function Kf(e,t,r){return Kr(e,po(t,r))}function Xr(e,t){return typeof e=="function"?e(t):e}function ho(e){return e.split("-")[0]}function sn(e){return e.split("-")[1]}function Wi(e){return e==="x"?"y":"x"}function Hi(e){return e==="y"?"height":"width"}function $r(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ji(e){return Wi($r(e))}function yS(e,t,r){r===void 0&&(r=!1);const o=sn(e),n=ji(e),s=Hi(n);let a=n==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=da(a)),[a,da(a)]}function vS(e){const t=da(e);return[qi(e),t,qi(t)]}function qi(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Rf=["left","right"],Xf=["right","left"],xS=["top","bottom"],wS=["bottom","top"];function SS(e,t,r){switch(e){case"top":case"bottom":return r?t?Xf:Rf:t?Rf:Xf;case"left":case"right":return t?xS:wS;default:return[]}}function NS(e,t,r,o){const n=sn(e);let s=SS(ho(e),r==="start",o);return n&&(s=s.map(a=>a+"-"+n),t&&(s=s.concat(s.map(qi)))),s}function da(e){const t=ho(e);return bS[t]+e.slice(t.length)}function CS(e){var t,r,o,n;return{top:(t=e.top)!=null?t:0,right:(r=e.right)!=null?r:0,bottom:(o=e.bottom)!=null?o:0,left:(n=e.left)!=null?n:0}}function Jf(e){return typeof e!="number"?CS(e):{top:e,right:e,bottom:e,left:e}}function ua(e){const{x:t,y:r,width:o,height:n}=e;return{width:o,height:n,top:r,left:t,right:t+o,bottom:r+n,x:t,y:r}}function Zf(e,t,r){let{reference:o,floating:n}=e;const s=$r(t),a=ji(t),i=Hi(a),c=ho(t),d=s==="y",p=o.x+o.width/2-n.width/2,u=o.y+o.height/2-n.height/2,f=o[i]/2-n[i]/2;let h;switch(c){case"top":h={x:p,y:o.y-n.height};break;case"bottom":h={x:p,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:u};break;case"left":h={x:o.x-n.width,y:u};break;default:h={x:o.x,y:o.y}}const g=sn(t);return g&&(h[a]+=f*(g==="end"?1:-1)*(r&&d?-1:1)),h}async function ES(e,t){var r;t===void 0&&(t={});const{x:o,y:n,platform:s,rects:a,elements:i,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:p="viewport",elementContext:u="floating",altBoundary:f=!1,padding:h=0}=Xr(t,e),g=Jf(h),b=i[f?u==="floating"?"reference":"floating":u],v=ua(await s.getClippingRect({element:(r=await(s.isElement==null?void 0:s.isElement(b)))==null||r?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(i.floating)),boundary:d,rootBoundary:p,strategy:c})),N=u==="floating"?{x:o,y:n,width:a.floating.width,height:a.floating.height}:a.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(i.floating)),w=await(s.isElement==null?void 0:s.isElement(x))&&await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1},C=ua(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:i,rect:N,offsetParent:x,strategy:c}):N);return{top:(v.top-C.top+g.top)/w.y,bottom:(C.bottom-v.bottom+g.bottom)/w.y,left:(v.left-C.left+g.left)/w.x,right:(C.right-v.right+g.right)/w.x}}const _S=50,kS=async(e,t,r)=>{const{placement:o="bottom",strategy:n="absolute",middleware:s=[],platform:a}=r,i=a.detectOverflow?a:{...a,detectOverflow:ES},c=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:n}),{x:p,y:u}=Zf(d,o,c),f=o,h=0;const g={};for(let y=0;y<s.length;y++){const b=s[y];if(!b)continue;const{name:v,fn:N}=b,{x,y:w,data:C,reset:E}=await N({x:p,y:u,initialPlacement:o,placement:f,strategy:n,middlewareData:g,rects:d,platform:i,elements:{reference:e,floating:t}});p=x??p,u=w??u,g[v]={...g[v],...C},E&&h<_S&&(h++,typeof E=="object"&&(E.placement&&(f=E.placement),E.rects&&(d=E.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:n}):E.rects),{x:p,y:u}=Zf(d,f,c)),y=-1)}return{x:p,y:u,placement:f,strategy:n,middlewareData:g}},AS=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:o,placement:n,rects:s,platform:a,elements:i,middlewareData:c}=t,{element:d,padding:p=0}=Xr(e,t)||{};if(d==null)return{};const u=Jf(p),f={x:r,y:o},h=ji(n),g=Hi(h),y=await a.getDimensions(d),b=h==="y",v=b?"top":"left",N=b?"bottom":"right",x=b?"clientHeight":"clientWidth",w=s.reference[g]+s.reference[h]-f[h]-s.floating[g],C=f[h]-s.reference[h],E=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let k=E?E[x]:0;(!k||!await(a.isElement==null?void 0:a.isElement(E)))&&(k=i.floating[x]||s.floating[g]);const _=w/2-C/2,D=k/2-y[g]/2-1,A=po(u[v],D),I=po(u[N],D),T=k-y[g]-I,L=k/2-y[g]/2+_,F=Kf(A,L,T),B=!c.arrow&&sn(n)!=null&&L!==F&&s.reference[g]/2-(L<A?A:I)-y[g]/2<0,G=B?L<A?L-A:L-T:0;return{[h]:f[h]+G,data:{[h]:F,centerOffset:L-F-G,...B&&{alignmentOffset:G}},reset:B}}}),DS=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,o;const{placement:n,middlewareData:s,rects:a,initialPlacement:i,platform:c,elements:d}=t,{mainAxis:p=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...b}=Xr(e,t);if((r=s.arrow)!=null&&r.alignmentOffset)return{};const v=ho(n),N=$r(i),x=ho(i)===i,w=await(c.isRTL==null?void 0:c.isRTL(d.floating)),C=f||(x||!y?[da(i)]:vS(i)),E=g!=="none";!f&&E&&C.push(...NS(i,y,g,w));const k=[i,...C],_=await c.detectOverflow(t,b),D=[];let A=((o=s.flip)==null?void 0:o.overflows)||[];if(p&&D.push(_[v]),u){const F=yS(n,a,w);D.push(_[F[0]],_[F[1]])}if(A=[...A,{placement:n,overflows:D}],!D.every(F=>F<=0)){var I,T;const F=(((I=s.flip)==null?void 0:I.index)||0)+1,B=k[F];if(B&&(!(u==="alignment"?N!==$r(B):!1)||A.every(H=>$r(H.placement)===N?H.overflows[0]>0:!0)))return{data:{index:F,overflows:A},reset:{placement:B}};let G=(T=A.filter(z=>z.overflows[0]<=0).sort((z,H)=>z.overflows[1]-H.overflows[1])[0])==null?void 0:T.placement;if(!G)switch(h){case"bestFit":{var L;const z=(L=A.filter(H=>{if(E){const V=$r(H.placement);return V===N||V==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(V=>V>0).reduce((V,W)=>V+W,0)]).sort((H,V)=>H[1]-V[1])[0])==null?void 0:L[0];z&&(G=z);break}case"initialPlacement":G=i;break}if(n!==G)return{reset:{placement:G}}}return{}}}};function ep(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function tp(e){return gS.some(t=>e[t]>=0)}const $S=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:o}=t,{strategy:n="referenceHidden",...s}=Xr(e,t);switch(n){case"referenceHidden":{const a=await o.detectOverflow(t,{...s,elementContext:"reference"}),i=ep(a,r.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:tp(i)}}}case"escaped":{const a=await o.detectOverflow(t,{...s,altBoundary:!0}),i=ep(a,r.floating);return{data:{escapedOffsets:i,escaped:tp(i)}}}default:return{}}}}},rp=new Set(["left","top"]);async function TS(e,t){const{placement:r,platform:o,elements:n}=e,s=await(o.isRTL==null?void 0:o.isRTL(n.floating)),a=ho(r),i=sn(r),c=$r(r)==="y",d=rp.has(a)?-1:1,p=s&&c?-1:1,u=Xr(t,e);let{mainAxis:f,crossAxis:h,alignmentAxis:g}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return i&&typeof g=="number"&&(h=i==="end"?g*-1:g),c?{x:h*p,y:f*d}:{x:f*d,y:h*p}}const PS=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,o;const{x:n,y:s,placement:a,middlewareData:i}=t,c=await TS(t,e);return a===((r=i.offset)==null?void 0:r.placement)&&(o=i.arrow)!=null&&o.alignmentOffset?{}:{x:n+c.x,y:s+c.y,data:{...c,placement:a}}}}},IS=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:o,placement:n,platform:s}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:c={fn:N=>{let{x,y:w}=N;return{x,y:w}}},...d}=Xr(e,t),p={x:r,y:o},u=await s.detectOverflow(t,d),f=$r(n),h=Wi(f);let g=p[h],y=p[f];const b=(N,x)=>Kf(x+u[N==="y"?"top":"left"],x,x-u[N==="y"?"bottom":"right"]);a&&(g=b(h,g)),i&&(y=b(f,y));const v=c.fn({...t,[h]:g,[f]:y});return{...v,data:{x:v.x-r,y:v.y-o,enabled:{[h]:a,[f]:i}}}}}},OS=function(e){return e===void 0&&(e={}),{options:e,fn(t){var r,o;const{x:n,y:s,placement:a,rects:i,middlewareData:c}=t,{offset:d=0,mainAxis:p=!0,crossAxis:u=!0}=Xr(e,t),f={x:n,y:s},h=$r(a),g=Wi(h);let y=f[g],b=f[h];const v=Xr(d,t),N=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:(r=v.mainAxis)!=null?r:0,crossAxis:(o=v.crossAxis)!=null?o:0};if(p){const C=g==="y"?"height":"width",E=i.reference[g]-i.floating[C]+N.mainAxis,k=i.reference[g]+i.reference[C]-N.mainAxis;y<E?y=E:y>k&&(y=k)}if(u){var x,w;const C=g==="y"?"width":"height",E=rp.has(ho(a)),k=i.reference[h]-i.floating[C]+(E&&((x=c.offset)==null?void 0:x[h])||0)+(E?0:N.crossAxis),_=i.reference[h]+i.reference[C]+(E?0:((w=c.offset)==null?void 0:w[h])||0)-(E?N.crossAxis:0);b<k?b=k:b>_&&(b=_)}return{[g]:y,[h]:b}}}},MS=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:r,rects:o,platform:n,elements:s}=t,{apply:a=()=>{},...i}=Xr(e,t),c=await n.detectOverflow(t,i),d=ho(r),p=sn(r),u=$r(r)==="y",{width:f,height:h}=o.floating;let g,y;d==="top"||d==="bottom"?(g=d,y=p===(await(n.isRTL==null?void 0:n.isRTL(s.floating))?"start":"end")?"left":"right"):(y=d,g=p==="end"?"top":"bottom");const b=h-c.top-c.bottom,v=f-c.left-c.right,N=po(h-c[g],b),x=po(f-c[y],v),w=t.middlewareData.shift,C=!w;let E=N,k=x;w!=null&&w.enabled.x&&(k=v),w!=null&&w.enabled.y&&(E=b),C&&!p&&(u?k=f-2*Kr(c.left,c.right):E=h-2*Kr(c.top,c.bottom)),await a({...t,availableWidth:k,availableHeight:E});const _=await n.getDimensions(s.floating);return f!==_.width||h!==_.height?{reset:{rects:!0}}:{}}}};function fa(){return typeof window<"u"}function an(e){return op(e)?(e.nodeName||"").toLowerCase():"#document"}function jt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Jr(e){var t;return(t=(op(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function op(e){return fa()?e instanceof Node||e instanceof jt(e).Node:!1}function Tr(e){return fa()?e instanceof Element||e instanceof jt(e).Element:!1}function mo(e){return fa()?e instanceof HTMLElement||e instanceof jt(e).HTMLElement:!1}function np(e){return!fa()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof jt(e).ShadowRoot}function pa(e){const{overflow:t,overflowX:r,overflowY:o,display:n}=Pr(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+r)&&n!=="inline"&&n!=="contents"}function LS(e){return/^(table|td|th)$/.test(an(e))}function ha(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const FS=/transform|translate|scale|rotate|perspective|filter/,VS=/paint|layout|strict|content/,Po=e=>!!e&&e!=="none";let Yi;function Qi(e){const t=Tr(e)?Pr(e):e;return Po(t.transform)||Po(t.translate)||Po(t.scale)||Po(t.rotate)||Po(t.perspective)||!Ki()&&(Po(t.backdropFilter)||Po(t.filter))||FS.test(t.willChange||"")||VS.test(t.contain||"")}function GS(e){let t=Io(e);for(;mo(t)&&!Gn(t);){if(Qi(t))return t;if(ha(t))return null;t=Io(t)}return null}function Ki(){return Yi==null&&(Yi=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Yi}function Gn(e){return/^(html|body|#document)$/.test(an(e))}function Pr(e){return jt(e).getComputedStyle(e)}function ma(e){return Tr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Io(e){if(an(e)==="html")return e;const t=e.assignedSlot||e.parentNode||np(e)&&e.host||Jr(e);return np(t)?t.host:t}function sp(e){const t=Io(e);return Gn(t)?(e.ownerDocument||e).body:mo(t)&&pa(t)?t:sp(t)}function zn(e,t,r){var o;t===void 0&&(t=[]),r===void 0&&(r=!0);const n=sp(e),s=n===((o=e.ownerDocument)==null?void 0:o.body),a=jt(n);if(s){const i=Ri(a);return t.concat(a,a.visualViewport||[],pa(n)?n:[],i&&r?zn(i):[])}else return t.concat(n,zn(n,[],r))}function Ri(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ap(e){const t=Pr(e);let r=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const n=mo(e),s=n?e.offsetWidth:r,a=n?e.offsetHeight:o,i=ia(r)!==s||ia(o)!==a;return i&&(r=s,o=a),{width:r,height:o,$:i}}function Xi(e){return Tr(e)?e:e.contextElement}function ln(e){const t=Xi(e);if(!mo(t))return Rr(1);const r=t.getBoundingClientRect(),{width:o,height:n,$:s}=ap(t);let a=(s?ia(r.width):r.width)/o,i=(s?ia(r.height):r.height)/n;return(!a||!Number.isFinite(a))&&(a=1),(!i||!Number.isFinite(i))&&(i=1),{x:a,y:i}}const zS=Rr(0);function lp(e){const t=jt(e);return!Ki()||!t.visualViewport?zS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function BS(e,t,r){return t===void 0&&(t=!1),!!r&&t&&r===jt(e)}function Oo(e,t,r,o){t===void 0&&(t=!1),r===void 0&&(r=!1);const n=e.getBoundingClientRect(),s=Xi(e);let a=Rr(1);t&&(o?Tr(o)&&(a=ln(o)):a=ln(e));const i=BS(s,r,o)?lp(s):Rr(0);let c=(n.left+i.x)/a.x,d=(n.top+i.y)/a.y,p=n.width/a.x,u=n.height/a.y;if(s&&o){const f=jt(s),h=Tr(o)?jt(o):o;let g=f,y=Ri(g);for(;y&&h!==g;){const b=ln(y),v=y.getBoundingClientRect(),N=Pr(y),x=v.left+(y.clientLeft+parseFloat(N.paddingLeft))*b.x,w=v.top+(y.clientTop+parseFloat(N.paddingTop))*b.y;c*=b.x,d*=b.y,p*=b.x,u*=b.y,c+=x,d+=w,g=jt(y),y=Ri(g)}}return ua({width:p,height:u,x:c,y:d})}function ga(e,t){const r=ma(e).scrollLeft;return t?t.left+r:Oo(Jr(e)).left+r}function ip(e,t){const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-ga(e,r),n=r.top+t.scrollTop;return{x:o,y:n}}function US(e){let{elements:t,rect:r,offsetParent:o,strategy:n}=e;const s=n==="fixed",a=Jr(o),i=t?ha(t.floating):!1;if(o===a||i&&s)return r;let c={scrollLeft:0,scrollTop:0},d=Rr(1);const p=Rr(0),u=mo(o);if((u||!s)&&((an(o)!=="body"||pa(a))&&(c=ma(o)),u)){const h=Oo(o);d=ln(o),p.x=h.x+o.clientLeft,p.y=h.y+o.clientTop}const f=a&&!u&&!s?ip(a,c):Rr(0);return{width:r.width*d.x,height:r.height*d.y,x:r.x*d.x-c.scrollLeft*d.x+p.x+f.x,y:r.y*d.y-c.scrollTop*d.y+p.y+f.y}}function WS(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function HS(e){const t=ma(e),r=e.ownerDocument.body,o=Kr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),n=Kr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let s=-t.scrollLeft+ga(e);const a=-t.scrollTop;return Pr(r).direction==="rtl"&&(s+=Kr(e.clientWidth,r.clientWidth)-o),{width:o,height:n,x:s,y:a}}const jS=25;function qS(e,t,r){r===void 0&&(r="viewport");const o=r==="layoutViewport",n=jt(e),s=Jr(e),a=n.visualViewport;let i=s.clientWidth,c=s.clientHeight,d=0,p=0;if(a){const f=!Ki()||t==="fixed";o?f||(d=-a.offsetLeft,p=-a.offsetTop):(i=a.width,c=a.height,f&&(d=a.offsetLeft,p=a.offsetTop))}if(ga(s)<=0){const f=s.ownerDocument,h=f.body,g=getComputedStyle(h),y=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,b=Math.abs(s.clientWidth-h.clientWidth-y),v=getComputedStyle(s).scrollbarGutter==="stable both-edges"?b/2:b;v<=jS&&(i-=v)}return{width:i,height:c,x:d,y:p}}function YS(e,t){const r=Oo(e,!0,t==="fixed"),o=r.top+e.clientTop,n=r.left+e.clientLeft,s=ln(e),a=e.clientWidth*s.x,i=e.clientHeight*s.y,c=n*s.x,d=o*s.y;return{width:a,height:i,x:c,y:d}}function cp(e,t,r){let o;if(t==="viewport"||t==="layoutViewport")o=qS(e,r,t);else if(t==="document")o=HS(Jr(e));else if(Tr(t))o=YS(t,r);else{const n=lp(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return ua(o)}function QS(e,t){const r=t.get(e);if(r)return r;let o=zn(e,[],!1).filter(i=>Tr(i)&&an(i)!=="body"),n=null;const s=Pr(e).position==="fixed";let a=s?Io(e):e;for(;Tr(a)&&!Gn(a);){const i=Pr(a),c=Qi(a),d=n?n.position:s?"fixed":"";!c&&(d==="fixed"||d==="absolute"&&i.position==="static")?o=o.filter(u=>u!==a):n=i,a=Io(a)}return t.set(e,o),o}function KS(e){let{element:t,boundary:r,rootBoundary:o,strategy:n}=e;const a=[...r==="clippingAncestors"?ha(t)?[]:QS(t,this._c):[].concat(r),o],i=cp(t,a[0],n);let c=i.top,d=i.right,p=i.bottom,u=i.left;for(let f=1;f<a.length;f++){const h=cp(t,a[f],n);c=Kr(h.top,c),d=po(h.right,d),p=po(h.bottom,p),u=Kr(h.left,u)}return{width:d-u,height:p-c,x:u,y:c}}function RS(e){const{width:t,height:r}=ap(e);return{width:t,height:r}}function XS(e,t,r){const o=mo(t),n=Jr(t),s=r==="fixed",a=Oo(e,!0,s,t);let i={scrollLeft:0,scrollTop:0};const c=Rr(0);if((o||!s)&&((an(t)!=="body"||pa(n))&&(i=ma(t)),o)){const f=Oo(t,!0,s,t);c.x=f.x+t.clientLeft,c.y=f.y+t.clientTop}!o&&n&&(c.x=ga(n));const d=n&&!o&&!s?ip(n,i):Rr(0),p=a.left+i.scrollLeft-c.x-d.x,u=a.top+i.scrollTop-c.y-d.y;return{x:p,y:u,width:a.width,height:a.height}}function Ji(e){return Pr(e).position==="static"}function dp(e,t){if(!mo(e)||Pr(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Jr(e)===r&&(r=r.ownerDocument.body),r}function up(e,t){const r=jt(e);if(ha(e))return r;if(!mo(e)){let n=Io(e);for(;n&&!Gn(n);){if(Tr(n)&&!Ji(n))return n;n=Io(n)}return r}let o=dp(e,t);for(;o&&LS(o)&&Ji(o);)o=dp(o,t);return o&&Gn(o)&&Ji(o)&&!Qi(o)?r:o||GS(e)||r}const JS=async function(e){const t=this.getOffsetParent||up,r=this.getDimensions,o=await r(e.floating);return{reference:XS(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function ZS(e){return Pr(e).direction==="rtl"}const eN={convertOffsetParentRelativeRectToViewportRelativeRect:US,getDocumentElement:Jr,getClippingRect:KS,getOffsetParent:up,getElementRects:JS,getClientRects:WS,getDimensions:RS,getScale:ln,isElement:Tr,isRTL:ZS};function fp(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function tN(e,t,r){let o=null,n;const s=Jr(e);function a(){var p;clearTimeout(n),(p=o)==null||p.disconnect(),o=null}function i(p,u){p===void 0&&(p=!1),u===void 0&&(u=1),a();const f=e.getBoundingClientRect(),{left:h,top:g,width:y,height:b}=f;if(p||t(),!y||!b)return;const v=ca(g),N=ca(s.clientWidth-(h+y)),x=ca(s.clientHeight-(g+b)),w=ca(h),E={rootMargin:-v+"px "+-N+"px "+-x+"px "+-w+"px",threshold:Kr(0,po(1,u))||1};let k=!0;function _(D){const A=D[0].intersectionRatio;if(!fp(f,e.getBoundingClientRect()))return i();if(A!==u){if(!k)return i();A?i(!1,A):n=setTimeout(()=>{i(!1,1e-7)},1e3)}k=!1}try{o=new IntersectionObserver(_,{...E,root:s.ownerDocument})}catch{o=new IntersectionObserver(_,E)}o.observe(e)}const c=jt(e),d=()=>i(r);return c.addEventListener("resize",d),i(!0),()=>{c.removeEventListener("resize",d),a()}}function rN(e,t,r,o){o===void 0&&(o={});const{ancestorScroll:n=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:i=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,d=Xi(e),p=n||s?[...d?zn(d):[],...t?zn(t):[]]:[];p.forEach(v=>{n&&v.addEventListener("scroll",r),s&&v.addEventListener("resize",r)});const u=d&&i?tN(d,r,s):null;let f=-1,h=null;a&&(h=new ResizeObserver(v=>{let[N]=v;N&&N.target===d&&h&&t&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(t)})),r()}),d&&!c&&h.observe(d),t&&h.observe(t));let g,y=c?Oo(e):null;c&&b();function b(){const v=Oo(e);y&&!fp(y,v)&&r(),y=v,g=requestAnimationFrame(b)}return r(),()=>{var v;p.forEach(N=>{n&&N.removeEventListener("scroll",r),s&&N.removeEventListener("resize",r)}),u==null||u(),(v=h)==null||v.disconnect(),h=null,c&&cancelAnimationFrame(g)}}const oN=PS,nN=IS,sN=DS,aN=MS,lN=$S,pp=AS,iN=OS,cN=(e,t,r)=>{const o=new Map,n=r??{},s={...eN,...n.platform,_c:o};return kS(e,t,{...n,platform:s})};var dN=typeof document<"u",uN=function(){},ba=dN?P.useLayoutEffect:uN;function ya(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,o,n;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(o=r;o--!==0;)if(!ya(e[o],t[o]))return!1;return!0}if(n=Object.keys(e),r=n.length,r!==Object.keys(t).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(t,n[o]))return!1;for(o=r;o--!==0;){const s=n[o];if(!(s==="_owner"&&e.$$typeof)&&!ya(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function hp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function mp(e,t){const r=hp(e);return Math.round(t*r)/r}function Zi(e){const t=S.useRef(e);return ba(()=>{t.current=e}),t}function fN(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:o=[],platform:n,elements:{reference:s,floating:a}={},transform:i=!0,whileElementsMounted:c,open:d}=e,[p,u]=S.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[f,h]=S.useState(o);ya(f,o)||h(o);const[g,y]=S.useState(null),[b,v]=S.useState(null),N=S.useCallback(H=>{H!==E.current&&(E.current=H,y(H))},[]),x=S.useCallback(H=>{H!==k.current&&(k.current=H,v(H))},[]),w=s||g,C=a||b,E=S.useRef(null),k=S.useRef(null),_=S.useRef(p),D=c!=null,A=Zi(c),I=Zi(n),T=Zi(d),L=S.useCallback(()=>{if(!E.current||!k.current)return;const H={placement:t,strategy:r,middleware:f};I.current&&(H.platform=I.current),cN(E.current,k.current,H).then(V=>{const W={...V,isPositioned:T.current!==!1};F.current&&!ya(_.current,W)&&(_.current=W,Tn.flushSync(()=>{u(W)}))})},[f,t,r,I,T]);ba(()=>{d===!1&&_.current.isPositioned&&(_.current.isPositioned=!1,u(H=>({...H,isPositioned:!1})))},[d]);const F=S.useRef(!1);ba(()=>(F.current=!0,()=>{F.current=!1}),[]),ba(()=>{if(w&&(E.current=w),C&&(k.current=C),w&&C){if(A.current)return A.current(w,C,L);L()}},[w,C,L,A,D]);const B=S.useMemo(()=>({reference:E,floating:k,setReference:N,setFloating:x}),[N,x]),G=S.useMemo(()=>({reference:w,floating:C}),[w,C]),z=S.useMemo(()=>{const H={position:r,left:0,top:0};if(!G.floating)return H;const V=mp(G.floating,p.x),W=mp(G.floating,p.y);return i?{...H,transform:"translate("+V+"px, "+W+"px)",...hp(G.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:V,top:W}},[r,i,G.floating,p.x,p.y]);return S.useMemo(()=>({...p,update:L,refs:B,elements:G,floatingStyles:z}),[p,L,B,G,z])}const pN=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:o,padding:n}=typeof e=="function"?e(r):e;return o&&t(o)?o.current!=null?pp({element:o.current,padding:n}).fn(r):{}:o?pp({element:o,padding:n}).fn(r):{}}}},hN=(e,t)=>{const r=oN(e);return{name:r.name,fn:r.fn,options:[e,t]}},mN=(e,t)=>{const r=nN(e);return{name:r.name,fn:r.fn,options:[e,t]}},gN=(e,t)=>({fn:iN(e).fn,options:[e,t]}),bN=(e,t)=>{const r=sN(e);return{name:r.name,fn:r.fn,options:[e,t]}},yN=(e,t)=>{const r=aN(e);return{name:r.name,fn:r.fn,options:[e,t]}},vN=(e,t)=>{const r=lN(e);return{name:r.name,fn:r.fn,options:[e,t]}},xN=(e,t)=>{const r=pN(e);return{name:r.name,fn:r.fn,options:[e,t]}};var wN=Object.defineProperty,SN=(e,t)=>wN(e,"name",{value:t,configurable:!0});function ec(e){const[t,r]=S.useState(void 0);return ot(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(n=>{if(!Array.isArray(n)||!n.length)return;const s=n[0];let a,i;if("borderBoxSize"in s){const c=s.borderBoxSize,d=Array.isArray(c)?c[0]:c;a=d.inlineSize,i=d.blockSize}else a=e.offsetWidth,i=e.offsetHeight;r({width:a,height:i})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else r(void 0)},[e]),t}SN(ec,"useSize");var NN=Object.defineProperty,go=(e,t)=>NN(e,"name",{value:t,configurable:!0}),gp="Popper",[bp,va]=sr(gp),[CN,yp]=bp(gp),EN=go(e=>{const{__scopePopper:t,children:r}=e,[o,n]=S.useState(null),[s,a]=S.useState(void 0);return l.jsx(CN,{scope:t,anchor:o,onAnchorChange:n,placementState:s,setPlacementState:a,children:r})},"Popper"),_N="PopperAnchor",kN=S.forwardRef(go(function(t,r){const{__scopePopper:o,virtualRef:n,...s}=t,a=yp(_N,o),i=S.useRef(null),c=a.onAnchorChange,d=S.useCallback(y=>{i.current=y,y&&c(y)},[c]),p=Ue(r,d),u=S.useRef(null);S.useEffect(()=>{if(!n)return;const y=u.current;u.current=n.current,y!==u.current&&c(u.current)});const f=a.placementState&&xa(a.placementState),h=f==null?void 0:f[0],g=f==null?void 0:f[1];return n?null:l.jsx(Ie.div,{"data-radix-popper-side":h,"data-radix-popper-align":g,...s,ref:p})},"PopperAnchor")),vp="PopperContent",[AN,vI]=bp(vp),DN=S.forwardRef(go(function(t,r){var re,Ae,we,ue,J,ne,fe;const{__scopePopper:o,side:n="bottom",sideOffset:s=0,align:a="center",alignOffset:i=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:p=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:g="optimized",onPlaced:y,...b}=t,v=yp(vp,o),[N,x]=S.useState(null),w=Ue(r,x),[C,E]=S.useState(null),k=ec(C),_=(k==null?void 0:k.width)??0,D=(k==null?void 0:k.height)??0,A=n+(a!=="center"?"-"+a:""),I=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},T=Array.isArray(p)?p:[p],L=T.length>0,F={padding:I,boundary:T.filter(xp),altBoundary:L},{refs:B,floatingStyles:G,placement:z,isPositioned:H,middlewareData:V}=fN({strategy:"fixed",placement:A,whileElementsMounted:go((...ke)=>rN(...ke,{animationFrame:g==="always"}),"whileElementsMounted"),elements:{reference:v.anchor},middleware:[hN({mainAxis:s+D,alignmentAxis:i}),d&&mN({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?gN():void 0,...F}),d&&bN({...F}),yN({...F,apply:go(({elements:ke,rects:Re,availableWidth:rt,availableHeight:st})=>{const{width:Xe,height:Ee}=Re.reference,yt=ke.floating.style;yt.setProperty("--radix-popper-available-width",`${rt}px`),yt.setProperty("--radix-popper-available-height",`${st}px`),yt.setProperty("--radix-popper-anchor-width",`${Xe}px`),yt.setProperty("--radix-popper-anchor-height",`${Ee}px`)},"apply")}),C&&xN({element:C,padding:c}),$N({arrowWidth:_,arrowHeight:D}),h&&vN({strategy:"referenceHidden",...F,boundary:L?F.boundary:void 0})]}),W=v.setPlacementState;ot(()=>(W(z),()=>{W(void 0)}),[z,W]);const[pe,U]=xa(z),Q=gr(y);ot(()=>{H&&(Q==null||Q())},[H,Q]);const Ce=(re=V.arrow)==null?void 0:re.x,oe=(Ae=V.arrow)==null?void 0:Ae.y,ye=((we=V.arrow)==null?void 0:we.centerOffset)!==0,[R,ce]=S.useState();return ot(()=>{N&&ce(window.getComputedStyle(N).zIndex)},[N]),l.jsx("div",{ref:B.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:H?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:R,"--radix-popper-transform-origin":[(ue=V.transformOrigin)==null?void 0:ue.x,(J=V.transformOrigin)==null?void 0:J.y].join(" "),...((ne=V.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:l.jsx(AN,{scope:o,placedSide:pe,placedAlign:U,onArrowChange:E,arrowX:Ce,arrowY:oe,shouldHideArrow:ye,children:l.jsx(Ie.div,{"data-side":pe,"data-align":U,...b,ref:w,style:{...b.style,animation:H?(fe=b.style)==null?void 0:fe.animation:"none"}})})})},"PopperContent"));function xp(e){return e!==null}go(xp,"isNotNull");var $N=go(e=>({name:"transformOrigin",options:e,fn(t){var b,v,N;const{placement:r,rects:o,middlewareData:n}=t,a=((b=n.arrow)==null?void 0:b.centerOffset)!==0,i=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[d,p]=xa(r),u={start:"0%",center:"50%",end:"100%"}[p],f=(((v=n.arrow)==null?void 0:v.x)??0)+i/2,h=(((N=n.arrow)==null?void 0:N.y)??0)+c/2;let g="",y="";return d==="bottom"?(g=a?u:`${f}px`,y=`${-c}px`):d==="top"?(g=a?u:`${f}px`,y=`${o.floating.height+c}px`):d==="right"?(g=`${-c}px`,y=a?u:`${h}px`):d==="left"&&(g=`${o.floating.width+c}px`,y=a?u:`${h}px`),{data:{x:g,y}}}}),"transformOrigin");function xa(e){const[t,r="center"]=e.split("-");return[t,r]}go(xa,"getSideAndAlignFromPlacement");var wp=EN,Sp=kN,Np=DN,TN=Object.defineProperty,PN=(e,t)=>TN(e,"name",{value:t,configurable:!0}),tc=S.forwardRef(PN(function(t,r){var c;const{container:o,...n}=t,[s,a]=S.useState(!1);ot(()=>a(!0),[]);const i=o||s&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return i?Tn.createPortal(l.jsx(Ie.div,{...n,ref:r}),i):null},"Portal")),IN=Object.defineProperty,Zr=(e,t)=>IN(e,"name",{value:t,configurable:!0});function Cp(e,t){return S.useReducer((r,o)=>t[r][o]??r,e)}Zr(Cp,"useStateMachine");var eo=Zr(e=>{const{present:t,children:r}=e,o=Ep(t),n=typeof r=="function"?r({present:o.isPresent}):S.Children.only(r),s=_p(o.ref,kp(n));return typeof r=="function"||o.isPresent?S.cloneElement(n,{ref:s}):null},"Presence");function Ep(e){const[t,r]=S.useState(),o=S.useRef(null),n=S.useRef(e),s=S.useRef("none"),a=S.useRef(void 0),i=e?"mounted":"unmounted",[c,d]=Cp(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return S.useEffect(()=>{c==="mounted"?(s.current=a.current??cn(o.current),a.current=void 0):s.current="none"},[c]),ot(()=>{const p=o.current,u=n.current;if(u!==e){const h=s.current,g=cn(p);e?(a.current=g,d("MOUNT")):g==="none"||(p==null?void 0:p.display)==="none"?d("UNMOUNT"):d(u&&h!==g?"ANIMATION_OUT":"UNMOUNT"),n.current=e}},[e,d]),ot(()=>{if(t){let p;const u=t.ownerDocument.defaultView??window,f=Zr(g=>{const b=cn(o.current).includes(CSS.escape(g.animationName));if(g.target===t&&b&&(d("ANIMATION_END"),!n.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",p=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},"handleAnimationEnd"),h=Zr(g=>{g.target===t&&(s.current=cn(o.current))},"handleAnimationStart");return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{u.clearTimeout(p),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:S.useCallback(p=>{if(p){const u=getComputedStyle(p);o.current=u,a.current=cn(u)}else o.current=null;r(p)},[])}}Zr(Ep,"usePresence");function rc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}Zr(rc,"setRef");function _p(...e){const t=S.useRef(e);return t.current=e,S.useCallback(r=>{const o=t.current;let n=!1;const s=o.map(a=>{const i=rc(a,r);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a<s.length;a++){const i=s[a];typeof i=="function"?i():rc(o[a],null)}}},[])}Zr(_p,"useStableComposedRefs");function cn(e){return(e==null?void 0:e.animationName)||"none"}Zr(cn,"getAnimationName");function kp(e){var o,n;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(n=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}Zr(kp,"getElementRef");var ON=Object.defineProperty,MN=(e,t)=>ON(e,"name",{value:t,configurable:!0}),Ap=S[" useEffectEvent ".trim().toString()],Dp=S[" useInsertionEffect ".trim().toString()];function $p(e){if(typeof Ap=="function")return Ap(e);const t=S.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Dp=="function"?Dp(()=>{t.current=e}):ot(()=>{t.current=e}),S.useMemo(()=>((...r)=>{var o;return(o=t.current)==null?void 0:o.call(t,...r)}),[])}MN($p,"useEffectEvent");var LN=Object.defineProperty,Bn=(e,t)=>LN(e,"name",{value:t,configurable:!0}),FN=S[" useInsertionEffect ".trim().toString()]||ot;function yr({prop:e,defaultProp:t,onChange:r=Bn(()=>{},"onChange"),caller:o}){const[n,s,a]=Tp({defaultProp:t,onChange:r}),i=e!==void 0,c=i?e:n,d=S.useCallback(p=>{var u;if(i){const f=Pp(p)?p(e):p;f!==e&&((u=a.current)==null||u.call(a,f))}else s(p)},[i,e,s,a]);return[c,d]}Bn(yr,"useControllableState");function Tp({defaultProp:e,onChange:t}){const[r,o]=S.useState(e),n=S.useRef(r),s=S.useRef(t);return FN(()=>{s.current=t},[t]),S.useEffect(()=>{var a;n.current!==r&&((a=s.current)==null||a.call(s,r),n.current=r)},[r,n]),[r,o,s]}Bn(Tp,"useUncontrolledState");function Pp(e){return typeof e=="function"}Bn(Pp,"isFunction");var Ip=Symbol("RADIX:SYNC_STATE");function VN(e,t,r,o){const{prop:n,defaultProp:s,onChange:a,caller:i}=t,c=n!==void 0,d=$p(a),p=[{...r,state:s}];o&&p.push(o);const[u,f]=S.useReducer((b,v)=>{if(v.type===Ip)return{...b,state:v.state};const N=e(b,v);return c&&!Object.is(N.state,b.state)&&d(N.state),N},...p),h=u.state,g=S.useRef(h);S.useEffect(()=>{g.current!==h&&(g.current=h,c||d(h))},[h,g,c]);const y=S.useMemo(()=>n!==void 0?{...u,state:n}:u,[u,n]);return S.useEffect(()=>{c&&!Object.is(n,u.state)&&f({type:Ip,state:n})},[n,u.state,c]),[y,f]}Bn(VN,"useControllableStateReducer");var GN=Object.defineProperty,zN=(e,t)=>GN(e,"name",{value:t,configurable:!0});function Op(e){const t=S.useRef({value:e,previous:e});return S.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}zN(Op,"usePrevious");var BN=Object.defineProperty,UN=(e,t)=>BN(e,"name",{value:t,configurable:!0}),Mp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),WN=S.forwardRef(UN(function(t,r){return l.jsx(Ie.span,{...t,ref:r,style:{...Mp,...t.style}})},"VisuallyHidden")),HN=WN,jN=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},dn=new WeakMap,wa=new WeakMap,Sa={},oc=0,Lp=function(e){return e&&(e.host||Lp(e.parentNode))},qN=function(e,t){return t.map(function(r){if(e.contains(r))return r;var o=Lp(r);return o&&e.contains(o)?o:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},YN=function(e,t,r,o){var n=qN(t,Array.isArray(e)?e:[e]);Sa[r]||(Sa[r]=new WeakMap);var s=Sa[r],a=[],i=new Set,c=new Set(n),d=function(u){!u||i.has(u)||(i.add(u),d(u.parentNode))};n.forEach(d);var p=function(u){!u||c.has(u)||Array.prototype.forEach.call(u.children,function(f){if(i.has(f))p(f);else try{var h=f.getAttribute(o),g=h!==null&&h!=="false",y=(dn.get(f)||0)+1,b=(s.get(f)||0)+1;dn.set(f,y),s.set(f,b),a.push(f),y===1&&g&&wa.set(f,!0),b===1&&f.setAttribute(r,"true"),g||f.setAttribute(o,"true")}catch(v){console.error("aria-hidden: cannot operate on ",f,v)}})};return p(t),i.clear(),oc++,function(){a.forEach(function(u){var f=dn.get(u)-1,h=s.get(u)-1;dn.set(u,f),s.set(u,h),f||(wa.has(u)||u.removeAttribute(o),wa.delete(u)),h||u.removeAttribute(r)}),oc--,oc||(dn=new WeakMap,dn=new WeakMap,wa=new WeakMap,Sa={})}},Fp=function(e,t,r){r===void 0&&(r="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),n=jN(e);return n?(o.push.apply(o,Array.from(n.querySelectorAll("[aria-live], script"))),YN(o,n,r,"aria-hidden")):function(){return null}},Ir=function(){return Ir=Object.assign||function(t){for(var r,o=1,n=arguments.length;o<n;o++){r=arguments[o];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s])}return t},Ir.apply(this,arguments)};function Vp(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r}function QN(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,s;o<n;o++)(s||!(o in t))&&(s||(s=Array.prototype.slice.call(t,0,o)),s[o]=t[o]);return e.concat(s||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Na="right-scroll-bar-position",Ca="width-before-scroll-bar",KN="with-scroll-bars-hidden",RN="--removed-body-scroll-bar-size";function nc(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function XN(e,t){var r=P.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(o){var n=r.value;n!==o&&(r.value=o,r.callback(o,n))}}}})[0];return r.callback=t,r.facade}var JN=typeof window<"u"?S.useLayoutEffect:S.useEffect,Gp=new WeakMap;function ZN(e,t){var r=XN(null,function(o){return e.forEach(function(n){return nc(n,o)})});return JN(function(){var o=Gp.get(r);if(o){var n=new Set(o),s=new Set(e),a=r.current;n.forEach(function(i){s.has(i)||nc(i,null)}),s.forEach(function(i){n.has(i)||nc(i,a)})}Gp.set(r,e)},[e]),r}function eC(e){return e}function tC(e,t){t===void 0&&(t=eC);var r=[],o=!1,n={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(s){var a=t(s,o);return r.push(a),function(){r=r.filter(function(i){return i!==a})}},assignSyncMedium:function(s){for(o=!0;r.length;){var a=r;r=[],a.forEach(s)}r={push:function(i){return s(i)},filter:function(){return r}}},assignMedium:function(s){o=!0;var a=[];if(r.length){var i=r;r=[],i.forEach(s),a=r}var c=function(){var p=a;a=[],p.forEach(s)},d=function(){return Promise.resolve().then(c)};d(),r={push:function(p){a.push(p),d()},filter:function(p){return a=a.filter(p),r}}}};return n}function rC(e){e===void 0&&(e={});var t=tC(null);return t.options=Ir({async:!0,ssr:!1},e),t}var zp=function(e){var t=e.sideCar,r=Vp(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return S.createElement(o,Ir({},r))};zp.isSideCarExport=!0;function oC(e,t){return e.useMedium(t),zp}var Bp=rC(),sc=function(){},Ea=S.forwardRef(function(e,t){var r=S.useRef(null),o=S.useState({onScrollCapture:sc,onWheelCapture:sc,onTouchMoveCapture:sc}),n=o[0],s=o[1],a=e.forwardProps,i=e.children,c=e.className,d=e.removeScrollBar,p=e.enabled,u=e.shards,f=e.sideCar,h=e.noRelative,g=e.noIsolation,y=e.inert,b=e.allowPinchZoom,v=e.as,N=v===void 0?"div":v,x=e.gapMode,w=Vp(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,E=ZN([r,t]),k=Ir(Ir({},w),n);return S.createElement(S.Fragment,null,p&&S.createElement(C,{sideCar:Bp,removeScrollBar:d,shards:u,noRelative:h,noIsolation:g,inert:y,setCallbacks:s,allowPinchZoom:!!b,lockRef:r,gapMode:x}),a?S.cloneElement(S.Children.only(i),Ir(Ir({},k),{ref:E})):S.createElement(N,Ir({},k,{className:c,ref:E}),i))});Ea.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ea.classNames={fullWidth:Ca,zeroRight:Na};var nC=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function sC(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=nC();return t&&e.setAttribute("nonce",t),e}function aC(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function lC(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var iC=function(){var e=0,t=null;return{add:function(r){e==0&&(t=sC())&&(aC(t,r),lC(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},cC=function(){var e=iC();return function(t,r){S.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},Up=function(){var e=cC(),t=function(r){var o=r.styles,n=r.dynamic;return e(o,n),null};return t},dC={left:0,top:0,right:0,gap:0},ac=function(e){return parseInt(e||"",10)||0},uC=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],n=t[e==="padding"?"paddingRight":"marginRight"];return[ac(r),ac(o),ac(n)]},fC=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return dC;var t=uC(e),r=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-r+t[2]-t[0])}},pC=Up(),un="data-scroll-locked",hC=function(e,t,r,o){var n=e.left,s=e.top,a=e.right,i=e.gap;return r===void 0&&(r="margin"),`
2
- .`.concat(KN,` {
1
+ (function(le,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react/jsx-runtime"),require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom"],i):(le=typeof globalThis<"u"?globalThis:le||self,i(le.EntryPulse={},le.jsxRuntime,le.React,le.ReactDOM))})(this,(function(le,i,P,Ba){"use strict";var d2=Object.defineProperty;var nw=le=>{throw TypeError(le)};var u2=(le,i,P)=>i in le?d2(le,i,{enumerable:!0,configurable:!0,writable:!0,value:P}):le[i]=P;var ni=(le,i,P)=>u2(le,typeof i!="symbol"?i+"":i,P),aw=(le,i,P)=>i.has(le)||nw("Cannot "+P);var jt=(le,i,P)=>(aw(le,i,"read from private field"),P?P.call(le):i.get(le)),sw=(le,i,P)=>i.has(le)?nw("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(le):i.set(le,P),Eu=(le,i,P,Ba)=>(aw(le,i,"write to private field"),Ba?Ba.call(le,P):i.set(le,P),P);var St,lr;function ku(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const C=ku(P),Pn=ku(Ba),Au=e=>{let t;const r=new Set,o=(d,p)=>{const u=typeof d=="function"?d(t):d;if(!Object.is(u,t)){const f=t;t=p??(typeof u!="object"||u===null)?u:Object.assign({},t,u),r.forEach(h=>h(t,f))}},n=()=>t,l={setState:o,getState:n,getInitialState:()=>c,subscribe:d=>(r.add(d),()=>r.delete(d))},c=t=e(o,n,l);return l},lw=(e=>e?Au(e):Au),iw=e=>e;function cw(e,t=iw){const r=P.useSyncExternalStore(e.subscribe,P.useCallback(()=>t(e.getState()),[e,t]),P.useCallback(()=>t(e.getInitialState()),[e,t]));return P.useDebugValue(r),r}const _u=e=>{const t=lw(e),r=o=>cw(t,o);return Object.assign(r,t),r},dw=(e=>e?_u(e):_u);var Tu=Symbol.for("immer-nothing"),Du=Symbol.for("immer-draftable"),er=Symbol.for("immer-state"),uw=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Qt(e,...t){if(process.env.NODE_ENV!=="production"){const r=uw[e],o=typeof r=="function"?r.apply(null,t):r;throw new Error(`[Immer] ${o}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Mn=Object.getPrototypeOf;function sn(e){return!!e&&!!e[er]}function Do(e){var t;return e?Pu(e)||Array.isArray(e)||!!e[Du]||!!((t=e.constructor)!=null&&t[Du])||On(e)||Ha(e):!1}var fw=Object.prototype.constructor.toString(),$u=new WeakMap;function Pu(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;const r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(r===Object)return!0;if(typeof r!="function")return!1;let o=$u.get(r);return o===void 0&&(o=Function.toString.call(r),$u.set(r,o)),o===fw}function Ua(e,t,r=!0){Wa(e)===0?(r?Reflect.ownKeys(e):Object.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((o,n)=>t(n,o,e))}function Wa(e){const t=e[er];return t?t.type_:Array.isArray(e)?1:On(e)?2:Ha(e)?3:0}function ai(e,t){return Wa(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Mu(e,t,r){const o=Wa(e);o===2?e.set(t,r):o===3?e.add(r):e[t]=r}function pw(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function On(e){return e instanceof Map}function Ha(e){return e instanceof Set}function $o(e){return e.copy_||e.base_}function si(e,t){if(On(e))return new Map(e);if(Ha(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const r=Pu(e);if(t===!0||t==="class_only"&&!r){const o=Object.getOwnPropertyDescriptors(e);delete o[er];let n=Reflect.ownKeys(o);for(let a=0;a<n.length;a++){const s=n[a],l=o[s];l.writable===!1&&(l.writable=!0,l.configurable=!0),(l.get||l.set)&&(o[s]={configurable:!0,writable:!0,enumerable:l.enumerable,value:e[s]})}return Object.create(Mn(e),o)}else{const o=Mn(e);if(o!==null&&r)return{...e};const n=Object.create(o);return Object.assign(n,e)}}function li(e,t=!1){return qa(e)||sn(e)||!Do(e)||(Wa(e)>1&&Object.defineProperties(e,{set:ja,add:ja,clear:ja,delete:ja}),Object.freeze(e),t&&Object.values(e).forEach(r=>li(r,!0))),e}function hw(){Qt(2)}var ja={value:hw};function qa(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var mw={};function Po(e){const t=mw[e];return t||Qt(0,e),t}var In;function Ou(){return In}function bw(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Iu(e,t){t&&(Po("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function ii(e){ci(e),e.drafts_.forEach(gw),e.drafts_=null}function ci(e){e===In&&(In=e.parent_)}function Lu(e){return In=bw(In,e)}function gw(e){const t=e[er];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Fu(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];return e!==void 0&&e!==r?(r[er].modified_&&(ii(t),Qt(4)),Do(e)&&(e=Ya(t,e),t.parent_||Qa(t,e)),t.patches_&&Po("Patches").generateReplacementPatches_(r[er].base_,e,t.patches_,t.inversePatches_)):e=Ya(t,r,[]),ii(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Tu?e:void 0}function Ya(e,t,r){if(qa(t))return t;const o=e.immer_.shouldUseStrictIteration(),n=t[er];if(!n)return Ua(t,(a,s)=>Vu(e,n,t,a,s,r),o),t;if(n.scope_!==e)return t;if(!n.modified_)return Qa(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;const a=n.copy_;let s=a,l=!1;n.type_===3&&(s=new Set(a),a.clear(),l=!0),Ua(s,(c,d)=>Vu(e,n,a,c,d,r,l),o),Qa(e,a,!1),r&&e.patches_&&Po("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function Vu(e,t,r,o,n,a,s){if(n==null||typeof n!="object"&&!s)return;const l=qa(n);if(!(l&&!s)){if(process.env.NODE_ENV!=="production"&&n===r&&Qt(5),sn(n)){const c=a&&t&&t.type_!==3&&!ai(t.assigned_,o)?a.concat(o):void 0,d=Ya(e,n,c);if(Mu(r,o,d),sn(d))e.canAutoFreeze_=!1;else return}else s&&r.add(n);if(Do(n)&&!l){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[o]===n&&l)return;Ya(e,n),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&(On(r)?r.has(o):Object.prototype.propertyIsEnumerable.call(r,o))&&Qa(e,n)}}}function Qa(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&li(t,r)}function yw(e,t){const r=Array.isArray(e),o={type_:r?1:0,scope_:t?t.scope_:Ou(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let n=o,a=di;r&&(n=[o],a=Ln);const{revoke:s,proxy:l}=Proxy.revocable(n,a);return o.draft_=l,o.revoke_=s,l}var di={get(e,t){if(t===er)return e;const r=$o(e);if(!ai(r,t))return vw(e,r,t);const o=r[t];return e.finalized_||!Do(o)?o:o===ui(e.base_,t)?(pi(e),e.copy_[t]=hi(o,e)):o},has(e,t){return t in $o(e)},ownKeys(e){return Reflect.ownKeys($o(e))},set(e,t,r){const o=Gu($o(e),t);if(o!=null&&o.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){const n=ui($o(e),t),a=n==null?void 0:n[er];if(a&&a.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(pw(r,n)&&(r!==void 0||ai(e.base_,t)))return!0;pi(e),fi(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return ui(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,pi(e),fi(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=$o(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:r[t]}},defineProperty(){Qt(11)},getPrototypeOf(e){return Mn(e.base_)},setPrototypeOf(){Qt(12)}},Ln={};Ua(di,(e,t)=>{Ln[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),Ln.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Qt(13),Ln.set.call(this,e,t,void 0)},Ln.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Qt(14),di.set.call(this,e[0],t,r,e[0])};function ui(e,t){const r=e[er];return(r?$o(r):e)[t]}function vw(e,t,r){var n;const o=Gu(t,r);return o?"value"in o?o.value:(n=o.get)==null?void 0:n.call(e.draft_):void 0}function Gu(e,t){if(!(t in e))return;let r=Mn(e);for(;r;){const o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=Mn(r)}}function fi(e){e.modified_||(e.modified_=!0,e.parent_&&fi(e.parent_))}function pi(e){e.copy_||(e.copy_=si(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var ww=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(r,o,n)=>{if(typeof r=="function"&&typeof o!="function"){const s=o;o=r;const l=this;return function(d=s,...p){return l.produce(d,u=>o.call(this,u,...p))}}typeof o!="function"&&Qt(6),n!==void 0&&typeof n!="function"&&Qt(7);let a;if(Do(r)){const s=Lu(this),l=hi(r,void 0);let c=!0;try{a=o(l),c=!1}finally{c?ii(s):ci(s)}return Iu(s,n),Fu(a,s)}else if(!r||typeof r!="object"){if(a=o(r),a===void 0&&(a=r),a===Tu&&(a=void 0),this.autoFreeze_&&li(a,!0),n){const s=[],l=[];Po("Patches").generateReplacementPatches_(r,a,s,l),n(s,l)}return a}else Qt(1,r)},this.produceWithPatches=(r,o)=>{if(typeof r=="function")return(l,...c)=>this.produceWithPatches(l,d=>r(d,...c));let n,a;return[this.produce(r,o,(l,c)=>{n=l,a=c}),n,a]},typeof(t==null?void 0:t.autoFreeze)=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof(t==null?void 0:t.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),typeof(t==null?void 0:t.useStrictIteration)=="boolean"&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Do(t)||Qt(8),sn(t)&&(t=xw(t));const r=Lu(this),o=hi(t,void 0);return o[er].isManual_=!0,ci(r),o}finishDraft(t,r){const o=t&&t[er];(!o||!o.isManual_)&&Qt(9);const{scope_:n}=o;return Iu(n,r),Fu(void 0,n)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,r){let o;for(o=r.length-1;o>=0;o--){const a=r[o];if(a.path.length===0&&a.op==="replace"){t=a.value;break}}o>-1&&(r=r.slice(o+1));const n=Po("Patches").applyPatches_;return sn(t)?n(t,r):this.produce(t,a=>n(a,r))}};function hi(e,t){const r=On(e)?Po("MapSet").proxyMap_(e,t):Ha(e)?Po("MapSet").proxySet_(e,t):yw(e,t);return(t?t.scope_:Ou()).drafts_.push(r),r}function xw(e){return sn(e)||Qt(10,e),zu(e)}function zu(e){if(!Do(e)||qa(e))return e;const t=e[er];let r,o=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=si(e,t.scope_.immer_.useStrictShallowCopy_),o=t.scope_.immer_.shouldUseStrictIteration()}else r=si(e,!0);return Ua(r,(n,a)=>{Mu(r,n,zu(a))},o),t&&(t.finalized_=!1),r}var Cw=new ww,Sw=Cw.produce;const Nw=e=>(t,r,o)=>(o.setState=(n,a,...s)=>{const l=typeof n=="function"?Sw(n):n;return t(l,a,...s)},e(o.setState,r,o));function Ka(){const e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return`${e}-${t}`}function mi(e){if(!e)return"";const t=e.trim().replace(/[^a-zA-Z0-9\s]/g,"").split(/\s+/).filter(Boolean);return t.length===0?"":t.map((r,o)=>{const n=r.toLowerCase();return o===0?n:n.charAt(0).toUpperCase()+n.slice(1)}).join("")}function Bu(e,t){const r=t instanceof Set?t:new Set(t),o=mi(e.replace(/([A-Z])/g," $1").trim())||"field";if(!r.has(o))return o;let n=1,a=`${o}${n}`;for(;r.has(a);)n++,a=`${o}${n}`;return a}function bi(e){return new Set(e.map(t=>t.attributes.name).filter(Boolean))}const Ew={shortText:{label:"Short Text",placeholder:"Enter text..."},longText:{label:"Long Text",placeholder:"Enter your text here..."},multiLineInput:{label:"Multi-line Input",placeholder:"Enter your text..."},textEditor:{label:"Text Editor",placeholder:"Start typing..."},number:{label:"Number",placeholder:"Enter a number..."},slider:{label:"Slider",description:"Slide to select a value"},rangeSlider:{label:"Range Slider",description:"Select a range"},email:{label:"Email",placeholder:"Enter your email..."},phone:{label:"Phone",placeholder:"Enter your phone number..."},url:{label:"URL",placeholder:"https://example.com"},location:{label:"Location",placeholder:"Enter address...",description:"Enter your address"},password:{label:"Password",placeholder:"Enter your password..."},signature:{label:"Signature",description:"Draw your signature below"},captcha:{label:"Verification",description:"Please verify you are human"},singleChoice:{label:"Single Choice",description:"Select one option"},multipleChoice:{label:"Multiple Choice",description:"Select all that apply"},dropdown:{label:"Dropdown",placeholder:"Select an option..."},tags:{label:"Tags",placeholder:"Type and press enter...",description:"Add tags"},decisionBox:{label:"I agree to the terms and conditions"},toggleSwitch:{label:"Toggle Switch",description:"Turn on or off"},singleChoiceMatrix:{label:"Single Choice Matrix",description:"Select one option per row"},multipleChoiceMatrix:{label:"Multiple Choice Matrix",description:"Select options per row"},matrixTable:{label:"Matrix Table",description:"Fill in the table"},date:{label:"Date",placeholder:"Select a date..."},time:{label:"Time",placeholder:"Select a time..."},dateTime:{label:"Date & Time",placeholder:"Select date and time..."},multipleDates:{label:"Multiple Dates",placeholder:"Select dates...",description:"Select multiple dates"},dateRange:{label:"Date Range",placeholder:"Select date range...",description:"Select start and end dates"},fileUpload:{label:"File Upload",description:"Upload a file"},imageUpload:{label:"Image Upload",description:"Upload an image"},multiFileUpload:{label:"Multi-File Upload",description:"Upload multiple files"},multiImageUpload:{label:"Multi-Image Upload",description:"Upload multiple images"},paragraph:{label:"Paragraph",content:"Enter your paragraph text here. You can use this to provide instructions or additional information."},image:{label:"Image",alt:"Image description",src:""},link:{label:"Link",href:"https://example.com",content:"Click here",target:"_blank"},formHeading:{label:"Form Title",description:"Form description goes here"},sectionHeading:{label:"Section Title"},subheading:{label:"Subheading"},divider:{},spacer:{},group:{label:"Group",description:"Group description"},grid:{label:"Grid Layout"},table:{label:"Table"},repeatElement:{label:"Repeat Element",description:"Add more items"},repeatGroup:{label:"Repeat Group",description:"Add more groups"},pages:{label:"Form Pages"},submit:{label:"Submit"}},kw={shortText:{labelPosition:"top",size:"full"},longText:{labelPosition:"top",size:"full"},multiLineInput:{labelPosition:"top",size:"full"},textEditor:{labelPosition:"top",size:"full"},number:{labelPosition:"top",size:"full"},slider:{labelPosition:"top",size:"full"},rangeSlider:{labelPosition:"top",size:"full"},email:{labelPosition:"top",size:"full"},phone:{labelPosition:"top",size:"full"},url:{labelPosition:"top",size:"full"},location:{labelPosition:"top",size:"full"},password:{labelPosition:"top",size:"full"},signature:{labelPosition:"top",size:"full"},captcha:{labelPosition:"hidden",size:"full"},singleChoice:{labelPosition:"top",size:"full"},multipleChoice:{labelPosition:"top",size:"full"},dropdown:{labelPosition:"top",size:"full"},tags:{labelPosition:"top",size:"full"},decisionBox:{labelPosition:"hidden",size:"full"},toggleSwitch:{labelPosition:"left",size:"full"},singleChoiceMatrix:{labelPosition:"top",size:"full"},multipleChoiceMatrix:{labelPosition:"top",size:"full"},matrixTable:{labelPosition:"top",size:"full"},date:{labelPosition:"top",size:"full"},time:{labelPosition:"top",size:"full"},dateTime:{labelPosition:"top",size:"full"},multipleDates:{labelPosition:"top",size:"full"},dateRange:{labelPosition:"top",size:"full"},fileUpload:{labelPosition:"top",size:"full"},imageUpload:{labelPosition:"top",size:"full"},multiFileUpload:{labelPosition:"top",size:"full"},multiImageUpload:{labelPosition:"top",size:"full"},paragraph:{labelPosition:"hidden",size:"full"},image:{labelPosition:"hidden",size:"full"},link:{labelPosition:"hidden",size:"full"},formHeading:{size:"full"},sectionHeading:{size:"full"},subheading:{size:"full"},divider:{size:"full"},spacer:{size:"full",height:24},group:{size:"full"},grid:{size:"full",columns:2,gap:16},table:{size:"full"},repeatElement:{size:"full"},repeatGroup:{size:"full"},pages:{size:"full"},submit:{size:"full"}},Uu={shortText:{maxLength:255},longText:{maxLength:5e3},multiLineInput:{maxLength:5e3},textEditor:{maxLength:5e4},number:{},slider:{},rangeSlider:{},email:{},phone:{},url:{},location:{},password:{minLength:8},singleChoice:{},multipleChoice:{},dropdown:{},tags:{},decisionBox:{},singleChoiceMatrix:{},multipleChoiceMatrix:{},date:{},time:{},dateTime:{},multipleDates:{},dateRange:{},fileUpload:{},imageUpload:{},multiFileUpload:{maxFiles:10},multiImageUpload:{maxFiles:10}},Wu={longText:{rows:3,autoResize:!1},multiLineInput:{minRows:2,maxRows:10,autoResize:!0},textEditor:{toolbar:["bold","italic","underline","link"],height:200,allowImages:!1,allowLinks:!0},number:{step:1,decimals:0,thousandsSeparator:!1},slider:{min:0,max:100,step:1,showValue:!0,showMarks:!1},rangeSlider:{min:0,max:100,step:1,showValue:!0,minRange:0},phone:{defaultCountry:"US",format:"international"},location:{enableGeolocation:!1,showMap:!1},password:{showStrengthMeter:!0,showToggle:!0,minStrength:"medium"},signature:{strokeWidth:2,strokeColor:"#000000",backgroundColor:"#ffffff",canvasWidth:400,canvasHeight:200},captcha:{provider:"recaptcha",theme:"light"},singleChoice:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],allowOther:!1},multipleChoice:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],allowOther:!1},dropdown:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],allowOther:!1},tags:{options:[{label:"Tag 1",value:"tag1"},{label:"Tag 2",value:"tag2"},{label:"Tag 3",value:"tag3"}],maxTags:10,allowCustomTags:!0},decisionBox:{checkedLabel:"Yes",uncheckedLabel:"No"},toggleSwitch:{onLabel:"On",offLabel:"Off"},singleChoiceMatrix:{matrixRows:[{id:"row1",label:"Row 1"},{id:"row2",label:"Row 2"},{id:"row3",label:"Row 3"}],matrixColumns:[{id:"col1",label:"Column 1"},{id:"col2",label:"Column 2"},{id:"col3",label:"Column 3"}]},multipleChoiceMatrix:{matrixRows:[{id:"row1",label:"Row 1"},{id:"row2",label:"Row 2"},{id:"row3",label:"Row 3"}],matrixColumns:[{id:"col1",label:"Column 1"},{id:"col2",label:"Column 2"},{id:"col3",label:"Column 3"}],allowMultiplePerRow:!0},matrixTable:{matrixRows:[{id:"row1",label:"Row 1"},{id:"row2",label:"Row 2"}],matrixColumns:[{id:"col1",label:"Text",type:"text"},{id:"col2",label:"Number",type:"number"}]},date:{format:"YYYY-MM-DD",showCalendar:!0},time:{timeFormat:"12h",timeInterval:15},dateTime:{format:"YYYY-MM-DD",timeFormat:"12h",timeInterval:15},multipleDates:{format:"YYYY-MM-DD",showCalendar:!0},dateRange:{format:"YYYY-MM-DD",showCalendar:!0,minDays:1},fileUpload:{accept:"*/*",maxSize:10485760,multiple:!1},imageUpload:{accept:"image/*",maxSize:5242880,multiple:!1,allowCrop:!1},multiFileUpload:{accept:"*/*",maxSize:10485760,multiple:!0,maxFiles:10},multiImageUpload:{accept:"image/*",maxSize:5242880,multiple:!0,maxFiles:10,allowCrop:!1},paragraph:{textAlign:"left",fontSize:"medium",fontWeight:"normal"},image:{imageWidth:"100%",objectFit:"contain",borderRadius:0},link:{linkStyle:"text"},formHeading:{level:1,alignment:"left"},sectionHeading:{level:2,alignment:"left"},subheading:{level:3,alignment:"left"},divider:{style:"solid",thickness:1,color:"#e5e7eb"},spacer:{spacerHeight:24},group:{collapsed:!1,collapsible:!1,showBorder:!0,padding:16},grid:{gridColumns:2,gridGap:16,responsiveColumns:{sm:1,md:2,lg:2}},table:{tableColumns:[{id:"col1",header:"Column 1",align:"left"},{id:"col2",header:"Column 2",align:"left"}],showHeader:!0,striped:!0,bordered:!0},repeatElement:{minItems:1,maxItems:10,addButtonText:"Add Item",removeButtonText:"Remove",showItemNumber:!0},repeatGroup:{minItems:1,maxItems:10,addButtonText:"Add Group",removeButtonText:"Remove",itemLabel:"Item",showItemNumber:!0},pages:{showProgressBar:!0,showStepNumbers:!0,allowSkip:!1,validateOnNext:!0,nextButtonLabel:"Next",activeStepId:"step1",steps:[{id:"step1",label:"Step 1",description:""},{id:"step2",label:"Step 2",description:""}]},submit:{buttonText:"Submit",buttonStyle:"primary",buttonSize:"medium",showIcon:!1,loadingText:"Submitting..."}},Aw={shortText:"string",longText:"string",multiLineInput:"string",textEditor:"string",number:"number",slider:"number",rangeSlider:"object",email:"string",phone:"string",url:"string",location:"object",password:"string",signature:"string",captcha:"string",singleChoice:"string",multipleChoice:"array",dropdown:"string",tags:"array",decisionBox:"boolean",toggleSwitch:"boolean",singleChoiceMatrix:"object",multipleChoiceMatrix:"object",matrixTable:"object",date:"date",time:"string",dateTime:"date",multipleDates:"array",dateRange:"object",fileUpload:"object",imageUpload:"object",multiFileUpload:"array",multiImageUpload:"array",paragraph:"string",image:"string",link:"string",formHeading:"string",sectionHeading:"string",subheading:"string",divider:"string",spacer:"string",group:"object",grid:"object",table:"object",repeatElement:"array",repeatGroup:"array",pages:"object",submit:"string"};function Hu(e,t,r){const o=Bu(e,t),n={id:Ka(),type:e,order:r,properties:{...Ew[e]},layout:{...kw[e]},attributes:{name:o,dataType:Aw[e]}};return Uu[e]&&(n.validation={...Uu[e]}),Wu[e]&&(n.config=JSON.parse(JSON.stringify(Wu[e]))),n}function ju(){return{id:`form-${Ka()}`,version:"1.0.0",title:"Untitled Form",description:"",metadata:{createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()},settings:{showProgressBar:!1,allowSaveDraft:!1,submitButtonText:"Submit",successMessage:"Thank you for your submission!",submitAction:"message"},elements:[]}}function _w(e,t){const r=JSON.parse(JSON.stringify(e));return r.id=Ka(),r.attributes.name=Bu(e.type,t),r}function gi(e){return["paragraph","image","link","formHeading","sectionHeading","subheading","divider","spacer"].includes(e)}function Tw(e){const t=["paragraph","image","link","formHeading","sectionHeading","subheading","divider","spacer","captcha"],r=["singleChoice","dropdown","decisionBox","toggleSwitch","signature","captcha",...t],o=["number","slider","rangeSlider","date","time","dateTime","multipleDates","dateRange","fileUpload","imageUpload","multiFileUpload","multiImageUpload","singleChoice","multipleChoice","dropdown","decisionBox","toggleSwitch","signature","captcha","singleChoiceMatrix","multipleChoiceMatrix","matrixTable",...t];return{supportsRequired:!t.includes(e),supportsMinMax:!r.includes(e),supportsPattern:!o.includes(e)}}const Dw=50;function cr(e,t){const r=e.history.slice(0,e.historyIndex+1);r.push(JSON.parse(JSON.stringify(t))),r.length>Dw&&r.shift(),e.history=r,e.historyIndex=r.length-1,e.schema=t}const qu=ju(),$w={schema:qu,selectedElementId:null,mode:"design",history:[JSON.parse(JSON.stringify(qu))],historyIndex:0,hoveredElementId:null,draggedElementType:null},ie=dw()(Nw((e,t)=>({...$w,addElement:(r,o)=>{e(n=>{var p;const a=n.schema.elements.some(u=>u.type==="pages");if(r==="pages"&&a){console.warn("Only one wizard can be added to the form");return}if(a&&r!=="pages"){console.warn("When a wizard exists, elements must be added inside wizard steps");return}const s=bi(n.schema.elements),l=o??n.schema.elements.length,c=Hu(r,s,l);(r==="group"||r==="grid"||r==="repeatGroup"||r==="pages")&&(c.children=[]);const d={...n.schema};o!==void 0?d.elements=[...n.schema.elements.slice(0,o),c,...n.schema.elements.slice(o).map(u=>({...u,order:u.order+1}))]:d.elements=[...n.schema.elements,c],d.metadata={...d.metadata,updatedAt:new Date().toISOString(),createdAt:((p=d.metadata)==null?void 0:p.createdAt)||new Date().toISOString()},cr(n,d),n.selectedElementId=c.id})},addElementToContainer:(r,o,n)=>{e(a=>{var f;if(r==="pages"){console.warn("Wizard cannot be added inside a container");return}if(a.schema.elements.findIndex(h=>h.id===o)===-1)return;const l=bi(a.schema.elements),d=a.schema.elements.filter(h=>n?h.parentId===`${o}:${n}`:h.parentId===o).length,p=Hu(r,l,d);n?p.parentId=`${o}:${n}`:p.parentId=o,(r==="group"||r==="grid"||r==="repeatGroup")&&(p.children=[]);const u={...a.schema};u.elements=a.schema.elements.map(h=>h.id===o?{...h,children:[...h.children||[],p.id]}:h),u.elements=[...u.elements,p],u.metadata={...u.metadata,updatedAt:new Date().toISOString(),createdAt:((f=u.metadata)==null?void 0:f.createdAt)||new Date().toISOString()},cr(a,u),a.selectedElementId=p.id})},updateElement:(r,o)=>{e(n=>{var l;if(n.schema.elements.findIndex(c=>c.id===r)===-1)return;const s={...n.schema};s.elements=n.schema.elements.map(c=>c.id===r?{...c,...o}:c),s.metadata={...s.metadata,updatedAt:new Date().toISOString(),createdAt:((l=s.metadata)==null?void 0:l.createdAt)||new Date().toISOString()},cr(n,s)})},deleteElement:r=>{e(o=>{var c;const n=o.schema.elements.find(d=>d.id===r);if(!n)return;const a=new Set([r]),s=d=>{o.schema.elements.forEach(p=>{var u;(p.parentId===d||(u=p.parentId)!=null&&u.startsWith(`${d}:`))&&(a.add(p.id),s(p.id))})};s(r);const l={...o.schema};if(n.parentId){const d=n.parentId.split(":")[0];l.elements=o.schema.elements.map(p=>p.id===d&&p.children?{...p,children:p.children.filter(u=>u!==r)}:p)}l.elements=l.elements.filter(d=>!a.has(d.id)).map((d,p)=>d.parentId?d:{...d,order:p}),l.metadata={...l.metadata,updatedAt:new Date().toISOString(),createdAt:((c=l.metadata)==null?void 0:c.createdAt)||new Date().toISOString()},cr(o,l),(o.selectedElementId===r||a.has(o.selectedElementId||""))&&(o.selectedElementId=null)})},duplicateElement:r=>{e(o=>{var d;const n=o.schema.elements.find(p=>p.id===r);if(!n)return;const a=bi(o.schema.elements),s=_w(n,a);s.order=n.order+1;const l={...o.schema},c=n.order+1;l.elements=[...o.schema.elements.slice(0,c),s,...o.schema.elements.slice(c).map(p=>({...p,order:p.order+1}))],l.metadata={...l.metadata,updatedAt:new Date().toISOString(),createdAt:((d=l.metadata)==null?void 0:d.createdAt)||new Date().toISOString()},cr(o,l),o.selectedElementId=s.id})},moveElement:(r,o)=>{e(n=>{var d;const a=n.schema.elements.findIndex(p=>p.id===r);if(a===-1||a===o)return;const s=[...n.schema.elements],[l]=s.splice(a,1);s.splice(o,0,l),s.forEach((p,u)=>{p.order=u});const c={...n.schema,elements:s,metadata:{...n.schema.metadata,updatedAt:new Date().toISOString(),createdAt:((d=n.schema.metadata)==null?void 0:d.createdAt)||new Date().toISOString()}};cr(n,c)})},reorderElements:(r,o)=>{e(n=>{var c;if(r===o)return;const a=[...n.schema.elements],[s]=a.splice(r,1);a.splice(o,0,s),a.forEach((d,p)=>{d.order=p});const l={...n.schema,elements:a,metadata:{...n.schema.metadata,updatedAt:new Date().toISOString(),createdAt:((c=n.schema.metadata)==null?void 0:c.createdAt)||new Date().toISOString()}};cr(n,l)})},selectElement:r=>{e(o=>{o.selectedElementId=r})},undo:()=>{e(r=>{r.historyIndex>0&&(r.historyIndex-=1,r.schema=JSON.parse(JSON.stringify(r.history[r.historyIndex])),r.selectedElementId=null)})},redo:()=>{e(r=>{r.historyIndex<r.history.length-1&&(r.historyIndex+=1,r.schema=JSON.parse(JSON.stringify(r.history[r.historyIndex])),r.selectedElementId=null)})},canUndo:()=>t().historyIndex>0,canRedo:()=>{const r=t();return r.historyIndex<r.history.length-1},setMode:r=>{e(o=>{o.mode=r})},loadSchema:r=>{e(o=>{o.schema=r,o.history=[JSON.parse(JSON.stringify(r))],o.historyIndex=0,o.selectedElementId=null})},exportSchema:()=>JSON.parse(JSON.stringify(t().schema)),resetForm:()=>{e(r=>{const o=ju();r.schema=o,r.history=[JSON.parse(JSON.stringify(o))],r.historyIndex=0,r.selectedElementId=null})},updateFormTitle:r=>{e(o=>{var a;const n={...o.schema,title:r,metadata:{...o.schema.metadata,updatedAt:new Date().toISOString(),createdAt:((a=o.schema.metadata)==null?void 0:a.createdAt)||new Date().toISOString()}};cr(o,n)})},updateFormDescription:r=>{e(o=>{var a;const n={...o.schema,description:r,metadata:{...o.schema.metadata,updatedAt:new Date().toISOString(),createdAt:((a=o.schema.metadata)==null?void 0:a.createdAt)||new Date().toISOString()}};cr(o,n)})},setHoveredElementId:r=>{e(o=>{o.hoveredElementId=r})},setDraggedElementType:r=>{e(o=>{o.draggedElementType=r})},hasWizard:()=>t().schema.elements.some(r=>r.type==="pages"),addWizardStep:(r,o)=>{e(n=>{var s;const a={...n.schema};a.elements=n.schema.elements.map(l=>{var c,d;if(l.id===r&&l.type==="pages"){const p=((c=l.config)==null?void 0:c.steps)||[];return{...l,config:{...l.config,steps:[...p,o],activeStepId:((d=l.config)==null?void 0:d.activeStepId)||o.id}}}return l}),a.metadata={...a.metadata,updatedAt:new Date().toISOString(),createdAt:((s=a.metadata)==null?void 0:s.createdAt)||new Date().toISOString()},cr(n,a)})},updateWizardStep:(r,o,n)=>{e(a=>{var l;const s={...a.schema};s.elements=a.schema.elements.map(c=>{var d;if(c.id===r&&c.type==="pages"){const p=(((d=c.config)==null?void 0:d.steps)||[]).map(u=>u.id===o?{...u,...n}:u);return{...c,config:{...c.config,steps:p}}}return c}),s.metadata={...s.metadata,updatedAt:new Date().toISOString(),createdAt:((l=s.metadata)==null?void 0:l.createdAt)||new Date().toISOString()},cr(a,s)})},removeWizardStep:(r,o)=>{e(n=>{var u,f;const a=n.schema.elements.find(h=>h.id===r);if(!a||a.type!=="pages")return;const s=((u=a.config)==null?void 0:u.steps)||[];if(s.length<=1){console.warn("Wizard must have at least one step");return}const l=`${r}:${o}`,c=new Set,d=h=>{n.schema.elements.forEach(b=>{var g;(b.parentId===h||(g=b.parentId)!=null&&g.startsWith(`${h}:`))&&(c.add(b.id),d(b.id))})};d(l);const p={...n.schema};p.elements=n.schema.elements.map(h=>{var b,g,y;if(h.id===r){const v=s.filter(x=>x.id!==o),S=((b=h.config)==null?void 0:b.activeStepId)===o?(g=v[0])==null?void 0:g.id:(y=h.config)==null?void 0:y.activeStepId;return{...h,config:{...h.config,steps:v,activeStepId:S},children:(h.children||[]).filter(x=>!c.has(x))}}return h}),p.elements=p.elements.filter(h=>!c.has(h.id)),p.metadata={...p.metadata,updatedAt:new Date().toISOString(),createdAt:((f=p.metadata)==null?void 0:f.createdAt)||new Date().toISOString()},cr(n,p)})},setActiveWizardStep:(r,o)=>{e(n=>{const a={...n.schema};a.elements=n.schema.elements.map(s=>s.id===r&&s.type==="pages"?{...s,config:{...s.config,activeStepId:o}}:s),n.schema=a})},getContainerChildren:(r,o)=>{const n=t(),a=o?`${r}:${o}`:r;return n.schema.elements.filter(s=>s.parentId===a).sort((s,l)=>s.order-l.order)},validateSchema:()=>{const r=t(),o=[],n=r.schema.elements.map(s=>s.attributes.name),a=n.filter((s,l)=>n.indexOf(s)!==l);return a.length>0&&a.forEach(s=>{o.push({type:"error",message:`Duplicate field name: "${s}"`})}),r.schema.elements.forEach(s=>{(!s.attributes.name||s.attributes.name.trim()==="")&&o.push({type:"error",elementId:s.id,message:`Element "${s.properties.label||s.type}" has no field name`})}),r.schema.elements.forEach(s=>{var l;(l=s.validation)!=null&&l.required&&(!s.properties.label||s.properties.label.trim()==="")&&o.push({type:"warning",elementId:s.id,message:"Required element has no label"})}),{valid:o.filter(s=>s.type==="error").length===0,errors:o}}})));function Pw(){const e=t=>{const o=navigator.platform.toUpperCase().indexOf("MAC")>=0?t.metaKey:t.ctrlKey;o&&t.key==="z"&&!t.shiftKey?(t.preventDefault(),ie.getState().undo()):(o&&t.shiftKey&&t.key==="z"||o&&t.key==="y")&&(t.preventDefault(),ie.getState().redo())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)}const Mw=()=>{const e=ie(r=>r.selectedElementId);return ie(r=>r.schema.elements).find(r=>r.id===e)};class Ow{constructor(){ni(this,"elements",new Map);ni(this,"customGroups",new Map)}register(t,r={}){const{override:o=!1,group:n}=r;if(this.elements.has(t.type)&&!o){console.warn(`Element type "${t.type}" is already registered. Use { override: true } to replace it.`);return}if(!t.type)throw new Error("Element definition must have a type");if(!t.renderOnCanvas)throw new Error(`Element "${t.type}" must have a renderOnCanvas function`);if(!t.render)throw new Error(`Element "${t.type}" must have a render function`);if(!t.getDefaultValues)throw new Error(`Element "${t.type}" must have a getDefaultValues function`);if(this.elements.set(t.type,t),n){const a=this.customGroups.get(n);a?a.elements.push(t):this.customGroups.set(n,{id:n,label:n,elements:[t]})}}get(t){return this.elements.get(t)}has(t){return this.elements.has(t)}getAll(){return Array.from(this.elements.values())}getByCategory(t){return this.getAll().filter(r=>r.category===t)}getByStructure(t){return this.getAll().filter(r=>r.structure===t)}getByTypeCategory(t){return this.getAll().filter(r=>r.typeCategory===t)}getGroups(){const t=[],r={textInput:{label:"Text Input",order:1},numeric:{label:"Numeric",order:2},contact:{label:"Contact",order:3},security:{label:"Security",order:4},selection:{label:"Selection",order:5},matrix:{label:"Matrix",order:6},dateTime:{label:"Date & Time",order:7},fileUpload:{label:"File Upload",order:8},display:{label:"Display",order:9},product:{label:"Porduct",order:10},payment:{label:"Payment",order:11},orther:{label:"Other",order:12}},o={heading:{label:"Headings",order:10},layout:{label:"Layout",order:11},repeatable:{label:"Repeatable",order:12},special:{label:"Special",order:13}};for(const[n,a]of Object.entries(r)){const s=this.getAll().filter(l=>l.category==="field"&&l.subCategory===n);s.length>0&&t.push({id:n,label:a.label,elements:s,order:a.order})}for(const[n,a]of Object.entries(o)){const s=this.getAll().filter(l=>l.category==="page"&&l.subCategory===n);s.length>0&&t.push({id:n,label:a.label,elements:s,order:a.order})}for(const n of this.customGroups.values())t.push({...n,order:n.order??100});return t.sort((n,a)=>(n.order??0)-(a.order??0))}unregister(t){if(!this.elements.has(t))return!1;this.elements.delete(t);for(const r of this.customGroups.values()){const o=r.elements.findIndex(n=>n.type===t);o!==-1&&r.elements.splice(o,1)}return!0}clear(){this.elements.clear(),this.customGroups.clear()}getIcon(t){const r=this.get(t);return r==null?void 0:r.icon}getLabel(t){const r=this.get(t);return r==null?void 0:r.label}isContainer(t){const r=this.get(t);return(r==null?void 0:r.isContainer)??!1}supportsValidation(t){const r=this.get(t);return(r==null?void 0:r.supportsValidation)??!0}supportsOptions(t){const r=this.get(t);return(r==null?void 0:r.supportsOptions)??!1}getDefaultValues(t){const r=this.get(t);return r?r.getDefaultValues():{properties:{},layout:{},validation:{},config:{}}}}const vt=new Ow;function Iw(e,t){vt.register(e,t)}function Lw(e,t){for(const r of e)vt.register(r,t)}function Fw(e){return vt.unregister(e)}function Vw(e){return vt.get(e)}function Gw(e){return vt.has(e)}function Yu(e){var t,r,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(t=0;t<n;t++)e[t]&&(r=Yu(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}function Qu(){for(var e,t,r=0,o="",n=arguments.length;r<n;r++)(e=arguments[r])&&(t=Yu(e))&&(o&&(o+=" "),o+=t);return o}const zw=(e,t)=>{const r=new Array(e.length+t.length);for(let o=0;o<e.length;o++)r[o]=e[o];for(let o=0;o<t.length;o++)r[e.length+o]=t[o];return r},Bw=(e,t)=>({classGroupId:e,validator:t}),Ku=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Ra="-",Ru=[],Uw="arbitrary..",Ww=e=>{const t=jw(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:s=>{if(s.startsWith("[")&&s.endsWith("]"))return Hw(s);const l=s.split(Ra),c=l[0]===""&&l.length>1?1:0;return Xu(l,c,t)},getConflictingClassGroupIds:(s,l)=>{if(l){const c=o[s],d=r[s];return c?d?zw(d,c):c:d||Ru}return r[s]||Ru}}},Xu=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const n=e[t],a=r.nextPart.get(n);if(a){const d=Xu(e,t+1,a);if(d)return d}const s=r.validators;if(s===null)return;const l=t===0?e.join(Ra):e.slice(t).join(Ra),c=s.length;for(let d=0;d<c;d++){const p=s[d];if(p.validator(l))return p.classGroupId}},Hw=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),o=t.slice(0,r);return o?Uw+o:void 0})(),jw=e=>{const{theme:t,classGroups:r}=e;return qw(r,t)},qw=(e,t)=>{const r=Ku();for(const o in e){const n=e[o];yi(n,r,o,t)}return r},yi=(e,t,r,o)=>{const n=e.length;for(let a=0;a<n;a++){const s=e[a];Yw(s,t,r,o)}},Yw=(e,t,r,o)=>{if(typeof e=="string"){Qw(e,t,r);return}if(typeof e=="function"){Kw(e,t,r,o);return}Rw(e,t,r,o)},Qw=(e,t,r)=>{const o=e===""?t:Ju(t,e);o.classGroupId=r},Kw=(e,t,r,o)=>{if(Xw(e)){yi(e(o),t,r,o);return}t.validators===null&&(t.validators=[]),t.validators.push(Bw(r,e))},Rw=(e,t,r,o)=>{const n=Object.entries(e),a=n.length;for(let s=0;s<a;s++){const[l,c]=n[s];yi(c,Ju(t,l),r,o)}},Ju=(e,t)=>{let r=e;const o=t.split(Ra),n=o.length;for(let a=0;a<n;a++){const s=o[a];let l=r.nextPart.get(s);l||(l=Ku(),r.nextPart.set(s,l)),r=l}return r},Xw=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Jw=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),o=Object.create(null);const n=(a,s)=>{r[a]=s,t++,t>e&&(t=0,o=r,r=Object.create(null))};return{get(a){let s=r[a];if(s!==void 0)return s;if((s=o[a])!==void 0)return n(a,s),s},set(a,s){a in r?r[a]=s:n(a,s)}}},vi="!",Zu=":",Zw=[],ef=(e,t,r,o,n)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:o,isExternal:n}),ex=e=>{const{prefix:t,experimentalParseClassName:r}=e;let o=n=>{const a=[];let s=0,l=0,c=0,d;const p=n.length;for(let g=0;g<p;g++){const y=n[g];if(s===0&&l===0){if(y===Zu){a.push(n.slice(c,g)),c=g+1;continue}if(y==="/"){d=g;continue}}y==="["?s++:y==="]"?s--:y==="("?l++:y===")"&&l--}const u=a.length===0?n:n.slice(c);let f=u,h=!1;u.endsWith(vi)?(f=u.slice(0,-1),h=!0):u.startsWith(vi)&&(f=u.slice(1),h=!0);const b=d&&d>c?d-c:void 0;return ef(a,h,f,b)};if(t){const n=t+Zu,a=o;o=s=>s.startsWith(n)?a(s.slice(n.length)):ef(Zw,!1,s,void 0,!0)}if(r){const n=o;o=a=>r({className:a,parseClassName:n})}return o},tx=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,o)=>{t.set(r,1e6+o)}),r=>{const o=[];let n=[];for(let a=0;a<r.length;a++){const s=r[a],l=s[0]==="[",c=t.has(s);l||c?(n.length>0&&(n.sort(),o.push(...n),n=[]),o.push(s)):n.push(s)}return n.length>0&&(n.sort(),o.push(...n)),o}},rx=e=>({cache:Jw(e.cacheSize),parseClassName:ex(e),sortModifiers:tx(e),postfixLookupClassGroupIds:ox(e),...Ww(e)}),ox=e=>{const t=Object.create(null),r=e.postfixLookupClassGroups;if(r)for(let o=0;o<r.length;o++)t[r[o]]=!0;return t},nx=/\s+/,ax=(e,t)=>{const{parseClassName:r,getClassGroupId:o,getConflictingClassGroupIds:n,sortModifiers:a,postfixLookupClassGroupIds:s}=t,l=[],c=e.trim().split(nx);let d="";for(let p=c.length-1;p>=0;p-=1){const u=c[p],{isExternal:f,modifiers:h,hasImportantModifier:b,baseClassName:g,maybePostfixModifierPosition:y}=r(u);if(f){d=u+(d.length>0?" "+d:d);continue}let v=!!y,S;if(v){const _=g.substring(0,y);S=o(_);const E=S&&s[S]?o(g):void 0;E&&E!==S&&(S=E,v=!1)}else S=o(g);if(!S){if(!v){d=u+(d.length>0?" "+d:d);continue}if(S=o(g),!S){d=u+(d.length>0?" "+d:d);continue}v=!1}const x=h.length===0?"":h.length===1?h[0]:a(h).join(":"),w=b?x+vi:x,N=w+S;if(l.indexOf(N)>-1)continue;l.push(N);const k=n(S,v);for(let _=0;_<k.length;++_){const E=k[_];l.push(w+E)}d=u+(d.length>0?" "+d:d)}return d},sx=(...e)=>{let t=0,r,o,n="";for(;t<e.length;)(r=e[t++])&&(o=tf(r))&&(n&&(n+=" "),n+=o);return n},tf=e=>{if(typeof e=="string")return e;let t,r="";for(let o=0;o<e.length;o++)e[o]&&(t=tf(e[o]))&&(r&&(r+=" "),r+=t);return r},rf=(e,...t)=>{let r,o,n,a;const s=c=>{const d=t.reduce((p,u)=>u(p),e());return r=rx(d),o=r.cache.get,n=r.cache.set,a=l,l(c)},l=c=>{const d=o(c);if(d)return d;const p=ax(c,r);return n(c,p),p};return a=s,(...c)=>a(sx(...c))},lx=[],Nt=e=>{const t=r=>r[e]||lx;return t.isThemeGetter=!0,t},of=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,nf=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ix=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,cx=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,dx=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ux=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fx=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,px=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,po=e=>ix.test(e),Ve=e=>!!e&&!Number.isNaN(Number(e)),$r=e=>!!e&&Number.isInteger(Number(e)),wi=e=>e.endsWith("%")&&Ve(e.slice(0,-1)),Qr=e=>cx.test(e),af=()=>!0,hx=e=>dx.test(e)&&!ux.test(e),xi=()=>!1,mx=e=>fx.test(e),bx=e=>px.test(e),gx=e=>!fe(e)&&!he(e),yx=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),vx=e=>ho(e,ff,xi),fe=e=>of.test(e),Mo=e=>ho(e,pf,hx),sf=e=>ho(e,Ax,Ve),wx=e=>ho(e,mf,af),xx=e=>ho(e,hf,xi),lf=e=>ho(e,df,xi),Cx=e=>ho(e,uf,bx),Xa=e=>ho(e,bf,mx),he=e=>nf.test(e),Fn=e=>Oo(e,pf),Sx=e=>Oo(e,hf),cf=e=>Oo(e,df),Nx=e=>Oo(e,ff),Ex=e=>Oo(e,uf),Ja=e=>Oo(e,bf,!0),kx=e=>Oo(e,mf,!0),ho=(e,t,r)=>{const o=of.exec(e);return o?o[1]?t(o[1]):r(o[2]):!1},Oo=(e,t,r=!1)=>{const o=nf.exec(e);return o?o[1]?t(o[1]):r:!1},df=e=>e==="position"||e==="percentage",uf=e=>e==="image"||e==="url",ff=e=>e==="length"||e==="size"||e==="bg-size",pf=e=>e==="length",Ax=e=>e==="number",hf=e=>e==="family-name",mf=e=>e==="number"||e==="weight",bf=e=>e==="shadow",gf=()=>{const e=Nt("color"),t=Nt("font"),r=Nt("text"),o=Nt("font-weight"),n=Nt("tracking"),a=Nt("leading"),s=Nt("breakpoint"),l=Nt("container"),c=Nt("spacing"),d=Nt("radius"),p=Nt("shadow"),u=Nt("inset-shadow"),f=Nt("text-shadow"),h=Nt("drop-shadow"),b=Nt("blur"),g=Nt("perspective"),y=Nt("aspect"),v=Nt("ease"),S=Nt("animate"),x=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],N=()=>[...w(),he,fe],k=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto","contain","none"],E=()=>[he,fe,c],D=()=>[po,"full","auto",...E()],T=()=>[$r,"none","subgrid",he,fe],O=()=>["auto",{span:["full",$r,he,fe]},$r,he,fe],$=()=>[$r,"auto",he,fe],V=()=>["auto","min","max","fr",he,fe],G=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],q=()=>["start","end","center","stretch","center-safe","end-safe"],H=()=>["auto",...E()],Y=()=>[po,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...E()],J=()=>[po,"screen","full","dvw","lvw","svw","min","max","fit",...E()],W=()=>[po,"screen","full","lh","dvh","lvh","svh","min","max","fit",...E()],R=()=>[e,he,fe],we=()=>[...w(),cf,lf,{position:[he,fe]}],Q=()=>["no-repeat",{repeat:["","x","y","space","round"]}],te=()=>["auto","cover","contain",Nx,vx,{size:[he,fe]}],De=()=>[wi,Fn,Mo],de=()=>["","none","full",d,he,fe],Se=()=>["",Ve,Fn,Mo],re=()=>["solid","dashed","dotted","double"],me=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ce=()=>[Ve,wi,cf,lf],Ie=()=>["","none",b,he,fe],xe=()=>["none",Ve,he,fe],be=()=>["none",Ve,he,fe],ae=()=>[Ve,he,fe],ue=()=>[po,"full",...E()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Qr],breakpoint:[Qr],color:[af],container:[Qr],"drop-shadow":[Qr],ease:["in","out","in-out"],font:[gx],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Qr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Qr],shadow:[Qr],spacing:["px",Ve],text:[Qr],"text-shadow":[Qr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",po,fe,he,y]}],container:["container"],"container-type":[{"@container":["","normal","size",he,fe]}],"container-named":[yx],columns:[{columns:[Ve,fe,he,l]}],"break-after":[{"break-after":x()}],"break-before":[{"break-before":x()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:N()}],overflow:[{overflow:k()}],"overflow-x":[{"overflow-x":k()}],"overflow-y":[{"overflow-y":k()}],overscroll:[{overscroll:_()}],"overscroll-x":[{"overscroll-x":_()}],"overscroll-y":[{"overscroll-y":_()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:D()}],"inset-x":[{"inset-x":D()}],"inset-y":[{"inset-y":D()}],start:[{"inset-s":D(),start:D()}],end:[{"inset-e":D(),end:D()}],"inset-bs":[{"inset-bs":D()}],"inset-be":[{"inset-be":D()}],top:[{top:D()}],right:[{right:D()}],bottom:[{bottom:D()}],left:[{left:D()}],visibility:["visible","invisible","collapse"],z:[{z:[$r,"auto",he,fe]}],basis:[{basis:[po,"full","auto",l,...E()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ve,po,"auto","initial","none",fe]}],grow:[{grow:["",Ve,he,fe]}],shrink:[{shrink:["",Ve,he,fe]}],order:[{order:[$r,"first","last","none",he,fe]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:O()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:O()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":V()}],"auto-rows":[{"auto-rows":V()}],gap:[{gap:E()}],"gap-x":[{"gap-x":E()}],"gap-y":[{"gap-y":E()}],"justify-content":[{justify:[...G(),"normal"]}],"justify-items":[{"justify-items":[...q(),"normal"]}],"justify-self":[{"justify-self":["auto",...q()]}],"align-content":[{content:["normal",...G()]}],"align-items":[{items:[...q(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...q(),{baseline:["","last"]}]}],"place-content":[{"place-content":G()}],"place-items":[{"place-items":[...q(),"baseline"]}],"place-self":[{"place-self":["auto",...q()]}],p:[{p:E()}],px:[{px:E()}],py:[{py:E()}],ps:[{ps:E()}],pe:[{pe:E()}],pbs:[{pbs:E()}],pbe:[{pbe:E()}],pt:[{pt:E()}],pr:[{pr:E()}],pb:[{pb:E()}],pl:[{pl:E()}],m:[{m:H()}],mx:[{mx:H()}],my:[{my:H()}],ms:[{ms:H()}],me:[{me:H()}],mbs:[{mbs:H()}],mbe:[{mbe:H()}],mt:[{mt:H()}],mr:[{mr:H()}],mb:[{mb:H()}],ml:[{ml:H()}],"space-x":[{"space-x":E()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":E()}],"space-y-reverse":["space-y-reverse"],size:[{size:Y()}],"inline-size":[{inline:["auto",...J()]}],"min-inline-size":[{"min-inline":["auto",...J()]}],"max-inline-size":[{"max-inline":["none",...J()]}],"block-size":[{block:["auto",...W()]}],"min-block-size":[{"min-block":["auto",...W()]}],"max-block-size":[{"max-block":["none",...W()]}],w:[{w:[l,"screen",...Y()]}],"min-w":[{"min-w":[l,"screen","none",...Y()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[s]},...Y()]}],h:[{h:["screen","lh",...Y()]}],"min-h":[{"min-h":["screen","lh","none",...Y()]}],"max-h":[{"max-h":["screen","lh",...Y()]}],"font-size":[{text:["base",r,Fn,Mo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[o,kx,wx]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",wi,fe]}],"font-family":[{font:[Sx,xx,t]}],"font-features":[{"font-features":[fe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[n,he,fe]}],"line-clamp":[{"line-clamp":[Ve,"none",he,sf]}],leading:[{leading:[a,...E()]}],"list-image":[{"list-image":["none",he,fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",he,fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:R()}],"text-color":[{text:R()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...re(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ve,"from-font","auto",he,Mo]}],"text-decoration-color":[{decoration:R()}],"underline-offset":[{"underline-offset":[Ve,"auto",he,fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:E()}],"tab-size":[{tab:[$r,he,fe]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",he,fe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",he,fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:we()}],"bg-repeat":[{bg:Q()}],"bg-size":[{bg:te()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},$r,he,fe],radial:["",he,fe],conic:[$r,he,fe]},Ex,Cx]}],"bg-color":[{bg:R()}],"gradient-from-pos":[{from:De()}],"gradient-via-pos":[{via:De()}],"gradient-to-pos":[{to:De()}],"gradient-from":[{from:R()}],"gradient-via":[{via:R()}],"gradient-to":[{to:R()}],rounded:[{rounded:de()}],"rounded-s":[{"rounded-s":de()}],"rounded-e":[{"rounded-e":de()}],"rounded-t":[{"rounded-t":de()}],"rounded-r":[{"rounded-r":de()}],"rounded-b":[{"rounded-b":de()}],"rounded-l":[{"rounded-l":de()}],"rounded-ss":[{"rounded-ss":de()}],"rounded-se":[{"rounded-se":de()}],"rounded-ee":[{"rounded-ee":de()}],"rounded-es":[{"rounded-es":de()}],"rounded-tl":[{"rounded-tl":de()}],"rounded-tr":[{"rounded-tr":de()}],"rounded-br":[{"rounded-br":de()}],"rounded-bl":[{"rounded-bl":de()}],"border-w":[{border:Se()}],"border-w-x":[{"border-x":Se()}],"border-w-y":[{"border-y":Se()}],"border-w-s":[{"border-s":Se()}],"border-w-e":[{"border-e":Se()}],"border-w-bs":[{"border-bs":Se()}],"border-w-be":[{"border-be":Se()}],"border-w-t":[{"border-t":Se()}],"border-w-r":[{"border-r":Se()}],"border-w-b":[{"border-b":Se()}],"border-w-l":[{"border-l":Se()}],"divide-x":[{"divide-x":Se()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Se()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...re(),"hidden","none"]}],"divide-style":[{divide:[...re(),"hidden","none"]}],"border-color":[{border:R()}],"border-color-x":[{"border-x":R()}],"border-color-y":[{"border-y":R()}],"border-color-s":[{"border-s":R()}],"border-color-e":[{"border-e":R()}],"border-color-bs":[{"border-bs":R()}],"border-color-be":[{"border-be":R()}],"border-color-t":[{"border-t":R()}],"border-color-r":[{"border-r":R()}],"border-color-b":[{"border-b":R()}],"border-color-l":[{"border-l":R()}],"divide-color":[{divide:R()}],"outline-style":[{outline:[...re(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ve,he,fe]}],"outline-w":[{outline:["",Ve,Fn,Mo]}],"outline-color":[{outline:R()}],shadow:[{shadow:["","none",p,Ja,Xa]}],"shadow-color":[{shadow:R()}],"inset-shadow":[{"inset-shadow":["none",u,Ja,Xa]}],"inset-shadow-color":[{"inset-shadow":R()}],"ring-w":[{ring:Se()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:R()}],"ring-offset-w":[{"ring-offset":[Ve,Mo]}],"ring-offset-color":[{"ring-offset":R()}],"inset-ring-w":[{"inset-ring":Se()}],"inset-ring-color":[{"inset-ring":R()}],"text-shadow":[{"text-shadow":["none",f,Ja,Xa]}],"text-shadow-color":[{"text-shadow":R()}],opacity:[{opacity:[Ve,he,fe]}],"mix-blend":[{"mix-blend":[...me(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":me()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ve]}],"mask-image-linear-from-pos":[{"mask-linear-from":ce()}],"mask-image-linear-to-pos":[{"mask-linear-to":ce()}],"mask-image-linear-from-color":[{"mask-linear-from":R()}],"mask-image-linear-to-color":[{"mask-linear-to":R()}],"mask-image-t-from-pos":[{"mask-t-from":ce()}],"mask-image-t-to-pos":[{"mask-t-to":ce()}],"mask-image-t-from-color":[{"mask-t-from":R()}],"mask-image-t-to-color":[{"mask-t-to":R()}],"mask-image-r-from-pos":[{"mask-r-from":ce()}],"mask-image-r-to-pos":[{"mask-r-to":ce()}],"mask-image-r-from-color":[{"mask-r-from":R()}],"mask-image-r-to-color":[{"mask-r-to":R()}],"mask-image-b-from-pos":[{"mask-b-from":ce()}],"mask-image-b-to-pos":[{"mask-b-to":ce()}],"mask-image-b-from-color":[{"mask-b-from":R()}],"mask-image-b-to-color":[{"mask-b-to":R()}],"mask-image-l-from-pos":[{"mask-l-from":ce()}],"mask-image-l-to-pos":[{"mask-l-to":ce()}],"mask-image-l-from-color":[{"mask-l-from":R()}],"mask-image-l-to-color":[{"mask-l-to":R()}],"mask-image-x-from-pos":[{"mask-x-from":ce()}],"mask-image-x-to-pos":[{"mask-x-to":ce()}],"mask-image-x-from-color":[{"mask-x-from":R()}],"mask-image-x-to-color":[{"mask-x-to":R()}],"mask-image-y-from-pos":[{"mask-y-from":ce()}],"mask-image-y-to-pos":[{"mask-y-to":ce()}],"mask-image-y-from-color":[{"mask-y-from":R()}],"mask-image-y-to-color":[{"mask-y-to":R()}],"mask-image-radial":[{"mask-radial":[he,fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":ce()}],"mask-image-radial-to-pos":[{"mask-radial-to":ce()}],"mask-image-radial-from-color":[{"mask-radial-from":R()}],"mask-image-radial-to-color":[{"mask-radial-to":R()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":w()}],"mask-image-conic-pos":[{"mask-conic":[Ve]}],"mask-image-conic-from-pos":[{"mask-conic-from":ce()}],"mask-image-conic-to-pos":[{"mask-conic-to":ce()}],"mask-image-conic-from-color":[{"mask-conic-from":R()}],"mask-image-conic-to-color":[{"mask-conic-to":R()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:we()}],"mask-repeat":[{mask:Q()}],"mask-size":[{mask:te()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",he,fe]}],filter:[{filter:["","none",he,fe]}],blur:[{blur:Ie()}],brightness:[{brightness:[Ve,he,fe]}],contrast:[{contrast:[Ve,he,fe]}],"drop-shadow":[{"drop-shadow":["","none",h,Ja,Xa]}],"drop-shadow-color":[{"drop-shadow":R()}],grayscale:[{grayscale:["",Ve,he,fe]}],"hue-rotate":[{"hue-rotate":[Ve,he,fe]}],invert:[{invert:["",Ve,he,fe]}],saturate:[{saturate:[Ve,he,fe]}],sepia:[{sepia:["",Ve,he,fe]}],"backdrop-filter":[{"backdrop-filter":["","none",he,fe]}],"backdrop-blur":[{"backdrop-blur":Ie()}],"backdrop-brightness":[{"backdrop-brightness":[Ve,he,fe]}],"backdrop-contrast":[{"backdrop-contrast":[Ve,he,fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ve,he,fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ve,he,fe]}],"backdrop-invert":[{"backdrop-invert":["",Ve,he,fe]}],"backdrop-opacity":[{"backdrop-opacity":[Ve,he,fe]}],"backdrop-saturate":[{"backdrop-saturate":[Ve,he,fe]}],"backdrop-sepia":[{"backdrop-sepia":["",Ve,he,fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":E()}],"border-spacing-x":[{"border-spacing-x":E()}],"border-spacing-y":[{"border-spacing-y":E()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",he,fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ve,"initial",he,fe]}],ease:[{ease:["linear","initial",v,he,fe]}],delay:[{delay:[Ve,he,fe]}],animate:[{animate:["none",S,he,fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[g,he,fe]}],"perspective-origin":[{"perspective-origin":N()}],rotate:[{rotate:xe()}],"rotate-x":[{"rotate-x":xe()}],"rotate-y":[{"rotate-y":xe()}],"rotate-z":[{"rotate-z":xe()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":["scale-3d"],skew:[{skew:ae()}],"skew-x":[{"skew-x":ae()}],"skew-y":[{"skew-y":ae()}],transform:[{transform:[he,fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:N()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ue()}],"translate-x":[{"translate-x":ue()}],"translate-y":[{"translate-y":ue()}],"translate-z":[{"translate-z":ue()}],"translate-none":["translate-none"],zoom:[{zoom:[$r,he,fe]}],accent:[{accent:R()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:R()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",he,fe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":R()}],"scrollbar-track-color":[{"scrollbar-track":R()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":E()}],"scroll-mx":[{"scroll-mx":E()}],"scroll-my":[{"scroll-my":E()}],"scroll-ms":[{"scroll-ms":E()}],"scroll-me":[{"scroll-me":E()}],"scroll-mbs":[{"scroll-mbs":E()}],"scroll-mbe":[{"scroll-mbe":E()}],"scroll-mt":[{"scroll-mt":E()}],"scroll-mr":[{"scroll-mr":E()}],"scroll-mb":[{"scroll-mb":E()}],"scroll-ml":[{"scroll-ml":E()}],"scroll-p":[{"scroll-p":E()}],"scroll-px":[{"scroll-px":E()}],"scroll-py":[{"scroll-py":E()}],"scroll-ps":[{"scroll-ps":E()}],"scroll-pe":[{"scroll-pe":E()}],"scroll-pbs":[{"scroll-pbs":E()}],"scroll-pbe":[{"scroll-pbe":E()}],"scroll-pt":[{"scroll-pt":E()}],"scroll-pr":[{"scroll-pr":E()}],"scroll-pb":[{"scroll-pb":E()}],"scroll-pl":[{"scroll-pl":E()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",he,fe]}],fill:[{fill:["none",...R()]}],"stroke-w":[{stroke:[Ve,Fn,Mo,sf]}],stroke:[{stroke:["none",...R()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},_x=(e,{cacheSize:t,prefix:r,experimentalParseClassName:o,extend:n={},override:a={}})=>(ln(e,"cacheSize",t),ln(e,"prefix",r),ln(e,"experimentalParseClassName",o),Za(e.theme,a.theme),Za(e.classGroups,a.classGroups),Za(e.conflictingClassGroups,a.conflictingClassGroups),Za(e.conflictingClassGroupModifiers,a.conflictingClassGroupModifiers),ln(e,"postfixLookupClassGroups",a.postfixLookupClassGroups),ln(e,"orderSensitiveModifiers",a.orderSensitiveModifiers),es(e.theme,n.theme),es(e.classGroups,n.classGroups),es(e.conflictingClassGroups,n.conflictingClassGroups),es(e.conflictingClassGroupModifiers,n.conflictingClassGroupModifiers),Ci(e,n,"postfixLookupClassGroups"),Ci(e,n,"orderSensitiveModifiers"),e),ln=(e,t,r)=>{r!==void 0&&(e[t]=r)},Za=(e,t)=>{if(t)for(const r in t)ln(e,r,t[r])},es=(e,t)=>{if(t)for(const r in t)Ci(e,t,r)},Ci=(e,t,r)=>{const o=t[r];o!==void 0&&(e[r]=e[r]?e[r].concat(o):o)},Tx=((e,...t)=>typeof e=="function"?rf(gf,e,...t):rf(()=>_x(gf(),e),...t))({prefix:""});function m(...e){const t=Qu(e);return Tx(t)}const ts=({label:e,required:t,htmlFor:r,className:o=""})=>e?i.jsxs("label",{htmlFor:r,className:m("block text-sm font-medium text-gray-700",o),children:[e,t&&i.jsx("span",{className:m("text-red-500 ml-1"),children:"*"})]}):null,rs=({description:e,className:t=""})=>e?i.jsx("p",{className:m("text-xs text-gray-500",t),children:e}):null,Vn=({errors:e,className:t=""})=>!e||e.length===0?null:i.jsx("div",{className:m("space-y-1",t),children:e.map((r,o)=>i.jsx("p",{className:m("text-xs text-red-500"),children:r},o))}),Dx=({label:e,description:t,required:r,errors:o,children:n})=>i.jsxs("div",{className:m("space-y-1.5"),children:[i.jsx(ts,{label:e,required:r}),i.jsx(rs,{description:t}),n,i.jsx(Vn,{errors:o})]}),ge=({label:e,description:t,required:r,errors:o,labelPosition:n="top",className:a="",children:s})=>n==="hidden"?i.jsxs("div",{className:m("space-y-1.5",a),children:[s,i.jsx(Vn,{errors:o})]}):n==="left"?i.jsxs("div",{className:m("flex items-start gap-4",a),children:[i.jsxs("div",{className:m("w-1/3 pt-2"),children:[i.jsx(ts,{label:e,required:r}),i.jsx(rs,{description:t})]}),i.jsxs("div",{className:m("flex-1 space-y-1.5"),children:[s,i.jsx(Vn,{errors:o})]})]}):i.jsxs("div",{className:m("space-y-1.5",a),children:[i.jsx(ts,{label:e,required:r}),i.jsx(rs,{description:t}),s,i.jsx(Vn,{errors:o})]}),$x=({children:e,className:t=""})=>i.jsx("div",{className:m("pointer-events-none",t),children:e}),Px=({icon:e="📋",message:t,subMessage:r})=>i.jsxs("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg p-6 text-center bg-gray-50"),children:[i.jsx("span",{className:m("text-4xl"),children:e}),i.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:t}),r&&i.jsx("p",{className:m("text-xs text-gray-400"),children:r})]}),Io=({icon:e,children:t,iconPosition:r="left"})=>i.jsxs("div",{className:m("relative"),children:[i.jsx("span",{className:m("absolute top-1/2 -translate-y-1/2 text-gray-400",r==="left"?"left-3":"right-3"),children:e}),t]}),Si=({prefix:e,suffix:t,children:r})=>i.jsxs("div",{className:m("flex"),children:[e&&i.jsx("span",{className:m("inline-flex items-center px-3 border border-r-0 border-gray-300 rounded-l-md bg-gray-100 text-gray-500 text-sm"),children:e}),i.jsx("div",{className:m("flex-1",!e&&"rounded-l-md",!t&&"rounded-r-md"),children:r}),t&&i.jsx("span",{className:m("inline-flex items-center px-3 border border-l-0 border-gray-300 rounded-r-md bg-gray-100 text-gray-500 text-sm"),children:t})]});function qt(e={}){const{hasError:t=!1,disabled:r=!1,size:o="medium",hasLeftIcon:n=!1,hasRightIcon:a=!1,hasPrefix:s=!1,hasSuffix:l=!1}=e;return m("w-full","border","transition-colors","focus:outline-none","focus:ring-2","focus:ring-offset-0",{small:"px-2 py-1.5 text-sm",medium:"px-3 py-2 text-sm",large:"px-4 py-3 text-base"}[o],!s&&!l&&"rounded-md",s&&!l&&"rounded-r-md",!s&&l&&"rounded-l-md",n&&"pl-10",a&&"pr-10",r&&"bg-gray-50 text-gray-500 cursor-not-allowed border-gray-300",t&&!r&&"border-red-500 focus:ring-red-500 focus:border-red-500",!t&&!r&&"border-gray-300 focus:ring-blue-500 focus:border-blue-500")}function Ot(e="medium"){return m("w-full",{small:"px-2 py-1.5 text-sm",medium:"px-3 py-2 text-sm",large:"px-4 py-3 text-base"}[e],"border","border-gray-300","rounded-md","bg-gray-50","text-gray-500")}function Mx(e={}){const{variant:t="primary",size:r="medium",disabled:o=!1}=e,n={small:"px-4 py-1.5 text-sm",medium:"px-6 py-2.5 text-base",large:"px-8 py-3 text-lg"},a={primary:"bg-blue-600 text-white hover:bg-blue-700",secondary:"bg-gray-600 text-white hover:bg-gray-700",outline:"border-2 border-blue-600 text-blue-600 bg-transparent hover:bg-blue-50",ghost:"text-blue-600 hover:bg-blue-50"};return m("rounded-md","font-medium","transition-colors","focus:outline-none","focus:ring-2","focus:ring-offset-2",n[r],o&&"opacity-50 cursor-not-allowed",a[t])}function oe(e){const{element:t,properties:r,layout:o,validation:n,config:a,mode:s,value:l,onChange:c,errors:d,readOnly:p,disabled:u}=e;return{label:r.label,description:r.description,placeholder:r.placeholder,prefix:r.prefix,suffix:r.suffix,required:(n==null?void 0:n.required)??!1,labelPosition:o.labelPosition??"top",isCanvas:s==="canvas",isDisabled:u||p||s==="canvas",value:l,onChange:c,errors:d,config:a,element:t}}/*!
2
+ * Copyright (c) 2023 Momo Bassit.
3
+ * Licensed under the MIT License (MIT)
4
+ * https://github.com/mdbassit/Wysi
5
+ */(function(e,t){function r(I,F){(F==null||F>I.length)&&(F=I.length);for(var K=0,j=new Array(F);K<F;K++)j[K]=I[K];return j}function o(I,F){var K=typeof Symbol<"u"&&I[Symbol.iterator]||I["@@iterator"];if(K)return(K=K.call(I)).next.bind(K);if(Array.isArray(I)||(K=(function(Z,se){if(Z){if(typeof Z=="string")return r(Z,se);var A=Object.prototype.toString.call(Z).slice(8,-1);return A==="Object"&&Z.constructor&&(A=Z.constructor.name),A==="Map"||A==="Set"?Array.from(Z):A==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(A)?r(Z,se):void 0}})(I))||F){K&&(I=K);var j=0;return function(){return j>=I.length?{done:!0}:{done:!1,value:I[j++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
6
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var n,a,s={el:"[data-wysi], .wysi-field",tools:["format","|","bold","italic","|",{label:"Text alignment",items:["alignLeft","alignCenter","alignRight","alignJustify"]},"|","ul","ol","|","indent","outdent","|","link","image"],allowedTags:{br:{attributes:[],styles:[],isEmpty:!0},p:{attributes:[],styles:[],isEmpty:!1}}},l={format:{tags:["p","h1","h2","h3","h4"],styles:["text-align"],label:"Select block format",paragraph:"Paragraph",heading:"Heading"},quote:{tags:["blockquote"],label:"Quote"},bold:{tags:["strong"],alias:["b"],label:"Bold"},italic:{tags:["em"],alias:["i"],label:"Italic"},underline:{tags:["u"],label:"Underline"},strike:{tags:["s"],alias:["del","strike"],label:"Strike-through",command:"strikeThrough"},alignLeft:{label:"Align left",command:"justifyLeft"},alignCenter:{label:"Align center",command:"justifyCenter"},alignRight:{label:"Align right",command:"justifyRight"},alignJustify:{label:"Justify",command:"justifyFull"},ul:{tags:["ul"],extraTags:["li"],styles:["text-align"],label:"Bulleted list",command:"insertUnorderedList"},ol:{tags:["ol"],extraTags:["li"],styles:["text-align"],label:"Numbered list",command:"insertOrderedList"},indent:{label:"Increase indent"},outdent:{label:"Decrease indent"},link:{tags:["a"],attributes:["href","target"],attributeLabels:["URL","Open link in"],hasForm:!0,formOptions:{target:[{label:"Current tab",value:""},{label:"New tab",value:"_blank"}]},label:"Link"},image:{tags:["img"],attributes:["src","alt"],attributeLabels:["URL","Alternative text"],extraSettings:["size","position"],extraSettingLabels:["Image size","Image position"],styles:["width","display","margin","float"],isEmpty:!0,hasForm:!0,formOptions:{size:[{label:"None",value:"",criterion:null},{label:"100%",value:"100%",criterion:{width:"100%"}},{label:"50%",value:"50%",criterion:{width:"50%"}},{label:"25%",value:"25%",criterion:{width:"25%"}}],position:[{label:"None",value:"",criterion:null},{label:"Left",value:"left",criterion:{float:"left"}},{label:"Center",value:"center",criterion:{margin:"auto"}},{label:"Right",value:"right",criterion:{float:"right"}}]},label:"Image"},hr:{tags:["hr"],isEmpty:!0,label:"Horizontal line",command:"insertHorizontalRule"},removeFormat:{label:"Remove format"},unlink:{label:"Remove link"}},c={},d="wysi-selected",p="wysi-fragment-placeholder",u=["H1","H2","H3","H4"],f=["BLOCKQUOTE","HR","P","OL","UL"].concat(u),h=navigator.userAgent.search(/Gecko\//)>-1,b=function(I,F){return I.dispatchEvent(new Event(F,{bubbles:!0}))},g=function(I,F){return F===void 0&&(F=null),t.execCommand(I,!1,F)},y=function(I,F){return I.classList&&I.classList.contains(F)};function v(I,F,K,j){typeof K=="string"?I.addEventListener(F,(function(Z){var se=Z.target;se.matches(K)&&j.call(se,Z)})):(j=K,I.addEventListener(F,j))}function S(I){var F=w("template");return F.innerHTML=I.trim(),F.content}function x(I){return I&&JSON.parse(JSON.stringify(I))}function w(I,F){var K=t.createElement(I);if(F)for(var j in F)j[0]==="_"?K[j.substring(1)]=F[j]:K.setAttribute(j,F[j]);return K}function N(I,F){F=F!==void 0?F:[],t.readyState!=="loading"?I.apply(void 0,F):v(t,"DOMContentLoaded",(function(){I.apply(void 0,F)}))}function k(I){var F=[];return D(I).forEach((function(K){var j=K.previousElementSibling;if(j&&y(j,"wysi-wrapper")){var Z=j.children,se=Z[0],A=Z[1],M=E(A);F.push({textarea:K,wrapper:j,toolbar:se,editor:A,instanceId:M})}})),F}function _(I){for(var F,K,j,Z=[];I&&I!==t.body;){if(I.tagName){if(y(I,"wysi-wrapper")){F=I;break}Z.push(I)}I=I.parentNode}if(F){var se=F.children;K=se[0],j=se[1]}return{toolbar:K,editor:j,nodes:Z}}function E(I){return I.dataset.wid}function D(I){return typeof I=="string"?Array.from(t.querySelectorAll(I)):I instanceof Node?[I]:I instanceof NodeList||I instanceof HTMLCollection?Array.from(I):Array.isArray(I)?I.filter((function(F){return F instanceof Node})):[]}function T(I){var F,K=I.parentNode,j=I.id;if(K.nodeName==="LABEL"?F=K:j!==void 0&&(F=t.querySelector('label[for="'+j+'"]')),F){var Z=[].filter.call(F.childNodes,(function(se){return se.nodeType===3})).map((function(se){return se.textContent.replace(/\s+/g," ").trim()})).filter((function(se){return se!==""}))[0];if(Z)return Z}return""}function O(I,F){return a[I]&&a[I][F]?a[I][F]:F}function $(){n&&(G(n),n=void 0)}function V(I){n=I}function G(I){var F=t.getSelection();F.removeAllRanges(),F.addRange(I)}function q(I,F){I.setAttribute("aria-expanded",F)}function H(I,F,K){K===void 0&&(K=[]);var j=l[I];if(j){var Z=j.command||I;$(),(function(se,A){switch(se){case"quote":A[0]="blockquote";case"format":g("formatBlock","<"+A[0]+">");break;case"link":var M=A[0],L=A[1],B=L===void 0?"":L,U=A[2];U&&g("insertHTML",'<a href="'+M+'"'+(B!==""?' target="'+B+'"':"")+">"+U+"</a>");break;case"image":var X=[],z=A[0],ee=A[1],ne=ee===void 0?"":ee,Ce=A[2],Fe=A[3],Ue=A[4];Ce!==""&&X.push("width: "+Ce+";"),Fe!==""&&(Fe==="center"?X.push("display: block; margin: auto;"):X.push("float: "+Fe+";"));var ye='<img src="'+z+'" alt="'+ne+'" class="wysi-selected"'+(X.length>0?' style="'+X.join(" ")+'"':"")+">",We=Ue?Ue.replace(/<img[^>]+>/i,ye):ye;g("insertHTML",We);break;default:g(se)}})(Z,K),F.focus()}}function Y(I){var F=I.label,K=I.items,j=K[0],Z=w("div",{class:["wysi-listbox"].concat(I.classes||[]).join(" ")}),se=w("button",{type:"button",title:F,"aria-label":F+" "+j.label,"aria-haspopup":"listbox","aria-expanded":!1,_innerHTML:J(j)}),A=w("div",{role:"listbox",tabindex:-1,"aria-label":F});return K.forEach((function(M){var L=w("button",{type:"button",role:"option",tabindex:-1,"aria-label":M.label,"aria-selected":!1,"data-action":M.action,"data-option":M.name||"",_innerHTML:J(M)});A.appendChild(L)})),Z.appendChild(se),Z.appendChild(A),Z}function J(I){return I.icon?'<svg><use href="#wysi-'+I.icon+'"></use></svg>':I.label}function W(I){var F=I.getAttribute("aria-expanded")==="true",K=I.nextElementSibling,j=K.querySelector('[aria-selected="true"]');j||(j=K.firstElementChild),q(I,!F),j.focus()}function R(I){var F=I.parentNode,K=F.previousElementSibling,j=F.querySelector('[aria-selected="true"]');j&&j.setAttribute("aria-selected","false"),I.setAttribute("aria-selected","true"),K.innerHTML=I.innerHTML}function we(){var I=t.querySelector('.wysi-listbox [aria-expanded="true"]');I&&q(I,!1)}NodeList!==void 0&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),v(t,"click",".wysi-listbox > button",(function(I){we(),W(I.target)})),v(t,"keydown",".wysi-listbox > button",(function(I){switch(I.key){case"ArrowUp":case"ArrowDown":case"Enter":case" ":W(I.target),I.preventDefault()}})),v(t.documentElement,"mousemove",".wysi-listbox > div > button",(function(I){I.target.focus()})),v(t,"click",".wysi-listbox > div > button",(function(I){var F=I.target,K=F.dataset.action,j=F.dataset.option,Z=_(F).editor,se=t.getSelection();se&&Z.contains(se.anchorNode)&&H(K,Z,[j]),R(F)})),v(t,"keydown",".wysi-listbox > div > button",(function(I){var F=I.target,K=F.parentNode,j=K.previousElementSibling,Z=!0;switch(I.key){case"ArrowUp":var se=F.previousElementSibling;se&&se.focus();break;case"ArrowDown":var A=F.nextElementSibling;A&&A.focus();break;case"Home":K.firstElementChild.focus();break;case"End":K.lastElementChild.focus();break;case"Tab":F.click();break;case"Escape":q(j,!1);break;default:Z=!1}Z&&(I.preventDefault(),I.stopImmediatePropagation())}));var Q=!1;v(t,"click",(function(I){Q||we()})),v(t,"mousedown",".wysi-listbox > button",(function(I){return Q=!0})),v(t,"mouseup",(function(I){return setTimeout((function(){Q=!1}))}));var te=0;function De(I){var F=te++,K=w("fieldset",{class:"wysi-segmented"});return K.appendChild(w("legend",{_textContent:I.label})),I.options.forEach((function(j){var Z=te++;K.appendChild(w("input",{id:"wysi-seg-"+Z,name:"wysi-"+I.toolName+"-"+I.name+"-"+F,type:"radio","data-attribute":I.name,value:j.value})),K.appendChild(w("label",{for:"wysi-seg-"+Z,_textContent:O(I.toolName,j.label)}))})),K}function de(I){var F=I.nextElementSibling.querySelectorAll('input[type="text"]'),K=I.nextElementSibling.querySelectorAll('input[type="radio"]'),j=t.getSelection(),Z=j.anchorNode,se=_(Z),A=se.editor,M=se.nodes,L={};if(A){var B=I.dataset.action,U=l[B],X=A.querySelector("."+d),z=!1;if(X||(X=M.filter((function(ne){return U.tags.includes(ne.tagName.toLowerCase())}))[0],z=!0),X){var ee=t.createRange();z?ee.selectNodeContents(X):ee.selectNode(X),V(ee),U.attributes.forEach((function(ne){L[ne]=X.getAttribute(ne)})),U.extraSettings&&U.extraSettings.forEach((function(ne){for(var Ce,Fe=o(U.formOptions[ne]);!(Ce=Fe()).done;){var Ue=Ce.value;if(Ue.criterion){var ye=Object.keys(Ue.criterion)[0],We=Ue.criterion[ye];if(X.style[ye]&&X.style[ye]===We){L[ne]=Ue.value;break}}}}))}else j&&A.contains(Z)&&j.rangeCount&&V(j.getRangeAt(0))}F.forEach((function(ne){ne.value=L[ne.dataset.attribute]||""})),K.forEach((function(ne){var Ce=L[ne.dataset.attribute]||"";ne.value===Ce&&(ne.checked=!0)})),q(I,!0),F[0].focus()}function Se(I){var F,K,j=I.dataset.action,Z=n,se=I.parentNode.querySelectorAll('input[type="text"]'),A=I.parentNode.querySelectorAll('input[type="radio"]'),M=_(I).editor,L=[];if(se.forEach((function(X){L.push(X.value)})),A.forEach((function(X){X.checked&&L.push(X.value)})),j==="image"){var B=M.querySelector("."+d),U=B?B.parentNode:{};B&&U.tagName==="A"&&L.push(U.outerHTML)}else j==="link"&&Z&&L.push((F=Z.cloneContents(),(K=w("div")).appendChild(F),K.innerHTML));H(j,M,L)}function re(I){var F=t.querySelector('.wysi-popover [aria-expanded="true"]');F&&q(F,!1),I||$()}v(t,"click",".wysi-popover > button",(function(I){re(),de(I.target)})),v(t,"keydown",".wysi-popover > button",(function(I){switch(I.key){case"ArrowUp":case"ArrowDown":case"Enter":case" ":de(I.target),I.preventDefault()}})),v(t,"click",".wysi-popover > div > button[data-action]",(function(I){Se(I.target),re(!0)})),v(t,"click",".wysi-popover > div > button:not([data-action])",(function(I){re()})),v(t,"click",".wysi-popover *:not(button)",(function(I){I.stopImmediatePropagation()})),v(t,"keydown",".wysi-popover *",(function(I){var F=I.target,K=F.parentNode,j=K.tagName==="DIV"?K:K.parentNode;switch(I.key){case"Tab":var Z=j.querySelector("input");I.shiftKey?F===Z&&(j.lastElementChild.focus(),I.preventDefault()):F.nextElementSibling||F.parentNode.nextElementSibling||(Z.focus(),I.preventDefault());break;case"Enter":F.tagName==="INPUT"&&(j.querySelector("[data-action]:last-of-type").click(),I.preventDefault());break;case"Escape":re(),I.stopImmediatePropagation()}}));var me=!1;function ce(I){var F=w("div",{class:"wysi-toolbar"});return I.forEach((function(K){switch(K){case"|":F.appendChild(w("div",{class:"wysi-separator"}));break;case"-":F.appendChild(w("div",{class:"wysi-newline"}));break;case"format":F.appendChild((function(){var A="format",M=O(A,l.format.label),L=O(A,l.format.paragraph),B=O(A,l.format.heading),U="wysi-format",X=l.format.tags.map((function(z){return{name:z,label:z==="p"?L:B+" "+z.substring(1),action:"format"}}));return Y({label:M,items:X,classes:U})})());break;default:typeof K=="object"?K.items&&F.appendChild((Z=(j=K).label||O("toolbar","Select an item"),se=j.items.map((function(A){return{label:O(A,l[A].label),icon:A,action:A}})),Y({label:Z,items:se}))):(function(A,M){var L=l[A],B=O(A,L.label),U=w("button",{type:"button",title:B,"aria-label":B,"aria-pressed":!1,"data-action":A,_innerHTML:'<svg><use href="#wysi-'+A+'"></use></svg>'});if(L.hasForm){var X=(function(z,ee){var ne=l[z],Ce=ne.attributeLabels,Fe=ne.attributes.map((function(pt,ir){return{name:pt,label:O(z,Ce[ir])}})),Ue=w("div",{class:"wysi-popover"}),ye=w("div",{tabindex:-1});if(ee.setAttribute("aria-haspopup",!0),ee.setAttribute("aria-expanded",!1),Ue.appendChild(ee),Ue.appendChild(ye),Fe.forEach((function(pt){if(z!=="link"||pt.name!=="target"){var ir=w("label"),kt=w("span",{_textContent:pt.label}),Ao=w("input",{type:"text",name:"wysi-"+pt.name,"data-attribute":pt.name});ir.appendChild(kt),ir.appendChild(Ao),ye.appendChild(ir)}})),z==="link"){var We=Fe.find((function(pt){return pt.name==="target"}));We&&(We.toolName=z,We.options=ne.formOptions&&ne.formOptions.target||[],ye.appendChild(w("span",{_textContent:We.label})),ye.appendChild(De(We)));var ct="unlink",Jt=O(z,l[ct].label);ye.appendChild(w("button",{type:"button",title:Jt,"aria-label":Jt,"data-action":ct,_innerHTML:'<svg><use href="#wysi-delete"></use></svg>'}))}z==="image"&&ne.extraSettings.map((function(pt,ir){return{name:pt,label:O(z,ne.extraSettingLabels[ir])}})).forEach((function(pt){pt.toolName=z,pt.options=ne.formOptions&&ne.formOptions[pt.name]||[],ye.appendChild(w("span",{_textContent:pt.label})),ye.appendChild(De(pt))}));var ko=w("button",{type:"button",_textContent:O("popover","Cancel")}),Zt=w("button",{type:"button","data-action":z,_textContent:O("popover","Save")});return ye.appendChild(ko),ye.appendChild(Zt),Ue})(A,U);M.appendChild(X)}else M.appendChild(U)})(K,F)}var j,Z,se})),F}function Ie(){var I=t.getSelection(),F=I.anchorNode;if(F){var K=I.getRangeAt(0),j=(function(z){for(;z.firstChild!==null;)z=z.firstChild;return z})(K.startContainer.nextElementSibling||K.startContainer),Z=_(K.intersectsNode(j)?j:F),se=Z.toolbar,A=Z.editor,M=Z.nodes,L=M.map((function(z){return z.tagName.toLowerCase()}));if(A){var B=A.querySelector("."+d);B&&L.push(B.tagName.toLowerCase());var U=E(A),X=c[U].allowedTags;se.querySelectorAll('[aria-pressed="true"]').forEach((function(z){return z.setAttribute("aria-pressed","false")})),se.querySelectorAll(".wysi-listbox > div > button:first-of-type").forEach((function(z){return R(z)})),L.forEach((function(z,ee){switch(z){case"p":case"h1":case"h2":case"h3":case"h4":case"li":var ne=se.querySelector('[data-action="format"][data-option="'+z+'"]'),Ce=M[ee].style.textAlign||M[ee].getAttribute("align");if(ne&&R(ne),Ce){var Fe="align"+Ce.charAt(0).toUpperCase()+Ce.slice(1),Ue=se.querySelector('[data-action="'+Fe+'"]');Ue&&(Ue.parentNode.getAttribute("role")==="listbox"?R(Ue):Ue.setAttribute("aria-pressed","true"))}break;default:var ye=X[z],We=ye?ye.toolName:void 0;We&&se.querySelector('[data-action="'+We+'"]').setAttribute("aria-pressed","true")}}))}}}v(t,"click",(function(I){me||re()})),v(t,"mousedown",".wysi-popover, .wysi-popover *",(function(I){me=!0})),v(t,"mouseup",(function(I){setTimeout((function(){me=!1}))})),v(t,"mousedown",".wysi-editor, .wysi-editor *",(function(I){var F=t.querySelector("."+d);F&&F!==I.target&&F.classList.remove(d)})),v(t,"mousedown",".wysi-editor img",(function(I){var F=I.target,K=t.createRange();F.classList.add(d),K.selectNode(F),G(K)})),v(t,"click",".wysi-toolbar > button",(function(I){var F=I.target,K=F.dataset.action,j=_(F).editor,Z=t.getSelection();Z&&j.contains(Z.anchorNode)&&H(K,j)})),v(t,"selectionchange",Ie),v(t,"input",".wysi-editor",Ie),N((function(){var I=S('<svg id="wysi-svg-icons" xmlns="http://www.w3.org/2000/svg"><defs><symbol id="wysi-bold" viewBox="0 0 24 24"><path d="M16.5,9.5A3.5,3.5,0,0,0,13,6H8.5a1,1,0,0,0-1,1V17a1,1,0,0,0,1,1H13a3.49,3.49,0,0,0,2.44-6A3.5,3.5,0,0,0,16.5,9.5ZM13,16H9.5V13H13a1.5,1.5,0,0,1,0,3Zm0-5H9.5V8H13a1.5,1.5,0,0,1,0,3Z"></path></symbol><symbol id="wysi-italic" viewBox="0 0 24 24"><path d="M17,6H11a1,1,0,0,0,0,2h1.52l-3.2,8H7a1,1,0,0,0,0,2h6a1,1,0,0,0,0-2H11.48l3.2-8H17a1,1,0,0,0,0-2Z"></path></symbol><symbol id="wysi-underline" viewBox="0 0 24 24"><path d="M12,15.5a5,5,0,0,0,5-5v-5a1,1,0,0,0-2,0v5a3,3,0,0,1-6,0v-5a1,1,0,0,0-2,0v5A5,5,0,0,0,12,15.5Zm5,2H7a1,1,0,0,0,0,2H17a1,1,0,0,0,0-2Z"></path></symbol><symbol id="wysi-strike" viewBox="0 0 24 24"><path d="M12 6C9.33 6 7.5 7.34 7.5 9.5c0 .58.12 1.07.35 1.5H13c-1.49-.34-3.49-.48-3.5-1.5 0-1.03 1.08-1.75 2.5-1.75s2.5.83 2.5 1.75h2C16.5 7.4 14.67 6 12 6zm-5.5 6c-.67 0-.67 1 0 1h4.35c.5.17 1.04.34 1.65.5.58.15 1.75.23 1.75 1s-.66 1.75-2.25 1.75-2.5-1.01-2.5-1.75h-2c0 1.64 1.33 3.5 4.5 3.5s4.5-2.08 4.5-3.5c0-.58-.05-1.07-.2-1.5h1.2c.67 0 .67-1 0-1z"></path></symbol><symbol id="wysi-alignLeft" viewBox="0 0 24 24"><path d="m4 8h16c1.33 0 1.33-2 0-2h-16c-1.33 0-1.33 2 0 2zm0 5h12c1.33 0 1.33-2 0-2h-12c-1.33 0-1.33 2 0 2zm16 3h-16c-1.33 0-1.33 2 0 2h16c1.34 0 1.29-2 0-2z"></path></symbol><symbol id="wysi-alignCenter" viewBox="0 0 24 24"><path d="m20 8h-16c-1.33 0-1.33-2 0-2h16c1.33 0 1.33 2 0 2zm-4 5h-8c-1.33 0-1.33-2 0-2h8c1.33 0 1.33 2 0 2zm-12 3h16c1.33 0 1.33 2 0 2h-16c-1.34 0-1.29-2 0-2z"></path></symbol><symbol id="wysi-alignRight" viewBox="0 0 24 24"><path d="m20 8h-16c-1.33 0-1.33-2 0-2h16c1.33 0 1.33 2 0 2zm0 5h-12c-1.33 0-1.33-2 0-2h12c1.33 0 1.33 2 0 2zm-16 3h16c1.33 0 1.33 2 0 2h-16c-1.34 0-1.29-2 0-2z"></path></symbol><symbol id="wysi-alignJustify" viewBox="0 0 24 24"><path d="m20 8h-16c-1.33 0-1.33-2 0-2h16c1.33 0 1.33 2 0 2zm0 5h-16c-1.33 0-1.33-2 0-2h16c1.33 0 1.33 2 0 2zm-16 3h16c1.33 0 1.33 2 0 2h-16c-1.34 0-1.29-2 0-2z"></path></symbol><symbol id="wysi-ul" viewBox="0 0 24 24"><path d="M3 6a1 1 0 0 0-1 1 1 1 0 0 0 1 1 1 1 0 0 0 1-1 1 1 0 0 0-1-1zm4 0a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2H7zm-4 5a1 1 0 0 0-1 1 1 1 0 0 0 1 1 1 1 0 0 0 1-1 1 1 0 0 0-1-1zm4 0a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2H7zm-4 5a1 1 0 0 0-1 1 1 1 0 0 0 1 1 1 1 0 0 0 1-1 1 1 0 0 0-1-1zm4 0a1 1 0 0 0 0 2h14a1 1 0 0 0 0-2H7z"></path></symbol><symbol id="wysi-ol" viewBox="0 0 24 24"><path d="M4 5c-.25 0-.5.17-.5.5v3c0 .67 1 .67 1 0v-3c0-.33-.25-.5-.5-.5zm4.5 1c-1.33 0-1.33 2 0 2h12c1.33 0 1.33-2 0-2zm-6 5.5h.75c0-.43.34-.75.75-.75.4 0 .75.28.75.75L2.5 13.25V14h3v-.75H3.75L5.5 12v-.5c0-.9-.73-1.49-1.5-1.5-.77 0-1.5.59-1.5 1.5zm6-.5c-1.33 0-1.33 2 0 2h12c1.33 0 1.33-2 0-2zM4 15c-.83 0-1.5.63-1.5 1.25h.75c0-.28.34-.5.75-.5s.75.22.75.5-.34.5-.75.5v.5c.41 0 .75.22.75.5s-.34.5-.75.5-.75-.22-.75-.5H2.5c0 .62.67 1.25 1.5 1.25s1.5-.5 1.5-1.12c0-.34-.2-.66-.56-.88.35-.2.56-.53.56-.87 0-.62-.67-1.12-1.5-1.12zm4.5 1c-1.33 0-1.33 2 0 2h12c1.33 0 1.33-2 0-2z"></path></symbol><symbol id="wysi-indent" viewBox="0 0 24 24"><path d="m20 8h-15.9c-1.33 0-1.33-2 0-2h15.9c1.33 0 1.33 2 0 2zm2.86e-4 5h-9.08c-1.33 0-1.33-2 0-2h9.08c1.33 0 1.33 2 0 2zm-16.7-3.31c0.356-0.423 0.988-0.477 1.41-0.12l2 1.66c0.483 0.4 0.483 1.14 0 1.54l-2 1.66c-0.179 0.153-0.405 0.238-0.64 0.24-0.297 4.83e-4 -0.58-0.131-0.77-0.36-0.354-0.425-0.296-1.06 0.13-1.41l1.08-0.9-1.08-0.9c-0.426-0.353-0.484-0.985-0.13-1.41zm0.77 6.31h15.9c1.33 0 1.33 2 0 2h-15.9c-1.33 0-1.33-2 0-2z"></path></symbol><symbol id="wysi-outdent" viewBox="0 0 24 24"><path d="m4.1 6c-1.33 0-1.33 2 0 2h15.9c1.33 0 1.33-2 0-2h-15.9zm1.96 3.33c-0.224 0.00238-0.448 0.0803-0.633 0.236l-2 1.66c-0.483 0.4-0.483 1.14 0 1.54l2 1.66c0.179 0.153 0.404 0.238 0.639 0.24 0.297 4.83e-4 0.581-0.131 0.771-0.359 0.354-0.425 0.295-1.06-0.131-1.41l-1.08-0.9 1.08-0.9c0.426-0.353 0.485-0.985 0.131-1.41-0.2-0.238-0.489-0.359-0.777-0.355zm4.88 1.67c-1.33 0-1.33 2 0 2h9.08c1.33 0 1.33-2 0-2h-9.08zm-6.87 5c-1.33 0-1.33 2 0 2h15.9c1.33 0 1.33-2 0-2h-15.9z"></path></symbol><symbol id="wysi-link" viewBox="0 0 24 24"><path d="M8,12a1,1,0,0,0,1,1h6a1,1,0,0,0,0-2H9A1,1,0,0,0,8,12Zm2,3H7A3,3,0,0,1,7,9h3a1,1,0,0,0,0-2H7A5,5,0,0,0,7,17h3a1,1,0,0,0,0-2Zm7-8H14a1,1,0,0,0,0,2h3a3,3,0,0,1,0,6H14a1,1,0,0,0,0,2h3A5,5,0,0,0,17,7Z"></path></symbol><symbol id="wysi-image" viewBox="0 0 24 24"><path d="M6 5a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3h12a3 3 0 0 0 3-3V8a3 3 0 0 0-3-3H6zm0 2h12a1 1 0 0 1 1 1v5.73l-.88-.88a3.06 3.06 0 0 0-4.24 0l-.88.88-2.88-2.88A3.06 3.06 0 0 0 8 10a3.06 3.06 0 0 0-2.12.85l-.88.88V8a1 1 0 0 1 1-1zm1.85 4.98a1 1 0 0 1 .85.27L13.45 17H6a1 1 0 0 1-.98-.92H5v-1.53l2.3-2.3a1 1 0 0 1 .55-.26zm8 2a1 1 0 0 1 .85.27l2.17 2.16c-.19.33-.55.59-.86.59h-1.72l-1.86-1.87.88-.88a1 1 0 0 1 .54-.28z"></path></symbol><symbol id="wysi-quote" viewBox="0 0 24 24"><path d="m9 6c-2.2 0-4 1.96-4 4.36v6c0 0.903 0.672 1.64 1.5 1.64h3c0.828 0 1.5-0.733 1.5-1.64v-3.27c0-0.903-0.672-1.64-1.5-1.64h-1.75c-0.414 0-0.75-0.367-0.75-0.818v-0.273c0-1.2 0.899-2.18 2-2.18h0.5c0.274 0 0.5-0.246 0.5-0.545v-1.09c0-0.298-0.226-0.545-0.5-0.545zm8 0c-2.2 0-4 1.96-4 4.36v6c0 0.903 0.672 1.64 1.5 1.64h3c0.828 0 1.5-0.733 1.5-1.64v-3.27c0-0.903-0.672-1.64-1.5-1.64h-1.75c-0.414 0-0.75-0.367-0.75-0.818v-0.273c0-1.2 0.899-2.18 2-2.18h0.5c0.274 0 0.5-0.246 0.5-0.545v-1.09c0-0.298-0.226-0.545-0.5-0.545z"></path></symbol><symbol id="wysi-hr" viewBox="0 0 24 24"><path d="m20 11h-16c-1.33 0-1.33 2 0 2 0 0 16-0.018 16 0 1.33 0 1.33-2 0-2z"></path></symbol><symbol id="wysi-removeFormat" viewBox="0 0 24 24"><path d="M7 6C5.67 6 5.67 8 7 8h3l-2 7c0 .02 2 0 2 0l2-7h3c1.33 0 1.33-2 0-2H7zm7.06 7c-.79-.04-1.49.98-.75 1.72l.78.78-.78.79c-.94.93.47 2.35 1.4 1.4l.79-.78.78.79c.94.93 2.35-.47 1.41-1.41l-.78-.79.78-.78c.94-.94-.47-2.35-1.4-1.41l-.8.79-.77-.79a.99.99 0 0 0-.66-.3zM7 16c-1.33 0-1.33 2 0 2 .02-.02 4 0 4 0 1.33 0 1.33-2 0-2H7z"></path></symbol><symbol id="wysi-delete" viewBox="0 0 24 24"><path d="M10,18a1,1,0,0,0,1-1V11a1,1,0,0,0-2,0v6A1,1,0,0,0,10,18ZM20,6H16V5a3,3,0,0,0-3-3H11A3,3,0,0,0,8,5V6H4A1,1,0,0,0,4,8H5V19a3,3,0,0,0,3,3h8a3,3,0,0,0,3-3V8h1a1,1,0,0,0,0-2ZM10,5a1,1,0,0,1,1-1h2a1,1,0,0,1,1,1V6H10Zm7,14a1,1,0,0,1-1,1H8a1,1,0,0,1-1-1V8H17Zm-3-1a1,1,0,0,0,1-1V11a1,1,0,0,0-2,0v6A1,1,0,0,0,14,18Z"></path></symbol></defs></svg>');t.body.appendChild(I)}));var xe="style",be="align";function ae(I,F,K){var j=w("div"),Z=S(I);return Oe(Z,F),(function(se){var A=Array.from(se.childNodes);if(!(!A||!A.length)){var M=!1;A.forEach((function(L){if(L.nodeType!==3&&f.includes(L.tagName))M=!1;else if(M){var B=L.previousElementSibling;B&&B.appendChild(L)}else ue(L,"p"),M=!0}))}})(Z),et(Z,F),j.appendChild(Z),j.innerHTML}function ue(I,F,K){var j=w(F),Z=I.parentNode,se=I.attributes;if(j.innerHTML=I.innerHTML||I.textContent||I.outerHTML,K&&se)for(var A=0;A<se.length;A++)j.setAttribute(se[A].name,se[A].value);Z.replaceChild(j,I)}function ve(I,F){var K=I.getAttribute(xe);if(K){var j=K.split(";").map((function(Z){var se=Z.split(":");return{name:se[0].trim(),value:se[1]}})).filter((function(Z){return F.includes(Z.name)})).filter((function(Z){return Z.name!=="text-align"||Z.value.trim()!=="left"})).map((function(Z){return Z.name+": "+Z.value.trim()+";"})).join("");j!==""?I.setAttribute(xe,j):I.removeAttribute(xe)}}function Oe(I,F){var K=Array.from(I.childNodes);K&&K.length&&K.forEach((function(j){if(j.nodeType===1){Oe(j,F);var Z=j.tagName.toLowerCase(),se=F[Z],A=Array.from(j.attributes),M=j.getAttribute(be);if(se){for(var L=se.attributes||[],B=se.styles||[],U=0;U<A.length;U++){var X=A[U].name;L.includes(A[U].name)||(X===be&&M!=="left"&&(j.style.textAlign=M),X===xe&&B.length?ve(j,B):j.removeAttribute(A[U].name))}se.alias&&ue(j,se.alias,!0)}else if(Z==="style")I.removeChild(j);else{if(M!==null)if(j.parentNode&&j.parentNode.tagName==="LI")j.parentNode.style.textAlign=M;else for(var z,ee=o(j.childNodes);!(z=ee()).done;)z.value.style.textAlign=M;j.replaceWith.apply(j,j.childNodes)}}else j.nodeType===8&&I.removeChild(j)}))}function et(I,F){var K=Array.from(I.childNodes);K&&K.length&&K.forEach((function(j){if(j.nodeType===1){et(j,F);var Z=j.tagName.toLowerCase(),se=F[Z];se&&!se.isEmpty&&j.innerHTML.replace(/^\s+|\s+$/g,"").trim()===""&&I.removeChild(j)}}))}var at=0;function it(I){var F=e.wysiGlobalTranslations||{};(function(A){a=A})(Object.assign({},F,I.translations||{}));var K=I.tools||s.tools,j=D(I.el||s.el),Z=ce(K),se=(function(A){var M=x(s.allowedTags);return A.forEach((function(L){var B=x(l[L]);if(B&&B.tags){var U=!!B.isEmpty,X=B.extraTags||[],z=B.alias||[],ee=z.length?B.tags[0]:void 0,ne=[].concat(B.tags,X,z),Ce=B.attributes||[],Fe=B.styles||[];ne.forEach((function(Ue){M[Ue]={attributes:Ce,styles:Fe,alias:ee,isEmpty:U},X.includes(Ue)||(M[Ue].toolName=L)}))}})),M})(K);(I.customTags||[]).forEach((function(A){if(A.tags){var M=A.attributes||[],L=A.styles||[],B=!!A.isEmpty;A.tags.forEach((function(U){se[U]={attributes:M,styles:L,isEmpty:B}}))}})),j.forEach((function(A){var M=A.previousElementSibling;if(M&&y(M,"wysi-wrapper"))tt(M,I);else{var L=at++;c[L]=I,c[L].allowedTags=x(se);var B=w("div",{class:"wysi-wrapper"}),U=w("div",{class:"wysi-editor",contenteditable:!0,role:"textbox","aria-multiline":!0,"aria-label":T(A),"data-wid":L,_innerHTML:ae(A.value,se)});B.appendChild(Z.cloneNode(!0)),B.appendChild(U),A.before(B),tt(B,I)}}))}function tt(I,F){if(typeof F=="object")for(var K in F)switch(K){case"darkMode":case"autoGrow":case"autoHide":I.classList.toggle("wysi-"+K.toLowerCase(),!!F[K]);break;case"height":var j=F.height;if(!isNaN(j)){var Z=I.lastChild;Z.style.minHeight=j+"px",Z.style.maxHeight=j+"px"}}}function $e(I,F,K,j,Z){var se=c[K],A=ae(j,se.allowedTags),M=se.onChange;Z===!0&&(F.innerHTML=A),I.value=A,b(I,"change"),M&&M(A)}function yt(I){for(var F,K=o(k(I));!(F=K()).done;){var j=F.value,Z=j.instanceId,se=j.wrapper;delete c[Z],se.remove()}}function Xt(I,F){for(var K,j=o(k(I));!(K=j()).done;){var Z=K.value;$e(Z.textarea,Z.editor,Z.instanceId,F,!0)}}function Wt(I){var F=_(I.target),K=F.editor,j=F.nodes,Z=I.clipboardData;if(K&&Z.types.includes("text/html")){var se=Z.getData("text/html"),A=E(K),M=ae(se,c[A].allowedTags),L=j.filter((function(U){return u.includes(U.tagName)})).length>0;if(L&&!h){var B='<h1 class="'+p+'"><br></h1><p class="'+p+'"><br></p>';M=B+M+B}g("insertHTML",M),L&&!h&&(K.querySelectorAll("."+p).forEach((function(U){U.remove()})),K.querySelectorAll(u.join()).forEach((function(U){var X=U.firstElementChild;X&&f.includes(X.tagName)&&U.replaceWith.apply(U,U.childNodes)}))),I.preventDefault()}}e.Wysi=(function(){var I={destroy:yt,setContent:Xt};function F(Z){N((function(){it(Z||{})}))}var K=function(Z){F[Z]=function(){for(var se=arguments.length,A=new Array(se),M=0;M<se;M++)A[M]=arguments[M];N(I[Z],A)}};for(var j in I)K(j);return F})(),N((function(){g("styleWithCSS",!1),g("enableObjectResizing",!1),g("enableInlineTableEditing",!1),g("defaultParagraphSeparator","p"),v(t,"input",".wysi-editor",(function(I){var F=I.target;$e(F.parentNode.nextElementSibling,F,E(F),F.innerHTML)})),v(t,"paste",Wt)}))})(window,document);const Ox={type:"shortText",structure:"field",typeCategory:"Text",label:"Short Text",description:"Single line text input",icon:"📝",category:"field",subCategory:"textInput",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!0,showSuffix:!0},configSection:{title:"Text Input Settings",icon:"📝"},fields:[{key:"showCharacterCount",label:"Show Character Count",type:"checkbox",section:"config",description:"Display remaining character count"},{key:"autoComplete",label:"Autocomplete",type:"select",section:"config",description:"Browser autofill hint",options:[{value:"off",label:"Off"},{value:"on",label:"On"},{value:"name",label:"Full Name"},{value:"given-name",label:"First Name"},{value:"family-name",label:"Last Name"},{value:"email",label:"Email"},{value:"tel",label:"Phone"},{value:"organization",label:"Organization"},{value:"street-address",label:"Street Address"},{value:"address-level2",label:"City"},{value:"address-level1",label:"State / Province"},{value:"postal-code",label:"Postal / Zip Code"},{value:"country",label:"Country"},{value:"username",label:"Username"},{value:"organization-title",label:"Job Title"}]}]},getDefaultValues:()=>({properties:{label:"Short Text",placeholder:"Enter text..."},layout:{labelPosition:"top",size:"full"},validation:{maxLength:255}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,children:i.jsx("input",{type:"text",placeholder:o,disabled:!0,className:Ot()})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,value:s,onChange:l,errors:c,isDisabled:d}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,errors:c,children:i.jsx("input",{type:"text",placeholder:o,value:s??"",onChange:p=>l==null?void 0:l(p.target.value),disabled:d,className:qt({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})})})}},Ix={type:"longText",structure:"field",typeCategory:"Text",label:"Long Text",description:"Multi-line text area",icon:"📄",category:"field",subCategory:"textInput",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Text Area Settings",icon:"📄"},fields:[{key:"rows",label:"Visible Rows",type:"number",section:"config",min:1,max:20,placeholder:"3",description:"Number of visible text lines"},{key:"autoResize",label:"Auto-resize",type:"checkbox",section:"config",description:"Automatically adjust height to content"},{key:"showCharacterCount",label:"Show Character Count",type:"checkbox",section:"config",description:"Display remaining character count"}]},getDefaultValues:()=>({properties:{label:"Long Text",placeholder:"Enter text..."},layout:{labelPosition:"top",size:"full"},config:{rows:3,autoResize:!1},validation:{maxLength:5e3}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,config:s}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,children:i.jsx("textarea",{placeholder:o,disabled:!0,rows:(s==null?void 0:s.rows)||3,className:`${Ot()} resize-none`})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,value:s,onChange:l,errors:c,isDisabled:d,config:p}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,errors:c,children:i.jsx("textarea",{placeholder:o,value:s??"",onChange:u=>l==null?void 0:l(u.target.value),disabled:d,rows:(p==null?void 0:p.rows)||3,className:`${qt({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})} resize-none`})})}},Lx={type:"multiLineInput",structure:"field",typeCategory:"Text",label:"Multi-Line Input",description:"Auto-expanding text area",icon:"📝",category:"field",subCategory:"textInput",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Auto-Resize Settings",icon:"📑"},fields:[{key:"minRows",label:"Min Rows",type:"number",section:"config",min:1,max:20,placeholder:"2",colSpan:1},{key:"maxRows",label:"Max Rows",type:"number",section:"config",min:1,max:50,placeholder:"10",colSpan:1},{key:"autoResize",label:"Auto-resize",type:"checkbox",section:"config",description:"Grow textarea to fit content"},{key:"showCharacterCount",label:"Show Character Count",type:"checkbox",section:"config",description:"Display remaining character count"}]},getDefaultValues:()=>({properties:{label:"Multi-Line Input",placeholder:"Enter text..."},layout:{labelPosition:"top",size:"full"},config:{minRows:2,maxRows:10,autoResize:!0},validation:{maxLength:5e3}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,config:s}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,children:i.jsx("textarea",{placeholder:o,disabled:!0,rows:(s==null?void 0:s.minRows)||2,className:`${Ot()} resize-none`})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,value:s,onChange:l,errors:c,isDisabled:d,config:p}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,errors:c,children:i.jsx("textarea",{placeholder:o,value:s??"",onChange:u=>l==null?void 0:l(u.target.value),disabled:d,rows:(p==null?void 0:p.minRows)||2,className:`${qt({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})} resize-none`})})}},yf={basic:["bold","italic","underline"],standard:["bold","italic","underline","strike","|","ul","ol","|","link"],advanced:["format","|","bold","italic","underline","strike","|","ul","ol","|","alignLeft","alignCenter","alignRight","|","link","quote","|","removeFormat"],full:["format","|","bold","italic","underline","strike","|","alignLeft","alignCenter","alignRight","alignJustify","|","ul","ol","|","indent","outdent","|","link","image","hr","quote","|","removeFormat"]},Fx=new Set(["format","quote","bold","italic","underline","strike","alignLeft","alignCenter","alignRight","alignJustify","ul","ol","indent","outdent","link","image","hr","removeFormat","unlink"]);function Vx(e){return e.filter((t,r,o)=>t!=="|"?!0:r>0&&r<o.length-1&&o[r-1]!=="|"&&o[r+1]!=="|")}function Gx(e){const t=e!=null&&e.toolbarPreset?yf[e.toolbarPreset]:void 0;let r;return t?r=[...t]:Array.isArray(e==null?void 0:e.toolbar)&&e.toolbar.length>0?r=e.toolbar.filter(o=>Fx.has(o)):r=[...yf.standard],(e==null?void 0:e.allowImages)===!1&&(r=r.filter(o=>o!=="image")),(e==null?void 0:e.allowLinks)===!1&&(r=r.filter(o=>o!=="link")),Vx(r)}const zx=({value:e,onChange:t,isDisabled:r,height:o,config:n})=>{const a=P.useRef(null),s=P.useRef(null),l=P.useRef(t);l.current=t;const c=P.useRef(e),d=P.useMemo(()=>Gx(n),[n]);return P.useEffect(()=>{if(r)return;const p=a.current;if(p)return window.Wysi({el:p,height:o,tools:d,onChange:u=>{var f;c.current=u,(f=l.current)==null||f.call(l,u)}}),s.current=p.previousElementSibling,()=>{s.current&&(s.current.remove(),s.current=null),window.Wysi.destroy(p)}},[r,o,d]),P.useEffect(()=>{r||!a.current||e!==c.current&&(c.current=e,window.Wysi.setContent(a.current,e??""))},[e,r]),r?i.jsx("div",{className:m("p-3 min-h-[120px] text-sm"),style:{height:o},dangerouslySetInnerHTML:{__html:e??""}}):i.jsx("textarea",{ref:a,value:e??"",onChange:()=>{},tabIndex:-1,"aria-hidden":"true",className:m("hidden")})},Bx=[Ox,Ix,Lx,{type:"textEditor",structure:"field",typeCategory:"Text",label:"Rich Text Editor",description:"WYSIWYG text editor",icon:"✏️",category:"field",subCategory:"textInput",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!1},configSection:{title:"Editor Settings",icon:"✏️"},fields:[{key:"toolbarPreset",label:"Toolbar",type:"select",section:"config",description:"Choose which formatting options appear",options:[{value:"basic",label:"Basic (Bold, Italic, Underline)"},{value:"standard",label:"Standard (+ Links, Lists)"},{value:"advanced",label:"Advanced (+ Headings, Blockquote)"},{value:"full",label:"Full (All options)"}]},{key:"height",label:"Height (px)",type:"number",section:"config",min:100,max:800,placeholder:"200",description:"Editor area height in pixels"},{key:"allowImages",label:"Allow Images",type:"checkbox",section:"config",description:"Let users embed images in content"},{key:"allowLinks",label:"Allow Links",type:"checkbox",section:"config",description:"Let users insert hyperlinks"}]},getDefaultValues:()=>({properties:{label:"Rich Text",placeholder:"Start typing..."},layout:{labelPosition:"top",size:"full"},config:{toolbarPreset:"standard",toolbar:["bold","italic","underline","link"],height:200,allowImages:!1,allowLinks:!0},validation:{maxLength:1e4}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,config:s}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,children:i.jsxs("div",{className:m("border border-gray-300 rounded-md bg-gray-50 overflow-hidden"),children:[i.jsxs("div",{className:m("flex items-center gap-1 p-2 border-b border-gray-200 bg-gray-100"),children:[i.jsx("button",{disabled:!0,className:m("p-1.5 rounded hover:bg-gray-200 text-gray-600"),children:i.jsx("strong",{children:"B"})}),i.jsx("button",{disabled:!0,className:m("p-1.5 rounded hover:bg-gray-200 text-gray-600"),children:i.jsx("em",{children:"I"})}),i.jsx("button",{disabled:!0,className:m("p-1.5 rounded hover:bg-gray-200 text-gray-600"),children:i.jsx("u",{children:"U"})}),i.jsx("span",{className:m("w-px h-4 bg-gray-300 mx-1")}),i.jsx("button",{disabled:!0,className:m("p-1.5 rounded hover:bg-gray-200 text-gray-600 text-xs"),children:"🔗"})]}),i.jsx("div",{className:m("p-3 min-h-[120px] text-gray-400 text-sm"),style:{height:(s==null?void 0:s.height)||200},children:o||"Start typing..."})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e);return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsx("div",{className:`border rounded-md overflow-hidden ${((l==null?void 0:l.length)??0)>0?"border-red-500":"border-gray-300"}`,children:i.jsx(zx,{value:a,onChange:s,isDisabled:c,height:(d==null?void 0:d.height)||200,config:d})})})}}],Ux=[{type:"number",structure:"field",typeCategory:"Numeric",label:"Number",description:"Numeric input field",icon:"🔢",category:"field",subCategory:"numeric",dataType:"number",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!0,showSuffix:!0},configSection:{title:"Number Settings",icon:"🔢"},fields:[{key:"step",label:"Step",type:"number",section:"config",min:.01,placeholder:"1",description:"Increment/decrement amount",colSpan:1},{key:"decimals",label:"Decimals",type:"number",section:"config",min:0,max:10,placeholder:"0",description:"Decimal places to allow",colSpan:1},{key:"thousandsSeparator",label:"Thousands Separator",type:"checkbox",section:"config",description:"Format numbers with commas (e.g. 1,000)"},{key:"currencySymbol",label:"Currency Symbol",type:"text",section:"config",placeholder:"$, €, £, ¥…",description:"Leave empty for plain numbers"},{key:"numberFormat",label:"Display Format",type:"select",section:"config",options:[{value:"number",label:"Plain Number"},{value:"currency",label:"Currency"},{value:"percent",label:"Percentage"}]},{key:"showStepper",label:"Show Stepper Buttons",type:"checkbox",section:"config",description:"Display +/- spin buttons"}]},getDefaultValues:()=>({properties:{label:"Number",placeholder:"Enter number..."},layout:{labelPosition:"top",size:"full"},config:{step:1,decimals:0,thousandsSeparator:!1}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,prefix:s,suffix:l}=oe(e),c=i.jsx("input",{type:"number",placeholder:o,disabled:!0,className:`${Ot()} ${s?"":"rounded-l-md"} ${l?"":"rounded-r-md"}`});return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,children:s||l?i.jsx(Si,{prefix:s,suffix:l,children:c}):c})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,prefix:s,suffix:l,value:c,onChange:d,errors:p,isDisabled:u,config:f}=oe(e),h=g=>{const y=g.target.value===""?void 0:Number(g.target.value);d==null||d(y)},b=i.jsx("input",{type:"number",placeholder:o,value:c??"",onChange:h,disabled:u,step:(f==null?void 0:f.step)||1,className:`${qt({hasError:((p==null?void 0:p.length)??0)>0,disabled:u})} ${s?"rounded-l-none":""} ${l?"rounded-r-none":""}`});return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,errors:p,children:s||l?i.jsx(Si,{prefix:s,suffix:l,children:b}):b})}},{type:"slider",structure:"field",typeCategory:"Numeric",label:"Slider",description:"Range slider for numeric values",icon:"🎚️",category:"field",subCategory:"numeric",dataType:"number",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Slider Settings",icon:"🎚️"},fields:[{key:"min",label:"Min Value",type:"number",section:"config",placeholder:"0",colSpan:1},{key:"max",label:"Max Value",type:"number",section:"config",placeholder:"100",colSpan:1},{key:"step",label:"Step",type:"number",section:"config",min:1,placeholder:"1",description:"Size of each increment"},{key:"showValue",label:"Show Value Label",type:"checkbox",section:"config",description:"Display the current value beside the slider"},{key:"showMarks",label:"Show Tick Marks",type:"checkbox",section:"config",description:"Display scale marks along the track"},{key:"showTooltip",label:"Show Tooltip on Drag",type:"checkbox",section:"config",description:"Floating tooltip while dragging"},{key:"trackColor",label:"Track Color",type:"select",section:"config",description:"Visual theme of the slider track",options:[{value:"primary",label:"Primary (Blue)"},{value:"success",label:"Success (Green)"},{value:"warning",label:"Warning (Amber)"},{value:"danger",label:"Danger (Red)"},{value:"neutral",label:"Neutral (Gray)"}]}]},getDefaultValues:()=>({properties:{label:"Slider",description:"Drag to select a value"},layout:{labelPosition:"top",size:"full"},config:{min:0,max:100,step:1,showValue:!0,showMarks:!1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e),s=(a==null?void 0:a.min)??0,l=(a==null?void 0:a.max)??100;return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsxs("div",{className:m("flex items-center gap-3"),children:[i.jsx("span",{className:m("text-xs text-gray-500"),children:s}),i.jsx("input",{type:"range",min:s,max:l,disabled:!0,className:m("flex-1 h-2 bg-gray-200 rounded-lg appearance-none cursor-not-allowed")}),i.jsx("span",{className:m("text-xs text-gray-500"),children:l}),(a==null?void 0:a.showValue)&&i.jsx("span",{className:m("text-sm font-medium text-gray-600 min-w-[40px] text-center"),children:Math.round((s+l)/2)})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),p=(d==null?void 0:d.min)??0,u=(d==null?void 0:d.max)??100,f=(d==null?void 0:d.step)??1,h=a??p;return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsxs("div",{className:m("flex items-center gap-3"),children:[i.jsx("span",{className:m("text-xs text-gray-500"),children:p}),i.jsx("input",{type:"range",min:p,max:u,step:f,value:h,onChange:b=>s==null?void 0:s(Number(b.target.value)),disabled:c,className:m("flex-1 h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer disabled:cursor-not-allowed")}),i.jsx("span",{className:m("text-xs text-gray-500"),children:u}),(d==null?void 0:d.showValue)&&i.jsx("span",{className:m("text-sm font-medium text-gray-600 min-w-[40px] text-center"),children:h})]})})}},{type:"rangeSlider",structure:"field",typeCategory:"Numeric",label:"Range Slider",description:"Select a range of values",icon:"↔️",category:"field",subCategory:"numeric",dataType:"object",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Range Slider Settings",icon:"↔️"},fields:[{key:"min",label:"Range Min",type:"number",section:"config",placeholder:"0",colSpan:1},{key:"max",label:"Range Max",type:"number",section:"config",placeholder:"100",colSpan:1},{key:"step",label:"Step",type:"number",section:"config",min:1,placeholder:"1",description:"Size of each increment",colSpan:1},{key:"minRange",label:"Min Gap",type:"number",section:"config",min:0,placeholder:"10",description:"Minimum distance between handles",colSpan:1},{key:"showValue",label:"Show Value Labels",type:"checkbox",section:"config",description:"Display selected range below the slider"},{key:"showTooltip",label:"Show Tooltip on Drag",type:"checkbox",section:"config",description:"Floating tooltip while dragging handles"},{key:"showBarLabels",label:"Show Min/Max Labels",type:"checkbox",section:"config",description:"Show the min/max values at track edges"}]},getDefaultValues:()=>({properties:{label:"Range Slider",description:"Select a range"},layout:{labelPosition:"top",size:"full"},config:{min:0,max:100,step:1,showValue:!0,minRange:10}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e),s=(a==null?void 0:a.min)??0,l=(a==null?void 0:a.max)??100;return i.jsxs(ge,{label:t,description:r,required:o,labelPosition:n,children:[i.jsxs("div",{className:m("flex items-center gap-3"),children:[i.jsx("span",{className:m("text-xs text-gray-500"),children:s}),i.jsxs("div",{className:m("flex-1 relative h-2 bg-gray-200 rounded-lg"),children:[i.jsx("div",{className:m("absolute h-full bg-blue-400 rounded-lg left-[20%] right-[30%]")}),i.jsx("div",{className:m("absolute w-4 h-4 bg-white border-2 border-blue-500 rounded-full -top-1 left-[20%] -ml-2")}),i.jsx("div",{className:m("absolute w-4 h-4 bg-white border-2 border-blue-500 rounded-full -top-1 right-[30%] -mr-2")})]}),i.jsx("span",{className:m("text-xs text-gray-500"),children:l})]}),(a==null?void 0:a.showValue)&&i.jsxs("div",{className:m("flex justify-between text-sm text-gray-600 mt-2"),children:[i.jsxs("span",{children:["Min: ",Math.round(s+(l-s)*.2)]}),i.jsxs("span",{children:["Max: ",Math.round(s+(l-s)*.7)]})]})]})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),p=(d==null?void 0:d.min)??0,u=(d==null?void 0:d.max)??100,f=(d==null?void 0:d.step)??1,h=(a==null?void 0:a.min)??Math.round(p+(u-p)*.2),b=(a==null?void 0:a.max)??Math.round(p+(u-p)*.8),g=x=>{const w=Number(x.target.value),N=Math.min(w,b-((d==null?void 0:d.minRange)??0));s==null||s({min:N,max:b})},y=x=>{const w=Number(x.target.value),N=Math.max(w,h+((d==null?void 0:d.minRange)??0));s==null||s({min:h,max:N})},v=(h-p)/(u-p)*100,S=100-(b-p)/(u-p)*100;return i.jsxs(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:[i.jsxs("div",{className:m("flex items-center gap-3"),children:[i.jsx("span",{className:m("text-xs text-gray-500"),children:p}),i.jsxs("div",{className:m("flex-1 relative h-2 bg-gray-200 rounded-lg"),children:[i.jsx("div",{className:m("absolute h-full bg-blue-400 rounded-lg"),style:{left:`${v}%`,right:`${S}%`}}),i.jsx("input",{type:"range",min:p,max:u,step:f,value:h,onChange:g,disabled:c,className:m("absolute w-full h-full appearance-none bg-transparent pointer-events-auto cursor-pointer disabled:cursor-not-allowed"),style:{zIndex:h>u-10?5:3}}),i.jsx("input",{type:"range",min:p,max:u,step:f,value:b,onChange:y,disabled:c,className:m("absolute w-full h-full appearance-none bg-transparent pointer-events-auto cursor-pointer disabled:cursor-not-allowed"),style:{zIndex:4}})]}),i.jsx("span",{className:m("text-xs text-gray-500"),children:u})]}),(d==null?void 0:d.showValue)&&i.jsxs("div",{className:m("flex justify-between text-sm text-gray-600 mt-2"),children:[i.jsxs("span",{children:["Min: ",h]}),i.jsxs("span",{children:["Max: ",b]})]})]})}}],Wx=[{type:"singleChoice",structure:"field",typeCategory:"Selection",label:"Single Choice",description:"Radio button selection",icon:"⭕",category:"field",subCategory:"selection",dataType:"string",supportsValidation:!0,supportsOptions:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Choice Settings",icon:"⭕"},fields:[{key:"layoutDirection",label:"Layout",type:"select",section:"config",description:"How options are arranged",options:[{value:"vertical",label:"Vertical (stacked)"},{value:"horizontal",label:"Horizontal (inline)"},{value:"grid",label:"Grid (2 columns)"}]},{key:"allowOther",label:'Allow "Other"',type:"checkbox",section:"config",description:'Add a free-text "Other" option at the end'},{key:"randomizeOptions",label:"Randomize Order",type:"checkbox",section:"config",description:"Shuffle options for each respondent (surveys)"},{key:"showAsButtonGroup",label:"Show as Button Group",type:"checkbox",section:"config",description:"Display options as selectable buttons instead of radios"},{key:"otherLabel",label:'"Other" Label',type:"text",section:"config",placeholder:"Other (please specify)",showWhen:{field:"allowOther",value:!0}}]},getDefaultValues:()=>({properties:{label:"Single Choice",description:"Select one option"},layout:{labelPosition:"top",size:"full"},config:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],allowOther:!1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e),s=(a==null?void 0:a.options)||[];return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsxs("div",{className:m("space-y-2"),children:[s.map((l,c)=>i.jsxs("label",{className:m("flex items-center gap-2"),children:[i.jsx("input",{type:"radio",disabled:!0,className:m("text-blue-600")}),i.jsx("span",{className:m("text-sm text-gray-700"),children:l.label})]},c)),(a==null?void 0:a.allowOther)&&i.jsxs("label",{className:m("flex items-center gap-2"),children:[i.jsx("input",{type:"radio",disabled:!0,className:m("text-blue-600")}),i.jsx("span",{className:m("text-sm text-gray-700"),children:"Other"})]})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),p=(d==null?void 0:d.options)||[];return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsxs("div",{className:m("space-y-2"),children:[p.map((u,f)=>i.jsxs("label",{className:m("flex items-center gap-2 cursor-pointer"),children:[i.jsx("input",{type:"radio",checked:a===u.value,onChange:()=>s==null?void 0:s(u.value),disabled:c,className:m("text-blue-600")}),i.jsx("span",{className:m("text-sm text-gray-700"),children:u.label})]},f)),(d==null?void 0:d.allowOther)&&i.jsxs("label",{className:m("flex items-center gap-2 cursor-pointer"),children:[i.jsx("input",{type:"radio",checked:a==="__other__",onChange:()=>s==null?void 0:s("__other__"),disabled:c,className:m("text-blue-600")}),i.jsx("span",{className:m("text-sm text-gray-700"),children:"Other"})]})]})})}},{type:"multipleChoice",structure:"field",typeCategory:"Selection",label:"Multiple Choice",description:"Checkbox multi-select",icon:"☑️",category:"field",subCategory:"selection",dataType:"array",supportsValidation:!0,supportsOptions:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Choice Settings",icon:"☑️"},fields:[{key:"layoutDirection",label:"Layout",type:"select",section:"config",description:"How options are arranged",options:[{value:"vertical",label:"Vertical (stacked)"},{value:"horizontal",label:"Horizontal (inline)"},{value:"grid",label:"Grid (2 columns)"}]},{key:"allowOther",label:'Allow "Other"',type:"checkbox",section:"config",description:'Add a free-text "Other" option at the end'},{key:"randomizeOptions",label:"Randomize Order",type:"checkbox",section:"config",description:"Shuffle options for each respondent (surveys)"},{key:"showSelectAll",label:'Show "Select All"',type:"checkbox",section:"config",description:"Add a shortcut to check all options at once"},{key:"otherLabel",label:'"Other" Label',type:"text",section:"config",placeholder:"Other (please specify)",showWhen:{field:"allowOther",value:!0}}]},getDefaultValues:()=>({properties:{label:"Multiple Choice",description:"Select all that apply"},layout:{labelPosition:"top",size:"full"},config:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],allowOther:!1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e),s=(a==null?void 0:a.options)||[];return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsxs("div",{className:m("space-y-2"),children:[s.map((l,c)=>i.jsxs("label",{className:m("flex items-center gap-2"),children:[i.jsx("input",{type:"checkbox",disabled:!0,className:m("text-blue-600 rounded")}),i.jsx("span",{className:m("text-sm text-gray-700"),children:l.label})]},c)),(a==null?void 0:a.allowOther)&&i.jsxs("label",{className:m("flex items-center gap-2"),children:[i.jsx("input",{type:"checkbox",disabled:!0,className:m("text-blue-600 rounded")}),i.jsx("span",{className:m("text-sm text-gray-700"),children:"Other"})]})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),p=(d==null?void 0:d.options)||[],u=Array.isArray(a)?a:[],f=h=>{const b=u.includes(h)?u.filter(g=>g!==h):[...u,h];s==null||s(b)};return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsxs("div",{className:m("space-y-2"),children:[p.map((h,b)=>i.jsxs("label",{className:m("flex items-center gap-2 cursor-pointer"),children:[i.jsx("input",{type:"checkbox",checked:u.includes(h.value),onChange:()=>f(h.value),disabled:c,className:m("text-blue-600 rounded")}),i.jsx("span",{className:m("text-sm text-gray-700"),children:h.label})]},b)),(d==null?void 0:d.allowOther)&&i.jsxs("label",{className:m("flex items-center gap-2 cursor-pointer"),children:[i.jsx("input",{type:"checkbox",checked:u.includes("__other__"),onChange:()=>f("__other__"),disabled:c,className:m("text-blue-600 rounded")}),i.jsx("span",{className:m("text-sm text-gray-700"),children:"Other"})]})]})})}},{type:"dropdown",structure:"field",typeCategory:"Selection",label:"Dropdown",description:"Select from a dropdown list",icon:"📋",category:"field",subCategory:"selection",dataType:"string",supportsValidation:!0,supportsOptions:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Dropdown Settings",icon:"📋"},fields:[{key:"allowOther",label:'Allow "Other"',type:"checkbox",section:"config",description:"Let users type a custom value"},{key:"searchable",label:"Searchable",type:"checkbox",section:"config",description:"Enable type-to-search filtering"},{key:"clearable",label:"Clearable",type:"checkbox",section:"config",description:"Show a clear button to deselect"},{key:"otherLabel",label:'"Other" Label',type:"text",section:"config",placeholder:"Other (please specify)",showWhen:{field:"allowOther",value:!0}}]},getDefaultValues:()=>({properties:{label:"Dropdown",placeholder:"Select an option..."},layout:{labelPosition:"top",size:"full"},config:{options:[{label:"Option 1",value:"option1"},{label:"Option 2",value:"option2"},{label:"Option 3",value:"option3"}],allowOther:!1}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,config:s}=oe(e),l=(s==null?void 0:s.options)||[];return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,children:i.jsxs("select",{disabled:!0,className:Ot(),children:[i.jsx("option",{children:o||"Select an option..."}),l.map((c,d)=>i.jsx("option",{value:c.value,children:c.label},d))]})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,value:s,onChange:l,errors:c,isDisabled:d,config:p}=oe(e),u=(p==null?void 0:p.options)||[];return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,errors:c,children:i.jsxs("select",{value:s??"",onChange:f=>l==null?void 0:l(f.target.value||void 0),disabled:d,className:qt({hasError:((c==null?void 0:c.length)??0)>0,disabled:d}),children:[i.jsx("option",{value:"",children:o||"Select an option..."}),u.map((f,h)=>i.jsx("option",{value:f.value,children:f.label},h))]})})}},{type:"tags",structure:"field",typeCategory:"Selection",label:"Tags",description:"Tag-style multi-select",icon:"🏷️",category:"field",subCategory:"selection",dataType:"array",supportsValidation:!0,supportsOptions:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Tags Settings",icon:"🏷️"},fields:[{key:"maxTags",label:"Max Tags",type:"number",section:"config",min:1,placeholder:"10",description:"Maximum number of tags allowed"},{key:"allowCustomTags",label:"Allow Custom Tags",type:"checkbox",section:"config",description:"Let users type their own tags"},{key:"showSuggestions",label:"Show Suggestions",type:"checkbox",section:"config",description:"Display suggestion dropdown while typing"},{key:"tagColor",label:"Tag Color",type:"select",section:"config",description:"Color theme for selected tags",options:[{value:"primary",label:"Primary (Blue)"},{value:"neutral",label:"Neutral (Gray)"},{value:"success",label:"Success (Green)"},{value:"warning",label:"Warning (Amber)"},{value:"danger",label:"Danger (Red)"}]}]},getDefaultValues:()=>({properties:{label:"Tags",placeholder:"Add tag...",description:"Type and press Enter to add tags"},layout:{labelPosition:"top",size:"full"},config:{options:[{label:"Tag 1",value:"tag1"},{label:"Tag 2",value:"tag2"},{label:"Tag 3",value:"tag3"}],maxTags:10,allowCustomTags:!0}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,children:i.jsxs("div",{className:m("flex flex-wrap gap-2 p-2 border border-gray-300 rounded-md bg-gray-50 min-h-[42px]"),children:[i.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-800 text-sm rounded"),children:["Tag 1",i.jsx("button",{disabled:!0,className:m("text-blue-600 hover:text-blue-800"),children:"×"})]}),i.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-800 text-sm rounded"),children:["Tag 2",i.jsx("button",{disabled:!0,className:m("text-blue-600 hover:text-blue-800"),children:"×"})]}),i.jsx("input",{type:"text",placeholder:o||"Add tag...",disabled:!0,className:m("flex-1 min-w-[100px] border-none bg-transparent text-sm focus:outline-none")})]})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,value:s,onChange:l,errors:c,isDisabled:d,config:p}=oe(e),u=Array.isArray(s)?s:[],[f,h]=P.useState(""),b=y=>{y.key==="Enter"&&f.trim()&&(y.preventDefault(),!u.includes(f.trim())&&(!(p!=null&&p.maxTags)||u.length<p.maxTags)&&(l==null||l([...u,f.trim()])),h(""))},g=y=>{l==null||l(u.filter(v=>v!==y))};return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,errors:c,children:i.jsxs("div",{className:`flex flex-wrap gap-2 p-2 border rounded-md min-h-[42px] ${((c==null?void 0:c.length)??0)>0?"border-red-500":"border-gray-300"} ${d?"bg-gray-50":"bg-white"}`,children:[u.map((y,v)=>i.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-800 text-sm rounded"),children:[y,!d&&i.jsx("button",{type:"button",onClick:()=>g(y),className:m("text-blue-600 hover:text-blue-800"),children:"×"})]},v)),!d&&(!(p!=null&&p.maxTags)||u.length<p.maxTags)&&i.jsx("input",{type:"text",placeholder:o||"Add tag...",value:f,onChange:y=>h(y.target.value),onKeyDown:b,disabled:d,className:m("flex-1 min-w-[100px] border-none bg-transparent text-sm focus:outline-none")})]})})}},{type:"decisionBox",structure:"field",typeCategory:"Selection",label:"Decision Box",description:"Yes/No checkbox",icon:"✅",category:"field",subCategory:"selection",dataType:"boolean",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Decision Box Settings",icon:"✅"},fields:[{key:"checkedLabel",label:"Checked Label",type:"text",section:"config",placeholder:"Yes",description:"Label shown when checked",colSpan:1},{key:"uncheckedLabel",label:"Unchecked Label",type:"text",section:"config",placeholder:"No",description:"Label shown when unchecked",colSpan:1},{key:"showAsSwitch",label:"Show as Toggle Switch",type:"checkbox",section:"config",description:"Display as a switch instead of a checkbox"}]},getDefaultValues:()=>({properties:{label:"I agree to the terms and conditions"},layout:{labelPosition:"top",size:"full"},config:{checkedLabel:"Yes",uncheckedLabel:"No"}}),renderOnCanvas:e=>{const{label:t,description:r,required:o}=oe(e);return i.jsx("div",{className:m("space-y-1.5"),children:i.jsxs("label",{className:m("flex items-start gap-3 cursor-pointer"),children:[i.jsx("input",{type:"checkbox",disabled:!0,className:m("mt-1 text-blue-600 rounded")}),i.jsxs("div",{children:[i.jsx("span",{className:m("text-sm text-gray-700"),children:t}),o&&i.jsx("span",{className:m("text-red-500 ml-1"),children:"*"}),r&&i.jsx("p",{className:m("text-xs text-gray-500 mt-0.5"),children:r})]})]})})},render:e=>{const{label:t,description:r,required:o,value:n,onChange:a,errors:s,isDisabled:l}=oe(e);return i.jsxs("div",{className:m("space-y-1.5"),children:[i.jsxs("label",{className:m("flex items-start gap-3 cursor-pointer"),children:[i.jsx("input",{type:"checkbox",checked:n??!1,onChange:c=>a==null?void 0:a(c.target.checked),disabled:l,className:m("mt-1 text-blue-600 rounded")}),i.jsxs("div",{children:[i.jsx("span",{className:m("text-sm text-gray-700"),children:t}),o&&i.jsx("span",{className:m("text-red-500 ml-1"),children:"*"}),r&&i.jsx("p",{className:m("text-xs text-gray-500 mt-0.5"),children:r})]})]}),s&&s.length>0&&i.jsx("div",{className:m("space-y-1"),children:s.map((c,d)=>i.jsx("p",{className:m("text-xs text-red-500"),children:c},d))})]})}},{type:"toggleSwitch",structure:"field",typeCategory:"Selection",label:"Toggle Switch",description:"On/Off toggle switch",icon:"🔀",category:"field",subCategory:"selection",dataType:"boolean",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Toggle Settings",icon:"🔀"},fields:[{key:"onLabel",label:"On Label",type:"text",section:"config",placeholder:"On",description:"Label for the active state",colSpan:1},{key:"offLabel",label:"Off Label",type:"text",section:"config",placeholder:"Off",description:"Label for the inactive state",colSpan:1},{key:"showLabels",label:"Show State Labels",type:"checkbox",section:"config",description:"Display on/off text next to the switch"},{key:"defaultValue",label:"Default State",type:"select",section:"config",description:"Initial state of the switch",options:[{value:"off",label:"Off (unchecked)"},{value:"on",label:"On (checked)"}]}]},getDefaultValues:()=>({properties:{label:"Toggle Switch",description:"Toggle on or off"},layout:{labelPosition:"top",size:"full"},config:{onLabel:"On",offLabel:"Off"}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e);return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsxs("div",{className:m("flex items-center gap-2"),children:[i.jsx("span",{className:m("text-sm text-gray-500"),children:(a==null?void 0:a.offLabel)||"Off"}),i.jsx("div",{className:m("relative w-11 h-6 bg-gray-300 rounded-full"),children:i.jsx("div",{className:m("absolute left-1 top-1 w-4 h-4 bg-white rounded-full transition-transform")})}),i.jsx("span",{className:m("text-sm text-gray-500"),children:(a==null?void 0:a.onLabel)||"On"})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),p=a??!1;return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsxs("div",{className:m("flex items-center gap-2"),children:[i.jsx("span",{className:m("text-sm text-gray-500"),children:(d==null?void 0:d.offLabel)||"Off"}),i.jsx("button",{type:"button",onClick:()=>!c&&(s==null?void 0:s(!p)),disabled:c,className:`relative w-11 h-6 rounded-full transition-colors ${p?"bg-blue-600":"bg-gray-300"} ${c?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:i.jsx("div",{className:`absolute top-1 w-4 h-4 bg-white rounded-full transition-transform ${p?"translate-x-6":"translate-x-1"}`})}),i.jsx("span",{className:m("text-sm text-gray-500"),children:(d==null?void 0:d.onLabel)||"On"})]})})}}];var Hx=Object.defineProperty,jx=(e,t)=>Hx(e,"name",{value:t,configurable:!0});function Ni(e,[t,r]){return Math.min(r,Math.max(t,e))}jx(Ni,"clamp");var qx=Object.defineProperty,cn=(e,t)=>qx(e,"name",{value:t,configurable:!0}),vf=!!(typeof window<"u"&&window.document&&window.document.createElement);function Pe(e,t,{checkForDefaultPrevented:r=!0}={}){return cn(function(n){if(e==null||e(n),r===!1||!n||!n.defaultPrevented)return t==null?void 0:t(n)},"handleEvent")}cn(Pe,"composeEventHandlers");function Yx(e){var t;if(!vf)throw new Error("Cannot access window outside of the DOM");return((t=e==null?void 0:e.ownerDocument)==null?void 0:t.defaultView)??window}cn(Yx,"getOwnerWindow");function Ei(e){if(!vf)throw new Error("Cannot access document outside of the DOM");return(e==null?void 0:e.ownerDocument)??document}cn(Ei,"getOwnerDocument");function wf(e,t=!1){const{activeElement:r}=Ei(e);if(!(r!=null&&r.nodeName))return null;if(xf(r)&&r.contentDocument)return wf(r.contentDocument.body,t);if(t){const o=r.getAttribute("aria-activedescendant");if(o){const n=Ei(r).getElementById(o);if(n)return n}}return r}cn(wf,"getActiveElement");function xf(e){return e.tagName==="IFRAME"}cn(xf,"isFrame");var Qx=Object.defineProperty,dr=(e,t)=>Qx(e,"name",{value:t,configurable:!0});function Kx(e,t){const r=C.createContext(t);r.displayName=e+"Context";const o=dr(a=>{const{children:s,...l}=a,c=C.useMemo(()=>l,Object.values(l));return i.jsx(r.Provider,{value:c,children:s})},"Provider");o.displayName=e+"Provider";function n(a,s={}){const{optional:l=!1}=s,c=C.useContext(r);if(c)return c;if(t!==void 0)return t;if(!l)throw new Error(`\`${a}\` must be used within \`${e}\``)}return dr(n,"useContext"),[o,n]}dr(Kx,"createContext");function ur(e,t=[]){let r=[];function o(a,s){const l=C.createContext(s);l.displayName=a+"Context";const c=r.length;r=[...r,s];const d=dr(u=>{var v;const{scope:f,children:h,...b}=u,g=((v=f==null?void 0:f[e])==null?void 0:v[c])||l,y=C.useMemo(()=>b,Object.values(b));return i.jsx(g.Provider,{value:y,children:h})},"Provider");d.displayName=a+"Provider";function p(u,f,h={}){var v;const{optional:b=!1}=h,g=((v=f==null?void 0:f[e])==null?void 0:v[c])||l,y=C.useContext(g);if(y)return y;if(s!==void 0)return s;if(!b)throw new Error(`\`${u}\` must be used within \`${a}\``)}return dr(p,"useContext"),[d,p]}dr(o,"createContext");const n=dr(()=>{const a=r.map(s=>C.createContext(s));return dr(function(l){const c=(l==null?void 0:l[e])||a;return C.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])},"useScope")},"createScope");return n.scopeName=e,[o,Cf(n,...t)]}dr(ur,"createContextScope");function Cf(...e){const t=e[0];if(e.length===1)return t;const r=dr(()=>{const o=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return dr(function(a){const s=o.reduce((l,{useScope:c,scopeName:d})=>{const u=c(a)[`__scope${d}`];return{...l,...u}},{});return C.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])},"useComposedScopes")},"createScope");return r.scopeName=t.scopeName,r}dr(Cf,"composeContextScopes");var Rx=Object.defineProperty,ki=(e,t)=>Rx(e,"name",{value:t,configurable:!0});function Ai(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}ki(Ai,"setRef");function Sf(...e){return t=>{let r=!1;const o=e.map(n=>{const a=Ai(n,t);return!r&&typeof a=="function"&&(r=!0),a});if(r)return()=>{for(let n=0;n<o.length;n++){const a=o[n];typeof a=="function"?a():Ai(e[n],null)}}}}ki(Sf,"composeRefs");function Re(...e){return C.useCallback(Sf(...e),e)}ki(Re,"useComposedRefs");var Xx=Object.defineProperty,vr=(e,t)=>Xx(e,"name",{value:t,configurable:!0});function Kr(e){const t=C.forwardRef((r,o)=>{let{children:n,...a}=r,s=null,l=!1;const c=[];_i(n)&&typeof os=="function"&&(n=os(n._payload)),C.Children.forEach(n,f=>{var h;if(_f(f)){l=!0;const b=f;let g="child"in b.props?b.props.child:b.props.children;_i(g)&&typeof os=="function"&&(g=os(g._payload)),s=Zx(b,g),c.push((h=s==null?void 0:s.props)==null?void 0:h.children)}else c.push(f)}),s?s=C.cloneElement(s,void 0,c):!l&&C.Children.count(n)===1&&C.isValidElement(n)&&(s=n);const d=s?Af(s):void 0,p=Re(o,d);if(!s){if(n||n===0)throw new Error(l?rC(e):tC(e));return n}const u=kf(a,s.props??{});return s.type!==C.Fragment&&(u.ref=o?p:d),C.cloneElement(s,u)});return t.displayName=`${e}.Slot`,t}vr(Kr,"createSlot");var Jx=Kr("Slot"),Nf=Symbol.for("radix.slottable");function Ef(e){const t=vr(r=>"child"in r?r.children(r.child):r.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=Nf,t}vr(Ef,"createSlottable");var Zx=vr((e,t)=>{if("child"in e.props){const r=e.props.child;return C.isValidElement(r)?C.cloneElement(r,void 0,e.props.children(r.props.children)):null}return C.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function kf(e,t){const r={...t};for(const o in t){const n=e[o],a=t[o];/^on[A-Z]/.test(o)?n&&a?r[o]=(...l)=>{const c=a(...l);return n(...l),c}:n&&(r[o]=n):o==="style"?r[o]={...n,...a}:o==="className"&&(r[o]=[n,a].filter(Boolean).join(" "))}return{...e,...r}}vr(kf,"mergeProps");function Af(e){var o,n;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(n=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}vr(Af,"getElementRef");function _f(e){return C.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Nf}vr(_f,"isSlottable");var eC=Symbol.for("react.lazy");function _i(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===eC&&"_payload"in e&&Tf(e._payload)}vr(_i,"isLazyComponent");function Tf(e){return typeof e=="object"&&e!==null&&"then"in e}vr(Tf,"isPromiseLike");var tC=vr(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),rC=vr(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),os=C[" use ".trim().toString()],oC=Object.defineProperty,_t=(e,t)=>oC(e,"name",{value:t,configurable:!0});function ns(e){const t=e+"CollectionProvider",[r,o]=ur(t),[n,a]=r(t,{collectionRef:{current:null},itemMap:new Map}),s=_t(g=>{const{scope:y,children:v}=g,S=C.useRef(null),x=C.useRef(new Map).current;return i.jsx(n,{scope:y,itemMap:x,collectionRef:S,children:v})},"CollectionProvider");s.displayName=t;const l=e+"CollectionSlot",c=Kr(l),d=C.forwardRef((g,y)=>{const{scope:v,children:S}=g,x=a(l,v),w=Re(y,x.collectionRef);return i.jsx(c,{ref:w,children:S})});d.displayName=l;const p=e+"CollectionItemSlot",u="data-radix-collection-item",f=Kr(p),h=C.forwardRef((g,y)=>{const{scope:v,children:S,...x}=g,w=C.useRef(null),N=Re(y,w),k=a(p,v);return C.useEffect(()=>(k.itemMap.set(w,{ref:w,...x}),()=>void k.itemMap.delete(w))),i.jsx(f,{[u]:"",ref:N,children:S})});h.displayName=p;function b(g){const y=a(e+"CollectionConsumer",g);return C.useCallback(()=>{const S=y.collectionRef.current;if(!S)return[];const x=Array.from(S.querySelectorAll(`[${u}]`));return Array.from(y.itemMap.values()).sort((k,_)=>x.indexOf(k.ref.current)-x.indexOf(_.ref.current))},[y.collectionRef,y.itemMap])}return _t(b,"useCollection"),[{Provider:s,Slot:d,ItemSlot:h},b,o]}_t(ns,"createCollection");var Df=new WeakMap,Ti=(lr=class extends Map{constructor(r){super(r);sw(this,St);Eu(this,St,[...super.keys()]),Df.set(this,!0)}set(r,o){return Df.get(this)&&(this.has(r)?jt(this,St)[jt(this,St).indexOf(r)]=r:jt(this,St).push(r)),super.set(r,o),this}insert(r,o,n){const a=this.has(o),s=jt(this,St).length,l=Di(r);let c=l>=0?l:s+l;const d=c<0||c>=s?-1:c;if(d===this.size||a&&d===this.size-1||d===-1)return this.set(o,n),this;const p=this.size+(a?0:1);l<0&&c++;const u=[...jt(this,St)];let f,h=!1;for(let b=c;b<p;b++)if(c===b){let g=u[b];u[b]===o&&(g=u[b+1]),a&&this.delete(o),f=this.get(g),this.set(o,n)}else{!h&&u[b-1]===o&&(h=!0);const g=u[h?b:b-1],y=f;f=this.get(g),this.delete(g),this.set(g,y)}return this}with(r,o,n){const a=new lr(this);return a.insert(r,o,n),a}before(r){const o=jt(this,St).indexOf(r)-1;if(!(o<0))return this.entryAt(o)}setBefore(r,o,n){const a=jt(this,St).indexOf(r);return a===-1?this:this.insert(a,o,n)}after(r){let o=jt(this,St).indexOf(r);if(o=o===-1||o===this.size-1?-1:o+1,o!==-1)return this.entryAt(o)}setAfter(r,o,n){const a=jt(this,St).indexOf(r);return a===-1?this:this.insert(a+1,o,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Eu(this,St,[]),super.clear()}delete(r){const o=super.delete(r);return o&&jt(this,St).splice(jt(this,St).indexOf(r),1),o}deleteAt(r){const o=this.keyAt(r);return o!==void 0?this.delete(o):!1}at(r){const o=as(jt(this,St),r);if(o!==void 0)return this.get(o)}entryAt(r){const o=as(jt(this,St),r);if(o!==void 0)return[o,this.get(o)]}indexOf(r){return jt(this,St).indexOf(r)}keyAt(r){return as(jt(this,St),r)}from(r,o){const n=this.indexOf(r);if(n===-1)return;let a=n+o;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.at(a)}keyFrom(r,o){const n=this.indexOf(r);if(n===-1)return;let a=n+o;return a<0&&(a=0),a>=this.size&&(a=this.size-1),this.keyAt(a)}find(r,o){let n=0;for(const a of this){if(Reflect.apply(r,o,[a,n,this]))return a;n++}}findIndex(r,o){let n=0;for(const a of this){if(Reflect.apply(r,o,[a,n,this]))return n;n++}return-1}filter(r,o){const n=[];let a=0;for(const s of this)Reflect.apply(r,o,[s,a,this])&&n.push(s),a++;return new lr(n)}map(r,o){const n=[];let a=0;for(const s of this)n.push([s[0],Reflect.apply(r,o,[s,a,this])]),a++;return new lr(n)}reduce(...r){const[o,n]=r;let a=0,s=n??this.at(0);for(const l of this)a===0&&r.length===1?s=l:s=Reflect.apply(o,this,[s,l,a,this]),a++;return s}reduceRight(...r){const[o,n]=r;let a=n??this.at(-1);for(let s=this.size-1;s>=0;s--){const l=this.at(s);s===this.size-1&&r.length===1?a=l:a=Reflect.apply(o,this,[a,l,s,this])}return a}toSorted(r){const o=[...this.entries()].sort(r);return new lr(o)}toReversed(){const r=new lr;for(let o=this.size-1;o>=0;o--){const n=this.keyAt(o),a=this.get(n);r.set(n,a)}return r}toSpliced(...r){const o=[...this.entries()];return o.splice(...r),new lr(o)}slice(r,o){const n=new lr;let a=this.size-1;if(r===void 0)return n;r<0&&(r=r+this.size),o!==void 0&&o>0&&(a=o-1);for(let s=r;s<=a;s++){const l=this.keyAt(s),c=this.get(l);n.set(l,c)}return n}every(r,o){let n=0;for(const a of this){if(!Reflect.apply(r,o,[a,n,this]))return!1;n++}return!0}some(r,o){let n=0;for(const a of this){if(Reflect.apply(r,o,[a,n,this]))return!0;n++}return!1}},St=new WeakMap,_t(lr,"OrderedDict"),lr);function as(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);const r=$f(e,t);return r===-1?void 0:e[r]}_t(as,"at");function $f(e,t){const r=e.length,o=Di(t),n=o>=0?o:r+o;return n<0||n>=r?-1:n}_t($f,"toSafeIndex");function Di(e){return e!==e||e===0?0:Math.trunc(e)}_t(Di,"toSafeInteger");function nC(e){const t=e+"CollectionProvider",[r,o]=ur(t),[n,a]=r(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Ti,setItemMap:_t(()=>{},"setItemMap")}),s=_t(({state:x,...w})=>x?i.jsx(c,{...w,state:x}):i.jsx(l,{...w}),"CollectionProvider");s.displayName=t;const l=_t(x=>{const w=y();return i.jsx(c,{...x,state:w})},"CollectionInit");l.displayName=t+"Init";const c=_t(x=>{const{scope:w,children:N,state:k}=x,_=C.useRef(null),[E,D]=C.useState(null),T=Re(_,D),[O,$]=k;return C.useEffect(()=>{if(!E)return;const V=Of(()=>{});return V.observe(E,{childList:!0,subtree:!0}),()=>{V.disconnect()}},[E]),i.jsx(n,{scope:w,itemMap:O,setItemMap:$,collectionRef:T,collectionRefObject:_,collectionElement:E,children:N})},"CollectionProviderImpl");c.displayName=t+"Impl";const d=e+"CollectionSlot",p=Kr(d),u=C.forwardRef((x,w)=>{const{scope:N,children:k}=x,_=a(d,N),E=Re(w,_.collectionRef);return i.jsx(p,{ref:E,children:k})});u.displayName=d;const f=e+"CollectionItemSlot",h="data-radix-collection-item",b=Kr(f),g=C.forwardRef((x,w)=>{const{scope:N,children:k,..._}=x,E=C.useRef(null),[D,T]=C.useState(null),O=Re(w,E,T),$=a(f,N),{setItemMap:V}=$,G=C.useRef(_);Pf(G.current,_)||(G.current=_);const q=G.current;return C.useEffect(()=>{const H=q;return V(Y=>D?Y.has(D)?Y.set(D,{...H,element:D}).toSorted($i):(Y.set(D,{...H,element:D}),Y.toSorted($i)):Y),()=>{V(Y=>!D||!Y.has(D)?Y:(Y.delete(D),new Ti(Y)))}},[D,q,V]),i.jsx(b,{[h]:"",ref:O,children:k})});g.displayName=f;function y(){return C.useState(new Ti)}_t(y,"useInitCollection");function v(x){const{itemMap:w}=a(e+"CollectionConsumer",x);return w}return _t(v,"useCollection"),[{Provider:s,Slot:u,ItemSlot:g},{createCollectionScope:o,useCollection:v,useInitCollection:y}]}_t(nC,"createCollection");function Pf(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e==null||t==null)return!1;const r=Object.keys(e),o=Object.keys(t);if(r.length!==o.length)return!1;for(const n of r)if(!Object.prototype.hasOwnProperty.call(t,n)||e[n]!==t[n])return!1;return!0}_t(Pf,"shallowEqual");function Mf(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}_t(Mf,"isElementPreceding");function $i(e,t){return!e[1].element||!t[1].element?0:Mf(e[1].element,t[1].element)?-1:1}_t($i,"sortByDocumentPosition");function Of(e){return new MutationObserver(r=>{for(const o of r)if(o.type==="childList"){e();return}})}_t(Of,"getChildListObserver");var aC=Object.defineProperty,sC=(e,t)=>aC(e,"name",{value:t,configurable:!0}),lC=C.createContext(void 0);function Gn(e){const t=C.useContext(lC);return e||t||"ltr"}sC(Gn,"useDirection");var iC=Object.defineProperty,cC=(e,t)=>iC(e,"name",{value:t,configurable:!0}),dC=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Be=dC.reduce((e,t)=>{const r=Kr(`Primitive.${t}`),o=C.forwardRef((n,a)=>{const{asChild:s,...l}=n,c=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),i.jsx(c,{...l,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function If(e,t){e&&Pn.flushSync(()=>e.dispatchEvent(t))}cC(If,"dispatchDiscreteCustomEvent");var uC=Object.defineProperty,fC=(e,t)=>uC(e,"name",{value:t,configurable:!0});function wr(e){const t=C.useRef(e);return C.useEffect(()=>{t.current=e}),C.useMemo(()=>((...r)=>{var o;return(o=t.current)==null?void 0:o.call(t,...r)}),[])}fC(wr,"useCallbackRef");var pC=Object.defineProperty,Tt=(e,t)=>pC(e,"name",{value:t,configurable:!0}),Pi="dismissableLayer.update",hC="dismissableLayer.pointerDownOutside",mC="dismissableLayer.focusOutside",Lf,Ff=C.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Mi=C.forwardRef(Tt(function(t,r){const{disableOutsidePointerEvents:o=!1,deferPointerDownOutside:n=!1,onEscapeKeyDown:a,onPointerDownOutside:s,onFocusOutside:l,onInteractOutside:c,onDismiss:d,...p}=t,u=C.useContext(Ff),[f,h]=C.useState(null),b=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=C.useState({}),y=Re(r,h),v=Array.from(u.layers),[S]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=S?v.indexOf(S):-1,w=f?v.indexOf(f):-1,N=u.layersWithOutsidePointerEventsDisabled.size>0,k=w>=x,_=C.useRef(!1),E=Gf($=>{s==null||s($),c==null||c($),$.defaultPrevented||d==null||d()},{ownerDocument:b,deferPointerDownOutside:n,isDeferredPointerDownOutsideRef:_,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:C.useCallback($=>{if(!($ instanceof Node))return!1;const V=[...u.branches].some(G=>G.contains($));return k&&!V},[u.branches,k])}),D=zf($=>{if(n&&_.current)return;const V=$.target;[...u.branches].some(q=>q.contains(V))||(l==null||l($),c==null||c($),$.defaultPrevented||d==null||d())},b),T=f?w===v.length-1:!1,O=wr($=>{$.key==="Escape"&&(a==null||a($),!$.defaultPrevented&&d&&($.preventDefault(),d()))});return C.useEffect(()=>{if(T)return b.addEventListener("keydown",O,{capture:!0}),()=>b.removeEventListener("keydown",O,{capture:!0})},[b,T,O]),C.useEffect(()=>{if(f)return o&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Lf=b.body.style.pointerEvents,b.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),Oi(),()=>{o&&(u.layersWithOutsidePointerEventsDisabled.delete(f),u.layersWithOutsidePointerEventsDisabled.size===0&&(b.body.style.pointerEvents=Lf))}},[f,b,o,u]),C.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),Oi())},[f,u]),C.useEffect(()=>{const $=Tt(()=>g({}),"handleUpdate");return document.addEventListener(Pi,$),()=>document.removeEventListener(Pi,$)},[]),i.jsx(Be.div,{...p,ref:y,style:{pointerEvents:N?k?"auto":"none":void 0,...t.style},onFocusCapture:Pe(t.onFocusCapture,D.onFocusCapture),onBlurCapture:Pe(t.onBlurCapture,D.onBlurCapture),onPointerDownCapture:Pe(t.onPointerDownCapture,E.onPointerDownCapture)})},"DismissableLayer"));function Vf(){const e=C.useContext(Ff),[t,r]=C.useState(null);return C.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),r}Tt(Vf,"useDismissableLayerSurface");var bC=Tt(()=>!0,"IS_TRUE");function Gf(e,t){const{ownerDocument:r=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:o=!1,isDeferredPointerDownOutsideRef:n,dismissableSurfaces:a,shouldHandlePointerDownOutside:s=bC}=t,l=wr(e),c=C.useRef(!1),d=C.useRef(!1),p=C.useRef(new Map),u=C.useRef(()=>{});return C.useEffect(()=>{function f(){d.current=!1,n.current=!1,p.current.clear()}Tt(f,"resetOutsideInteraction");function h(){return Array.from(p.current.values()).some(Boolean)}Tt(h,"isOutsideInteractionIntercepted");function b(x){if(!d.current)return;const w=x.target;w instanceof Node&&[...a].some(k=>k.contains(w))||p.current.set(x.type,!0),x.type==="click"&&window.setTimeout(()=>{d.current&&u.current()},0)}Tt(b,"handleInteractionCapture");function g(x){d.current&&p.current.set(x.type,!1)}Tt(g,"handleInteractionBubble");const y=Tt(x=>{if(x.target&&!c.current){let w=function(){r.removeEventListener("click",u.current);const k=h();f(),k||Ii(hC,l,N,{discrete:!0})};if(Tt(w,"handleAndDispatchPointerDownOutsideEvent"),!s(x.target)){r.removeEventListener("click",u.current),f(),c.current=!1;return}const N={originalEvent:x};d.current=!0,n.current=o&&x.button===0,p.current.clear(),!o||x.button!==0?w():(r.removeEventListener("click",u.current),u.current=w,r.addEventListener("click",u.current,{once:!0}))}else r.removeEventListener("click",u.current),f();c.current=!1},"handlePointerDown"),v=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const x of v)r.addEventListener(x,b,!0),r.addEventListener(x,g);const S=window.setTimeout(()=>{r.addEventListener("pointerdown",y)},0);return()=>{window.clearTimeout(S),r.removeEventListener("pointerdown",y),r.removeEventListener("click",u.current);for(const x of v)r.removeEventListener(x,b,!0),r.removeEventListener(x,g)}},[r,l,o,n,a,s]),{onPointerDownCapture:Tt(()=>c.current=!0,"onPointerDownCapture")}}Tt(Gf,"usePointerDownOutside");function zf(e,t=globalThis==null?void 0:globalThis.document){const r=wr(e),o=C.useRef(!1);return C.useEffect(()=>{const n=Tt(a=>{a.target&&!o.current&&Ii(mC,r,{originalEvent:a},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",n),()=>t.removeEventListener("focusin",n)},[t,r]),{onFocusCapture:Tt(()=>o.current=!0,"onFocusCapture"),onBlurCapture:Tt(()=>o.current=!1,"onBlurCapture")}}Tt(zf,"useFocusOutside");function Oi(){const e=new CustomEvent(Pi);document.dispatchEvent(e)}Tt(Oi,"dispatchUpdate");function Ii(e,t,r,{discrete:o}){const n=r.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),o?If(n,a):n.dispatchEvent(a)}Tt(Ii,"handleAndDispatchCustomEvent");var gC=Object.defineProperty,Li=(e,t)=>gC(e,"name",{value:t,configurable:!0}),ss=0,Pr=null;function yC(e){return ls(),e.children}Li(yC,"FocusGuards");function ls(){C.useEffect(()=>{Pr||(Pr={start:Fi(),end:Fi()});const{start:e,end:t}=Pr;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),ss++,()=>{ss===1&&(Pr==null||Pr.start.remove(),Pr==null||Pr.end.remove(),Pr=null),ss=Math.max(0,ss-1)}},[])}Li(ls,"useFocusGuards");function Fi(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}Li(Fi,"createFocusGuard");var vC=Object.defineProperty,Yt=(e,t)=>vC(e,"name",{value:t,configurable:!0}),Vi="focusScope.autoFocusOnMount",Gi="focusScope.autoFocusOnUnmount",Bf={bubbles:!1,cancelable:!0},Uf=C.forwardRef(Yt(function(t,r){const{loop:o=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:s,...l}=t,[c,d]=C.useState(null),p=wr(a),u=wr(s),f=C.useRef(null),h=Re(r,d),b=C.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;C.useEffect(()=>{if(n){let y=function(w){if(b.paused||!c)return;const N=w.target;c.contains(N)?f.current=N:Rr(f.current,{select:!0})},v=function(w){if(b.paused||!c)return;const N=w.relatedTarget;N!==null&&(c.contains(N)||Rr(f.current,{select:!0}))},S=function(w){if(document.activeElement===document.body)for(const k of w)k.removedNodes.length>0&&Rr(c)};Yt(y,"handleFocusIn"),Yt(v,"handleFocusOut"),Yt(S,"handleMutations"),document.addEventListener("focusin",y),document.addEventListener("focusout",v);const x=new MutationObserver(S);return c&&x.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",v),x.disconnect()}}},[n,c,b.paused]),C.useEffect(()=>{if(c){Yf.add(b);const y=document.activeElement;if(!c.contains(y)){const S=new CustomEvent(Vi,Bf);c.addEventListener(Vi,p),c.dispatchEvent(S),S.defaultPrevented||(Wf(Kf(zi(c)),{select:!0}),document.activeElement===y&&Rr(c))}return()=>{c.removeEventListener(Vi,p),setTimeout(()=>{const S=new CustomEvent(Gi,Bf);c.addEventListener(Gi,u),c.dispatchEvent(S),S.defaultPrevented||Rr(y??document.body,{select:!0}),c.removeEventListener(Gi,u),Yf.remove(b)},0)}}},[c,p,u,b]);const g=C.useCallback(y=>{if(!o&&!n||b.paused)return;const v=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,S=document.activeElement;if(v&&S){const x=y.currentTarget,[w,N]=Hf(x);w&&N?!y.shiftKey&&S===N?(y.preventDefault(),o&&Rr(w,{select:!0})):y.shiftKey&&S===w&&(y.preventDefault(),o&&Rr(N,{select:!0})):S===x&&y.preventDefault()}},[o,n,b.paused]);return i.jsx(Be.div,{tabIndex:-1,...l,ref:h,onKeyDown:g})},"FocusScope"));function Wf(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(Rr(o,{select:t}),document.activeElement!==r)return}Yt(Wf,"focusFirst");function Hf(e){const t=zi(e),r=Bi(t,e),o=Bi(t.reverse(),e);return[r,o]}Yt(Hf,"getTabbableEdges");function zi(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Yt(o=>{const n=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||n?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;r.nextNode();)t.push(r.currentNode);return t}Yt(zi,"getTabbableCandidates");function Bi(e,t){const r=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const o of e)if(!(r?!o.checkVisibility({checkVisibilityCSS:!0}):jf(o,{upTo:t})))return o}Yt(Bi,"findVisible");function jf(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}Yt(jf,"isHidden");function qf(e){return e instanceof HTMLInputElement&&"select"in e}Yt(qf,"isSelectableInput");function Rr(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&qf(e)&&t&&e.select()}}Yt(Rr,"focus");var Yf=Qf();function Qf(){let e=[];return{add(t){const r=e[0];t!==r&&(r==null||r.pause()),e=Ui(e,t),e.unshift(t)},remove(t){var r;e=Ui(e,t),(r=e[0])==null||r.resume()}}}Yt(Qf,"createFocusScopesStack");function Ui(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}Yt(Ui,"arrayRemove");function Kf(e){return e.filter(t=>t.tagName!=="A")}Yt(Kf,"removeLinks");var ut=globalThis!=null&&globalThis.document?C.useLayoutEffect:()=>{},wC=Object.defineProperty,xC=(e,t)=>wC(e,"name",{value:t,configurable:!0}),CC=C[" useId ".trim().toString()]||(()=>{}),SC=0;function xr(e){const[t,r]=C.useState(CC());return ut(()=>{e||r(o=>o??String(SC++))},[e]),e||(t?`radix-${t}`:"")}xC(xr,"useId");const NC=["top","right","bottom","left"],mo=Math.min,Xr=Math.max,is=Math.round,cs=Math.floor,Jr=e=>({x:e,y:e}),EC={left:"right",right:"left",bottom:"top",top:"bottom"};function Rf(e,t,r){return Xr(e,mo(t,r))}function Zr(e,t){return typeof e=="function"?e(t):e}function bo(e){return e.split("-")[0]}function dn(e){return e.split("-")[1]}function Wi(e){return e==="x"?"y":"x"}function Hi(e){return e==="y"?"height":"width"}function Mr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function ji(e){return Wi(Mr(e))}function kC(e,t,r){r===void 0&&(r=!1);const o=dn(e),n=ji(e),a=Hi(n);let s=n==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(s=ds(s)),[s,ds(s)]}function AC(e){const t=ds(e);return[qi(e),t,qi(t)]}function qi(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Xf=["left","right"],Jf=["right","left"],_C=["top","bottom"],TC=["bottom","top"];function DC(e,t,r){switch(e){case"top":case"bottom":return r?t?Jf:Xf:t?Xf:Jf;case"left":case"right":return t?_C:TC;default:return[]}}function $C(e,t,r,o){const n=dn(e);let a=DC(bo(e),r==="start",o);return n&&(a=a.map(s=>s+"-"+n),t&&(a=a.concat(a.map(qi)))),a}function ds(e){const t=bo(e);return EC[t]+e.slice(t.length)}function PC(e){var t,r,o,n;return{top:(t=e.top)!=null?t:0,right:(r=e.right)!=null?r:0,bottom:(o=e.bottom)!=null?o:0,left:(n=e.left)!=null?n:0}}function Zf(e){return typeof e!="number"?PC(e):{top:e,right:e,bottom:e,left:e}}function us(e){const{x:t,y:r,width:o,height:n}=e;return{width:o,height:n,top:r,left:t,right:t+o,bottom:r+n,x:t,y:r}}function ep(e,t,r){let{reference:o,floating:n}=e;const a=Mr(t),s=ji(t),l=Hi(s),c=bo(t),d=a==="y",p=o.x+o.width/2-n.width/2,u=o.y+o.height/2-n.height/2,f=o[l]/2-n[l]/2;let h;switch(c){case"top":h={x:p,y:o.y-n.height};break;case"bottom":h={x:p,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:u};break;case"left":h={x:o.x-n.width,y:u};break;default:h={x:o.x,y:o.y}}const b=dn(t);return b&&(h[s]+=f*(b==="end"?1:-1)*(r&&d?-1:1)),h}async function MC(e,t){var r;t===void 0&&(t={});const{x:o,y:n,platform:a,rects:s,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:p="viewport",elementContext:u="floating",altBoundary:f=!1,padding:h=0}=Zr(t,e),b=Zf(h),y=l[f?u==="floating"?"reference":"floating":u],v=us(await a.getClippingRect({element:(r=await(a.isElement==null?void 0:a.isElement(y)))==null||r?y:y.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:d,rootBoundary:p,strategy:c})),S=u==="floating"?{x:o,y:n,width:s.floating.width,height:s.floating.height}:s.reference,x=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),w=await(a.isElement==null?void 0:a.isElement(x))&&await(a.getScale==null?void 0:a.getScale(x))||{x:1,y:1},N=us(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:S,offsetParent:x,strategy:c}):S);return{top:(v.top-N.top+b.top)/w.y,bottom:(N.bottom-v.bottom+b.bottom)/w.y,left:(v.left-N.left+b.left)/w.x,right:(N.right-v.right+b.right)/w.x}}const OC=50,IC=async(e,t,r)=>{const{placement:o="bottom",strategy:n="absolute",middleware:a=[],platform:s}=r,l=s.detectOverflow?s:{...s,detectOverflow:MC},c=await(s.isRTL==null?void 0:s.isRTL(t));let d=await s.getElementRects({reference:e,floating:t,strategy:n}),{x:p,y:u}=ep(d,o,c),f=o,h=0;const b={};for(let g=0;g<a.length;g++){const y=a[g];if(!y)continue;const{name:v,fn:S}=y,{x,y:w,data:N,reset:k}=await S({x:p,y:u,initialPlacement:o,placement:f,strategy:n,middlewareData:b,rects:d,platform:l,elements:{reference:e,floating:t}});p=x??p,u=w??u,b[v]={...b[v],...N},k&&h<OC&&(h++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(d=k.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:n}):k.rects),{x:p,y:u}=ep(d,f,c)),g=-1)}return{x:p,y:u,placement:f,strategy:n,middlewareData:b}},LC=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:o,placement:n,rects:a,platform:s,elements:l,middlewareData:c}=t,{element:d,padding:p=0}=Zr(e,t)||{};if(d==null)return{};const u=Zf(p),f={x:r,y:o},h=ji(n),b=Hi(h),g=await s.getDimensions(d),y=h==="y",v=y?"top":"left",S=y?"bottom":"right",x=y?"clientHeight":"clientWidth",w=a.reference[b]+a.reference[h]-f[h]-a.floating[b],N=f[h]-a.reference[h],k=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d));let _=k?k[x]:0;(!_||!await(s.isElement==null?void 0:s.isElement(k)))&&(_=l.floating[x]||a.floating[b]);const E=w/2-N/2,D=_/2-g[b]/2-1,T=mo(u[v],D),O=mo(u[S],D),$=_-g[b]-O,V=_/2-g[b]/2+E,G=Rf(T,V,$),q=!c.arrow&&dn(n)!=null&&V!==G&&a.reference[b]/2-(V<T?T:O)-g[b]/2<0,H=q?V<T?V-T:V-$:0;return{[h]:f[h]+H,data:{[h]:G,centerOffset:V-G-H,...q&&{alignmentOffset:H}},reset:q}}}),FC=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,o;const{placement:n,middlewareData:a,rects:s,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:p=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:g=!0,...y}=Zr(e,t);if((r=a.arrow)!=null&&r.alignmentOffset)return{};const v=bo(n),S=Mr(l),x=bo(l)===l,w=await(c.isRTL==null?void 0:c.isRTL(d.floating)),N=f||(x||!g?[ds(l)]:AC(l)),k=b!=="none";!f&&k&&N.push(...$C(l,g,b,w));const _=[l,...N],E=await c.detectOverflow(t,y),D=[];let T=((o=a.flip)==null?void 0:o.overflows)||[];if(p&&D.push(E[v]),u){const G=kC(n,s,w);D.push(E[G[0]],E[G[1]])}if(T=[...T,{placement:n,overflows:D}],!D.every(G=>G<=0)){var O,$;const G=(((O=a.flip)==null?void 0:O.index)||0)+1,q=_[G];if(q&&(!(u==="alignment"?S!==Mr(q):!1)||T.every(J=>Mr(J.placement)===S?J.overflows[0]>0:!0)))return{data:{index:G,overflows:T},reset:{placement:q}};let H=($=T.filter(Y=>Y.overflows[0]<=0).sort((Y,J)=>Y.overflows[1]-J.overflows[1])[0])==null?void 0:$.placement;if(!H)switch(h){case"bestFit":{var V;const Y=(V=T.filter(J=>{if(k){const W=Mr(J.placement);return W===S||W==="y"}return!0}).map(J=>[J.placement,J.overflows.filter(W=>W>0).reduce((W,R)=>W+R,0)]).sort((J,W)=>J[1]-W[1])[0])==null?void 0:V[0];Y&&(H=Y);break}case"initialPlacement":H=l;break}if(n!==H)return{reset:{placement:H}}}return{}}}};function tp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function rp(e){return NC.some(t=>e[t]>=0)}const VC=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:o}=t,{strategy:n="referenceHidden",...a}=Zr(e,t);switch(n){case"referenceHidden":{const s=await o.detectOverflow(t,{...a,elementContext:"reference"}),l=tp(s,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:rp(l)}}}case"escaped":{const s=await o.detectOverflow(t,{...a,altBoundary:!0}),l=tp(s,r.floating);return{data:{escapedOffsets:l,escaped:rp(l)}}}default:return{}}}}},op=new Set(["left","top"]);async function GC(e,t){const{placement:r,platform:o,elements:n}=e,a=await(o.isRTL==null?void 0:o.isRTL(n.floating)),s=bo(r),l=dn(r),c=Mr(r)==="y",d=op.has(s)?-1:1,p=a&&c?-1:1,u=Zr(t,e);let{mainAxis:f,crossAxis:h,alignmentAxis:b}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof b=="number"&&(h=l==="end"?b*-1:b),c?{x:h*p,y:f*d}:{x:f*d,y:h*p}}const zC=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,o;const{x:n,y:a,placement:s,middlewareData:l}=t,c=await GC(t,e);return s===((r=l.offset)==null?void 0:r.placement)&&(o=l.arrow)!=null&&o.alignmentOffset?{}:{x:n+c.x,y:a+c.y,data:{...c,placement:s}}}}},BC=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:o,placement:n,platform:a}=t,{mainAxis:s=!0,crossAxis:l=!1,limiter:c={fn:S=>{let{x,y:w}=S;return{x,y:w}}},...d}=Zr(e,t),p={x:r,y:o},u=await a.detectOverflow(t,d),f=Mr(n),h=Wi(f);let b=p[h],g=p[f];const y=(S,x)=>Rf(x+u[S==="y"?"top":"left"],x,x-u[S==="y"?"bottom":"right"]);s&&(b=y(h,b)),l&&(g=y(f,g));const v=c.fn({...t,[h]:b,[f]:g});return{...v,data:{x:v.x-r,y:v.y-o,enabled:{[h]:s,[f]:l}}}}}},UC=function(e){return e===void 0&&(e={}),{options:e,fn(t){var r,o;const{x:n,y:a,placement:s,rects:l,middlewareData:c}=t,{offset:d=0,mainAxis:p=!0,crossAxis:u=!0}=Zr(e,t),f={x:n,y:a},h=Mr(s),b=Wi(h);let g=f[b],y=f[h];const v=Zr(d,t),S=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:(r=v.mainAxis)!=null?r:0,crossAxis:(o=v.crossAxis)!=null?o:0};if(p){const N=b==="y"?"height":"width",k=l.reference[b]-l.floating[N]+S.mainAxis,_=l.reference[b]+l.reference[N]-S.mainAxis;g<k?g=k:g>_&&(g=_)}if(u){var x,w;const N=b==="y"?"width":"height",k=op.has(bo(s)),_=l.reference[h]-l.floating[N]+(k&&((x=c.offset)==null?void 0:x[h])||0)+(k?0:S.crossAxis),E=l.reference[h]+l.reference[N]+(k?0:((w=c.offset)==null?void 0:w[h])||0)-(k?S.crossAxis:0);y<_?y=_:y>E&&(y=E)}return{[b]:g,[h]:y}}}},WC=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){const{placement:r,rects:o,platform:n,elements:a}=t,{apply:s=()=>{},...l}=Zr(e,t),c=await n.detectOverflow(t,l),d=bo(r),p=dn(r),u=Mr(r)==="y",{width:f,height:h}=o.floating;let b,g;d==="top"||d==="bottom"?(b=d,g=p===(await(n.isRTL==null?void 0:n.isRTL(a.floating))?"start":"end")?"left":"right"):(g=d,b=p==="end"?"top":"bottom");const y=h-c.top-c.bottom,v=f-c.left-c.right,S=mo(h-c[b],y),x=mo(f-c[g],v),w=t.middlewareData.shift,N=!w;let k=S,_=x;w!=null&&w.enabled.x&&(_=v),w!=null&&w.enabled.y&&(k=y),N&&!p&&(u?_=f-2*Xr(c.left,c.right):k=h-2*Xr(c.top,c.bottom)),await s({...t,availableWidth:_,availableHeight:k});const E=await n.getDimensions(a.floating);return f!==E.width||h!==E.height?{reset:{rects:!0}}:{}}}};function fs(){return typeof window<"u"}function un(e){return np(e)?(e.nodeName||"").toLowerCase():"#document"}function Kt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function eo(e){var t;return(t=(np(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function np(e){return fs()?e instanceof Node||e instanceof Kt(e).Node:!1}function Or(e){return fs()?e instanceof Element||e instanceof Kt(e).Element:!1}function go(e){return fs()?e instanceof HTMLElement||e instanceof Kt(e).HTMLElement:!1}function ap(e){return!fs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Kt(e).ShadowRoot}function ps(e){const{overflow:t,overflowX:r,overflowY:o,display:n}=Ir(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+r)&&n!=="inline"&&n!=="contents"}function HC(e){return/^(table|td|th)$/.test(un(e))}function hs(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const jC=/transform|translate|scale|rotate|perspective|filter/,qC=/paint|layout|strict|content/,Lo=e=>!!e&&e!=="none";let Yi;function Qi(e){const t=Or(e)?Ir(e):e;return Lo(t.transform)||Lo(t.translate)||Lo(t.scale)||Lo(t.rotate)||Lo(t.perspective)||!Ki()&&(Lo(t.backdropFilter)||Lo(t.filter))||jC.test(t.willChange||"")||qC.test(t.contain||"")}function YC(e){let t=Fo(e);for(;go(t)&&!zn(t);){if(Qi(t))return t;if(hs(t))return null;t=Fo(t)}return null}function Ki(){return Yi==null&&(Yi=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Yi}function zn(e){return/^(html|body|#document)$/.test(un(e))}function Ir(e){return Kt(e).getComputedStyle(e)}function ms(e){return Or(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fo(e){if(un(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ap(e)&&e.host||eo(e);return ap(t)?t.host:t}function sp(e){const t=Fo(e);return zn(t)?(e.ownerDocument||e).body:go(t)&&ps(t)?t:sp(t)}function Bn(e,t,r){var o;t===void 0&&(t=[]),r===void 0&&(r=!0);const n=sp(e),a=n===((o=e.ownerDocument)==null?void 0:o.body),s=Kt(n);if(a){const l=Ri(s);return t.concat(s,s.visualViewport||[],ps(n)?n:[],l&&r?Bn(l):[])}else return t.concat(n,Bn(n,[],r))}function Ri(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function lp(e){const t=Ir(e);let r=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const n=go(e),a=n?e.offsetWidth:r,s=n?e.offsetHeight:o,l=is(r)!==a||is(o)!==s;return l&&(r=a,o=s),{width:r,height:o,$:l}}function Xi(e){return Or(e)?e:e.contextElement}function fn(e){const t=Xi(e);if(!go(t))return Jr(1);const r=t.getBoundingClientRect(),{width:o,height:n,$:a}=lp(t);let s=(a?is(r.width):r.width)/o,l=(a?is(r.height):r.height)/n;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const QC=Jr(0);function ip(e){const t=Kt(e);return!Ki()||!t.visualViewport?QC:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function KC(e,t,r){return t===void 0&&(t=!1),!!r&&t&&r===Kt(e)}function Vo(e,t,r,o){t===void 0&&(t=!1),r===void 0&&(r=!1);const n=e.getBoundingClientRect(),a=Xi(e);let s=Jr(1);t&&(o?Or(o)&&(s=fn(o)):s=fn(e));const l=KC(a,r,o)?ip(a):Jr(0);let c=(n.left+l.x)/s.x,d=(n.top+l.y)/s.y,p=n.width/s.x,u=n.height/s.y;if(a&&o){const f=Kt(a),h=Or(o)?Kt(o):o;let b=f,g=Ri(b);for(;g&&h!==b;){const y=fn(g),v=g.getBoundingClientRect(),S=Ir(g),x=v.left+(g.clientLeft+parseFloat(S.paddingLeft))*y.x,w=v.top+(g.clientTop+parseFloat(S.paddingTop))*y.y;c*=y.x,d*=y.y,p*=y.x,u*=y.y,c+=x,d+=w,b=Kt(g),g=Ri(b)}}return us({width:p,height:u,x:c,y:d})}function bs(e,t){const r=ms(e).scrollLeft;return t?t.left+r:Vo(eo(e)).left+r}function cp(e,t){const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-bs(e,r),n=r.top+t.scrollTop;return{x:o,y:n}}function RC(e){let{elements:t,rect:r,offsetParent:o,strategy:n}=e;const a=n==="fixed",s=eo(o),l=t?hs(t.floating):!1;if(o===s||l&&a)return r;let c={scrollLeft:0,scrollTop:0},d=Jr(1);const p=Jr(0),u=go(o);if((u||!a)&&((un(o)!=="body"||ps(s))&&(c=ms(o)),u)){const h=Vo(o);d=fn(o),p.x=h.x+o.clientLeft,p.y=h.y+o.clientTop}const f=s&&!u&&!a?cp(s,c):Jr(0);return{width:r.width*d.x,height:r.height*d.y,x:r.x*d.x-c.scrollLeft*d.x+p.x+f.x,y:r.y*d.y-c.scrollTop*d.y+p.y+f.y}}function XC(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function JC(e){const t=ms(e),r=e.ownerDocument.body,o=Xr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),n=Xr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let a=-t.scrollLeft+bs(e);const s=-t.scrollTop;return Ir(r).direction==="rtl"&&(a+=Xr(e.clientWidth,r.clientWidth)-o),{width:o,height:n,x:a,y:s}}const ZC=25;function eS(e,t,r){r===void 0&&(r="viewport");const o=r==="layoutViewport",n=Kt(e),a=eo(e),s=n.visualViewport;let l=a.clientWidth,c=a.clientHeight,d=0,p=0;if(s){const f=!Ki()||t==="fixed";o?f||(d=-s.offsetLeft,p=-s.offsetTop):(l=s.width,c=s.height,f&&(d=s.offsetLeft,p=s.offsetTop))}if(bs(a)<=0){const f=a.ownerDocument,h=f.body,b=getComputedStyle(h),g=f.compatMode==="CSS1Compat"&&parseFloat(b.marginLeft)+parseFloat(b.marginRight)||0,y=Math.abs(a.clientWidth-h.clientWidth-g),v=getComputedStyle(a).scrollbarGutter==="stable both-edges"?y/2:y;v<=ZC&&(l-=v)}return{width:l,height:c,x:d,y:p}}function tS(e,t){const r=Vo(e,!0,t==="fixed"),o=r.top+e.clientTop,n=r.left+e.clientLeft,a=fn(e),s=e.clientWidth*a.x,l=e.clientHeight*a.y,c=n*a.x,d=o*a.y;return{width:s,height:l,x:c,y:d}}function dp(e,t,r){let o;if(t==="viewport"||t==="layoutViewport")o=eS(e,r,t);else if(t==="document")o=JC(eo(e));else if(Or(t))o=tS(t,r);else{const n=ip(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return us(o)}function rS(e,t){const r=t.get(e);if(r)return r;let o=Bn(e,[],!1).filter(l=>Or(l)&&un(l)!=="body"),n=null;const a=Ir(e).position==="fixed";let s=a?Fo(e):e;for(;Or(s)&&!zn(s);){const l=Ir(s),c=Qi(s),d=n?n.position:a?"fixed":"";!c&&(d==="fixed"||d==="absolute"&&l.position==="static")?o=o.filter(u=>u!==s):n=l,s=Fo(s)}return t.set(e,o),o}function oS(e){let{element:t,boundary:r,rootBoundary:o,strategy:n}=e;const s=[...r==="clippingAncestors"?hs(t)?[]:rS(t,this._c):[].concat(r),o],l=dp(t,s[0],n);let c=l.top,d=l.right,p=l.bottom,u=l.left;for(let f=1;f<s.length;f++){const h=dp(t,s[f],n);c=Xr(h.top,c),d=mo(h.right,d),p=mo(h.bottom,p),u=Xr(h.left,u)}return{width:d-u,height:p-c,x:u,y:c}}function nS(e){const{width:t,height:r}=lp(e);return{width:t,height:r}}function aS(e,t,r){const o=go(t),n=eo(t),a=r==="fixed",s=Vo(e,!0,a,t);let l={scrollLeft:0,scrollTop:0};const c=Jr(0);if((o||!a)&&((un(t)!=="body"||ps(n))&&(l=ms(t)),o)){const f=Vo(t,!0,a,t);c.x=f.x+t.clientLeft,c.y=f.y+t.clientTop}!o&&n&&(c.x=bs(n));const d=n&&!o&&!a?cp(n,l):Jr(0),p=s.left+l.scrollLeft-c.x-d.x,u=s.top+l.scrollTop-c.y-d.y;return{x:p,y:u,width:s.width,height:s.height}}function Ji(e){return Ir(e).position==="static"}function up(e,t){if(!go(e)||Ir(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return eo(e)===r&&(r=r.ownerDocument.body),r}function fp(e,t){const r=Kt(e);if(hs(e))return r;if(!go(e)){let n=Fo(e);for(;n&&!zn(n);){if(Or(n)&&!Ji(n))return n;n=Fo(n)}return r}let o=up(e,t);for(;o&&HC(o)&&Ji(o);)o=up(o,t);return o&&zn(o)&&Ji(o)&&!Qi(o)?r:o||YC(e)||r}const sS=async function(e){const t=this.getOffsetParent||fp,r=this.getDimensions,o=await r(e.floating);return{reference:aS(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function lS(e){return Ir(e).direction==="rtl"}const iS={convertOffsetParentRelativeRectToViewportRelativeRect:RC,getDocumentElement:eo,getClippingRect:oS,getOffsetParent:fp,getElementRects:sS,getClientRects:XC,getDimensions:nS,getScale:fn,isElement:Or,isRTL:lS};function pp(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function cS(e,t,r){let o=null,n;const a=eo(e);function s(){var p;clearTimeout(n),(p=o)==null||p.disconnect(),o=null}function l(p,u){p===void 0&&(p=!1),u===void 0&&(u=1),s();const f=e.getBoundingClientRect(),{left:h,top:b,width:g,height:y}=f;if(p||t(),!g||!y)return;const v=cs(b),S=cs(a.clientWidth-(h+g)),x=cs(a.clientHeight-(b+y)),w=cs(h),k={rootMargin:-v+"px "+-S+"px "+-x+"px "+-w+"px",threshold:Xr(0,mo(1,u))||1};let _=!0;function E(D){const T=D[0].intersectionRatio;if(!pp(f,e.getBoundingClientRect()))return l();if(T!==u){if(!_)return l();T?l(!1,T):n=setTimeout(()=>{l(!1,1e-7)},1e3)}_=!1}try{o=new IntersectionObserver(E,{...k,root:a.ownerDocument})}catch{o=new IntersectionObserver(E,k)}o.observe(e)}const c=Kt(e),d=()=>l(r);return c.addEventListener("resize",d),l(!0),()=>{c.removeEventListener("resize",d),s()}}function dS(e,t,r,o){o===void 0&&(o={});const{ancestorScroll:n=!0,ancestorResize:a=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,d=Xi(e),p=n||a?[...d?Bn(d):[],...t?Bn(t):[]]:[];p.forEach(v=>{n&&v.addEventListener("scroll",r),a&&v.addEventListener("resize",r)});const u=d&&l?cS(d,r,a):null;let f=-1,h=null;s&&(h=new ResizeObserver(v=>{let[S]=v;S&&S.target===d&&h&&t&&(h.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(t)})),r()}),d&&!c&&h.observe(d),t&&h.observe(t));let b,g=c?Vo(e):null;c&&y();function y(){const v=Vo(e);g&&!pp(g,v)&&r(),g=v,b=requestAnimationFrame(y)}return r(),()=>{var v;p.forEach(S=>{n&&S.removeEventListener("scroll",r),a&&S.removeEventListener("resize",r)}),u==null||u(),(v=h)==null||v.disconnect(),h=null,c&&cancelAnimationFrame(b)}}const uS=zC,fS=BC,pS=FC,hS=WC,mS=VC,hp=LC,bS=UC,gS=(e,t,r)=>{const o=new Map,n=r??{},a={...iS,...n.platform,_c:o};return IC(e,t,{...n,platform:a})};var yS=typeof document<"u",vS=function(){},gs=yS?P.useLayoutEffect:vS;function ys(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,o,n;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(o=r;o--!==0;)if(!ys(e[o],t[o]))return!1;return!0}if(n=Object.keys(e),r=n.length,r!==Object.keys(t).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(t,n[o]))return!1;for(o=r;o--!==0;){const a=n[o];if(!(a==="_owner"&&e.$$typeof)&&!ys(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function mp(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function bp(e,t){const r=mp(e);return Math.round(t*r)/r}function Zi(e){const t=C.useRef(e);return gs(()=>{t.current=e}),t}function wS(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:o=[],platform:n,elements:{reference:a,floating:s}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[p,u]=C.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[f,h]=C.useState(o);ys(f,o)||h(o);const[b,g]=C.useState(null),[y,v]=C.useState(null),S=C.useCallback(J=>{J!==k.current&&(k.current=J,g(J))},[]),x=C.useCallback(J=>{J!==_.current&&(_.current=J,v(J))},[]),w=a||b,N=s||y,k=C.useRef(null),_=C.useRef(null),E=C.useRef(p),D=c!=null,T=Zi(c),O=Zi(n),$=Zi(d),V=C.useCallback(()=>{if(!k.current||!_.current)return;const J={placement:t,strategy:r,middleware:f};O.current&&(J.platform=O.current),gS(k.current,_.current,J).then(W=>{const R={...W,isPositioned:$.current!==!1};G.current&&!ys(E.current,R)&&(E.current=R,Pn.flushSync(()=>{u(R)}))})},[f,t,r,O,$]);gs(()=>{d===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,u(J=>({...J,isPositioned:!1})))},[d]);const G=C.useRef(!1);gs(()=>(G.current=!0,()=>{G.current=!1}),[]),gs(()=>{if(w&&(k.current=w),N&&(_.current=N),w&&N){if(T.current)return T.current(w,N,V);V()}},[w,N,V,T,D]);const q=C.useMemo(()=>({reference:k,floating:_,setReference:S,setFloating:x}),[S,x]),H=C.useMemo(()=>({reference:w,floating:N}),[w,N]),Y=C.useMemo(()=>{const J={position:r,left:0,top:0};if(!H.floating)return J;const W=bp(H.floating,p.x),R=bp(H.floating,p.y);return l?{...J,transform:"translate("+W+"px, "+R+"px)",...mp(H.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:W,top:R}},[r,l,H.floating,p.x,p.y]);return C.useMemo(()=>({...p,update:V,refs:q,elements:H,floatingStyles:Y}),[p,V,q,H,Y])}const xS=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:o,padding:n}=typeof e=="function"?e(r):e;return o&&t(o)?o.current!=null?hp({element:o.current,padding:n}).fn(r):{}:o?hp({element:o,padding:n}).fn(r):{}}}},CS=(e,t)=>{const r=uS(e);return{name:r.name,fn:r.fn,options:[e,t]}},SS=(e,t)=>{const r=fS(e);return{name:r.name,fn:r.fn,options:[e,t]}},NS=(e,t)=>({fn:bS(e).fn,options:[e,t]}),ES=(e,t)=>{const r=pS(e);return{name:r.name,fn:r.fn,options:[e,t]}},kS=(e,t)=>{const r=hS(e);return{name:r.name,fn:r.fn,options:[e,t]}},AS=(e,t)=>{const r=mS(e);return{name:r.name,fn:r.fn,options:[e,t]}},_S=(e,t)=>{const r=xS(e);return{name:r.name,fn:r.fn,options:[e,t]}};var TS=Object.defineProperty,DS=(e,t)=>TS(e,"name",{value:t,configurable:!0});function ec(e){const[t,r]=C.useState(void 0);return ut(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(n=>{if(!Array.isArray(n)||!n.length)return;const a=n[0];let s,l;if("borderBoxSize"in a){const c=a.borderBoxSize,d=Array.isArray(c)?c[0]:c;s=d.inlineSize,l=d.blockSize}else s=e.offsetWidth,l=e.offsetHeight;r({width:s,height:l})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else r(void 0)},[e]),t}DS(ec,"useSize");var $S=Object.defineProperty,yo=(e,t)=>$S(e,"name",{value:t,configurable:!0}),gp="Popper",[yp,vs]=ur(gp),[PS,vp]=yp(gp),MS=yo(e=>{const{__scopePopper:t,children:r}=e,[o,n]=C.useState(null),[a,s]=C.useState(void 0);return i.jsx(PS,{scope:t,anchor:o,onAnchorChange:n,placementState:a,setPlacementState:s,children:r})},"Popper"),OS="PopperAnchor",IS=C.forwardRef(yo(function(t,r){const{__scopePopper:o,virtualRef:n,...a}=t,s=vp(OS,o),l=C.useRef(null),c=s.onAnchorChange,d=C.useCallback(g=>{l.current=g,g&&c(g)},[c]),p=Re(r,d),u=C.useRef(null);C.useEffect(()=>{if(!n)return;const g=u.current;u.current=n.current,g!==u.current&&c(u.current)});const f=s.placementState&&ws(s.placementState),h=f==null?void 0:f[0],b=f==null?void 0:f[1];return n?null:i.jsx(Be.div,{"data-radix-popper-side":h,"data-radix-popper-align":b,...a,ref:p})},"PopperAnchor")),wp="PopperContent",[LS,N2]=yp(wp),FS=C.forwardRef(yo(function(t,r){var ce,Ie,xe,be,ae,ue,ve;const{__scopePopper:o,side:n="bottom",sideOffset:a=0,align:s="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:p=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:b="optimized",onPlaced:g,...y}=t,v=vp(wp,o),[S,x]=C.useState(null),w=Re(r,x),[N,k]=C.useState(null),_=ec(N),E=(_==null?void 0:_.width)??0,D=(_==null?void 0:_.height)??0,T=n+(s!=="center"?"-"+s:""),O=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},$=Array.isArray(p)?p:[p],V=$.length>0,G={padding:O,boundary:$.filter(xp),altBoundary:V},{refs:q,floatingStyles:H,placement:Y,isPositioned:J,middlewareData:W}=wS({strategy:"fixed",placement:T,whileElementsMounted:yo((...Oe)=>dS(...Oe,{animationFrame:b==="always"}),"whileElementsMounted"),elements:{reference:v.anchor},middleware:[CS({mainAxis:a+D,alignmentAxis:l}),d&&SS({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?NS():void 0,...G}),d&&ES({...G}),kS({...G,apply:yo(({elements:Oe,rects:et,availableWidth:at,availableHeight:it})=>{const{width:tt,height:$e}=et.reference,yt=Oe.floating.style;yt.setProperty("--radix-popper-available-width",`${at}px`),yt.setProperty("--radix-popper-available-height",`${it}px`),yt.setProperty("--radix-popper-anchor-width",`${tt}px`),yt.setProperty("--radix-popper-anchor-height",`${$e}px`)},"apply")}),N&&_S({element:N,padding:c}),VS({arrowWidth:E,arrowHeight:D}),h&&AS({strategy:"referenceHidden",...G,boundary:V?G.boundary:void 0})]}),R=v.setPlacementState;ut(()=>(R(Y),()=>{R(void 0)}),[Y,R]);const[we,Q]=ws(Y),te=wr(g);ut(()=>{J&&(te==null||te())},[J,te]);const De=(ce=W.arrow)==null?void 0:ce.x,de=(Ie=W.arrow)==null?void 0:Ie.y,Se=((xe=W.arrow)==null?void 0:xe.centerOffset)!==0,[re,me]=C.useState();return ut(()=>{S&&me(window.getComputedStyle(S).zIndex)},[S]),i.jsx("div",{ref:q.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:J?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:re,"--radix-popper-transform-origin":[(be=W.transformOrigin)==null?void 0:be.x,(ae=W.transformOrigin)==null?void 0:ae.y].join(" "),...((ue=W.hide)==null?void 0:ue.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:i.jsx(LS,{scope:o,placedSide:we,placedAlign:Q,onArrowChange:k,arrowX:De,arrowY:de,shouldHideArrow:Se,children:i.jsx(Be.div,{"data-side":we,"data-align":Q,...y,ref:w,style:{...y.style,animation:J?(ve=y.style)==null?void 0:ve.animation:"none"}})})})},"PopperContent"));function xp(e){return e!==null}yo(xp,"isNotNull");var VS=yo(e=>({name:"transformOrigin",options:e,fn(t){var y,v,S;const{placement:r,rects:o,middlewareData:n}=t,s=((y=n.arrow)==null?void 0:y.centerOffset)!==0,l=s?0:e.arrowWidth,c=s?0:e.arrowHeight,[d,p]=ws(r),u={start:"0%",center:"50%",end:"100%"}[p],f=(((v=n.arrow)==null?void 0:v.x)??0)+l/2,h=(((S=n.arrow)==null?void 0:S.y)??0)+c/2;let b="",g="";return d==="bottom"?(b=s?u:`${f}px`,g=`${-c}px`):d==="top"?(b=s?u:`${f}px`,g=`${o.floating.height+c}px`):d==="right"?(b=`${-c}px`,g=s?u:`${h}px`):d==="left"&&(b=`${o.floating.width+c}px`,g=s?u:`${h}px`),{data:{x:b,y:g}}}}),"transformOrigin");function ws(e){const[t,r="center"]=e.split("-");return[t,r]}yo(ws,"getSideAndAlignFromPlacement");var Cp=MS,Sp=IS,Np=FS,GS=Object.defineProperty,zS=(e,t)=>GS(e,"name",{value:t,configurable:!0}),tc=C.forwardRef(zS(function(t,r){var c;const{container:o,...n}=t,[a,s]=C.useState(!1);ut(()=>s(!0),[]);const l=o||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return l?Pn.createPortal(i.jsx(Be.div,{...n,ref:r}),l):null},"Portal")),BS=Object.defineProperty,to=(e,t)=>BS(e,"name",{value:t,configurable:!0});function Ep(e,t){return C.useReducer((r,o)=>t[r][o]??r,e)}to(Ep,"useStateMachine");var ro=to(e=>{const{present:t,children:r}=e,o=kp(t),n=typeof r=="function"?r({present:o.isPresent}):C.Children.only(r),a=Ap(o.ref,_p(n));return typeof r=="function"||o.isPresent?C.cloneElement(n,{ref:a}):null},"Presence");function kp(e){const[t,r]=C.useState(),o=C.useRef(null),n=C.useRef(e),a=C.useRef("none"),s=C.useRef(void 0),l=e?"mounted":"unmounted",[c,d]=Ep(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return C.useEffect(()=>{c==="mounted"?(a.current=s.current??pn(o.current),s.current=void 0):a.current="none"},[c]),ut(()=>{const p=o.current,u=n.current;if(u!==e){const h=a.current,b=pn(p);e?(s.current=b,d("MOUNT")):b==="none"||(p==null?void 0:p.display)==="none"?d("UNMOUNT"):d(u&&h!==b?"ANIMATION_OUT":"UNMOUNT"),n.current=e}},[e,d]),ut(()=>{if(t){let p;const u=t.ownerDocument.defaultView??window,f=to(b=>{const y=pn(o.current).includes(CSS.escape(b.animationName));if(b.target===t&&y&&(d("ANIMATION_END"),!n.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",p=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},"handleAnimationEnd"),h=to(b=>{b.target===t&&(a.current=pn(o.current))},"handleAnimationStart");return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{u.clearTimeout(p),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:C.useCallback(p=>{if(p){const u=getComputedStyle(p);o.current=u,s.current=pn(u)}else o.current=null;r(p)},[])}}to(kp,"usePresence");function rc(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}to(rc,"setRef");function Ap(...e){const t=C.useRef(e);return t.current=e,C.useCallback(r=>{const o=t.current;let n=!1;const a=o.map(s=>{const l=rc(s,r);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let s=0;s<a.length;s++){const l=a[s];typeof l=="function"?l():rc(o[s],null)}}},[])}to(Ap,"useStableComposedRefs");function pn(e){return(e==null?void 0:e.animationName)||"none"}to(pn,"getAnimationName");function _p(e){var o,n;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(n=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}to(_p,"getElementRef");var US=Object.defineProperty,WS=(e,t)=>US(e,"name",{value:t,configurable:!0}),Tp=C[" useEffectEvent ".trim().toString()],Dp=C[" useInsertionEffect ".trim().toString()];function $p(e){if(typeof Tp=="function")return Tp(e);const t=C.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Dp=="function"?Dp(()=>{t.current=e}):ut(()=>{t.current=e}),C.useMemo(()=>((...r)=>{var o;return(o=t.current)==null?void 0:o.call(t,...r)}),[])}WS($p,"useEffectEvent");var HS=Object.defineProperty,Un=(e,t)=>HS(e,"name",{value:t,configurable:!0}),jS=C[" useInsertionEffect ".trim().toString()]||ut;function Cr({prop:e,defaultProp:t,onChange:r=Un(()=>{},"onChange"),caller:o}){const[n,a,s]=Pp({defaultProp:t,onChange:r}),l=e!==void 0,c=l?e:n,d=C.useCallback(p=>{var u;if(l){const f=Mp(p)?p(e):p;f!==e&&((u=s.current)==null||u.call(s,f))}else a(p)},[l,e,a,s]);return[c,d]}Un(Cr,"useControllableState");function Pp({defaultProp:e,onChange:t}){const[r,o]=C.useState(e),n=C.useRef(r),a=C.useRef(t);return jS(()=>{a.current=t},[t]),C.useEffect(()=>{var s;n.current!==r&&((s=a.current)==null||s.call(a,r),n.current=r)},[r,n]),[r,o,a]}Un(Pp,"useUncontrolledState");function Mp(e){return typeof e=="function"}Un(Mp,"isFunction");var Op=Symbol("RADIX:SYNC_STATE");function qS(e,t,r,o){const{prop:n,defaultProp:a,onChange:s,caller:l}=t,c=n!==void 0,d=$p(s),p=[{...r,state:a}];o&&p.push(o);const[u,f]=C.useReducer((y,v)=>{if(v.type===Op)return{...y,state:v.state};const S=e(y,v);return c&&!Object.is(S.state,y.state)&&d(S.state),S},...p),h=u.state,b=C.useRef(h);C.useEffect(()=>{b.current!==h&&(b.current=h,c||d(h))},[h,b,c]);const g=C.useMemo(()=>n!==void 0?{...u,state:n}:u,[u,n]);return C.useEffect(()=>{c&&!Object.is(n,u.state)&&f({type:Op,state:n})},[n,u.state,c]),[g,f]}Un(qS,"useControllableStateReducer");var YS=Object.defineProperty,QS=(e,t)=>YS(e,"name",{value:t,configurable:!0});function Ip(e){const t=C.useRef({value:e,previous:e});return C.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}QS(Ip,"usePrevious");var KS=Object.defineProperty,RS=(e,t)=>KS(e,"name",{value:t,configurable:!0}),Lp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),XS=C.forwardRef(RS(function(t,r){return i.jsx(Be.span,{...t,ref:r,style:{...Lp,...t.style}})},"VisuallyHidden")),JS=XS,ZS=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},hn=new WeakMap,xs=new WeakMap,Cs={},oc=0,Fp=function(e){return e&&(e.host||Fp(e.parentNode))},eN=function(e,t){return t.map(function(r){if(e.contains(r))return r;var o=Fp(r);return o&&e.contains(o)?o:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},tN=function(e,t,r,o){var n=eN(t,Array.isArray(e)?e:[e]);Cs[r]||(Cs[r]=new WeakMap);var a=Cs[r],s=[],l=new Set,c=new Set(n),d=function(u){!u||l.has(u)||(l.add(u),d(u.parentNode))};n.forEach(d);var p=function(u){!u||c.has(u)||Array.prototype.forEach.call(u.children,function(f){if(l.has(f))p(f);else try{var h=f.getAttribute(o),b=h!==null&&h!=="false",g=(hn.get(f)||0)+1,y=(a.get(f)||0)+1;hn.set(f,g),a.set(f,y),s.push(f),g===1&&b&&xs.set(f,!0),y===1&&f.setAttribute(r,"true"),b||f.setAttribute(o,"true")}catch(v){console.error("aria-hidden: cannot operate on ",f,v)}})};return p(t),l.clear(),oc++,function(){s.forEach(function(u){var f=hn.get(u)-1,h=a.get(u)-1;hn.set(u,f),a.set(u,h),f||(xs.has(u)||u.removeAttribute(o),xs.delete(u)),h||u.removeAttribute(r)}),oc--,oc||(hn=new WeakMap,hn=new WeakMap,xs=new WeakMap,Cs={})}},Vp=function(e,t,r){r===void 0&&(r="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),n=ZS(e);return n?(o.push.apply(o,Array.from(n.querySelectorAll("[aria-live], script"))),tN(o,n,r,"aria-hidden")):function(){return null}},Lr=function(){return Lr=Object.assign||function(t){for(var r,o=1,n=arguments.length;o<n;o++){r=arguments[o];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},Lr.apply(this,arguments)};function Gp(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r}function rN(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,a;o<n;o++)(a||!(o in t))&&(a||(a=Array.prototype.slice.call(t,0,o)),a[o]=t[o]);return e.concat(a||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;var Ss="right-scroll-bar-position",Ns="width-before-scroll-bar",oN="with-scroll-bars-hidden",nN="--removed-body-scroll-bar-size";function nc(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function aN(e,t){var r=P.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(o){var n=r.value;n!==o&&(r.value=o,r.callback(o,n))}}}})[0];return r.callback=t,r.facade}var sN=typeof window<"u"?C.useLayoutEffect:C.useEffect,zp=new WeakMap;function lN(e,t){var r=aN(null,function(o){return e.forEach(function(n){return nc(n,o)})});return sN(function(){var o=zp.get(r);if(o){var n=new Set(o),a=new Set(e),s=r.current;n.forEach(function(l){a.has(l)||nc(l,null)}),a.forEach(function(l){n.has(l)||nc(l,s)})}zp.set(r,e)},[e]),r}function iN(e){return e}function cN(e,t){t===void 0&&(t=iN);var r=[],o=!1,n={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(a){var s=t(a,o);return r.push(s),function(){r=r.filter(function(l){return l!==s})}},assignSyncMedium:function(a){for(o=!0;r.length;){var s=r;r=[],s.forEach(a)}r={push:function(l){return a(l)},filter:function(){return r}}},assignMedium:function(a){o=!0;var s=[];if(r.length){var l=r;r=[],l.forEach(a),s=r}var c=function(){var p=s;s=[],p.forEach(a)},d=function(){return Promise.resolve().then(c)};d(),r={push:function(p){s.push(p),d()},filter:function(p){return s=s.filter(p),r}}}};return n}function dN(e){e===void 0&&(e={});var t=cN(null);return t.options=Lr({async:!0,ssr:!1},e),t}var Bp=function(e){var t=e.sideCar,r=Gp(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return C.createElement(o,Lr({},r))};Bp.isSideCarExport=!0;function uN(e,t){return e.useMedium(t),Bp}var Up=dN(),ac=function(){},Es=C.forwardRef(function(e,t){var r=C.useRef(null),o=C.useState({onScrollCapture:ac,onWheelCapture:ac,onTouchMoveCapture:ac}),n=o[0],a=o[1],s=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,p=e.enabled,u=e.shards,f=e.sideCar,h=e.noRelative,b=e.noIsolation,g=e.inert,y=e.allowPinchZoom,v=e.as,S=v===void 0?"div":v,x=e.gapMode,w=Gp(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=f,k=lN([r,t]),_=Lr(Lr({},w),n);return C.createElement(C.Fragment,null,p&&C.createElement(N,{sideCar:Up,removeScrollBar:d,shards:u,noRelative:h,noIsolation:b,inert:g,setCallbacks:a,allowPinchZoom:!!y,lockRef:r,gapMode:x}),s?C.cloneElement(C.Children.only(l),Lr(Lr({},_),{ref:k})):C.createElement(S,Lr({},_,{className:c,ref:k}),l))});Es.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Es.classNames={fullWidth:Ns,zeroRight:Ss};var fN=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function pN(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=fN();return t&&e.setAttribute("nonce",t),e}function hN(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function mN(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var bN=function(){var e=0,t=null;return{add:function(r){e==0&&(t=pN())&&(hN(t,r),mN(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},gN=function(){var e=bN();return function(t,r){C.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},Wp=function(){var e=gN(),t=function(r){var o=r.styles,n=r.dynamic;return e(o,n),null};return t},yN={left:0,top:0,right:0,gap:0},sc=function(e){return parseInt(e||"",10)||0},vN=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],n=t[e==="padding"?"paddingRight":"marginRight"];return[sc(r),sc(o),sc(n)]},wN=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return yN;var t=vN(e),r=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-r+t[2]-t[0])}},xN=Wp(),mn="data-scroll-locked",CN=function(e,t,r,o){var n=e.left,a=e.top,s=e.right,l=e.gap;return r===void 0&&(r="margin"),`
7
+ .`.concat(oN,` {
3
8
  overflow: hidden `).concat(o,`;
4
- padding-right: `).concat(i,"px ").concat(o,`;
9
+ padding-right: `).concat(l,"px ").concat(o,`;
5
10
  }
6
- body[`).concat(un,`] {
11
+ body[`).concat(mn,`] {
7
12
  overflow: hidden `).concat(o,`;
8
13
  overscroll-behavior: contain;
9
14
  `).concat([t&&"position: relative ".concat(o,";"),r==="margin"&&`
10
15
  padding-left: `.concat(n,`px;
11
- padding-top: `).concat(s,`px;
12
- padding-right: `).concat(a,`px;
16
+ padding-top: `).concat(a,`px;
17
+ padding-right: `).concat(s,`px;
13
18
  margin-left:0;
14
19
  margin-top:0;
15
- margin-right: `).concat(i,"px ").concat(o,`;
16
- `),r==="padding"&&"padding-right: ".concat(i,"px ").concat(o,";")].filter(Boolean).join(""),`
20
+ margin-right: `).concat(l,"px ").concat(o,`;
21
+ `),r==="padding"&&"padding-right: ".concat(l,"px ").concat(o,";")].filter(Boolean).join(""),`
17
22
  }
18
23
 
19
- .`).concat(Na,` {
20
- right: `).concat(i,"px ").concat(o,`;
24
+ .`).concat(Ss,` {
25
+ right: `).concat(l,"px ").concat(o,`;
21
26
  }
22
27
 
23
- .`).concat(Ca,` {
24
- margin-right: `).concat(i,"px ").concat(o,`;
28
+ .`).concat(Ns,` {
29
+ margin-right: `).concat(l,"px ").concat(o,`;
25
30
  }
26
31
 
27
- .`).concat(Na," .").concat(Na,` {
32
+ .`).concat(Ss," .").concat(Ss,` {
28
33
  right: 0 `).concat(o,`;
29
34
  }
30
35
 
31
- .`).concat(Ca," .").concat(Ca,` {
36
+ .`).concat(Ns," .").concat(Ns,` {
32
37
  margin-right: 0 `).concat(o,`;
33
38
  }
34
39
 
35
- body[`).concat(un,`] {
36
- `).concat(RN,": ").concat(i,`px;
40
+ body[`).concat(mn,`] {
41
+ `).concat(nN,": ").concat(l,`px;
37
42
  }
38
- `)},Wp=function(){var e=parseInt(document.body.getAttribute(un)||"0",10);return isFinite(e)?e:0},mC=function(){S.useEffect(function(){return document.body.setAttribute(un,(Wp()+1).toString()),function(){var e=Wp()-1;e<=0?document.body.removeAttribute(un):document.body.setAttribute(un,e.toString())}},[])},gC=function(e){var t=e.noRelative,r=e.noImportant,o=e.gapMode,n=o===void 0?"margin":o;mC();var s=S.useMemo(function(){return fC(n)},[n]);return S.createElement(pC,{styles:hC(s,!t,n,r?"":"!important")})},lc=!1;if(typeof window<"u")try{var _a=Object.defineProperty({},"passive",{get:function(){return lc=!0,!0}});window.addEventListener("test",_a,_a),window.removeEventListener("test",_a,_a)}catch{lc=!1}var fn=lc?{passive:!1}:!1,bC=function(e){return e.tagName==="TEXTAREA"},Hp=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!bC(e)&&r[t]==="visible")},yC=function(e){return Hp(e,"overflowY")},vC=function(e){return Hp(e,"overflowX")},jp=function(e,t){var r=t.ownerDocument,o=t;do{typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(o=o.host);var n=qp(e,o);if(n){var s=Yp(e,o),a=s[1],i=s[2];if(a>i)return!0}o=o.parentNode}while(o&&o!==r.body);return!1},xC=function(e){var t=e.scrollTop,r=e.scrollHeight,o=e.clientHeight;return[t,r,o]},wC=function(e){var t=e.scrollLeft,r=e.scrollWidth,o=e.clientWidth;return[t,r,o]},qp=function(e,t){return e==="v"?yC(t):vC(t)},Yp=function(e,t){return e==="v"?xC(t):wC(t)},SC=function(e,t){return e==="h"&&t==="rtl"?-1:1},NC=function(e,t,r,o,n){var s=SC(e,window.getComputedStyle(t).direction),a=s*o,i=r.target,c=t.contains(i),d=!1,p=a>0,u=0,f=0;do{if(!i)break;var h=Yp(e,i),g=h[0],y=h[1],b=h[2],v=y-b-s*g;(g||v)&&qp(e,i)&&(u+=v,f+=g);var N=i.parentNode;i=N&&N.nodeType===Node.DOCUMENT_FRAGMENT_NODE?N.host:N}while(!c&&i!==document.body||c&&(t.contains(i)||t===i));return(p&&Math.abs(u)<1||!p&&Math.abs(f)<1)&&(d=!0),d},ka=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Qp=function(e){return[e.deltaX,e.deltaY]},Kp=function(e){return e&&"current"in e?e.current:e},CC=function(e,t){return e[0]===t[0]&&e[1]===t[1]},EC=function(e){return`
43
+ `)},Hp=function(){var e=parseInt(document.body.getAttribute(mn)||"0",10);return isFinite(e)?e:0},SN=function(){C.useEffect(function(){return document.body.setAttribute(mn,(Hp()+1).toString()),function(){var e=Hp()-1;e<=0?document.body.removeAttribute(mn):document.body.setAttribute(mn,e.toString())}},[])},NN=function(e){var t=e.noRelative,r=e.noImportant,o=e.gapMode,n=o===void 0?"margin":o;SN();var a=C.useMemo(function(){return wN(n)},[n]);return C.createElement(xN,{styles:CN(a,!t,n,r?"":"!important")})},lc=!1;if(typeof window<"u")try{var ks=Object.defineProperty({},"passive",{get:function(){return lc=!0,!0}});window.addEventListener("test",ks,ks),window.removeEventListener("test",ks,ks)}catch{lc=!1}var bn=lc?{passive:!1}:!1,EN=function(e){return e.tagName==="TEXTAREA"},jp=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!EN(e)&&r[t]==="visible")},kN=function(e){return jp(e,"overflowY")},AN=function(e){return jp(e,"overflowX")},qp=function(e,t){var r=t.ownerDocument,o=t;do{typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(o=o.host);var n=Yp(e,o);if(n){var a=Qp(e,o),s=a[1],l=a[2];if(s>l)return!0}o=o.parentNode}while(o&&o!==r.body);return!1},_N=function(e){var t=e.scrollTop,r=e.scrollHeight,o=e.clientHeight;return[t,r,o]},TN=function(e){var t=e.scrollLeft,r=e.scrollWidth,o=e.clientWidth;return[t,r,o]},Yp=function(e,t){return e==="v"?kN(t):AN(t)},Qp=function(e,t){return e==="v"?_N(t):TN(t)},DN=function(e,t){return e==="h"&&t==="rtl"?-1:1},$N=function(e,t,r,o,n){var a=DN(e,window.getComputedStyle(t).direction),s=a*o,l=r.target,c=t.contains(l),d=!1,p=s>0,u=0,f=0;do{if(!l)break;var h=Qp(e,l),b=h[0],g=h[1],y=h[2],v=g-y-a*b;(b||v)&&Yp(e,l)&&(u+=v,f+=b);var S=l.parentNode;l=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(p&&Math.abs(u)<1||!p&&Math.abs(f)<1)&&(d=!0),d},As=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Kp=function(e){return[e.deltaX,e.deltaY]},Rp=function(e){return e&&"current"in e?e.current:e},PN=function(e,t){return e[0]===t[0]&&e[1]===t[1]},MN=function(e){return`
39
44
  .block-interactivity-`.concat(e,` {pointer-events: none;}
40
45
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
41
- `)},_C=0,pn=[];function kC(e){var t=S.useRef([]),r=S.useRef([0,0]),o=S.useRef(),n=S.useState(_C++)[0],s=S.useState(Up)[0],a=S.useRef(e);S.useEffect(function(){a.current=e},[e]),S.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(n));var y=QN([e.lockRef.current],(e.shards||[]).map(Kp),!0).filter(Boolean);return y.forEach(function(b){return b.classList.add("allow-interactivity-".concat(n))}),function(){document.body.classList.remove("block-interactivity-".concat(n)),y.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(n))})}}},[e.inert,e.lockRef.current,e.shards]);var i=S.useCallback(function(y,b){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!a.current.allowPinchZoom;var v=ka(y),N=r.current,x="deltaX"in y?y.deltaX:N[0]-v[0],w="deltaY"in y?y.deltaY:N[1]-v[1],C,E=y.target,k=Math.abs(x)>Math.abs(w)?"h":"v";if("touches"in y&&k==="h"&&E.type==="range")return!1;var _=window.getSelection(),D=_&&_.anchorNode,A=D?D===E||D.contains(E):!1;if(A)return!1;var I=jp(k,E);if(!I)return!0;if(I?C=k:(C=k==="v"?"h":"v",I=jp(k,E)),!I)return!1;if(!o.current&&"changedTouches"in y&&(x||w)&&(o.current=C),!C)return!0;var T=o.current||C;return NC(T,b,y,T==="h"?x:w)},[]),c=S.useCallback(function(y){var b=y;if(!(!pn.length||pn[pn.length-1]!==s)){var v="deltaY"in b?Qp(b):ka(b),N=t.current.filter(function(C){return C.name===b.type&&(C.target===b.target||b.target===C.shadowParent)&&CC(C.delta,v)})[0];if(N&&N.should){b.cancelable&&b.preventDefault();return}if(!N){var x=(a.current.shards||[]).map(Kp).filter(Boolean).filter(function(C){return C.contains(b.target)}),w=x.length>0?i(b,x[0]):!a.current.noIsolation;w&&b.cancelable&&b.preventDefault()}}},[]),d=S.useCallback(function(y,b,v,N){var x={name:y,delta:b,target:v,should:N,shadowParent:AC(v)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(w){return w!==x})},1)},[]),p=S.useCallback(function(y){r.current=ka(y),o.current=void 0},[]),u=S.useCallback(function(y){d(y.type,Qp(y),y.target,i(y,e.lockRef.current))},[]),f=S.useCallback(function(y){d(y.type,ka(y),y.target,i(y,e.lockRef.current))},[]);S.useEffect(function(){return pn.push(s),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:f}),document.addEventListener("wheel",c,fn),document.addEventListener("touchmove",c,fn),document.addEventListener("touchstart",p,fn),function(){pn=pn.filter(function(y){return y!==s}),document.removeEventListener("wheel",c,fn),document.removeEventListener("touchmove",c,fn),document.removeEventListener("touchstart",p,fn)}},[]);var h=e.removeScrollBar,g=e.inert;return S.createElement(S.Fragment,null,g?S.createElement(s,{styles:EC(n)}):null,h?S.createElement(gC,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function AC(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const DC=oC(Bp,kC);var ic=S.forwardRef(function(e,t){return S.createElement(Ea,Ir({},e,{ref:t,sideCar:DC}))});ic.classNames=Ea.classNames;var $C=Object.defineProperty,Le=(e,t)=>$C(e,"name",{value:t,configurable:!0}),TC=[" ","Enter","ArrowUp","ArrowDown"],PC=[" ","Enter"],hn="Select",[Aa,Da,IC]=na(hn),[Mo,xI]=sr(hn,[IC,va]),cc=va(),[OC,bo]=Mo(hn),[MC,LC]=Mo(hn);function Rp(e){const{__scopeSelect:t,children:r,open:o,defaultOpen:n,onOpenChange:s,value:a,defaultValue:i,onValueChange:c,dir:d,name:p,autoComplete:u,disabled:f,required:h,form:g,internal_do_not_use_render:y}=e,b=cc(t),[v,N]=S.useState(null),[x,w]=S.useState(null),[C,E]=S.useState(!1),k=Vn(d),[_,D]=yr({prop:o,defaultProp:n??!1,onChange:s,caller:hn}),[A,I]=yr({prop:a,defaultProp:i,onChange:c,caller:hn}),T=S.useRef(null),L=S.useRef(A);S.useEffect(()=>{const U=g?v==null?void 0:v.ownerDocument.getElementById(g):v==null?void 0:v.form;if(U instanceof HTMLFormElement){const Q=Le(()=>I(L.current),"reset");return U.addEventListener("reset",Q),()=>U.removeEventListener("reset",Q)}},[g,v,I]);const F=v?!!g||!!v.closest("form"):!0,[B,G]=S.useState(new Set),z=br(),H=Array.from(B).map(U=>U.props.value).join(";"),V=S.useCallback(U=>{G(Q=>new Set(Q).add(U))},[]),W=S.useCallback(U=>{G(Q=>{const Ce=new Set(Q);return Ce.delete(U),Ce})},[]),pe={required:h,trigger:v,onTriggerChange:N,valueNode:x,onValueNodeChange:w,valueNodeHasChildren:C,onValueNodeHasChildrenChange:E,contentId:z,value:A,onValueChange:I,open:_,onOpenChange:D,dir:k,triggerPointerDownPosRef:T,disabled:f,name:p,autoComplete:u,form:g,nativeOptions:B,nativeSelectKey:H,isFormControl:F};return l.jsx(wp,{...b,children:l.jsx(OC,{scope:t,...pe,children:l.jsx(Aa.Provider,{scope:t,children:l.jsx(MC,{scope:t,onNativeOptionAdd:V,onNativeOptionRemove:W,children:uh(y)?y(pe):r})})})})}Le(Rp,"SelectProvider");var FC=Le(e=>{const{__scopeSelect:t,children:r,...o}=e;return l.jsx(Rp,{__scopeSelect:t,...o,internal_do_not_use_render:({isFormControl:n})=>l.jsxs(l.Fragment,{children:[r,n?l.jsx(aE,{__scopeSelect:t}):null]})})},"Select"),VC="SelectTrigger",Xp=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,disabled:n=!1,...s}=t,a=cc(o),i=bo(VC,o),c=i.disabled||n,d=Ue(r,i.onTriggerChange),p=Da(o),u=S.useRef("touch"),[f,h,g]=fc(b=>{const v=p().filter(w=>!w.disabled),N=v.find(w=>w.value===i.value),x=pc(v,b,N);x!==void 0&&i.onValueChange(x.value)}),y=Le(b=>{c||(i.onOpenChange(!0),g()),b&&(i.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})},"handleOpen");return l.jsx(Sp,{asChild:!0,...a,children:l.jsx(Ie.button,{type:"button",role:"combobox","aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":Un(i.value)?"":void 0,...s,ref:d,onClick:Se(s.onClick,b=>{b.currentTarget.focus(),u.current!=="mouse"&&y(b)}),onPointerDown:Se(s.onPointerDown,b=>{u.current=b.pointerType;const v=b.target;v.hasPointerCapture(b.pointerId)&&v.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(y(b),b.preventDefault())}),onKeyDown:Se(s.onKeyDown,b=>{const v=f.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&h(b.key),!(v&&b.key===" ")&&TC.includes(b.key)&&(y(),b.preventDefault())})})})},"SelectTrigger")),GC="SelectValue",zC=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,className:n,style:s,children:a,placeholder:i="",...c}=t,d=bo(GC,o),{onValueNodeHasChildrenChange:p}=d,u=a!==void 0,f=Ue(r,d.onValueNodeChange);ot(()=>{p(u)},[p,u]);const h=Un(d.value);return l.jsx(Ie.span,{...c,asChild:h?!1:c.asChild,ref:f,style:{pointerEvents:"none"},children:l.jsx(S.Fragment,{children:h?i:a},h?"placeholder":"value")})},"SelectValue")),BC=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,children:n,...s}=t;return l.jsx(Ie.span,{"aria-hidden":!0,...s,ref:r,children:n||"▼"})},"SelectIcon")),UC="SelectPortal",[WC,HC]=Mo(UC,{forceMount:void 0}),jC=Le(e=>{const{__scopeSelect:t,forceMount:r,...o}=e;return l.jsx(WC,{scope:e.__scopeSelect,forceMount:r,children:l.jsx(tc,{asChild:!0,...o})})},"SelectPortal"),Lo="SelectContent",Jp=S.forwardRef(Le(function(t,r){const o=HC(Lo,t.__scopeSelect),{forceMount:n=o.forceMount,...s}=t,a=bo(Lo,t.__scopeSelect),[i,c]=S.useState();return ot(()=>{c(new DocumentFragment)},[]),l.jsx(eo,{present:n||a.open,children:({present:d})=>d?l.jsx(QC,{...s,ref:r}):l.jsx(qC,{...s,fragment:i})})},"SelectContent")),qC=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,children:n,fragment:s}=t;return s?Tn.createPortal(l.jsx(Zp,{scope:o,children:l.jsx(Aa.Slot,{scope:o,children:l.jsx("div",{ref:r,children:n})})}),s):null},"SelectContentFragment")),vr=10,[Zp,Fo]=Mo(Lo),YC=Yr("SelectContent.RemoveScroll"),QC=S.forwardRef(Le(function(t,r){const{__scopeSelect:o}=t,{position:n="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:d,align:p,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:g,sticky:y,hideWhenDetached:b,avoidCollisions:v,...N}=t,x=bo(Lo,o),[w,C]=S.useState(null),[E,k]=S.useState(null),_=Ue(r,C),[D,A]=S.useState(null),[I,T]=S.useState(null),L=Da(o),[F,B]=S.useState(!1),G=S.useRef(!1);S.useEffect(()=>{if(w)return Fp(w)},[w]),la();const z=S.useCallback(ce=>{const[re,...Ae]=L().map(J=>J.ref.current),[we]=Ae.slice(-1),ue=document.activeElement;for(const J of ce)if(J===ue||(J==null||J.scrollIntoView({block:"nearest"}),J===re&&E&&(E.scrollTop=0),J===we&&E&&(E.scrollTop=E.scrollHeight),J==null||J.focus(),document.activeElement!==ue))return},[L,E]),H=S.useCallback(()=>z([D,w]),[z,D,w]);S.useEffect(()=>{F&&H()},[F,H]);const{onOpenChange:V,triggerPointerDownPosRef:W}=x;S.useEffect(()=>{if(w){let ce={x:0,y:0};const re=Le(we=>{var ue,J;ce={x:Math.abs(Math.round(we.pageX)-(((ue=W.current)==null?void 0:ue.x)??0)),y:Math.abs(Math.round(we.pageY)-(((J=W.current)==null?void 0:J.y)??0))}},"handlePointerMove"),Ae=Le(we=>{ce.x<=10&&ce.y<=10?we.preventDefault():we.composedPath().includes(w)||V(!1),document.removeEventListener("pointermove",re),W.current=null},"handlePointerUp");return W.current!==null&&(document.addEventListener("pointermove",re),document.addEventListener("pointerup",Ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",re),document.removeEventListener("pointerup",Ae,{capture:!0})}}},[w,V,W]),S.useEffect(()=>{const ce=Le(()=>V(!1),"close");return window.addEventListener("blur",ce),window.addEventListener("resize",ce),()=>{window.removeEventListener("blur",ce),window.removeEventListener("resize",ce)}},[V]);const[pe,U]=fc(ce=>{const re=L().filter(ue=>!ue.disabled),Ae=re.find(ue=>ue.ref.current===document.activeElement),we=pc(re,ce,Ae);we&&setTimeout(()=>{var ue;return(ue=we.ref.current)==null?void 0:ue.focus()})}),Q=S.useCallback((ce,re,Ae)=>{const we=!G.current&&!Ae;(x.value!==void 0&&x.value===re||we)&&(A(ce),we&&(G.current=!0))},[x.value]),Ce=S.useCallback(()=>w==null?void 0:w.focus(),[w]),oe=S.useCallback((ce,re,Ae)=>{const we=!G.current&&!Ae;(x.value!==void 0&&x.value===re||we)&&T(ce)},[x.value]),ye=n==="popper"?eh:KC,R=ye===eh?{side:c,sideOffset:d,align:p,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:g,sticky:y,hideWhenDetached:b,avoidCollisions:v}:{};return l.jsx(Zp,{scope:o,content:w,viewport:E,onViewportChange:k,itemRefCallback:Q,selectedItem:D,onItemLeave:Ce,itemTextRefCallback:oe,focusSelectedItem:H,selectedItemText:I,position:n,isPositioned:F,searchRef:pe,children:l.jsx(ic,{as:YC,allowPinchZoom:!0,children:l.jsx(Bf,{asChild:!0,trapped:x.open,onMountAutoFocus:ce=>{ce.preventDefault()},onUnmountAutoFocus:Se(s,ce=>{var re;(re=x.trigger)==null||re.focus({preventScroll:!0}),ce.preventDefault()}),children:l.jsx(Ii,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:ce=>ce.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:l.jsx(ye,{role:"listbox",id:x.contentId,"data-state":x.open?"open":"closed",dir:x.dir,onContextMenu:ce=>ce.preventDefault(),...N,...R,onPlaced:()=>B(!0),ref:_,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:Se(N.onKeyDown,ce=>{const re=ce.ctrlKey||ce.altKey||ce.metaKey;if(ce.key==="Tab"&&ce.preventDefault(),!re&&ce.key.length===1&&U(ce.key),["ArrowUp","ArrowDown","Home","End"].includes(ce.key)){let we=L().filter(ue=>!ue.disabled).map(ue=>ue.ref.current);if(["ArrowUp","End"].includes(ce.key)&&(we=we.slice().reverse()),["ArrowUp","ArrowDown"].includes(ce.key)){const ue=ce.target,J=we.indexOf(ue);we=we.slice(J+1)}setTimeout(()=>z(we)),ce.preventDefault()}})})})})})})},"SelectContentImpl")),KC=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,onPlaced:n,...s}=t,a=bo(Lo,o),i=Fo(Lo,o),[c,d]=S.useState(null),[p,u]=S.useState(null),f=Ue(r,u),h=Da(o),g=S.useRef(!1),y=S.useRef(!0),{viewport:b,selectedItem:v,selectedItemText:N,focusSelectedItem:x}=i,w=S.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&p&&b&&v&&N){const _=a.trigger.getBoundingClientRect(),D=p.getBoundingClientRect(),A=a.valueNode.getBoundingClientRect(),I=N.getBoundingClientRect();if(a.dir!=="rtl"){const ue=I.left-D.left,J=A.left-ue,ne=_.left-J,fe=_.width+ne,ke=Math.max(fe,D.width),Re=window.innerWidth-vr,rt=Ci(J,[vr,Math.max(vr,Re-ke)]);c.style.minWidth=fe+"px",c.style.left=rt+"px"}else{const ue=D.right-I.right,J=window.innerWidth-A.right-ue,ne=window.innerWidth-_.right-J,fe=_.width+ne,ke=Math.max(fe,D.width),Re=window.innerWidth-vr,rt=Ci(J,[vr,Math.max(vr,Re-ke)]);c.style.minWidth=fe+"px",c.style.right=rt+"px"}const T=h(),L=window.innerHeight-vr*2,F=b.scrollHeight,B=window.getComputedStyle(p),G=parseInt(B.borderTopWidth,10),z=parseInt(B.paddingTop,10),H=parseInt(B.borderBottomWidth,10),V=parseInt(B.paddingBottom,10),W=G+z+F+V+H,pe=Math.min(v.offsetHeight*5,W),U=window.getComputedStyle(b),Q=parseInt(U.paddingTop,10),Ce=parseInt(U.paddingBottom,10),oe=_.top+_.height/2-vr,ye=L-oe,R=v.offsetHeight/2,ce=v.offsetTop+R,re=G+z+ce,Ae=W-re;if(re<=oe){const ue=T.length>0&&v===T[T.length-1].ref.current;c.style.bottom="0px";const J=p.clientHeight-b.offsetTop-b.offsetHeight,ne=Math.max(ye,R+(ue?Ce:0)+J+H),fe=re+ne;c.style.height=fe+"px"}else{const ue=T.length>0&&v===T[0].ref.current;c.style.top="0px";const ne=Math.max(oe,G+b.offsetTop+(ue?Q:0)+R)+Ae;c.style.height=ne+"px",b.scrollTop=re-oe+b.offsetTop}c.style.margin=`${vr}px 0`,c.style.minHeight=pe+"px",c.style.maxHeight=L+"px",n==null||n(),requestAnimationFrame(()=>g.current=!0)}},[h,a.trigger,a.valueNode,c,p,b,v,N,a.dir,n]);ot(()=>w(),[w]);const[C,E]=S.useState();ot(()=>{p&&E(window.getComputedStyle(p).zIndex)},[p]);const k=S.useCallback(_=>{_&&y.current===!0&&(w(),x==null||x(),y.current=!1)},[w,x]);return l.jsx(RC,{scope:o,contentWrapper:c,shouldExpandOnScrollRef:g,onScrollButtonChange:k,children:l.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:C},children:l.jsx(Ie.div,{...s,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})},"SelectItemAlignedPosition")),eh=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,align:n="start",collisionPadding:s=vr,...a}=t,i=cc(o);return l.jsx(Np,{...i,...a,ref:r,align:n,collisionPadding:s,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[RC,dc]=Mo(Lo,{}),th="SelectViewport",XC=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,nonce:n,...s}=t,a=Fo(th,o),i=dc(th,o),c=Ue(r,a.onViewportChange),d=S.useRef(0);return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),l.jsx(Aa.Slot,{scope:o,children:l.jsx(Ie.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:Se(s.onScroll,p=>{const u=p.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const g=Math.abs(d.current-u.scrollTop);if(g>0){const y=window.innerHeight-vr*2,b=parseFloat(f.style.minHeight),v=parseFloat(f.style.height),N=Math.max(b,v);if(N<y){const x=N+g,w=Math.min(y,x),C=x-w;f.style.height=w+"px",f.style.bottom==="0px"&&(u.scrollTop=C>0?C:0,f.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})},"SelectViewport")),JC="SelectGroup",[wI,ZC]=Mo(JC),eE="SelectLabel",rh=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,...n}=t,s=ZC(eE,o);return l.jsx(Ie.div,{id:s.id,...n,ref:r})},"SelectLabel")),uc="SelectItem",[tE,oh]=Mo(uc),nh=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,value:n,disabled:s=!1,textValue:a,...i}=t,c=bo(uc,o),d=Fo(uc,o),p=c.value===n,[u,f]=S.useState(a??""),[h,g]=S.useState(!1),y=gr(w=>{var C;return(C=d.itemRefCallback)==null?void 0:C.call(d,w,n,s)}),b=Ue(r,y),v=br(),N=S.useRef("touch"),x=Le(()=>{s||(c.onValueChange(n),c.onOpenChange(!1))},"handleSelect");return l.jsx(tE,{scope:o,value:n,disabled:s,textId:v,isSelected:p,onItemTextChange:S.useCallback(w=>{f(C=>C||((w==null?void 0:w.textContent)??"").trim())},[]),children:l.jsx(Aa.ItemSlot,{scope:o,value:n,disabled:s,textValue:u,children:l.jsx(Ie.div,{role:"option","aria-labelledby":v,"data-highlighted":h?"":void 0,"aria-selected":p&&h,"data-state":p?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...i,ref:b,onFocus:Se(i.onFocus,()=>g(!0)),onBlur:Se(i.onBlur,()=>g(!1)),onClick:Se(i.onClick,()=>{N.current!=="mouse"&&x()}),onPointerUp:Se(i.onPointerUp,()=>{N.current==="mouse"&&x()}),onPointerDown:Se(i.onPointerDown,w=>{N.current=w.pointerType}),onPointerMove:Se(i.onPointerMove,w=>{var C;N.current=w.pointerType,s?(C=d.onItemLeave)==null||C.call(d):N.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Se(i.onPointerLeave,w=>{var C;w.currentTarget===document.activeElement&&((C=d.onItemLeave)==null||C.call(d))}),onKeyDown:Se(i.onKeyDown,w=>{var E;s||w.target!==w.currentTarget||((E=d.searchRef)==null?void 0:E.current)!==""&&w.key===" "||(PC.includes(w.key)&&x(),w.key===" "&&w.preventDefault())})})})})},"SelectItem")),$a="SelectItemText",rE=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,className:n,style:s,...a}=t,i=bo($a,o),c=Fo($a,o),d=oh($a,o),p=LC($a,o),[u,f]=S.useState(null),h=gr(x=>{var w;return(w=c.itemTextRefCallback)==null?void 0:w.call(c,x,d.value,d.disabled)}),g=Ue(r,f,d.onItemTextChange,h),y=u==null?void 0:u.textContent,b=S.useMemo(()=>l.jsx("option",{value:d.value,disabled:d.disabled,children:y},d.value),[d.disabled,d.value,y]),{onNativeOptionAdd:v,onNativeOptionRemove:N}=p;return ot(()=>(v(b),()=>N(b)),[v,N,b]),l.jsxs(l.Fragment,{children:[l.jsx(Ie.span,{id:d.textId,...a,ref:g}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren&&!Un(i.value)?Tn.createPortal(a.children,i.valueNode):null]})},"SelectItemText")),oE="SelectItemIndicator",nE=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,...n}=t;return oh(oE,o).isSelected?l.jsx(Ie.span,{"aria-hidden":!0,...n,ref:r}):null},"SelectItemIndicator")),sh="SelectScrollUpButton",ah=S.forwardRef(Le(function(t,r){const o=Fo(sh,t.__scopeSelect),n=dc(sh,t.__scopeSelect),[s,a]=S.useState(!1),i=Ue(r,n.onScrollButtonChange);return ot(()=>{if(o.viewport&&o.isPositioned){let c=function(){const p=d.scrollTop>0;a(p)};Le(c,"handleScroll");const d=o.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[o.viewport,o.isPositioned]),s?l.jsx(ch,{...t,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=o;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null},"SelectScrollUpButton")),lh="SelectScrollDownButton",ih=S.forwardRef(Le(function(t,r){const o=Fo(lh,t.__scopeSelect),n=dc(lh,t.__scopeSelect),[s,a]=S.useState(!1),i=Ue(r,n.onScrollButtonChange);return ot(()=>{if(o.viewport&&o.isPositioned){let c=function(){const p=d.scrollHeight-d.clientHeight,u=Math.ceil(d.scrollTop)<p;a(u)};Le(c,"handleScroll");const d=o.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[o.viewport,o.isPositioned]),s?l.jsx(ch,{...t,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=o;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null},"SelectScrollDownButton")),ch=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,onAutoScroll:n,...s}=t,a=Fo("SelectScrollButton",o),i=S.useRef(null),c=Da(o),d=S.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return S.useEffect(()=>()=>d(),[d]),ot(()=>{var u;const p=c().find(f=>f.ref.current===document.activeElement);(u=p==null?void 0:p.ref.current)==null||u.scrollIntoView({block:"nearest"})},[c]),l.jsx(Ie.div,{"aria-hidden":!0,...s,ref:r,style:{flexShrink:0,...s.style},onPointerDown:Se(s.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(n,50))}),onPointerMove:Se(s.onPointerMove,()=>{var p;(p=a.onItemLeave)==null||p.call(a),i.current===null&&(i.current=window.setInterval(n,50))}),onPointerLeave:Se(s.onPointerLeave,()=>{d()})})},"SelectScrollButtonImpl")),dh=S.forwardRef(Le(function(t,r){const{__scopeSelect:o,...n}=t;return l.jsx(Ie.div,{"aria-hidden":!0,...n,ref:r})},"SelectSeparator")),sE="SelectBubbleInput",aE=S.forwardRef(Le(function({__scopeSelect:t,...r},o){const n=bo(sE,t),{value:s,onValueChange:a,required:i,disabled:c,name:d,autoComplete:p,form:u}=n,{nativeOptions:f,nativeSelectKey:h}=n,g=S.useRef(null),y=Ue(o,g),b=s??"",v=Op(b),N=Array.from(f).some(x=>(x.props.value??"")==="");return S.useEffect(()=>{const x=g.current;if(!x)return;const w=window.HTMLSelectElement.prototype,E=Object.getOwnPropertyDescriptor(w,"value").set;if(v!==b&&E){const k=new Event("change",{bubbles:!0});E.call(x,b),x.dispatchEvent(k)}},[v,b]),l.jsxs(Ie.select,{"aria-hidden":!0,required:i,tabIndex:-1,name:d,autoComplete:p,disabled:c,form:u,onChange:x=>a(x.target.value),...r,style:{...Mp,...r.style},ref:y,defaultValue:b,children:[Un(s)&&!N?l.jsx("option",{value:""}):null,Array.from(f)]},h)},"SelectBubbleInput"));function uh(e){return typeof e=="function"}Le(uh,"isFunction");function Un(e){return e===""||e===void 0}Le(Un,"shouldShowPlaceholder");function fc(e){const t=gr(e),r=S.useRef(""),o=S.useRef(0),n=S.useCallback(a=>{const i=r.current+a;t(i),Le((function c(d){r.current=d,window.clearTimeout(o.current),d!==""&&(o.current=window.setTimeout(()=>c(""),1e3))}),"updateSearch")(i)},[t]),s=S.useCallback(()=>{r.current="",window.clearTimeout(o.current)},[]);return S.useEffect(()=>()=>window.clearTimeout(o.current),[]),[r,n,s]}Le(fc,"useTypeaheadSearch");function pc(e,t,r){const n=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,s=r?e.indexOf(r):-1;let a=fh(e,Math.max(s,0));n.length===1&&(a=a.filter(d=>d!==r));const c=a.find(d=>d.textValue.toLowerCase().startsWith(n.toLowerCase()));return c!==r?c:void 0}Le(pc,"findNextItem");function fh(e,t){return e.map((r,o)=>e[(t+o)%e.length])}Le(fh,"wrapArray");/**
46
+ `)},ON=0,gn=[];function IN(e){var t=C.useRef([]),r=C.useRef([0,0]),o=C.useRef(),n=C.useState(ON++)[0],a=C.useState(Wp)[0],s=C.useRef(e);C.useEffect(function(){s.current=e},[e]),C.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(n));var g=rN([e.lockRef.current],(e.shards||[]).map(Rp),!0).filter(Boolean);return g.forEach(function(y){return y.classList.add("allow-interactivity-".concat(n))}),function(){document.body.classList.remove("block-interactivity-".concat(n)),g.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(n))})}}},[e.inert,e.lockRef.current,e.shards]);var l=C.useCallback(function(g,y){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!s.current.allowPinchZoom;var v=As(g),S=r.current,x="deltaX"in g?g.deltaX:S[0]-v[0],w="deltaY"in g?g.deltaY:S[1]-v[1],N,k=g.target,_=Math.abs(x)>Math.abs(w)?"h":"v";if("touches"in g&&_==="h"&&k.type==="range")return!1;var E=window.getSelection(),D=E&&E.anchorNode,T=D?D===k||D.contains(k):!1;if(T)return!1;var O=qp(_,k);if(!O)return!0;if(O?N=_:(N=_==="v"?"h":"v",O=qp(_,k)),!O)return!1;if(!o.current&&"changedTouches"in g&&(x||w)&&(o.current=N),!N)return!0;var $=o.current||N;return $N($,y,g,$==="h"?x:w)},[]),c=C.useCallback(function(g){var y=g;if(!(!gn.length||gn[gn.length-1]!==a)){var v="deltaY"in y?Kp(y):As(y),S=t.current.filter(function(N){return N.name===y.type&&(N.target===y.target||y.target===N.shadowParent)&&PN(N.delta,v)})[0];if(S&&S.should){y.cancelable&&y.preventDefault();return}if(!S){var x=(s.current.shards||[]).map(Rp).filter(Boolean).filter(function(N){return N.contains(y.target)}),w=x.length>0?l(y,x[0]):!s.current.noIsolation;w&&y.cancelable&&y.preventDefault()}}},[]),d=C.useCallback(function(g,y,v,S){var x={name:g,delta:y,target:v,should:S,shadowParent:LN(v)};t.current.push(x),setTimeout(function(){t.current=t.current.filter(function(w){return w!==x})},1)},[]),p=C.useCallback(function(g){r.current=As(g),o.current=void 0},[]),u=C.useCallback(function(g){d(g.type,Kp(g),g.target,l(g,e.lockRef.current))},[]),f=C.useCallback(function(g){d(g.type,As(g),g.target,l(g,e.lockRef.current))},[]);C.useEffect(function(){return gn.push(a),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:f}),document.addEventListener("wheel",c,bn),document.addEventListener("touchmove",c,bn),document.addEventListener("touchstart",p,bn),function(){gn=gn.filter(function(g){return g!==a}),document.removeEventListener("wheel",c,bn),document.removeEventListener("touchmove",c,bn),document.removeEventListener("touchstart",p,bn)}},[]);var h=e.removeScrollBar,b=e.inert;return C.createElement(C.Fragment,null,b?C.createElement(a,{styles:MN(n)}):null,h?C.createElement(NN,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function LN(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const FN=uN(Up,IN);var ic=C.forwardRef(function(e,t){return C.createElement(Es,Lr({},e,{ref:t,sideCar:FN}))});ic.classNames=Es.classNames;var VN=Object.defineProperty,He=(e,t)=>VN(e,"name",{value:t,configurable:!0}),GN=[" ","Enter","ArrowUp","ArrowDown"],zN=[" ","Enter"],yn="Select",[_s,Ts,BN]=ns(yn),[Go,E2]=ur(yn,[BN,vs]),cc=vs(),[UN,vo]=Go(yn),[WN,HN]=Go(yn);function Xp(e){const{__scopeSelect:t,children:r,open:o,defaultOpen:n,onOpenChange:a,value:s,defaultValue:l,onValueChange:c,dir:d,name:p,autoComplete:u,disabled:f,required:h,form:b,internal_do_not_use_render:g}=e,y=cc(t),[v,S]=C.useState(null),[x,w]=C.useState(null),[N,k]=C.useState(!1),_=Gn(d),[E,D]=Cr({prop:o,defaultProp:n??!1,onChange:a,caller:yn}),[T,O]=Cr({prop:s,defaultProp:l,onChange:c,caller:yn}),$=C.useRef(null),V=C.useRef(T);C.useEffect(()=>{const Q=b?v==null?void 0:v.ownerDocument.getElementById(b):v==null?void 0:v.form;if(Q instanceof HTMLFormElement){const te=He(()=>O(V.current),"reset");return Q.addEventListener("reset",te),()=>Q.removeEventListener("reset",te)}},[b,v,O]);const G=v?!!b||!!v.closest("form"):!0,[q,H]=C.useState(new Set),Y=xr(),J=Array.from(q).map(Q=>Q.props.value).join(";"),W=C.useCallback(Q=>{H(te=>new Set(te).add(Q))},[]),R=C.useCallback(Q=>{H(te=>{const De=new Set(te);return De.delete(Q),De})},[]),we={required:h,trigger:v,onTriggerChange:S,valueNode:x,onValueNodeChange:w,valueNodeHasChildren:N,onValueNodeHasChildrenChange:k,contentId:Y,value:T,onValueChange:O,open:E,onOpenChange:D,dir:_,triggerPointerDownPosRef:$,disabled:f,name:p,autoComplete:u,form:b,nativeOptions:q,nativeSelectKey:J,isFormControl:G};return i.jsx(Cp,{...y,children:i.jsx(UN,{scope:t,...we,children:i.jsx(_s.Provider,{scope:t,children:i.jsx(WN,{scope:t,onNativeOptionAdd:W,onNativeOptionRemove:R,children:fh(g)?g(we):r})})})})}He(Xp,"SelectProvider");var jN=He(e=>{const{__scopeSelect:t,children:r,...o}=e;return i.jsx(Xp,{__scopeSelect:t,...o,internal_do_not_use_render:({isFormControl:n})=>i.jsxs(i.Fragment,{children:[r,n?i.jsx(h1,{__scopeSelect:t}):null]})})},"Select"),qN="SelectTrigger",Jp=C.forwardRef(He(function(t,r){const{__scopeSelect:o,disabled:n=!1,...a}=t,s=cc(o),l=vo(qN,o),c=l.disabled||n,d=Re(r,l.onTriggerChange),p=Ts(o),u=C.useRef("touch"),[f,h,b]=fc(y=>{const v=p().filter(w=>!w.disabled),S=v.find(w=>w.value===l.value),x=pc(v,y,S);x!==void 0&&l.onValueChange(x.value)}),g=He(y=>{c||(l.onOpenChange(!0),b()),y&&(l.triggerPointerDownPosRef.current={x:Math.round(y.pageX),y:Math.round(y.pageY)})},"handleOpen");return i.jsx(Sp,{asChild:!0,...s,children:i.jsx(Be.button,{type:"button",role:"combobox","aria-controls":l.open?l.contentId:void 0,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":Wn(l.value)?"":void 0,...a,ref:d,onClick:Pe(a.onClick,y=>{y.currentTarget.focus(),u.current!=="mouse"&&g(y)}),onPointerDown:Pe(a.onPointerDown,y=>{u.current=y.pointerType;const v=y.target;v.hasPointerCapture(y.pointerId)&&v.releasePointerCapture(y.pointerId),y.button===0&&y.ctrlKey===!1&&y.pointerType==="mouse"&&(g(y),y.preventDefault())}),onKeyDown:Pe(a.onKeyDown,y=>{const v=f.current!=="";!(y.ctrlKey||y.altKey||y.metaKey)&&y.key.length===1&&h(y.key),!(v&&y.key===" ")&&GN.includes(y.key)&&(g(),y.preventDefault())})})})},"SelectTrigger")),YN="SelectValue",QN=C.forwardRef(He(function(t,r){const{__scopeSelect:o,className:n,style:a,children:s,placeholder:l="",...c}=t,d=vo(YN,o),{onValueNodeHasChildrenChange:p}=d,u=s!==void 0,f=Re(r,d.onValueNodeChange);ut(()=>{p(u)},[p,u]);const h=Wn(d.value);return i.jsx(Be.span,{...c,asChild:h?!1:c.asChild,ref:f,style:{pointerEvents:"none"},children:i.jsx(C.Fragment,{children:h?l:s},h?"placeholder":"value")})},"SelectValue")),KN=C.forwardRef(He(function(t,r){const{__scopeSelect:o,children:n,...a}=t;return i.jsx(Be.span,{"aria-hidden":!0,...a,ref:r,children:n||"▼"})},"SelectIcon")),RN="SelectPortal",[XN,JN]=Go(RN,{forceMount:void 0}),ZN=He(e=>{const{__scopeSelect:t,forceMount:r,...o}=e;return i.jsx(XN,{scope:e.__scopeSelect,forceMount:r,children:i.jsx(tc,{asChild:!0,...o})})},"SelectPortal"),zo="SelectContent",Zp=C.forwardRef(He(function(t,r){const o=JN(zo,t.__scopeSelect),{forceMount:n=o.forceMount,...a}=t,s=vo(zo,t.__scopeSelect),[l,c]=C.useState();return ut(()=>{c(new DocumentFragment)},[]),i.jsx(ro,{present:n||s.open,children:({present:d})=>d?i.jsx(r1,{...a,ref:r}):i.jsx(e1,{...a,fragment:l})})},"SelectContent")),e1=C.forwardRef(He(function(t,r){const{__scopeSelect:o,children:n,fragment:a}=t;return a?Pn.createPortal(i.jsx(eh,{scope:o,children:i.jsx(_s.Slot,{scope:o,children:i.jsx("div",{ref:r,children:n})})}),a):null},"SelectContentFragment")),Sr=10,[eh,Bo]=Go(zo),t1=Kr("SelectContent.RemoveScroll"),r1=C.forwardRef(He(function(t,r){const{__scopeSelect:o}=t,{position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:s,onPointerDownOutside:l,side:c,sideOffset:d,align:p,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:b,sticky:g,hideWhenDetached:y,avoidCollisions:v,...S}=t,x=vo(zo,o),[w,N]=C.useState(null),[k,_]=C.useState(null),E=Re(r,N),[D,T]=C.useState(null),[O,$]=C.useState(null),V=Ts(o),[G,q]=C.useState(!1),H=C.useRef(!1);C.useEffect(()=>{if(w)return Vp(w)},[w]),ls();const Y=C.useCallback(me=>{const[ce,...Ie]=V().map(ae=>ae.ref.current),[xe]=Ie.slice(-1),be=document.activeElement;for(const ae of me)if(ae===be||(ae==null||ae.scrollIntoView({block:"nearest"}),ae===ce&&k&&(k.scrollTop=0),ae===xe&&k&&(k.scrollTop=k.scrollHeight),ae==null||ae.focus(),document.activeElement!==be))return},[V,k]),J=C.useCallback(()=>Y([D,w]),[Y,D,w]);C.useEffect(()=>{G&&J()},[G,J]);const{onOpenChange:W,triggerPointerDownPosRef:R}=x;C.useEffect(()=>{if(w){let me={x:0,y:0};const ce=He(xe=>{var be,ae;me={x:Math.abs(Math.round(xe.pageX)-(((be=R.current)==null?void 0:be.x)??0)),y:Math.abs(Math.round(xe.pageY)-(((ae=R.current)==null?void 0:ae.y)??0))}},"handlePointerMove"),Ie=He(xe=>{me.x<=10&&me.y<=10?xe.preventDefault():xe.composedPath().includes(w)||W(!1),document.removeEventListener("pointermove",ce),R.current=null},"handlePointerUp");return R.current!==null&&(document.addEventListener("pointermove",ce),document.addEventListener("pointerup",Ie,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ce),document.removeEventListener("pointerup",Ie,{capture:!0})}}},[w,W,R]),C.useEffect(()=>{const me=He(()=>W(!1),"close");return window.addEventListener("blur",me),window.addEventListener("resize",me),()=>{window.removeEventListener("blur",me),window.removeEventListener("resize",me)}},[W]);const[we,Q]=fc(me=>{const ce=V().filter(be=>!be.disabled),Ie=ce.find(be=>be.ref.current===document.activeElement),xe=pc(ce,me,Ie);xe&&setTimeout(()=>{var be;return(be=xe.ref.current)==null?void 0:be.focus()})}),te=C.useCallback((me,ce,Ie)=>{const xe=!H.current&&!Ie;(x.value!==void 0&&x.value===ce||xe)&&(T(me),xe&&(H.current=!0))},[x.value]),De=C.useCallback(()=>w==null?void 0:w.focus(),[w]),de=C.useCallback((me,ce,Ie)=>{const xe=!H.current&&!Ie;(x.value!==void 0&&x.value===ce||xe)&&$(me)},[x.value]),Se=n==="popper"?th:o1,re=Se===th?{side:c,sideOffset:d,align:p,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:b,sticky:g,hideWhenDetached:y,avoidCollisions:v}:{};return i.jsx(eh,{scope:o,content:w,viewport:k,onViewportChange:_,itemRefCallback:te,selectedItem:D,onItemLeave:De,itemTextRefCallback:de,focusSelectedItem:J,selectedItemText:O,position:n,isPositioned:G,searchRef:we,children:i.jsx(ic,{as:t1,allowPinchZoom:!0,children:i.jsx(Uf,{asChild:!0,trapped:x.open,onMountAutoFocus:me=>{me.preventDefault()},onUnmountAutoFocus:Pe(a,me=>{var ce;(ce=x.trigger)==null||ce.focus({preventScroll:!0}),me.preventDefault()}),children:i.jsx(Mi,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:me=>me.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:i.jsx(Se,{role:"listbox",id:x.contentId,"data-state":x.open?"open":"closed",dir:x.dir,onContextMenu:me=>me.preventDefault(),...S,...re,onPlaced:()=>q(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:Pe(S.onKeyDown,me=>{const ce=me.ctrlKey||me.altKey||me.metaKey;if(me.key==="Tab"&&me.preventDefault(),!ce&&me.key.length===1&&Q(me.key),["ArrowUp","ArrowDown","Home","End"].includes(me.key)){let xe=V().filter(be=>!be.disabled).map(be=>be.ref.current);if(["ArrowUp","End"].includes(me.key)&&(xe=xe.slice().reverse()),["ArrowUp","ArrowDown"].includes(me.key)){const be=me.target,ae=xe.indexOf(be);xe=xe.slice(ae+1)}setTimeout(()=>Y(xe)),me.preventDefault()}})})})})})})},"SelectContentImpl")),o1=C.forwardRef(He(function(t,r){const{__scopeSelect:o,onPlaced:n,...a}=t,s=vo(zo,o),l=Bo(zo,o),[c,d]=C.useState(null),[p,u]=C.useState(null),f=Re(r,u),h=Ts(o),b=C.useRef(!1),g=C.useRef(!0),{viewport:y,selectedItem:v,selectedItemText:S,focusSelectedItem:x}=l,w=C.useCallback(()=>{if(s.trigger&&s.valueNode&&c&&p&&y&&v&&S){const E=s.trigger.getBoundingClientRect(),D=p.getBoundingClientRect(),T=s.valueNode.getBoundingClientRect(),O=S.getBoundingClientRect();if(s.dir!=="rtl"){const be=O.left-D.left,ae=T.left-be,ue=E.left-ae,ve=E.width+ue,Oe=Math.max(ve,D.width),et=window.innerWidth-Sr,at=Ni(ae,[Sr,Math.max(Sr,et-Oe)]);c.style.minWidth=ve+"px",c.style.left=at+"px"}else{const be=D.right-O.right,ae=window.innerWidth-T.right-be,ue=window.innerWidth-E.right-ae,ve=E.width+ue,Oe=Math.max(ve,D.width),et=window.innerWidth-Sr,at=Ni(ae,[Sr,Math.max(Sr,et-Oe)]);c.style.minWidth=ve+"px",c.style.right=at+"px"}const $=h(),V=window.innerHeight-Sr*2,G=y.scrollHeight,q=window.getComputedStyle(p),H=parseInt(q.borderTopWidth,10),Y=parseInt(q.paddingTop,10),J=parseInt(q.borderBottomWidth,10),W=parseInt(q.paddingBottom,10),R=H+Y+G+W+J,we=Math.min(v.offsetHeight*5,R),Q=window.getComputedStyle(y),te=parseInt(Q.paddingTop,10),De=parseInt(Q.paddingBottom,10),de=E.top+E.height/2-Sr,Se=V-de,re=v.offsetHeight/2,me=v.offsetTop+re,ce=H+Y+me,Ie=R-ce;if(ce<=de){const be=$.length>0&&v===$[$.length-1].ref.current;c.style.bottom="0px";const ae=p.clientHeight-y.offsetTop-y.offsetHeight,ue=Math.max(Se,re+(be?De:0)+ae+J),ve=ce+ue;c.style.height=ve+"px"}else{const be=$.length>0&&v===$[0].ref.current;c.style.top="0px";const ue=Math.max(de,H+y.offsetTop+(be?te:0)+re)+Ie;c.style.height=ue+"px",y.scrollTop=ce-de+y.offsetTop}c.style.margin=`${Sr}px 0`,c.style.minHeight=we+"px",c.style.maxHeight=V+"px",n==null||n(),requestAnimationFrame(()=>b.current=!0)}},[h,s.trigger,s.valueNode,c,p,y,v,S,s.dir,n]);ut(()=>w(),[w]);const[N,k]=C.useState();ut(()=>{p&&k(window.getComputedStyle(p).zIndex)},[p]);const _=C.useCallback(E=>{E&&g.current===!0&&(w(),x==null||x(),g.current=!1)},[w,x]);return i.jsx(n1,{scope:o,contentWrapper:c,shouldExpandOnScrollRef:b,onScrollButtonChange:_,children:i.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:i.jsx(Be.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})},"SelectItemAlignedPosition")),th=C.forwardRef(He(function(t,r){const{__scopeSelect:o,align:n="start",collisionPadding:a=Sr,...s}=t,l=cc(o);return i.jsx(Np,{...l,...s,ref:r,align:n,collisionPadding:a,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[n1,dc]=Go(zo,{}),rh="SelectViewport",a1=C.forwardRef(He(function(t,r){const{__scopeSelect:o,nonce:n,...a}=t,s=Bo(rh,o),l=dc(rh,o),c=Re(r,s.onViewportChange),d=C.useRef(0);return i.jsxs(i.Fragment,{children:[i.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),i.jsx(_s.Slot,{scope:o,children:i.jsx(Be.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Pe(a.onScroll,p=>{const u=p.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=l;if(h!=null&&h.current&&f){const b=Math.abs(d.current-u.scrollTop);if(b>0){const g=window.innerHeight-Sr*2,y=parseFloat(f.style.minHeight),v=parseFloat(f.style.height),S=Math.max(y,v);if(S<g){const x=S+b,w=Math.min(g,x),N=x-w;f.style.height=w+"px",f.style.bottom==="0px"&&(u.scrollTop=N>0?N:0,f.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})},"SelectViewport")),s1="SelectGroup",[k2,l1]=Go(s1),i1="SelectLabel",oh=C.forwardRef(He(function(t,r){const{__scopeSelect:o,...n}=t,a=l1(i1,o);return i.jsx(Be.div,{id:a.id,...n,ref:r})},"SelectLabel")),uc="SelectItem",[c1,nh]=Go(uc),ah=C.forwardRef(He(function(t,r){const{__scopeSelect:o,value:n,disabled:a=!1,textValue:s,...l}=t,c=vo(uc,o),d=Bo(uc,o),p=c.value===n,[u,f]=C.useState(s??""),[h,b]=C.useState(!1),g=wr(w=>{var N;return(N=d.itemRefCallback)==null?void 0:N.call(d,w,n,a)}),y=Re(r,g),v=xr(),S=C.useRef("touch"),x=He(()=>{a||(c.onValueChange(n),c.onOpenChange(!1))},"handleSelect");return i.jsx(c1,{scope:o,value:n,disabled:a,textId:v,isSelected:p,onItemTextChange:C.useCallback(w=>{f(N=>N||((w==null?void 0:w.textContent)??"").trim())},[]),children:i.jsx(_s.ItemSlot,{scope:o,value:n,disabled:a,textValue:u,children:i.jsx(Be.div,{role:"option","aria-labelledby":v,"data-highlighted":h?"":void 0,"aria-selected":p&&h,"data-state":p?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:y,onFocus:Pe(l.onFocus,()=>b(!0)),onBlur:Pe(l.onBlur,()=>b(!1)),onClick:Pe(l.onClick,()=>{S.current!=="mouse"&&x()}),onPointerUp:Pe(l.onPointerUp,()=>{S.current==="mouse"&&x()}),onPointerDown:Pe(l.onPointerDown,w=>{S.current=w.pointerType}),onPointerMove:Pe(l.onPointerMove,w=>{var N;S.current=w.pointerType,a?(N=d.onItemLeave)==null||N.call(d):S.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Pe(l.onPointerLeave,w=>{var N;w.currentTarget===document.activeElement&&((N=d.onItemLeave)==null||N.call(d))}),onKeyDown:Pe(l.onKeyDown,w=>{var k;a||w.target!==w.currentTarget||((k=d.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(zN.includes(w.key)&&x(),w.key===" "&&w.preventDefault())})})})})},"SelectItem")),Ds="SelectItemText",d1=C.forwardRef(He(function(t,r){const{__scopeSelect:o,className:n,style:a,...s}=t,l=vo(Ds,o),c=Bo(Ds,o),d=nh(Ds,o),p=HN(Ds,o),[u,f]=C.useState(null),h=wr(x=>{var w;return(w=c.itemTextRefCallback)==null?void 0:w.call(c,x,d.value,d.disabled)}),b=Re(r,f,d.onItemTextChange,h),g=u==null?void 0:u.textContent,y=C.useMemo(()=>i.jsx("option",{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:v,onNativeOptionRemove:S}=p;return ut(()=>(v(y),()=>S(y)),[v,S,y]),i.jsxs(i.Fragment,{children:[i.jsx(Be.span,{id:d.textId,...s,ref:b}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren&&!Wn(l.value)?Pn.createPortal(s.children,l.valueNode):null]})},"SelectItemText")),u1="SelectItemIndicator",f1=C.forwardRef(He(function(t,r){const{__scopeSelect:o,...n}=t;return nh(u1,o).isSelected?i.jsx(Be.span,{"aria-hidden":!0,...n,ref:r}):null},"SelectItemIndicator")),sh="SelectScrollUpButton",lh=C.forwardRef(He(function(t,r){const o=Bo(sh,t.__scopeSelect),n=dc(sh,t.__scopeSelect),[a,s]=C.useState(!1),l=Re(r,n.onScrollButtonChange);return ut(()=>{if(o.viewport&&o.isPositioned){let c=function(){const p=d.scrollTop>0;s(p)};He(c,"handleScroll");const d=o.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[o.viewport,o.isPositioned]),a?i.jsx(dh,{...t,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=o;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null},"SelectScrollUpButton")),ih="SelectScrollDownButton",ch=C.forwardRef(He(function(t,r){const o=Bo(ih,t.__scopeSelect),n=dc(ih,t.__scopeSelect),[a,s]=C.useState(!1),l=Re(r,n.onScrollButtonChange);return ut(()=>{if(o.viewport&&o.isPositioned){let c=function(){const p=d.scrollHeight-d.clientHeight,u=Math.ceil(d.scrollTop)<p;s(u)};He(c,"handleScroll");const d=o.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[o.viewport,o.isPositioned]),a?i.jsx(dh,{...t,ref:l,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=o;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null},"SelectScrollDownButton")),dh=C.forwardRef(He(function(t,r){const{__scopeSelect:o,onAutoScroll:n,...a}=t,s=Bo("SelectScrollButton",o),l=C.useRef(null),c=Ts(o),d=C.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return C.useEffect(()=>()=>d(),[d]),ut(()=>{var u;const p=c().find(f=>f.ref.current===document.activeElement);(u=p==null?void 0:p.ref.current)==null||u.scrollIntoView({block:"nearest"})},[c]),i.jsx(Be.div,{"aria-hidden":!0,...a,ref:r,style:{flexShrink:0,...a.style},onPointerDown:Pe(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Pe(a.onPointerMove,()=>{var p;(p=s.onItemLeave)==null||p.call(s),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Pe(a.onPointerLeave,()=>{d()})})},"SelectScrollButtonImpl")),uh=C.forwardRef(He(function(t,r){const{__scopeSelect:o,...n}=t;return i.jsx(Be.div,{"aria-hidden":!0,...n,ref:r})},"SelectSeparator")),p1="SelectBubbleInput",h1=C.forwardRef(He(function({__scopeSelect:t,...r},o){const n=vo(p1,t),{value:a,onValueChange:s,required:l,disabled:c,name:d,autoComplete:p,form:u}=n,{nativeOptions:f,nativeSelectKey:h}=n,b=C.useRef(null),g=Re(o,b),y=a??"",v=Ip(y),S=Array.from(f).some(x=>(x.props.value??"")==="");return C.useEffect(()=>{const x=b.current;if(!x)return;const w=window.HTMLSelectElement.prototype,k=Object.getOwnPropertyDescriptor(w,"value").set;if(v!==y&&k){const _=new Event("change",{bubbles:!0});k.call(x,y),x.dispatchEvent(_)}},[v,y]),i.jsxs(Be.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:d,autoComplete:p,disabled:c,form:u,onChange:x=>s(x.target.value),...r,style:{...Lp,...r.style},ref:g,defaultValue:y,children:[Wn(a)&&!S?i.jsx("option",{value:""}):null,Array.from(f)]},h)},"SelectBubbleInput"));function fh(e){return typeof e=="function"}He(fh,"isFunction");function Wn(e){return e===""||e===void 0}He(Wn,"shouldShowPlaceholder");function fc(e){const t=wr(e),r=C.useRef(""),o=C.useRef(0),n=C.useCallback(s=>{const l=r.current+s;t(l),He((function c(d){r.current=d,window.clearTimeout(o.current),d!==""&&(o.current=window.setTimeout(()=>c(""),1e3))}),"updateSearch")(l)},[t]),a=C.useCallback(()=>{r.current="",window.clearTimeout(o.current)},[]);return C.useEffect(()=>()=>window.clearTimeout(o.current),[]),[r,n,a]}He(fc,"useTypeaheadSearch");function pc(e,t,r){const n=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=r?e.indexOf(r):-1;let s=ph(e,Math.max(a,0));n.length===1&&(s=s.filter(d=>d!==r));const c=s.find(d=>d.textValue.toLowerCase().startsWith(n.toLowerCase()));return c!==r?c:void 0}He(pc,"findNextItem");function ph(e,t){return e.map((r,o)=>e[(t+o)%e.length])}He(ph,"wrapArray");/**
42
47
  * @license lucide-react v0.563.0 - ISC
43
48
  *
44
49
  * This source code is licensed under the ISC license.
45
50
  * See the LICENSE file in the root directory of this source tree.
46
- */const ph=(...e)=>e.filter((t,r,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===r).join(" ").trim();/**
51
+ */const hh=(...e)=>e.filter((t,r,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===r).join(" ").trim();/**
47
52
  * @license lucide-react v0.563.0 - ISC
48
53
  *
49
54
  * This source code is licensed under the ISC license.
50
55
  * See the LICENSE file in the root directory of this source tree.
51
- */const lE=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
56
+ */const m1=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
52
57
  * @license lucide-react v0.563.0 - ISC
53
58
  *
54
59
  * This source code is licensed under the ISC license.
55
60
  * See the LICENSE file in the root directory of this source tree.
56
- */const iE=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,o)=>o?o.toUpperCase():r.toLowerCase());/**
61
+ */const b1=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,o)=>o?o.toUpperCase():r.toLowerCase());/**
57
62
  * @license lucide-react v0.563.0 - ISC
58
63
  *
59
64
  * This source code is licensed under the ISC license.
60
65
  * See the LICENSE file in the root directory of this source tree.
61
- */const hh=e=>{const t=iE(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
66
+ */const mh=e=>{const t=b1(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
62
67
  * @license lucide-react v0.563.0 - ISC
63
68
  *
64
69
  * This source code is licensed under the ISC license.
65
70
  * See the LICENSE file in the root directory of this source tree.
66
- */var cE={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
71
+ */var g1={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
67
72
  * @license lucide-react v0.563.0 - ISC
68
73
  *
69
74
  * This source code is licensed under the ISC license.
70
75
  * See the LICENSE file in the root directory of this source tree.
71
- */const dE=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
76
+ */const y1=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};/**
72
77
  * @license lucide-react v0.563.0 - ISC
73
78
  *
74
79
  * This source code is licensed under the ISC license.
75
80
  * See the LICENSE file in the root directory of this source tree.
76
- */const uE=P.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:n="",children:s,iconNode:a,...i},c)=>P.createElement("svg",{ref:c,...cE,width:t,height:t,stroke:e,strokeWidth:o?Number(r)*24/Number(t):r,className:ph("lucide",n),...!s&&!dE(i)&&{"aria-hidden":"true"},...i},[...a.map(([d,p])=>P.createElement(d,p)),...Array.isArray(s)?s:[s]]));/**
81
+ */const v1=P.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:n="",children:a,iconNode:s,...l},c)=>P.createElement("svg",{ref:c,...g1,width:t,height:t,stroke:e,strokeWidth:o?Number(r)*24/Number(t):r,className:hh("lucide",n),...!a&&!y1(l)&&{"aria-hidden":"true"},...l},[...s.map(([d,p])=>P.createElement(d,p)),...Array.isArray(a)?a:[a]]));/**
77
82
  * @license lucide-react v0.563.0 - ISC
78
83
  *
79
84
  * This source code is licensed under the ISC license.
80
85
  * See the LICENSE file in the root directory of this source tree.
81
- */const St=(e,t)=>{const r=P.forwardRef(({className:o,...n},s)=>P.createElement(uE,{ref:s,iconNode:t,className:ph(`lucide-${lE(hh(e))}`,`lucide-${e}`,o),...n}));return r.displayName=hh(e),r};/**
86
+ */const Dt=(e,t)=>{const r=P.forwardRef(({className:o,...n},a)=>P.createElement(v1,{ref:a,iconNode:t,className:hh(`lucide-${m1(mh(e))}`,`lucide-${e}`,o),...n}));return r.displayName=mh(e),r};/**
82
87
  * @license lucide-react v0.563.0 - ISC
83
88
  *
84
89
  * This source code is licensed under the ISC license.
85
90
  * See the LICENSE file in the root directory of this source tree.
86
- */const fE=St("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
91
+ */const w1=Dt("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
87
92
  * @license lucide-react v0.563.0 - ISC
88
93
  *
89
94
  * This source code is licensed under the ISC license.
90
95
  * See the LICENSE file in the root directory of this source tree.
91
- */const mh=St("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
96
+ */const bh=Dt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
92
97
  * @license lucide-react v0.563.0 - ISC
93
98
  *
94
99
  * This source code is licensed under the ISC license.
95
100
  * See the LICENSE file in the root directory of this source tree.
96
- */const mn=St("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
101
+ */const vn=Dt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
97
102
  * @license lucide-react v0.563.0 - ISC
98
103
  *
99
104
  * This source code is licensed under the ISC license.
100
105
  * See the LICENSE file in the root directory of this source tree.
101
- */const gh=St("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
106
+ */const gh=Dt("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
102
107
  * @license lucide-react v0.563.0 - ISC
103
108
  *
104
109
  * This source code is licensed under the ISC license.
105
110
  * See the LICENSE file in the root directory of this source tree.
106
- */const pE=St("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
111
+ */const x1=Dt("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
107
112
  * @license lucide-react v0.563.0 - ISC
108
113
  *
109
114
  * This source code is licensed under the ISC license.
110
115
  * See the LICENSE file in the root directory of this source tree.
111
- */const hE=St("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);/**
116
+ */const C1=Dt("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);/**
112
117
  * @license lucide-react v0.563.0 - ISC
113
118
  *
114
119
  * This source code is licensed under the ISC license.
115
120
  * See the LICENSE file in the root directory of this source tree.
116
- */const bh=St("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
121
+ */const yh=Dt("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
117
122
  * @license lucide-react v0.563.0 - ISC
118
123
  *
119
124
  * This source code is licensed under the ISC license.
120
125
  * See the LICENSE file in the root directory of this source tree.
121
- */const mE=St("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
126
+ */const S1=Dt("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
122
127
  * @license lucide-react v0.563.0 - ISC
123
128
  *
124
129
  * This source code is licensed under the ISC license.
125
130
  * See the LICENSE file in the root directory of this source tree.
126
- */const yh=St("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
131
+ */const vh=Dt("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
127
132
  * @license lucide-react v0.563.0 - ISC
128
133
  *
129
134
  * This source code is licensed under the ISC license.
130
135
  * See the LICENSE file in the root directory of this source tree.
131
- */const gE=St("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
136
+ */const N1=Dt("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
132
137
  * @license lucide-react v0.563.0 - ISC
133
138
  *
134
139
  * This source code is licensed under the ISC license.
135
140
  * See the LICENSE file in the root directory of this source tree.
136
- */const hc=St("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
141
+ */const hc=Dt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
137
142
  * @license lucide-react v0.563.0 - ISC
138
143
  *
139
144
  * This source code is licensed under the ISC license.
140
145
  * See the LICENSE file in the root directory of this source tree.
141
- */const bE=St("redo-2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/**
146
+ */const E1=Dt("redo-2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/**
142
147
  * @license lucide-react v0.563.0 - ISC
143
148
  *
144
149
  * This source code is licensed under the ISC license.
145
150
  * See the LICENSE file in the root directory of this source tree.
146
- */const yE=St("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/**
151
+ */const k1=Dt("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/**
147
152
  * @license lucide-react v0.563.0 - ISC
148
153
  *
149
154
  * This source code is licensed under the ISC license.
150
155
  * See the LICENSE file in the root directory of this source tree.
151
- */const vh=St("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/**
156
+ */const wh=Dt("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/**
152
157
  * @license lucide-react v0.563.0 - ISC
153
158
  *
154
159
  * This source code is licensed under the ISC license.
155
160
  * See the LICENSE file in the root directory of this source tree.
156
- */const mc=St("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);/**
161
+ */const mc=Dt("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);/**
157
162
  * @license lucide-react v0.563.0 - ISC
158
163
  *
159
164
  * This source code is licensed under the ISC license.
160
165
  * See the LICENSE file in the root directory of this source tree.
161
- */const vE=St("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/**
166
+ */const A1=Dt("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/**
162
167
  * @license lucide-react v0.563.0 - ISC
163
168
  *
164
169
  * This source code is licensed under the ISC license.
165
170
  * See the LICENSE file in the root directory of this source tree.
166
- */const xE=St("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);/**
171
+ */const _1=Dt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);/**
167
172
  * @license lucide-react v0.563.0 - ISC
168
173
  *
169
174
  * This source code is licensed under the ISC license.
170
175
  * See the LICENSE file in the root directory of this source tree.
171
- */const Wn=St("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Ta=FC,Pa=zC,Hn=S.forwardRef(({className:e,children:t,...r},o)=>l.jsxs(Xp,{ref:o,className:m("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...r,children:[t,l.jsx(BC,{asChild:!0,children:l.jsx(mn,{className:m("h-4 w-4 opacity-50")})})]}));Hn.displayName=Xp.displayName;const xh=S.forwardRef(({className:e,...t},r)=>l.jsx(ah,{ref:r,className:m("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(gh,{className:m("h-4 w-4")})}));xh.displayName=ah.displayName;const wh=S.forwardRef(({className:e,...t},r)=>l.jsx(ih,{ref:r,className:m("flex cursor-default items-center justify-center py-1",e),...t,children:l.jsx(mn,{className:m("h-4 w-4")})}));wh.displayName=ih.displayName;const jn=S.forwardRef(({className:e,children:t,position:r="popper",...o},n)=>l.jsx(jC,{children:l.jsxs(Jp,{ref:n,className:m("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...o,children:[l.jsx(xh,{}),l.jsx(XC,{className:m("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),l.jsx(wh,{})]})}));jn.displayName=Jp.displayName;const wE=S.forwardRef(({className:e,...t},r)=>l.jsx(rh,{ref:r,className:m("px-2 py-1.5 text-sm font-semibold",e),...t}));wE.displayName=rh.displayName;const Vo=S.forwardRef(({className:e,children:t,...r},o)=>l.jsxs(nh,{ref:o,className:m("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[l.jsx("span",{className:m("absolute right-2 flex h-3.5 w-3.5 items-center justify-center"),children:l.jsx(nE,{children:l.jsx(mh,{className:m("h-4 w-4")})})}),l.jsx(rE,{children:t})]}));Vo.displayName=nh.displayName;const SE=S.forwardRef(({className:e,...t},r)=>l.jsx(dh,{ref:r,className:m("-mx-1 my-1 h-px bg-muted",e),...t}));SE.displayName=dh.displayName;const Go=[{code:"US",name:"United States",dialCode:"+1",flag:"🇺🇸"},{code:"GB",name:"United Kingdom",dialCode:"+44",flag:"🇬🇧"},{code:"CA",name:"Canada",dialCode:"+1",flag:"🇨🇦"},{code:"AU",name:"Australia",dialCode:"+61",flag:"🇦🇺"},{code:"DE",name:"Germany",dialCode:"+49",flag:"🇩🇪"},{code:"FR",name:"France",dialCode:"+33",flag:"🇫🇷"},{code:"IT",name:"Italy",dialCode:"+39",flag:"🇮🇹"},{code:"ES",name:"Spain",dialCode:"+34",flag:"🇪🇸"},{code:"NL",name:"Netherlands",dialCode:"+31",flag:"🇳🇱"},{code:"BE",name:"Belgium",dialCode:"+32",flag:"🇧🇪"},{code:"CH",name:"Switzerland",dialCode:"+41",flag:"🇨🇭"},{code:"AT",name:"Austria",dialCode:"+43",flag:"🇦🇹"},{code:"SE",name:"Sweden",dialCode:"+46",flag:"🇸🇪"},{code:"NO",name:"Norway",dialCode:"+47",flag:"🇳🇴"},{code:"DK",name:"Denmark",dialCode:"+45",flag:"🇩🇰"},{code:"FI",name:"Finland",dialCode:"+358",flag:"🇫🇮"},{code:"IE",name:"Ireland",dialCode:"+353",flag:"🇮🇪"},{code:"PT",name:"Portugal",dialCode:"+351",flag:"🇵🇹"},{code:"GR",name:"Greece",dialCode:"+30",flag:"🇬🇷"},{code:"PL",name:"Poland",dialCode:"+48",flag:"🇵🇱"},{code:"CZ",name:"Czech Republic",dialCode:"+420",flag:"🇨🇿"},{code:"HU",name:"Hungary",dialCode:"+36",flag:"🇭🇺"},{code:"RO",name:"Romania",dialCode:"+40",flag:"🇷🇴"},{code:"BG",name:"Bulgaria",dialCode:"+359",flag:"🇧🇬"},{code:"HR",name:"Croatia",dialCode:"+385",flag:"🇭🇷"},{code:"SK",name:"Slovakia",dialCode:"+421",flag:"🇸🇰"},{code:"SI",name:"Slovenia",dialCode:"+386",flag:"🇸🇮"},{code:"RS",name:"Serbia",dialCode:"+381",flag:"🇷🇸"},{code:"UA",name:"Ukraine",dialCode:"+380",flag:"🇺🇦"},{code:"RU",name:"Russia",dialCode:"+7",flag:"🇷🇺"},{code:"TR",name:"Turkey",dialCode:"+90",flag:"🇹🇷"},{code:"IL",name:"Israel",dialCode:"+972",flag:"🇮🇱"},{code:"SA",name:"Saudi Arabia",dialCode:"+966",flag:"🇸🇦"},{code:"AE",name:"United Arab Emirates",dialCode:"+971",flag:"🇦🇪"},{code:"QA",name:"Qatar",dialCode:"+974",flag:"🇶🇦"},{code:"KW",name:"Kuwait",dialCode:"+965",flag:"🇰🇼"},{code:"BH",name:"Bahrain",dialCode:"+973",flag:"🇧🇭"},{code:"OM",name:"Oman",dialCode:"+968",flag:"🇴🇲"},{code:"EG",name:"Egypt",dialCode:"+20",flag:"🇪🇬"},{code:"MA",name:"Morocco",dialCode:"+212",flag:"🇲🇦"},{code:"ZA",name:"South Africa",dialCode:"+27",flag:"🇿🇦"},{code:"NG",name:"Nigeria",dialCode:"+234",flag:"🇳🇬"},{code:"KE",name:"Kenya",dialCode:"+254",flag:"🇰🇪"},{code:"GH",name:"Ghana",dialCode:"+233",flag:"🇬🇭"},{code:"IN",name:"India",dialCode:"+91",flag:"🇮🇳"},{code:"PK",name:"Pakistan",dialCode:"+92",flag:"🇵🇰"},{code:"BD",name:"Bangladesh",dialCode:"+880",flag:"🇧🇩"},{code:"CN",name:"China",dialCode:"+86",flag:"🇨🇳"},{code:"JP",name:"Japan",dialCode:"+81",flag:"🇯🇵"},{code:"KR",name:"South Korea",dialCode:"+82",flag:"🇰🇷"},{code:"TW",name:"Taiwan",dialCode:"+886",flag:"🇹🇼"},{code:"HK",name:"Hong Kong",dialCode:"+852",flag:"🇭🇰"},{code:"SG",name:"Singapore",dialCode:"+65",flag:"🇸🇬"},{code:"MY",name:"Malaysia",dialCode:"+60",flag:"🇲🇾"},{code:"TH",name:"Thailand",dialCode:"+66",flag:"🇹🇭"},{code:"VN",name:"Vietnam",dialCode:"+84",flag:"🇻🇳"},{code:"ID",name:"Indonesia",dialCode:"+62",flag:"🇮🇩"},{code:"PH",name:"Philippines",dialCode:"+63",flag:"🇵🇭"},{code:"NZ",name:"New Zealand",dialCode:"+64",flag:"🇳🇿"},{code:"MX",name:"Mexico",dialCode:"+52",flag:"🇲🇽"},{code:"BR",name:"Brazil",dialCode:"+55",flag:"🇧🇷"},{code:"AR",name:"Argentina",dialCode:"+54",flag:"🇦🇷"},{code:"CL",name:"Chile",dialCode:"+56",flag:"🇨🇱"},{code:"CO",name:"Colombia",dialCode:"+57",flag:"🇨🇴"},{code:"PE",name:"Peru",dialCode:"+51",flag:"🇵🇪"},{code:"VE",name:"Venezuela",dialCode:"+58",flag:"🇻🇪"},{code:"EC",name:"Ecuador",dialCode:"+593",flag:"🇪🇨"},{code:"UY",name:"Uruguay",dialCode:"+598",flag:"🇺🇾"},{code:"PY",name:"Paraguay",dialCode:"+595",flag:"🇵🇾"},{code:"BO",name:"Bolivia",dialCode:"+591",flag:"🇧🇴"},{code:"CR",name:"Costa Rica",dialCode:"+506",flag:"🇨🇷"},{code:"PA",name:"Panama",dialCode:"+507",flag:"🇵🇦"},{code:"DO",name:"Dominican Republic",dialCode:"+1",flag:"🇩🇴"},{code:"PR",name:"Puerto Rico",dialCode:"+1",flag:"🇵🇷"},{code:"JM",name:"Jamaica",dialCode:"+1",flag:"🇯🇲"},{code:"TT",name:"Trinidad and Tobago",dialCode:"+1",flag:"🇹🇹"},{code:"IS",name:"Iceland",dialCode:"+354",flag:"🇮🇸"},{code:"LU",name:"Luxembourg",dialCode:"+352",flag:"🇱🇺"},{code:"MT",name:"Malta",dialCode:"+356",flag:"🇲🇹"},{code:"CY",name:"Cyprus",dialCode:"+357",flag:"🇨🇾"},{code:"EE",name:"Estonia",dialCode:"+372",flag:"🇪🇪"},{code:"LV",name:"Latvia",dialCode:"+371",flag:"🇱🇻"},{code:"LT",name:"Lithuania",dialCode:"+370",flag:"🇱🇹"}],NE=[...Go].sort((e,t)=>e.name.localeCompare(t.name)),qn=e=>Go.find(t=>t.code===e),CE=(e,t="US")=>{const r=qn(t)||Go[0];if(!e)return{countryCode:r.code,dialCode:r.dialCode,number:""};if(e.startsWith("+")){for(const o of Go)if(e.startsWith(o.dialCode))return{countryCode:o.code,dialCode:o.dialCode,number:e.slice(o.dialCode.length).trim()}}return{countryCode:r.code,dialCode:r.dialCode,number:e.replace(/^\+/,"")}},EE=({value:e,onChange:t,onBlur:r,defaultCountry:o="US",disabled:n=!1,placeholder:s="Phone number",hasError:a=!1,className:i,inputClassName:c})=>{const d=P.useMemo(()=>{if(!e){const N=qn(o)||Go[0];return{countryCode:N.code,dialCode:N.dialCode,number:""}}return typeof e=="string"?CE(e,o):e},[e,o]),[p,u]=P.useState(d.countryCode),[f,h]=P.useState(d.number),g=P.useRef(null);P.useEffect(()=>{u(d.countryCode),h(d.number)},[d.countryCode,d.number]);const y=P.useMemo(()=>qn(p)||Go[0],[p]),b=N=>{const x=qn(N);if(x){u(N);const w={countryCode:x.code,dialCode:x.dialCode,number:f};t==null||t(w)}},v=N=>{const x=N.target.value.replace(/[^\d\s\-()]/g,"");h(x),t==null||t({countryCode:y.code,dialCode:y.dialCode,number:x})};return l.jsxs("div",{className:m("flex",i),children:[l.jsxs(Ta,{value:p,onValueChange:b,disabled:n,children:[l.jsx(Hn,{className:m("w-[110px] rounded-r-none border-r-0 focus:z-10",a&&"border-red-500",n&&"opacity-50 cursor-not-allowed"),children:l.jsx(Pa,{children:l.jsxs("span",{className:m("flex items-center gap-1.5"),children:[l.jsx("span",{className:m("text-base"),children:y.flag}),l.jsx("span",{className:m("text-sm text-muted-foreground"),children:y.dialCode})]})})}),l.jsx(jn,{className:m("max-h-[300px]"),children:NE.map(N=>l.jsx(Vo,{value:N.code,className:m("cursor-pointer"),children:l.jsxs("span",{className:m("flex items-center gap-2"),children:[l.jsx("span",{className:m("text-base"),children:N.flag}),l.jsx("span",{className:m("flex-1"),children:N.name}),l.jsx("span",{className:m("text-muted-foreground text-sm"),children:N.dialCode})]})},N.code))})]}),l.jsx("input",{ref:g,type:"tel",value:f,onChange:v,onBlur:r,disabled:n,placeholder:s,className:m("flex-1 h-9 rounded-l-none rounded-r-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm transition-colors","placeholder:text-muted-foreground","focus:outline-none focus:ring-1 focus:ring-ring","disabled:cursor-not-allowed disabled:opacity-50",a&&"border-red-500 focus:ring-red-500",c)})]})},_E=({defaultCountry:e="US",placeholder:t="Phone number",className:r})=>{const o=qn(e)||Go[0];return l.jsxs("div",{className:m("flex",r),children:[l.jsxs("div",{className:m("flex items-center gap-1.5 h-9 px-3 rounded-l-md border border-r-0 border-input bg-muted/50 text-sm"),children:[l.jsx("span",{className:m("text-base"),children:o.flag}),l.jsx("span",{className:m("text-muted-foreground"),children:o.dialCode}),l.jsx("svg",{className:m("h-4 w-4 opacity-50"),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:l.jsx("path",{d:"m6 9 6 6 6-6"})})]}),l.jsx("input",{type:"tel",placeholder:t,disabled:!0,className:m("flex-1 h-9 rounded-l-none rounded-r-md border border-input bg-muted/50 px-3 py-2 text-sm","placeholder:text-muted-foreground","disabled:cursor-not-allowed disabled:opacity-50")})]})},kE=[{type:"email",structure:"field",typeCategory:"Contact",label:"Email",description:"Email address input",icon:"✉️",category:"field",subCategory:"contact",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!1,showSuffix:!1},fields:[]},getDefaultValues:()=>({properties:{label:"Email",placeholder:"email@example.com"},layout:{labelPosition:"top",size:"full"},validation:{}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,children:l.jsx(To,{icon:"✉️",children:l.jsx("input",{type:"email",placeholder:o||"email@example.com",disabled:!0,className:m(`${kt()} pl-10`)})})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,value:a,onChange:i,errors:c,isDisabled:d}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,errors:c,children:l.jsx(To,{icon:"✉️",children:l.jsx("input",{type:"email",placeholder:o||"email@example.com",value:a??"",onChange:p=>i==null?void 0:i(p.target.value),disabled:d,className:m(`${Ut({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})} pl-10`)})})})}},{type:"phone",structure:"field",typeCategory:"Contact",label:"Phone",description:"Phone number input with country code",icon:"📱",category:"field",subCategory:"contact",dataType:"object",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!1,showSuffix:!1},configSection:{title:"Phone Settings",icon:"📱"},fields:[{key:"defaultCountry",label:"Default Country",type:"select",section:"config",options:[{value:"US",label:"🇺🇸 United States (+1)"},{value:"GB",label:"🇬🇧 United Kingdom (+44)"},{value:"CA",label:"🇨🇦 Canada (+1)"},{value:"AU",label:"🇦🇺 Australia (+61)"},{value:"DE",label:"🇩🇪 Germany (+49)"},{value:"FR",label:"🇫🇷 France (+33)"},{value:"IT",label:"🇮🇹 Italy (+39)"},{value:"ES",label:"🇪🇸 Spain (+34)"},{value:"NL",label:"🇳🇱 Netherlands (+31)"},{value:"BE",label:"🇧🇪 Belgium (+32)"},{value:"CH",label:"🇨🇭 Switzerland (+41)"},{value:"AT",label:"🇦🇹 Austria (+43)"},{value:"SE",label:"🇸🇪 Sweden (+46)"},{value:"NO",label:"🇳🇴 Norway (+47)"},{value:"DK",label:"🇩🇰 Denmark (+45)"},{value:"FI",label:"🇫🇮 Finland (+358)"},{value:"IE",label:"🇮🇪 Ireland (+353)"},{value:"PT",label:"🇵🇹 Portugal (+351)"},{value:"PL",label:"🇵🇱 Poland (+48)"},{value:"TR",label:"🇹🇷 Turkey (+90)"},{value:"IN",label:"🇮🇳 India (+91)"},{value:"JP",label:"🇯🇵 Japan (+81)"},{value:"KR",label:"🇰🇷 South Korea (+82)"},{value:"BR",label:"🇧🇷 Brazil (+55)"},{value:"MX",label:"🇲🇽 Mexico (+52)"}]},{key:"format",label:"Number Format",type:"select",section:"config",options:[{value:"international",label:"International (+1 555 123 4567)"},{value:"national",label:"National ((555) 123-4567)"}]}]},getDefaultValues:()=>({properties:{label:"Phone",placeholder:"Phone number"},layout:{labelPosition:"top",size:"full"},config:{defaultCountry:"US",format:"international"}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,config:a}=K(e),i=(a==null?void 0:a.defaultCountry)||"US";return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,children:l.jsx(_E,{defaultCountry:i,placeholder:o||"Phone number"})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,value:a,onChange:i,errors:c,isDisabled:d,config:p}=K(e),u=(p==null?void 0:p.defaultCountry)||"US",f=h=>{i==null||i(h)};return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,errors:c,children:l.jsx(EE,{value:a,onChange:f,defaultCountry:u,disabled:d,placeholder:o||"Phone number",hasError:((c==null?void 0:c.length)??0)>0})})}},{type:"url",structure:"field",typeCategory:"Contact",label:"URL",description:"Website URL input",icon:"🔗",category:"field",subCategory:"contact",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!1,showSuffix:!1},fields:[]},getDefaultValues:()=>({properties:{label:"Website",placeholder:"https://example.com"},layout:{labelPosition:"top",size:"full"}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,children:l.jsx(To,{icon:"🔗",children:l.jsx("input",{type:"url",placeholder:o||"https://example.com",disabled:!0,className:m(`${kt()} pl-10`)})})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,value:a,onChange:i,errors:c,isDisabled:d}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,errors:c,children:l.jsx(To,{icon:"🔗",children:l.jsx("input",{type:"url",placeholder:o||"https://example.com",value:a??"",onChange:p=>i==null?void 0:i(p.target.value),disabled:d,className:m(`${Ut({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})} pl-10`)})})})}},{type:"location",structure:"field",typeCategory:"Contact",label:"Location",description:"Address/location input",icon:"📍",category:"field",subCategory:"contact",dataType:"object",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!1,showSuffix:!1},configSection:{title:"Location Settings",icon:"📍"},fields:[{key:"enableGeolocation",label:"Enable Geolocation",type:"checkbox",section:"config",description:"Allow auto-detect location"},{key:"showMap",label:"Show Map",type:"checkbox",section:"config",description:"Display map preview"},{key:"mapProvider",label:"Map Provider",type:"select",section:"config",showWhen:{field:"showMap",value:!0},options:[{value:"google",label:"Google Maps"},{value:"openstreetmap",label:"OpenStreetMap"}]}]},getDefaultValues:()=>({properties:{label:"Location",placeholder:"Enter address...",description:"Enter your address"},layout:{labelPosition:"top",size:"full"},config:{enableGeolocation:!1,showMap:!1,mapProvider:"openstreetmap"}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,config:a}=K(e);return l.jsxs(de,{label:t,description:r,required:n,labelPosition:s,children:[l.jsx(To,{icon:"📍",children:l.jsx("input",{type:"text",placeholder:o||"Enter address...",disabled:!0,className:m(`${kt()} pl-10`)})}),(a==null?void 0:a.showMap)&&l.jsx("div",{className:m("h-32 bg-gray-200 rounded-md flex items-center justify-center text-gray-400 text-sm mt-2"),children:"🗺️ Map Preview"})]})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,value:a,onChange:i,errors:c,isDisabled:d,config:p}=K(e);return l.jsx(de,{label:t,description:r,required:n,labelPosition:s,errors:c,children:l.jsxs("div",{className:m("space-y-2"),children:[l.jsx(To,{icon:"📍",children:l.jsx("input",{type:"text",placeholder:o||"Enter address...",value:typeof a=="string"?a:(a==null?void 0:a.address)??"",onChange:u=>i==null?void 0:i(u.target.value),disabled:d,className:m(`${Ut({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})} pl-10`)})}),(p==null?void 0:p.enableGeolocation)&&!d&&l.jsx("button",{type:"button",className:m("text-sm text-blue-600 hover:text-blue-700 flex items-center gap-1"),children:"📍 Use current location"}),(p==null?void 0:p.showMap)&&l.jsx("div",{className:m("h-32 bg-gray-200 rounded-md flex items-center justify-center text-gray-400 text-sm"),children:"🗺️ Map Preview"})]})})}}],AE=[{type:"date",structure:"field",typeCategory:"DateTime",label:"Date",description:"Date picker input",icon:"📅",category:"field",subCategory:"dateTime",dataType:"date",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Date Settings",icon:"📅"},fields:[{key:"format",label:"Display Format",type:"select",section:"config",options:[{value:"YYYY-MM-DD",label:"YYYY-MM-DD (2025-01-15)"},{value:"DD/MM/YYYY",label:"DD/MM/YYYY (15/01/2025)"},{value:"MM/DD/YYYY",label:"MM/DD/YYYY (01/15/2025)"},{value:"MMMM D, YYYY",label:"MMMM D, YYYY (January 15, 2025)"}]},{key:"showCalendar",label:"Show Calendar Picker",type:"checkbox",section:"config",description:"Display a calendar dropdown for date selection"},{key:"minDate",label:"Min Date",type:"text",section:"config",placeholder:"YYYY-MM-DD",description:"Earliest selectable date"},{key:"maxDate",label:"Max Date",type:"text",section:"config",placeholder:"YYYY-MM-DD",description:"Latest selectable date"},{key:"disableWeekends",label:"Disable Weekends",type:"checkbox",section:"config",description:"Prevent selecting Saturday and Sunday"}]},getDefaultValues:()=>({properties:{label:"Date",placeholder:"Select a date"},layout:{labelPosition:"top",size:"full"},config:{format:"YYYY-MM-DD",showCalendar:!0}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n}=K(e);return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsx("input",{type:"date",disabled:!0,className:kt()})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c}=K(e);return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsx("input",{type:"date",value:s??"",onChange:d=>a==null?void 0:a(d.target.value),disabled:c,className:Ut({hasError:((i==null?void 0:i.length)??0)>0,disabled:c})})})}},{type:"time",structure:"field",typeCategory:"DateTime",label:"Time",description:"Time picker input",icon:"🕐",category:"field",subCategory:"dateTime",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Time Settings",icon:"⏰"},fields:[{key:"timeFormat",label:"Time Format",type:"select",section:"config",options:[{value:"12h",label:"12-hour (AM / PM)"},{value:"24h",label:"24-hour"}]},{key:"timeInterval",label:"Minute Interval",type:"select",section:"config",description:"Granularity for the time dropdown",options:[{value:5,label:"5 minutes"},{value:10,label:"10 minutes"},{value:15,label:"15 minutes"},{value:30,label:"30 minutes"},{value:60,label:"1 hour"}]},{key:"minTime",label:"Earliest Time",type:"text",section:"config",placeholder:"09:00",description:"Minimum selectable time",colSpan:1},{key:"maxTime",label:"Latest Time",type:"text",section:"config",placeholder:"17:00",description:"Maximum selectable time",colSpan:1},{key:"showNowButton",label:'Show "Now" Button',type:"checkbox",section:"config",description:"Quick-fill with the current time"}]},getDefaultValues:()=>({properties:{label:"Time",placeholder:"Select a time"},layout:{labelPosition:"top",size:"full"},config:{timeFormat:"24h",timeInterval:15}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n}=K(e);return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsx("input",{type:"time",disabled:!0,className:kt()})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c}=K(e);return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsx("input",{type:"time",value:s??"",onChange:d=>a==null?void 0:a(d.target.value),disabled:c,className:Ut({hasError:((i==null?void 0:i.length)??0)>0,disabled:c})})})}},{type:"dateTime",structure:"field",typeCategory:"DateTime",label:"Date & Time",description:"Combined date and time picker",icon:"📆",category:"field",subCategory:"dateTime",dataType:"date",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Date & Time Settings",icon:"📅"},fields:[{key:"format",label:"Date Format",type:"select",section:"config",options:[{value:"YYYY-MM-DD",label:"YYYY-MM-DD"},{value:"DD/MM/YYYY",label:"DD/MM/YYYY"},{value:"MM/DD/YYYY",label:"MM/DD/YYYY"},{value:"MMMM D, YYYY",label:"MMMM D, YYYY"}]},{key:"timeFormat",label:"Time Format",type:"select",section:"config",options:[{value:"12h",label:"12-hour (AM / PM)"},{value:"24h",label:"24-hour"}]},{key:"timeInterval",label:"Minute Interval",type:"select",section:"config",options:[{value:5,label:"5 minutes"},{value:10,label:"10 minutes"},{value:15,label:"15 minutes"},{value:30,label:"30 minutes"},{value:60,label:"1 hour"}]},{key:"minDate",label:"Min Date",type:"text",section:"config",placeholder:"YYYY-MM-DD",colSpan:1},{key:"maxDate",label:"Max Date",type:"text",section:"config",placeholder:"YYYY-MM-DD",colSpan:1},{key:"showSeconds",label:"Show Seconds",type:"checkbox",section:"config",description:"Include seconds in the time picker"}]},getDefaultValues:()=>({properties:{label:"Date & Time",placeholder:"Select date and time"},layout:{labelPosition:"top",size:"full"},config:{format:"YYYY-MM-DD",timeFormat:"24h",timeInterval:15}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n}=K(e);return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsxs("div",{className:m("flex gap-2"),children:[l.jsx("input",{type:"date",disabled:!0,className:`flex-1 ${kt()}`}),l.jsx("input",{type:"time",disabled:!0,className:`w-32 ${kt()}`})]})})},render:e=>{var g;const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c}=K(e),d=typeof s=="object"?s==null?void 0:s.date:(s==null?void 0:s.split("T")[0])??"",p=typeof s=="object"?s==null?void 0:s.time:((g=s==null?void 0:s.split("T")[1])==null?void 0:g.substring(0,5))??"",u=y=>{typeof s=="object"?a==null||a({...s,date:y}):a==null||a(`${y}T${p||"00:00"}`)},f=y=>{typeof s=="object"?a==null||a({...s,time:y}):a==null||a(`${d||""}T${y}`)},h=Ut({hasError:((i==null?void 0:i.length)??0)>0,disabled:c});return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsxs("div",{className:m("flex gap-2"),children:[l.jsx("input",{type:"date",value:d,onChange:y=>u(y.target.value),disabled:c,className:`flex-1 ${h}`}),l.jsx("input",{type:"time",value:p,onChange:y=>f(y.target.value),disabled:c,className:`w-32 ${h}`})]})})}},{type:"multipleDates",structure:"field",typeCategory:"DateTime",label:"Multiple Dates",description:"Select multiple dates",icon:"📅",category:"field",subCategory:"dateTime",dataType:"array",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Multiple Dates Settings",icon:"📆"},fields:[{key:"format",label:"Display Format",type:"select",section:"config",options:[{value:"YYYY-MM-DD",label:"YYYY-MM-DD"},{value:"DD/MM/YYYY",label:"DD/MM/YYYY"},{value:"MM/DD/YYYY",label:"MM/DD/YYYY"},{value:"MMMM D, YYYY",label:"MMMM D, YYYY"}]},{key:"showCalendar",label:"Show Calendar Picker",type:"checkbox",section:"config",description:"Display a calendar for multi-date selection"},{key:"minDates",label:"Min Dates",type:"number",section:"validation",min:1,placeholder:"1",description:"Minimum number of dates to select",colSpan:1},{key:"maxDates",label:"Max Dates",type:"number",section:"validation",min:1,placeholder:"10",description:"Maximum number of dates allowed",colSpan:1},{key:"allowPastDates",label:"Allow Past Dates",type:"checkbox",section:"config",description:"Let users select dates in the past"},{key:"disableWeekends",label:"Disable Weekends",type:"checkbox",section:"config",description:"Prevent selecting Saturday and Sunday"}]},getDefaultValues:()=>({properties:{label:"Multiple Dates",placeholder:"Add dates",description:"Select one or more dates"},layout:{labelPosition:"top",size:"full"},config:{format:"YYYY-MM-DD",showCalendar:!0}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n}=K(e);return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsxs("div",{className:m("space-y-2"),children:[l.jsxs("div",{className:m("flex flex-wrap gap-2"),children:[l.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-800 text-sm rounded"),children:["2024-01-15",l.jsx("button",{disabled:!0,className:m("text-blue-600"),children:"×"})]}),l.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-800 text-sm rounded"),children:["2024-01-20",l.jsx("button",{disabled:!0,className:m("text-blue-600"),children:"×"})]})]}),l.jsx("input",{type:"date",disabled:!0,className:kt()})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c}=K(e),d=Array.isArray(s)?s:[],p=f=>{f&&!d.includes(f)&&(a==null||a([...d,f]))},u=f=>{a==null||a(d.filter(h=>h!==f))};return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsxs("div",{className:m("space-y-2"),children:[d.length>0&&l.jsx("div",{className:m("flex flex-wrap gap-2"),children:d.map((f,h)=>l.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-800 text-sm rounded"),children:[f,!c&&l.jsx("button",{type:"button",onClick:()=>u(f),className:m("text-blue-600 hover:text-blue-800"),children:"×"})]},h))}),l.jsx("input",{type:"date",onChange:f=>{p(f.target.value),f.target.value=""},disabled:c,className:Ut({hasError:((i==null?void 0:i.length)??0)>0,disabled:c})})]})})}},{type:"dateRange",structure:"field",typeCategory:"DateTime",label:"Date Range",description:"Select a date range",icon:"📆",category:"field",subCategory:"dateTime",dataType:"object",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Date Range Settings",icon:"📊"},fields:[{key:"format",label:"Display Format",type:"select",section:"config",options:[{value:"YYYY-MM-DD",label:"YYYY-MM-DD"},{value:"DD/MM/YYYY",label:"DD/MM/YYYY"},{value:"MM/DD/YYYY",label:"MM/DD/YYYY"},{value:"MMMM D, YYYY",label:"MMMM D, YYYY"}]},{key:"showCalendar",label:"Show Calendar Picker",type:"checkbox",section:"config",description:"Display a calendar range selector"},{key:"minDays",label:"Min Days",type:"number",section:"config",min:1,placeholder:"1",description:"Minimum length of the selected range",colSpan:1},{key:"maxDays",label:"Max Days",type:"number",section:"config",min:1,placeholder:"30",description:"Maximum length of the selected range",colSpan:1},{key:"allowSameDayRange",label:"Allow Same-Day Range",type:"checkbox",section:"config",description:"Start and end date can be the same day"},{key:"disableWeekends",label:"Disable Weekends",type:"checkbox",section:"config",description:"Exclude Saturday and Sunday from selection"},{key:"minDate",label:"Earliest Start Date",type:"text",section:"config",placeholder:"YYYY-MM-DD",description:"First selectable date in the range"},{key:"maxDate",label:"Latest End Date",type:"text",section:"config",placeholder:"YYYY-MM-DD",description:"Last selectable date in the range"}]},getDefaultValues:()=>({properties:{label:"Date Range",placeholder:"Select date range",description:"Select start and end dates"},layout:{labelPosition:"top",size:"full"},config:{format:"YYYY-MM-DD",showCalendar:!0,minDays:1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n}=K(e);return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsxs("div",{className:m("flex items-center gap-2"),children:[l.jsx("input",{type:"date",disabled:!0,placeholder:"Start date",className:`flex-1 ${kt()}`}),l.jsx("span",{className:m("text-gray-400"),children:"→"}),l.jsx("input",{type:"date",disabled:!0,placeholder:"End date",className:`flex-1 ${kt()}`})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c}=K(e),d=(s==null?void 0:s.start)??"",p=(s==null?void 0:s.end)??"",u=g=>{a==null||a({start:g,end:p})},f=g=>{a==null||a({start:d,end:g})},h=Ut({hasError:((i==null?void 0:i.length)??0)>0,disabled:c});return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsxs("div",{className:m("flex items-center gap-2"),children:[l.jsx("input",{type:"date",value:d,onChange:g=>u(g.target.value),disabled:c,placeholder:"Start date",className:`flex-1 ${h}`}),l.jsx("span",{className:m("text-gray-400"),children:"→"}),l.jsx("input",{type:"date",value:p,onChange:g=>f(g.target.value),disabled:c,min:d,placeholder:"End date",className:`flex-1 ${h}`})]})})}}],DE=[{type:"paragraph",structure:"field",typeCategory:"Display",label:"Paragraph",description:"Static text content",icon:"📜",category:"field",subCategory:"display",dataType:"string",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Paragraph",content:"Enter your paragraph text here. This is a static text element that displays information to users."},layout:{labelPosition:"hidden",size:"full"},config:{textAlign:"left",fontSize:"medium",fontWeight:"normal"}}),renderOnCanvas:e=>{const{element:t,config:r}=K(e),o=t.properties.content||"Enter your paragraph text here.",n={small:"text-sm",medium:"text-base",large:"text-lg"}[(r==null?void 0:r.fontSize)||"medium"],s={normal:"font-normal",medium:"font-medium",bold:"font-bold"}[(r==null?void 0:r.fontWeight)||"normal"];return l.jsx("div",{className:m("prose prose-sm max-w-none"),style:{textAlign:(r==null?void 0:r.textAlign)||"left"},children:l.jsx("p",{className:m("text-gray-700",n,s),children:o})})},render:e=>{const{element:t,config:r}=K(e),o=t.properties.content||"",n={small:"text-sm",medium:"text-base",large:"text-lg"}[(r==null?void 0:r.fontSize)||"medium"],s={normal:"font-normal",medium:"font-medium",bold:"font-bold"}[(r==null?void 0:r.fontWeight)||"normal"];return l.jsx("div",{className:m("prose prose-sm max-w-none"),style:{textAlign:(r==null?void 0:r.textAlign)||"left"},children:l.jsx("p",{className:m("text-gray-700",n,s),children:o})})}},{type:"image",structure:"field",typeCategory:"Display",label:"Image",description:"Display an image",icon:"🖼️",category:"field",subCategory:"display",dataType:"string",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Image",alt:"Image description",src:""},layout:{labelPosition:"hidden",size:"full"},config:{imageWidth:"100%",objectFit:"contain",borderRadius:0}}),renderOnCanvas:e=>{const{element:t,config:r}=K(e),o=t.properties.src,n=t.properties.alt||"Image";return o?l.jsx("div",{className:m("space-y-1.5"),children:l.jsx("img",{src:o,alt:n,className:m("max-w-full rounded"),style:{width:(r==null?void 0:r.imageWidth)||"100%",objectFit:(r==null?void 0:r.objectFit)||"contain",borderRadius:(r==null?void 0:r.borderRadius)||0}})}):l.jsxs("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg p-8 text-center bg-gray-50"),children:[l.jsx("span",{className:m("text-4xl"),children:"🏞️"}),l.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"No image selected"}),l.jsx("p",{className:m("text-xs text-gray-400"),children:"Set image URL in properties"})]})},render:e=>{const{element:t,config:r}=K(e),o=t.properties.src,n=t.properties.alt||"Image";return o?l.jsx("div",{className:m("space-y-1.5"),children:l.jsx("img",{src:o,alt:n,className:m("max-w-full"),style:{width:(r==null?void 0:r.imageWidth)||"100%",objectFit:(r==null?void 0:r.objectFit)||"contain",borderRadius:(r==null?void 0:r.borderRadius)||0}})}):null}},{type:"link",structure:"field",typeCategory:"Display",label:"Link",description:"Clickable link or button",icon:"🔗",category:"field",subCategory:"display",dataType:"string",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Link",href:"https://example.com",content:"Click here",target:"_blank"},layout:{labelPosition:"hidden",size:"default"},config:{linkStyle:"text"}}),renderOnCanvas:e=>{const{element:t,config:r}=K(e),o=t.properties.content||(r==null?void 0:r.linkText)||"Click here",n=t.properties.href||"https://example.com";return(r==null?void 0:r.linkStyle)==="button"?l.jsxs("div",{className:m("space-y-1"),children:[l.jsx("a",{href:"#",onClick:s=>s.preventDefault(),className:m("inline-block px-4 py-2 bg-blue-600 text-white rounded-md text-sm hover:bg-blue-700"),children:o}),l.jsx("p",{className:m("text-xs text-gray-400"),children:n})]}):l.jsxs("div",{className:m("space-y-1"),children:[l.jsx("a",{href:"#",onClick:s=>s.preventDefault(),className:m("text-blue-600 hover:text-blue-800 underline text-sm"),children:o}),l.jsx("p",{className:m("text-xs text-gray-400"),children:n})]})},render:e=>{const{element:t,config:r}=K(e),o=t.properties.content||(r==null?void 0:r.linkText)||"Click here",n=t.properties.href||"#",s=t.properties.target||"_blank";return(r==null?void 0:r.linkStyle)==="button"?l.jsx("a",{href:n,target:s,rel:s==="_blank"?"noopener noreferrer":void 0,className:m("inline-block px-4 py-2 bg-blue-600 text-white rounded-md text-sm hover:bg-blue-700 transition-colors"),children:o}):l.jsx("a",{href:n,target:s,rel:s==="_blank"?"noopener noreferrer":void 0,className:m("text-blue-600 hover:text-blue-800 underline text-sm transition-colors"),children:o})}}],$E=[{type:"divider",structure:"page",typeCategory:"Layout",label:"Divider",description:"Horizontal line separator",icon:"➖",category:"page",subCategory:"layout",supportsValidation:!1,getDefaultValues:()=>({properties:{},layout:{size:"full"},config:{style:"solid",thickness:1,color:"rgb(209, 213, 219)"}}),renderOnCanvas:e=>{const{config:t}=K(e);return l.jsx("hr",{style:{borderStyle:(t==null?void 0:t.style)||"solid",borderWidth:`${(t==null?void 0:t.thickness)||1}px 0 0 0`,borderColor:(t==null?void 0:t.color)||"rgb(209, 213, 219)"}})},render:e=>{const{config:t}=K(e);return l.jsx("hr",{style:{borderStyle:(t==null?void 0:t.style)||"solid",borderWidth:`${(t==null?void 0:t.thickness)||1}px 0 0 0`,borderColor:(t==null?void 0:t.color)||"rgb(209, 213, 219)"}})}},{type:"spacer",structure:"page",typeCategory:"Layout",label:"Spacer",description:"Vertical spacing element",icon:"↕️",category:"page",subCategory:"layout",supportsValidation:!1,getDefaultValues:()=>({properties:{},layout:{size:"full",height:24},config:{spacerHeight:24}}),renderOnCanvas:e=>{const{config:t}=K(e),r=(t==null?void 0:t.spacerHeight)||24;return l.jsx("div",{className:m("bg-gray-100/50 border border-dashed border-gray-300 rounded flex items-center justify-center"),style:{height:r},children:l.jsxs("span",{className:m("text-xs text-gray-400"),children:["↕️ Spacer (",r,"px)"]})})},render:e=>{const{config:t}=K(e),r=(t==null?void 0:t.spacerHeight)||24;return l.jsx("div",{style:{height:r}})}},{type:"formHeading",structure:"page",typeCategory:"Heading",label:"Form Heading",description:"Main form title",icon:"📋",category:"page",subCategory:"heading",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Form Title",description:"Form description goes here"},layout:{size:"full"},config:{level:1,alignment:"left"}}),renderOnCanvas:e=>{const{label:t,description:r,config:o}=K(e);return l.jsxs("div",{className:m(`text-${(o==null?void 0:o.alignment)||"left"}`),children:[l.jsx("h1",{className:m("text-2xl font-bold text-gray-900"),children:t}),r&&l.jsx("p",{className:m("text-gray-600 mt-1"),children:r})]})},render:e=>{const{label:t,description:r,config:o}=K(e);return l.jsxs("div",{className:m(`text-${(o==null?void 0:o.alignment)||"left"}`),children:[l.jsx("h1",{className:m("text-2xl font-bold text-gray-900"),children:t}),r&&l.jsx("p",{className:m("text-gray-600 mt-1"),children:r})]})}},{type:"sectionHeading",structure:"page",typeCategory:"Heading",label:"Section Heading",description:"Section title",icon:"📑",category:"page",subCategory:"heading",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Section Title"},layout:{size:"full"},config:{level:2,alignment:"left"}}),renderOnCanvas:e=>{const{label:t,description:r,config:o}=K(e);return l.jsxs("div",{className:m(`text-${(o==null?void 0:o.alignment)||"left"}`),children:[l.jsx("h2",{className:m("text-xl font-semibold text-gray-800"),children:t}),r&&l.jsx("p",{className:m("text-gray-500 text-sm mt-1"),children:r})]})},render:e=>{const{label:t,description:r,config:o}=K(e);return l.jsxs("div",{className:m(`text-${(o==null?void 0:o.alignment)||"left"}`),children:[l.jsx("h2",{className:m("text-xl font-semibold text-gray-800"),children:t}),r&&l.jsx("p",{className:m("text-gray-500 text-sm mt-1"),children:r})]})}},{type:"subheading",structure:"page",typeCategory:"Heading",label:"Subheading",description:"Smaller heading",icon:"📝",category:"page",subCategory:"heading",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Subheading"},layout:{size:"full"},config:{level:3,alignment:"left"}}),renderOnCanvas:e=>{const{label:t,description:r,config:o}=K(e);return l.jsxs("div",{className:m(`text-${(o==null?void 0:o.alignment)||"left"}`),children:[l.jsx("h3",{className:m("text-lg font-medium text-gray-700"),children:t}),r&&l.jsx("p",{className:m("text-gray-500 text-sm mt-0.5"),children:r})]})},render:e=>{const{label:t,description:r,config:o}=K(e);return l.jsxs("div",{className:m(`text-${(o==null?void 0:o.alignment)||"left"}`),children:[l.jsx("h3",{className:m("text-lg font-medium text-gray-700"),children:t}),r&&l.jsx("p",{className:m("text-gray-500 text-sm mt-0.5"),children:r})]})}},{type:"submit",structure:"page",typeCategory:"Special",label:"Submit Button",description:"Form submission button",icon:"🚀",category:"page",subCategory:"special",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Submit"},layout:{size:"default"},config:{buttonText:"Submit",buttonStyle:"primary",buttonSize:"medium",showIcon:!1,loadingText:"Submitting..."}}),renderOnCanvas:e=>{const{label:t,config:r}=K(e),o=(r==null?void 0:r.buttonText)||t||"Submit",n=(r==null?void 0:r.buttonStyle)||"primary",s=(r==null?void 0:r.buttonSize)||"medium",a={primary:"bg-blue-600 text-white hover:bg-blue-700",secondary:"bg-gray-600 text-white hover:bg-gray-700",outline:"border-2 border-blue-600 text-blue-600 bg-transparent hover:bg-blue-50",ghost:"text-blue-600 hover:bg-blue-50"},i={small:"px-4 py-1.5 text-sm",medium:"px-6 py-2.5 text-base",large:"px-8 py-3 text-lg"};return l.jsxs("button",{type:"button",disabled:!0,className:m("rounded-md font-medium transition-colors",a[n],i[s]),children:[(r==null?void 0:r.showIcon)&&(r==null?void 0:r.iconPosition)==="left"&&l.jsx("span",{className:m("mr-2"),children:"🚀"}),o,(r==null?void 0:r.showIcon)&&(r==null?void 0:r.iconPosition)==="right"&&l.jsx("span",{className:m("ml-2"),children:"🚀"})]})},render:e=>{const{label:t,config:r,isDisabled:o}=K(e),n=(r==null?void 0:r.buttonText)||t||"Submit",s=(r==null?void 0:r.buttonStyle)||"primary",a=(r==null?void 0:r.buttonSize)||"medium",i={primary:"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",secondary:"bg-gray-600 text-white hover:bg-gray-700 focus:ring-gray-500",outline:"border-2 border-blue-600 text-blue-600 bg-transparent hover:bg-blue-50 focus:ring-blue-500",ghost:"text-blue-600 hover:bg-blue-50 focus:ring-blue-500"},c={small:"px-4 py-1.5 text-sm",medium:"px-6 py-2.5 text-base",large:"px-8 py-3 text-lg"};return l.jsxs("button",{type:"submit",disabled:o,className:m("rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2",i[s],c[a],o&&"opacity-50 cursor-not-allowed"),children:[(r==null?void 0:r.showIcon)&&(r==null?void 0:r.iconPosition)==="left"&&l.jsx("span",{className:m("mr-2"),children:"🚀"}),n,(r==null?void 0:r.showIcon)&&(r==null?void 0:r.iconPosition)==="right"&&l.jsx("span",{className:m("ml-2"),children:"🚀"})]})}}],TE=[{type:"singleChoiceMatrix",structure:"field",typeCategory:"Matrix",label:"Single Choice Matrix",description:"Matrix with radio button selections",icon:"📊",category:"field",subCategory:"matrix",dataType:"object",supportsValidation:!0,supportsMatrix:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Matrix Settings",icon:"📊"},fields:[{key:"randomizeRows",label:"Randomize Row Order",type:"checkbox",section:"config",description:"Shuffle rows for each respondent (surveys)"},{key:"randomizeColumns",label:"Randomize Column Order",type:"checkbox",section:"config",description:"Shuffle columns for each respondent"},{key:"showRowNumbers",label:"Show Row Numbers",type:"checkbox",section:"config",description:"Number each row for easy reference"},{key:"requiredPerRow",label:"Require Every Row",type:"checkbox",section:"config",description:"Each row must have a selection before submit"},{key:"layoutStyle",label:"Layout Style",type:"select",section:"config",description:"Visual presentation of the matrix",options:[{value:"table",label:"Table (grid)"},{value:"card",label:"Card per row"},{value:"inline",label:"Inline (compact)"}]}]},getDefaultValues:()=>({properties:{label:"Single Choice Matrix",description:"Select one option per row"},layout:{labelPosition:"top",size:"full"},config:{matrixRows:[{id:"row1",label:"Row 1"},{id:"row2",label:"Row 2"},{id:"row3",label:"Row 3"}],matrixColumns:[{id:"col1",label:"Option 1"},{id:"col2",label:"Option 2"},{id:"col3",label:"Option 3"}]}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e),a=(s==null?void 0:s.matrixRows)||[],i=(s==null?void 0:s.matrixColumns)||[];return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsx("div",{className:m("overflow-x-auto"),children:l.jsxs("table",{className:m("w-full border-collapse text-sm"),children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{className:m("p-2 text-left")}),i.map(c=>l.jsx("th",{className:m("p-2 text-center font-medium text-gray-700"),children:c.label},c.id))]})}),l.jsx("tbody",{children:a.map(c=>l.jsxs("tr",{className:m("border-t border-gray-200"),children:[l.jsx("td",{className:m("p-2 text-gray-700"),children:c.label}),i.map(d=>l.jsx("td",{className:m("p-2 text-center"),children:l.jsx("input",{type:"radio",disabled:!0,name:c.id,className:m("text-blue-600")})},d.id))]},c.id))})]})})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),p=(d==null?void 0:d.matrixRows)||[],u=(d==null?void 0:d.matrixColumns)||[],f=s||{},h=(g,y)=>{c||a==null||a({...f,[g]:y})};return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsx("div",{className:m("overflow-x-auto"),children:l.jsxs("table",{className:m("w-full border-collapse text-sm"),children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{className:m("p-2 text-left")}),u.map(g=>l.jsx("th",{className:m("p-2 text-center font-medium text-gray-700"),children:g.label},g.id))]})}),l.jsx("tbody",{children:p.map(g=>l.jsxs("tr",{className:m("border-t border-gray-200"),children:[l.jsx("td",{className:m("p-2 text-gray-700"),children:g.label}),u.map(y=>l.jsx("td",{className:m("p-2 text-center"),children:l.jsx("input",{type:"radio",name:`${e.element.id}-${g.id}`,checked:f[g.id]===y.id,onChange:()=>h(g.id,y.id),disabled:c,className:m("text-blue-600 cursor-pointer disabled:cursor-not-allowed")})},y.id))]},g.id))})]})})})}},{type:"multipleChoiceMatrix",structure:"field",typeCategory:"Matrix",label:"Multiple Choice Matrix",description:"Matrix with checkbox selections",icon:"📋",category:"field",subCategory:"matrix",dataType:"object",supportsValidation:!0,supportsMatrix:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Matrix Settings",icon:"📋"},fields:[{key:"allowMultiplePerRow",label:"Allow Multiple Per Row",type:"checkbox",section:"config",description:"Let users select more than one column per row"},{key:"maxSelectionsPerRow",label:"Max Selections Per Row",type:"number",section:"config",min:1,placeholder:"e.g. 3",description:"Limit how many columns can be checked per row",showWhen:{field:"allowMultiplePerRow",value:!0}},{key:"randomizeRows",label:"Randomize Row Order",type:"checkbox",section:"config",description:"Shuffle rows for each respondent (surveys)"},{key:"randomizeColumns",label:"Randomize Column Order",type:"checkbox",section:"config",description:"Shuffle columns for each respondent"},{key:"showRowNumbers",label:"Show Row Numbers",type:"checkbox",section:"config",description:"Number each row for easy reference"},{key:"showSelectAll",label:'Show "Select All" Column',type:"checkbox",section:"config",description:"Add a column header to check all rows at once"}]},getDefaultValues:()=>({properties:{label:"Multiple Choice Matrix",description:"Select multiple options per row"},layout:{labelPosition:"top",size:"full"},config:{matrixRows:[{id:"row1",label:"Row 1"},{id:"row2",label:"Row 2"},{id:"row3",label:"Row 3"}],matrixColumns:[{id:"col1",label:"Option 1"},{id:"col2",label:"Option 2"},{id:"col3",label:"Option 3"}],allowMultiplePerRow:!0}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e),a=(s==null?void 0:s.matrixRows)||[],i=(s==null?void 0:s.matrixColumns)||[];return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsx("div",{className:m("overflow-x-auto"),children:l.jsxs("table",{className:m("w-full border-collapse text-sm"),children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{className:m("p-2 text-left")}),i.map(c=>l.jsx("th",{className:m("p-2 text-center font-medium text-gray-700"),children:c.label},c.id))]})}),l.jsx("tbody",{children:a.map(c=>l.jsxs("tr",{className:m("border-t border-gray-200"),children:[l.jsx("td",{className:m("p-2 text-gray-700"),children:c.label}),i.map(d=>l.jsx("td",{className:m("p-2 text-center"),children:l.jsx("input",{type:"checkbox",disabled:!0,className:m("text-blue-600 rounded")})},d.id))]},c.id))})]})})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),p=(d==null?void 0:d.matrixRows)||[],u=(d==null?void 0:d.matrixColumns)||[],f=s||{},h=(g,y)=>{if(c)return;const b=f[g]||[],v=b.includes(y)?b.filter(N=>N!==y):[...b,y];a==null||a({...f,[g]:v})};return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsx("div",{className:m("overflow-x-auto"),children:l.jsxs("table",{className:m("w-full border-collapse text-sm"),children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{className:m("p-2 text-left")}),u.map(g=>l.jsx("th",{className:m("p-2 text-center font-medium text-gray-700"),children:g.label},g.id))]})}),l.jsx("tbody",{children:p.map(g=>l.jsxs("tr",{className:m("border-t border-gray-200"),children:[l.jsx("td",{className:m("p-2 text-gray-700"),children:g.label}),u.map(y=>l.jsx("td",{className:m("p-2 text-center"),children:l.jsx("input",{type:"checkbox",checked:(f[g.id]||[]).includes(y.id),onChange:()=>h(g.id,y.id),disabled:c,className:m("text-blue-600 rounded cursor-pointer disabled:cursor-not-allowed")})},y.id))]},g.id))})]})})})}},{type:"matrixTable",structure:"field",typeCategory:"Matrix",label:"Matrix Table",description:"Table with text/number inputs",icon:"📑",category:"field",subCategory:"matrix",dataType:"object",supportsValidation:!0,supportsMatrix:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Table Settings",icon:"📑"},fields:[{key:"showRowNumbers",label:"Show Row Numbers",type:"checkbox",section:"config",description:"Number each row for easy reference"},{key:"showColumnTotals",label:"Show Column Totals",type:"checkbox",section:"config",description:"Display sum at the bottom of numeric columns"},{key:"allowAddRows",label:"Allow Adding Rows",type:"checkbox",section:"config",description:"Let users add extra rows beyond the defaults"},{key:"allowDeleteRows",label:"Allow Deleting Rows",type:"checkbox",section:"config",description:"Let users remove rows they added",showWhen:{field:"allowAddRows",value:!0}},{key:"stickyHeader",label:"Sticky Header",type:"checkbox",section:"config",description:"Keep column headers visible while scrolling"},{key:"cellPlaceholder",label:"Cell Placeholder",type:"text",section:"config",placeholder:"Enter value...",description:"Placeholder text shown inside empty cells"}]},getDefaultValues:()=>({properties:{label:"Matrix Table",description:"Enter values in each cell"},layout:{labelPosition:"top",size:"full"},config:{matrixRows:[{id:"row1",label:"Row 1"},{id:"row2",label:"Row 2"}],matrixColumns:[{id:"col1",label:"Column 1",type:"text"},{id:"col2",label:"Column 2",type:"number"}]}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e),a=(s==null?void 0:s.matrixRows)||[],i=(s==null?void 0:s.matrixColumns)||[];return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsx("div",{className:m("overflow-x-auto"),children:l.jsxs("table",{className:m("w-full border-collapse text-sm border border-gray-200"),children:[l.jsx("thead",{children:l.jsxs("tr",{className:m("bg-gray-50"),children:[l.jsx("th",{className:m("p-2 text-left border border-gray-200")}),i.map(c=>l.jsx("th",{className:m("p-2 text-center font-medium text-gray-700 border border-gray-200"),children:c.label},c.id))]})}),l.jsx("tbody",{children:a.map(c=>l.jsxs("tr",{children:[l.jsx("td",{className:m("p-2 text-gray-700 border border-gray-200 bg-gray-50"),children:c.label}),i.map(d=>l.jsx("td",{className:m("p-2 border border-gray-200"),children:l.jsx("input",{type:d.type==="number"?"number":"text",disabled:!0,className:m("w-full px-2 py-1 border border-gray-300 rounded text-sm bg-gray-50")})},d.id))]},c.id))})]})})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),p=(d==null?void 0:d.matrixRows)||[],u=(d==null?void 0:d.matrixColumns)||[],f=s||{},h=(g,y,b)=>{const v={...f,[g]:{...f[g]||{},[y]:b}};a==null||a(v)};return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsx("div",{className:m("overflow-x-auto"),children:l.jsxs("table",{className:m("w-full border-collapse text-sm border border-gray-200"),children:[l.jsx("thead",{children:l.jsxs("tr",{className:m("bg-gray-50"),children:[l.jsx("th",{className:m("p-2 text-left border border-gray-200")}),u.map(g=>l.jsx("th",{className:m("p-2 text-center font-medium text-gray-700 border border-gray-200"),children:g.label},g.id))]})}),l.jsx("tbody",{children:p.map(g=>l.jsxs("tr",{children:[l.jsx("td",{className:m("p-2 text-gray-700 border border-gray-200 bg-gray-50"),children:g.label}),u.map(y=>{var b;return l.jsx("td",{className:m("p-2 border border-gray-200"),children:l.jsx("input",{type:y.type==="number"?"number":"text",value:((b=f[g.id])==null?void 0:b[y.id])??"",onChange:v=>h(g.id,y.id,y.type==="number"?Number(v.target.value):v.target.value),disabled:c,className:`w-full px-2 py-1 border rounded text-sm ${c?"bg-gray-50 border-gray-300":"bg-white border-gray-300 focus:border-blue-500 focus:ring-1 focus:ring-blue-500"}`})},y.id)})]},g.id))})]})})})}}],PE=[{type:"fileUpload",structure:"field",typeCategory:"FileUpload",label:"File Upload",description:"Single file upload",icon:"📎",category:"field",subCategory:"fileUpload",dataType:"file",supportsValidation:!0,getDefaultValues:()=>({properties:{label:"File Upload",description:"Upload a file"},layout:{labelPosition:"top",size:"full"},config:{accept:"*/*",maxSize:10485760,multiple:!1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e);return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsxs("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg p-6 text-center bg-gray-50"),children:[l.jsx("svg",{className:m("mx-auto h-8 w-8 text-gray-400"),stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:l.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),l.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload"}),l.jsxs("p",{className:m("text-xs text-gray-400"),children:[(s==null?void 0:s.accept)||"All files"," (Max:"," ",Math.round(((s==null?void 0:s.maxSize)||10485760)/1024/1024),"MB)"]})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),p=g=>{var b;const y=(b=g.target.files)==null?void 0:b[0];y&&(a==null||a(y))},u=g=>{var b;g.preventDefault();const y=(b=g.dataTransfer.files)==null?void 0:b[0];y&&(a==null||a(y))},f=g=>{g.preventDefault()},h=s instanceof File?s.name:s==null?void 0:s.name;return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:l.jsxs("div",{onDrop:c?void 0:u,onDragOver:c?void 0:f,className:`border-2 border-dashed rounded-lg p-6 text-center transition-colors ${((i==null?void 0:i.length)??0)>0?"border-red-300 bg-red-50":"border-gray-300 bg-gray-50 hover:border-gray-400"} ${c?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[l.jsx("input",{type:"file",accept:d==null?void 0:d.accept,onChange:p,disabled:c,className:m("hidden"),id:`file-upload-${e.element.id}`}),l.jsx("label",{htmlFor:`file-upload-${e.element.id}`,className:c?"cursor-not-allowed":"cursor-pointer",children:h?l.jsxs("div",{className:m("flex items-center justify-center gap-2"),children:[l.jsx("span",{className:m("text-2xl"),children:"📄"}),l.jsx("span",{className:m("text-sm text-gray-700"),children:h}),!c&&l.jsx("button",{type:"button",onClick:g=>{g.preventDefault(),a==null||a(null)},className:m("text-red-500 hover:text-red-700"),children:"×"})]}):l.jsxs(l.Fragment,{children:[l.jsx("svg",{className:m("mx-auto h-8 w-8 text-gray-400"),stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:l.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),l.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload"}),l.jsxs("p",{className:m("text-xs text-gray-400"),children:[(d==null?void 0:d.accept)||"All files"," (Max:"," ",Math.round(((d==null?void 0:d.maxSize)||10485760)/1024/1024),"MB)"]})]})})]})})}},{type:"imageUpload",structure:"field",typeCategory:"FileUpload",label:"Image Upload",description:"Single image upload with preview",icon:"🖼️",category:"field",subCategory:"fileUpload",dataType:"file",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Image Upload Settings",icon:"🖼️"},fields:[{key:"maxSize",label:"Max Size (MB)",type:"number",section:"config",min:1,max:100,placeholder:"5",description:"Maximum image file size"},{key:"allowCrop",label:"Allow Cropping",type:"checkbox",section:"config",description:"Let users crop the image after upload"},{key:"aspectRatio",label:"Aspect Ratio",type:"select",section:"config",description:"Constrain crop to a specific ratio",showWhen:{field:"allowCrop",value:!0},options:[{value:"free",label:"Free (no constraint)"},{value:"1:1",label:"1:1 (Square)"},{value:"4:3",label:"4:3 (Standard)"},{value:"16:9",label:"16:9 (Widescreen)"},{value:"3:2",label:"3:2 (Portrait)"},{value:"2:3",label:"2:3 (Landscape)"}]},{key:"minWidth",label:"Min Width (px)",type:"number",section:"config",min:1,placeholder:"e.g. 200",description:"Minimum allowed image width",colSpan:1},{key:"minHeight",label:"Min Height (px)",type:"number",section:"config",min:1,placeholder:"e.g. 200",description:"Minimum allowed image height",colSpan:1},{key:"showPreview",label:"Show Preview",type:"checkbox",section:"config",description:"Display a thumbnail preview of the uploaded image"},{key:"compressOnUpload",label:"Auto-compress",type:"checkbox",section:"config",description:"Automatically compress large images on upload"}]},getDefaultValues:()=>({properties:{label:"Image Upload",description:"Upload an image"},layout:{labelPosition:"top",size:"full"},config:{accept:"image/*",maxSize:5242880,multiple:!1,allowCrop:!1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e);return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,children:l.jsxs("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg p-6 text-center bg-gray-50"),children:[l.jsx("span",{className:m("text-4xl"),children:"🖼️"}),l.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload image"}),l.jsxs("p",{className:m("text-xs text-gray-400"),children:["Images only (Max:"," ",Math.round(((s==null?void 0:s.maxSize)||5242880)/1024/1024),"MB)"]})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),[p,u]=P.useState(null);P.useEffect(()=>{if(s instanceof File){const g=new FileReader;g.onloadend=()=>{u(g.result)},g.readAsDataURL(s)}else u(typeof s=="string"?s:null)},[s]);const f=g=>{var b;const y=(b=g.target.files)==null?void 0:b[0];y&&(a==null||a(y))},h=()=>{a==null||a(null),u(null)};return l.jsx(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:p?l.jsxs("div",{className:m("relative inline-block"),children:[l.jsx("img",{src:p,alt:"Preview",className:m("max-w-full max-h-48 rounded-lg border border-gray-200")}),!c&&l.jsx("button",{type:"button",onClick:h,className:m("absolute -top-2 -right-2 w-6 h-6 bg-red-500 text-white rounded-full flex items-center justify-center text-sm hover:bg-red-600"),children:"×"})]}):l.jsxs("div",{className:`border-2 border-dashed rounded-lg p-6 text-center transition-colors ${((i==null?void 0:i.length)??0)>0?"border-red-300 bg-red-50":"border-gray-300 bg-gray-50 hover:border-gray-400"} ${c?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[l.jsx("input",{type:"file",accept:(d==null?void 0:d.accept)||"image/*",onChange:f,disabled:c,className:m("hidden"),id:`image-upload-${e.element.id}`}),l.jsxs("label",{htmlFor:`image-upload-${e.element.id}`,className:c?"cursor-not-allowed":"cursor-pointer",children:[l.jsx("span",{className:m("text-4xl"),children:"🖼️"}),l.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload image"}),l.jsxs("p",{className:m("text-xs text-gray-400"),children:["Images only (Max:"," ",Math.round(((d==null?void 0:d.maxSize)||5242880)/1024/1024),"MB)"]})]})]})})}},{type:"multiFileUpload",structure:"field",typeCategory:"FileUpload",label:"Multi File Upload",description:"Upload multiple files",icon:"📁",category:"field",subCategory:"fileUpload",dataType:"array",supportsValidation:!0,getDefaultValues:()=>({properties:{label:"Multi File Upload",description:"Upload multiple files"},layout:{labelPosition:"top",size:"full"},config:{accept:"*/*",maxSize:10485760,multiple:!0,maxFiles:10}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e);return l.jsxs(de,{label:t,description:r,required:o,labelPosition:n,children:[l.jsxs("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg p-6 text-center bg-gray-50"),children:[l.jsx("span",{className:m("text-4xl"),children:"📁"}),l.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload files"}),l.jsxs("p",{className:m("text-xs text-gray-400"),children:["Up to ",(s==null?void 0:s.maxFiles)||10," files"]})]}),l.jsx("div",{className:m("space-y-2 mt-2"),children:l.jsxs("div",{className:m("flex items-center gap-2 p-2 bg-gray-100 rounded text-sm"),children:[l.jsx("span",{children:"📄"}),l.jsx("span",{className:m("flex-1 truncate"),children:"document.pdf"}),l.jsx("button",{disabled:!0,className:m("text-gray-400 hover:text-red-500"),children:"×"})]})})]})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),p=Array.isArray(s)?s:[],u=(d==null?void 0:d.maxFiles)||10,f=g=>{const y=Array.from(g.target.files||[]),b=[...p,...y].slice(0,u);a==null||a(b)},h=g=>{const y=p.filter((b,v)=>v!==g);a==null||a(y)};return l.jsxs(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:[l.jsxs("div",{className:`border-2 border-dashed rounded-lg p-6 text-center transition-colors ${((i==null?void 0:i.length)??0)>0?"border-red-300 bg-red-50":"border-gray-300 bg-gray-50 hover:border-gray-400"} ${c||p.length>=u?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[l.jsx("input",{type:"file",accept:d==null?void 0:d.accept,multiple:!0,onChange:f,disabled:c||p.length>=u,className:m("hidden"),id:`multi-file-upload-${e.element.id}`}),l.jsxs("label",{htmlFor:`multi-file-upload-${e.element.id}`,className:c||p.length>=u?"cursor-not-allowed":"cursor-pointer",children:[l.jsx("span",{className:m("text-4xl"),children:"📁"}),l.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload files"}),l.jsxs("p",{className:m("text-xs text-gray-400"),children:[p.length," / ",u," files"]})]})]}),p.length>0&&l.jsx("div",{className:m("space-y-2 mt-2"),children:p.map((g,y)=>l.jsxs("div",{className:m("flex items-center gap-2 p-2 bg-gray-100 rounded text-sm"),children:[l.jsx("span",{children:"📄"}),l.jsx("span",{className:m("flex-1 truncate"),children:g.name}),l.jsxs("span",{className:m("text-xs text-gray-500"),children:[(g.size/1024).toFixed(1)," KB"]}),!c&&l.jsx("button",{type:"button",onClick:()=>h(y),className:m("text-gray-400 hover:text-red-500"),children:"×"})]},y))})]})}},{type:"multiImageUpload",structure:"field",typeCategory:"FileUpload",label:"Multi Image Upload",description:"Upload multiple images with preview",icon:"🖼️",category:"field",subCategory:"fileUpload",dataType:"array",supportsValidation:!0,getDefaultValues:()=>({properties:{label:"Multi Image Upload",description:"Upload multiple images"},layout:{labelPosition:"top",size:"full"},config:{accept:"image/*",maxSize:5242880,multiple:!0,maxFiles:10,allowCrop:!1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e);return l.jsxs(de,{label:t,description:r,required:o,labelPosition:n,children:[l.jsxs("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg p-6 text-center bg-gray-50"),children:[l.jsx("span",{className:m("text-4xl"),children:"🖼️"}),l.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload images"}),l.jsxs("p",{className:m("text-xs text-gray-400"),children:["Up to ",(s==null?void 0:s.maxFiles)||10," images"]})]}),l.jsx("div",{className:m("flex gap-2 flex-wrap mt-2"),children:l.jsxs("div",{className:m("w-20 h-20 bg-gray-200 rounded-lg flex items-center justify-center relative"),children:[l.jsx("span",{className:m("text-2xl"),children:"🖼️"}),l.jsx("button",{disabled:!0,className:m("absolute -top-1 -right-1 w-5 h-5 bg-red-500 text-white rounded-full text-xs"),children:"×"})]})})]})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),[p,u]=P.useState([]),f=Array.isArray(s)?s:[],h=(d==null?void 0:d.maxFiles)||10;P.useEffect(()=>{(async()=>{const v=[];for(const N of f)if(N instanceof File){const x=new FileReader,w=await new Promise(C=>{x.onloadend=()=>C(x.result),x.readAsDataURL(N)});v.push(w)}u(v)})()},[f]);const g=b=>{const v=Array.from(b.target.files||[]),N=[...f,...v].slice(0,h);a==null||a(N)},y=b=>{const v=f.filter((N,x)=>x!==b);a==null||a(v)};return l.jsxs(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:[l.jsxs("div",{className:`border-2 border-dashed rounded-lg p-6 text-center transition-colors ${((i==null?void 0:i.length)??0)>0?"border-red-300 bg-red-50":"border-gray-300 bg-gray-50 hover:border-gray-400"} ${c||f.length>=h?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[l.jsx("input",{type:"file",accept:(d==null?void 0:d.accept)||"image/*",multiple:!0,onChange:g,disabled:c||f.length>=h,className:m("hidden"),id:`multi-image-upload-${e.element.id}`}),l.jsxs("label",{htmlFor:`multi-image-upload-${e.element.id}`,className:c||f.length>=h?"cursor-not-allowed":"cursor-pointer",children:[l.jsx("span",{className:m("text-4xl"),children:"🖼️"}),l.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload images"}),l.jsxs("p",{className:m("text-xs text-gray-400"),children:[f.length," / ",h," images"]})]})]}),p.length>0&&l.jsx("div",{className:m("flex gap-2 flex-wrap mt-2"),children:p.map((b,v)=>l.jsxs("div",{className:m("w-20 h-20 rounded-lg overflow-hidden relative border border-gray-200"),children:[l.jsx("img",{src:b,alt:`Preview ${v+1}`,className:m("w-full h-full object-cover")}),!c&&l.jsx("button",{type:"button",onClick:()=>y(v),className:m("absolute -top-1 -right-1 w-5 h-5 bg-red-500 text-white rounded-full text-xs hover:bg-red-600 flex items-center justify-center"),children:"×"})]},v))})]})}}],IE=[{type:"password",structure:"field",typeCategory:"Security",label:"Password",description:"Secure password input",icon:"🔒",category:"field",subCategory:"security",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Password Settings",icon:"🔒"},fields:[{key:"showStrengthMeter",label:"Show Strength Meter",type:"checkbox",section:"config",description:"Visual indicator of password strength"},{key:"showToggle",label:"Show / Hide Toggle",type:"checkbox",section:"config",description:"Let users reveal their password"},{key:"minStrength",label:"Minimum Strength",type:"select",section:"config",description:"Lowest accepted password strength level",options:[{value:"weak",label:"Weak"},{value:"medium",label:"Medium"},{value:"strong",label:"Strong"}]},{key:"strengthLabels",label:"Show Requirements Hint",type:"checkbox",section:"config",description:"Display password rules (length, special chars, etc.)"}]},getDefaultValues:()=>({properties:{label:"Password",placeholder:"••••••••"},layout:{labelPosition:"top",size:"full"},config:{showStrengthMeter:!1,showToggle:!0,minStrength:"medium"},validation:{minLength:8}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,config:a}=K(e);return l.jsxs(de,{label:t,description:r,required:n,labelPosition:s,children:[l.jsxs("div",{className:m("relative"),children:[l.jsx("input",{type:"password",placeholder:o||"••••••••",disabled:!0,className:`${kt()} pr-10`}),(a==null?void 0:a.showToggle)&&l.jsx("button",{disabled:!0,className:m("absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"),children:"👁️"})]}),(a==null?void 0:a.showStrengthMeter)&&l.jsxs("div",{className:m("flex gap-1 mt-2"),children:[l.jsx("div",{className:m("h-1 flex-1 bg-gray-300 rounded")}),l.jsx("div",{className:m("h-1 flex-1 bg-gray-300 rounded")}),l.jsx("div",{className:m("h-1 flex-1 bg-gray-300 rounded")}),l.jsx("div",{className:m("h-1 flex-1 bg-gray-300 rounded")})]})]})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:s,value:a,onChange:i,errors:c,isDisabled:d,config:p}=K(e),[u,f]=P.useState(!1),g=(b=>{if(!b)return 0;let v=0;return b.length>=8&&v++,/[a-z]/.test(b)&&/[A-Z]/.test(b)&&v++,/\d/.test(b)&&v++,/[^a-zA-Z0-9]/.test(b)&&v++,v})(a||""),y=["bg-red-500","bg-orange-500","bg-yellow-500","bg-green-500"];return l.jsxs(de,{label:t,description:r,required:n,labelPosition:s,errors:c,children:[l.jsxs("div",{className:m("relative"),children:[l.jsx("input",{type:u?"text":"password",placeholder:o||"••••••••",value:a??"",onChange:b=>i==null?void 0:i(b.target.value),disabled:d,className:`${Ut({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})} pr-10`}),(p==null?void 0:p.showToggle)&&!d&&l.jsx("button",{type:"button",onClick:()=>f(!u),className:m("absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"),children:u?"🙈":"👁️"})]}),(p==null?void 0:p.showStrengthMeter)&&a&&l.jsx("div",{className:m("flex gap-1 mt-2"),children:[0,1,2,3].map(b=>l.jsx("div",{className:`h-1 flex-1 rounded ${b<g?y[g-1]:"bg-gray-300"}`},b))})]})}},{type:"signature",structure:"field",typeCategory:"Security",label:"Signature",description:"Handwritten signature pad",icon:"✍️",category:"field",subCategory:"security",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Signature Pad Settings",icon:"✍️"},fields:[{key:"canvasWidth",label:"Width (px)",type:"number",section:"config",min:100,max:1200,placeholder:"400",description:"Drawing area width",colSpan:1},{key:"canvasHeight",label:"Height (px)",type:"number",section:"config",min:50,max:600,placeholder:"200",description:"Drawing area height",colSpan:1},{key:"strokeWidth",label:"Stroke Width",type:"number",section:"config",min:1,max:10,placeholder:"2",description:"Pen thickness",colSpan:1},{key:"strokeColor",label:"Stroke Color",type:"color",section:"config",placeholder:"#000000",description:"Pen color",colSpan:1},{key:"backgroundColor",label:"Background Color",type:"color",section:"config",placeholder:"#ffffff",description:"Pad background color"},{key:"requireFullName",label:"Require Full Name",type:"checkbox",section:"config",description:"Ask for a printed name below the signature"},{key:"showTimestamp",label:"Show Timestamp",type:"checkbox",section:"config",description:"Auto-record date and time of signing"}]},getDefaultValues:()=>({properties:{label:"Signature",description:"Please sign below"},layout:{labelPosition:"top",size:"full"},config:{strokeWidth:2,strokeColor:"#000000",backgroundColor:"#ffffff",canvasWidth:400,canvasHeight:200}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:s}=K(e);return l.jsxs(de,{label:t,description:r,required:o,labelPosition:n,children:[l.jsx("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg bg-gray-50 flex items-center justify-center"),style:{height:(s==null?void 0:s.canvasHeight)||200,backgroundColor:(s==null?void 0:s.backgroundColor)||"#ffffff"},children:l.jsxs("div",{className:m("text-center text-gray-400"),children:[l.jsx("span",{className:m("text-3xl"),children:"✍️"}),l.jsx("p",{className:m("text-sm mt-2"),children:"Draw your signature here"})]})}),l.jsx("button",{disabled:!0,className:m("text-sm text-blue-600 hover:text-blue-700 mt-2"),children:"Clear signature"})]})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:s,onChange:a,errors:i,isDisabled:c,config:d}=K(e),p=P.useRef(null),[u,f]=P.useState(!1),h=v=>{if(c)return;f(!0);const N=p.current;if(!N)return;const x=N.getContext("2d");if(!x)return;const w=N.getBoundingClientRect();x.beginPath(),x.moveTo(v.clientX-w.left,v.clientY-w.top)},g=v=>{if(!u||c)return;const N=p.current;if(!N)return;const x=N.getContext("2d");if(!x)return;const w=N.getBoundingClientRect();x.lineWidth=(d==null?void 0:d.strokeWidth)||2,x.strokeStyle=(d==null?void 0:d.strokeColor)||"#000000",x.lineCap="round",x.lineTo(v.clientX-w.left,v.clientY-w.top),x.stroke()},y=()=>{u&&p.current&&(f(!1),a==null||a(p.current.toDataURL()))},b=()=>{const v=p.current;if(!v)return;const N=v.getContext("2d");N&&(N.fillStyle=(d==null?void 0:d.backgroundColor)||"#ffffff",N.fillRect(0,0,v.width,v.height),a==null||a(""))};return l.jsxs(de,{label:t,description:r,required:o,labelPosition:n,errors:i,children:[l.jsx("div",{className:`border-2 rounded-lg overflow-hidden ${((i==null?void 0:i.length)??0)>0?"border-red-500":"border-gray-300"} ${c?"opacity-50":""}`,style:{backgroundColor:(d==null?void 0:d.backgroundColor)||"#ffffff"},children:l.jsx("canvas",{ref:p,width:(d==null?void 0:d.canvasWidth)||400,height:(d==null?void 0:d.canvasHeight)||200,onMouseDown:h,onMouseMove:g,onMouseUp:y,onMouseLeave:y,className:c?"cursor-not-allowed":"cursor-crosshair",style:{display:"block",width:"100%"}})}),!c&&l.jsx("button",{type:"button",onClick:b,className:m("text-sm text-blue-600 hover:text-blue-700 mt-2"),children:"Clear signature"})]})}},{type:"captcha",structure:"field",typeCategory:"Security",label:"Captcha",description:"Bot protection verification",icon:"🤖",category:"field",subCategory:"security",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!1,showPlaceholder:!1,showDescription:!0},configSection:{title:"Captcha Settings",icon:"🤖"},fields:[{key:"provider",label:"Provider",type:"select",section:"config",description:"Which CAPTCHA service to use",options:[{value:"recaptcha",label:"Google reCAPTCHA v3"},{value:"recaptcha-v2",label:"Google reCAPTCHA v2"},{value:"hcaptcha",label:"hCaptcha"},{value:"turnstile",label:"Cloudflare Turnstile"},{value:"friendly",label:"Friendly Captcha"}]},{key:"siteKey",label:"Site Key",type:"text",section:"config",placeholder:"Your site key from provider",description:"Public key provided by the CAPTCHA service"},{key:"theme",label:"Widget Theme",type:"select",section:"config",options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"auto",label:"Auto (match page)"}]},{key:"size",label:"Widget Size",type:"select",section:"config",options:[{value:"normal",label:"Normal"},{value:"compact",label:"Compact"},{value:"invisible",label:"Invisible"}]}]},getDefaultValues:()=>({properties:{label:"CAPTCHA",description:"Please verify you are human"},layout:{labelPosition:"hidden",size:"default"},config:{provider:"recaptcha",siteKey:"",theme:"light"}}),renderOnCanvas:e=>{const{description:t}=K(e);return l.jsxs("div",{className:m("space-y-1.5"),children:[t&&l.jsx("p",{className:m("text-xs text-gray-500"),children:t}),l.jsx("div",{className:m("border border-gray-300 rounded-md p-4 bg-gray-50 max-w-[300px]"),children:l.jsxs("div",{className:m("flex items-center gap-3"),children:[l.jsx("div",{className:m("w-7 h-7 border-2 border-gray-300 rounded flex items-center justify-center"),children:"☐"}),l.jsx("span",{className:m("text-sm text-gray-700"),children:"I'm not a robot"}),l.jsx("div",{className:m("ml-auto"),children:l.jsxs("div",{className:m("text-xs text-gray-400 text-center"),children:[l.jsx("div",{className:m("text-lg"),children:"🔄"}),l.jsx("span",{children:"reCAPTCHA"})]})})]})})]})},render:e=>{const{description:t,value:r,onChange:o,errors:n,isDisabled:s,config:a}=K(e),i=r===!0,c=()=>{s||o==null||o(!0)};return l.jsxs("div",{className:m("space-y-1.5"),children:[t&&l.jsx("p",{className:m("text-xs text-gray-500"),children:t}),l.jsx("div",{className:`border rounded-md p-4 max-w-[300px] ${((n==null?void 0:n.length)??0)>0?"border-red-500 bg-red-50":i?"border-green-500 bg-green-50":"border-gray-300 bg-gray-50"}`,children:l.jsxs("div",{className:m("flex items-center gap-3"),children:[l.jsx("button",{type:"button",onClick:c,disabled:s||i,className:`w-7 h-7 border-2 rounded flex items-center justify-center transition-colors ${i?"border-green-500 bg-green-500 text-white":"border-gray-300 hover:border-gray-400"} ${s?"cursor-not-allowed opacity-50":"cursor-pointer"}`,children:i?"✓":""}),l.jsx("span",{className:m("text-sm text-gray-700"),children:i?"Verified!":"I'm not a robot"}),l.jsx("div",{className:m("ml-auto"),children:l.jsxs("div",{className:m("text-xs text-gray-400 text-center"),children:[l.jsx("div",{className:m("text-lg"),children:(a==null?void 0:a.provider)==="hcaptcha"?"🛡️":"🔄"}),l.jsx("span",{children:(a==null?void 0:a.provider)==="hcaptcha"?"hCaptcha":(a==null?void 0:a.provider)==="turnstile"?"Turnstile":"reCAPTCHA"})]})})]})}),n&&n.length>0&&l.jsx("div",{className:m("space-y-1"),children:n.map((d,p)=>l.jsx("p",{className:m("text-xs text-red-500"),children:d},p))})]})}}],OE=[{type:"group",structure:"page",typeCategory:"Layout",label:"Group",description:"Container to group related elements together",icon:"📦",category:"page",subCategory:"layout",supportsValidation:!1,isContainer:!0,dataType:"object",getDefaultValues:()=>({properties:{label:"Group",description:""},layout:{size:"full"},config:{collapsed:!1,collapsible:!1,showBorder:!0,padding:16}}),renderOnCanvas:e=>{const{label:t,description:r,config:o}=K(e),n=(o==null?void 0:o.showBorder)??!0,s=(o==null?void 0:o.collapsible)??!1;return l.jsxs("div",{className:m("rounded-lg",n?"border border-gray-200":""),style:{padding:(o==null?void 0:o.padding)||16},children:[l.jsx("div",{className:m("flex items-center justify-between mb-2"),children:l.jsxs("div",{children:[l.jsxs("h3",{className:m("font-medium text-gray-800 flex items-center gap-2"),children:[s&&l.jsx("span",{className:m("text-gray-400 text-sm"),children:"▼"}),t||"Group"]}),r&&l.jsx("p",{className:m("text-sm text-gray-500 mt-0.5"),children:r})]})}),l.jsx("div",{className:m("border-2 border-dashed border-gray-200 rounded-md p-4 min-h-[80px] flex items-center justify-center"),children:l.jsx("span",{className:m("text-sm text-gray-400"),children:"Drop elements here"})})]})},render:e=>{const{label:t,description:r,config:o,element:n}=K(e),{renderChildren:s}=e,a=(o==null?void 0:o.showBorder)??!0,i=(o==null?void 0:o.collapsible)??!1,[c,d]=P.useState((o==null?void 0:o.collapsed)??!1);return l.jsxs("div",{className:`rounded-lg ${a?"border border-gray-200":""}`,style:{padding:(o==null?void 0:o.padding)||16},children:[l.jsx("div",{className:`flex items-center justify-between ${i?"cursor-pointer":""}`,onClick:()=>i&&d(!c),children:l.jsxs("div",{children:[l.jsxs("h3",{className:m("font-medium text-gray-800 flex items-center gap-2"),children:[i&&l.jsx("span",{className:m("text-gray-400 text-sm transition-transform",c?"-rotate-90":""),children:"▼"}),t||"Group"]}),r&&!c&&l.jsx("p",{className:m("text-sm text-gray-500 mt-0.5"),children:r})]})}),!c&&l.jsx("div",{className:m("mt-3"),children:s?s(n.id):l.jsx("div",{"data-container-id":n.id,className:m("space-y-4")})})]})}},{type:"grid",structure:"page",typeCategory:"Layout",label:"Grid",description:"Arrange elements in a responsive grid layout",icon:"⊞",category:"page",subCategory:"layout",supportsValidation:!1,isContainer:!0,dataType:"object",getDefaultValues:()=>({properties:{label:""},layout:{size:"full"},config:{gridColumns:2,gridGap:16,responsiveColumns:{sm:1,md:2,lg:2}}}),renderOnCanvas:e=>{const{label:t,config:r}=K(e),o=(r==null?void 0:r.gridColumns)||2,n=(r==null?void 0:r.gridGap)||16;return l.jsxs("div",{className:m("border border-gray-200 rounded-lg p-4"),children:[t&&l.jsx("div",{className:m("mb-3"),children:l.jsx("h3",{className:m("font-medium text-gray-800"),children:t})}),l.jsx("div",{className:m("grid"),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,gap:n},children:Array.from({length:o}).map((s,a)=>l.jsx("div",{className:m("border-2 border-dashed border-gray-200 rounded-md p-4 min-h-[60px] flex items-center justify-center"),children:l.jsxs("span",{className:m("text-xs text-gray-400"),children:["Column ",a+1]})},a))})]})},render:e=>{const{label:t,config:r,element:o}=K(e),{renderChildren:n}=e,s=(r==null?void 0:r.gridColumns)||2,a=(r==null?void 0:r.gridGap)||16;return l.jsxs("div",{children:[t&&l.jsx("div",{className:m("mb-3"),children:l.jsx("h3",{className:m("font-medium text-gray-800"),children:t})}),l.jsx("div",{className:m("grid"),style:{gridTemplateColumns:`repeat(${s}, 1fr)`,gap:a},children:n?n(o.id):l.jsx("div",{"data-container-id":o.id,className:m("space-y-4")})})]})}},{type:"table",structure:"page",typeCategory:"Layout",label:"Table",description:"Display data in a table format",icon:"📊",category:"page",subCategory:"layout",supportsValidation:!1,isContainer:!0,dataType:"array",getDefaultValues:()=>({properties:{label:"Table",description:""},layout:{size:"full"},config:{tableColumns:[{id:"col1",header:"Column 1",width:"auto",align:"left"},{id:"col2",header:"Column 2",width:"auto",align:"left"},{id:"col3",header:"Column 3",width:"auto",align:"left"}],showHeader:!0,striped:!0,bordered:!0}}),renderOnCanvas:e=>{const{label:t,description:r,config:o}=K(e),n=(o==null?void 0:o.tableColumns)||[{id:"col1",header:"Column 1"},{id:"col2",header:"Column 2"}],s=(o==null?void 0:o.showHeader)??!0,a=(o==null?void 0:o.striped)??!0,i=(o==null?void 0:o.bordered)??!0;return l.jsxs("div",{className:m("space-y-2"),children:[t&&l.jsxs("div",{children:[l.jsx("h3",{className:m("font-medium text-gray-800"),children:t}),r&&l.jsx("p",{className:m("text-sm text-gray-500"),children:r})]}),l.jsx("div",{className:`overflow-hidden rounded-lg ${i?"border border-gray-200":""}`,children:l.jsxs("table",{className:m("min-w-full divide-y divide-gray-200"),children:[s&&l.jsx("thead",{className:m("bg-gray-50"),children:l.jsx("tr",{children:n.map(c=>l.jsx("th",{className:`px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider text-${c.align||"left"}`,children:c.header},c.id))})}),l.jsx("tbody",{className:`bg-white ${a?"divide-y divide-gray-200":""}`,children:[1,2].map((c,d)=>l.jsx("tr",{className:a&&d%2===1?"bg-gray-50":"",children:n.map(p=>l.jsx("td",{className:`px-4 py-3 text-sm text-gray-500 text-${p.align||"left"}`,children:l.jsx("span",{className:m("text-gray-300"),children:"Sample data"})},p.id))},c))})]})}),l.jsx("p",{className:m("text-xs text-gray-400 text-center"),children:"Table preview - drop elements to define row structure"})]})},render:e=>{const{label:t,description:r,config:o,value:n=[]}=K(e),s=(o==null?void 0:o.tableColumns)||[],a=(o==null?void 0:o.showHeader)??!0,i=(o==null?void 0:o.striped)??!0,c=(o==null?void 0:o.bordered)??!0,d=Array.isArray(n)?n:[];return l.jsxs("div",{className:m("space-y-2"),children:[t&&l.jsxs("div",{children:[l.jsx("h3",{className:m("font-medium text-gray-800"),children:t}),r&&l.jsx("p",{className:m("text-sm text-gray-500"),children:r})]}),l.jsx("div",{className:`overflow-x-auto rounded-lg ${c?"border border-gray-200":""}`,children:l.jsxs("table",{className:m("min-w-full divide-y divide-gray-200"),children:[a&&l.jsx("thead",{className:m("bg-gray-50"),children:l.jsx("tr",{children:s.map(p=>l.jsx("th",{style:{width:p.width||"auto"},className:`px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider text-${p.align||"left"}`,children:p.header},p.id))})}),l.jsx("tbody",{className:`bg-white ${i?"divide-y divide-gray-200":""}`,children:d.length===0?l.jsx("tr",{children:l.jsx("td",{colSpan:s.length,className:m("px-4 py-8 text-sm text-gray-400 text-center"),children:"No data available"})}):d.map((p,u)=>l.jsx("tr",{className:i&&u%2===1?"bg-gray-50":"",children:s.map(f=>l.jsx("td",{className:`px-4 py-3 text-sm text-gray-700 text-${f.align||"left"}`,children:p[f.id]??"-"},f.id))},u))})]})})]})}},{type:"pages",structure:"page",typeCategory:"Special",label:"Wizard / Pages",description:"Multi-step form wizard with progress tracking",icon:"📑",category:"page",subCategory:"special",supportsValidation:!1,isContainer:!0,dataType:"object",settingsSchema:{configSection:{title:"Wizard Settings",icon:"📑"},fields:[{key:"showProgressBar",label:"Show Progress Bar",type:"checkbox",section:"config",description:"Display the progress bar and step indicators"},{key:"showStepNumbers",label:"Show Step Numbers",type:"checkbox",section:"config",description:"Display step numbers next to each step"},{key:"allowSkip",label:"Allow Skipping Steps",type:"checkbox",section:"config",description:"Let users jump to earlier steps via the progress bar"},{key:"validateOnNext",label:"Validate Before Next",type:"checkbox",section:"config",description:"Validate the current step's fields before advancing"},{key:"nextButtonLabel",label:"Next Button Label",type:"text",section:"config",placeholder:"Next",description:"Label for the button that advances to the next step"}]},getDefaultValues:()=>({properties:{label:"Form Wizard"},layout:{size:"full"},config:{showProgressBar:!0,showStepNumbers:!0,allowSkip:!1,validateOnNext:!0,nextButtonLabel:"Next",steps:[{id:"step-1",label:"Step 1",description:"First step"},{id:"step-2",label:"Step 2",description:"Second step"}],activeStepId:"step-1"}}),renderOnCanvas:e=>{var i,c;const{config:t}=K(e),r=(t==null?void 0:t.steps)||[{id:"step-1",label:"Step 1"},{id:"step-2",label:"Step 2"}],o=(t==null?void 0:t.activeStepId)||((i=r[0])==null?void 0:i.id),n=r.findIndex(d=>d.id===o),s=(t==null?void 0:t.showProgressBar)??!0,a=(t==null?void 0:t.showStepNumbers)??!0;return l.jsxs("div",{className:m("border border-gray-200 rounded-lg p-4 bg-white"),children:[s&&l.jsxs("div",{className:m("mb-6"),children:[l.jsx("div",{className:m("h-2 bg-gray-200 rounded-full overflow-hidden"),children:l.jsx("div",{className:m("h-full bg-blue-600 transition-all duration-300"),style:{width:`${(n+1)/r.length*100}%`}})}),a&&l.jsx("div",{className:m("flex justify-between mt-3"),children:r.map((d,p)=>{const u=p<n,f=p===n;return l.jsxs("div",{className:m("flex flex-col items-center"),children:[l.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors ${u?"bg-green-500 text-white":f?"bg-blue-600 text-white":"bg-gray-200 text-gray-500"}`,children:u?"✓":p+1}),l.jsx("span",{className:`text-xs mt-1 ${f?"text-blue-600 font-medium":"text-gray-500"}`,children:d.label})]},d.id)})})]}),l.jsx("div",{className:m("border-2 border-dashed border-gray-200 rounded-lg p-6 min-h-[150px] flex items-center justify-center"),children:l.jsxs("div",{className:m("text-center"),children:[l.jsxs("span",{className:m("text-gray-400 text-sm"),children:["Step ",n+1,":"," ",(c=r[n])==null?void 0:c.label]}),l.jsx("p",{className:m("text-gray-300 text-xs mt-1"),children:"Drop elements here for this step"})]})}),l.jsxs("div",{className:m("flex justify-between mt-4 pt-4 border-t border-gray-200"),children:[l.jsx("button",{type:"button",disabled:n===0,className:`px-4 py-2 text-sm rounded-md ${n===0?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-200 text-gray-700 hover:bg-gray-300"}`,children:"← Previous"}),l.jsx("button",{type:"button",className:m("px-4 py-2 text-sm rounded-md bg-blue-600 text-white hover:bg-blue-700"),children:n===r.length-1?"Submit":"Next →"})]})]})},render:e=>{const{config:t,element:r}=K(e),o=(t==null?void 0:t.steps)||[];return l.jsx("div",{"data-wizard-id":r.id,"data-wizard-steps":o.length})}}],ME=[{type:"repeatElement",structure:"page",typeCategory:"Repeatable",label:"Repeat Element",description:"Allow users to add multiple values of a single field",icon:"🔄",category:"page",subCategory:"repeatable",supportsValidation:!0,isContainer:!1,dataType:"array",getDefaultValues:()=>({properties:{label:"Repeatable Field",description:"Add multiple values",placeholder:"Enter value"},layout:{labelPosition:"top",size:"full"},validation:{required:!1},config:{minItems:1,maxItems:10,addButtonText:"Add Item",removeButtonText:"Remove",showItemNumber:!0}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,config:s}=K(e),a=(s==null?void 0:s.minItems)||1,i=(s==null?void 0:s.maxItems)||10,c=(s==null?void 0:s.addButtonText)||"Add Item",d=(s==null?void 0:s.showItemNumber)??!0;return l.jsxs("div",{className:m("space-y-3"),children:[l.jsxs("div",{children:[l.jsxs("label",{className:m("block text-sm font-medium text-gray-700"),children:[t||"Repeatable Field",n&&l.jsx("span",{className:m("text-red-500 ml-1"),children:"*"})]}),r&&l.jsx("p",{className:m("text-xs text-gray-500 mt-0.5"),children:r})]}),l.jsx("div",{className:m("space-y-2"),children:Array.from({length:Math.min(2,a)}).map((p,u)=>l.jsxs("div",{className:m("flex items-center gap-2"),children:[d&&l.jsxs("span",{className:m("text-xs text-gray-400 w-4"),children:[u+1,"."]}),l.jsx("input",{type:"text",placeholder:o||"Enter value",disabled:!0,className:m("flex-1 px-3 py-2 text-sm border border-gray-300 rounded-md bg-gray-50 text-gray-500")}),l.jsx("button",{type:"button",disabled:!0,className:m("p-2 text-gray-400 hover:text-red-500 disabled:opacity-50"),children:"✕"})]},u))}),l.jsxs("button",{type:"button",disabled:!0,className:m("flex items-center gap-1 text-sm text-blue-600 hover:text-blue-700 disabled:opacity-50"),children:[l.jsx("span",{children:"+"}),l.jsx("span",{children:c})]}),l.jsxs("p",{className:m("text-xs text-gray-400"),children:["Min: ",a," | Max: ",i," items"]})]})},render:e=>{const{label:t,description:r,placeholder:o,required:n,config:s,value:a=[],onChange:i,errors:c,isDisabled:d}=K(e),p=(s==null?void 0:s.minItems)||1,u=(s==null?void 0:s.maxItems)||10,f=(s==null?void 0:s.addButtonText)||"Add Item",h=(s==null?void 0:s.showItemNumber)??!0,g=Array.isArray(a)?a:[""],y=g.length<u,b=g.length>p,v=()=>{y&&i&&i([...g,""])},N=C=>{if(b&&i){const E=g.filter((k,_)=>_!==C);i(E)}},x=(C,E)=>{if(i){const k=[...g];k[C]=E,i(k)}},w=c&&c.length>0;return l.jsxs("div",{className:m("space-y-3"),children:[l.jsxs("div",{children:[l.jsxs("label",{className:m("block text-sm font-medium text-gray-700"),children:[t||"Repeatable Field",n&&l.jsx("span",{className:m("text-red-500 ml-1"),children:"*"})]}),r&&l.jsx("p",{className:m("text-xs text-gray-500 mt-0.5"),children:r})]}),l.jsx("div",{className:m("space-y-2"),children:g.map((C,E)=>l.jsxs("div",{className:m("flex items-center gap-2"),children:[h&&l.jsxs("span",{className:m("text-xs text-gray-400 w-4"),children:[E+1,"."]}),l.jsx("input",{type:"text",value:C,onChange:k=>x(E,k.target.value),placeholder:o||"Enter value",disabled:d,className:`flex-1 px-3 py-2 text-sm border rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-offset-0 ${w?"border-red-500 focus:ring-red-500":"border-gray-300 focus:ring-blue-500 focus:border-blue-500"} ${d?"bg-gray-50 text-gray-500 cursor-not-allowed":""}`}),l.jsx("button",{type:"button",onClick:()=>N(E),disabled:!b||d,className:`p-2 transition-colors ${b&&!d?"text-gray-400 hover:text-red-500":"text-gray-300 cursor-not-allowed"}`,children:"✕"})]},E))}),y&&!d&&l.jsxs("button",{type:"button",onClick:v,className:m("flex items-center gap-1 text-sm text-blue-600 hover:text-blue-700"),children:[l.jsx("span",{children:"+"}),l.jsx("span",{children:f})]}),c&&c.length>0&&l.jsx("div",{className:m("space-y-1"),children:c.map((C,E)=>l.jsx("p",{className:m("text-xs text-red-500"),children:C},E))})]})}},{type:"repeatGroup",structure:"page",typeCategory:"Repeatable",label:"Repeat Group",description:"Allow users to add multiple instances of a group of fields",icon:"📚",category:"page",subCategory:"repeatable",supportsValidation:!0,isContainer:!0,dataType:"array",getDefaultValues:()=>({properties:{label:"Repeatable Section",description:"Add multiple entries"},layout:{size:"full"},validation:{required:!1},config:{minItems:1,maxItems:10,addButtonText:"Add Entry",removeButtonText:"Remove",itemLabel:"Entry",showItemNumber:!0}}),renderOnCanvas:e=>{const{label:t,description:r,config:o}=K(e),n=(o==null?void 0:o.minItems)||1,s=(o==null?void 0:o.maxItems)||10,a=(o==null?void 0:o.addButtonText)||"Add Entry",i=(o==null?void 0:o.itemLabel)||"Entry",c=(o==null?void 0:o.showItemNumber)??!0;return l.jsxs("div",{className:m("border border-gray-200 rounded-lg p-4 space-y-4"),children:[l.jsxs("div",{className:m("flex items-center justify-between"),children:[l.jsxs("div",{children:[l.jsxs("h3",{className:m("font-medium text-gray-800 flex items-center gap-2"),children:[l.jsx("span",{className:m("text-lg"),children:"📚"}),t||"Repeatable Section"]}),r&&l.jsx("p",{className:m("text-sm text-gray-500 mt-0.5"),children:r})]}),l.jsxs("span",{className:m("text-xs text-gray-400 bg-gray-100 px-2 py-1 rounded"),children:[n,"-",s," items"]})]}),l.jsxs("div",{className:m("border border-dashed border-gray-300 rounded-lg"),children:[l.jsxs("div",{className:m("flex items-center justify-between px-4 py-2 bg-gray-50 border-b border-dashed border-gray-300 rounded-t-lg"),children:[l.jsxs("span",{className:m("text-sm font-medium text-gray-600"),children:[c&&"1. ",i]}),l.jsxs("div",{className:m("flex items-center gap-2"),children:[l.jsx("button",{type:"button",disabled:!0,className:m("text-gray-400 hover:text-gray-600 text-sm"),children:"▲"}),l.jsx("button",{type:"button",disabled:!0,className:m("text-gray-400 hover:text-gray-600 text-sm"),children:"▼"}),l.jsx("button",{type:"button",disabled:!0,className:m("text-gray-400 hover:text-red-500 text-sm"),children:"✕"})]})]}),l.jsx("div",{className:m("p-4 min-h-[80px] flex items-center justify-center"),children:l.jsx("span",{className:m("text-sm text-gray-400"),children:"Drop elements here to define the repeatable group structure"})})]}),l.jsxs("button",{type:"button",disabled:!0,className:m("w-full flex items-center justify-center gap-2 py-2 border-2 border-dashed border-gray-300 rounded-lg text-sm text-gray-500 hover:border-blue-400 hover:text-blue-600 transition-colors disabled:opacity-50"),children:[l.jsx("span",{children:"+"}),l.jsx("span",{children:a})]})]})},render:e=>{const{label:t,description:r,config:o,element:n,value:s=[],onChange:a,errors:i,isDisabled:c}=K(e),{renderChildren:d}=e,p=(o==null?void 0:o.minItems)||1,u=(o==null?void 0:o.maxItems)||10,f=(o==null?void 0:o.addButtonText)||"Add Entry",h=(o==null?void 0:o.removeButtonText)||"Remove",g=(o==null?void 0:o.itemLabel)||"Entry",y=(o==null?void 0:o.showItemNumber)??!0,b=Array.isArray(s)?s:Array.from({length:p},()=>({})),v=b.length<u,N=b.length>p,x=()=>{v&&a&&a([...b,{}])},w=_=>{if(N&&a){const D=b.filter((A,I)=>I!==_);a(D)}},C=_=>{if(_>0&&a){const D=[...b];[D[_-1],D[_]]=[D[_],D[_-1]],a(D)}},E=_=>{if(_<b.length-1&&a){const D=[...b];[D[_],D[_+1]]=[D[_+1],D[_]],a(D)}},k=i&&i.length>0;return l.jsxs("div",{className:`border rounded-lg p-4 space-y-4 ${k?"border-red-300":"border-gray-200"}`,children:[l.jsxs("div",{className:m("flex items-center justify-between"),children:[l.jsxs("div",{children:[l.jsx("h3",{className:m("font-medium text-gray-800"),children:t||"Repeatable Section"}),r&&l.jsx("p",{className:m("text-sm text-gray-500 mt-0.5"),children:r})]}),l.jsxs("span",{className:m("text-xs text-gray-400"),children:[b.length," of ",u]})]}),l.jsx("div",{className:m("space-y-3"),children:b.map((_,D)=>{var A;return l.jsxs("div",{className:m("border border-gray-200 rounded-lg overflow-hidden"),children:[l.jsxs("div",{className:m("flex items-center justify-between px-4 py-2 bg-gray-50 border-b border-gray-200"),children:[l.jsxs("span",{className:m("text-sm font-medium text-gray-600"),children:[y&&`${D+1}. `,g]}),!c&&l.jsxs("div",{className:m("flex items-center gap-1"),children:[l.jsx("button",{type:"button",onClick:()=>C(D),disabled:D===0,className:`p-1 rounded transition-colors ${D===0?"text-gray-300 cursor-not-allowed":"text-gray-400 hover:text-gray-600 hover:bg-gray-100"}`,title:"Move up",children:"▲"}),l.jsx("button",{type:"button",onClick:()=>E(D),disabled:D===b.length-1,className:`p-1 rounded transition-colors ${D===b.length-1?"text-gray-300 cursor-not-allowed":"text-gray-400 hover:text-gray-600 hover:bg-gray-100"}`,title:"Move down",children:"▼"}),l.jsx("button",{type:"button",onClick:()=>w(D),disabled:!N,className:`p-1 rounded transition-colors ${N?"text-gray-400 hover:text-red-500 hover:bg-red-50":"text-gray-300 cursor-not-allowed"}`,title:h,children:"✕"})]})]}),l.jsx("div",{className:m("p-4"),children:d?d(n.id,`${((A=n.attributes)==null?void 0:A.name)||n.id}[${D}]`):l.jsx("div",{"data-repeat-group-item":n.id,"data-repeat-index":D,className:m("text-sm text-gray-400 text-center py-4"),children:"Group fields render here"})})]},D)})}),v&&!c&&l.jsxs("button",{type:"button",onClick:x,className:m("w-full flex items-center justify-center gap-2 py-2 border-2 border-dashed border-gray-300 rounded-lg text-sm text-gray-500 hover:border-blue-400 hover:text-blue-600 transition-colors"),children:[l.jsx("span",{children:"+"}),l.jsx("span",{children:f})]}),i&&i.length>0&&l.jsx("div",{className:m("space-y-1"),children:i.map((_,D)=>l.jsx("p",{className:m("text-xs text-red-500"),children:_},D))})]})}}],Sh=[...I0,...O0,...M0,...kE,...AE,...DE,...$E,...TE,...PE,...IE,...OE,...ME];function LE(){for(const e of Sh)ut.register(e)}const FE=["shortText","longText","multiLineInput","textEditor"],VE=["number","slider","rangeSlider"],GE=["email","phone","url","location"],zE=["password","signature","captcha"],BE=["singleChoice","multipleChoice","dropdown","tags","decisionBox","toggleSwitch"],UE=["singleChoiceMatrix","multipleChoiceMatrix","matrixTable"],WE=["date","time","dateTime","multipleDates","dateRange"],HE=["fileUpload","imageUpload","multiFileUpload","multiImageUpload"],jE=["paragraph","image","link"],qE=[...FE,...VE,...GE,...zE,...BE,...UE,...WE,...HE,...jE],gc={shortText:"Short Text",longText:"Long Text",multiLineInput:"Multi-line Input",textEditor:"Text Editor",number:"Number",slider:"Slider",rangeSlider:"Range Slider",email:"Email",phone:"Phone",url:"URL",location:"Location",password:"Password",signature:"Signature",captcha:"Captcha",singleChoice:"Single Choice",multipleChoice:"Multiple Choice",dropdown:"Dropdown",tags:"Tags",decisionBox:"Decision Box",toggleSwitch:"Toggle Switch",singleChoiceMatrix:"Single Choice Matrix",multipleChoiceMatrix:"Multiple Choice Matrix",matrixTable:"Matrix Table",date:"Date",time:"Time",dateTime:"Date & Time",multipleDates:"Multiple Dates",dateRange:"Date Range",fileUpload:"File Upload",imageUpload:"Image Upload",multiFileUpload:"Multi-File Upload",multiImageUpload:"Multi-Image Upload",paragraph:"Paragraph",image:"Image",link:"Link",formHeading:"Form Heading",sectionHeading:"Section Heading",subheading:"Subheading",divider:"Divider",spacer:"Spacer",group:"Group",grid:"Grid",table:"Table",repeatElement:"Repeat Element",repeatGroup:"Repeat Group",pages:"Pages (Wizard)",submit:"Submit Button"},bc={shortText:"📝",longText:"📄",multiLineInput:"📑",textEditor:"✏️",number:"🔢",slider:"🎚️",rangeSlider:"↔️",email:"✉️",phone:"📱",url:"🔗",location:"📍",password:"🔒",signature:"✍️",captcha:"🤖",singleChoice:"🔘",multipleChoice:"☑️",dropdown:"📋",tags:"🏷️",decisionBox:"✅",toggleSwitch:"🔀",singleChoiceMatrix:"📊",multipleChoiceMatrix:"📈",matrixTable:"📉",date:"📅",time:"⏰",dateTime:"📆",multipleDates:"🗓️",dateRange:"↔️",fileUpload:"📎",imageUpload:"🖼️",multiFileUpload:"📁",multiImageUpload:"🖼️",paragraph:"📃",image:"🏞️",link:"🔗",formHeading:"🏷️",sectionHeading:"📌",subheading:"📎",divider:"➖",spacer:"↕️",group:"📦",grid:"⊞",table:"📊",repeatElement:"🔄",repeatGroup:"🔁",pages:"📖",submit:"🚀"};function YE(e){return qE.includes(e)}const QE=["singleChoice","multipleChoice","dropdown","tags"],KE=["shortText","longText","multiLineInput","textEditor","number","slider","rangeSlider","email","phone","url","location","password","singleChoice","multipleChoice","dropdown","tags","decisionBox","date","time","dateTime","multipleDates","dateRange","fileUpload","imageUpload","multiFileUpload","multiImageUpload"],RE=["singleChoiceMatrix","multipleChoiceMatrix","matrixTable"];function XE(e){return QE.includes(e)}function JE(e){return KE.includes(e)}function ZE(e){return RE.includes(e)}const Ia=({element:e,isSelected:t=!1})=>{const r=ut.get(e.type),o={element:e,properties:e.properties,layout:e.layout,validation:e.validation,logic:e.logic,config:e.config,isSelected:t,mode:"canvas"};if(r&&r.renderOnCanvas)try{return l.jsx(l.Fragment,{children:r.renderOnCanvas(o)})}catch(n){return console.error(`Error rendering element "${e.type}" on canvas:`,n),l.jsx(Oa,{element:e,error:n})}return l.jsx(Oa,{element:e})},Nh=({element:e,value:t,onChange:r,errors:o=[],formValues:n={},readOnly:s=!1,disabled:a=!1})=>{const i=ut.get(e.type),c={element:e,properties:e.properties,layout:e.layout,validation:e.validation,logic:e.logic,config:e.config,mode:"render",value:t,onChange:r,errors:o,formValues:n,readOnly:s,disabled:a};if(i&&i.render)try{return l.jsx(l.Fragment,{children:i.render(c)})}catch(d){return console.error(`Error rendering element "${e.type}":`,d),l.jsx(Oa,{element:e,error:d})}return l.jsx(Oa,{element:e})},Oa=({element:e,error:t})=>{const r=bc[e.type]||"❓",o=gc[e.type]||e.type;return t?l.jsxs("div",{className:m("p-4 bg-red-50 border border-red-200 rounded text-red-600 text-sm"),children:[l.jsxs("div",{className:m("flex items-center gap-2"),children:[l.jsx("span",{children:"⚠️"}),l.jsxs("span",{children:["Error rendering: ",o]})]}),l.jsx("p",{className:m("text-xs mt-1 text-red-500"),children:t instanceof Error?t.message:"Unknown error"})]}):l.jsxs("div",{className:m("p-4 bg-gray-100 rounded text-gray-600 text-sm"),children:[l.jsxs("div",{className:m("flex items-center gap-2"),children:[l.jsx("span",{children:r}),l.jsx("span",{children:o})]}),l.jsx("p",{className:m("text-xs mt-1 text-gray-400"),children:"Element type not registered in the element registry"})]})};function e1(e){return ut.has(e)}function Ch(e){const t=ut.get(e);return t?t.icon:bc[e]}function yc(e){const t=ut.get(e);return t?t.label:gc[e]||e}function t1(e,t){return l.jsx(Ia,{element:e,isSelected:t})}function r1(e,t,r,o,n){return l.jsx(Nh,{element:e,value:t,onChange:r,errors:o,formValues:n})}const ar=S.forwardRef(({className:e,type:t,...r},o)=>l.jsx("input",{type:t,className:m("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:o,...r}));ar.displayName="Input";const Eh=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,_h=Qu,Ma=(e,t)=>r=>{var o;if((t==null?void 0:t.variants)==null)return _h(e,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:n,defaultVariants:s}=t,a=Object.keys(n).map(d=>{const p=r==null?void 0:r[d],u=s==null?void 0:s[d];if(p===null)return null;const f=Eh(p)||Eh(u);return n[d][f]}),i=r&&Object.entries(r).reduce((d,p)=>{let[u,f]=p;return f===void 0||(d[u]=f),d},{}),c=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((d,p)=>{let{class:u,className:f,...h}=p;return Object.entries(h).every(g=>{let[y,b]=g;return Array.isArray(b)?b.includes({...s,...i}[y]):{...s,...i}[y]===b})?[...d,u,f]:d},[]);return _h(e,a,c,r==null?void 0:r.class,r==null?void 0:r.className)},o1=Ma("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function vc({className:e,variant:t,...r}){return l.jsx("div",{className:m(o1({variant:t}),e),...r})}var n1=Object.defineProperty,xc=(e,t)=>n1(e,"name",{value:t,configurable:!0}),wc=!1;function kh(){const[e,t]=S.useState(wc);return S.useEffect(()=>{wc||(wc=!0,t(!0))},[]),e}xc(kh,"useIsHydrated");var Ah=S[" useSyncExternalStore ".trim().toString()];function Dh(){return()=>{}}xc(Dh,"subscribe");function $h(){return Ah(Dh,()=>!0,()=>!1)}xc($h,"useIsHydratedModern");var s1=typeof Ah=="function"?$h:kh,a1=Object.defineProperty,zo=(e,t)=>a1(e,"name",{value:t,configurable:!0}),Sc="rovingFocusGroup.onEntryFocus",l1={bubbles:!1,cancelable:!0},La="RovingFocusGroup",[Nc,Th,i1]=na(La),[c1,Ph]=sr(La,[i1]),[d1,u1]=c1(La),f1=S.forwardRef(zo(function(t,r){return l.jsx(Nc.Provider,{scope:t.__scopeRovingFocusGroup,children:l.jsx(Nc.Slot,{scope:t.__scopeRovingFocusGroup,children:l.jsx(p1,{...t,ref:r})})})},"RovingFocusGroup")),p1=S.forwardRef(zo(function(t,r){const{__scopeRovingFocusGroup:o,orientation:n,loop:s=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:p,preventScrollOnEntryFocus:u=!1,...f}=t,h=S.useRef(null),g=Ue(r,h),y=Vn(a),[b,v]=yr({prop:i,defaultProp:c??null,onChange:d,caller:La}),[N,x]=S.useState(!1),w=gr(p),C=Th(o),E=S.useRef(!1),[k,_]=S.useState(0);return S.useEffect(()=>{const D=h.current;if(D)return D.addEventListener(Sc,w),()=>D.removeEventListener(Sc,w)},[w]),l.jsx(d1,{scope:o,orientation:n,dir:y,loop:s,currentTabStopId:b,onItemFocus:S.useCallback(D=>v(D),[v]),onItemShiftTab:S.useCallback(()=>x(!0),[]),onFocusableItemAdd:S.useCallback(()=>_(D=>D+1),[]),onFocusableItemRemove:S.useCallback(()=>_(D=>D-1),[]),children:l.jsx(Ie.div,{tabIndex:N||k===0?-1:0,"data-orientation":n,...f,ref:g,style:{outline:"none",...t.style},onMouseDown:Se(t.onMouseDown,()=>{E.current=!0}),onFocus:Se(t.onFocus,D=>{const A=!E.current;if(D.target===D.currentTarget&&A&&!N){const I=new CustomEvent(Sc,l1);if(D.currentTarget.dispatchEvent(I),!I.defaultPrevented){const T=C().filter(z=>z.focusable),L=T.find(z=>z.active),F=T.find(z=>z.id===b),G=[L,F,...T].filter(Boolean).map(z=>z.ref.current);Cc(G,u)}}E.current=!1}),onBlur:Se(t.onBlur,()=>x(!1))})})},"RovingFocusGroupImpl")),h1="RovingFocusGroupItem",m1=S.forwardRef(zo(function(t,r){const{__scopeRovingFocusGroup:o,focusable:n=!0,active:s=!1,tabStopId:a,children:i,...c}=t,d=br(),p=a||d,u=u1(h1,o),f=u.currentTabStopId===p,h=Th(o),{onFocusableItemAdd:g,onFocusableItemRemove:y,currentTabStopId:b}=u,v=s1();return ot(()=>{if(!(!v||!n))return g(),()=>y()},[v,n,g,y]),S.useEffect(()=>{if(!(v||!n))return g(),()=>y()},[v,n,g,y]),l.jsx(Nc.ItemSlot,{scope:o,id:p,focusable:n,active:s,children:l.jsx(Ie.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...c,ref:r,onMouseDown:Se(t.onMouseDown,N=>{n?u.onItemFocus(p):N.preventDefault()}),onFocus:Se(t.onFocus,()=>u.onItemFocus(p)),onKeyDown:Se(t.onKeyDown,N=>{if(N.key==="Tab"&&N.shiftKey){u.onItemShiftTab();return}if(N.target!==N.currentTarget)return;const x=Oh(N,u.orientation,u.dir);if(x!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let C=h().filter(E=>E.focusable).map(E=>E.ref.current);if(x==="last")C.reverse();else if(x==="prev"||x==="next"){x==="prev"&&C.reverse();const E=C.indexOf(N.currentTarget);C=u.loop?Mh(C,E+1):C.slice(E+1)}setTimeout(()=>Cc(C))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:b!=null}):i})})},"RovingFocusGroupItem")),g1={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ih(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}zo(Ih,"getDirectionAwareKey");function Oh(e,t,r){const o=Ih(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return g1[o]}zo(Oh,"getFocusIntent");function Cc(e,t=!1){const r=document.activeElement;for(const o of e)if(o===r||(o.focus({preventScroll:t}),document.activeElement!==r))return}zo(Cc,"focusFirst");function Mh(e,t){return e.map((r,o)=>e[(t+o)%e.length])}zo(Mh,"wrapArray");var b1=f1,y1=m1,v1=Object.defineProperty,gn=(e,t)=>v1(e,"name",{value:t,configurable:!0}),Ec="Tabs",[x1,xO]=sr(Ec,[Ph]),Lh=Ph(),[w1,_c]=x1(Ec),S1=S.forwardRef(gn(function(t,r){const{__scopeTabs:o,value:n,onValueChange:s,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...p}=t,u=Vn(c),[f,h]=yr({prop:n,onChange:s,defaultProp:a??"",caller:Ec});return l.jsx(w1,{scope:o,baseId:br(),value:f,onValueChange:h,orientation:i,dir:u,activationMode:d,children:l.jsx(Ie.div,{dir:u,"data-orientation":i,...p,ref:r})})},"Tabs")),N1="TabsList",C1=S.forwardRef(gn(function(t,r){const{__scopeTabs:o,loop:n=!0,...s}=t,a=_c(N1,o),i=Lh(o);return l.jsx(b1,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:n,children:l.jsx(Ie.div,{role:"tablist","aria-orientation":a.orientation,...s,ref:r})})},"TabsList")),E1="TabsTrigger",_1=S.forwardRef(gn(function(t,r){const{__scopeTabs:o,value:n,disabled:s=!1,...a}=t,i=_c(E1,o),c=Lh(o),d=kc(i.baseId,n),p=Ac(i.baseId,n),u=n===i.value;return l.jsx(y1,{asChild:!0,...c,focusable:!s,active:u,children:l.jsx(Ie.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":p,"data-state":u?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:d,...a,ref:r,onMouseDown:Se(t.onMouseDown,f=>{!s&&f.button===0&&f.ctrlKey===!1?i.onValueChange(n):f.preventDefault()}),onKeyDown:Se(t.onKeyDown,f=>{s||f.target!==f.currentTarget||[" ","Enter"].includes(f.key)&&i.onValueChange(n)}),onFocus:Se(t.onFocus,()=>{const f=i.activationMode!=="manual";!u&&!s&&f&&i.onValueChange(n)})})})},"TabsTrigger")),k1="TabsContent",A1=S.forwardRef(gn(function(t,r){const{__scopeTabs:o,value:n,forceMount:s,children:a,...i}=t,c=_c(k1,o),d=kc(c.baseId,n),p=Ac(c.baseId,n),u=n===c.value,f=S.useRef(u);return S.useEffect(()=>{const h=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(h)},[]),l.jsx(eo,{present:s||u,children:({present:h})=>l.jsx(Ie.div,{"data-state":u?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!h,id:p,tabIndex:0,...i,ref:r,style:{...t.style,animationDuration:f.current?"0s":void 0},children:h&&a})})},"TabsContent"));function kc(e,t){return`${e}-trigger-${t}`}gn(kc,"makeTriggerId");function Ac(e,t){return`${e}-content-${t}`}gn(Ac,"makeContentId");var D1=S1,Fh=C1,Vh=_1,Gh=A1;const zh=D1,Dc=S.forwardRef(({className:e,...t},r)=>l.jsx(Fh,{ref:r,className:m("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));Dc.displayName=Fh.displayName;const Yn=S.forwardRef(({className:e,...t},r)=>l.jsx(Vh,{ref:r,className:m("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));Yn.displayName=Vh.displayName;const Qn=S.forwardRef(({className:e,...t},r)=>l.jsx(Gh,{ref:r,className:m("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Qn.displayName=Gh.displayName;var $1=Object.defineProperty,Kn=(e,t)=>$1(e,"name",{value:t,configurable:!0}),$c="Collapsible",[T1,Bh]=sr($c),[P1,Tc]=T1($c),I1=S.forwardRef(Kn(function(t,r){const{__scopeCollapsible:o,open:n,defaultOpen:s,disabled:a,onOpenChange:i,...c}=t,[d,p]=yr({prop:n,defaultProp:s??!1,onChange:i,caller:$c});return l.jsx(P1,{scope:o,disabled:a,contentId:br(),open:d,onOpenToggle:S.useCallback(()=>p(u=>!u),[p]),children:l.jsx(Ie.div,{"data-state":Fa(d),"data-disabled":a?"":void 0,...c,ref:r})})},"Collapsible")),O1="CollapsibleTrigger",Uh=S.forwardRef(Kn(function(t,r){const{__scopeCollapsible:o,...n}=t,s=Tc(O1,o);return l.jsx(Ie.button,{type:"button","aria-controls":s.open?s.contentId:void 0,"aria-expanded":s.open||!1,"data-state":Fa(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...n,ref:r,onClick:Se(t.onClick,s.onOpenToggle)})},"CollapsibleTrigger")),Wh="CollapsibleContent",Hh=S.forwardRef(Kn(function(t,r){const{forceMount:o,...n}=t,s=Tc(Wh,t.__scopeCollapsible);return l.jsx(eo,{present:o||s.open,children:({present:a})=>l.jsx(M1,{...n,ref:r,present:a})})},"CollapsibleContent")),M1=S.forwardRef(Kn(function(t,r){const{__scopeCollapsible:o,present:n,children:s,...a}=t,i=Tc(Wh,o),[c,d]=S.useState(n),p=S.useRef(null),u=Ue(r,p),f=S.useRef(0),h=f.current,g=S.useRef(0),y=g.current,b=i.open||c,v=S.useRef(b),N=S.useRef(void 0);return S.useEffect(()=>{const x=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(x)},[]),ot(()=>{const x=p.current;if(x){N.current=N.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const w=x.getBoundingClientRect();f.current=w.height,g.current=w.width,v.current||(x.style.transitionDuration=N.current.transitionDuration,x.style.animationName=N.current.animationName),d(n)}},[i.open,n]),l.jsx(Ie.div,{"data-state":Fa(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!b,...a,ref:u,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...t.style},children:b&&s})},"CollapsibleContentImpl"));function Fa(e){return e?"open":"closed"}Kn(Fa,"getState");var jh=I1,L1=Uh,F1=Hh;const qh=jh,Yh=Uh,Qh=Hh,V1=Ma("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Je=S.forwardRef(({className:e,variant:t,size:r,asChild:o=!1,...n},s)=>{const a=o?H0:"button";return l.jsx(a,{className:m(V1({variant:t,size:r,className:e})),ref:s,...n})});Je.displayName="Button";var G1=Object.defineProperty,Nt=(e,t)=>G1(e,"name",{value:t,configurable:!0}),[Pc,wO]=sr("Tooltip",[va]),Ic=va(),z1="TooltipProvider",B1=700,Oc="tooltip.open",[U1,Mc]=Pc(z1),W1=Nt(e=>{const{__scopeTooltip:t,delayDuration:r=B1,skipDelayDuration:o=300,disableHoverableContent:n=!1,children:s}=e,a=S.useRef(!0),i=S.useRef(!1),c=S.useRef(0);return S.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),l.jsx(U1,{scope:t,isOpenDelayedRef:a,delayDuration:r,onOpen:S.useCallback(()=>{o<=0||(window.clearTimeout(c.current),a.current=!1)},[o]),onClose:S.useCallback(()=>{o<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,o))},[o]),isPointerInTransitRef:i,onPointerInTransitChange:S.useCallback(d=>{i.current=d},[]),disableHoverableContent:n,children:s})},"TooltipProvider"),Lc="Tooltip",[H1,Rn]=Pc(Lc),j1=Nt(e=>{const{__scopeTooltip:t,children:r,open:o,defaultOpen:n,onOpenChange:s,disableHoverableContent:a,delayDuration:i}=e,c=Mc(Lc,e.__scopeTooltip),d=Ic(t),[p,u]=S.useState(null),[f,h]=S.useState(void 0),g=br(),y=S.useRef(0),b=a??c.disableHoverableContent,v=i??c.delayDuration,N=S.useRef(!1),[x,w]=yr({prop:o,defaultProp:n??!1,onChange:Nt(A=>{A?(c.onOpen(),document.dispatchEvent(new CustomEvent(Oc))):c.onClose(),s==null||s(A)},"onChange"),caller:Lc}),C=S.useMemo(()=>x?N.current?"delayed-open":"instant-open":"closed",[x]),E=S.useCallback(()=>{window.clearTimeout(y.current),y.current=0,N.current=!1,w(!0)},[w]),k=S.useCallback(()=>{window.clearTimeout(y.current),y.current=0,w(!1)},[w]),_=S.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{N.current=!0,w(!0),y.current=0},v)},[v,w]);S.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]);const D=f??g;return l.jsx(wp,{...d,children:l.jsx(H1,{scope:t,contentId:D,setContentId:h,open:x,stateAttribute:C,trigger:p,onTriggerChange:u,onTriggerEnter:S.useCallback(()=>{c.isOpenDelayedRef.current?_():E()},[c.isOpenDelayedRef,_,E]),onTriggerLeave:S.useCallback(()=>{b?k():(window.clearTimeout(y.current),y.current=0)},[k,b]),onOpen:E,onClose:k,disableHoverableContent:b,children:r})})},"Tooltip"),Kh="TooltipTrigger",q1=S.forwardRef(Nt(function(t,r){const{__scopeTooltip:o,...n}=t,s=Rn(Kh,o),a=Mc(Kh,o),i=Ic(o),c=S.useRef(null),d=Ue(r,c,s.onTriggerChange),p=S.useRef(!1),u=S.useRef(!1),f=S.useCallback(()=>p.current=!1,[]);return S.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),l.jsx(Sp,{asChild:!0,...i,children:l.jsx(Ie.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...n,ref:d,onPointerMove:Se(t.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!a.isPointerInTransitRef.current&&(s.onTriggerEnter(),u.current=!0)}),onPointerLeave:Se(t.onPointerLeave,()=>{s.onTriggerLeave(),u.current=!1}),onPointerDown:Se(t.onPointerDown,()=>{s.open&&s.onClose(),p.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Se(t.onFocus,()=>{p.current||s.onOpen()}),onBlur:Se(t.onBlur,s.onClose),onClick:Se(t.onClick,s.onClose)})})},"TooltipTrigger")),Rh="TooltipPortal",[Y1,Q1]=Pc(Rh,{forceMount:void 0}),K1=Nt(e=>{const{__scopeTooltip:t,forceMount:r,children:o,container:n}=e,s=Rn(Rh,t);return l.jsx(Y1,{scope:t,forceMount:r,children:l.jsx(eo,{present:r||s.open,children:l.jsx(tc,{asChild:!0,container:n,children:o})})})},"TooltipPortal"),Xn="TooltipContent",R1=S.forwardRef(Nt(function(t,r){const o=Q1(Xn,t.__scopeTooltip),{forceMount:n=o.forceMount,side:s="top",...a}=t,i=Rn(Xn,t.__scopeTooltip);return l.jsx(eo,{present:n||i.open,children:i.disableHoverableContent?l.jsx(Xh,{side:s,...a,ref:r}):l.jsx(X1,{side:s,...a,ref:r})})},"TooltipContent")),X1=S.forwardRef(Nt(function(t,r){const o=Rn(Xn,t.__scopeTooltip),n=Mc(Xn,t.__scopeTooltip),s=S.useRef(null),a=Ue(r,s),[i,c]=S.useState(null),{trigger:d,onClose:p}=o,u=s.current,{onPointerInTransitChange:f}=n,h=S.useCallback(()=>{c(null),f(!1)},[f]),g=S.useCallback((y,b)=>{const v=y.currentTarget,N={x:y.clientX,y:y.clientY},x=Jh(N,v.getBoundingClientRect()),w=Zh(N,x),C=em(b.getBoundingClientRect()),E=rm([...w,...C]);c(E),f(!0)},[f]);return S.useEffect(()=>()=>h(),[h]),S.useEffect(()=>{if(d&&u){const y=Nt(v=>g(v,u),"handleTriggerLeave"),b=Nt(v=>g(v,d),"handleContentLeave");return d.addEventListener("pointerleave",y),u.addEventListener("pointerleave",b),()=>{d.removeEventListener("pointerleave",y),u.removeEventListener("pointerleave",b)}}},[d,u,g,h]),S.useEffect(()=>{if(i){const y=Nt(b=>{const v=b.target,N={x:b.clientX,y:b.clientY},x=(d==null?void 0:d.contains(v))||(u==null?void 0:u.contains(v)),w=!tm(N,i);x?h():w&&(h(),p())},"handleTrackPointerGrace");return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[d,u,i,p,h]),l.jsx(Xh,{...t,ref:a})},"TooltipContentHoverable")),J1=Cf("TooltipContent"),Xh=S.forwardRef(Nt(function(t,r){const{__scopeTooltip:o,children:n,"aria-label":s,id:a,onEscapeKeyDown:i,onPointerDownOutside:c,...d}=t,p=Rn(Xn,o),u=Ic(o),{onClose:f}=p;S.useEffect(()=>(document.addEventListener(Oc,f),()=>document.removeEventListener(Oc,f)),[f]),S.useEffect(()=>{if(p.trigger){const g=Nt(y=>{y.target instanceof Node&&y.target.contains(p.trigger)&&f()},"handleScroll");return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[p.trigger,f]);const{setContentId:h}=p;return ot(()=>(h(a),()=>{h(void 0)}),[a,h]),l.jsx(Ii,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:f,children:l.jsxs(Np,{"data-state":p.stateAttribute,role:s?void 0:"tooltip",id:s?void 0:p.contentId,...u,...d,ref:r,style:{...d.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[l.jsx(J1,{children:n}),s?l.jsx(HN,{id:p.contentId,role:"tooltip",children:s}):null]})})},"TooltipContentImpl"));function Jh(e,t){const r=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),n=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(r,o,n,s)){case s:return"left";case n:return"right";case r:return"top";case o:return"bottom";default:throw new Error("unreachable")}}Nt(Jh,"getExitSideFromRect");function Zh(e,t,r=5){const o=[];switch(t){case"top":o.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":o.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":o.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":o.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return o}Nt(Zh,"getPaddedExitPoints");function em(e){const{top:t,right:r,bottom:o,left:n}=e;return[{x:n,y:t},{x:r,y:t},{x:r,y:o},{x:n,y:o}]}Nt(em,"getPointsFromRect");function tm(e,t){const{x:r,y:o}=e;let n=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const i=t[s],c=t[a],d=i.x,p=i.y,u=c.x,f=c.y;p>o!=f>o&&r<(u-d)*(o-p)/(f-p)+d&&(n=!n)}return n}Nt(tm,"isPointInPolygon");function rm(e){const t=e.slice();return t.sort((r,o)=>r.x<o.x?-1:r.x>o.x?1:r.y<o.y?-1:r.y>o.y?1:0),om(t)}Nt(rm,"getHull");function om(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const n=e[o];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(n.y-a.y)>=(s.y-a.y)*(n.x-a.x))t.pop();else break}t.push(n)}t.pop();const r=[];for(let o=e.length-1;o>=0;o--){const n=e[o];for(;r.length>=2;){const s=r[r.length-1],a=r[r.length-2];if((s.x-a.x)*(n.y-a.y)>=(s.y-a.y)*(n.x-a.x))r.pop();else break}r.push(n)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}Nt(om,"getHullPresorted");var Z1=W1,e_=j1,t_=q1,r_=K1,nm=R1;const Va=Z1,Or=e_,Mr=t_,xr=S.forwardRef(({className:e,sideOffset:t=4,...r},o)=>l.jsx(r_,{children:l.jsx(nm,{ref:o,sideOffset:t,className:m("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",e),...r})}));xr.displayName=nm.displayName;const Fc=S.forwardRef(({className:e,children:t,...r},o)=>l.jsx("div",{ref:o,className:m("relative overflow-hidden",e),...r,children:l.jsx("div",{className:m("h-full w-full overflow-auto rounded-[inherit]"),children:t})}));Fc.displayName="ScrollArea";const o_=S.forwardRef(({className:e,orientation:t="vertical",...r},o)=>l.jsx("div",{ref:o,className:m("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...r,children:l.jsx("div",{className:m("relative flex-1 rounded-full bg-border")})}));o_.displayName="ScrollBar";function sm(e){return{order:99,disabled:!1,hidden:!1,...e}}function n_(e){return e.map((t,r)=>sm({...t,order:t.order??100+r}))}function am(e,t){return typeof e.disabled=="function"?e.disabled(t):e.disabled??!1}function lm(e,t){return typeof e.hidden=="function"?e.hidden(t):e.hidden??!1}const s_=({element:e,onAddElement:t,isDisabled:r=!1,disabledReason:o,wizardExists:n=!1})=>{const s=te(u=>u.setDraggedElementType),a=u=>{if(r){u.preventDefault();return}u.dataTransfer.setData("elementType",e.type),u.dataTransfer.effectAllowed="copy",s(e.type)},i=()=>{s(null)},c=()=>{r||t(e.type)},d=()=>{if(typeof e.icon=="string")return l.jsx("span",{className:m("text-lg flex-shrink-0"),children:e.icon});const u=e.icon;return l.jsx(u,{className:m("w-5 h-5 flex-shrink-0")})},p=l.jsxs("div",{draggable:!r,onDragStart:a,onDragEnd:i,onClick:c,className:m("flex items-center gap-2 p-2 bg-card border border-border rounded-md transition-all duration-150 select-none",r?"opacity-50 cursor-not-allowed":"cursor-grab hover:border-primary hover:shadow-sm active:cursor-grabbing"),children:[d(),l.jsxs("div",{className:m("flex-1 min-w-0"),children:[l.jsx("div",{className:m("text-xs font-medium text-foreground truncate"),children:e.label}),r&&l.jsx("div",{className:m("text-xs text-orange-500 truncate"),children:"Already added"})]})]});return r&&o?l.jsx(Va,{children:l.jsxs(Or,{children:[l.jsx(Mr,{asChild:!0,children:p}),l.jsx(xr,{children:l.jsx("p",{children:o})})]})}):l.jsx(Va,{children:l.jsxs(Or,{children:[l.jsx(Mr,{asChild:!0,children:p}),l.jsx(xr,{children:l.jsxs("div",{className:m("max-w-xs"),children:[l.jsx("p",{className:m("font-medium"),children:e.label}),l.jsx("p",{className:m("text-xs text-muted-foreground"),children:e.description}),l.jsx("p",{className:m("text-xs mt-1 text-muted-foreground/70"),children:n?"Drag into wizard step":"Drag or click to add"})]})})]})})},im=({label:e,elements:t,searchQuery:r,onAddElement:o,defaultExpanded:n=!1,hasWizard:s=!1,wizardExists:a=!1})=>{const[i,c]=P.useState(n),d=P.useMemo(()=>{if(!r.trim())return t;const u=r.toLowerCase();return t.filter(f=>f.label.toLowerCase().includes(u)||f.description.toLowerCase().includes(u)||f.searchKeywords&&f.searchKeywords.some(h=>h.toLowerCase().includes(u)))},[t,r]);if(r&&d.length===0)return null;const p=r?!0:i;return l.jsxs(qh,{open:p,onOpenChange:c,className:m("mb-2"),children:[l.jsx(Yh,{asChild:!0,children:l.jsxs(Je,{variant:"ghost",className:m("w-full flex items-center justify-between px-2 py-1.5 h-auto text-xs font-semibold text-muted-foreground uppercase tracking-wider hover:bg-muted"),children:[l.jsx("span",{children:e}),l.jsxs("span",{className:m("flex items-center gap-1"),children:[l.jsx(vc,{variant:"secondary",className:m("font-normal normal-case text-xs"),children:d.length}),l.jsx(mn,{className:m("h-4 w-4 transition-transform",p&&"rotate-180")})]})]})}),l.jsx(Qh,{children:l.jsx("div",{className:m("grid grid-cols-2 gap-1.5 mt-1.5"),children:d.map(u=>l.jsx(s_,{element:u,onAddElement:o,isDisabled:u.type==="pages"&&s,disabledReason:"Only one wizard can be added per form",wizardExists:a},u.type))})})]})},cm=({searchQuery:e,elements:t})=>t.some(o=>o.label.toLowerCase().includes(e.toLowerCase())||o.description.toLowerCase().includes(e.toLowerCase())||o.searchKeywords&&o.searchKeywords.some(n=>n.toLowerCase().includes(e.toLowerCase())))?null:l.jsxs("div",{className:m("text-center py-8 text-muted-foreground text-sm"),children:[l.jsx("div",{className:m("text-3xl mb-2"),children:"🔍"}),l.jsxs("p",{children:['No elements found for "',e,'"']}),l.jsx("p",{className:m("text-xs mt-1 text-muted-foreground/70"),children:"Try a different search term"})]}),a_=({sidebarTabs:e=[]})=>{const[t,r]=P.useState("fields"),[o,n]=P.useState(""),s=te(A=>A.addElement),a=te(A=>A.hasWizard),i=te(A=>A.schema),c=te(A=>A.mode),d=te(A=>A.loadSchema),p=te(A=>A.exportSchema),u=te(A=>A.resetForm),f=te(A=>A.updateFormTitle),h=te(A=>A.updateFormDescription),g=te(A=>A.updateElement),y=te(A=>A.deleteElement),b=te(A=>A.selectElement),v=te(A=>A.setMode),N=A=>{x&&A!=="pages"||s(A)},x=a(),w=P.useMemo(()=>{const A=ut.getGroups(),I=A.filter(L=>L.elements.some(F=>F.category==="field")),T=A.filter(L=>L.elements.some(F=>F.category==="page"));return{fieldGroups:I,pageGroups:T}},[]),C=P.useMemo(()=>ut.getByCategory("field"),[]),E=P.useMemo(()=>ut.getByCategory("page"),[]),k=["textInput","selection","heading","layout","special"],_=P.useMemo(()=>({schema:i,mode:c,actions:{addElement:s,loadSchema:d,exportSchema:p,resetForm:u,updateFormTitle:f,updateFormDescription:h,updateElement:g,deleteElement:y,selectElement:b,setMode:v}}),[i,c,s,d,p,u,f,h,g,y,b,v]),D=P.useMemo(()=>e.length?[...e].filter(A=>!lm(A,_)).sort((A,I)=>(A.order??99)-(I.order??99)):[],[e,_]);return l.jsxs("div",{className:m("w-72 bg-muted/50 border-r border-border flex flex-col h-full flex-shrink-0"),children:[x&&l.jsx("div",{className:m("p-2 bg-orange-50 border-b border-orange-200"),children:l.jsxs("div",{className:m("flex items-start gap-2 text-xs text-orange-700"),children:[l.jsx("span",{className:m("text-base"),children:"📑"}),l.jsxs("div",{children:[l.jsx("p",{className:m("font-medium"),children:"Wizard Mode Active"}),l.jsx("p",{className:m("text-orange-600"),children:"Drop elements inside wizard steps, not on the main canvas."})]})]})}),l.jsx("div",{className:m("p-3 border-b border-border bg-card"),children:l.jsxs("div",{className:m("relative"),children:[l.jsx(yE,{className:m("absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground")}),l.jsx(ar,{type:"text",placeholder:"Search elements...",value:o,onChange:A=>n(A.target.value),className:m("pl-9 pr-8")}),o&&l.jsx(Je,{variant:"ghost",size:"icon",className:m("absolute right-1 top-1/2 -translate-y-1/2 h-6 w-6"),onClick:()=>n(""),children:l.jsx(Wn,{className:m("h-4 w-4")})})]})}),l.jsxs(zh,{value:t,onValueChange:r,className:m("flex-1 flex flex-col min-h-0 overflow-hidden"),children:[l.jsx(Fc,{"aria-disabled":!0,children:l.jsxs(Dc,{className:m("w-full rounded-none border-b border-border bg-card h-auto p-0 flex-shrink-0"),children:[l.jsxs(Yn,{value:"fields",className:m("flex-1 rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-primary/5 py-2.5"),children:["Fields (",C.length,")"]}),l.jsxs(Yn,{value:"pages",className:m("flex-1 rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-primary/5 py-2.5"),children:["Page (",E.length,")"]}),D.map(A=>{const I=A.icon;return l.jsxs(Yn,{value:A.id,className:m("flex-1 rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-primary/5 py-2.5"),disabled:am(A,_),children:[I&&l.jsx(I,{className:m("h-3.5 w-3.5 mr-1")}),A.label]},A.id)})]})}),l.jsxs("div",{className:m("flex-1 min-h-0 relative"),children:[l.jsx(Qn,{value:"fields",className:m("absolute inset-0 mt-0 data-[state=inactive]:hidden overflow-auto"),children:l.jsxs("div",{className:m("p-3"),children:[w.fieldGroups.map(A=>l.jsx(im,{label:A.label,elements:A.elements.filter(I=>I.category==="field"),searchQuery:o,onAddElement:N,defaultExpanded:k.includes(A.id),wizardExists:x},A.id)),o&&l.jsx(cm,{searchQuery:o,elements:C})]})}),l.jsx(Qn,{value:"pages",className:m("absolute inset-0 mt-0 data-[state=inactive]:hidden overflow-auto"),children:l.jsxs("div",{className:m("p-3"),children:[w.pageGroups.map(A=>l.jsx(im,{label:A.label,elements:A.elements.filter(I=>I.category==="page"),searchQuery:o,onAddElement:N,defaultExpanded:k.includes(A.id),hasWizard:x,wizardExists:x},A.id)),o&&l.jsx(cm,{searchQuery:o,elements:E})]})}),D.map(A=>{const I=A.content;return l.jsx(Qn,{value:A.id,className:m("absolute inset-0 mt-0 data-[state=inactive]:hidden overflow-auto"),children:l.jsx(I,{..._})},A.id)})]})]})]})},l_=["shortText","longText","multiLineInput","textEditor","number","slider","rangeSlider","email","phone","url","location","password","signature","captcha","singleChoice","multipleChoice","dropdown","tags","decisionBox","toggleSwitch","singleChoiceMatrix","multipleChoiceMatrix","matrixTable","date","time","dateTime","multipleDates","dateRange","fileUpload","imageUpload","multiFileUpload","multiImageUpload","paragraph","image","link","formHeading","sectionHeading","subheading","divider","spacer","group","grid","table","repeatElement","repeatGroup","pages","submit"];function i_(e){const t=[];if(!e||typeof e!="object")return t.push({type:"error",message:"Schema must be a valid object"}),{valid:!1,errors:t};const r=e;if((!r.id||typeof r.id!="string")&&t.push({type:"error",message:'Schema must have a valid "id" field (string)'}),(!r.version||typeof r.version!="string")&&t.push({type:"error",message:'Schema must have a valid "version" field (string)'}),(!r.title||typeof r.title!="string")&&t.push({type:"error",message:'Schema must have a valid "title" field (string)'}),!Array.isArray(r.elements))return t.push({type:"error",message:'Schema must have an "elements" array'}),{valid:!1,errors:t};const o=new Set,n=new Map;r.elements.forEach((i,c)=>{const d=c_(i,c,o,n);t.push(...d)}),n.forEach((i,c)=>{i.length>1&&t.push({type:"error",message:`Duplicate field name "${c}" found in elements: ${i.join(", ")}`})});const s=new Set(o);return r.elements.forEach(i=>{if(i&&i.logic){const c=u_(i,s);t.push(...c)}}),r.elements.length===0&&t.push({type:"warning",message:"Schema has no elements"}),!r.elements.some(i=>i&&i.type==="submit")&&r.elements.length>0&&t.push({type:"warning",message:"Schema has no submit button"}),{valid:t.filter(i=>i.type==="error").length===0,errors:t}}function c_(e,t,r,o){const n=[],s=`Element at index ${t}`;if(!e||typeof e!="object")return n.push({type:"error",message:`${s}: Must be a valid object`}),n;const a=e;if(!a.id||typeof a.id!="string"?n.push({type:"error",message:`${s}: Must have a valid "id" field (string)`}):(r.has(a.id)&&n.push({type:"error",message:`${s}: Duplicate element ID "${a.id}"`}),r.add(a.id)),!a.type||typeof a.type!="string"?n.push({type:"error",message:`${s}: Must have a valid "type" field (string)`}):l_.includes(a.type)||n.push({type:"error",message:`${s}: Invalid element type "${a.type}"`}),typeof a.order!="number"&&n.push({type:"warning",elementId:a.id,message:`${s}: Missing or invalid "order" field`}),(!a.properties||typeof a.properties!="object")&&n.push({type:"warning",elementId:a.id,message:`${s}: Missing "properties" object`}),(!a.layout||typeof a.layout!="object")&&n.push({type:"warning",elementId:a.id,message:`${s}: Missing "layout" object`}),!a.attributes||typeof a.attributes!="object")n.push({type:"warning",elementId:a.id,message:`${s}: Missing "attributes" object`});else{const c=a.attributes;if(!c.name||typeof c.name!="string")n.push({type:"error",elementId:a.id,message:`${s}: Missing or invalid "attributes.name" field`});else{const d=o.get(c.name)||[];d.push(a.id),o.set(c.name,d)}}const i=d_(a);return n.push(...i),n}function d_(e){const t=[],r=e.type,o=e.config,n=e.id;return["singleChoice","multipleChoice","dropdown","tags"].includes(r)&&(!(o!=null&&o.options)||!Array.isArray(o.options)?t.push({type:"warning",elementId:n,message:`${r} element should have config.options array`}):o.options.length===0?t.push({type:"warning",elementId:n,message:`${r} element has no options defined`}):o.options.forEach((i,c)=>{if(!i||typeof i!="object")t.push({type:"error",elementId:n,message:`${r} option at index ${c} is invalid`});else{const d=i;(typeof d.label!="string"||typeof d.value!="string")&&t.push({type:"warning",elementId:n,message:`${r} option at index ${c} should have label and value strings`})}})),["singleChoiceMatrix","multipleChoiceMatrix","matrixTable"].includes(r)&&((!(o!=null&&o.matrixRows)||!Array.isArray(o.matrixRows))&&t.push({type:"warning",elementId:n,message:`${r} element should have config.matrixRows array`}),(!(o!=null&&o.matrixColumns)||!Array.isArray(o.matrixColumns))&&t.push({type:"warning",elementId:n,message:`${r} element should have config.matrixColumns array`})),r==="pages"&&(!(o!=null&&o.pagesList)||!Array.isArray(o.pagesList))&&t.push({type:"warning",elementId:n,message:"pages element should have config.pagesList array"}),(r==="slider"||r==="rangeSlider")&&o&&typeof o.min=="number"&&typeof o.max=="number"&&o.min>=o.max&&t.push({type:"error",elementId:n,message:`${r} min value must be less than max value`}),t}function u_(e,t){var s,a,i,c;const r=[],o=e.logic;if(!o)return r;const n=(d,p)=>{d&&d.forEach((u,f)=>{u.field?t.has(u.field)||r.push({type:"warning",elementId:e.id,message:`${p} rule ${f+1}: References unknown field "${u.field}"`}):r.push({type:"warning",elementId:e.id,message:`${p} rule ${f+1}: Missing field reference`}),u.operator||r.push({type:"warning",elementId:e.id,message:`${p} rule ${f+1}: Missing operator`})})};return(s=o.showWhen)!=null&&s.rules&&n(o.showWhen.rules,"showWhen"),(a=o.hideWhen)!=null&&a.rules&&n(o.hideWhen.rules,"hideWhen"),(i=o.requireWhen)!=null&&i.rules&&n(o.requireWhen.rules,"requireWhen"),(c=o.disableWhen)!=null&&c.rules&&n(o.disableWhen.rules,"disableWhen"),r}function f_(e){let t;try{t=JSON.parse(e)}catch(o){return{schema:null,validation:{valid:!1,errors:[{type:"error",message:`Invalid JSON: ${o.message}`}]}}}const r=i_(t);return{schema:r.valid?t:null,validation:r}}function p_(e){var r;const t=JSON.parse(JSON.stringify(e));return t.id||(t.id=((r=crypto.randomUUID)==null?void 0:r.call(crypto))||`form_${Date.now()}`),t.version||(t.version="1.0"),t.title||(t.title="Untitled Form"),Array.isArray(t.elements)||(t.elements=[]),t.metadata||(t.metadata={createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}),t.elements=t.elements.map((o,n)=>{var s;return o.id||(o.id=((s=crypto.randomUUID)==null?void 0:s.call(crypto))||`element_${Date.now()}_${n}`),typeof o.order!="number"&&(o.order=n),o.properties||(o.properties={}),o.layout||(o.layout={}),o.attributes||(o.attributes={name:`field_${n}`}),o.attributes.name||(o.attributes.name=`field_${n}`),o}),t.elements.forEach((o,n)=>{o.order=n}),t}function h_(e){if(e.valid&&e.errors.length===0)return"Schema is valid.";const t=e.errors.filter(n=>n.type==="error").length,r=e.errors.filter(n=>n.type==="warning").length;let o="";return t>0&&(o+=`${t} error${t!==1?"s":""}`),r>0&&(o&&(o+=", "),o+=`${r} warning${r!==1?"s":""}`),o}function dm(e){return{order:0,variant:"ghost",disabled:!1,hidden:!1,...e}}function m_(e){return e.map((t,r)=>dm({...t,order:t.order??r}))}function um(e,t){return typeof e.disabled=="function"?e.disabled(t):e.disabled??!1}function Vc(e,t){return typeof e.hidden=="function"?e.hidden(t):e.hidden??!1}class g_{constructor(){ni(this,"modes",new Map)}register(t){if(!t.id)throw new Error("Mode definition must have an id");if(!t.label)throw new Error(`Mode "${t.id}" must have a label`);if(!t.icon)throw new Error(`Mode "${t.id}" must have an icon`);if(!t.renderContent)throw new Error(`Mode "${t.id}" must have a renderContent function`);if(this.modes.has(t.id)){console.warn(`Mode "${t.id}" is already registered. Use modeRegistry.unregister("${t.id}") first or manage registration order.`);return}this.modes.set(t.id,t)}get(t){return this.modes.get(t)}has(t){return this.modes.has(t)}getAll(){return Array.from(this.modes.values()).sort((t,r)=>(t.order??50)-(r.order??50))}getVisible(){return this.getAll().filter(t=>!t.hidden)}unregister(t){return this.modes.delete(t)}clear(){this.modes.clear()}}const Kt=new g_;function b_(e){Kt.register(e)}function y_(e){for(const t of e)Kt.register(t)}function v_(e){return Kt.unregister(e)}function x_(e){return Kt.get(e)}function w_(e){return Kt.has(e)}const Bo=({action:e,context:t})=>{const r=e.icon,o=um(e,t),n=async()=>{o||await e.onClick(t)},s=m(e.variant==="destructive"?"text-destructive hover:text-destructive hover:bg-destructive/10":"");return l.jsxs(Or,{children:[l.jsx(Mr,{asChild:!0,children:l.jsx(Je,{variant:"ghost",size:"icon",onClick:n,disabled:o,className:s,children:l.jsx(r,{className:m("h-5 w-5")})})}),l.jsx(xr,{children:l.jsx("p",{children:e.label})})]})},S_=({schema:e,canUndo:t,canRedo:r,onUndo:o,onRedo:n,onExport:s,exportSchema:a,onImport:i,onReset:c,mode:d,onModeChange:p,toolbarConfig:u})=>{const f=P.useRef(null),h=P.useMemo(()=>({schema:e,mode:d,canUndo:t,canRedo:r,actions:{undo:o,redo:n,loadSchema:i,exportSchema:a,setMode:p,resetForm:c}}),[e,d,t,r,o,n,i,a,p,c]),g=()=>{var E;(E=f.current)==null||E.click()},y=E=>{var _;const k=(_=E.target.files)==null?void 0:_[0];if(k){const D=new FileReader;D.onload=A=>{var I;try{const T=(I=A.target)==null?void 0:I.result,{schema:L,validation:F}=f_(T);if(!F.valid){const G=h_(F),z=F.errors.filter(V=>V.type==="error").slice(0,5).map(V=>`• ${V.message}`).join(`
172
- `);if(window.confirm(`Schema validation failed (${G}):
176
+ */const Hn=Dt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),$s=jN,Ps=QN,jn=C.forwardRef(({className:e,children:t,...r},o)=>i.jsxs(Jp,{ref:o,className:m("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...r,children:[t,i.jsx(KN,{asChild:!0,children:i.jsx(vn,{className:m("h-4 w-4 opacity-50")})})]}));jn.displayName=Jp.displayName;const xh=C.forwardRef(({className:e,...t},r)=>i.jsx(lh,{ref:r,className:m("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(gh,{className:m("h-4 w-4")})}));xh.displayName=lh.displayName;const Ch=C.forwardRef(({className:e,...t},r)=>i.jsx(ch,{ref:r,className:m("flex cursor-default items-center justify-center py-1",e),...t,children:i.jsx(vn,{className:m("h-4 w-4")})}));Ch.displayName=ch.displayName;const qn=C.forwardRef(({className:e,children:t,position:r="popper",...o},n)=>i.jsx(ZN,{children:i.jsxs(Zp,{ref:n,className:m("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...o,children:[i.jsx(xh,{}),i.jsx(a1,{className:m("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),i.jsx(Ch,{})]})}));qn.displayName=Zp.displayName;const T1=C.forwardRef(({className:e,...t},r)=>i.jsx(oh,{ref:r,className:m("px-2 py-1.5 text-sm font-semibold",e),...t}));T1.displayName=oh.displayName;const Uo=C.forwardRef(({className:e,children:t,...r},o)=>i.jsxs(ah,{ref:o,className:m("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[i.jsx("span",{className:m("absolute right-2 flex h-3.5 w-3.5 items-center justify-center"),children:i.jsx(f1,{children:i.jsx(bh,{className:m("h-4 w-4")})})}),i.jsx(d1,{children:t})]}));Uo.displayName=ah.displayName;const D1=C.forwardRef(({className:e,...t},r)=>i.jsx(uh,{ref:r,className:m("-mx-1 my-1 h-px bg-muted",e),...t}));D1.displayName=uh.displayName;const Wo=[{code:"US",name:"United States",dialCode:"+1",flag:"🇺🇸"},{code:"GB",name:"United Kingdom",dialCode:"+44",flag:"🇬🇧"},{code:"CA",name:"Canada",dialCode:"+1",flag:"🇨🇦"},{code:"AU",name:"Australia",dialCode:"+61",flag:"🇦🇺"},{code:"DE",name:"Germany",dialCode:"+49",flag:"🇩🇪"},{code:"FR",name:"France",dialCode:"+33",flag:"🇫🇷"},{code:"IT",name:"Italy",dialCode:"+39",flag:"🇮🇹"},{code:"ES",name:"Spain",dialCode:"+34",flag:"🇪🇸"},{code:"NL",name:"Netherlands",dialCode:"+31",flag:"🇳🇱"},{code:"BE",name:"Belgium",dialCode:"+32",flag:"🇧🇪"},{code:"CH",name:"Switzerland",dialCode:"+41",flag:"🇨🇭"},{code:"AT",name:"Austria",dialCode:"+43",flag:"🇦🇹"},{code:"SE",name:"Sweden",dialCode:"+46",flag:"🇸🇪"},{code:"NO",name:"Norway",dialCode:"+47",flag:"🇳🇴"},{code:"DK",name:"Denmark",dialCode:"+45",flag:"🇩🇰"},{code:"FI",name:"Finland",dialCode:"+358",flag:"🇫🇮"},{code:"IE",name:"Ireland",dialCode:"+353",flag:"🇮🇪"},{code:"PT",name:"Portugal",dialCode:"+351",flag:"🇵🇹"},{code:"GR",name:"Greece",dialCode:"+30",flag:"🇬🇷"},{code:"PL",name:"Poland",dialCode:"+48",flag:"🇵🇱"},{code:"CZ",name:"Czech Republic",dialCode:"+420",flag:"🇨🇿"},{code:"HU",name:"Hungary",dialCode:"+36",flag:"🇭🇺"},{code:"RO",name:"Romania",dialCode:"+40",flag:"🇷🇴"},{code:"BG",name:"Bulgaria",dialCode:"+359",flag:"🇧🇬"},{code:"HR",name:"Croatia",dialCode:"+385",flag:"🇭🇷"},{code:"SK",name:"Slovakia",dialCode:"+421",flag:"🇸🇰"},{code:"SI",name:"Slovenia",dialCode:"+386",flag:"🇸🇮"},{code:"RS",name:"Serbia",dialCode:"+381",flag:"🇷🇸"},{code:"UA",name:"Ukraine",dialCode:"+380",flag:"🇺🇦"},{code:"RU",name:"Russia",dialCode:"+7",flag:"🇷🇺"},{code:"TR",name:"Turkey",dialCode:"+90",flag:"🇹🇷"},{code:"IL",name:"Israel",dialCode:"+972",flag:"🇮🇱"},{code:"SA",name:"Saudi Arabia",dialCode:"+966",flag:"🇸🇦"},{code:"AE",name:"United Arab Emirates",dialCode:"+971",flag:"🇦🇪"},{code:"QA",name:"Qatar",dialCode:"+974",flag:"🇶🇦"},{code:"KW",name:"Kuwait",dialCode:"+965",flag:"🇰🇼"},{code:"BH",name:"Bahrain",dialCode:"+973",flag:"🇧🇭"},{code:"OM",name:"Oman",dialCode:"+968",flag:"🇴🇲"},{code:"EG",name:"Egypt",dialCode:"+20",flag:"🇪🇬"},{code:"MA",name:"Morocco",dialCode:"+212",flag:"🇲🇦"},{code:"ZA",name:"South Africa",dialCode:"+27",flag:"🇿🇦"},{code:"NG",name:"Nigeria",dialCode:"+234",flag:"🇳🇬"},{code:"KE",name:"Kenya",dialCode:"+254",flag:"🇰🇪"},{code:"GH",name:"Ghana",dialCode:"+233",flag:"🇬🇭"},{code:"IN",name:"India",dialCode:"+91",flag:"🇮🇳"},{code:"PK",name:"Pakistan",dialCode:"+92",flag:"🇵🇰"},{code:"BD",name:"Bangladesh",dialCode:"+880",flag:"🇧🇩"},{code:"CN",name:"China",dialCode:"+86",flag:"🇨🇳"},{code:"JP",name:"Japan",dialCode:"+81",flag:"🇯🇵"},{code:"KR",name:"South Korea",dialCode:"+82",flag:"🇰🇷"},{code:"TW",name:"Taiwan",dialCode:"+886",flag:"🇹🇼"},{code:"HK",name:"Hong Kong",dialCode:"+852",flag:"🇭🇰"},{code:"SG",name:"Singapore",dialCode:"+65",flag:"🇸🇬"},{code:"MY",name:"Malaysia",dialCode:"+60",flag:"🇲🇾"},{code:"TH",name:"Thailand",dialCode:"+66",flag:"🇹🇭"},{code:"VN",name:"Vietnam",dialCode:"+84",flag:"🇻🇳"},{code:"ID",name:"Indonesia",dialCode:"+62",flag:"🇮🇩"},{code:"PH",name:"Philippines",dialCode:"+63",flag:"🇵🇭"},{code:"NZ",name:"New Zealand",dialCode:"+64",flag:"🇳🇿"},{code:"MX",name:"Mexico",dialCode:"+52",flag:"🇲🇽"},{code:"BR",name:"Brazil",dialCode:"+55",flag:"🇧🇷"},{code:"AR",name:"Argentina",dialCode:"+54",flag:"🇦🇷"},{code:"CL",name:"Chile",dialCode:"+56",flag:"🇨🇱"},{code:"CO",name:"Colombia",dialCode:"+57",flag:"🇨🇴"},{code:"PE",name:"Peru",dialCode:"+51",flag:"🇵🇪"},{code:"VE",name:"Venezuela",dialCode:"+58",flag:"🇻🇪"},{code:"EC",name:"Ecuador",dialCode:"+593",flag:"🇪🇨"},{code:"UY",name:"Uruguay",dialCode:"+598",flag:"🇺🇾"},{code:"PY",name:"Paraguay",dialCode:"+595",flag:"🇵🇾"},{code:"BO",name:"Bolivia",dialCode:"+591",flag:"🇧🇴"},{code:"CR",name:"Costa Rica",dialCode:"+506",flag:"🇨🇷"},{code:"PA",name:"Panama",dialCode:"+507",flag:"🇵🇦"},{code:"DO",name:"Dominican Republic",dialCode:"+1",flag:"🇩🇴"},{code:"PR",name:"Puerto Rico",dialCode:"+1",flag:"🇵🇷"},{code:"JM",name:"Jamaica",dialCode:"+1",flag:"🇯🇲"},{code:"TT",name:"Trinidad and Tobago",dialCode:"+1",flag:"🇹🇹"},{code:"IS",name:"Iceland",dialCode:"+354",flag:"🇮🇸"},{code:"LU",name:"Luxembourg",dialCode:"+352",flag:"🇱🇺"},{code:"MT",name:"Malta",dialCode:"+356",flag:"🇲🇹"},{code:"CY",name:"Cyprus",dialCode:"+357",flag:"🇨🇾"},{code:"EE",name:"Estonia",dialCode:"+372",flag:"🇪🇪"},{code:"LV",name:"Latvia",dialCode:"+371",flag:"🇱🇻"},{code:"LT",name:"Lithuania",dialCode:"+370",flag:"🇱🇹"}],$1=[...Wo].sort((e,t)=>e.name.localeCompare(t.name)),Yn=e=>Wo.find(t=>t.code===e),P1=(e,t="US")=>{const r=Yn(t)||Wo[0];if(!e)return{countryCode:r.code,dialCode:r.dialCode,number:""};if(e.startsWith("+")){for(const o of Wo)if(e.startsWith(o.dialCode))return{countryCode:o.code,dialCode:o.dialCode,number:e.slice(o.dialCode.length).trim()}}return{countryCode:r.code,dialCode:r.dialCode,number:e.replace(/^\+/,"")}},M1=({value:e,onChange:t,onBlur:r,defaultCountry:o="US",disabled:n=!1,placeholder:a="Phone number",hasError:s=!1,className:l,inputClassName:c})=>{const d=P.useMemo(()=>{if(!e){const S=Yn(o)||Wo[0];return{countryCode:S.code,dialCode:S.dialCode,number:""}}return typeof e=="string"?P1(e,o):e},[e,o]),[p,u]=P.useState(d.countryCode),[f,h]=P.useState(d.number),b=P.useRef(null);P.useEffect(()=>{u(d.countryCode),h(d.number)},[d.countryCode,d.number]);const g=P.useMemo(()=>Yn(p)||Wo[0],[p]),y=S=>{const x=Yn(S);if(x){u(S);const w={countryCode:x.code,dialCode:x.dialCode,number:f};t==null||t(w)}},v=S=>{const x=S.target.value.replace(/[^\d\s\-()]/g,"");h(x),t==null||t({countryCode:g.code,dialCode:g.dialCode,number:x})};return i.jsxs("div",{className:m("flex",l),children:[i.jsxs($s,{value:p,onValueChange:y,disabled:n,children:[i.jsx(jn,{className:m("w-[110px] rounded-r-none border-r-0 focus:z-10",s&&"border-red-500",n&&"opacity-50 cursor-not-allowed"),children:i.jsx(Ps,{children:i.jsxs("span",{className:m("flex items-center gap-1.5"),children:[i.jsx("span",{className:m("text-base"),children:g.flag}),i.jsx("span",{className:m("text-sm text-muted-foreground"),children:g.dialCode})]})})}),i.jsx(qn,{className:m("max-h-[300px]"),children:$1.map(S=>i.jsx(Uo,{value:S.code,className:m("cursor-pointer"),children:i.jsxs("span",{className:m("flex items-center gap-2"),children:[i.jsx("span",{className:m("text-base"),children:S.flag}),i.jsx("span",{className:m("flex-1"),children:S.name}),i.jsx("span",{className:m("text-muted-foreground text-sm"),children:S.dialCode})]})},S.code))})]}),i.jsx("input",{ref:b,type:"tel",value:f,onChange:v,onBlur:r,disabled:n,placeholder:a,className:m("flex-1 h-9 rounded-l-none rounded-r-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm transition-colors","placeholder:text-muted-foreground","focus:outline-none focus:ring-1 focus:ring-ring","disabled:cursor-not-allowed disabled:opacity-50",s&&"border-red-500 focus:ring-red-500",c)})]})},O1=({defaultCountry:e="US",placeholder:t="Phone number",className:r})=>{const o=Yn(e)||Wo[0];return i.jsxs("div",{className:m("flex",r),children:[i.jsxs("div",{className:m("flex items-center gap-1.5 h-9 px-3 rounded-l-md border border-r-0 border-input bg-muted/50 text-sm"),children:[i.jsx("span",{className:m("text-base"),children:o.flag}),i.jsx("span",{className:m("text-muted-foreground"),children:o.dialCode}),i.jsx("svg",{className:m("h-4 w-4 opacity-50"),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"m6 9 6 6 6-6"})})]}),i.jsx("input",{type:"tel",placeholder:t,disabled:!0,className:m("flex-1 h-9 rounded-l-none rounded-r-md border border-input bg-muted/50 px-3 py-2 text-sm","placeholder:text-muted-foreground","disabled:cursor-not-allowed disabled:opacity-50")})]})},I1=[{type:"email",structure:"field",typeCategory:"Contact",label:"Email",description:"Email address input",icon:"✉️",category:"field",subCategory:"contact",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!1,showSuffix:!1},fields:[]},getDefaultValues:()=>({properties:{label:"Email",placeholder:"email@example.com"},layout:{labelPosition:"top",size:"full"},validation:{}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,children:i.jsx(Io,{icon:"✉️",children:i.jsx("input",{type:"email",placeholder:o||"email@example.com",disabled:!0,className:m(`${Ot()} pl-10`)})})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,value:s,onChange:l,errors:c,isDisabled:d}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,errors:c,children:i.jsx(Io,{icon:"✉️",children:i.jsx("input",{type:"email",placeholder:o||"email@example.com",value:s??"",onChange:p=>l==null?void 0:l(p.target.value),disabled:d,className:m(`${qt({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})} pl-10`)})})})}},{type:"phone",structure:"field",typeCategory:"Contact",label:"Phone",description:"Phone number input with country code",icon:"📱",category:"field",subCategory:"contact",dataType:"object",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!1,showSuffix:!1},configSection:{title:"Phone Settings",icon:"📱"},fields:[{key:"defaultCountry",label:"Default Country",type:"select",section:"config",options:[{value:"US",label:"🇺🇸 United States (+1)"},{value:"GB",label:"🇬🇧 United Kingdom (+44)"},{value:"CA",label:"🇨🇦 Canada (+1)"},{value:"AU",label:"🇦🇺 Australia (+61)"},{value:"DE",label:"🇩🇪 Germany (+49)"},{value:"FR",label:"🇫🇷 France (+33)"},{value:"IT",label:"🇮🇹 Italy (+39)"},{value:"ES",label:"🇪🇸 Spain (+34)"},{value:"NL",label:"🇳🇱 Netherlands (+31)"},{value:"BE",label:"🇧🇪 Belgium (+32)"},{value:"CH",label:"🇨🇭 Switzerland (+41)"},{value:"AT",label:"🇦🇹 Austria (+43)"},{value:"SE",label:"🇸🇪 Sweden (+46)"},{value:"NO",label:"🇳🇴 Norway (+47)"},{value:"DK",label:"🇩🇰 Denmark (+45)"},{value:"FI",label:"🇫🇮 Finland (+358)"},{value:"IE",label:"🇮🇪 Ireland (+353)"},{value:"PT",label:"🇵🇹 Portugal (+351)"},{value:"PL",label:"🇵🇱 Poland (+48)"},{value:"TR",label:"🇹🇷 Turkey (+90)"},{value:"IN",label:"🇮🇳 India (+91)"},{value:"JP",label:"🇯🇵 Japan (+81)"},{value:"KR",label:"🇰🇷 South Korea (+82)"},{value:"BR",label:"🇧🇷 Brazil (+55)"},{value:"MX",label:"🇲🇽 Mexico (+52)"}]},{key:"format",label:"Number Format",type:"select",section:"config",options:[{value:"international",label:"International (+1 555 123 4567)"},{value:"national",label:"National ((555) 123-4567)"}]}]},getDefaultValues:()=>({properties:{label:"Phone",placeholder:"Phone number"},layout:{labelPosition:"top",size:"full"},config:{defaultCountry:"US",format:"international"}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,config:s}=oe(e),l=(s==null?void 0:s.defaultCountry)||"US";return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,children:i.jsx(O1,{defaultCountry:l,placeholder:o||"Phone number"})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,value:s,onChange:l,errors:c,isDisabled:d,config:p}=oe(e),u=(p==null?void 0:p.defaultCountry)||"US",f=h=>{l==null||l(h)};return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,errors:c,children:i.jsx(M1,{value:s,onChange:f,defaultCountry:u,disabled:d,placeholder:o||"Phone number",hasError:((c==null?void 0:c.length)??0)>0})})}},{type:"url",structure:"field",typeCategory:"Contact",label:"URL",description:"Website URL input",icon:"🔗",category:"field",subCategory:"contact",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!1,showSuffix:!1},fields:[]},getDefaultValues:()=>({properties:{label:"Website",placeholder:"https://example.com"},layout:{labelPosition:"top",size:"full"}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,children:i.jsx(Io,{icon:"🔗",children:i.jsx("input",{type:"url",placeholder:o||"https://example.com",disabled:!0,className:m(`${Ot()} pl-10`)})})})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,value:s,onChange:l,errors:c,isDisabled:d}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,errors:c,children:i.jsx(Io,{icon:"🔗",children:i.jsx("input",{type:"url",placeholder:o||"https://example.com",value:s??"",onChange:p=>l==null?void 0:l(p.target.value),disabled:d,className:m(`${qt({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})} pl-10`)})})})}},{type:"location",structure:"field",typeCategory:"Contact",label:"Location",description:"Address/location input",icon:"📍",category:"field",subCategory:"contact",dataType:"object",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!1,showSuffix:!1},configSection:{title:"Location Settings",icon:"📍"},fields:[{key:"enableGeolocation",label:"Enable Geolocation",type:"checkbox",section:"config",description:"Allow auto-detect location"},{key:"showMap",label:"Show Map",type:"checkbox",section:"config",description:"Display map preview"},{key:"mapProvider",label:"Map Provider",type:"select",section:"config",showWhen:{field:"showMap",value:!0},options:[{value:"google",label:"Google Maps"},{value:"openstreetmap",label:"OpenStreetMap"}]}]},getDefaultValues:()=>({properties:{label:"Location",placeholder:"Enter address...",description:"Enter your address"},layout:{labelPosition:"top",size:"full"},config:{enableGeolocation:!1,showMap:!1,mapProvider:"openstreetmap"}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,config:s}=oe(e);return i.jsxs(ge,{label:t,description:r,required:n,labelPosition:a,children:[i.jsx(Io,{icon:"📍",children:i.jsx("input",{type:"text",placeholder:o||"Enter address...",disabled:!0,className:m(`${Ot()} pl-10`)})}),(s==null?void 0:s.showMap)&&i.jsx("div",{className:m("h-32 bg-gray-200 rounded-md flex items-center justify-center text-gray-400 text-sm mt-2"),children:"🗺️ Map Preview"})]})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,value:s,onChange:l,errors:c,isDisabled:d,config:p}=oe(e);return i.jsx(ge,{label:t,description:r,required:n,labelPosition:a,errors:c,children:i.jsxs("div",{className:m("space-y-2"),children:[i.jsx(Io,{icon:"📍",children:i.jsx("input",{type:"text",placeholder:o||"Enter address...",value:typeof s=="string"?s:(s==null?void 0:s.address)??"",onChange:u=>l==null?void 0:l(u.target.value),disabled:d,className:m(`${qt({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})} pl-10`)})}),(p==null?void 0:p.enableGeolocation)&&!d&&i.jsx("button",{type:"button",className:m("text-sm text-blue-600 hover:text-blue-700 flex items-center gap-1"),children:"📍 Use current location"}),(p==null?void 0:p.showMap)&&i.jsx("div",{className:m("h-32 bg-gray-200 rounded-md flex items-center justify-center text-gray-400 text-sm"),children:"🗺️ Map Preview"})]})})}}],L1=[{type:"date",structure:"field",typeCategory:"DateTime",label:"Date",description:"Date picker input",icon:"📅",category:"field",subCategory:"dateTime",dataType:"date",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Date Settings",icon:"📅"},fields:[{key:"format",label:"Display Format",type:"select",section:"config",options:[{value:"YYYY-MM-DD",label:"YYYY-MM-DD (2025-01-15)"},{value:"DD/MM/YYYY",label:"DD/MM/YYYY (15/01/2025)"},{value:"MM/DD/YYYY",label:"MM/DD/YYYY (01/15/2025)"},{value:"MMMM D, YYYY",label:"MMMM D, YYYY (January 15, 2025)"}]},{key:"showCalendar",label:"Show Calendar Picker",type:"checkbox",section:"config",description:"Display a calendar dropdown for date selection"},{key:"minDate",label:"Min Date",type:"text",section:"config",placeholder:"YYYY-MM-DD",description:"Earliest selectable date"},{key:"maxDate",label:"Max Date",type:"text",section:"config",placeholder:"YYYY-MM-DD",description:"Latest selectable date"},{key:"disableWeekends",label:"Disable Weekends",type:"checkbox",section:"config",description:"Prevent selecting Saturday and Sunday"}]},getDefaultValues:()=>({properties:{label:"Date",placeholder:"Select a date"},layout:{labelPosition:"top",size:"full"},config:{format:"YYYY-MM-DD",showCalendar:!0}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n}=oe(e);return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsx("input",{type:"date",disabled:!0,className:Ot()})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c}=oe(e);return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsx("input",{type:"date",value:a??"",onChange:d=>s==null?void 0:s(d.target.value),disabled:c,className:qt({hasError:((l==null?void 0:l.length)??0)>0,disabled:c})})})}},{type:"time",structure:"field",typeCategory:"DateTime",label:"Time",description:"Time picker input",icon:"🕐",category:"field",subCategory:"dateTime",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Time Settings",icon:"⏰"},fields:[{key:"timeFormat",label:"Time Format",type:"select",section:"config",options:[{value:"12h",label:"12-hour (AM / PM)"},{value:"24h",label:"24-hour"}]},{key:"timeInterval",label:"Minute Interval",type:"select",section:"config",description:"Granularity for the time dropdown",options:[{value:5,label:"5 minutes"},{value:10,label:"10 minutes"},{value:15,label:"15 minutes"},{value:30,label:"30 minutes"},{value:60,label:"1 hour"}]},{key:"minTime",label:"Earliest Time",type:"text",section:"config",placeholder:"09:00",description:"Minimum selectable time",colSpan:1},{key:"maxTime",label:"Latest Time",type:"text",section:"config",placeholder:"17:00",description:"Maximum selectable time",colSpan:1},{key:"showNowButton",label:'Show "Now" Button',type:"checkbox",section:"config",description:"Quick-fill with the current time"}]},getDefaultValues:()=>({properties:{label:"Time",placeholder:"Select a time"},layout:{labelPosition:"top",size:"full"},config:{timeFormat:"24h",timeInterval:15}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n}=oe(e);return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsx("input",{type:"time",disabled:!0,className:Ot()})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c}=oe(e);return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsx("input",{type:"time",value:a??"",onChange:d=>s==null?void 0:s(d.target.value),disabled:c,className:qt({hasError:((l==null?void 0:l.length)??0)>0,disabled:c})})})}},{type:"dateTime",structure:"field",typeCategory:"DateTime",label:"Date & Time",description:"Combined date and time picker",icon:"📆",category:"field",subCategory:"dateTime",dataType:"date",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Date & Time Settings",icon:"📅"},fields:[{key:"format",label:"Date Format",type:"select",section:"config",options:[{value:"YYYY-MM-DD",label:"YYYY-MM-DD"},{value:"DD/MM/YYYY",label:"DD/MM/YYYY"},{value:"MM/DD/YYYY",label:"MM/DD/YYYY"},{value:"MMMM D, YYYY",label:"MMMM D, YYYY"}]},{key:"timeFormat",label:"Time Format",type:"select",section:"config",options:[{value:"12h",label:"12-hour (AM / PM)"},{value:"24h",label:"24-hour"}]},{key:"timeInterval",label:"Minute Interval",type:"select",section:"config",options:[{value:5,label:"5 minutes"},{value:10,label:"10 minutes"},{value:15,label:"15 minutes"},{value:30,label:"30 minutes"},{value:60,label:"1 hour"}]},{key:"minDate",label:"Min Date",type:"text",section:"config",placeholder:"YYYY-MM-DD",colSpan:1},{key:"maxDate",label:"Max Date",type:"text",section:"config",placeholder:"YYYY-MM-DD",colSpan:1},{key:"showSeconds",label:"Show Seconds",type:"checkbox",section:"config",description:"Include seconds in the time picker"}]},getDefaultValues:()=>({properties:{label:"Date & Time",placeholder:"Select date and time"},layout:{labelPosition:"top",size:"full"},config:{format:"YYYY-MM-DD",timeFormat:"24h",timeInterval:15}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n}=oe(e);return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsxs("div",{className:m("flex gap-2"),children:[i.jsx("input",{type:"date",disabled:!0,className:`flex-1 ${Ot()}`}),i.jsx("input",{type:"time",disabled:!0,className:`w-32 ${Ot()}`})]})})},render:e=>{var b;const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c}=oe(e),d=typeof a=="object"?a==null?void 0:a.date:(a==null?void 0:a.split("T")[0])??"",p=typeof a=="object"?a==null?void 0:a.time:((b=a==null?void 0:a.split("T")[1])==null?void 0:b.substring(0,5))??"",u=g=>{typeof a=="object"?s==null||s({...a,date:g}):s==null||s(`${g}T${p||"00:00"}`)},f=g=>{typeof a=="object"?s==null||s({...a,time:g}):s==null||s(`${d||""}T${g}`)},h=qt({hasError:((l==null?void 0:l.length)??0)>0,disabled:c});return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsxs("div",{className:m("flex gap-2"),children:[i.jsx("input",{type:"date",value:d,onChange:g=>u(g.target.value),disabled:c,className:`flex-1 ${h}`}),i.jsx("input",{type:"time",value:p,onChange:g=>f(g.target.value),disabled:c,className:`w-32 ${h}`})]})})}},{type:"multipleDates",structure:"field",typeCategory:"DateTime",label:"Multiple Dates",description:"Select multiple dates",icon:"📅",category:"field",subCategory:"dateTime",dataType:"array",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Multiple Dates Settings",icon:"📆"},fields:[{key:"format",label:"Display Format",type:"select",section:"config",options:[{value:"YYYY-MM-DD",label:"YYYY-MM-DD"},{value:"DD/MM/YYYY",label:"DD/MM/YYYY"},{value:"MM/DD/YYYY",label:"MM/DD/YYYY"},{value:"MMMM D, YYYY",label:"MMMM D, YYYY"}]},{key:"showCalendar",label:"Show Calendar Picker",type:"checkbox",section:"config",description:"Display a calendar for multi-date selection"},{key:"minDates",label:"Min Dates",type:"number",section:"validation",min:1,placeholder:"1",description:"Minimum number of dates to select",colSpan:1},{key:"maxDates",label:"Max Dates",type:"number",section:"validation",min:1,placeholder:"10",description:"Maximum number of dates allowed",colSpan:1},{key:"allowPastDates",label:"Allow Past Dates",type:"checkbox",section:"config",description:"Let users select dates in the past"},{key:"disableWeekends",label:"Disable Weekends",type:"checkbox",section:"config",description:"Prevent selecting Saturday and Sunday"}]},getDefaultValues:()=>({properties:{label:"Multiple Dates",placeholder:"Add dates",description:"Select one or more dates"},layout:{labelPosition:"top",size:"full"},config:{format:"YYYY-MM-DD",showCalendar:!0}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n}=oe(e);return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsxs("div",{className:m("space-y-2"),children:[i.jsxs("div",{className:m("flex flex-wrap gap-2"),children:[i.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-800 text-sm rounded"),children:["2024-01-15",i.jsx("button",{disabled:!0,className:m("text-blue-600"),children:"×"})]}),i.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-800 text-sm rounded"),children:["2024-01-20",i.jsx("button",{disabled:!0,className:m("text-blue-600"),children:"×"})]})]}),i.jsx("input",{type:"date",disabled:!0,className:Ot()})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c}=oe(e),d=Array.isArray(a)?a:[],p=f=>{f&&!d.includes(f)&&(s==null||s([...d,f]))},u=f=>{s==null||s(d.filter(h=>h!==f))};return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsxs("div",{className:m("space-y-2"),children:[d.length>0&&i.jsx("div",{className:m("flex flex-wrap gap-2"),children:d.map((f,h)=>i.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 bg-blue-100 text-blue-800 text-sm rounded"),children:[f,!c&&i.jsx("button",{type:"button",onClick:()=>u(f),className:m("text-blue-600 hover:text-blue-800"),children:"×"})]},h))}),i.jsx("input",{type:"date",onChange:f=>{p(f.target.value),f.target.value=""},disabled:c,className:qt({hasError:((l==null?void 0:l.length)??0)>0,disabled:c})})]})})}},{type:"dateRange",structure:"field",typeCategory:"DateTime",label:"Date Range",description:"Select a date range",icon:"📆",category:"field",subCategory:"dateTime",dataType:"object",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Date Range Settings",icon:"📊"},fields:[{key:"format",label:"Display Format",type:"select",section:"config",options:[{value:"YYYY-MM-DD",label:"YYYY-MM-DD"},{value:"DD/MM/YYYY",label:"DD/MM/YYYY"},{value:"MM/DD/YYYY",label:"MM/DD/YYYY"},{value:"MMMM D, YYYY",label:"MMMM D, YYYY"}]},{key:"showCalendar",label:"Show Calendar Picker",type:"checkbox",section:"config",description:"Display a calendar range selector"},{key:"minDays",label:"Min Days",type:"number",section:"config",min:1,placeholder:"1",description:"Minimum length of the selected range",colSpan:1},{key:"maxDays",label:"Max Days",type:"number",section:"config",min:1,placeholder:"30",description:"Maximum length of the selected range",colSpan:1},{key:"allowSameDayRange",label:"Allow Same-Day Range",type:"checkbox",section:"config",description:"Start and end date can be the same day"},{key:"disableWeekends",label:"Disable Weekends",type:"checkbox",section:"config",description:"Exclude Saturday and Sunday from selection"},{key:"minDate",label:"Earliest Start Date",type:"text",section:"config",placeholder:"YYYY-MM-DD",description:"First selectable date in the range"},{key:"maxDate",label:"Latest End Date",type:"text",section:"config",placeholder:"YYYY-MM-DD",description:"Last selectable date in the range"}]},getDefaultValues:()=>({properties:{label:"Date Range",placeholder:"Select date range",description:"Select start and end dates"},layout:{labelPosition:"top",size:"full"},config:{format:"YYYY-MM-DD",showCalendar:!0,minDays:1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n}=oe(e);return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsxs("div",{className:m("flex items-center gap-2"),children:[i.jsx("input",{type:"date",disabled:!0,placeholder:"Start date",className:`flex-1 ${Ot()}`}),i.jsx("span",{className:m("text-gray-400"),children:"→"}),i.jsx("input",{type:"date",disabled:!0,placeholder:"End date",className:`flex-1 ${Ot()}`})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c}=oe(e),d=(a==null?void 0:a.start)??"",p=(a==null?void 0:a.end)??"",u=b=>{s==null||s({start:b,end:p})},f=b=>{s==null||s({start:d,end:b})},h=qt({hasError:((l==null?void 0:l.length)??0)>0,disabled:c});return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsxs("div",{className:m("flex items-center gap-2"),children:[i.jsx("input",{type:"date",value:d,onChange:b=>u(b.target.value),disabled:c,placeholder:"Start date",className:`flex-1 ${h}`}),i.jsx("span",{className:m("text-gray-400"),children:"→"}),i.jsx("input",{type:"date",value:p,onChange:b=>f(b.target.value),disabled:c,min:d,placeholder:"End date",className:`flex-1 ${h}`})]})})}}],F1=[{type:"paragraph",structure:"field",typeCategory:"Display",label:"Paragraph",description:"Static text content",icon:"📜",category:"field",subCategory:"display",dataType:"string",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Paragraph",content:"Enter your paragraph text here. This is a static text element that displays information to users."},layout:{labelPosition:"hidden",size:"full"},config:{textAlign:"left",fontSize:"medium",fontWeight:"normal"}}),renderOnCanvas:e=>{const{element:t,config:r}=oe(e),o=t.properties.content||"Enter your paragraph text here.",n={small:"text-sm",medium:"text-base",large:"text-lg"}[(r==null?void 0:r.fontSize)||"medium"],a={normal:"font-normal",medium:"font-medium",bold:"font-bold"}[(r==null?void 0:r.fontWeight)||"normal"];return i.jsx("div",{className:m("prose prose-sm max-w-none"),style:{textAlign:(r==null?void 0:r.textAlign)||"left"},children:i.jsx("p",{className:m("text-gray-700",n,a),children:o})})},render:e=>{const{element:t,config:r}=oe(e),o=t.properties.content||"",n={small:"text-sm",medium:"text-base",large:"text-lg"}[(r==null?void 0:r.fontSize)||"medium"],a={normal:"font-normal",medium:"font-medium",bold:"font-bold"}[(r==null?void 0:r.fontWeight)||"normal"];return i.jsx("div",{className:m("prose prose-sm max-w-none"),style:{textAlign:(r==null?void 0:r.textAlign)||"left"},children:i.jsx("p",{className:m("text-gray-700",n,a),children:o})})}},{type:"image",structure:"field",typeCategory:"Display",label:"Image",description:"Display an image",icon:"🖼️",category:"field",subCategory:"display",dataType:"string",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Image",alt:"Image description",src:""},layout:{labelPosition:"hidden",size:"full"},config:{imageWidth:"100%",objectFit:"contain",borderRadius:0}}),renderOnCanvas:e=>{const{element:t,config:r}=oe(e),o=t.properties.src,n=t.properties.alt||"Image";return o?i.jsx("div",{className:m("space-y-1.5"),children:i.jsx("img",{src:o,alt:n,className:m("max-w-full rounded"),style:{width:(r==null?void 0:r.imageWidth)||"100%",objectFit:(r==null?void 0:r.objectFit)||"contain",borderRadius:(r==null?void 0:r.borderRadius)||0}})}):i.jsxs("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg p-8 text-center bg-gray-50"),children:[i.jsx("span",{className:m("text-4xl"),children:"🏞️"}),i.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"No image selected"}),i.jsx("p",{className:m("text-xs text-gray-400"),children:"Set image URL in properties"})]})},render:e=>{const{element:t,config:r}=oe(e),o=t.properties.src,n=t.properties.alt||"Image";return o?i.jsx("div",{className:m("space-y-1.5"),children:i.jsx("img",{src:o,alt:n,className:m("max-w-full"),style:{width:(r==null?void 0:r.imageWidth)||"100%",objectFit:(r==null?void 0:r.objectFit)||"contain",borderRadius:(r==null?void 0:r.borderRadius)||0}})}):null}},{type:"link",structure:"field",typeCategory:"Display",label:"Link",description:"Clickable link or button",icon:"🔗",category:"field",subCategory:"display",dataType:"string",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Link",href:"https://example.com",content:"Click here",target:"_blank"},layout:{labelPosition:"hidden",size:"full"},config:{linkStyle:"text"}}),renderOnCanvas:e=>{const{element:t,config:r}=oe(e),o=t.properties.content||(r==null?void 0:r.linkText)||"Click here",n=t.properties.href||"https://example.com";return(r==null?void 0:r.linkStyle)==="button"?i.jsxs("div",{className:m("space-y-1"),children:[i.jsx("a",{href:"#",onClick:a=>a.preventDefault(),className:m("inline-block px-4 py-2 bg-blue-600 text-white rounded-md text-sm hover:bg-blue-700"),children:o}),i.jsx("p",{className:m("text-xs text-gray-400"),children:n})]}):i.jsxs("div",{className:m("space-y-1"),children:[i.jsx("a",{href:"#",onClick:a=>a.preventDefault(),className:m("text-blue-600 hover:text-blue-800 underline text-sm"),children:o}),i.jsx("p",{className:m("text-xs text-gray-400"),children:n})]})},render:e=>{const{element:t,config:r}=oe(e),o=t.properties.content||(r==null?void 0:r.linkText)||"Click here",n=t.properties.href||"#",a=t.properties.target||"_blank";return(r==null?void 0:r.linkStyle)==="button"?i.jsx("a",{href:n,target:a,rel:a==="_blank"?"noopener noreferrer":void 0,className:m("inline-block px-4 py-2 bg-blue-600 text-white rounded-md text-sm hover:bg-blue-700 transition-colors"),children:o}):i.jsx("a",{href:n,target:a,rel:a==="_blank"?"noopener noreferrer":void 0,className:m("text-blue-600 hover:text-blue-800 underline text-sm transition-colors"),children:o})}}],V1=[{type:"divider",structure:"page",typeCategory:"Layout",label:"Divider",description:"Horizontal line separator",icon:"➖",category:"page",subCategory:"layout",supportsValidation:!1,getDefaultValues:()=>({properties:{},layout:{size:"full"},config:{style:"solid",thickness:1,color:"rgb(209, 213, 219)"}}),renderOnCanvas:e=>{const{config:t}=oe(e);return i.jsx("hr",{style:{borderStyle:(t==null?void 0:t.style)||"solid",borderWidth:`${(t==null?void 0:t.thickness)||1}px 0 0 0`,borderColor:(t==null?void 0:t.color)||"rgb(209, 213, 219)"}})},render:e=>{const{config:t}=oe(e);return i.jsx("hr",{style:{borderStyle:(t==null?void 0:t.style)||"solid",borderWidth:`${(t==null?void 0:t.thickness)||1}px 0 0 0`,borderColor:(t==null?void 0:t.color)||"rgb(209, 213, 219)"}})}},{type:"spacer",structure:"page",typeCategory:"Layout",label:"Spacer",description:"Vertical spacing element",icon:"↕️",category:"page",subCategory:"layout",supportsValidation:!1,getDefaultValues:()=>({properties:{},layout:{size:"full",height:24},config:{spacerHeight:24}}),renderOnCanvas:e=>{const{config:t}=oe(e),r=(t==null?void 0:t.spacerHeight)||24;return i.jsx("div",{className:m("bg-gray-100/50 border border-dashed border-gray-300 rounded flex items-center justify-center"),style:{height:r},children:i.jsxs("span",{className:m("text-xs text-gray-400"),children:["↕️ Spacer (",r,"px)"]})})},render:e=>{const{config:t}=oe(e),r=(t==null?void 0:t.spacerHeight)||24;return i.jsx("div",{style:{height:r}})}},{type:"formHeading",structure:"page",typeCategory:"Heading",label:"Form Heading",description:"Main form title",icon:"📋",category:"page",subCategory:"heading",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Form Title",description:"Form description goes here"},layout:{size:"full"},config:{level:1,alignment:"left"}}),renderOnCanvas:e=>{const{label:t,description:r,config:o}=oe(e);return i.jsxs("div",{className:m(`text-${(o==null?void 0:o.alignment)||"left"}`),children:[i.jsx("h1",{className:m("text-2xl font-bold text-gray-900"),children:t}),r&&i.jsx("p",{className:m("text-gray-600 mt-1"),children:r})]})},render:e=>{const{label:t,description:r,config:o}=oe(e);return i.jsxs("div",{className:m(`text-${(o==null?void 0:o.alignment)||"left"}`),children:[i.jsx("h1",{className:m("text-2xl font-bold text-gray-900"),children:t}),r&&i.jsx("p",{className:m("text-gray-600 mt-1"),children:r})]})}},{type:"sectionHeading",structure:"page",typeCategory:"Heading",label:"Section Heading",description:"Section title",icon:"📑",category:"page",subCategory:"heading",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Section Title"},layout:{size:"full"},config:{level:2,alignment:"left"}}),renderOnCanvas:e=>{const{label:t,description:r,config:o}=oe(e);return i.jsxs("div",{className:m(`text-${(o==null?void 0:o.alignment)||"left"}`),children:[i.jsx("h2",{className:m("text-xl font-semibold text-gray-800"),children:t}),r&&i.jsx("p",{className:m("text-gray-500 text-sm mt-1"),children:r})]})},render:e=>{const{label:t,description:r,config:o}=oe(e);return i.jsxs("div",{className:m(`text-${(o==null?void 0:o.alignment)||"left"}`),children:[i.jsx("h2",{className:m("text-xl font-semibold text-gray-800"),children:t}),r&&i.jsx("p",{className:m("text-gray-500 text-sm mt-1"),children:r})]})}},{type:"subheading",structure:"page",typeCategory:"Heading",label:"Subheading",description:"Smaller heading",icon:"📝",category:"page",subCategory:"heading",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Subheading"},layout:{size:"full"},config:{level:3,alignment:"left"}}),renderOnCanvas:e=>{const{label:t,description:r,config:o}=oe(e);return i.jsxs("div",{className:m(`text-${(o==null?void 0:o.alignment)||"left"}`),children:[i.jsx("h3",{className:m("text-lg font-medium text-gray-700"),children:t}),r&&i.jsx("p",{className:m("text-gray-500 text-sm mt-0.5"),children:r})]})},render:e=>{const{label:t,description:r,config:o}=oe(e);return i.jsxs("div",{className:m(`text-${(o==null?void 0:o.alignment)||"left"}`),children:[i.jsx("h3",{className:m("text-lg font-medium text-gray-700"),children:t}),r&&i.jsx("p",{className:m("text-gray-500 text-sm mt-0.5"),children:r})]})}},{type:"submit",structure:"page",typeCategory:"Special",label:"Submit Button",description:"Form submission button",icon:"🚀",category:"page",subCategory:"special",supportsValidation:!1,getDefaultValues:()=>({properties:{label:"Submit"},layout:{size:"full"},config:{buttonText:"Submit",buttonStyle:"primary",buttonSize:"medium",showIcon:!1,loadingText:"Submitting..."}}),renderOnCanvas:e=>{const{label:t,config:r}=oe(e),o=(r==null?void 0:r.buttonText)||t||"Submit",n=(r==null?void 0:r.buttonStyle)||"primary",a=(r==null?void 0:r.buttonSize)||"medium",s={primary:"bg-blue-600 text-white hover:bg-blue-700",secondary:"bg-gray-600 text-white hover:bg-gray-700",outline:"border-2 border-blue-600 text-blue-600 bg-transparent hover:bg-blue-50",ghost:"text-blue-600 hover:bg-blue-50"},l={small:"px-4 py-1.5 text-sm",medium:"px-6 py-2.5 text-base",large:"px-8 py-3 text-lg"};return i.jsxs("button",{type:"button",disabled:!0,className:m("rounded-md font-medium transition-colors",s[n],l[a]),children:[(r==null?void 0:r.showIcon)&&(r==null?void 0:r.iconPosition)==="left"&&i.jsx("span",{className:m("mr-2"),children:"🚀"}),o,(r==null?void 0:r.showIcon)&&(r==null?void 0:r.iconPosition)==="right"&&i.jsx("span",{className:m("ml-2"),children:"🚀"})]})},render:e=>{const{label:t,config:r,isDisabled:o}=oe(e),n=(r==null?void 0:r.buttonText)||t||"Submit",a=(r==null?void 0:r.buttonStyle)||"primary",s=(r==null?void 0:r.buttonSize)||"medium",l={primary:"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",secondary:"bg-gray-600 text-white hover:bg-gray-700 focus:ring-gray-500",outline:"border-2 border-blue-600 text-blue-600 bg-transparent hover:bg-blue-50 focus:ring-blue-500",ghost:"text-blue-600 hover:bg-blue-50 focus:ring-blue-500"},c={small:"px-4 py-1.5 text-sm",medium:"px-6 py-2.5 text-base",large:"px-8 py-3 text-lg"};return i.jsxs("button",{type:"submit",disabled:o,className:m("rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2",l[a],c[s],o&&"opacity-50 cursor-not-allowed"),children:[(r==null?void 0:r.showIcon)&&(r==null?void 0:r.iconPosition)==="left"&&i.jsx("span",{className:m("mr-2"),children:"🚀"}),n,(r==null?void 0:r.showIcon)&&(r==null?void 0:r.iconPosition)==="right"&&i.jsx("span",{className:m("ml-2"),children:"🚀"})]})}}],G1=[{type:"singleChoiceMatrix",structure:"field",typeCategory:"Matrix",label:"Single Choice Matrix",description:"Matrix with radio button selections",icon:"📊",category:"field",subCategory:"matrix",dataType:"object",supportsValidation:!0,supportsMatrix:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Matrix Settings",icon:"📊"},fields:[{key:"randomizeRows",label:"Randomize Row Order",type:"checkbox",section:"config",description:"Shuffle rows for each respondent (surveys)"},{key:"randomizeColumns",label:"Randomize Column Order",type:"checkbox",section:"config",description:"Shuffle columns for each respondent"},{key:"showRowNumbers",label:"Show Row Numbers",type:"checkbox",section:"config",description:"Number each row for easy reference"},{key:"requiredPerRow",label:"Require Every Row",type:"checkbox",section:"config",description:"Each row must have a selection before submit"},{key:"layoutStyle",label:"Layout Style",type:"select",section:"config",description:"Visual presentation of the matrix",options:[{value:"table",label:"Table (grid)"},{value:"card",label:"Card per row"},{value:"inline",label:"Inline (compact)"}]}]},getDefaultValues:()=>({properties:{label:"Single Choice Matrix",description:"Select one option per row"},layout:{labelPosition:"top",size:"full"},config:{matrixRows:[{id:"row1",label:"Row 1"},{id:"row2",label:"Row 2"},{id:"row3",label:"Row 3"}],matrixColumns:[{id:"col1",label:"Option 1"},{id:"col2",label:"Option 2"},{id:"col3",label:"Option 3"}]}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e),s=(a==null?void 0:a.matrixRows)||[],l=(a==null?void 0:a.matrixColumns)||[];return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsx("div",{className:m("overflow-x-auto"),children:i.jsxs("table",{className:m("w-full border-collapse text-sm"),children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{className:m("p-2 text-left")}),l.map(c=>i.jsx("th",{className:m("p-2 text-center font-medium text-gray-700"),children:c.label},c.id))]})}),i.jsx("tbody",{children:s.map(c=>i.jsxs("tr",{className:m("border-t border-gray-200"),children:[i.jsx("td",{className:m("p-2 text-gray-700"),children:c.label}),l.map(d=>i.jsx("td",{className:m("p-2 text-center"),children:i.jsx("input",{type:"radio",disabled:!0,name:c.id,className:m("text-blue-600")})},d.id))]},c.id))})]})})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),p=(d==null?void 0:d.matrixRows)||[],u=(d==null?void 0:d.matrixColumns)||[],f=a||{},h=(b,g)=>{c||s==null||s({...f,[b]:g})};return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsx("div",{className:m("overflow-x-auto"),children:i.jsxs("table",{className:m("w-full border-collapse text-sm"),children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{className:m("p-2 text-left")}),u.map(b=>i.jsx("th",{className:m("p-2 text-center font-medium text-gray-700"),children:b.label},b.id))]})}),i.jsx("tbody",{children:p.map(b=>i.jsxs("tr",{className:m("border-t border-gray-200"),children:[i.jsx("td",{className:m("p-2 text-gray-700"),children:b.label}),u.map(g=>i.jsx("td",{className:m("p-2 text-center"),children:i.jsx("input",{type:"radio",name:`${e.element.id}-${b.id}`,checked:f[b.id]===g.id,onChange:()=>h(b.id,g.id),disabled:c,className:m("text-blue-600 cursor-pointer disabled:cursor-not-allowed")})},g.id))]},b.id))})]})})})}},{type:"multipleChoiceMatrix",structure:"field",typeCategory:"Matrix",label:"Multiple Choice Matrix",description:"Matrix with checkbox selections",icon:"📋",category:"field",subCategory:"matrix",dataType:"object",supportsValidation:!0,supportsMatrix:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Matrix Settings",icon:"📋"},fields:[{key:"allowMultiplePerRow",label:"Allow Multiple Per Row",type:"checkbox",section:"config",description:"Let users select more than one column per row"},{key:"maxSelectionsPerRow",label:"Max Selections Per Row",type:"number",section:"config",min:1,placeholder:"e.g. 3",description:"Limit how many columns can be checked per row",showWhen:{field:"allowMultiplePerRow",value:!0}},{key:"randomizeRows",label:"Randomize Row Order",type:"checkbox",section:"config",description:"Shuffle rows for each respondent (surveys)"},{key:"randomizeColumns",label:"Randomize Column Order",type:"checkbox",section:"config",description:"Shuffle columns for each respondent"},{key:"showRowNumbers",label:"Show Row Numbers",type:"checkbox",section:"config",description:"Number each row for easy reference"},{key:"showSelectAll",label:'Show "Select All" Column',type:"checkbox",section:"config",description:"Add a column header to check all rows at once"}]},getDefaultValues:()=>({properties:{label:"Multiple Choice Matrix",description:"Select multiple options per row"},layout:{labelPosition:"top",size:"full"},config:{matrixRows:[{id:"row1",label:"Row 1"},{id:"row2",label:"Row 2"},{id:"row3",label:"Row 3"}],matrixColumns:[{id:"col1",label:"Option 1"},{id:"col2",label:"Option 2"},{id:"col3",label:"Option 3"}],allowMultiplePerRow:!0}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e),s=(a==null?void 0:a.matrixRows)||[],l=(a==null?void 0:a.matrixColumns)||[];return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsx("div",{className:m("overflow-x-auto"),children:i.jsxs("table",{className:m("w-full border-collapse text-sm"),children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{className:m("p-2 text-left")}),l.map(c=>i.jsx("th",{className:m("p-2 text-center font-medium text-gray-700"),children:c.label},c.id))]})}),i.jsx("tbody",{children:s.map(c=>i.jsxs("tr",{className:m("border-t border-gray-200"),children:[i.jsx("td",{className:m("p-2 text-gray-700"),children:c.label}),l.map(d=>i.jsx("td",{className:m("p-2 text-center"),children:i.jsx("input",{type:"checkbox",disabled:!0,className:m("text-blue-600 rounded")})},d.id))]},c.id))})]})})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),p=(d==null?void 0:d.matrixRows)||[],u=(d==null?void 0:d.matrixColumns)||[],f=a||{},h=(b,g)=>{if(c)return;const y=f[b]||[],v=y.includes(g)?y.filter(S=>S!==g):[...y,g];s==null||s({...f,[b]:v})};return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsx("div",{className:m("overflow-x-auto"),children:i.jsxs("table",{className:m("w-full border-collapse text-sm"),children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{className:m("p-2 text-left")}),u.map(b=>i.jsx("th",{className:m("p-2 text-center font-medium text-gray-700"),children:b.label},b.id))]})}),i.jsx("tbody",{children:p.map(b=>i.jsxs("tr",{className:m("border-t border-gray-200"),children:[i.jsx("td",{className:m("p-2 text-gray-700"),children:b.label}),u.map(g=>i.jsx("td",{className:m("p-2 text-center"),children:i.jsx("input",{type:"checkbox",checked:(f[b.id]||[]).includes(g.id),onChange:()=>h(b.id,g.id),disabled:c,className:m("text-blue-600 rounded cursor-pointer disabled:cursor-not-allowed")})},g.id))]},b.id))})]})})})}},{type:"matrixTable",structure:"field",typeCategory:"Matrix",label:"Matrix Table",description:"Table with text/number inputs",icon:"📑",category:"field",subCategory:"matrix",dataType:"object",supportsValidation:!0,supportsMatrix:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Table Settings",icon:"📑"},fields:[{key:"showRowNumbers",label:"Show Row Numbers",type:"checkbox",section:"config",description:"Number each row for easy reference"},{key:"showColumnTotals",label:"Show Column Totals",type:"checkbox",section:"config",description:"Display sum at the bottom of numeric columns"},{key:"allowAddRows",label:"Allow Adding Rows",type:"checkbox",section:"config",description:"Let users add extra rows beyond the defaults"},{key:"allowDeleteRows",label:"Allow Deleting Rows",type:"checkbox",section:"config",description:"Let users remove rows they added",showWhen:{field:"allowAddRows",value:!0}},{key:"stickyHeader",label:"Sticky Header",type:"checkbox",section:"config",description:"Keep column headers visible while scrolling"},{key:"cellPlaceholder",label:"Cell Placeholder",type:"text",section:"config",placeholder:"Enter value...",description:"Placeholder text shown inside empty cells"}]},getDefaultValues:()=>({properties:{label:"Matrix Table",description:"Enter values in each cell"},layout:{labelPosition:"top",size:"full"},config:{matrixRows:[{id:"row1",label:"Row 1"},{id:"row2",label:"Row 2"}],matrixColumns:[{id:"col1",label:"Column 1",type:"text"},{id:"col2",label:"Column 2",type:"number"}]}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e),s=(a==null?void 0:a.matrixRows)||[],l=(a==null?void 0:a.matrixColumns)||[];return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsx("div",{className:m("overflow-x-auto"),children:i.jsxs("table",{className:m("w-full border-collapse text-sm border border-gray-200"),children:[i.jsx("thead",{children:i.jsxs("tr",{className:m("bg-gray-50"),children:[i.jsx("th",{className:m("p-2 text-left border border-gray-200")}),l.map(c=>i.jsx("th",{className:m("p-2 text-center font-medium text-gray-700 border border-gray-200"),children:c.label},c.id))]})}),i.jsx("tbody",{children:s.map(c=>i.jsxs("tr",{children:[i.jsx("td",{className:m("p-2 text-gray-700 border border-gray-200 bg-gray-50"),children:c.label}),l.map(d=>i.jsx("td",{className:m("p-2 border border-gray-200"),children:i.jsx("input",{type:d.type==="number"?"number":"text",disabled:!0,className:m("w-full px-2 py-1 border border-gray-300 rounded text-sm bg-gray-50")})},d.id))]},c.id))})]})})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),p=(d==null?void 0:d.matrixRows)||[],u=(d==null?void 0:d.matrixColumns)||[],f=a||{},h=(b,g,y)=>{const v={...f,[b]:{...f[b]||{},[g]:y}};s==null||s(v)};return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsx("div",{className:m("overflow-x-auto"),children:i.jsxs("table",{className:m("w-full border-collapse text-sm border border-gray-200"),children:[i.jsx("thead",{children:i.jsxs("tr",{className:m("bg-gray-50"),children:[i.jsx("th",{className:m("p-2 text-left border border-gray-200")}),u.map(b=>i.jsx("th",{className:m("p-2 text-center font-medium text-gray-700 border border-gray-200"),children:b.label},b.id))]})}),i.jsx("tbody",{children:p.map(b=>i.jsxs("tr",{children:[i.jsx("td",{className:m("p-2 text-gray-700 border border-gray-200 bg-gray-50"),children:b.label}),u.map(g=>{var y;return i.jsx("td",{className:m("p-2 border border-gray-200"),children:i.jsx("input",{type:g.type==="number"?"number":"text",value:((y=f[b.id])==null?void 0:y[g.id])??"",onChange:v=>h(b.id,g.id,g.type==="number"?Number(v.target.value):v.target.value),disabled:c,className:`w-full px-2 py-1 border rounded text-sm ${c?"bg-gray-50 border-gray-300":"bg-white border-gray-300 focus:border-blue-500 focus:ring-1 focus:ring-blue-500"}`})},g.id)})]},b.id))})]})})})}}],z1=[{type:"fileUpload",structure:"field",typeCategory:"FileUpload",label:"File Upload",description:"Single file upload",icon:"📎",category:"field",subCategory:"fileUpload",dataType:"file",supportsValidation:!0,getDefaultValues:()=>({properties:{label:"File Upload",description:"Upload a file"},layout:{labelPosition:"top",size:"full"},config:{accept:"*/*",maxSize:10485760,multiple:!1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e);return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsxs("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg p-6 text-center bg-gray-50"),children:[i.jsx("svg",{className:m("mx-auto h-8 w-8 text-gray-400"),stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:i.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),i.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload"}),i.jsxs("p",{className:m("text-xs text-gray-400"),children:[(a==null?void 0:a.accept)||"All files"," (Max:"," ",Math.round(((a==null?void 0:a.maxSize)||10485760)/1024/1024),"MB)"]})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),p=b=>{var y;const g=(y=b.target.files)==null?void 0:y[0];g&&(s==null||s(g))},u=b=>{var y;b.preventDefault();const g=(y=b.dataTransfer.files)==null?void 0:y[0];g&&(s==null||s(g))},f=b=>{b.preventDefault()},h=a instanceof File?a.name:a==null?void 0:a.name;return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:i.jsxs("div",{onDrop:c?void 0:u,onDragOver:c?void 0:f,className:`border-2 border-dashed rounded-lg p-6 text-center transition-colors ${((l==null?void 0:l.length)??0)>0?"border-red-300 bg-red-50":"border-gray-300 bg-gray-50 hover:border-gray-400"} ${c?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[i.jsx("input",{type:"file",accept:d==null?void 0:d.accept,onChange:p,disabled:c,className:m("hidden"),id:`file-upload-${e.element.id}`}),i.jsx("label",{htmlFor:`file-upload-${e.element.id}`,className:c?"cursor-not-allowed":"cursor-pointer",children:h?i.jsxs("div",{className:m("flex items-center justify-center gap-2"),children:[i.jsx("span",{className:m("text-2xl"),children:"📄"}),i.jsx("span",{className:m("text-sm text-gray-700"),children:h}),!c&&i.jsx("button",{type:"button",onClick:b=>{b.preventDefault(),s==null||s(null)},className:m("text-red-500 hover:text-red-700"),children:"×"})]}):i.jsxs(i.Fragment,{children:[i.jsx("svg",{className:m("mx-auto h-8 w-8 text-gray-400"),stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:i.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),i.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload"}),i.jsxs("p",{className:m("text-xs text-gray-400"),children:[(d==null?void 0:d.accept)||"All files"," (Max:"," ",Math.round(((d==null?void 0:d.maxSize)||10485760)/1024/1024),"MB)"]})]})})]})})}},{type:"imageUpload",structure:"field",typeCategory:"FileUpload",label:"Image Upload",description:"Single image upload with preview",icon:"🖼️",category:"field",subCategory:"fileUpload",dataType:"file",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Image Upload Settings",icon:"🖼️"},fields:[{key:"maxSize",label:"Max Size (MB)",type:"number",section:"config",min:1,max:100,placeholder:"5",description:"Maximum image file size"},{key:"allowCrop",label:"Allow Cropping",type:"checkbox",section:"config",description:"Let users crop the image after upload"},{key:"aspectRatio",label:"Aspect Ratio",type:"select",section:"config",description:"Constrain crop to a specific ratio",showWhen:{field:"allowCrop",value:!0},options:[{value:"free",label:"Free (no constraint)"},{value:"1:1",label:"1:1 (Square)"},{value:"4:3",label:"4:3 (Standard)"},{value:"16:9",label:"16:9 (Widescreen)"},{value:"3:2",label:"3:2 (Portrait)"},{value:"2:3",label:"2:3 (Landscape)"}]},{key:"minWidth",label:"Min Width (px)",type:"number",section:"config",min:1,placeholder:"e.g. 200",description:"Minimum allowed image width",colSpan:1},{key:"minHeight",label:"Min Height (px)",type:"number",section:"config",min:1,placeholder:"e.g. 200",description:"Minimum allowed image height",colSpan:1},{key:"showPreview",label:"Show Preview",type:"checkbox",section:"config",description:"Display a thumbnail preview of the uploaded image"},{key:"compressOnUpload",label:"Auto-compress",type:"checkbox",section:"config",description:"Automatically compress large images on upload"}]},getDefaultValues:()=>({properties:{label:"Image Upload",description:"Upload an image"},layout:{labelPosition:"top",size:"full"},config:{accept:"image/*",maxSize:5242880,multiple:!1,allowCrop:!1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e);return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,children:i.jsxs("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg p-6 text-center bg-gray-50"),children:[i.jsx("span",{className:m("text-4xl"),children:"🖼️"}),i.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload image"}),i.jsxs("p",{className:m("text-xs text-gray-400"),children:["Images only (Max:"," ",Math.round(((a==null?void 0:a.maxSize)||5242880)/1024/1024),"MB)"]})]})})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),[p,u]=P.useState(null);P.useEffect(()=>{if(a instanceof File){const b=new FileReader;b.onloadend=()=>{u(b.result)},b.readAsDataURL(a)}else u(typeof a=="string"?a:null)},[a]);const f=b=>{var y;const g=(y=b.target.files)==null?void 0:y[0];g&&(s==null||s(g))},h=()=>{s==null||s(null),u(null)};return i.jsx(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:p?i.jsxs("div",{className:m("relative inline-block"),children:[i.jsx("img",{src:p,alt:"Preview",className:m("max-w-full max-h-48 rounded-lg border border-gray-200")}),!c&&i.jsx("button",{type:"button",onClick:h,className:m("absolute -top-2 -right-2 w-6 h-6 bg-red-500 text-white rounded-full flex items-center justify-center text-sm hover:bg-red-600"),children:"×"})]}):i.jsxs("div",{className:`border-2 border-dashed rounded-lg p-6 text-center transition-colors ${((l==null?void 0:l.length)??0)>0?"border-red-300 bg-red-50":"border-gray-300 bg-gray-50 hover:border-gray-400"} ${c?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[i.jsx("input",{type:"file",accept:(d==null?void 0:d.accept)||"image/*",onChange:f,disabled:c,className:m("hidden"),id:`image-upload-${e.element.id}`}),i.jsxs("label",{htmlFor:`image-upload-${e.element.id}`,className:c?"cursor-not-allowed":"cursor-pointer",children:[i.jsx("span",{className:m("text-4xl"),children:"🖼️"}),i.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload image"}),i.jsxs("p",{className:m("text-xs text-gray-400"),children:["Images only (Max:"," ",Math.round(((d==null?void 0:d.maxSize)||5242880)/1024/1024),"MB)"]})]})]})})}},{type:"multiFileUpload",structure:"field",typeCategory:"FileUpload",label:"Multi File Upload",description:"Upload multiple files",icon:"📁",category:"field",subCategory:"fileUpload",dataType:"array",supportsValidation:!0,getDefaultValues:()=>({properties:{label:"Multi File Upload",description:"Upload multiple files"},layout:{labelPosition:"top",size:"full"},config:{accept:"*/*",maxSize:10485760,multiple:!0,maxFiles:10}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e);return i.jsxs(ge,{label:t,description:r,required:o,labelPosition:n,children:[i.jsxs("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg p-6 text-center bg-gray-50"),children:[i.jsx("span",{className:m("text-4xl"),children:"📁"}),i.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload files"}),i.jsxs("p",{className:m("text-xs text-gray-400"),children:["Up to ",(a==null?void 0:a.maxFiles)||10," files"]})]}),i.jsx("div",{className:m("space-y-2 mt-2"),children:i.jsxs("div",{className:m("flex items-center gap-2 p-2 bg-gray-100 rounded text-sm"),children:[i.jsx("span",{children:"📄"}),i.jsx("span",{className:m("flex-1 truncate"),children:"document.pdf"}),i.jsx("button",{disabled:!0,className:m("text-gray-400 hover:text-red-500"),children:"×"})]})})]})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),p=Array.isArray(a)?a:[],u=(d==null?void 0:d.maxFiles)||10,f=b=>{const g=Array.from(b.target.files||[]),y=[...p,...g].slice(0,u);s==null||s(y)},h=b=>{const g=p.filter((y,v)=>v!==b);s==null||s(g)};return i.jsxs(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:[i.jsxs("div",{className:`border-2 border-dashed rounded-lg p-6 text-center transition-colors ${((l==null?void 0:l.length)??0)>0?"border-red-300 bg-red-50":"border-gray-300 bg-gray-50 hover:border-gray-400"} ${c||p.length>=u?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[i.jsx("input",{type:"file",accept:d==null?void 0:d.accept,multiple:!0,onChange:f,disabled:c||p.length>=u,className:m("hidden"),id:`multi-file-upload-${e.element.id}`}),i.jsxs("label",{htmlFor:`multi-file-upload-${e.element.id}`,className:c||p.length>=u?"cursor-not-allowed":"cursor-pointer",children:[i.jsx("span",{className:m("text-4xl"),children:"📁"}),i.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload files"}),i.jsxs("p",{className:m("text-xs text-gray-400"),children:[p.length," / ",u," files"]})]})]}),p.length>0&&i.jsx("div",{className:m("space-y-2 mt-2"),children:p.map((b,g)=>i.jsxs("div",{className:m("flex items-center gap-2 p-2 bg-gray-100 rounded text-sm"),children:[i.jsx("span",{children:"📄"}),i.jsx("span",{className:m("flex-1 truncate"),children:b.name}),i.jsxs("span",{className:m("text-xs text-gray-500"),children:[(b.size/1024).toFixed(1)," KB"]}),!c&&i.jsx("button",{type:"button",onClick:()=>h(g),className:m("text-gray-400 hover:text-red-500"),children:"×"})]},g))})]})}},{type:"multiImageUpload",structure:"field",typeCategory:"FileUpload",label:"Multi Image Upload",description:"Upload multiple images with preview",icon:"🖼️",category:"field",subCategory:"fileUpload",dataType:"array",supportsValidation:!0,getDefaultValues:()=>({properties:{label:"Multi Image Upload",description:"Upload multiple images"},layout:{labelPosition:"top",size:"full"},config:{accept:"image/*",maxSize:5242880,multiple:!0,maxFiles:10,allowCrop:!1}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e);return i.jsxs(ge,{label:t,description:r,required:o,labelPosition:n,children:[i.jsxs("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg p-6 text-center bg-gray-50"),children:[i.jsx("span",{className:m("text-4xl"),children:"🖼️"}),i.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload images"}),i.jsxs("p",{className:m("text-xs text-gray-400"),children:["Up to ",(a==null?void 0:a.maxFiles)||10," images"]})]}),i.jsx("div",{className:m("flex gap-2 flex-wrap mt-2"),children:i.jsxs("div",{className:m("w-20 h-20 bg-gray-200 rounded-lg flex items-center justify-center relative"),children:[i.jsx("span",{className:m("text-2xl"),children:"🖼️"}),i.jsx("button",{disabled:!0,className:m("absolute -top-1 -right-1 w-5 h-5 bg-red-500 text-white rounded-full text-xs"),children:"×"})]})})]})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),[p,u]=P.useState([]),f=Array.isArray(a)?a:[],h=(d==null?void 0:d.maxFiles)||10;P.useEffect(()=>{(async()=>{const v=[];for(const S of f)if(S instanceof File){const x=new FileReader,w=await new Promise(N=>{x.onloadend=()=>N(x.result),x.readAsDataURL(S)});v.push(w)}u(v)})()},[f]);const b=y=>{const v=Array.from(y.target.files||[]),S=[...f,...v].slice(0,h);s==null||s(S)},g=y=>{const v=f.filter((S,x)=>x!==y);s==null||s(v)};return i.jsxs(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:[i.jsxs("div",{className:`border-2 border-dashed rounded-lg p-6 text-center transition-colors ${((l==null?void 0:l.length)??0)>0?"border-red-300 bg-red-50":"border-gray-300 bg-gray-50 hover:border-gray-400"} ${c||f.length>=h?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[i.jsx("input",{type:"file",accept:(d==null?void 0:d.accept)||"image/*",multiple:!0,onChange:b,disabled:c||f.length>=h,className:m("hidden"),id:`multi-image-upload-${e.element.id}`}),i.jsxs("label",{htmlFor:`multi-image-upload-${e.element.id}`,className:c||f.length>=h?"cursor-not-allowed":"cursor-pointer",children:[i.jsx("span",{className:m("text-4xl"),children:"🖼️"}),i.jsx("p",{className:m("mt-2 text-sm text-gray-500"),children:"Click or drag to upload images"}),i.jsxs("p",{className:m("text-xs text-gray-400"),children:[f.length," / ",h," images"]})]})]}),p.length>0&&i.jsx("div",{className:m("flex gap-2 flex-wrap mt-2"),children:p.map((y,v)=>i.jsxs("div",{className:m("w-20 h-20 rounded-lg overflow-hidden relative border border-gray-200"),children:[i.jsx("img",{src:y,alt:`Preview ${v+1}`,className:m("w-full h-full object-cover")}),!c&&i.jsx("button",{type:"button",onClick:()=>g(v),className:m("absolute -top-1 -right-1 w-5 h-5 bg-red-500 text-white rounded-full text-xs hover:bg-red-600 flex items-center justify-center"),children:"×"})]},v))})]})}}],B1=[{type:"password",structure:"field",typeCategory:"Security",label:"Password",description:"Secure password input",icon:"🔒",category:"field",subCategory:"security",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!0,showDescription:!0},configSection:{title:"Password Settings",icon:"🔒"},fields:[{key:"showStrengthMeter",label:"Show Strength Meter",type:"checkbox",section:"config",description:"Visual indicator of password strength"},{key:"showToggle",label:"Show / Hide Toggle",type:"checkbox",section:"config",description:"Let users reveal their password"},{key:"minStrength",label:"Minimum Strength",type:"select",section:"config",description:"Lowest accepted password strength level",options:[{value:"weak",label:"Weak"},{value:"medium",label:"Medium"},{value:"strong",label:"Strong"}]},{key:"strengthLabels",label:"Show Requirements Hint",type:"checkbox",section:"config",description:"Display password rules (length, special chars, etc.)"}]},getDefaultValues:()=>({properties:{label:"Password",placeholder:"••••••••"},layout:{labelPosition:"top",size:"full"},config:{showStrengthMeter:!1,showToggle:!0,minStrength:"medium"},validation:{minLength:8}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,config:s}=oe(e);return i.jsxs(ge,{label:t,description:r,required:n,labelPosition:a,children:[i.jsxs("div",{className:m("relative"),children:[i.jsx("input",{type:"password",placeholder:o||"••••••••",disabled:!0,className:`${Ot()} pr-10`}),(s==null?void 0:s.showToggle)&&i.jsx("button",{disabled:!0,className:m("absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"),children:"👁️"})]}),(s==null?void 0:s.showStrengthMeter)&&i.jsxs("div",{className:m("flex gap-1 mt-2"),children:[i.jsx("div",{className:m("h-1 flex-1 bg-gray-300 rounded")}),i.jsx("div",{className:m("h-1 flex-1 bg-gray-300 rounded")}),i.jsx("div",{className:m("h-1 flex-1 bg-gray-300 rounded")}),i.jsx("div",{className:m("h-1 flex-1 bg-gray-300 rounded")})]})]})},render:e=>{const{label:t,description:r,placeholder:o,required:n,labelPosition:a,value:s,onChange:l,errors:c,isDisabled:d,config:p}=oe(e),[u,f]=P.useState(!1),b=(y=>{if(!y)return 0;let v=0;return y.length>=8&&v++,/[a-z]/.test(y)&&/[A-Z]/.test(y)&&v++,/\d/.test(y)&&v++,/[^a-zA-Z0-9]/.test(y)&&v++,v})(s||""),g=["bg-red-500","bg-orange-500","bg-yellow-500","bg-green-500"];return i.jsxs(ge,{label:t,description:r,required:n,labelPosition:a,errors:c,children:[i.jsxs("div",{className:m("relative"),children:[i.jsx("input",{type:u?"text":"password",placeholder:o||"••••••••",value:s??"",onChange:y=>l==null?void 0:l(y.target.value),disabled:d,className:`${qt({hasError:((c==null?void 0:c.length)??0)>0,disabled:d})} pr-10`}),(p==null?void 0:p.showToggle)&&!d&&i.jsx("button",{type:"button",onClick:()=>f(!u),className:m("absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"),children:u?"🙈":"👁️"})]}),(p==null?void 0:p.showStrengthMeter)&&s&&i.jsx("div",{className:m("flex gap-1 mt-2"),children:[0,1,2,3].map(y=>i.jsx("div",{className:`h-1 flex-1 rounded ${y<b?g[b-1]:"bg-gray-300"}`},y))})]})}},{type:"signature",structure:"field",typeCategory:"Security",label:"Signature",description:"Handwritten signature pad",icon:"✍️",category:"field",subCategory:"security",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!0,showPlaceholder:!1,showDescription:!0},configSection:{title:"Signature Pad Settings",icon:"✍️"},fields:[{key:"canvasWidth",label:"Width (px)",type:"number",section:"config",min:100,max:1200,placeholder:"400",description:"Drawing area width",colSpan:1},{key:"canvasHeight",label:"Height (px)",type:"number",section:"config",min:50,max:600,placeholder:"200",description:"Drawing area height",colSpan:1},{key:"strokeWidth",label:"Stroke Width",type:"number",section:"config",min:1,max:10,placeholder:"2",description:"Pen thickness",colSpan:1},{key:"strokeColor",label:"Stroke Color",type:"color",section:"config",placeholder:"#000000",description:"Pen color",colSpan:1},{key:"backgroundColor",label:"Background Color",type:"color",section:"config",placeholder:"#ffffff",description:"Pad background color"},{key:"requireFullName",label:"Require Full Name",type:"checkbox",section:"config",description:"Ask for a printed name below the signature"},{key:"showTimestamp",label:"Show Timestamp",type:"checkbox",section:"config",description:"Auto-record date and time of signing"}]},getDefaultValues:()=>({properties:{label:"Signature",description:"Please sign below"},layout:{labelPosition:"top",size:"full"},config:{strokeWidth:2,strokeColor:"#000000",backgroundColor:"#ffffff",canvasWidth:400,canvasHeight:200}}),renderOnCanvas:e=>{const{label:t,description:r,required:o,labelPosition:n,config:a}=oe(e);return i.jsxs(ge,{label:t,description:r,required:o,labelPosition:n,children:[i.jsx("div",{className:m("border-2 border-dashed border-gray-300 rounded-lg bg-gray-50 flex items-center justify-center"),style:{height:(a==null?void 0:a.canvasHeight)||200,backgroundColor:(a==null?void 0:a.backgroundColor)||"#ffffff"},children:i.jsxs("div",{className:m("text-center text-gray-400"),children:[i.jsx("span",{className:m("text-3xl"),children:"✍️"}),i.jsx("p",{className:m("text-sm mt-2"),children:"Draw your signature here"})]})}),i.jsx("button",{disabled:!0,className:m("text-sm text-blue-600 hover:text-blue-700 mt-2"),children:"Clear signature"})]})},render:e=>{const{label:t,description:r,required:o,labelPosition:n,value:a,onChange:s,errors:l,isDisabled:c,config:d}=oe(e),p=P.useRef(null),[u,f]=P.useState(!1),h=v=>{if(c)return;f(!0);const S=p.current;if(!S)return;const x=S.getContext("2d");if(!x)return;const w=S.getBoundingClientRect();x.beginPath(),x.moveTo(v.clientX-w.left,v.clientY-w.top)},b=v=>{if(!u||c)return;const S=p.current;if(!S)return;const x=S.getContext("2d");if(!x)return;const w=S.getBoundingClientRect();x.lineWidth=(d==null?void 0:d.strokeWidth)||2,x.strokeStyle=(d==null?void 0:d.strokeColor)||"#000000",x.lineCap="round",x.lineTo(v.clientX-w.left,v.clientY-w.top),x.stroke()},g=()=>{u&&p.current&&(f(!1),s==null||s(p.current.toDataURL()))},y=()=>{const v=p.current;if(!v)return;const S=v.getContext("2d");S&&(S.fillStyle=(d==null?void 0:d.backgroundColor)||"#ffffff",S.fillRect(0,0,v.width,v.height),s==null||s(""))};return i.jsxs(ge,{label:t,description:r,required:o,labelPosition:n,errors:l,children:[i.jsx("div",{className:`border-2 rounded-lg overflow-hidden ${((l==null?void 0:l.length)??0)>0?"border-red-500":"border-gray-300"} ${c?"opacity-50":""}`,style:{backgroundColor:(d==null?void 0:d.backgroundColor)||"#ffffff"},children:i.jsx("canvas",{ref:p,width:(d==null?void 0:d.canvasWidth)||400,height:(d==null?void 0:d.canvasHeight)||200,onMouseDown:h,onMouseMove:b,onMouseUp:g,onMouseLeave:g,className:c?"cursor-not-allowed":"cursor-crosshair",style:{display:"block",width:"100%"}})}),!c&&i.jsx("button",{type:"button",onClick:y,className:m("text-sm text-blue-600 hover:text-blue-700 mt-2"),children:"Clear signature"})]})}},{type:"captcha",structure:"field",typeCategory:"Security",label:"Captcha",description:"Bot protection verification",icon:"🤖",category:"field",subCategory:"security",dataType:"string",supportsValidation:!0,settingsSchema:{properties:{showLabel:!1,showPlaceholder:!1,showDescription:!0},configSection:{title:"Captcha Settings",icon:"🤖"},fields:[{key:"provider",label:"Provider",type:"select",section:"config",description:"Which CAPTCHA service to use",options:[{value:"recaptcha",label:"Google reCAPTCHA v3"},{value:"recaptcha-v2",label:"Google reCAPTCHA v2"},{value:"hcaptcha",label:"hCaptcha"},{value:"turnstile",label:"Cloudflare Turnstile"},{value:"friendly",label:"Friendly Captcha"}]},{key:"siteKey",label:"Site Key",type:"text",section:"config",placeholder:"Your site key from provider",description:"Public key provided by the CAPTCHA service"},{key:"theme",label:"Widget Theme",type:"select",section:"config",options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"auto",label:"Auto (match page)"}]},{key:"size",label:"Widget Size",type:"select",section:"config",options:[{value:"normal",label:"Normal"},{value:"compact",label:"Compact"},{value:"invisible",label:"Invisible"}]}]},getDefaultValues:()=>({properties:{label:"CAPTCHA",description:"Please verify you are human"},layout:{labelPosition:"hidden",size:"full"},config:{provider:"recaptcha",siteKey:"",theme:"light"}}),renderOnCanvas:e=>{const{description:t}=oe(e);return i.jsxs("div",{className:m("space-y-1.5"),children:[t&&i.jsx("p",{className:m("text-xs text-gray-500"),children:t}),i.jsx("div",{className:m("border border-gray-300 rounded-md p-4 bg-gray-50 max-w-[300px]"),children:i.jsxs("div",{className:m("flex items-center gap-3"),children:[i.jsx("div",{className:m("w-7 h-7 border-2 border-gray-300 rounded flex items-center justify-center"),children:"☐"}),i.jsx("span",{className:m("text-sm text-gray-700"),children:"I'm not a robot"}),i.jsx("div",{className:m("ml-auto"),children:i.jsxs("div",{className:m("text-xs text-gray-400 text-center"),children:[i.jsx("div",{className:m("text-lg"),children:"🔄"}),i.jsx("span",{children:"reCAPTCHA"})]})})]})})]})},render:e=>{const{description:t,value:r,onChange:o,errors:n,isDisabled:a,config:s}=oe(e),l=r===!0,c=()=>{a||o==null||o(!0)};return i.jsxs("div",{className:m("space-y-1.5"),children:[t&&i.jsx("p",{className:m("text-xs text-gray-500"),children:t}),i.jsx("div",{className:`border rounded-md p-4 max-w-[300px] ${((n==null?void 0:n.length)??0)>0?"border-red-500 bg-red-50":l?"border-green-500 bg-green-50":"border-gray-300 bg-gray-50"}`,children:i.jsxs("div",{className:m("flex items-center gap-3"),children:[i.jsx("button",{type:"button",onClick:c,disabled:a||l,className:`w-7 h-7 border-2 rounded flex items-center justify-center transition-colors ${l?"border-green-500 bg-green-500 text-white":"border-gray-300 hover:border-gray-400"} ${a?"cursor-not-allowed opacity-50":"cursor-pointer"}`,children:l?"✓":""}),i.jsx("span",{className:m("text-sm text-gray-700"),children:l?"Verified!":"I'm not a robot"}),i.jsx("div",{className:m("ml-auto"),children:i.jsxs("div",{className:m("text-xs text-gray-400 text-center"),children:[i.jsx("div",{className:m("text-lg"),children:(s==null?void 0:s.provider)==="hcaptcha"?"🛡️":"🔄"}),i.jsx("span",{children:(s==null?void 0:s.provider)==="hcaptcha"?"hCaptcha":(s==null?void 0:s.provider)==="turnstile"?"Turnstile":"reCAPTCHA"})]})})]})}),n&&n.length>0&&i.jsx("div",{className:m("space-y-1"),children:n.map((d,p)=>i.jsx("p",{className:m("text-xs text-red-500"),children:d},p))})]})}}],U1=[{type:"group",structure:"page",typeCategory:"Layout",label:"Group",description:"Container to group related elements together",icon:"📦",category:"page",subCategory:"layout",supportsValidation:!1,isContainer:!0,dataType:"object",getDefaultValues:()=>({properties:{label:"Group",description:""},layout:{size:"full"},config:{collapsed:!1,collapsible:!1,showBorder:!0,padding:16}}),renderOnCanvas:e=>{const{label:t,description:r,config:o}=oe(e),n=(o==null?void 0:o.showBorder)??!0,a=(o==null?void 0:o.collapsible)??!1;return i.jsxs("div",{className:m("rounded-lg",n?"border border-gray-200":""),style:{padding:(o==null?void 0:o.padding)||16},children:[i.jsx("div",{className:m("flex items-center justify-between mb-2"),children:i.jsxs("div",{children:[i.jsxs("h3",{className:m("font-medium text-gray-800 flex items-center gap-2"),children:[a&&i.jsx("span",{className:m("text-gray-400 text-sm"),children:"▼"}),t||"Group"]}),r&&i.jsx("p",{className:m("text-sm text-gray-500 mt-0.5"),children:r})]})}),i.jsx("div",{className:m("border-2 border-dashed border-gray-200 rounded-md p-4 min-h-[80px] flex items-center justify-center"),children:i.jsx("span",{className:m("text-sm text-gray-400"),children:"Drop elements here"})})]})},render:e=>{const{label:t,description:r,config:o,element:n}=oe(e),{renderChildren:a}=e,s=(o==null?void 0:o.showBorder)??!0,l=(o==null?void 0:o.collapsible)??!1,[c,d]=P.useState((o==null?void 0:o.collapsed)??!1);return i.jsxs("div",{className:`rounded-lg ${s?"border border-gray-200":""}`,style:{padding:(o==null?void 0:o.padding)||16},children:[i.jsx("div",{className:`flex items-center justify-between ${l?"cursor-pointer":""}`,onClick:()=>l&&d(!c),children:i.jsxs("div",{children:[i.jsxs("h3",{className:m("font-medium text-gray-800 flex items-center gap-2"),children:[l&&i.jsx("span",{className:m("text-gray-400 text-sm transition-transform",c?"-rotate-90":""),children:"▼"}),t||"Group"]}),r&&!c&&i.jsx("p",{className:m("text-sm text-gray-500 mt-0.5"),children:r})]})}),!c&&i.jsx("div",{className:m("mt-3"),children:a?a(n.id):i.jsx("div",{"data-container-id":n.id,className:m("space-y-4")})})]})}},{type:"grid",structure:"page",typeCategory:"Layout",label:"Grid",description:"Arrange elements in a responsive grid layout",icon:"⊞",category:"page",subCategory:"layout",supportsValidation:!1,isContainer:!0,dataType:"object",getDefaultValues:()=>({properties:{label:""},layout:{size:"full"},config:{gridColumns:2,gridGap:16,responsiveColumns:{sm:1,md:2,lg:2}}}),renderOnCanvas:e=>{const{label:t,config:r}=oe(e),o=(r==null?void 0:r.gridColumns)||2,n=(r==null?void 0:r.gridGap)||16;return i.jsxs("div",{className:m("border border-gray-200 rounded-lg p-4"),children:[t&&i.jsx("div",{className:m("mb-3"),children:i.jsx("h3",{className:m("font-medium text-gray-800"),children:t})}),i.jsx("div",{className:m("grid"),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,gap:n},children:Array.from({length:o}).map((a,s)=>i.jsx("div",{className:m("border-2 border-dashed border-gray-200 rounded-md p-4 min-h-[60px] flex items-center justify-center"),children:i.jsxs("span",{className:m("text-xs text-gray-400"),children:["Column ",s+1]})},s))})]})},render:e=>{const{label:t,config:r,element:o}=oe(e),{renderChildren:n}=e,a=(r==null?void 0:r.gridColumns)||2,s=(r==null?void 0:r.gridGap)||16;return i.jsxs("div",{children:[t&&i.jsx("div",{className:m("mb-3"),children:i.jsx("h3",{className:m("font-medium text-gray-800"),children:t})}),i.jsx("div",{className:m("grid"),style:{gridTemplateColumns:`repeat(${a}, 1fr)`,gap:s},children:n?n(o.id):i.jsx("div",{"data-container-id":o.id,className:m("space-y-4")})})]})}},{type:"table",structure:"page",typeCategory:"Layout",label:"Table",description:"Display data in a table format",icon:"📊",category:"page",subCategory:"layout",supportsValidation:!1,isContainer:!0,dataType:"array",getDefaultValues:()=>({properties:{label:"Table",description:""},layout:{size:"full"},config:{tableColumns:[{id:"col1",header:"Column 1",width:"auto",align:"left"},{id:"col2",header:"Column 2",width:"auto",align:"left"},{id:"col3",header:"Column 3",width:"auto",align:"left"}],showHeader:!0,striped:!0,bordered:!0}}),renderOnCanvas:e=>{const{label:t,description:r,config:o}=oe(e),n=(o==null?void 0:o.tableColumns)||[{id:"col1",header:"Column 1"},{id:"col2",header:"Column 2"}],a=(o==null?void 0:o.showHeader)??!0,s=(o==null?void 0:o.striped)??!0,l=(o==null?void 0:o.bordered)??!0;return i.jsxs("div",{className:m("space-y-2"),children:[t&&i.jsxs("div",{children:[i.jsx("h3",{className:m("font-medium text-gray-800"),children:t}),r&&i.jsx("p",{className:m("text-sm text-gray-500"),children:r})]}),i.jsx("div",{className:`overflow-hidden rounded-lg ${l?"border border-gray-200":""}`,children:i.jsxs("table",{className:m("min-w-full divide-y divide-gray-200"),children:[a&&i.jsx("thead",{className:m("bg-gray-50"),children:i.jsx("tr",{children:n.map(c=>i.jsx("th",{className:`px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider text-${c.align||"left"}`,children:c.header},c.id))})}),i.jsx("tbody",{className:`bg-white ${s?"divide-y divide-gray-200":""}`,children:[1,2].map((c,d)=>i.jsx("tr",{className:s&&d%2===1?"bg-gray-50":"",children:n.map(p=>i.jsx("td",{className:`px-4 py-3 text-sm text-gray-500 text-${p.align||"left"}`,children:i.jsx("span",{className:m("text-gray-300"),children:"Sample data"})},p.id))},c))})]})}),i.jsx("p",{className:m("text-xs text-gray-400 text-center"),children:"Table preview - drop elements to define row structure"})]})},render:e=>{const{label:t,description:r,config:o,value:n=[]}=oe(e),a=(o==null?void 0:o.tableColumns)||[],s=(o==null?void 0:o.showHeader)??!0,l=(o==null?void 0:o.striped)??!0,c=(o==null?void 0:o.bordered)??!0,d=Array.isArray(n)?n:[];return i.jsxs("div",{className:m("space-y-2"),children:[t&&i.jsxs("div",{children:[i.jsx("h3",{className:m("font-medium text-gray-800"),children:t}),r&&i.jsx("p",{className:m("text-sm text-gray-500"),children:r})]}),i.jsx("div",{className:`overflow-x-auto rounded-lg ${c?"border border-gray-200":""}`,children:i.jsxs("table",{className:m("min-w-full divide-y divide-gray-200"),children:[s&&i.jsx("thead",{className:m("bg-gray-50"),children:i.jsx("tr",{children:a.map(p=>i.jsx("th",{style:{width:p.width||"auto"},className:`px-4 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider text-${p.align||"left"}`,children:p.header},p.id))})}),i.jsx("tbody",{className:`bg-white ${l?"divide-y divide-gray-200":""}`,children:d.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:a.length,className:m("px-4 py-8 text-sm text-gray-400 text-center"),children:"No data available"})}):d.map((p,u)=>i.jsx("tr",{className:l&&u%2===1?"bg-gray-50":"",children:a.map(f=>i.jsx("td",{className:`px-4 py-3 text-sm text-gray-700 text-${f.align||"left"}`,children:p[f.id]??"-"},f.id))},u))})]})})]})}},{type:"pages",structure:"page",typeCategory:"Special",label:"Wizard / Pages",description:"Multi-step form wizard with progress tracking",icon:"📑",category:"page",subCategory:"special",supportsValidation:!1,isContainer:!0,dataType:"object",settingsSchema:{configSection:{title:"Wizard Settings",icon:"📑"},fields:[{key:"showProgressBar",label:"Show Progress Bar",type:"checkbox",section:"config",description:"Display the progress bar and step indicators"},{key:"showStepNumbers",label:"Show Step Numbers",type:"checkbox",section:"config",description:"Display step numbers next to each step"},{key:"allowSkip",label:"Allow Skipping Steps",type:"checkbox",section:"config",description:"Let users jump to earlier steps via the progress bar"},{key:"validateOnNext",label:"Validate Before Next",type:"checkbox",section:"config",description:"Validate the current step's fields before advancing"},{key:"nextButtonLabel",label:"Next Button Label",type:"text",section:"config",placeholder:"Next",description:"Label for the button that advances to the next step"}]},getDefaultValues:()=>({properties:{label:"Form Wizard"},layout:{size:"full"},config:{showProgressBar:!0,showStepNumbers:!0,allowSkip:!1,validateOnNext:!0,nextButtonLabel:"Next",steps:[{id:"step-1",label:"Step 1",description:"First step"},{id:"step-2",label:"Step 2",description:"Second step"}],activeStepId:"step-1"}}),renderOnCanvas:e=>{var l,c;const{config:t}=oe(e),r=(t==null?void 0:t.steps)||[{id:"step-1",label:"Step 1"},{id:"step-2",label:"Step 2"}],o=(t==null?void 0:t.activeStepId)||((l=r[0])==null?void 0:l.id),n=r.findIndex(d=>d.id===o),a=(t==null?void 0:t.showProgressBar)??!0,s=(t==null?void 0:t.showStepNumbers)??!0;return i.jsxs("div",{className:m("border border-gray-200 rounded-lg p-4 bg-white"),children:[a&&i.jsxs("div",{className:m("mb-6"),children:[i.jsx("div",{className:m("h-2 bg-gray-200 rounded-full overflow-hidden"),children:i.jsx("div",{className:m("h-full bg-blue-600 transition-all duration-300"),style:{width:`${(n+1)/r.length*100}%`}})}),s&&i.jsx("div",{className:m("flex justify-between mt-3"),children:r.map((d,p)=>{const u=p<n,f=p===n;return i.jsxs("div",{className:m("flex flex-col items-center"),children:[i.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors ${u?"bg-green-500 text-white":f?"bg-blue-600 text-white":"bg-gray-200 text-gray-500"}`,children:u?"✓":p+1}),i.jsx("span",{className:`text-xs mt-1 ${f?"text-blue-600 font-medium":"text-gray-500"}`,children:d.label})]},d.id)})})]}),i.jsx("div",{className:m("border-2 border-dashed border-gray-200 rounded-lg p-6 min-h-[150px] flex items-center justify-center"),children:i.jsxs("div",{className:m("text-center"),children:[i.jsxs("span",{className:m("text-gray-400 text-sm"),children:["Step ",n+1,":"," ",(c=r[n])==null?void 0:c.label]}),i.jsx("p",{className:m("text-gray-300 text-xs mt-1"),children:"Drop elements here for this step"})]})}),i.jsxs("div",{className:m("flex justify-between mt-4 pt-4 border-t border-gray-200"),children:[i.jsx("button",{type:"button",disabled:n===0,className:`px-4 py-2 text-sm rounded-md ${n===0?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-gray-200 text-gray-700 hover:bg-gray-300"}`,children:"← Previous"}),i.jsx("button",{type:"button",className:m("px-4 py-2 text-sm rounded-md bg-blue-600 text-white hover:bg-blue-700"),children:n===r.length-1?"Submit":"Next →"})]})]})},render:e=>{const{config:t,element:r}=oe(e),o=(t==null?void 0:t.steps)||[];return i.jsx("div",{"data-wizard-id":r.id,"data-wizard-steps":o.length})}}],W1=[{type:"repeatElement",structure:"page",typeCategory:"Repeatable",label:"Repeat Element",description:"Allow users to add multiple values of a single field",icon:"🔄",category:"page",subCategory:"repeatable",supportsValidation:!0,isContainer:!1,dataType:"array",getDefaultValues:()=>({properties:{label:"Repeatable Field",description:"Add multiple values",placeholder:"Enter value"},layout:{labelPosition:"top",size:"full"},validation:{required:!1},config:{minItems:1,maxItems:10,addButtonText:"Add Item",removeButtonText:"Remove",showItemNumber:!0}}),renderOnCanvas:e=>{const{label:t,description:r,placeholder:o,required:n,config:a}=oe(e),s=(a==null?void 0:a.minItems)||1,l=(a==null?void 0:a.maxItems)||10,c=(a==null?void 0:a.addButtonText)||"Add Item",d=(a==null?void 0:a.showItemNumber)??!0;return i.jsxs("div",{className:m("space-y-3"),children:[i.jsxs("div",{children:[i.jsxs("label",{className:m("block text-sm font-medium text-gray-700"),children:[t||"Repeatable Field",n&&i.jsx("span",{className:m("text-red-500 ml-1"),children:"*"})]}),r&&i.jsx("p",{className:m("text-xs text-gray-500 mt-0.5"),children:r})]}),i.jsx("div",{className:m("space-y-2"),children:Array.from({length:Math.min(2,s)}).map((p,u)=>i.jsxs("div",{className:m("flex items-center gap-2"),children:[d&&i.jsxs("span",{className:m("text-xs text-gray-400 w-4"),children:[u+1,"."]}),i.jsx("input",{type:"text",placeholder:o||"Enter value",disabled:!0,className:m("flex-1 px-3 py-2 text-sm border border-gray-300 rounded-md bg-gray-50 text-gray-500")}),i.jsx("button",{type:"button",disabled:!0,className:m("p-2 text-gray-400 hover:text-red-500 disabled:opacity-50"),children:"✕"})]},u))}),i.jsxs("button",{type:"button",disabled:!0,className:m("flex items-center gap-1 text-sm text-blue-600 hover:text-blue-700 disabled:opacity-50"),children:[i.jsx("span",{children:"+"}),i.jsx("span",{children:c})]}),i.jsxs("p",{className:m("text-xs text-gray-400"),children:["Min: ",s," | Max: ",l," items"]})]})},render:e=>{const{label:t,description:r,placeholder:o,required:n,config:a,value:s=[],onChange:l,errors:c,isDisabled:d}=oe(e),p=(a==null?void 0:a.minItems)||1,u=(a==null?void 0:a.maxItems)||10,f=(a==null?void 0:a.addButtonText)||"Add Item",h=(a==null?void 0:a.showItemNumber)??!0,b=Array.isArray(s)?s:[""],g=b.length<u,y=b.length>p,v=()=>{g&&l&&l([...b,""])},S=N=>{if(y&&l){const k=b.filter((_,E)=>E!==N);l(k)}},x=(N,k)=>{if(l){const _=[...b];_[N]=k,l(_)}},w=c&&c.length>0;return i.jsxs("div",{className:m("space-y-3"),children:[i.jsxs("div",{children:[i.jsxs("label",{className:m("block text-sm font-medium text-gray-700"),children:[t||"Repeatable Field",n&&i.jsx("span",{className:m("text-red-500 ml-1"),children:"*"})]}),r&&i.jsx("p",{className:m("text-xs text-gray-500 mt-0.5"),children:r})]}),i.jsx("div",{className:m("space-y-2"),children:b.map((N,k)=>i.jsxs("div",{className:m("flex items-center gap-2"),children:[h&&i.jsxs("span",{className:m("text-xs text-gray-400 w-4"),children:[k+1,"."]}),i.jsx("input",{type:"text",value:N,onChange:_=>x(k,_.target.value),placeholder:o||"Enter value",disabled:d,className:`flex-1 px-3 py-2 text-sm border rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-offset-0 ${w?"border-red-500 focus:ring-red-500":"border-gray-300 focus:ring-blue-500 focus:border-blue-500"} ${d?"bg-gray-50 text-gray-500 cursor-not-allowed":""}`}),i.jsx("button",{type:"button",onClick:()=>S(k),disabled:!y||d,className:`p-2 transition-colors ${y&&!d?"text-gray-400 hover:text-red-500":"text-gray-300 cursor-not-allowed"}`,children:"✕"})]},k))}),g&&!d&&i.jsxs("button",{type:"button",onClick:v,className:m("flex items-center gap-1 text-sm text-blue-600 hover:text-blue-700"),children:[i.jsx("span",{children:"+"}),i.jsx("span",{children:f})]}),c&&c.length>0&&i.jsx("div",{className:m("space-y-1"),children:c.map((N,k)=>i.jsx("p",{className:m("text-xs text-red-500"),children:N},k))})]})}},{type:"repeatGroup",structure:"page",typeCategory:"Repeatable",label:"Repeat Group",description:"Allow users to add multiple instances of a group of fields",icon:"📚",category:"page",subCategory:"repeatable",supportsValidation:!0,isContainer:!0,dataType:"array",getDefaultValues:()=>({properties:{label:"Repeatable Section",description:"Add multiple entries"},layout:{size:"full"},validation:{required:!1},config:{minItems:1,maxItems:10,addButtonText:"Add Entry",removeButtonText:"Remove",itemLabel:"Entry",showItemNumber:!0}}),renderOnCanvas:e=>{const{label:t,description:r,config:o}=oe(e),n=(o==null?void 0:o.minItems)||1,a=(o==null?void 0:o.maxItems)||10,s=(o==null?void 0:o.addButtonText)||"Add Entry",l=(o==null?void 0:o.itemLabel)||"Entry",c=(o==null?void 0:o.showItemNumber)??!0;return i.jsxs("div",{className:m("border border-gray-200 rounded-lg p-4 space-y-4"),children:[i.jsxs("div",{className:m("flex items-center justify-between"),children:[i.jsxs("div",{children:[i.jsxs("h3",{className:m("font-medium text-gray-800 flex items-center gap-2"),children:[i.jsx("span",{className:m("text-lg"),children:"📚"}),t||"Repeatable Section"]}),r&&i.jsx("p",{className:m("text-sm text-gray-500 mt-0.5"),children:r})]}),i.jsxs("span",{className:m("text-xs text-gray-400 bg-gray-100 px-2 py-1 rounded"),children:[n,"-",a," items"]})]}),i.jsxs("div",{className:m("border border-dashed border-gray-300 rounded-lg"),children:[i.jsxs("div",{className:m("flex items-center justify-between px-4 py-2 bg-gray-50 border-b border-dashed border-gray-300 rounded-t-lg"),children:[i.jsxs("span",{className:m("text-sm font-medium text-gray-600"),children:[c&&"1. ",l]}),i.jsxs("div",{className:m("flex items-center gap-2"),children:[i.jsx("button",{type:"button",disabled:!0,className:m("text-gray-400 hover:text-gray-600 text-sm"),children:"▲"}),i.jsx("button",{type:"button",disabled:!0,className:m("text-gray-400 hover:text-gray-600 text-sm"),children:"▼"}),i.jsx("button",{type:"button",disabled:!0,className:m("text-gray-400 hover:text-red-500 text-sm"),children:"✕"})]})]}),i.jsx("div",{className:m("p-4 min-h-[80px] flex items-center justify-center"),children:i.jsx("span",{className:m("text-sm text-gray-400"),children:"Drop elements here to define the repeatable group structure"})})]}),i.jsxs("button",{type:"button",disabled:!0,className:m("w-full flex items-center justify-center gap-2 py-2 border-2 border-dashed border-gray-300 rounded-lg text-sm text-gray-500 hover:border-blue-400 hover:text-blue-600 transition-colors disabled:opacity-50"),children:[i.jsx("span",{children:"+"}),i.jsx("span",{children:s})]})]})},render:e=>{const{label:t,description:r,config:o,element:n,value:a=[],onChange:s,errors:l,isDisabled:c}=oe(e),{renderChildren:d}=e,p=(o==null?void 0:o.minItems)||1,u=(o==null?void 0:o.maxItems)||10,f=(o==null?void 0:o.addButtonText)||"Add Entry",h=(o==null?void 0:o.removeButtonText)||"Remove",b=(o==null?void 0:o.itemLabel)||"Entry",g=(o==null?void 0:o.showItemNumber)??!0,y=Array.isArray(a)?a:Array.from({length:p},()=>({})),v=y.length<u,S=y.length>p,x=()=>{v&&s&&s([...y,{}])},w=E=>{if(S&&s){const D=y.filter((T,O)=>O!==E);s(D)}},N=E=>{if(E>0&&s){const D=[...y];[D[E-1],D[E]]=[D[E],D[E-1]],s(D)}},k=E=>{if(E<y.length-1&&s){const D=[...y];[D[E],D[E+1]]=[D[E+1],D[E]],s(D)}},_=l&&l.length>0;return i.jsxs("div",{className:`border rounded-lg p-4 space-y-4 ${_?"border-red-300":"border-gray-200"}`,children:[i.jsxs("div",{className:m("flex items-center justify-between"),children:[i.jsxs("div",{children:[i.jsx("h3",{className:m("font-medium text-gray-800"),children:t||"Repeatable Section"}),r&&i.jsx("p",{className:m("text-sm text-gray-500 mt-0.5"),children:r})]}),i.jsxs("span",{className:m("text-xs text-gray-400"),children:[y.length," of ",u]})]}),i.jsx("div",{className:m("space-y-3"),children:y.map((E,D)=>{var T;return i.jsxs("div",{className:m("border border-gray-200 rounded-lg overflow-hidden"),children:[i.jsxs("div",{className:m("flex items-center justify-between px-4 py-2 bg-gray-50 border-b border-gray-200"),children:[i.jsxs("span",{className:m("text-sm font-medium text-gray-600"),children:[g&&`${D+1}. `,b]}),!c&&i.jsxs("div",{className:m("flex items-center gap-1"),children:[i.jsx("button",{type:"button",onClick:()=>N(D),disabled:D===0,className:`p-1 rounded transition-colors ${D===0?"text-gray-300 cursor-not-allowed":"text-gray-400 hover:text-gray-600 hover:bg-gray-100"}`,title:"Move up",children:"▲"}),i.jsx("button",{type:"button",onClick:()=>k(D),disabled:D===y.length-1,className:`p-1 rounded transition-colors ${D===y.length-1?"text-gray-300 cursor-not-allowed":"text-gray-400 hover:text-gray-600 hover:bg-gray-100"}`,title:"Move down",children:"▼"}),i.jsx("button",{type:"button",onClick:()=>w(D),disabled:!S,className:`p-1 rounded transition-colors ${S?"text-gray-400 hover:text-red-500 hover:bg-red-50":"text-gray-300 cursor-not-allowed"}`,title:h,children:"✕"})]})]}),i.jsx("div",{className:m("p-4"),children:d?d(n.id,`${((T=n.attributes)==null?void 0:T.name)||n.id}[${D}]`):i.jsx("div",{"data-repeat-group-item":n.id,"data-repeat-index":D,className:m("text-sm text-gray-400 text-center py-4"),children:"Group fields render here"})})]},D)})}),v&&!c&&i.jsxs("button",{type:"button",onClick:x,className:m("w-full flex items-center justify-center gap-2 py-2 border-2 border-dashed border-gray-300 rounded-lg text-sm text-gray-500 hover:border-blue-400 hover:text-blue-600 transition-colors"),children:[i.jsx("span",{children:"+"}),i.jsx("span",{children:f})]}),l&&l.length>0&&i.jsx("div",{className:m("space-y-1"),children:l.map((E,D)=>i.jsx("p",{className:m("text-xs text-red-500"),children:E},D))})]})}}],Sh=[...Bx,...Ux,...Wx,...I1,...L1,...F1,...V1,...G1,...z1,...B1,...U1,...W1];function H1(){for(const e of Sh)vt.register(e)}const j1=["shortText","longText","multiLineInput","textEditor"],q1=["number","slider","rangeSlider"],Y1=["email","phone","url","location"],Q1=["password","signature","captcha"],K1=["singleChoice","multipleChoice","dropdown","tags","decisionBox","toggleSwitch"],R1=["singleChoiceMatrix","multipleChoiceMatrix","matrixTable"],X1=["date","time","dateTime","multipleDates","dateRange"],J1=["fileUpload","imageUpload","multiFileUpload","multiImageUpload"],Z1=["paragraph","image","link"],eE=[...j1,...q1,...Y1,...Q1,...K1,...R1,...X1,...J1,...Z1],bc={shortText:"Short Text",longText:"Long Text",multiLineInput:"Multi-line Input",textEditor:"Text Editor",number:"Number",slider:"Slider",rangeSlider:"Range Slider",email:"Email",phone:"Phone",url:"URL",location:"Location",password:"Password",signature:"Signature",captcha:"Captcha",singleChoice:"Single Choice",multipleChoice:"Multiple Choice",dropdown:"Dropdown",tags:"Tags",decisionBox:"Decision Box",toggleSwitch:"Toggle Switch",singleChoiceMatrix:"Single Choice Matrix",multipleChoiceMatrix:"Multiple Choice Matrix",matrixTable:"Matrix Table",date:"Date",time:"Time",dateTime:"Date & Time",multipleDates:"Multiple Dates",dateRange:"Date Range",fileUpload:"File Upload",imageUpload:"Image Upload",multiFileUpload:"Multi-File Upload",multiImageUpload:"Multi-Image Upload",paragraph:"Paragraph",image:"Image",link:"Link",formHeading:"Form Heading",sectionHeading:"Section Heading",subheading:"Subheading",divider:"Divider",spacer:"Spacer",group:"Group",grid:"Grid",table:"Table",repeatElement:"Repeat Element",repeatGroup:"Repeat Group",pages:"Pages (Wizard)",submit:"Submit Button"},gc={shortText:"📝",longText:"📄",multiLineInput:"📑",textEditor:"✏️",number:"🔢",slider:"🎚️",rangeSlider:"↔️",email:"✉️",phone:"📱",url:"🔗",location:"📍",password:"🔒",signature:"✍️",captcha:"🤖",singleChoice:"🔘",multipleChoice:"☑️",dropdown:"📋",tags:"🏷️",decisionBox:"✅",toggleSwitch:"🔀",singleChoiceMatrix:"📊",multipleChoiceMatrix:"📈",matrixTable:"📉",date:"📅",time:"⏰",dateTime:"📆",multipleDates:"🗓️",dateRange:"↔️",fileUpload:"📎",imageUpload:"🖼️",multiFileUpload:"📁",multiImageUpload:"🖼️",paragraph:"📃",image:"🏞️",link:"🔗",formHeading:"🏷️",sectionHeading:"📌",subheading:"📎",divider:"➖",spacer:"↕️",group:"📦",grid:"⊞",table:"📊",repeatElement:"🔄",repeatGroup:"🔁",pages:"📖",submit:"🚀"};function tE(e){return eE.includes(e)}const rE=["singleChoice","multipleChoice","dropdown","tags"],oE=["shortText","longText","multiLineInput","textEditor","number","slider","rangeSlider","email","phone","url","location","password","singleChoice","multipleChoice","dropdown","tags","decisionBox","date","time","dateTime","multipleDates","dateRange","fileUpload","imageUpload","multiFileUpload","multiImageUpload"],nE=["singleChoiceMatrix","multipleChoiceMatrix","matrixTable"];function aE(e){return rE.includes(e)}function sE(e){return oE.includes(e)}function lE(e){return nE.includes(e)}const Ms=({element:e,isSelected:t=!1})=>{const r=vt.get(e.type),o={element:e,properties:e.properties,layout:e.layout,validation:e.validation,logic:e.logic,config:e.config,isSelected:t,mode:"canvas"};if(r&&r.renderOnCanvas)try{return i.jsx(i.Fragment,{children:r.renderOnCanvas(o)})}catch(n){return console.error(`Error rendering element "${e.type}" on canvas:`,n),i.jsx(Os,{element:e,error:n})}return i.jsx(Os,{element:e})},Nh=({element:e,value:t,onChange:r,errors:o=[],formValues:n={},readOnly:a=!1,disabled:s=!1})=>{const l=vt.get(e.type),c={element:e,properties:e.properties,layout:e.layout,validation:e.validation,logic:e.logic,config:e.config,mode:"render",value:t,onChange:r,errors:o,formValues:n,readOnly:a,disabled:s};if(l&&l.render)try{return i.jsx(i.Fragment,{children:l.render(c)})}catch(d){return console.error(`Error rendering element "${e.type}":`,d),i.jsx(Os,{element:e,error:d})}return i.jsx(Os,{element:e})},Os=({element:e,error:t})=>{const r=gc[e.type]||"❓",o=bc[e.type]||e.type;return t?i.jsxs("div",{className:m("p-4 bg-red-50 border border-red-200 rounded text-red-600 text-sm"),children:[i.jsxs("div",{className:m("flex items-center gap-2"),children:[i.jsx("span",{children:"⚠️"}),i.jsxs("span",{children:["Error rendering: ",o]})]}),i.jsx("p",{className:m("text-xs mt-1 text-red-500"),children:t instanceof Error?t.message:"Unknown error"})]}):i.jsxs("div",{className:m("p-4 bg-gray-100 rounded text-gray-600 text-sm"),children:[i.jsxs("div",{className:m("flex items-center gap-2"),children:[i.jsx("span",{children:r}),i.jsx("span",{children:o})]}),i.jsx("p",{className:m("text-xs mt-1 text-gray-400"),children:"Element type not registered in the element registry"})]})};function iE(e){return vt.has(e)}function Eh(e){const t=vt.get(e);return t?t.icon:gc[e]}function yc(e){const t=vt.get(e);return t?t.label:bc[e]||e}function cE(e,t){return i.jsx(Ms,{element:e,isSelected:t})}function dE(e,t,r,o,n){return i.jsx(Nh,{element:e,value:t,onChange:r,errors:o,formValues:n})}const fr=C.forwardRef(({className:e,type:t,...r},o)=>i.jsx("input",{type:t,className:m("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:o,...r}));fr.displayName="Input";const kh=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ah=Qu,Is=(e,t)=>r=>{var o;if((t==null?void 0:t.variants)==null)return Ah(e,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:n,defaultVariants:a}=t,s=Object.keys(n).map(d=>{const p=r==null?void 0:r[d],u=a==null?void 0:a[d];if(p===null)return null;const f=kh(p)||kh(u);return n[d][f]}),l=r&&Object.entries(r).reduce((d,p)=>{let[u,f]=p;return f===void 0||(d[u]=f),d},{}),c=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((d,p)=>{let{class:u,className:f,...h}=p;return Object.entries(h).every(b=>{let[g,y]=b;return Array.isArray(y)?y.includes({...a,...l}[g]):{...a,...l}[g]===y})?[...d,u,f]:d},[]);return Ah(e,s,c,r==null?void 0:r.class,r==null?void 0:r.className)},uE=Is("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function vc({className:e,variant:t,...r}){return i.jsx("div",{className:m(uE({variant:t}),e),...r})}var fE=Object.defineProperty,wc=(e,t)=>fE(e,"name",{value:t,configurable:!0}),xc=!1;function _h(){const[e,t]=C.useState(xc);return C.useEffect(()=>{xc||(xc=!0,t(!0))},[]),e}wc(_h,"useIsHydrated");var Th=C[" useSyncExternalStore ".trim().toString()];function Dh(){return()=>{}}wc(Dh,"subscribe");function $h(){return Th(Dh,()=>!0,()=>!1)}wc($h,"useIsHydratedModern");var pE=typeof Th=="function"?$h:_h,hE=Object.defineProperty,Ho=(e,t)=>hE(e,"name",{value:t,configurable:!0}),Cc="rovingFocusGroup.onEntryFocus",mE={bubbles:!1,cancelable:!0},Ls="RovingFocusGroup",[Sc,Ph,bE]=ns(Ls),[gE,Mh]=ur(Ls,[bE]),[yE,vE]=gE(Ls),wE=C.forwardRef(Ho(function(t,r){return i.jsx(Sc.Provider,{scope:t.__scopeRovingFocusGroup,children:i.jsx(Sc.Slot,{scope:t.__scopeRovingFocusGroup,children:i.jsx(xE,{...t,ref:r})})})},"RovingFocusGroup")),xE=C.forwardRef(Ho(function(t,r){const{__scopeRovingFocusGroup:o,orientation:n,loop:a=!1,dir:s,currentTabStopId:l,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:p,preventScrollOnEntryFocus:u=!1,...f}=t,h=C.useRef(null),b=Re(r,h),g=Gn(s),[y,v]=Cr({prop:l,defaultProp:c??null,onChange:d,caller:Ls}),[S,x]=C.useState(!1),w=wr(p),N=Ph(o),k=C.useRef(!1),[_,E]=C.useState(0);return C.useEffect(()=>{const D=h.current;if(D)return D.addEventListener(Cc,w),()=>D.removeEventListener(Cc,w)},[w]),i.jsx(yE,{scope:o,orientation:n,dir:g,loop:a,currentTabStopId:y,onItemFocus:C.useCallback(D=>v(D),[v]),onItemShiftTab:C.useCallback(()=>x(!0),[]),onFocusableItemAdd:C.useCallback(()=>E(D=>D+1),[]),onFocusableItemRemove:C.useCallback(()=>E(D=>D-1),[]),children:i.jsx(Be.div,{tabIndex:S||_===0?-1:0,"data-orientation":n,...f,ref:b,style:{outline:"none",...t.style},onMouseDown:Pe(t.onMouseDown,()=>{k.current=!0}),onFocus:Pe(t.onFocus,D=>{const T=!k.current;if(D.target===D.currentTarget&&T&&!S){const O=new CustomEvent(Cc,mE);if(D.currentTarget.dispatchEvent(O),!O.defaultPrevented){const $=N().filter(Y=>Y.focusable),V=$.find(Y=>Y.active),G=$.find(Y=>Y.id===y),H=[V,G,...$].filter(Boolean).map(Y=>Y.ref.current);Nc(H,u)}}k.current=!1}),onBlur:Pe(t.onBlur,()=>x(!1))})})},"RovingFocusGroupImpl")),CE="RovingFocusGroupItem",SE=C.forwardRef(Ho(function(t,r){const{__scopeRovingFocusGroup:o,focusable:n=!0,active:a=!1,tabStopId:s,children:l,...c}=t,d=xr(),p=s||d,u=vE(CE,o),f=u.currentTabStopId===p,h=Ph(o),{onFocusableItemAdd:b,onFocusableItemRemove:g,currentTabStopId:y}=u,v=pE();return ut(()=>{if(!(!v||!n))return b(),()=>g()},[v,n,b,g]),C.useEffect(()=>{if(!(v||!n))return b(),()=>g()},[v,n,b,g]),i.jsx(Sc.ItemSlot,{scope:o,id:p,focusable:n,active:a,children:i.jsx(Be.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...c,ref:r,onMouseDown:Pe(t.onMouseDown,S=>{n?u.onItemFocus(p):S.preventDefault()}),onFocus:Pe(t.onFocus,()=>u.onItemFocus(p)),onKeyDown:Pe(t.onKeyDown,S=>{if(S.key==="Tab"&&S.shiftKey){u.onItemShiftTab();return}if(S.target!==S.currentTarget)return;const x=Ih(S,u.orientation,u.dir);if(x!==void 0){if(S.metaKey||S.ctrlKey||S.altKey||S.shiftKey)return;S.preventDefault();let N=h().filter(k=>k.focusable).map(k=>k.ref.current);if(x==="last")N.reverse();else if(x==="prev"||x==="next"){x==="prev"&&N.reverse();const k=N.indexOf(S.currentTarget);N=u.loop?Lh(N,k+1):N.slice(k+1)}setTimeout(()=>Nc(N))}}),children:typeof l=="function"?l({isCurrentTabStop:f,hasTabStop:y!=null}):l})})},"RovingFocusGroupItem")),NE={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Oh(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}Ho(Oh,"getDirectionAwareKey");function Ih(e,t,r){const o=Oh(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return NE[o]}Ho(Ih,"getFocusIntent");function Nc(e,t=!1){const r=document.activeElement;for(const o of e)if(o===r||(o.focus({preventScroll:t}),document.activeElement!==r))return}Ho(Nc,"focusFirst");function Lh(e,t){return e.map((r,o)=>e[(t+o)%e.length])}Ho(Lh,"wrapArray");var EE=wE,kE=SE,AE=Object.defineProperty,wn=(e,t)=>AE(e,"name",{value:t,configurable:!0}),Ec="Tabs",[_E,EM]=ur(Ec,[Mh]),Fh=Mh(),[TE,kc]=_E(Ec),DE=C.forwardRef(wn(function(t,r){const{__scopeTabs:o,value:n,onValueChange:a,defaultValue:s,orientation:l="horizontal",dir:c,activationMode:d="automatic",...p}=t,u=Gn(c),[f,h]=Cr({prop:n,onChange:a,defaultProp:s??"",caller:Ec});return i.jsx(TE,{scope:o,baseId:xr(),value:f,onValueChange:h,orientation:l,dir:u,activationMode:d,children:i.jsx(Be.div,{dir:u,"data-orientation":l,...p,ref:r})})},"Tabs")),$E="TabsList",PE=C.forwardRef(wn(function(t,r){const{__scopeTabs:o,loop:n=!0,...a}=t,s=kc($E,o),l=Fh(o);return i.jsx(EE,{asChild:!0,...l,orientation:s.orientation,dir:s.dir,loop:n,children:i.jsx(Be.div,{role:"tablist","aria-orientation":s.orientation,...a,ref:r})})},"TabsList")),ME="TabsTrigger",OE=C.forwardRef(wn(function(t,r){const{__scopeTabs:o,value:n,disabled:a=!1,...s}=t,l=kc(ME,o),c=Fh(o),d=Ac(l.baseId,n),p=_c(l.baseId,n),u=n===l.value;return i.jsx(kE,{asChild:!0,...c,focusable:!a,active:u,children:i.jsx(Be.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":p,"data-state":u?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...s,ref:r,onMouseDown:Pe(t.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:Pe(t.onKeyDown,f=>{a||f.target!==f.currentTarget||[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:Pe(t.onFocus,()=>{const f=l.activationMode!=="manual";!u&&!a&&f&&l.onValueChange(n)})})})},"TabsTrigger")),IE="TabsContent",LE=C.forwardRef(wn(function(t,r){const{__scopeTabs:o,value:n,forceMount:a,children:s,...l}=t,c=kc(IE,o),d=Ac(c.baseId,n),p=_c(c.baseId,n),u=n===c.value,f=C.useRef(u);return C.useEffect(()=>{const h=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(h)},[]),i.jsx(ro,{present:a||u,children:({present:h})=>i.jsx(Be.div,{"data-state":u?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!h,id:p,tabIndex:0,...l,ref:r,style:{...t.style,animationDuration:f.current?"0s":void 0},children:h&&s})})},"TabsContent"));function Ac(e,t){return`${e}-trigger-${t}`}wn(Ac,"makeTriggerId");function _c(e,t){return`${e}-content-${t}`}wn(_c,"makeContentId");var FE=DE,Vh=PE,Gh=OE,zh=LE;const Bh=FE,Tc=C.forwardRef(({className:e,...t},r)=>i.jsx(Vh,{ref:r,className:m("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));Tc.displayName=Vh.displayName;const Qn=C.forwardRef(({className:e,...t},r)=>i.jsx(Gh,{ref:r,className:m("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));Qn.displayName=Gh.displayName;const Kn=C.forwardRef(({className:e,...t},r)=>i.jsx(zh,{ref:r,className:m("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Kn.displayName=zh.displayName;var VE=Object.defineProperty,Rn=(e,t)=>VE(e,"name",{value:t,configurable:!0}),Dc="Collapsible",[GE,Uh]=ur(Dc),[zE,$c]=GE(Dc),BE=C.forwardRef(Rn(function(t,r){const{__scopeCollapsible:o,open:n,defaultOpen:a,disabled:s,onOpenChange:l,...c}=t,[d,p]=Cr({prop:n,defaultProp:a??!1,onChange:l,caller:Dc});return i.jsx(zE,{scope:o,disabled:s,contentId:xr(),open:d,onOpenToggle:C.useCallback(()=>p(u=>!u),[p]),children:i.jsx(Be.div,{"data-state":Fs(d),"data-disabled":s?"":void 0,...c,ref:r})})},"Collapsible")),UE="CollapsibleTrigger",Wh=C.forwardRef(Rn(function(t,r){const{__scopeCollapsible:o,...n}=t,a=$c(UE,o);return i.jsx(Be.button,{type:"button","aria-controls":a.open?a.contentId:void 0,"aria-expanded":a.open||!1,"data-state":Fs(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:r,onClick:Pe(t.onClick,a.onOpenToggle)})},"CollapsibleTrigger")),Hh="CollapsibleContent",jh=C.forwardRef(Rn(function(t,r){const{forceMount:o,...n}=t,a=$c(Hh,t.__scopeCollapsible);return i.jsx(ro,{present:o||a.open,children:({present:s})=>i.jsx(WE,{...n,ref:r,present:s})})},"CollapsibleContent")),WE=C.forwardRef(Rn(function(t,r){const{__scopeCollapsible:o,present:n,children:a,...s}=t,l=$c(Hh,o),[c,d]=C.useState(n),p=C.useRef(null),u=Re(r,p),f=C.useRef(0),h=f.current,b=C.useRef(0),g=b.current,y=l.open||c,v=C.useRef(y),S=C.useRef(void 0);return C.useEffect(()=>{const x=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(x)},[]),ut(()=>{const x=p.current;if(x){S.current=S.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const w=x.getBoundingClientRect();f.current=w.height,b.current=w.width,v.current||(x.style.transitionDuration=S.current.transitionDuration,x.style.animationName=S.current.animationName),d(n)}},[l.open,n]),i.jsx(Be.div,{"data-state":Fs(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!y,...s,ref:u,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...t.style},children:y&&a})},"CollapsibleContentImpl"));function Fs(e){return e?"open":"closed"}Rn(Fs,"getState");var qh=BE,HE=Wh,jE=jh;const Yh=qh,Qh=Wh,Kh=jh,qE=Is("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),st=C.forwardRef(({className:e,variant:t,size:r,asChild:o=!1,...n},a)=>{const s=o?Jx:"button";return i.jsx(s,{className:m(qE({variant:t,size:r,className:e})),ref:a,...n})});st.displayName="Button";var YE=Object.defineProperty,$t=(e,t)=>YE(e,"name",{value:t,configurable:!0}),[Pc,kM]=ur("Tooltip",[vs]),Mc=vs(),QE="TooltipProvider",KE=700,Oc="tooltip.open",[RE,Ic]=Pc(QE),XE=$t(e=>{const{__scopeTooltip:t,delayDuration:r=KE,skipDelayDuration:o=300,disableHoverableContent:n=!1,children:a}=e,s=C.useRef(!0),l=C.useRef(!1),c=C.useRef(0);return C.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),i.jsx(RE,{scope:t,isOpenDelayedRef:s,delayDuration:r,onOpen:C.useCallback(()=>{o<=0||(window.clearTimeout(c.current),s.current=!1)},[o]),onClose:C.useCallback(()=>{o<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>s.current=!0,o))},[o]),isPointerInTransitRef:l,onPointerInTransitChange:C.useCallback(d=>{l.current=d},[]),disableHoverableContent:n,children:a})},"TooltipProvider"),Lc="Tooltip",[JE,Xn]=Pc(Lc),ZE=$t(e=>{const{__scopeTooltip:t,children:r,open:o,defaultOpen:n,onOpenChange:a,disableHoverableContent:s,delayDuration:l}=e,c=Ic(Lc,e.__scopeTooltip),d=Mc(t),[p,u]=C.useState(null),[f,h]=C.useState(void 0),b=xr(),g=C.useRef(0),y=s??c.disableHoverableContent,v=l??c.delayDuration,S=C.useRef(!1),[x,w]=Cr({prop:o,defaultProp:n??!1,onChange:$t(T=>{T?(c.onOpen(),document.dispatchEvent(new CustomEvent(Oc))):c.onClose(),a==null||a(T)},"onChange"),caller:Lc}),N=C.useMemo(()=>x?S.current?"delayed-open":"instant-open":"closed",[x]),k=C.useCallback(()=>{window.clearTimeout(g.current),g.current=0,S.current=!1,w(!0)},[w]),_=C.useCallback(()=>{window.clearTimeout(g.current),g.current=0,w(!1)},[w]),E=C.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{S.current=!0,w(!0),g.current=0},v)},[v,w]);C.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]);const D=f??b;return i.jsx(Cp,{...d,children:i.jsx(JE,{scope:t,contentId:D,setContentId:h,open:x,stateAttribute:N,trigger:p,onTriggerChange:u,onTriggerEnter:C.useCallback(()=>{c.isOpenDelayedRef.current?E():k()},[c.isOpenDelayedRef,E,k]),onTriggerLeave:C.useCallback(()=>{y?_():(window.clearTimeout(g.current),g.current=0)},[_,y]),onOpen:k,onClose:_,disableHoverableContent:y,children:r})})},"Tooltip"),Rh="TooltipTrigger",ek=C.forwardRef($t(function(t,r){const{__scopeTooltip:o,...n}=t,a=Xn(Rh,o),s=Ic(Rh,o),l=Mc(o),c=C.useRef(null),d=Re(r,c,a.onTriggerChange),p=C.useRef(!1),u=C.useRef(!1),f=C.useCallback(()=>p.current=!1,[]);return C.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),i.jsx(Sp,{asChild:!0,...l,children:i.jsx(Be.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:d,onPointerMove:Pe(t.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:Pe(t.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:Pe(t.onPointerDown,()=>{a.open&&a.onClose(),p.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Pe(t.onFocus,()=>{p.current||a.onOpen()}),onBlur:Pe(t.onBlur,a.onClose),onClick:Pe(t.onClick,a.onClose)})})},"TooltipTrigger")),Xh="TooltipPortal",[tk,rk]=Pc(Xh,{forceMount:void 0}),ok=$t(e=>{const{__scopeTooltip:t,forceMount:r,children:o,container:n}=e,a=Xn(Xh,t);return i.jsx(tk,{scope:t,forceMount:r,children:i.jsx(ro,{present:r||a.open,children:i.jsx(tc,{asChild:!0,container:n,children:o})})})},"TooltipPortal"),Jn="TooltipContent",nk=C.forwardRef($t(function(t,r){const o=rk(Jn,t.__scopeTooltip),{forceMount:n=o.forceMount,side:a="top",...s}=t,l=Xn(Jn,t.__scopeTooltip);return i.jsx(ro,{present:n||l.open,children:l.disableHoverableContent?i.jsx(Jh,{side:a,...s,ref:r}):i.jsx(ak,{side:a,...s,ref:r})})},"TooltipContent")),ak=C.forwardRef($t(function(t,r){const o=Xn(Jn,t.__scopeTooltip),n=Ic(Jn,t.__scopeTooltip),a=C.useRef(null),s=Re(r,a),[l,c]=C.useState(null),{trigger:d,onClose:p}=o,u=a.current,{onPointerInTransitChange:f}=n,h=C.useCallback(()=>{c(null),f(!1)},[f]),b=C.useCallback((g,y)=>{const v=g.currentTarget,S={x:g.clientX,y:g.clientY},x=Zh(S,v.getBoundingClientRect()),w=em(S,x),N=tm(y.getBoundingClientRect()),k=om([...w,...N]);c(k),f(!0)},[f]);return C.useEffect(()=>()=>h(),[h]),C.useEffect(()=>{if(d&&u){const g=$t(v=>b(v,u),"handleTriggerLeave"),y=$t(v=>b(v,d),"handleContentLeave");return d.addEventListener("pointerleave",g),u.addEventListener("pointerleave",y),()=>{d.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",y)}}},[d,u,b,h]),C.useEffect(()=>{if(l){const g=$t(y=>{const v=y.target,S={x:y.clientX,y:y.clientY},x=(d==null?void 0:d.contains(v))||(u==null?void 0:u.contains(v)),w=!rm(S,l);x?h():w&&(h(),p())},"handleTrackPointerGrace");return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,l,p,h]),i.jsx(Jh,{...t,ref:s})},"TooltipContentHoverable")),sk=Ef("TooltipContent"),Jh=C.forwardRef($t(function(t,r){const{__scopeTooltip:o,children:n,"aria-label":a,id:s,onEscapeKeyDown:l,onPointerDownOutside:c,...d}=t,p=Xn(Jn,o),u=Mc(o),{onClose:f}=p;C.useEffect(()=>(document.addEventListener(Oc,f),()=>document.removeEventListener(Oc,f)),[f]),C.useEffect(()=>{if(p.trigger){const b=$t(g=>{g.target instanceof Node&&g.target.contains(p.trigger)&&f()},"handleScroll");return window.addEventListener("scroll",b,{capture:!0}),()=>window.removeEventListener("scroll",b,{capture:!0})}},[p.trigger,f]);const{setContentId:h}=p;return ut(()=>(h(s),()=>{h(void 0)}),[s,h]),i.jsx(Mi,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:b=>b.preventDefault(),onDismiss:f,children:i.jsxs(Np,{"data-state":p.stateAttribute,role:a?void 0:"tooltip",id:a?void 0:p.contentId,...u,...d,ref:r,style:{...d.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[i.jsx(sk,{children:n}),a?i.jsx(JS,{id:p.contentId,role:"tooltip",children:a}):null]})})},"TooltipContentImpl"));function Zh(e,t){const r=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),n=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(r,o,n,a)){case a:return"left";case n:return"right";case r:return"top";case o:return"bottom";default:throw new Error("unreachable")}}$t(Zh,"getExitSideFromRect");function em(e,t,r=5){const o=[];switch(t){case"top":o.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":o.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":o.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":o.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return o}$t(em,"getPaddedExitPoints");function tm(e){const{top:t,right:r,bottom:o,left:n}=e;return[{x:n,y:t},{x:r,y:t},{x:r,y:o},{x:n,y:o}]}$t(tm,"getPointsFromRect");function rm(e,t){const{x:r,y:o}=e;let n=!1;for(let a=0,s=t.length-1;a<t.length;s=a++){const l=t[a],c=t[s],d=l.x,p=l.y,u=c.x,f=c.y;p>o!=f>o&&r<(u-d)*(o-p)/(f-p)+d&&(n=!n)}return n}$t(rm,"isPointInPolygon");function om(e){const t=e.slice();return t.sort((r,o)=>r.x<o.x?-1:r.x>o.x?1:r.y<o.y?-1:r.y>o.y?1:0),nm(t)}$t(om,"getHull");function nm(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const n=e[o];for(;t.length>=2;){const a=t[t.length-1],s=t[t.length-2];if((a.x-s.x)*(n.y-s.y)>=(a.y-s.y)*(n.x-s.x))t.pop();else break}t.push(n)}t.pop();const r=[];for(let o=e.length-1;o>=0;o--){const n=e[o];for(;r.length>=2;){const a=r[r.length-1],s=r[r.length-2];if((a.x-s.x)*(n.y-s.y)>=(a.y-s.y)*(n.x-s.x))r.pop();else break}r.push(n)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}$t(nm,"getHullPresorted");var lk=XE,ik=ZE,ck=ek,dk=ok,am=nk;const Vs=lk,Fr=ik,Vr=ck,Nr=C.forwardRef(({className:e,sideOffset:t=4,...r},o)=>i.jsx(dk,{children:i.jsx(am,{ref:o,sideOffset:t,className:m("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",e),...r})}));Nr.displayName=am.displayName;const Fc=C.forwardRef(({className:e,children:t,...r},o)=>i.jsx("div",{ref:o,className:m("relative overflow-hidden",e),...r,children:i.jsx("div",{className:m("h-full w-full overflow-auto rounded-[inherit]"),children:t})}));Fc.displayName="ScrollArea";const uk=C.forwardRef(({className:e,orientation:t="vertical",...r},o)=>i.jsx("div",{ref:o,className:m("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...r,children:i.jsx("div",{className:m("relative flex-1 rounded-full bg-border")})}));uk.displayName="ScrollBar";function sm(e){return{order:99,disabled:!1,hidden:!1,...e}}function fk(e){return e.map((t,r)=>sm({...t,order:t.order??100+r}))}function lm(e,t){return typeof e.disabled=="function"?e.disabled(t):e.disabled??!1}function im(e,t){return typeof e.hidden=="function"?e.hidden(t):e.hidden??!1}const pk=({element:e,onAddElement:t,isDisabled:r=!1,disabledReason:o,wizardExists:n=!1})=>{const a=ie(u=>u.setDraggedElementType),s=u=>{if(r){u.preventDefault();return}u.dataTransfer.setData("elementType",e.type),u.dataTransfer.effectAllowed="copy",a(e.type)},l=()=>{a(null)},c=()=>{r||t(e.type)},d=()=>{if(typeof e.icon=="string")return i.jsx("span",{className:m("text-lg flex-shrink-0"),children:e.icon});const u=e.icon;return i.jsx(u,{className:m("w-5 h-5 flex-shrink-0")})},p=i.jsxs("div",{draggable:!r,onDragStart:s,onDragEnd:l,onClick:c,className:m("flex items-center gap-2 p-2 bg-card border border-border rounded-md transition-all duration-150 select-none",r?"opacity-50 cursor-not-allowed":"cursor-grab hover:border-primary hover:shadow-sm active:cursor-grabbing"),children:[d(),i.jsxs("div",{className:m("flex-1 min-w-0"),children:[i.jsx("div",{className:m("text-xs font-medium text-foreground truncate"),children:e.label}),r&&i.jsx("div",{className:m("text-xs text-orange-500 truncate"),children:"Already added"})]})]});return r&&o?i.jsx(Vs,{children:i.jsxs(Fr,{children:[i.jsx(Vr,{asChild:!0,children:p}),i.jsx(Nr,{children:i.jsx("p",{children:o})})]})}):i.jsx(Vs,{children:i.jsxs(Fr,{children:[i.jsx(Vr,{asChild:!0,children:p}),i.jsx(Nr,{children:i.jsxs("div",{className:m("max-w-xs"),children:[i.jsx("p",{className:m("font-medium"),children:e.label}),i.jsx("p",{className:m("text-xs text-muted-foreground"),children:e.description}),i.jsx("p",{className:m("text-xs mt-1 text-muted-foreground/70"),children:n?"Drag into wizard step":"Drag or click to add"})]})})]})})},cm=({label:e,elements:t,searchQuery:r,onAddElement:o,defaultExpanded:n=!1,hasWizard:a=!1,wizardExists:s=!1})=>{const[l,c]=P.useState(n),d=P.useMemo(()=>{if(!r.trim())return t;const u=r.toLowerCase();return t.filter(f=>f.label.toLowerCase().includes(u)||f.description.toLowerCase().includes(u)||f.searchKeywords&&f.searchKeywords.some(h=>h.toLowerCase().includes(u)))},[t,r]);if(r&&d.length===0)return null;const p=r?!0:l;return i.jsxs(Yh,{open:p,onOpenChange:c,className:m("mb-2"),children:[i.jsx(Qh,{asChild:!0,children:i.jsxs(st,{variant:"ghost",className:m("w-full flex items-center justify-between px-2 py-1.5 h-auto text-xs font-semibold text-muted-foreground uppercase tracking-wider hover:bg-muted"),children:[i.jsx("span",{children:e}),i.jsxs("span",{className:m("flex items-center gap-1"),children:[i.jsx(vc,{variant:"secondary",className:m("font-normal normal-case text-xs"),children:d.length}),i.jsx(vn,{className:m("h-4 w-4 transition-transform",p&&"rotate-180")})]})]})}),i.jsx(Kh,{children:i.jsx("div",{className:m("grid grid-cols-2 gap-1.5 mt-1.5"),children:d.map(u=>i.jsx(pk,{element:u,onAddElement:o,isDisabled:u.type==="pages"&&a,disabledReason:"Only one wizard can be added per form",wizardExists:s},u.type))})})]})},dm=({searchQuery:e,elements:t})=>t.some(o=>o.label.toLowerCase().includes(e.toLowerCase())||o.description.toLowerCase().includes(e.toLowerCase())||o.searchKeywords&&o.searchKeywords.some(n=>n.toLowerCase().includes(e.toLowerCase())))?null:i.jsxs("div",{className:m("text-center py-8 text-muted-foreground text-sm"),children:[i.jsx("div",{className:m("text-3xl mb-2"),children:"🔍"}),i.jsxs("p",{children:['No elements found for "',e,'"']}),i.jsx("p",{className:m("text-xs mt-1 text-muted-foreground/70"),children:"Try a different search term"})]}),hk=({sidebarTabs:e=[]})=>{const[t,r]=P.useState("fields"),[o,n]=P.useState(""),a=ie(T=>T.addElement),s=ie(T=>T.hasWizard),l=ie(T=>T.schema),c=ie(T=>T.mode),d=ie(T=>T.loadSchema),p=ie(T=>T.exportSchema),u=ie(T=>T.resetForm),f=ie(T=>T.updateFormTitle),h=ie(T=>T.updateFormDescription),b=ie(T=>T.updateElement),g=ie(T=>T.deleteElement),y=ie(T=>T.selectElement),v=ie(T=>T.setMode),S=T=>{x&&T!=="pages"||a(T)},x=s(),w=P.useMemo(()=>{const T=vt.getGroups(),O=T.filter(V=>V.elements.some(G=>G.category==="field")),$=T.filter(V=>V.elements.some(G=>G.category==="page"));return{fieldGroups:O,pageGroups:$}},[]),N=P.useMemo(()=>vt.getByCategory("field"),[]),k=P.useMemo(()=>vt.getByCategory("page"),[]),_=["textInput","selection","heading","layout","special"],E=P.useMemo(()=>({schema:l,mode:c,actions:{addElement:a,loadSchema:d,exportSchema:p,resetForm:u,updateFormTitle:f,updateFormDescription:h,updateElement:b,deleteElement:g,selectElement:y,setMode:v}}),[l,c,a,d,p,u,f,h,b,g,y,v]),D=P.useMemo(()=>e.length?[...e].filter(T=>!im(T,E)).sort((T,O)=>(T.order??99)-(O.order??99)):[],[e,E]);return i.jsxs("div",{className:m("w-72 bg-muted/50 border-r border-border flex flex-col h-full flex-shrink-0"),children:[x&&i.jsx("div",{className:m("p-2 bg-orange-50 border-b border-orange-200"),children:i.jsxs("div",{className:m("flex items-start gap-2 text-xs text-orange-700"),children:[i.jsx("span",{className:m("text-base"),children:"📑"}),i.jsxs("div",{children:[i.jsx("p",{className:m("font-medium"),children:"Wizard Mode Active"}),i.jsx("p",{className:m("text-orange-600"),children:"Drop elements inside wizard steps, not on the main canvas."})]})]})}),i.jsx("div",{className:m("p-3 border-b border-border bg-card"),children:i.jsxs("div",{className:m("relative"),children:[i.jsx(k1,{className:m("absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground")}),i.jsx(fr,{type:"text",placeholder:"Search elements...",value:o,onChange:T=>n(T.target.value),className:m("pl-9 pr-8")}),o&&i.jsx(st,{variant:"ghost",size:"icon",className:m("absolute right-1 top-1/2 -translate-y-1/2 h-6 w-6"),onClick:()=>n(""),children:i.jsx(Hn,{className:m("h-4 w-4")})})]})}),i.jsxs(Bh,{value:t,onValueChange:r,className:m("flex-1 flex flex-col min-h-0 overflow-hidden"),children:[i.jsx(Fc,{"aria-disabled":!0,children:i.jsxs(Tc,{className:m("w-full rounded-none border-b border-border bg-card h-auto p-0 flex-shrink-0"),children:[i.jsxs(Qn,{value:"fields",className:m("flex-1 rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-primary/5 py-2.5"),children:["Fields (",N.length,")"]}),i.jsxs(Qn,{value:"pages",className:m("flex-1 rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-primary/5 py-2.5"),children:["Page (",k.length,")"]}),D.map(T=>{const O=T.icon;return i.jsxs(Qn,{value:T.id,className:m("flex-1 rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-primary/5 py-2.5"),disabled:lm(T,E),children:[O&&i.jsx(O,{className:m("h-3.5 w-3.5 mr-1")}),T.label]},T.id)})]})}),i.jsxs("div",{className:m("flex-1 min-h-0 relative"),children:[i.jsx(Kn,{value:"fields",className:m("absolute inset-0 mt-0 data-[state=inactive]:hidden overflow-auto"),children:i.jsxs("div",{className:m("p-3"),children:[w.fieldGroups.map(T=>i.jsx(cm,{label:T.label,elements:T.elements.filter(O=>O.category==="field"),searchQuery:o,onAddElement:S,defaultExpanded:_.includes(T.id),wizardExists:x},T.id)),o&&i.jsx(dm,{searchQuery:o,elements:N})]})}),i.jsx(Kn,{value:"pages",className:m("absolute inset-0 mt-0 data-[state=inactive]:hidden overflow-auto"),children:i.jsxs("div",{className:m("p-3"),children:[w.pageGroups.map(T=>i.jsx(cm,{label:T.label,elements:T.elements.filter(O=>O.category==="page"),searchQuery:o,onAddElement:S,defaultExpanded:_.includes(T.id),hasWizard:x,wizardExists:x},T.id)),o&&i.jsx(dm,{searchQuery:o,elements:k})]})}),D.map(T=>{const O=T.content;return i.jsx(Kn,{value:T.id,className:m("absolute inset-0 mt-0 data-[state=inactive]:hidden overflow-auto"),children:i.jsx(O,{...E})},T.id)})]})]})]})},mk=["shortText","longText","multiLineInput","textEditor","number","slider","rangeSlider","email","phone","url","location","password","signature","captcha","singleChoice","multipleChoice","dropdown","tags","decisionBox","toggleSwitch","singleChoiceMatrix","multipleChoiceMatrix","matrixTable","date","time","dateTime","multipleDates","dateRange","fileUpload","imageUpload","multiFileUpload","multiImageUpload","paragraph","image","link","formHeading","sectionHeading","subheading","divider","spacer","group","grid","table","repeatElement","repeatGroup","pages","submit"];function bk(e){const t=[];if(!e||typeof e!="object")return t.push({type:"error",message:"Schema must be a valid object"}),{valid:!1,errors:t};const r=e;if((!r.id||typeof r.id!="string")&&t.push({type:"error",message:'Schema must have a valid "id" field (string)'}),(!r.version||typeof r.version!="string")&&t.push({type:"error",message:'Schema must have a valid "version" field (string)'}),(!r.title||typeof r.title!="string")&&t.push({type:"error",message:'Schema must have a valid "title" field (string)'}),!Array.isArray(r.elements))return t.push({type:"error",message:'Schema must have an "elements" array'}),{valid:!1,errors:t};const o=new Set,n=new Map;r.elements.forEach((l,c)=>{const d=gk(l,c,o,n);t.push(...d)}),n.forEach((l,c)=>{l.length>1&&t.push({type:"error",message:`Duplicate field name "${c}" found in elements: ${l.join(", ")}`})});const a=new Set(o);return r.elements.forEach(l=>{if(l&&l.logic){const c=vk(l,a);t.push(...c)}}),r.elements.length===0&&t.push({type:"warning",message:"Schema has no elements"}),!r.elements.some(l=>l&&l.type==="submit")&&r.elements.length>0&&t.push({type:"warning",message:"Schema has no submit button"}),{valid:t.filter(l=>l.type==="error").length===0,errors:t}}function gk(e,t,r,o){const n=[],a=`Element at index ${t}`;if(!e||typeof e!="object")return n.push({type:"error",message:`${a}: Must be a valid object`}),n;const s=e;if(!s.id||typeof s.id!="string"?n.push({type:"error",message:`${a}: Must have a valid "id" field (string)`}):(r.has(s.id)&&n.push({type:"error",message:`${a}: Duplicate element ID "${s.id}"`}),r.add(s.id)),!s.type||typeof s.type!="string"?n.push({type:"error",message:`${a}: Must have a valid "type" field (string)`}):mk.includes(s.type)||n.push({type:"error",message:`${a}: Invalid element type "${s.type}"`}),typeof s.order!="number"&&n.push({type:"warning",elementId:s.id,message:`${a}: Missing or invalid "order" field`}),(!s.properties||typeof s.properties!="object")&&n.push({type:"warning",elementId:s.id,message:`${a}: Missing "properties" object`}),(!s.layout||typeof s.layout!="object")&&n.push({type:"warning",elementId:s.id,message:`${a}: Missing "layout" object`}),!s.attributes||typeof s.attributes!="object")n.push({type:"warning",elementId:s.id,message:`${a}: Missing "attributes" object`});else{const c=s.attributes;if(!c.name||typeof c.name!="string")n.push({type:"error",elementId:s.id,message:`${a}: Missing or invalid "attributes.name" field`});else{const d=o.get(c.name)||[];d.push(s.id),o.set(c.name,d)}}const l=yk(s);return n.push(...l),n}function yk(e){const t=[],r=e.type,o=e.config,n=e.id;return["singleChoice","multipleChoice","dropdown","tags"].includes(r)&&(!(o!=null&&o.options)||!Array.isArray(o.options)?t.push({type:"warning",elementId:n,message:`${r} element should have config.options array`}):o.options.length===0?t.push({type:"warning",elementId:n,message:`${r} element has no options defined`}):o.options.forEach((l,c)=>{if(!l||typeof l!="object")t.push({type:"error",elementId:n,message:`${r} option at index ${c} is invalid`});else{const d=l;(typeof d.label!="string"||typeof d.value!="string")&&t.push({type:"warning",elementId:n,message:`${r} option at index ${c} should have label and value strings`})}})),["singleChoiceMatrix","multipleChoiceMatrix","matrixTable"].includes(r)&&((!(o!=null&&o.matrixRows)||!Array.isArray(o.matrixRows))&&t.push({type:"warning",elementId:n,message:`${r} element should have config.matrixRows array`}),(!(o!=null&&o.matrixColumns)||!Array.isArray(o.matrixColumns))&&t.push({type:"warning",elementId:n,message:`${r} element should have config.matrixColumns array`})),r==="pages"&&(!(o!=null&&o.pagesList)||!Array.isArray(o.pagesList))&&t.push({type:"warning",elementId:n,message:"pages element should have config.pagesList array"}),(r==="slider"||r==="rangeSlider")&&o&&typeof o.min=="number"&&typeof o.max=="number"&&o.min>=o.max&&t.push({type:"error",elementId:n,message:`${r} min value must be less than max value`}),t}function vk(e,t){var a,s,l,c;const r=[],o=e.logic;if(!o)return r;const n=(d,p)=>{d&&d.forEach((u,f)=>{u.field?t.has(u.field)||r.push({type:"warning",elementId:e.id,message:`${p} rule ${f+1}: References unknown field "${u.field}"`}):r.push({type:"warning",elementId:e.id,message:`${p} rule ${f+1}: Missing field reference`}),u.operator||r.push({type:"warning",elementId:e.id,message:`${p} rule ${f+1}: Missing operator`})})};return(a=o.showWhen)!=null&&a.rules&&n(o.showWhen.rules,"showWhen"),(s=o.hideWhen)!=null&&s.rules&&n(o.hideWhen.rules,"hideWhen"),(l=o.requireWhen)!=null&&l.rules&&n(o.requireWhen.rules,"requireWhen"),(c=o.disableWhen)!=null&&c.rules&&n(o.disableWhen.rules,"disableWhen"),r}function wk(e){let t;try{t=JSON.parse(e)}catch(o){return{schema:null,validation:{valid:!1,errors:[{type:"error",message:`Invalid JSON: ${o.message}`}]}}}const r=bk(t);return{schema:r.valid?t:null,validation:r}}function xk(e){var r;const t=JSON.parse(JSON.stringify(e));return t.id||(t.id=((r=crypto.randomUUID)==null?void 0:r.call(crypto))||`form_${Date.now()}`),t.version||(t.version="1.0"),t.title||(t.title="Untitled Form"),Array.isArray(t.elements)||(t.elements=[]),t.metadata||(t.metadata={createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}),t.elements=t.elements.map((o,n)=>{var a;return o.id||(o.id=((a=crypto.randomUUID)==null?void 0:a.call(crypto))||`element_${Date.now()}_${n}`),typeof o.order!="number"&&(o.order=n),o.properties||(o.properties={}),o.layout||(o.layout={}),o.attributes||(o.attributes={name:`field_${n}`}),o.attributes.name||(o.attributes.name=`field_${n}`),o}),t.elements.forEach((o,n)=>{o.order=n}),t}function Ck(e){if(e.valid&&e.errors.length===0)return"Schema is valid.";const t=e.errors.filter(n=>n.type==="error").length,r=e.errors.filter(n=>n.type==="warning").length;let o="";return t>0&&(o+=`${t} error${t!==1?"s":""}`),r>0&&(o&&(o+=", "),o+=`${r} warning${r!==1?"s":""}`),o}function um(e){return{order:0,variant:"ghost",disabled:!1,hidden:!1,...e}}function Sk(e){return e.map((t,r)=>um({...t,order:t.order??r}))}function fm(e,t){return typeof e.disabled=="function"?e.disabled(t):e.disabled??!1}function Vc(e,t){return typeof e.hidden=="function"?e.hidden(t):e.hidden??!1}class Nk{constructor(){ni(this,"modes",new Map)}register(t){if(!t.id)throw new Error("Mode definition must have an id");if(!t.label)throw new Error(`Mode "${t.id}" must have a label`);if(!t.icon)throw new Error(`Mode "${t.id}" must have an icon`);if(!t.renderContent)throw new Error(`Mode "${t.id}" must have a renderContent function`);if(this.modes.has(t.id)){console.warn(`Mode "${t.id}" is already registered. Use modeRegistry.unregister("${t.id}") first or manage registration order.`);return}this.modes.set(t.id,t)}get(t){return this.modes.get(t)}has(t){return this.modes.has(t)}getAll(){return Array.from(this.modes.values()).sort((t,r)=>(t.order??50)-(r.order??50))}getVisible(){return this.getAll().filter(t=>!t.hidden)}unregister(t){return this.modes.delete(t)}clear(){this.modes.clear()}}const tr=new Nk;function Ek(e){tr.register(e)}function kk(e){for(const t of e)tr.register(t)}function Ak(e){return tr.unregister(e)}function _k(e){return tr.get(e)}function Tk(e){return tr.has(e)}const jo=({action:e,context:t})=>{const r=e.icon,o=fm(e,t),n=async()=>{o||await e.onClick(t)},a=m(e.variant==="destructive"?"text-destructive hover:text-destructive hover:bg-destructive/10":"");return i.jsxs(Fr,{children:[i.jsx(Vr,{asChild:!0,children:i.jsx(st,{variant:"ghost",size:"icon",onClick:n,disabled:o,className:a,children:i.jsx(r,{className:m("h-5 w-5")})})}),i.jsx(Nr,{children:i.jsx("p",{children:e.label})})]})},Dk=({schema:e,canUndo:t,canRedo:r,onUndo:o,onRedo:n,onExport:a,exportSchema:s,onImport:l,onReset:c,mode:d,onModeChange:p,toolbarConfig:u})=>{const f=P.useRef(null),h=P.useMemo(()=>({schema:e,mode:d,canUndo:t,canRedo:r,actions:{undo:o,redo:n,loadSchema:l,exportSchema:s,setMode:p,resetForm:c}}),[e,d,t,r,o,n,l,s,p,c]),b=()=>{var k;(k=f.current)==null||k.click()},g=k=>{var E;const _=(E=k.target.files)==null?void 0:E[0];if(_){const D=new FileReader;D.onload=T=>{var O;try{const $=(O=T.target)==null?void 0:O.result,{schema:V,validation:G}=wk($);if(!G.valid){const H=Ck(G),Y=G.errors.filter(W=>W.type==="error").slice(0,5).map(W=>`• ${W.message}`).join(`
177
+ `);if(window.confirm(`Schema validation failed (${H}):
173
178
 
174
- ${z}
179
+ ${Y}
175
180
 
176
- Would you like to attempt to import anyway? The schema will be sanitized.`)){const V=JSON.parse(T),W=p_(V);i(W)}return}const B=F.errors.filter(G=>G.type==="warning");B.length>0&&console.warn("Schema import warnings:",B),i(L)}catch(T){console.error("Failed to import schema:",T),alert("Invalid JSON file. Please select a valid form schema.")}},D.readAsText(k)}f.current&&(f.current.value="")},b=new Set((u==null?void 0:u.hideBuiltinActions)??[]);(u==null?void 0:u.showUndoRedo)===!1&&(b.add("undo"),b.add("redo")),(u==null?void 0:u.showModeToggle)===!1&&(b.add("design-mode"),b.add("preview-mode")),(u==null?void 0:u.showImportExport)===!1&&(b.add("import"),b.add("export")),(u==null?void 0:u.showReset)===!1&&b.add("reset");const v=new Map,N=(u==null?void 0:u.actions)??[];N.forEach(E=>{E.override&&v.set(E.override,E)});const x=P.useMemo(()=>{const E={left:[],center:[],right:[]};return N.filter(k=>!k.override&&!Vc(k,h)).forEach(k=>{E[k.position].push(k)}),Object.values(E).forEach(k=>{k.sort((_,D)=>(_.order??0)-(D.order??0))}),E},[N,h]),w=E=>!(b.has(E)||v.has(E)),C=(E,k)=>{if(b.has(E))return null;const _=v.get(E);return _&&!Vc(_,h)?l.jsx(Bo,{action:_,context:h},E):k()};return l.jsx(Va,{children:l.jsxs("div",{className:m("flex items-center justify-between px-4 py-2 bg-card border-b border-border"),children:[l.jsxs("div",{className:m("flex items-center gap-1"),children:[x.left.filter(E=>(E.order??0)<0).map(E=>l.jsx(Bo,{action:E,context:h},E.id)),C("undo",()=>w("undo")?l.jsxs(Or,{children:[l.jsx(Mr,{asChild:!0,children:l.jsx(Je,{variant:"ghost",size:"icon",onClick:o,disabled:!t,children:l.jsx(vE,{className:m("h-5 w-5")})})}),l.jsx(xr,{children:l.jsx("p",{children:"Undo (⌘Z)"})})]},"undo"):null),C("redo",()=>w("redo")?l.jsxs(Or,{children:[l.jsx(Mr,{asChild:!0,children:l.jsx(Je,{variant:"ghost",size:"icon",onClick:n,disabled:!r,children:l.jsx(bE,{className:m("h-5 w-5")})})}),l.jsx(xr,{children:l.jsx("p",{children:"Redo (⌘⇧Z)"})})]},"redo"):null),x.left.filter(E=>(E.order??0)>=0).map(E=>l.jsx(Bo,{action:E,context:h},E.id))]}),l.jsxs("div",{className:m("flex items-center gap-2"),children:[x.center.filter(E=>(E.order??0)<0).map(E=>l.jsx(Bo,{action:E,context:h},E.id)),(u==null?void 0:u.showModeToggle)!==!1&&Kt.getVisible().length>0&&l.jsx("div",{className:m("flex items-center bg-muted rounded-lg p-1"),children:Kt.getVisible().map(E=>{const k=`${E.id}-mode`;if(b.has(k))return null;const _=E.icon,D=d===E.id;return l.jsxs(Or,{children:[l.jsx(Mr,{asChild:!0,children:l.jsx(Je,{variant:D?"secondary":"ghost",size:"icon",onClick:()=>p(E.id),className:m(D&&"bg-background shadow-sm"),children:l.jsx(_,{className:m("h-5 w-5")})})}),l.jsx(xr,{children:l.jsx("p",{children:E.description??E.label})})]},E.id)})}),x.center.filter(E=>(E.order??0)>=0).map(E=>l.jsx(Bo,{action:E,context:h},E.id))]}),l.jsxs("div",{className:m("flex items-center gap-1"),children:[x.right.filter(E=>(E.order??0)<0).map(E=>l.jsx(Bo,{action:E,context:h},E.id)),l.jsx("input",{ref:f,type:"file",accept:".json",onChange:y,className:m("hidden")}),C("import",()=>w("import")?l.jsxs(Or,{children:[l.jsx(Mr,{asChild:!0,children:l.jsx(Je,{variant:"ghost",size:"icon",onClick:g,children:l.jsx(xE,{className:m("h-5 w-5")})})}),l.jsx(xr,{children:l.jsx("p",{children:"Import"})})]},"import"):null),C("export",()=>w("export")?l.jsxs(Or,{children:[l.jsx(Mr,{asChild:!0,children:l.jsx(Je,{variant:"ghost",size:"icon",onClick:s,children:l.jsx(hE,{className:m("h-5 w-5")})})}),l.jsx(xr,{children:l.jsx("p",{children:"Export"})})]},"export"):null),C("reset",()=>w("reset")?l.jsxs(Or,{children:[l.jsx(Mr,{asChild:!0,children:l.jsx(Je,{variant:"ghost",size:"icon",className:m("text-destructive hover:text-destructive hover:bg-destructive/10"),onClick:c,children:l.jsx(mc,{className:m("h-5 w-5")})})}),l.jsx(xr,{children:l.jsx("p",{children:"Reset"})})]},"reset"):null),x.right.filter(E=>(E.order??0)>=0).map(E=>l.jsx(Bo,{action:E,context:h},E.id))]})]})})},Jn=({containerId:e,stepId:t,label:r="Drop elements here",children:o,isEmpty:n=!0})=>{const[s,a]=P.useState(!1),i=P.useRef(null),c=te(h=>h.addElementToContainer),d=te(h=>h.setDraggedElementType),p=h=>{h.preventDefault();const y=h.currentTarget.querySelectorAll("[data-drop-zone]");for(const b of y){const v=b.getBoundingClientRect();if(h.clientX>=v.left&&h.clientX<=v.right&&h.clientY>=v.top&&h.clientY<=v.bottom){a(!1);return}}h.stopPropagation(),a(!0)},u=h=>{h.preventDefault();const g=h.relatedTarget,y=h.currentTarget;if(g&&y.contains(g)){const b=g.closest("[data-drop-zone]");b&&b!==y&&a(!1);return}h.stopPropagation(),a(!1)},f=h=>{h.preventDefault();const y=h.currentTarget.querySelectorAll("[data-drop-zone]");for(const v of y){const N=v.getBoundingClientRect();if(h.clientX>=N.left&&h.clientX<=N.right&&h.clientY>=N.top&&h.clientY<=N.bottom){a(!1);return}}h.stopPropagation(),a(!1);const b=h.dataTransfer.getData("elementType");b&&(c(b,e,t),d(null))};return l.jsx("div",{ref:i,"data-drop-zone":e,"data-step-id":t,onDragOver:p,onDragLeave:u,onDrop:f,className:m("min-h-[60px] rounded transition-all",s?"border-2 border-blue-400 border-dashed bg-blue-50":n?"border-2 border-dashed border-gray-300 bg-gray-50/50":"border border-dashed border-gray-200"),style:{pointerEvents:"auto"},children:n?l.jsx("div",{className:m("flex items-center justify-center h-full min-h-[60px] text-gray-400 text-sm pointer-events-none"),children:s?"Release to drop":r}):l.jsx("div",{className:m("space-y-2 p-2"),children:o})})},fm=e=>{const t=Ch(e);if(!t)return"📋";if(typeof t=="string")return t;const r=t;return l.jsx(r,{className:m("w-4 h-4 inline-block")})},Ga=({element:e,isSelected:t,isHovered:r,onSelect:o,onHover:n,onDelete:s})=>{const a=()=>e.type==="group"?l.jsx(pm,{element:e}):e.type==="grid"?l.jsx(hm,{element:e}):e.type==="repeatGroup"?l.jsx(mm,{element:e}):l.jsx(Ia,{element:e,isSelected:t}),i=e.type==="group"||e.type==="grid"||e.type==="repeatGroup";return l.jsxs("div",{onClick:c=>{c.stopPropagation(),o()},onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),className:m("relative p-3 rounded-lg border transition-all",i?"cursor-default":"cursor-pointer",t?"border-blue-500 bg-blue-50/50 shadow-sm":r?"border-blue-300 bg-gray-50":"border-gray-200 hover:border-gray-300"),children:[(t||r)&&l.jsxs("div",{className:m("absolute -top-2 left-2 px-1.5 py-0.5 bg-blue-500 text-white text-xs rounded-full shadow-sm flex items-center gap-1"),children:[fm(e.type)," ",yc(e.type)]}),(t||r)&&l.jsx("button",{onClick:c=>{c.stopPropagation(),s()},className:m("absolute -top-2 right-2 w-5 h-5 bg-red-500 text-white rounded-full flex items-center justify-center text-xs hover:bg-red-600 shadow-sm"),children:"×"}),a()]})},N_=({element:e,index:t,isSelected:r,isHovered:o,onSelect:n,onHover:s,onDelete:a,onDuplicate:i,onDragStart:c,onDragOver:d,onDragEnd:p,isDragTarget:u})=>{const f=()=>e.type==="group"?l.jsx(pm,{element:e}):e.type==="grid"?l.jsx(hm,{element:e}):e.type==="repeatGroup"?l.jsx(mm,{element:e}):e.type==="pages"?l.jsx(C_,{element:e}):l.jsx(Ia,{element:e,isSelected:r}),h=b=>{b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("elementId",e.id),c(t)},g=b=>{b.preventDefault(),b.dataTransfer.dropEffect="move",d(t)},y=()=>{p()};return l.jsxs("div",{draggable:!0,onDragStart:h,onDragOver:g,onDragEnd:y,onClick:n,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),className:m("relative p-4 rounded-lg border-2 transition-all cursor-grab active:cursor-grabbing",u?"border-blue-500 border-dashed bg-blue-50":r?"border-blue-500 bg-blue-50/30 shadow-sm":o?"border-blue-300 bg-gray-50/50":"border-gray-200 bg-white hover:border-gray-300"),children:[u&&l.jsx("div",{className:m("absolute -top-1 left-0 right-0 h-0.5 bg-blue-500 rounded")}),(r||o)&&l.jsxs("div",{className:m("absolute -top-3 left-3 px-2 py-0.5 bg-blue-500 text-white text-xs rounded-full shadow-sm flex items-center gap-1"),children:[fm(e.type)," ",yc(e.type)]}),(r||o)&&l.jsxs("div",{className:m("absolute -top-3 right-3 flex gap-1"),children:[l.jsx("button",{onClick:b=>{b.stopPropagation(),i()},className:m("p-1 bg-white border border-gray-200 rounded shadow-sm hover:bg-gray-50 text-xs"),title:"Duplicate",children:"📋"}),l.jsx("button",{onClick:b=>{b.stopPropagation(),a()},className:m("p-1 bg-white border border-gray-200 rounded shadow-sm hover:bg-red-50 hover:border-red-200 text-xs"),title:"Delete",children:"🗑️"})]}),f(),(r||o)&&l.jsxs("div",{className:m("absolute left-1 top-1/2 -translate-y-1/2 flex flex-col gap-0.5 cursor-grab"),title:"Drag to reorder",children:[l.jsx("div",{className:m("w-4 h-0.5 bg-gray-400 rounded")}),l.jsx("div",{className:m("w-4 h-0.5 bg-gray-400 rounded")}),l.jsx("div",{className:m("w-4 h-0.5 bg-gray-400 rounded")})]})]})},pm=({element:e})=>{var p;const t=e.properties.label||"Group",r=e.properties.description,o=te(u=>u.schema.elements),n=te(u=>u.selectedElementId),s=te(u=>u.hoveredElementId),a=te(u=>u.selectElement),i=te(u=>u.setHoveredElementId),c=te(u=>u.deleteElement),d=o.filter(u=>u.parentId===e.id).sort((u,f)=>u.order-f.order);return l.jsxs("div",{className:m("border border-gray-200 rounded-lg overflow-hidden"),style:{padding:((p=e.config)==null?void 0:p.padding)||16},children:[l.jsxs("div",{className:m("mb-3"),children:[l.jsx("h3",{className:m("font-medium text-gray-800"),children:t}),r&&l.jsx("p",{className:m("text-sm text-gray-500"),children:r})]}),l.jsx(Jn,{containerId:e.id,label:"Drop elements into this group",isEmpty:d.length===0,children:d.map(u=>l.jsx(Ga,{element:u,isSelected:n===u.id,isHovered:s===u.id,onSelect:()=>a(u.id),onHover:f=>i(f?u.id:null),onDelete:()=>c(u.id)},u.id))})]})},hm=({element:e})=>{var p,u;const t=e.properties.label,r=((p=e.config)==null?void 0:p.gridColumns)||2,o=te(f=>f.schema.elements),n=te(f=>f.selectedElementId),s=te(f=>f.hoveredElementId),a=te(f=>f.selectElement),i=te(f=>f.setHoveredElementId),c=te(f=>f.deleteElement),d=o.filter(f=>f.parentId===e.id).sort((f,h)=>f.order-h.order);return l.jsxs("div",{className:m("border border-gray-200 rounded-lg p-4"),children:[t&&l.jsx("div",{className:m("mb-3"),children:l.jsx("h3",{className:m("font-medium text-gray-800"),children:t})}),l.jsx("div",{className:m("grid"),style:{gridTemplateColumns:`repeat(${r}, 1fr)`,gap:((u=e.config)==null?void 0:u.gridGap)||16},children:d.length===0?Array.from({length:r}).map((f,h)=>l.jsx(Jn,{containerId:e.id,label:`Column ${h+1}`},h)):d.map(f=>l.jsx(Ga,{element:f,isSelected:n===f.id,isHovered:s===f.id,onSelect:()=>a(f.id),onHover:h=>i(h?f.id:null),onDelete:()=>c(f.id)},f.id))}),d.length>0&&d.length<r*3&&l.jsx("div",{className:m("mt-3"),children:l.jsx(Jn,{containerId:e.id,label:"Add more elements"})})]})},mm=({element:e})=>{var p,u,f;const t=e.properties.label||"Repeat Group",r=e.properties.description,o=te(h=>h.schema.elements),n=te(h=>h.selectedElementId),s=te(h=>h.hoveredElementId),a=te(h=>h.selectElement),i=te(h=>h.setHoveredElementId),c=te(h=>h.deleteElement),d=o.filter(h=>h.parentId===e.id).sort((h,g)=>h.order-g.order);return l.jsxs("div",{className:m("border border-gray-200 rounded-lg p-4"),children:[l.jsxs("div",{className:m("mb-3"),children:[l.jsxs("div",{className:m("flex items-center gap-2"),children:[l.jsx("span",{className:m("text-lg"),children:"🔄"}),l.jsx("h3",{className:m("font-medium text-gray-800"),children:t})]}),r&&l.jsx("p",{className:m("text-sm text-gray-500"),children:r})]}),l.jsxs("div",{className:m("border border-dashed border-gray-300 rounded-lg p-3 bg-gray-50/50"),children:[l.jsx("div",{className:m("text-xs text-gray-500 mb-2 font-medium"),children:"📋 Item Template (will repeat)"}),l.jsx(Jn,{containerId:e.id,label:"Drop elements to create the repeatable template",isEmpty:d.length===0,children:d.map(h=>l.jsx(Ga,{element:h,isSelected:n===h.id,isHovered:s===h.id,onSelect:()=>a(h.id),onHover:g=>i(g?h.id:null),onDelete:()=>c(h.id)},h.id))})]}),l.jsx("div",{className:m("mt-3"),children:l.jsxs("button",{disabled:!0,className:m("text-sm text-blue-600 hover:text-blue-700 flex items-center gap-1 opacity-70"),children:["➕ ",((p=e.config)==null?void 0:p.addButtonText)||"Add Item"]})}),l.jsxs("div",{className:m("mt-3 text-xs text-gray-500 bg-gray-100 rounded p-2"),children:["ℹ️ Min: ",((u=e.config)==null?void 0:u.minItems)||1,", Max:"," ",((f=e.config)==null?void 0:f.maxItems)||10," items"]})]})},C_=({element:e})=>{var w,C,E,k;const t=te(_=>_.schema.elements),r=te(_=>_.selectedElementId),o=te(_=>_.hoveredElementId),n=te(_=>_.selectElement),s=te(_=>_.setHoveredElementId),a=te(_=>_.deleteElement),i=te(_=>_.addWizardStep),c=te(_=>_.updateWizardStep),d=te(_=>_.removeWizardStep),p=te(_=>_.setActiveWizardStep),u=((w=e.config)==null?void 0:w.steps)||[],f=((C=e.config)==null?void 0:C.activeStepId)||((E=u[0])==null?void 0:E.id),h=u.findIndex(_=>_.id===f),g=u[h],y=h===u.length-1,b=t.filter(_=>{var D;return _.parentId?_.parentId===`${e.id}:${f}`||_.parentId===e.id&&((D=_.config)==null?void 0:D.wizardStepId)===f:!1}).sort((_,D)=>_.order-D.order),v=()=>{const _={id:Ks(),label:`Step ${u.length+1}`,description:""};i(e.id,_)},N=()=>{h>0&&p(e.id,u[h-1].id)},x=()=>{h<u.length-1&&p(e.id,u[h+1].id)};return l.jsxs("div",{className:m("border border-gray-200 rounded-lg overflow-hidden"),children:[l.jsxs("div",{className:m("bg-gray-50 border-b border-gray-200 p-3"),children:[l.jsxs("div",{className:m("flex items-center gap-2 mb-2"),children:[l.jsx("span",{className:m("text-lg"),children:"📑"}),l.jsx("h3",{className:m("font-medium text-gray-800"),children:e.properties.label||"Multi-Step Form"})]}),l.jsxs("div",{className:m("flex gap-1 flex-wrap"),children:[u.map((_,D)=>l.jsxs("button",{onClick:()=>p(e.id,_.id),className:m("px-3 py-1.5 text-sm rounded transition-colors",_.id===f?"bg-blue-500 text-white":"bg-white border border-gray-200 hover:bg-gray-100"),children:[D+1,". ",_.label]},_.id)),l.jsx("button",{onClick:v,className:m("px-3 py-1.5 text-sm border border-dashed border-gray-300 rounded hover:bg-gray-100 text-gray-500"),children:"+ Add Step"})]}),((k=e.config)==null?void 0:k.showProgressBar)&&l.jsxs("div",{className:m("mt-3"),children:[l.jsx("div",{className:m("h-2 bg-gray-200 rounded-full overflow-hidden"),children:l.jsx("div",{className:m("h-full bg-blue-500 transition-all"),style:{width:`${(h+1)/u.length*100}%`}})}),l.jsxs("div",{className:m("text-xs text-gray-500 mt-1"),children:["Step ",h+1," of ",u.length]})]})]}),l.jsx("div",{className:m("p-4"),children:g&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:m("mb-4"),children:[l.jsx("input",{type:"text",value:g.label,onChange:_=>c(e.id,f,{label:_.target.value}),className:m("text-lg font-semibold text-gray-800 border-none bg-transparent w-full focus:outline-none focus:ring-0"),placeholder:"Step title"}),l.jsx("input",{type:"text",value:g.description||"",onChange:_=>c(e.id,f,{description:_.target.value}),className:m("text-sm text-gray-500 border-none bg-transparent w-full focus:outline-none focus:ring-0"),placeholder:"Step description (optional)"})]}),l.jsx(Jn,{containerId:e.id,stepId:f,label:"Drop elements for this step",isEmpty:b.length===0,children:b.map(_=>l.jsx(Ga,{element:_,isSelected:r===_.id,isHovered:o===_.id,onSelect:()=>n(_.id),onHover:D=>s(D?_.id:null),onDelete:()=>a(_.id)},_.id))}),l.jsxs("div",{className:m("flex justify-between mt-4 pt-4 border-t border-gray-200"),children:[l.jsx("button",{disabled:h===0,onClick:N,className:m("px-4 py-2 text-sm border border-gray-300 rounded hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"),children:"← Previous"}),l.jsxs("div",{className:m("flex gap-2"),children:[u.length>1&&l.jsx("button",{onClick:()=>d(e.id,f),className:m("px-3 py-2 text-sm text-red-600 hover:bg-red-50 rounded"),children:"🗑️ Delete Step"}),l.jsx("button",{disabled:y,onClick:x,className:m("px-4 py-2 text-sm bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed"),children:"Next →"})]})]})]})}),l.jsx("div",{className:m("px-4 pb-4"),children:l.jsxs("div",{className:m("text-xs text-gray-500 bg-gray-50 rounded p-2"),children:["ℹ️ This wizard has ",u.length," step(s). Click on step tabs to switch between them and add elements. The Submit button will only appear on the last step during form submission."]})})]})},E_=()=>l.jsxs("div",{className:m("flex flex-col items-center justify-center h-full text-muted-foreground"),children:[l.jsx("div",{className:m("text-6xl mb-4"),children:"📝"}),l.jsx("h3",{className:m("text-lg font-medium text-foreground/70 mb-2"),children:"Start Building Your Form"}),l.jsx("p",{className:m("text-sm text-center max-w-md"),children:"Drag elements from the left sidebar or click them to add to your form. Click on any element to configure its properties."})]}),__=({toolbarConfig:e})=>{const t=te(U=>U.schema),r=te(U=>U.selectedElementId),o=te(U=>U.hoveredElementId),n=te(U=>U.addElement),s=te(U=>U.selectElement),a=te(U=>U.deleteElement),i=te(U=>U.duplicateElement),c=te(U=>U.reorderElements),d=te(U=>U.setHoveredElementId),p=te(U=>U.undo),u=te(U=>U.redo),f=te(U=>U.canUndo),h=te(U=>U.canRedo),g=te(U=>U.exportSchema),y=te(U=>U.loadSchema),b=te(U=>U.resetForm),v=te(U=>U.mode),N=te(U=>U.setMode),x=te(U=>U.hasWizard),[w,C]=P.useState(!1),[E,k]=P.useState(null),[_,D]=P.useState(null),A=x(),I=U=>{if(U.preventDefault(),A){U.dataTransfer.dropEffect="none";return}U.dataTransfer.dropEffect="copy",C(!0)},T=U=>{U.currentTarget.contains(U.relatedTarget)||C(!1)},L=U=>{if(U.preventDefault(),C(!1),A)return;const Q=U.dataTransfer.getData("elementType");Q&&n(Q)},F=()=>{const U=g(),Q=new Blob([JSON.stringify(U,null,2)],{type:"application/json"}),Ce=URL.createObjectURL(Q),oe=document.createElement("a");oe.href=Ce,oe.download=`${t.title.replace(/\s+/g,"-").toLowerCase()}-schema.json`,document.body.appendChild(oe),oe.click(),document.body.removeChild(oe),URL.revokeObjectURL(Ce)},B=U=>{y(U)},G=()=>{(t.elements.length===0||window.confirm("Are you sure you want to reset the form? This will delete all elements."))&&b()},z=U=>{U.target===U.currentTarget&&s(null)},H=[...t.elements].filter(U=>!U.parentId).sort((U,Q)=>U.order-Q.order),V=U=>{k(U)},W=U=>{E!==null&&E!==U&&D(U)},pe=()=>{E!==null&&_!==null&&E!==_&&c(E,_),k(null),D(null)};return l.jsxs("div",{className:m("flex-1 flex flex-col bg-gray-100 overflow-hidden"),children:[l.jsx(S_,{schema:t,canUndo:f(),canRedo:h(),onUndo:p,onRedo:u,onExport:F,exportSchema:g,onImport:B,onReset:G,mode:v,onModeChange:N,toolbarConfig:e}),l.jsx("div",{className:m("flex-1 overflow-auto p-4",w&&!A?"bg-blue-50":""),onDragOver:I,onDragLeave:T,onDrop:L,onClick:z,children:l.jsxs("div",{className:m("max-w-4xl mx-auto p-2"),children:[l.jsx("div",{className:m("mb-0 text-center"),children:t.description&&l.jsx("p",{className:m("text-gray-500"),children:t.description})}),l.jsx("div",{className:m("bg-white rounded-xl shadow-sm border-2 transition-colors",w&&!A?"border-blue-400 border-dashed":"border-gray-200"),children:H.length===0?l.jsx("div",{className:m("p-2"),children:l.jsx(E_,{})}):l.jsx("div",{className:m("p-4 space-y-2"),children:H.map((U,Q)=>l.jsx(N_,{element:U,index:Q,isSelected:r===U.id,isHovered:o===U.id,onSelect:()=>s(U.id),onHover:Ce=>d(Ce?U.id:null),onDelete:()=>a(U.id),onDuplicate:()=>i(U.id),onDragStart:V,onDragOver:W,onDragEnd:pe,isDragTarget:_===Q},U.id))})}),w&&!A&&l.jsx("div",{className:m("mt-4 p-4 border-2 border-dashed border-blue-400 rounded-lg text-center text-blue-500 bg-blue-50/50"),children:"Drop element here"}),A&&w&&l.jsx("div",{className:m("mt-4 p-4 border-2 border-dashed border-orange-400 rounded-lg text-center text-orange-600 bg-orange-50/50"),children:"⚠️ Drop elements inside wizard steps, not here"})]})})]})},Gc=[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],k_=e=>e.replace(new RegExp("\\p{Nd}","gu"),t=>{const r=t.codePointAt(0);if(r<=57)return t;let o=0,n=Gc.length-1;for(;o<n;){const s=o+n+1>>>1;Gc[s]<=r?o=s:n=s-1}return String(r-Gc[o])}),A_={"⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9"},D_=/[⁰¹²³⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅₆₇₈₉]/g,$_={"¼":"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/"},T_=/^(?=[-+]?\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)*)?$/,P_=/^(?=[-+]?\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/].*)?/,I_=/([¼½¾⅐⅑⅒⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞⅟}])/g,za={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},O_={"Ⅰ":"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"},M_=/([ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿ])/gi,L_=/^(?=[MDCLXVI])(M{0,3})(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$/i,gm={round:3,allowTrailingInvalid:!1,romanNumerals:!1,bigIntOnOverflow:!1,decimalSeparator:".",allowCurrency:!1,percentage:!1,verbose:!1},F_=e=>{const t=`${e}`.replace(M_,(i,c)=>O_[c]).toUpperCase(),r=L_.exec(t);if(!r)return NaN;const[,o,n,s,a]=r;return(za[o]??0)+(za[n]??0)+(za[s]??0)+(za[a]??0)},V_=/^\s*\//,G_=new RegExp("^([-+]?)\\s*(\\p{Sc}+)\\s*","u"),z_=new RegExp("\\s*(\\p{Sc}+)$","u"),B_=/%$/;function U_(e,t=gm){const r={...gm,...t},o=typeof e=="string"?e:`${e}`;let n,s,a,i,c,d,p,u;const f=A=>{const I={value:A,input:o};return n&&(I.currencyPrefix=n),s&&(I.currencySuffix=s),a&&(I.percentageSuffix=a),i&&(I.trailingInvalid=i),c&&(I.sign=c),d!==void 0&&(I.whole=d),p!==void 0&&(I.numerator=p),u!==void 0&&(I.denominator=u),I},h=A=>r.verbose?f(A):A;if(typeof e=="number"||typeof e=="bigint")return h(e);let g=NaN,y=o;if(r.allowCurrency){const A=G_.exec(y);A&&A[2]&&(n=A[2],y=(A[1]||"")+y.slice(A[0].length))}if(r.allowCurrency){const A=z_.exec(y);A&&(s=A[1],y=y.slice(0,-A[0].length))}r.percentage&&B_.test(y)&&(a=!0,y=y.slice(0,-1));const b=k_(y.replace(I_,(A,I)=>` ${$_[I]}`).replace(D_,A=>A_[A]).replace("⁄","/").trim());if(b.length===0)return h(NaN);let v=b;if(r.decimalSeparator===","){const A=(b.match(/,/g)||[]).length;if(A===1)v=b.replaceAll(".","_").replace(",",".");else if(A>1){if(!r.allowTrailingInvalid)return h(NaN);const I=b.indexOf(","),T=b.indexOf(",",I+1),L=b.substring(0,T).replaceAll(".","_").replace(",","."),F=b.substring(T+1);v=r.allowTrailingInvalid?L+"&"+F:L}else v=b.replaceAll(".","_")}const N=P_.exec(v);if(!N)return h(r.romanNumerals?F_(b):NaN);const x=(N[7]||v.slice(N[0].length)).trim();if(x&&(i=x,!r.allowTrailingInvalid))return h(NaN);const[,w,C,E]=N;(w==="-"||w==="+")&&(c=w);const k=C.replaceAll(",","").replaceAll("_",""),_=E==null?void 0:E.replaceAll(",","").replaceAll("_","");if(!k&&_&&_.startsWith("."))g=0;else{if(r.bigIntOnOverflow){const A=BigInt(w==="-"?`-${k}`:k);if(A>BigInt(Number.MAX_SAFE_INTEGER)||A<BigInt(Number.MIN_SAFE_INTEGER))return h(A)}g=parseInt(k)}if(!_)return g=w==="-"?g*-1:g,a&&r.percentage!=="number"&&(g=g/100),h(g);const D=r.round===!1?NaN:parseFloat(`1e${Math.floor(Math.max(0,r.round))}`);if(_.startsWith(".")||_.startsWith("e")||_.startsWith("E")){const A=parseFloat(`${g}${_}`);g=isNaN(D)?A:Math.round(A*D)/D}else if(V_.test(_)){const A=parseInt(k),I=parseInt(_.replace("/",""));p=A,u=I,g=isNaN(D)?A/I:Math.round(A*D/I)/D}else{const[A,I]=_.split("/").map(T=>parseInt(T));d=g,p=A,u=I,g+=isNaN(D)?A/I:Math.round(A*D/I)/D}return g=w==="-"?g*-1:g,a&&r.percentage!=="number"&&(g=isNaN(D)?g/100:Math.round(g/100*D)/D),h(g)}var bm=Symbol.for("immer-nothing"),ym=Symbol.for("immer-draftable"),Ft=Symbol.for("immer-state"),W_=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Rt(e,...t){if(process.env.NODE_ENV!=="production"){const r=W_[e],o=Uo(r)?r.apply(null,t):r;throw new Error(`[Immer] ${o}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Xt=Object,bn=Xt.getPrototypeOf,Ba="constructor",Ua="prototype",zc="configurable",Wa="enumerable",Ha="writable",Zn="value",Lr=e=>!!e&&!!e[Ft];function Fr(e){var t;return e?xm(e)||Ya(e)||!!e[ym]||!!((t=e[Ba])!=null&&t[ym])||Qa(e)||Ka(e):!1}var H_=Xt[Ua][Ba].toString(),vm=new WeakMap;function xm(e){if(!e||!Wc(e))return!1;const t=bn(e);if(t===null||t===Xt[Ua])return!0;const r=Xt.hasOwnProperty.call(t,Ba)&&t[Ba];if(r===Object)return!0;if(!Uo(r))return!1;let o=vm.get(r);return o===void 0&&(o=Function.toString.call(r),vm.set(r,o)),o===H_}function ja(e,t,r=!0){es(e)===0?(r?Reflect.ownKeys(e):Xt.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((o,n)=>t(n,o,e))}function es(e){const t=e[Ft];return t?t.type_:Ya(e)?1:Qa(e)?2:Ka(e)?3:0}var Bc=(e,t,r=es(e))=>r===2?e.has(t):Xt[Ua].hasOwnProperty.call(e,t),Uc=(e,t,r=es(e))=>r===2?e.get(t):e[t],qa=(e,t,r,o=es(e))=>{o===2?e.set(t,r):o===3?e.add(r):e[t]=r};function j_(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Ya=Array.isArray,Qa=e=>e instanceof Map,Ka=e=>e instanceof Set,Wc=e=>typeof e=="object",Uo=e=>typeof e=="function",Hc=e=>typeof e=="boolean";function q_(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var to=e=>e.copy_||e.base_,jc=e=>e.modified_?e.copy_:e.base_;function qc(e,t){if(Qa(e))return new Map(e);if(Ka(e))return new Set(e);if(Ya(e))return Array[Ua].slice.call(e);const r=xm(e);if(t===!0||t==="class_only"&&!r){const o=Xt.getOwnPropertyDescriptors(e);delete o[Ft];let n=Reflect.ownKeys(o);for(let s=0;s<n.length;s++){const a=n[s],i=o[a];i[Ha]===!1&&(i[Ha]=!0,i[zc]=!0),(i.get||i.set)&&(o[a]={[zc]:!0,[Ha]:!0,[Wa]:i[Wa],[Zn]:e[a]})}return Xt.create(bn(e),o)}else{const o=bn(e);if(o!==null&&r)return{...e};const n=Xt.create(o);return Xt.assign(n,e)}}function Yc(e,t=!1){return Xa(e)||Lr(e)||!Fr(e)||(es(e)>1&&Xt.defineProperties(e,{set:Ra,add:Ra,clear:Ra,delete:Ra}),Xt.freeze(e),t&&ja(e,(r,o)=>{Yc(o,!0)},!1)),e}function Y_(){Rt(2)}var Ra={[Zn]:Y_};function Xa(e){return e===null||!Wc(e)?!0:Xt.isFrozen(e)}var Ja="MapSet",Qc="Patches",wm="ArrayMethods",Sm={};function Wo(e){const t=Sm[e];return t||Rt(0,e),t}var Nm=e=>!!Sm[e],ts,Cm=()=>ts,Q_=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Nm(Ja)?Wo(Ja):void 0,arrayMethodsPlugin_:Nm(wm)?Wo(wm):void 0});function Em(e,t){t&&(e.patchPlugin_=Wo(Qc),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Kc(e){Rc(e),e.drafts_.forEach(K_),e.drafts_=null}function Rc(e){e===ts&&(ts=e.parent_)}var _m=e=>ts=Q_(ts,e);function K_(e){const t=e[Ft];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function km(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];if(e!==void 0&&e!==r){r[Ft].modified_&&(Kc(t),Rt(4)),Fr(e)&&(e=Am(t,e));const{patchPlugin_:n}=t;n&&n.generateReplacementPatches_(r[Ft].base_,e,t)}else e=Am(t,r);return R_(t,e,!0),Kc(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==bm?e:void 0}function Am(e,t){if(Xa(t))return t;const r=t[Ft];if(!r)return el(t,e.handledSet_,e);if(!Za(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){const{callbacks_:o}=r;if(o)for(;o.length>0;)o.pop()(e);Tm(r,e)}return r.copy_}function R_(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Yc(t,r)}function Dm(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Za=(e,t)=>e.scope_===t,X_=[];function $m(e,t,r,o){const n=to(e),s=e.type_;if(o!==void 0&&Uc(n,o,s)===t){qa(n,o,r,s);return}if(!e.draftLocations_){const i=e.draftLocations_=new Map;ja(n,(c,d)=>{if(Lr(d)){const p=i.get(d)||[];p.push(c),i.set(d,p)}})}const a=e.draftLocations_.get(t)??X_;for(const i of a)qa(n,i,r,s)}function J_(e,t,r){e.callbacks_.push(function(n){var i;const s=t;if(!s||!Za(s,n))return;(i=n.mapSetPlugin_)==null||i.fixSetContents(s);const a=jc(s);$m(e,s.draft_??s,a,r),Tm(s,n)})}function Tm(e,t){var o;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((o=e.assigned_)==null?void 0:o.size)??0)>0)){const{patchPlugin_:n}=t;if(n){const s=n.getPath(e);s&&n.generatePatches_(e,s,t)}Dm(e)}}function Z_(e,t,r){const{scope_:o}=e;if(Lr(r)){const n=r[Ft];Za(n,o)&&n.callbacks_.push(function(){rl(e);const a=jc(n);$m(e,r,a,t)})}else Fr(r)&&e.callbacks_.push(function(){const s=to(e);e.type_===3?s.has(r)&&el(r,o.handledSet_,o):Uc(s,t,e.type_)===r&&o.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&el(Uc(e.copy_,t,e.type_),o.handledSet_,o)})}function el(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||Lr(e)||t.has(e)||!Fr(e)||Xa(e)||(t.add(e),ja(e,(o,n)=>{if(Lr(n)){const s=n[Ft];if(Za(s,r)){const a=jc(s);qa(e,o,a,e.type_),Dm(s)}}else Fr(n)&&el(n,t,r)})),e}function ek(e,t){const r=Ya(e),o={type_:r?1:0,scope_:t?t.scope_:Cm(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let n=o,s=tl;r&&(n=[o],s=rs);const{revoke:a,proxy:i}=Proxy.revocable(n,s);return o.draft_=i,o.revoke_=a,[i,o]}var tl={get(e,t){if(t===Ft)return e;let r=e.scope_.arrayMethodsPlugin_;const o=e.type_===1&&typeof t=="string";if(o&&r!=null&&r.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);const n=to(e);if(!Bc(n,t,e.type_))return rk(e,n,t);const s=n[t];if(e.finalized_||!Fr(s)||o&&e.operationMethod&&(r!=null&&r.isMutatingArrayMethod(e.operationMethod))&&q_(t))return s;if(s===Xc(e.base_,t)||tk(e,t,s)){rl(e);const a=e.type_===1?+t:t,i=Zc(e.scope_,s,e,a);return e.copy_[a]=i}return s},has(e,t){return t in to(e)},ownKeys(e){return Reflect.ownKeys(to(e))},set(e,t,r){const o=Pm(to(e),t);if(o!=null&&o.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){const n=Xc(to(e),t),s=n==null?void 0:n[Ft];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_.set(t,!1),!0;if(j_(r,n)&&(r!==void 0||Bc(e.base_,t,e.type_)))return!0;rl(e),Jc(e)}return e.copy_[t]===r&&(r!==void 0||Bc(e.copy_,t,e.type_))||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),Z_(e,t,r)),!0},deleteProperty(e,t){return rl(e),Xc(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Jc(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=to(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{[Ha]:!0,[zc]:e.type_!==1||t!=="length",[Wa]:o[Wa],[Zn]:r[t]}},defineProperty(){Rt(11)},getPrototypeOf(e){return bn(e.base_)},setPrototypeOf(){Rt(12)}},rs={};for(let e in tl){let t=tl[e];rs[e]=function(){const r=arguments;return r[0]=r[0][0],t.apply(this,r)}}rs.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Rt(13),rs.set.call(this,e,t,void 0)},rs.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Rt(14),tl.set.call(this,e[0],t,r,e[0])};function Xc(e,t){const r=e[Ft];return(r?to(r):e)[t]}function tk(e,t,r){var o;return e.type_!==1||!e.allIndicesReassigned_||(o=e.assigned_)!=null&&o.get(t)||!Fr(r)||r[Ft]?!1:e.baseRefs_.has(r)}function rk(e,t,r){var n;const o=Pm(t,r);return o?Zn in o?o[Zn]:(n=o.get)==null?void 0:n.call(e.draft_):void 0}function Pm(e,t){if(!(t in e))return;let r=bn(e);for(;r;){const o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=bn(r)}}function Jc(e){e.modified_||(e.modified_=!0,e.parent_&&Jc(e.parent_))}function rl(e){e.copy_||(e.assigned_=new Map,e.copy_=qc(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var ok=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(r,o,n)=>{if(Uo(r)&&!Uo(o)){const a=o;o=r;const i=this;return function(d=a,...p){return i.produce(d,u=>o.call(this,u,...p))}}Uo(o)||Rt(6),n!==void 0&&!Uo(n)&&Rt(7);let s;if(Fr(r)){const a=_m(this),i=Zc(a,r,void 0);let c=!0;try{s=o(i),c=!1}finally{c?Kc(a):Rc(a)}return Em(a,n),km(s,a)}else if(!r||!Wc(r)){if(s=o(r),s===void 0&&(s=r),s===bm&&(s=void 0),this.autoFreeze_&&Yc(s,!0),n){const a=[],i=[];Wo(Qc).generateReplacementPatches_(r,s,{patches_:a,inversePatches_:i}),n(a,i)}return s}else Rt(1,r)},this.produceWithPatches=(r,o)=>{if(Uo(r))return(i,...c)=>this.produceWithPatches(i,d=>r(d,...c));let n,s;return[this.produce(r,o,(i,c)=>{n=i,s=c}),n,s]},Hc(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),Hc(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),Hc(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Fr(t)||Rt(8),Lr(t)&&(t=ed(t));const r=_m(this),o=Zc(r,t,void 0);return o[Ft].isManual_=!0,Rc(r),o}finishDraft(t,r){const o=t&&t[Ft];(!o||!o.isManual_)&&Rt(9);const{scope_:n}=o;return Em(n,r),km(void 0,n)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,r){let o;for(o=r.length-1;o>=0;o--){const s=r[o];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}o>-1&&(r=r.slice(o+1));const n=Wo(Qc).applyPatches_;return Lr(t)?n(t,r):this.produce(t,s=>n(s,r))}};function Zc(e,t,r,o){const[n,s]=Qa(t)?Wo(Ja).proxyMap_(t,r):Ka(t)?Wo(Ja).proxySet_(t,r):ek(t,r);return((r==null?void 0:r.scope_)??Cm()).drafts_.push(n),s.callbacks_=(r==null?void 0:r.callbacks_)??[],s.key_=o,r&&o!==void 0?J_(r,s,o):s.callbacks_.push(function(c){var p;(p=c.mapSetPlugin_)==null||p.fixSetContents(s);const{patchPlugin_:d}=c;s.modified_&&d&&d.generatePatches_(s,[],c)}),n}function ed(e){return Lr(e)||Rt(10,e),Im(e)}function Im(e){if(!Fr(e)||Xa(e))return e;const t=e[Ft];let r,o=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=qc(e,t.scope_.immer_.useStrictShallowCopy_),o=t.scope_.immer_.shouldUseStrictIteration()}else r=qc(e,!0);return ja(r,(n,s)=>{qa(r,n,Im(s))},o),t&&(t.finalized_=!1),r}var nk=new ok,os=nk.produce;const yo="------",Qe={fields:{title:"Field",placeholderName:"~",placeholderLabel:yo,placeholderGroupLabel:yo},operators:{title:"Operator",placeholderName:"~",placeholderLabel:yo,placeholderGroupLabel:yo},values:{title:"Values",placeholderName:"~",placeholderLabel:yo,placeholderGroupLabel:yo},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"},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"}},Om={"=":"=","!=":"!=","<":"<",">":">","<=":"<=",">=":">=",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"},sk={and:"AND",or:"OR",xor:"XOR"},ak=[{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"}],ns=[{name:"and",value:"and",label:"AND"},{name:"or",value:"or",label:"OR"}];[...ns];const Mm=[{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"}],ve={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",dndDragging:"dndDragging",dndOver:"dndOver",dndCopy:"dndCopy",dndGroup:"dndGroup",dndDropNotAllowed:"dndDropNotAllowed",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",hasSubQuery:"rule-hasSubQuery"},xe={rule:"rule",ruleGroup:"rule-group",inlineCombinator:"inline-combinator",addGroup:"add-group",removeGroup:"remove-group",cloneGroup:"clone-group",cloneRule:"clone-rule",addRule:"add-rule",removeRule:"remove-rule",combinators:"combinators",fields:"fields",operators:"operators",valueEditor:"value-editor",notToggle:"not-toggle",shiftActions:"shift-actions",dragHandle:"drag-handle",lockRule:"lock-rule",lockGroup:"lock-group",muteRule:"mute-rule",muteGroup:"mute-group",valueSourceSelector:"value-source-selector",matchModeEditor:"match-mode-editor"},bt={parentPathDisabled:"action aborted: parent path disabled",pathDisabled:"action aborted: path is disabled",onAddRuleFalse:"onAddRule callback returned false",onAddGroupFalse:"onAddGroup callback returned false",onGroupRuleFalse:"onGroupRule callback returned false",onGroupGroupFalse:"onGroupGroup callback returned false",onMoveRuleFalse:"onMoveRule callback returned false",onMoveGroupFalse:"onMoveGroup callback returned false",onRemoveFalse:"onRemove callback returned false",add:"rule or group added",remove:"rule or group removed",update:"rule or group updated",move:"rule or group moved",group:"rule or group grouped with another"},Lm=[],lk={addRuleToNewGroups:!1,autoSelectField:!0,autoSelectOperator:!0,autoSelectValue:!1,debugMode:!1,enableDragAndDrop:!1,enableMountQueryChange:!0,listsAsArrays:!1,resetOnFieldChange:!0,resetOnOperatorChange:!1,showCloneButtons:!1,showCombinatorsBetweenRules:!1,showLockButtons:!1,showMuteButtons:!1,showNotToggle:!1,showShiftActions:!1,suppressStandardClassnames:!1},Fm=(e,t=",")=>typeof e=="string"?e.split(`\\${t}`).map(r=>r.split(t)).reduce((r,o,n)=>n===0?o:[...r.slice(0,-1),`${r.at(-1)}${t}${o[0]}`,...o.slice(1)],[]):[],ss=(e,t=",")=>e.map(r=>`${r??""}`.replaceAll(t[0],`\\${t[0]}`)).join(t),Be=e=>typeof e=="string"?e.trim():e,me=(e,{retainEmptyStrings:t}={})=>Array.isArray(e)?e.map(Be):typeof e=="string"?Fm(e,",").filter(t?()=>!0:r=>!/^\s*$/.test(r)).map(r=>r.trim()):typeof e=="number"?[e]:[];function Vm(e){var t,r,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(t=0;t<n;t++)e[t]&&(r=Vm(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}function ze(){for(var e,t,r=0,o="",n=arguments.length;r<n;r++)(e=arguments[r])&&(t=Vm(e))&&(o&&(o+=" "),o+=t);return o}const $e=e=>typeof e=="string"?e.toLowerCase():e,Gm=new RegExp(T_.source.replace(/^\^/,String.raw`^\s*`).replace(/\$$/,String.raw`\s*$`)),wr=e=>e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype,ro=e=>e==null||e==="",ge=e=>wr(e)&&Array.isArray(e.rules),Vt=e=>ge(e)&&typeof e.combinator=="string",yn=e=>ge(e)&&e.combinator===void 0,zm=["or","xor","and"],ik=(e,t)=>$e(e)===t,ol=(e,t=0)=>{const r=zm[t];if(!e.rules.includes(r))return t<zm.length-2?ol(e,t+1):e;const o=[...e.rules];let n=0;for(;n<o.length-2;){if(ik(o[n+1],r)){n+=2;continue}let s=-1;for(let a=n+2;a<o.length;a++)if(typeof o[a]=="string"&&$e(o[a])===r){s=a;break}if(s===-1){o.splice(n,o.length,ol({rules:o.slice(n)},t+1));break}else o.splice(n,s-n,ol({rules:o.slice(n,s)},t+1))}return{...e,rules:o}},Sr=e=>{if(Vt(e))return e;const t=ol(e),r=[];let o="and";for(const[n,s]of t.rules.entries())typeof s=="string"?n===1&&(o=s):r.push(ge(s)?Sr(s):s);return{...t,combinator:o,rules:r}},ck=Object.keys,Bm=Object.entries,nl=e=>e==="__proto__"||e==="constructor"||e==="prototype",td=e=>wr(e)&&"name"in e&&typeof e.name=="string",rd=e=>wr(e)&&"value"in e&&typeof e.value=="string";function Vr(e,t,r){if(typeof e=="string")return{...t,name:e,value:e,label:(r==null?void 0:r[e])??e};const o={};let n=!!t;return td(e)&&!rd(e)?(o.value=e.name,n=!0):!td(e)&&rd(e)&&(o.name=e.value,n=!0),n?Object.assign({},t,e,o):e}function Gr(e,t,r){if(!Array.isArray(e))return[];const o=e;return vo(o)?o.map(n=>({...n,options:n.options.map(s=>Vr(s,t,r))})):o.map(n=>Vr(n,t,r))}function Um(e,t){return Object.fromEntries(Object.entries(e).map(([r,o])=>[r,Vr(o,t)]))}const od=e=>{const t=new Set,r=[];for(const o of e)t.has(o.value??o.name)||(t.add(o.value??o.name),r.push(o));return e.length===r.length?e:r},Wm=e=>Array.isArray(e)&&e.length>0&&wr(e[0])&&"options"in e[0]&&Array.isArray(e[0].options),sl=e=>{let t=!1;if(Array.isArray(e))for(const r of e)if(td(r)||rd(r))t=!0;else return!1;return t},vo=(e,{allowEmpty:t=!1}={})=>{let r=!1;if(Array.isArray(e))for(const o of e)if(wr(o)&&"options"in o&&(sl(o.options)||t&&Array.isArray(o.options)&&o.options.length===0))r=!0;else return!1;return r};function We(e,t){return(vo(e,{allowEmpty:!0})?e.flatMap(r=>r.options):e).find(r=>r.value===t||r.name===t)}function Ct(e){if(!Array.isArray(e)||e.length===0)return null;if(vo(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 nd=e=>od(Wm(e)?e.flatMap(t=>t.options):e),Hm=e=>{const t=new Set,r=new Set,o=[];for(const n of e)if(!t.has(n.label)){t.add(n.label);const s=[];for(const a of n.options)r.has(a.value??a.name)||(r.add(a.value??a.name),s.push(Vr(a)));o.push({...n,options:s})}return o},vn=e=>{const{optionList:t,baseOption:r={},labelMap:o={},placeholder:{placeholderName:n="~",placeholderLabel:s=yo,placeholderGroupLabel:a=yo}={},autoSelectOption:i=!0}=e,c={id:n,name:n,value:n,label:s},d=t??[c];let p;const u=Array.isArray(d)?Gr(d,r,o):ck(Um(d,r)).map(h=>({...d[h],name:h,value:h})).sort((h,g)=>h.label.localeCompare(g.label));vo(u)?p=Hm(i?u:[{label:a,options:[c]},...u]):p=od(i?u:[c,...u]);let f={};if(Array.isArray(d))if(vo(p))for(const h of p)for(const g of h.options)f[g.value??g.name]=Vr(g,r);else for(const h of p)f[h.value??h.name]=Vr(h,r);else{const h=Um(d,r);f=i?h:{...h,[n]:c}}return{defaultOption:c,optionList:p,optionsMap:f}},jm=(e,t,r)=>{var s;const o=Vr(e),n=Vr(r);return o.value===n.value?!1:typeof o.comparator=="string"?o[o.comparator]===n[o.comparator]:((s=o.comparator)==null?void 0:s.call(o,n,t))??!1},qm=(e,t,r)=>{if(!e.comparator){const o=n=>(n.value??n.name)!==(e.value??e.name);return vo(t)?t.map(n=>({...n,options:n.options.filter(s=>o(s))})):t.filter(n=>o(n))}return vo(t)?t.map(o=>({...o,options:o.options.filter(n=>jm(e,r,n))})).filter(o=>o.options.length>0):t.filter(o=>jm(e,r,o))},_e=(e,{parseNumbers:t,bigIntOnOverflow:r}={})=>{if(!t||typeof e=="bigint"||typeof e=="number")return e;if(t==="native")return Number.parseFloat(e);const o=U_(e,{allowTrailingInvalid:t==="enhanced",bigIntOnOverflow:r,romanNumerals:!1,round:!1});return typeof o=="bigint"||!Number.isNaN(o)?o:e},Ym=(e,t,r)=>{const o={};for(const n in e){if(nl(n))continue;const s=t[n];s!==!1&&(s&&n!==s?(nl(s)||(o[s]=e[n]),r||(o[n]=e[n])):o[n]=e[n])}return o};function oo(e,t={}){const{ruleProcessor:r=p=>p,ruleGroupProcessor:o=p=>p,propertyMap:n={},combinatorMap:s={},operatorMap:a={},omitPath:i=!1,deleteRemappedProperties:c=!0}=t,d=p=>({...o(Ym({...p,...Vt(p)?{combinator:s[p.combinator]??p.combinator}:{}},n,c)),...n.rules===!1?null:{[n.rules??"rules"]:p.rules.map((u,f)=>{const h=i?null:{path:[...p.path,f]};return typeof u=="string"?s[u]??u:ge(u)?d({...u,...h}):r(Ym({...u,...h,..."operator"in u?{operator:a[u.operator]??u.operator}:{}},n,c))})}});return d({...e,...i?null:{path:[]}})}const xn=e=>wr(e)&&typeof e.valid=="boolean",Te=(e,t,r)=>{if(e.muted)return!1;if(typeof t=="boolean")return t;if(xn(t))return t.valid;if(typeof r=="function"&&!ge(e)){const o=r(e);if(typeof o=="boolean")return o;if(xn(o))return o.valid}return!0},sd=({parseNumbers:e,inputType:t})=>{if(typeof e=="string"){const[r,o]=e.split("-");return o==="limited"?t==="number"?r:!1:r}return e?"strict":!1},dk=e=>{switch($e(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}},uk=(e="||")=>(...t)=>e.toUpperCase()==="CONCAT"?`CONCAT(${t.join(", ")})`:t.join(` ${e} `),fk=e=>{switch(e){case"contains":case"doesnotcontain":return["%","%"];case"beginswith":case"doesnotbeginwith":return["","%"];case"endswith":case"doesnotendwith":return["%",""];default:return["",""]}},as=(e,t,{concatOperator:r="||",quoteValuesWith:o,wrapValueWith:n=["",""]}={})=>{const[s,a]=fk(t),i=o||"'",c=p=>`${n[0]}${i}${p}${i}${n[1]}`,d=[s&&c(s),e,a&&c(a)].filter(Boolean);return d.length>1?uk(r)(...d):e},Ho={"=":"$eq","!=":"$ne","<":"$lt","<=":"$lte",">":"$gt",">=":"$gte",in:"$in",notin:"$nin",notIn:"$nin"},Qm={"=":"equals","!=":"not","<":"lt","<=":"lte",">":"gt",">=":"gte",in:"in",notin:"notIn"},al={and:"&&",or:"||"},Km=(e,t)=>({...e,rules:e.rules.map(r=>{if(typeof r=="string")return r;if(ge(r))return Km(r,t);const o=We(t.fields,r.field),n=sd({parseNumbers:t.parseNumbers,inputType:o==null?void 0:o.inputType});if(Array.isArray(r.value))return{...r,value:r.value.map(a=>_e(a,{parseNumbers:n}))};const s=me(r.value,{retainEmptyStrings:!0}).map(a=>_e(a,{parseNumbers:n}));if(s.every(a=>typeof a=="number")){if(s.length>1)return{...r,value:s};if(s.length===1)return{...r,value:s[0]}}return r})}),ft=e=>typeof e=="string"&&e.length>0||typeof e=="number"&&!Number.isNaN(e)||typeof e!="string"&&typeof e!="number",be=(e,t)=>!!t&&(typeof e=="number"||typeof e=="bigint"||typeof e=="string"&&Gm.test(e)),pk=e=>e.length>=3,Rm=(e=["",""])=>Array.isArray(e)?e:typeof e=="string"?[e,e]:e??["",""],wn=(e,{quoteFieldNamesWith:t,fieldIdentifierSeparator:r})=>{const[o,n]=Rm(t);return typeof r=="string"&&r.length>0?ss(Fm(e,r).map(s=>`${o}${s}${n}`),r):`${o}${e}${n}`},Xm=["S","V","O"],hk=e=>{const t=[],r=new Set(Xm);for(const o of e.toUpperCase())if(r.has(o)&&(t.push(o),r.delete(o),r.size===0))break;for(const o of Xm)r.has(o)&&t.push(o);return t},ls=(e,t=":")=>{const r=`${e??""}`;return t&&r.startsWith(t)?r:`${t}${r}`},ad=(e,t=":")=>{const r=`${e??""}`;return t&&r.startsWith(t)?r.slice(t.length):r},ld={groupPrefix:"",groupPrefix_not_xor:"either zero or more than one of",groupPrefix_xor:"exactly one of",groupSuffix:"is true",groupSuffix_not:"is not true"},Jm=(e,t,r)=>t.startsWith(e)&&r.every(o=>{var n;return t.includes(`_${o}`)&&((n=t.match(/_/g))==null?void 0:n.length)===r.length}),ll=(e,t,r=[])=>{var o,n;return r.length===0?t[e]??ld[e]??"":((o=Object.entries(t).find(([s])=>Jm(e,s,r)))==null?void 0:o[1])??((n=Object.entries(ld).find(([s])=>Jm(e,s,r)))==null?void 0:n[1])??ld[e]??""},qt=e=>{const{mode:t,threshold:r}=e.match??{};if(!t)return null;if(!ge(e.value))return!1;const o=$e(t),n=o==="atleast"&&r===1?"some":o==="atmost"&&r===0?"none":o;return(n==="atleast"||n==="atmost"||n==="exactly")&&(typeof r!="number"||r<0)?!1:{mode:n,threshold:r}},Zm="elem_alias",il=(e=0)=>e>0?`${Zm}_${e}`:Zm,eg=(e,t)=>typeof t=="bigint"?{$bigint:t.toString()}:t,tg=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:s,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!Te(f,p[f.id??""]))return h?o:"";const g=[];let y="",b=!0;for(const w of f.rules){if(typeof w=="string"){y=al[w];continue}if(ge(w)){const D=u(w);D&&(!b&&y&&(g.push(y),y=""),b=!1,g.push(D));continue}const[C,E]=d(w);if(!Te(w,C,E)||w.field===s||w.operator===a||i!==void 0&&w.value===i)continue;const k=We(r,w.field),_=c(w,{...t,parseNumbers:n(k==null?void 0:k.inputType),escapeQuotes:(w.valueSource??"value")==="value",fieldData:k});_&&(!b&&y&&(g.push(y),y=""),b=!1,g.push(_))}const v=g.join(Vt(f)?` ${al[f.combinator]} `:" "),[N,x]=f.not||!h?[`${f.not?"!":""}(`,")"]:["",""];return v?`${N}${v}${x}`:o};return u(e,!0)},cl=e=>e.startsWith("not")||e.startsWith("doesnot"),jo=(e,t)=>typeof e!="string"||!t?`${e}`:e.replaceAll('"','\\"'),mk=(e,t={})=>{const{escapeQuotes:r,parseNumbers:o,preserveValueOrder:n}=t,{field:s,operator:a,value:i,valueSource:c}=e,d=c==="field"||c==="parameter",p=$e(a==="="?"==":a),u=typeof i=="number"||typeof i=="boolean"||typeof i=="bigint"||be(i,o),f=qt(e);if(f===!1)return"";if(f){const{mode:h,threshold:g}=f,y=t.subqueryDepth??0,b=il(y),v=tg(oo(e.value,{ruleProcessor:N=>({...N,field:`${b}${N.field?`.${N.field}`:""}`})}),{...t,subqueryDepth:y+1});switch(h){case"all":return`${s}.all(${b}, ${v})`;case"none":case"some":return`${h==="none"?"!":""}${s}.exists(${b}, ${v})`;case"atleast":case"atmost":case"exactly":{const N=`double(${s}.size())`,x=`${s}.filter(${b}, ${v}).size()`,w=h==="atleast"?">=":h==="atmost"?"<=":"==";return g>0&&g<1?`double(${x}) ${w} (${N} * ${g})`:`${x} ${w} ${g}`}}}switch(p){case"<":case"<=":case"==":case"!=":case">":case">=":return`${s} ${p} ${d||u?Be(i):`"${jo(i,r)}"`}`;case"contains":case"doesnotcontain":return`${cl(p)?"!":""}${s}.contains(${d?Be(i):`"${jo(i,r)}"`})`;case"beginswith":case"doesnotbeginwith":return`${cl(p)?"!":""}${s}.startsWith(${d?Be(i):`"${jo(i,r)}"`})`;case"endswith":case"doesnotendwith":return`${cl(p)?"!":""}${s}.endsWith(${d?Be(i):`"${jo(i,r)}"`})`;case"null":return`${s} == null`;case"notnull":return`${s} != null`;case"in":case"notin":{const[h,g]=cl(p)?["!(",")"]:["",""];return`${h}${s} in [${me(i).map(y=>d||be(y,o)?`${Be(y)}`:`"${jo(y,r)}"`).join(", ")}]${g}`}case"between":case"notbetween":{const h=me(i);if(h.length>=2&&!ro(h[0])&&!ro(h[1])){const[g,y]=h,b=o!==!1,v=be(g,b)?_e(g,{parseNumbers:b}):NaN,N=be(y,b)?_e(y,{parseNumbers:b}):NaN;let x=Number.isNaN(v)?d?`${g}`:`"${jo(g,r)}"`:v,w=Number.isNaN(N)?d?`${y}`:`"${jo(y,r)}"`:N;if(!n&&x===v&&w===N&&N<v){const C=N;w=v,x=C}return p==="between"?`(${s} >= ${x} && ${s} <= ${w})`:`(${s} < ${x} || ${s} > ${w})`}else return""}}return""},id={$and:[{$expr:!0}]},cd=(e,t,r)=>{const{context:o,fields:n,getParseNumberBoolean:s,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:c,ruleProcessor:d,validateRule:p,validationMap:u}=t,{inExpressionContext:f}=o??{},h=(g,y)=>{if(!Te(g,u[g.id??""]))return y?id:!1;const b=`$${$e(g.combinator)}`;let v=!1;const N=g.rules.map(w=>{if(ge(w)){const _=h(w);return _?(v=!0,_):!1}const[C,E]=p(w);if(!Te(w,C,E)||w.field===a||w.operator===i||c!==void 0&&w.value===c)return!1;const k=We(n,w.field);return d(w,{...t,parseNumbers:s(k==null?void 0:k.inputType),fieldData:k},r)}).filter(Boolean),x=N.length>0?N.length===1&&!v?N[0]:{[b]:N}:id;return g.not?f?{$not:x}:{$nor:[x]}:x};return h(Sr(e),!0)},no=(e,t,r=!1)=>be(e,r||typeof e=="bigint")?Number(_e(e,{parseNumbers:"strict"})):t,dl=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:s}=e,{parseNumbers:a,preserveValueOrder:i,context:c}=t,d=s==="field",{avoidFieldsAsKeys:p}=c??{},u=qt(e);if(u===!1)return;if(u){const{mode:h,threshold:g}=u,y={$size:{$ifNull:[`$${r}`,[]]}},b=cd(oo(n,{ruleProcessor:x=>({...x,field:x.field?`${r}.${x.field}`:r})}),{...t,ruleProcessor:dl,context:{...t.context,avoidFieldsAsKeys:!1}}),v=cd(oo(n,{ruleProcessor:x=>({...x,field:x.field?`$item.${x.field}`:"$item"})}),{...t,ruleProcessor:dl,context:{...t.context,avoidFieldsAsKeys:!0,inExpressionContext:!0}}),N={$size:{$ifNull:[{$filter:{input:`$${r}`,as:"item",cond:{$and:[v]}}},[]]}};switch(h){case"all":return{$expr:{$eq:[N,y]}};case"none":return{$nor:[b]};case"some":return b;case"atleast":case"atmost":case"exactly":{const x=h==="atleast"?Ho[">="]:h==="atmost"?Ho["<="]:Ho["="];return g>0&&g<1?{$expr:{[x]:[N,{$multiply:[y,g]}]}}:{$expr:{[x]:[N,g]}}}}}if(o==="="&&!d)return p?{$eq:[`$${r}`,no(n,n,a)]}:{[r]:no(n,n,a)};const f=$e(o);switch(f){case"<":case"<=":case"=":case"!=":case">":case">=":{const h=Ho[f];return d?{[h]:[`$${r}`,`$${n}`]}:p?{$and:[{$ne:[`$${r}`,null]},{[h]:[`$${r}`,no(n,n,a)]}]}:{[r]:{[h]:no(n,n,a)}}}case"contains":return d?{$where:`this.${r}.includes(this.${n})`}:p?{$regexMatch:{input:`$${r}`,regex:n}}:{[r]:{$regex:n}};case"beginswith":return d?{$where:`this.${r}.startsWith(this.${n})`}:p?{$regexMatch:{input:`$${r}`,regex:`^${n}`}}:{[r]:{$regex:`^${n}`}};case"endswith":return d?{$where:`this.${r}.endsWith(this.${n})`}:p?{$regexMatch:{input:`$${r}`,regex:`${n}$`}}:{[r]:{$regex:`${n}$`}};case"doesnotcontain":return d?{$where:`!this.${r}.includes(this.${n})`}:p?{$not:{$regexMatch:{input:`$${r}`,regex:n}}}:{[r]:{$not:{$regex:n}}};case"doesnotbeginwith":return d?{$where:`!this.${r}.startsWith(this.${n})`}:p?{$not:{$regexMatch:{input:`$${r}`,regex:`^${n}`}}}:{[r]:{$not:{$regex:`^${n}`}}};case"doesnotendwith":return d?{$where:`!this.${r}.endsWith(this.${n})`}:p?{$not:{$regexMatch:{input:`$${r}`,regex:`${n}$`}}}:{[r]:{$not:{$regex:`${n}$`}}};case"null":return p?{$eq:[`$${r}`,null]}:{[r]:null};case"notnull":return p?{$ne:[`$${r}`,null]}:{[r]:{$ne:null}};case"in":case"notin":{const h=me(n);return d?{$where:`${f==="notin"?"!":""}[${h.map(g=>`this.${g}`).join(",")}].includes(this.${r})`}:p?f==="notin"?{$not:{[Ho.in]:[`$${r}`,h.map(g=>no(g,g,a))]}}:{[Ho[f]]:[`$${r}`,h.map(g=>no(g,g,a))]}:{[r]:{[Ho[f]]:h.map(g=>no(g,g,a))}}}case"between":case"notbetween":{const h=me(n);if(h.length>=2&&ft(h[0])&&ft(h[1])){const[g,y]=h,b=no(g,NaN,!0),v=no(y,NaN,!0);let N=d||Number.isNaN(b)?g:b,x=d||Number.isNaN(v)?y:v;if(!i&&N===b&&x===v&&v<b){const w=v;x=b,N=w}return f==="between"?d?{$gte:[`$${r}`,`$${N}`],$lte:[`$${r}`,`$${x}`]}:p?{$and:[{$gte:[`$${r}`,N]},{$lte:[`$${r}`,x]}]}:{[r]:{$gte:N,$lte:x}}:d?{$or:[{$lt:[`$${r}`,`$${N}`]},{$gt:[`$${r}`,`$${x}`]}]}:p?{$or:[{$lt:[`$${r}`,N]},{$gt:[`$${r}`,x]}]}:{$or:[{[r]:{$lt:N}},{[r]:{$gt:x}}]}}else return""}}return""},gk=(e,t)=>{const r=dl(e,t);return r?JSON.stringify(r):""},rg=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:s,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!Te(f,p[f.id??""]))return h?o:"";const g=[];let y="",b=!0;for(const w of f.rules){if(typeof w=="string"){y=w;continue}if(ge(w)){const D=u(w);D&&(!b&&y&&(g.push(y),y=""),b=!1,g.push(D));continue}const[C,E]=d(w);if(!Te(w,C,E)||w.field===s||w.operator===a||i!==void 0&&w.value===i)continue;const k=We(r,w.field),_=c(w,{...t,parseNumbers:n(k==null?void 0:k.inputType),escapeQuotes:(w.valueSource??"value")==="value",fieldData:k});_&&(!b&&y&&(g.push(y),y=""),b=!1,g.push(_))}const v=g.join(Vt(f)?` ${f.combinator} `:" "),[N,x]=f.not||!h?[`${f.not?"!":""}(`,")"]:["",""];return v?`${N}${v}${x}`:o};return u(e,!0)},ul=e=>e.startsWith("not")||e.startsWith("doesnot"),dd=(e,t)=>t?`!(${e})`:e,qo=(e,t)=>typeof e!="string"||!t?`${e}`:e.replaceAll("'","\\'"),bk=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:s}=e,{escapeQuotes:a,parseNumbers:i,preserveValueOrder:c}=t,d=s==="field"||s==="parameter",p=$e(o==="="?"==":o),u=typeof n=="number"||typeof n=="boolean"||typeof n=="bigint"||be(n,i),f=qt(e);if(f===!1)return"";if(f){const{mode:h,threshold:g}=f,y=rg(oo(e.value,{ruleProcessor:N=>({...N,field:N.field||"#this"})}),t),b=`${r}.size()`,v=`${r}.?[${y}].size()`;switch(h){case"all":return`${v} == ${b}`;case"none":return`${v} == 0`;case"some":return`${v} >= 1`;case"atleast":case"atmost":case"exactly":{const N=h==="atleast"?">=":h==="atmost"?"<=":"==";return g>0&&g<1?`${v} ${N} (${b} * ${g})`:`${v} ${N} ${g}`}}}switch(p){case"<":case"<=":case"==":case"!=":case">":case">=":return`${r} ${p} ${d||u?Be(n):`'${qo(n,a)}'`}`;case"contains":case"doesnotcontain":{const h=d?`'.*'.concat(${Be(n)}).concat('.*')`:`'.*${qo(n,a)}.*'`;return dd(`${r} matches ${h}`,ul(p))}case"beginswith":case"doesnotbeginwith":{const h=d?`'^'.concat(${Be(n)}).concat('.*')`:`'${typeof n=="string"&&!n.startsWith("^")||u?"^":""}${qo(n,a)}.*'`;return dd(`${r} matches ${h}`,ul(p))}case"endswith":case"doesnotendwith":{const h=d?`'.*'.concat(${Be(n)}).concat('$')`:`'.*${qo(n,a)}${typeof n=="string"&&!n.endsWith("$")||u?"$":""}'`;return dd(`${r} matches ${h}`,ul(p))}case"null":return`${r} == null`;case"notnull":return`${r} != null`;case"in":case"notin":{const h=ul(p)?"!":"",g=me(n);return g.length>0?`${h}(${g.map(y=>`${r} == ${d||be(y,i)?`${Be(y)}`:`'${qo(y,a)}'`}`).join(" or ")})`:""}case"between":case"notbetween":{const h=me(n);if(h.length>=2&&!ro(h[0])&&!ro(h[1])){const[g,y]=h,b=i!==!1,v=be(g,b)?_e(g,{parseNumbers:b}):NaN,N=be(y,b)?_e(y,{parseNumbers:b}):NaN;let x=Number.isNaN(v)?d?`${g}`:`'${qo(g,a)}'`:v,w=Number.isNaN(N)?d?`${y}`:`'${qo(y,a)}'`:N;if(!c&&x===v&&w===N&&N<v){const C=N;w=v,x=C}return p==="between"?`(${r} >= ${x} and ${r} <= ${w})`:`(${r} < ${x} or ${r} > ${w})`}else return""}}return""},yk=(e,t,r)=>r&&typeof e=="string"?e.replaceAll(`${t}`,`${t}${t}`):e,is=({operator:e,value:t,valueSource:r},{escapeQuotes:o,parseNumbers:n,preserveValueOrder:s,quoteFieldNamesWith:a,quoteValuesWith:i,concatOperator:c="||",fieldIdentifierSeparator:d,paramPrefix:p,wrapValueWith:u=["",""],translations:f}={})=>{if(r==="parameter"){const C=$e(e);if(C==="between"||C==="notbetween"){const k=me(t,{retainEmptyStrings:!0});if(k.length<2||!ft(k[0])||!ft(k[1]))return"";const[_,D]=k;return[ls(_,p),ls(D,p)].join(` ${(f==null?void 0:f.betweenAnd)??(f==null?void 0:f.and)??"and"} `)}if(C==="in"||C==="notin"){const k=me(t);return k.length===0?"":`(${k.map(_=>ls(_,p)).join(", ")})`}const E=ls(t,p);switch(C){case"contains":case"doesnotcontain":case"beginswith":case"doesnotbeginwith":case"endswith":case"doesnotendwith":return as(E,C,{concatOperator:c,quoteValuesWith:i,wrapValueWith:u})}return E}const h=r==="field",g=$e(e),y=i||"'",b=C=>`${u[0]}${y}${C}${y}${u[1]}`,v=C=>yk(C,y,o),N=C=>b(v(C)),x=C=>wn(C,{quoteFieldNamesWith:a,fieldIdentifierSeparator:d}),w={concatOperator:c,quoteValuesWith:i,wrapValueWith:u};switch(g){case"null":case"notnull":return"";case"in":case"notin":{const C=me(t);return C.length>0?`(${C.map(E=>h?x(E):be(E,n)?`${Be(E)}`:`${N(E)}`).join(", ")})`:""}case"between":case"notbetween":{const C=me(t,{retainEmptyStrings:!0});if(C.length<2||!ft(C[0])||!ft(C[1]))return"";const[E,k]=C,_=be(E,n)?_e(E,{parseNumbers:"strict"}):NaN,D=be(k,n)?_e(k,{parseNumbers:"strict"}):NaN,A=Number.isNaN(_)?h?`${E}`:E:_,I=Number.isNaN(D)?h?`${k}`:k:D,T=[A,I];return!s&&A===_&&I===D&&D<_&&(T[0]=D,T[1]=_),(h?T.map(L=>x(L)):T.every(L=>be(L,n))?T.map(L=>_e(L,{parseNumbers:"strict"})):T.map(L=>N(L))).join(` ${(f==null?void 0:f.betweenAnd)??(f==null?void 0:f.and)??"and"} `)}case"contains":case"doesnotcontain":return h?as(x(t),g,w):b(`%${v(t)}%`);case"beginswith":case"doesnotbeginwith":return h?as(x(t),g,w):b(`${v(t)}%`);case"endswith":case"doesnotendwith":return h?as(x(t),g,w):b(`%${v(t)}`)}return typeof t=="boolean"?t?"TRUE":"FALSE":h?x(t):be(t,n)?`${Be(t)}`:`${N(t)}`},og={and:"AND",or:"OR"},vk=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:s,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!Te(f,p[f.id??""]))return h?o:"";const g=[];let y="",b=!0;for(const w of f.rules){if(typeof w=="string"){y=og[w];continue}if(ge(w)){const D=u(w);D&&(!b&&y&&(g.push(y),y=""),b=!1,g.push(D));continue}const[C,E]=d(w);if(!Te(w,C,E)||w.field===s||w.operator===a||i!==void 0&&w.value===i)continue;const k=We(r,w.field),_=c(w,{...t,parseNumbers:n(k==null?void 0:k.inputType),escapeQuotes:(w.valueSource??"value")==="value",fieldData:k});_&&(!b&&y&&(g.push(y),y=""),b=!1,g.push(_))}const v=g.join(Vt(f)?` ${og[f.combinator]} `:" "),[N,x]=f.not||!h?[`${f.not?"NOT ":""}(`,")"]:["",""];return v?`${N}${v}${x}`:o};return u(e,!0)},ng=(e,t,r)=>(o,n)=>{const{fields:s,getParseNumberBoolean:a,placeholderFieldName:i,placeholderOperatorName:c,placeholderValueName:d,validateRule:p,validationMap:u,ruleProcessor:f}=t;if(!o||!n)return;const{and:h,not:g,or:y}=n,b=(v,N)=>{if(!Te(v,u[v.id??""]))return;const x=v.rules.map(C=>{if(ge(C))return b(C);const[E,k]=p(C);if(!Te(C,E,k)||C.field===i||C.operator===c||d!==void 0&&C.value===d)return;const _=We(s,C.field);return f(C,{...t,parseNumbers:a(_==null?void 0:_.inputType),fieldData:_,context:{...t.context,columns:o,drizzleOperators:n}})}).filter(Boolean);if(x.length===0)return;const w=v.combinator==="or"?y(...x):h(...x);return v.not?g(w):w};return b(Sr(e))},sg=(e,t)=>{const{fields:r,getParseNumberBoolean:o,placeholderFieldName:n,placeholderOperatorName:s,placeholderValueName:a,ruleProcessor:i,validateRule:c,validationMap:d}=t,p=f=>{if(!Te(f,d[f.id??""]))return!1;const h=f.rules.map(g=>{if(ge(g))return p(g);const[y,b]=c(g);if(!Te(g,y,b)||g.field===n||g.operator===s||a!==void 0&&g.value===a)return!1;const v=We(r,g.field);return i(g,{...t,parseNumbers:o(v==null?void 0:v.inputType),fieldData:v})}).filter(Boolean);return h.length===0?!1:{bool:f.not?{must_not:/^or$/i.test(f.combinator)?{bool:{should:h}}:h}:{[/^or$/i.test(f.combinator)?"should":"must"]:h}}},u=p(Sr(e));return u===!1?{}:u},xk=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:s,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=g=>{// v8 ignore next -- @preserve
177
- if(typeof g=="string"||ge(g))return;const[y,b]=d(g);if(!Te(g,y,b)||g.field===s||g.operator===a||i!==void 0&&g.value===i)return;const v=We(r,g.field);return c(g,{...t,parseNumbers:n(v==null?void 0:v.inputType),escapeQuotes:(g.valueSource??"value")==="value",fieldData:v})},f=g=>{if(!Te(g,p[g.id??""]))return"";const y=[];for(const N of g.rules){if(typeof N=="string")continue;if(ge(N)){const w=f(N);w&&y.push(w);continue}const x=u(N);x&&y.push(x)}if(y.length===0)return"";const b=g.combinator??"and",v=g.not?"not":b;return y.length===1&&!g.not?y[0]:`.${v}(${y.map(N=>N.startsWith(".")?`__${N}`:N).join(", ")})`};if(!Te(e,p[e.id??""]))return o;const h=[];for(const g of e.rules){if(typeof g=="string")continue;if(ge(g)){const b=f(g);b&&h.push(b);continue}const y=u(g);y&&h.push(y)}return h.length===0?o:h.join("")},ag=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:s,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!Te(f,p[f.id??""]))return h?o:"";const g=[];let y="",b=!0;for(const w of f.rules){if(typeof w=="string"){y=w;continue}if(ge(w)){const D=u(w);D&&(!b&&y&&(g.push(y),y=""),b=!1,g.push(D));continue}const[C,E]=d(w);if(!Te(w,C,E)||w.field===s||w.operator===a||i!==void 0&&w.value===i)continue;const k=We(r,w.field),_=c(w,{...t,parseNumbers:n(k==null?void 0:k.inputType),escapeQuotes:(w.valueSource??"value")==="value",fieldData:k});_&&(!b&&y&&(g.push(y),y=""),b=!1,g.push(_))}const v=g.join(Vt(f)?` ${f.combinator} `:" "),[N,x]=f.not||!h?[`${f.not?"$not":""}(`,")"]:["",""];return v?`${N}${v}${x}`:o};return u(e,!0)},ud=(e,t)=>{const{fields:r,getParseNumberBoolean:o,placeholderFieldName:n,placeholderOperatorName:s,placeholderValueName:a,ruleProcessor:i,validateRule:c,validationMap:d}=t,p=Sr(e),u=(f,h)=>{if(!Te(f,d[f.id??""]))return!1;const g=f.rules.map(b=>{if(ge(b))return u(b);const[v,N]=c(b);if(!Te(b,v,N)||b.field===n||b.operator===s||a!==void 0&&b.value===a)return!1;const x=We(r,b.field);return i(b,{...t,parseNumbers:o(x==null?void 0:x.inputType),fieldData:x})}).filter(Boolean);if(g.length===0)return!1;const y={[f.combinator]:g};return f.not?{"!":y}:y};return u(p)},wk=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:s,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!Te(f,p[f.id??""]))return h?o:"";const g=f.rules.map(w=>{if(ge(w))return u(w);const[C,E]=d(w);if(!Te(w,C,E)||w.field===s||w.operator===a||i!==void 0&&w.value===i)return"";const k=We(r,w.field);return c(w,{...t,parseNumbers:n(k==null?void 0:k.inputType),escapeQuotes:(w.valueSource??"value")==="value",fieldData:k})}).filter(Boolean),y=g.join(""),[b,v]=f.not?["(!",")"]:["",""],[N,x]=g.length>1?[`${b}(${f.combinator==="or"?"|":"&"}`,`)${v}`]:[b,v];return y?`${N}${y}${x}`:o};return u(Sr(e),!0)},fd=e=>e.startsWith("{")&&e.endsWith("}"),Sk=(e,t,r)=>{const{fields:o,fallbackExpression:n,getParseNumberBoolean:s,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:c,ruleProcessor:d,validateRule:p,validationMap:u}=t,f=(g,y)=>{if(!Te(g,u[g.id??""]))return y?n:"";const b=`"$${$e(g.combinator)}"`;let v=!1;const N=g.rules.map(w=>{if(ge(w)){const _=f(w);return _?(v=!0,fd(_)?_:`{${_}}`):""}const[C,E]=p(w);if(!Te(w,C,E)||w.field===a||w.operator===i||c!==void 0&&w.value===c)return"";const k=We(o,w.field);return d(w,{...t,parseNumbers:s(k==null?void 0:k.inputType),fieldData:k},r)}).filter(Boolean),x=N.length>0?N.length===1&&!v?N[0]:`${b}:[${N.join(",")}]`:n;return g.not?`"$nor":[${fd(x)?x:`{${x}}`}]`:x},h=f(Sr(e),!0);return fd(h)?h:`{${h}}`},lg=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:s,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:c,translations:d,validateRule:p,validationMap:u}=t,f=(h,g)=>{if(!Te(h,u[h.id??""]))return g?o:"";const y=yn(h)&&h.rules.some(I=>typeof I=="string"&&$e(I)==="xor")?Sr(h):h,b=[];let v="",N=!0;for(const I of y.rules){if(typeof I=="string"){v=`${d.ruleSeparator??", "}${d[I]??I} `;continue}if(ge(I)){const z=f(I,y.rules.length===1&&!(y.not||/^xor$/i.test(y.combinator??"")));z&&(!N&&v&&(b.push(v),v=""),N=!1,b.push(z));continue}const[T,L]=p(I);if(!Te(I,T,L)||I.field===s||I.operator===a||i!==void 0&&I.value===i)continue;const F=(I.valueSource??"value")==="value",B=We(r,I.field),G=c(I,{...t,parseNumbers:n(B==null?void 0:B.inputType),escapeQuotes:F,fieldData:B});G&&(!N&&v&&(b.push(v),v=""),N=!1,b.push(G))}if(b.length===0)return o;const x=$e(y.combinator??"")==="xor",w=x?y.combinator.slice(1):y.combinator,C=y.not||!g||x&&b.length>1,[E,k]=["groupPrefix","groupSuffix"].map(I=>y.not?x?ll(I,d,["not","xor"]):ll(I,d,["not"]):x?ll(I,d,["xor"]):ll(I,d)),_=C?`${E} (`.trim():"",D=C?`) ${k}`.trim():"",A=d.ruleSeparator??", ";return`${_}${b.join(Vt(y)?`${A}${d[w]??w} `:"")}${D}`};return f(e,!0)},ig=(e,t)=>{const{format:r,fields:o,fallbackExpression:n,getParseNumberBoolean:s,placeholderFieldName:a,placeholderOperatorName:i,placeholderValueName:c,ruleProcessor:d,validateRule:p,validationMap:u}=t,f=r==="parameterized",h=[],g={},y=new Map,b=x=>{y.has(x)||y.set(x,new Set);const w=`${x}_${y.get(x).size+1}`;return y.get(x).add(w),w},v=x=>{var I;const[w,C]=p(x);if(!Te(x,w,C)||x.field===a||x.operator===i||c!==void 0&&x.value===c)return"";const E=We(o,x.field),k=Object.fromEntries([...y.entries()].map(([T,L])=>[T,[...L]])),_=d(x,{...t,parseNumbers:s(E==null?void 0:E.inputType),getNextNamedParam:b,fieldParamNames:k,fieldData:E},{processedParams:h});if(!wr(_))return"";const{sql:D,params:A}=_;if(typeof D!="string"||!D)return"";if(r==="parameterized"&&Array.isArray(A))h.push(...A);else if(r==="parameterized_named"&&wr(A)){Object.assign(g,A);for(const T of Object.keys(A))(I=y.get(x.field))==null||I.add(T)}return D},N=(x,w)=>{if(!Te(x,u[x.id??""]))return w?n:"";const C=[];let E="",k=!0;for(const _ of x.rules){if(typeof _=="string"){E=_;continue}if(ge(_)){const A=N(_,x.rules.length===1);A&&(!k&&E&&(C.push(E),E=""),k=!1,C.push(A));continue}const D=v(_);D&&(!k&&E&&(C.push(E),E=""),k=!1,C.push(D))}return C.length===0?n:`${x.not?"NOT ":""}(${C.join(Vt(x)?` ${x.combinator} `:" ")})`};return f?{sql:N(e,!0),params:h}:{sql:N(e,!0),params:g}},pd={},Nk=(e,t)=>{const{fields:r,getParseNumberBoolean:o,placeholderFieldName:n,placeholderOperatorName:s,placeholderValueName:a,ruleProcessor:i,validateRule:c,validationMap:d}=t,p=(f,h)=>{if(!Te(f,d[f.id??""]))return h?pd:void 0;const g=f.combinator.toUpperCase();let y=!1;const b=f.rules.map(v=>{if(ge(v)){const C=p(v);return C?(y=!0,C):void 0}const[N,x]=c(v);if(!Te(v,N,x)||v.field===n||v.operator===s||a!==void 0&&v.value===a)return;const w=We(r,v.field);return i(v,{...t,parseNumbers:o(w==null?void 0:w.inputType),fieldData:w})}).filter(Boolean);return b.length>0?b.length===1&&!y?b[0]:{[g]:b}:pd},u=p(Sr(e),!0);return e.not?{NOT:u}:u},Ck=(e,t)=>{const{fields:r,getParseNumberBoolean:o,placeholderFieldName:n,placeholderOperatorName:s,placeholderValueName:a,ruleProcessor:i,validateRule:c,validationMap:d,context:p={}}=t,{sequelizeOperators:u}=p;if(!u)return;const f=(h,g)=>{if(!Te(h,d[h.id??""]))return;const y=h.combinator.toUpperCase();let b=!1;const v=h.rules.map(x=>{if(ge(x)){const k=f(x);return k?(b=!0,k):void 0}const[w,C]=c(x);if(!Te(x,w,C)||x.field===n||x.operator===s||a!==void 0&&x.value===a)return;const E=We(r,x.field);return i(x,{...t,parseNumbers:o(E==null?void 0:E.inputType),fieldData:E})}).filter(Boolean);if(v.length===0)return;const N=v.length===1&&!b?v[0]:{[$e(y)==="or"?u.or:u.and]:v};return h.not?{[u.not]:N}:N};return f(Sr(e))},Ek=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:s,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!Te(f,p[f.id??""]))return h?o:"";const g=[];let y="",b=!0;for(const w of f.rules){if(typeof w=="string"){y=al[w];continue}if(ge(w)){const D=u(w);D&&(!b&&y&&(g.push(y),y=""),b=!1,g.push(D));continue}const[C,E]=d(w);if(!Te(w,C,E)||w.field===s||w.operator===a||i!==void 0&&w.value===i)continue;const k=We(r,w.field),_=c(w,{...t,parseNumbers:n(k==null?void 0:k.inputType),escapeQuotes:(w.valueSource??"value")==="value",fieldData:k});_&&(!b&&y&&(g.push(y),y=""),b=!1,g.push(_))}const v=g.join(Vt(f)?` ${al[f.combinator]} `:" "),[N,x]=f.not||!h?[`${f.not?"!":""}(`,")"]:["",""];return v?`${N}${v}${x}`:o};return u(e,!0)},cg=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:s,placeholderOperatorName:a,placeholderValueName:i,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!Te(f,p[f.id??""]))return h?o:"";const g=[];let y="",b=!0;for(const v of f.rules){if(typeof v=="string"){y=v;continue}if(ge(v)){const k=u(v,f.rules.length===1);k&&(!b&&y&&(g.push(y),y=""),b=!1,g.push(k));continue}const[N,x]=d(v);if(!Te(v,N,x)||v.field===s||v.operator===a||i!==void 0&&v.value===i)continue;const w=(v.valueSource??"value")==="value",C=We(r,v.field),E=c(v,{...t,parseNumbers:n(C==null?void 0:C.inputType),escapeQuotes:w,fieldData:C});E&&(!b&&y&&(g.push(y),y=""),b=!1,g.push(E))}return g.length===0?o:`${f.not?"NOT ":""}(${g.join(Vt(f)?` ${f.combinator} `:" ")})`};return u(e,!0)},_k=(e,t)=>r=>{const{fields:o,getParseNumberBoolean:n,placeholderFieldName:s,placeholderOperatorName:a,placeholderValueName:i,validateRule:c,validationMap:d,context:p={},ruleProcessor:u}=t,f=p.tanStackDbOperators;if(!f)return;const{and:h,eq:g,not:y,or:b}=f,v=g(1,1),N=Object.keys(r);/* v8 ignore next -- @preserve */if(N.length===0)return v;const x=w=>{if(!Te(w,d[w.id??""]))return;const C=w.rules.map(k=>{if(ge(k))return x(k);const[_,D]=c(k);if(!Te(k,_,D)||k.field===s||k.operator===a||i!==void 0&&k.value===i)return;const A=We(o,k.field);return u(k,{...t,parseNumbers:n(A==null?void 0:A.inputType),fieldData:A,context:{...p,_tanstackDbRefs:r,_tanstackDbPrimaryRef:N[0]}})}).filter(Boolean);if(C.length===0)return v;const E=C.length===1?C[0]:w.combinator==="or"?b(...C):h(...C);return w.not?y(E):E};return x(Sr(e))??v},kk=new Set(["number","range","bigint"]),dg=/^\d{4}-\d{2}-\d{2}$/,ug=/^\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/,Ak=/^\d{4}-\d{2}$/,Dk=/^\d{4}-W\d{2}$/,$k=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,Tk=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,fg=(e,t,r)=>{const o=new Date(Date.UTC(e,t-1,r));return o.getUTCFullYear()===e&&o.getUTCMonth()===t-1&&o.getUTCDate()===r},pg=e=>{const t=e.split(":"),r=Number(t[0]),o=Number(t[1]),n=t[2]?Number.parseFloat(t[2]):0;return r>=0&&r<=23&&o>=0&&o<=59&&n>=0&&n<60},Pk=(e,t)=>{if(!(e==null||e==="")){if(kk.has(t)){const r=typeof e=="string"?e.trim():e;return typeof r=="number"||typeof r=="bigint"||typeof r=="string"&&Gm.test(r)?void 0:"VALUE_TYPE_MISMATCH"}if(t==="date"){if(typeof e!="string")return"VALUE_TYPE_MISMATCH";const r=e.trim();if(!dg.test(r))return"VALUE_TYPE_MISMATCH";const[o,n,s]=r.split("-").map(Number);return fg(o,n,s)?void 0:"VALUE_TYPE_MISMATCH"}if(t==="datetime-local"){if(typeof e!="string")return"VALUE_TYPE_MISMATCH";const r=e.trim().replace(/(Z|[+-]\d{2}:?\d{2}|[+-]\d{2})$/,""),o=r.indexOf("T");if(o===-1)return"VALUE_TYPE_MISMATCH";const n=r.slice(0,o),s=r.slice(o+1);if(!dg.test(n)||!ug.test(s))return"VALUE_TYPE_MISMATCH";const[a,i,c]=n.split("-").map(Number);return fg(a,i,c)&&pg(s)?void 0:"VALUE_TYPE_MISMATCH"}if(t==="time"){if(typeof e!="string")return"VALUE_TYPE_MISMATCH";const r=e.trim();return ug.test(r)&&pg(r)?void 0:"VALUE_TYPE_MISMATCH"}if(t==="month"){if(typeof e!="string")return"VALUE_TYPE_MISMATCH";const r=e.trim();if(!Ak.test(r))return"VALUE_TYPE_MISMATCH";const o=Number(r.slice(5));return o>=1&&o<=12?void 0:"VALUE_TYPE_MISMATCH"}if(t==="week"){if(typeof e!="string")return"VALUE_TYPE_MISMATCH";const r=e.trim();if(!Dk.test(r))return"VALUE_TYPE_MISMATCH";const o=Number(r.slice(6));return o>=1&&o<=53?void 0:"VALUE_TYPE_MISMATCH"}if(t==="color")return typeof e!="string"?"VALUE_TYPE_MISMATCH":$k.test(e.trim())?void 0:"VALUE_TYPE_MISMATCH";if(t==="url"){if(typeof e!="string")return"VALUE_TYPE_MISMATCH";try{new URL(e.trim());return}catch{return"VALUE_TYPE_MISMATCH"}}if(t==="email")return typeof e!="string"?"VALUE_TYPE_MISMATCH":Tk.test(e.trim())?void 0:"VALUE_TYPE_MISMATCH"}},Ik=(e,t)=>{const{fields:r,placeholderFieldName:o,placeholderOperatorName:n,placeholderValueName:s,validateRule:a,validationMap:i}=t,c=[],d={totalRules:0,totalGroups:0,validRules:0,invalidRules:0,validGroups:0,invalidGroups:0},p={},u=nd(r),f=new Map;for(const b of u)f.set(b.name,b);const h=f.size>0,g=(b,v)=>{d.totalGroups++;const N=v.length,x=i[b.id??""],w=Te(b,x),C=hg(x);b.muted?c.push({id:b.id??"",path:v,code:"MUTED",message:"Group is muted",source:"muted"}):!w&&x!==void 0&&c.push({id:b.id??"",path:v,code:"CUSTOM_VALIDATOR",message:C?`Invalid: ${C.join(", ")}`:"Group failed validation",source:"query-validator"});let E=!0,k=0;const _=[];for(const A of b.rules){if(typeof A=="string"){_.push(A),k++;continue}const I=[...v,k];if(ge(A)){const V=g(A,I);V.valid||(E=!1),_.push(V),k++;continue}d.totalRules++;const T=I.length,[L,F]=a(A),B=Te(A,L,F)&&A.field!==o&&A.operator!==n&&!(s!==void 0&&A.value===s);Ok(A,I,L,F,B,c,o,n,s,h,f),B?d.validRules++:(E=!1,d.invalidRules++);const G=A.field;p[G]||(p[G]={ruleCount:0,invalidCount:0}),p[G].ruleCount++,B||p[G].invalidCount++;const z=hg(L)??Mk(A,F),H={...A,valid:B,...z?{reasons:z}:null,path:I,level:T};_.push(H),k++}const D=w&&E;return D?d.validGroups++:d.invalidGroups++,Vt(b)?{...b,valid:D,...C?{reasons:C}:null,path:v,level:N,rules:_}:{...b,valid:D,...C?{reasons:C}:null,path:v,level:N,rules:_}},y=g(e,[]);if(h){const b=new Set(Object.keys(p));for(const[v]of f)b.has(v)||c.push({id:"",path:[],code:"UNREFERENCED_FIELD",message:`Field "${v}" is defined in the fields config but not used in the query`,source:"field-check"})}return{query:y,diagnostics:c,stats:d,fieldSummary:p}},Ok=(e,t,r,o,n,s,a,i,c,d,p)=>{const u=e.id??"";if(e.muted&&s.push({id:u,path:t,code:"MUTED",message:"Rule is muted",source:"muted"}),e.field===a&&s.push({id:u,path:t,code:"PLACEHOLDER_FIELD",message:"Rule has a placeholder field",source:"placeholder"}),e.operator===i&&s.push({id:u,path:t,code:"PLACEHOLDER_OPERATOR",message:"Rule has a placeholder operator",source:"placeholder"}),c!==void 0&&e.value===c&&s.push({id:u,path:t,code:"PLACEHOLDER_VALUE",message:"Rule has a placeholder value",source:"placeholder"}),!e.muted&&e.field!==a&&e.operator!==i&&!(c!==void 0&&e.value===c)){if(typeof r=="boolean"&&!r)s.push({id:u,path:t,code:"CUSTOM_VALIDATOR",message:"Rule failed validation",source:"query-validator"});else if(typeof r!="boolean"&&xn(r)&&!r.valid){const f=r.reasons;s.push({id:u,path:t,code:"CUSTOM_VALIDATOR",message:f?`Invalid: ${f.join(", ")}`:"Rule failed validation",source:"query-validator"})}else if(!n&&typeof o=="function"){const f=o(e),h=typeof f!="boolean"&&xn(f)&&!f.valid?f.reasons:void 0;s.push({id:u,path:t,code:"CUSTOM_VALIDATOR",message:h?`Invalid: ${h.join(", ")}`:"Rule failed field validation",source:"field-validator"})}}if(d&&!p.has(e.field)&&e.field!==a&&s.push({id:u,path:t,code:"UNDEFINED_FIELD",message:`Field "${e.field}" is not defined in the fields config`,source:"field-check"}),d){const f=p.get(e.field);if(f!=null&&f.inputType){const h=Pk(e.value,f.inputType);h&&s.push({id:u,path:t,code:h,message:`Value "${e.value}" is not compatible with input type "${f.inputType}"`,source:"type-check"})}}},hg=e=>{if(typeof e!="boolean"&&xn(e)&&!e.valid&&e.reasons)return e.reasons},Mk=(e,t)=>{if(typeof t=="function"){const r=t(e);if(typeof r!="boolean"&&xn(r)&&!r.valid&&r.reasons)return r.reasons}},Lk=(e,t)=>typeof e!="string"||!t?`${e}`:e.replaceAll("'","\\'"),mg=(e,t={})=>{const{escapeQuotes:r,parseNumbers:o}=t,{field:n,operator:s,value:a,valueSource:i}=e,c=i==="field",d=s.toLowerCase(),p=u=>u==null?"null":typeof u=="boolean"||typeof u=="bigint"?String(u):c||typeof u=="number"||be(u,o)?Be(u):`'${Lk(u,r)}'`;switch(d){case"=":return`${n} = ${p(a)}`;case"!=":case"<>":return`${n} <> ${p(a)}`;case"<":case">":case"<=":case">=":return`${n} ${d} ${p(a)}`;case"contains":return`${n} CONTAINS ${p(a)}`;case"doesnotcontain":return`NOT ${n} CONTAINS ${p(a)}`;case"beginswith":return`${n} STARTS WITH ${p(a)}`;case"doesnotbeginwith":return`NOT ${n} STARTS WITH ${p(a)}`;case"endswith":return`${n} ENDS WITH ${p(a)}`;case"doesnotendwith":return`NOT ${n} ENDS WITH ${p(a)}`;case"null":return`${n} IS NULL`;case"notnull":return`${n} IS NOT NULL`;case"in":case"notin":{const u=me(a).map(p);return u.length?`${d==="notin"?"NOT ":""}${n} IN [${u.join(", ")}]`:""}case"between":case"notbetween":{const u=me(a);if(u.length<2)return"";const[f,h]=[p(u[0]),p(u[1])],g=`${f} <= ${n} AND ${n} <= ${h}`;return d==="notbetween"?`NOT (${g})`:g}default:return`${n} ${s} ${p(a)}`}},Fk=(e,t)=>{const r=t??{},{parseNumbers:o,preserveValueOrder:n,context:s={}}=r,{columns:a,drizzleOperators:i,useRawFields:c}=s;if(!a||!i)return;const{between:d,eq:p,gt:u,gte:f,inArray:h,isNotNull:g,isNull:y,like:b,lt:v,lte:N,ne:x,notBetween:w,notInArray:C,notLike:E,sql:k}=i,{field:_,operator:D,value:A,valueSource:I}=e,T=c&&/^[a-z_][a-z0-9_.]*$/i.test(_)?k.raw(_):a[_],L=$e(D),F=I==="field",B=H=>F?a[H]:H,G=H=>F||!o?B(H):be(H,!0)?_e(H,{parseNumbers:!0}):H;if(!T)return;const z=qt(e);if(z!==!1){if(z){if(r.preset!=="postgresql")return;const{mode:H,threshold:V}=z,W=r.subqueryDepth??0,pe=il(W),U=ng(oo(e.value,{ruleProcessor:Q=>({...Q,field:pe})}),{...r,context:{...r.context,useRawFields:!0},subqueryDepth:W+1});switch(H){case"all":return k`(select count(*) from unnest(${T}) as ${k.raw(pe)} where ${U({},i)}) = array_length(${T}, 1)`;case"none":return k`not exists (select 1 from unnest(${T}) as ${k.raw(pe)} where ${U({},i)})`;case"some":return k`exists (select 1 from unnest(${T}) as ${k.raw(pe)} where ${U({},i)})`;case"atleast":case"atmost":case"exactly":{const Q=H==="atleast"?">=":H==="atmost"?"<=":"=";return V>0&&V<1?k`(select count(*)::float / array_length(${T}, 1) from unnest(${T}) as ${k.raw(pe)} where ${U({},i)}) ${k.raw(`${Q} ${V}`)}`:k`(select count(*) from unnest(${T}) as ${k.raw(pe)} where ${U({},i)}) ${k.raw(`${Q} ${V}`)}`}}}switch(L){case"=":return p(T,G(A));case"!=":return x(T,G(A));case">":return u(T,G(A));case"<":return v(T,G(A));case">=":return f(T,G(A));case"<=":return N(T,G(A));case"beginswith":case"doesnotbeginwith":return(L==="doesnotbeginwith"?E:b)(T,F?k`${B(A)} || '%'`:`${A}%`);case"contains":case"doesnotcontain":return(L==="doesnotcontain"?E:b)(T,F?k`'%' || ${B(A)} || '%'`:`%${A}%`);case"endswith":case"doesnotendwith":return(L==="doesnotendwith"?E:b)(T,F?k`'%' || ${B(A)}`:`%${A}`);case"null":return y(T);case"notnull":return g(T);case"in":case"notin":{const H=me(A).map(V=>G(V));return L==="notin"?C(T,H):h(T,H)}case"between":case"notbetween":{const H=me(A);if(H.length>=2&&ft(H[0])&&ft(H[1])){let[V,W]=H;const pe=o!==!1;if(!F&&be(V,pe)&&be(W,pe)){const U=_e(V,{parseNumbers:pe}),Q=_e(W,{parseNumbers:pe});if(!n&&Q<U){const Ce=Q;W=U,V=Ce}else V=U,W=Q}else F&&(V=B(V),W=B(W));return L==="notbetween"?w(T,V,W):d(T,V,W)}return}default:return}}},Vk={"<":"lt","<=":"lte",">":"gt",">=":"gte"},fl=(e,t)=>e.startsWith("not")||e.startsWith("doesnot")?{bool:{must_not:t}}:t,hd=e=>e==null?void 0:e.replace(/('|\\)/g,"\\$1"),Gk={beginswith:"startsWith",doesnotbeginwith:"startsWith",doesnotcontain:"contains",doesnotendwith:"endsWith",endswith:"endsWith"},zk=(e,t,r)=>{const o=`doc['${e}'].value.${Gk[t]??t}(doc['${r}'].value)`;return t.startsWith("d")?`!${o}`:o},cs=(e,t)=>typeof e=="boolean"?e:be(e,t)?_e(e,{parseNumbers:t}):e,Bk=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:s}=e,{parseNumbers:a,preserveValueOrder:i}=t,c=$e(o),d=qt(e);if(d===!1)return!1;if(d){const{mode:p}=d,u=sg(oo(e.value,{ruleProcessor:f=>({...f,field:f.field?`${r}.${f.field}`:r})}),t);if(Object.keys(u).length===0)return!1;switch(p){case"some":return{nested:{path:r,query:u}};case"none":return{bool:{must_not:{nested:{path:r,query:u}}}};case"all":case"atleast":case"atmost":case"exactly":return!1}}if(s==="field"){if(me(n).some(u=>typeof u!="string"))return!1;const p=hd(r);switch(c){case"=":case"!=":case">":case">=":case"<":case"<=":{const u=c==="="?"==":c,f=hd(n);return f?{bool:{filter:{script:{script:`doc['${p}'].value ${u} doc['${f}'].value`}}}}:!1}case"in":case"notin":{const u=me(n);if(u.length>0){const f=u.map(h=>({bool:{filter:{script:{script:`doc['${p}'].value == doc['${h}'].value`}}}}));return{bool:c==="in"?{should:f}:{must_not:f}}}return!1}case"between":case"notbetween":{const u=me(n);if(u.length>=2&&u[0]&&u[1]){const f=`doc['${p}'].value >= doc['${u[0]}'].value && doc['${p}'].value <= doc['${u[1]}'].value`;return{bool:{filter:{script:{script:c==="notbetween"?`!(${f})`:f}}}}}return!1}case"contains":case"doesnotcontain":case"beginswith":case"doesnotbeginwith":case"endswith":case"doesnotendwith":{const u=hd(n);return u?{bool:{filter:{script:{script:zk(p,c,u)}}}}:!1}}}switch(c){case"<":case"<=":case">":case">=":return{range:{[r]:{[Vk[c]]:cs(n,a)}}};case"=":return{term:{[r]:cs(n,a)}};case"!=":return{bool:{must_not:{term:{[r]:cs(n,a)}}}};case"null":return{bool:{must_not:{exists:{field:r}}}};case"notnull":return{exists:{field:r}};case"in":case"notin":{const p=me(n).map(u=>cs(u,a));if(p.length>0){const u=p.map(f=>({term:{[r]:cs(f,a)}}));return{bool:c==="in"?{should:u}:{must_not:u}}}return!1}case"between":case"notbetween":{const p=me(n);if(p.length>=2&&ft(p[0])&&ft(p[1])){let[u,f]=p;const h=a!==!1;if(be(u,h)&&be(f,h)){const g=_e(u,{parseNumbers:h}),y=_e(f,{parseNumbers:h});if(!i&&y<g){const b=y;f=g,u=b}else u=g,f=y}return fl(c,{range:{[r]:{gte:u,lte:f}}})}return!1}case"contains":case"doesnotcontain":return fl(c,{regexp:{[r]:{value:`.*${n}.*`}}});case"beginswith":case"doesnotbeginwith":return fl(c,{regexp:{[r]:{value:`${n}.*`}}});case"endswith":case"doesnotendwith":return fl(c,{regexp:{[r]:{value:`.*${n}`}}})}return!1},Uk=(e,t)=>typeof e!="string"||!t?`${e}`:e.replaceAll("'","\\'"),Wk=(e,t={})=>{const{escapeQuotes:r,parseNumbers:o}=t,{field:n,operator:s,value:a,valueSource:i}=e,c=i==="field",d=s.toLowerCase(),p=n.includes(".")?n.split(".").pop():n,u=f=>f==null?"null":typeof f=="boolean"||typeof f=="bigint"?String(f):c||typeof f=="number"||be(f,o)?Be(f):`'${Uk(f,r)}'`;switch(d){case"=":return`.has('${p}', ${u(a)})`;case"!=":case"<>":return`.has('${p}', neq(${u(a)}))`;case"<":return`.has('${p}', lt(${u(a)}))`;case">":return`.has('${p}', gt(${u(a)}))`;case"<=":return`.has('${p}', lte(${u(a)}))`;case">=":return`.has('${p}', gte(${u(a)}))`;case"contains":return`.has('${p}', containing(${u(a)}))`;case"doesnotcontain":return`.has('${p}', notContaining(${u(a)}))`;case"beginswith":return`.has('${p}', startingWith(${u(a)}))`;case"doesnotbeginwith":return`.has('${p}', notStartingWith(${u(a)}))`;case"endswith":return`.has('${p}', endingWith(${u(a)}))`;case"doesnotendwith":return`.has('${p}', notEndingWith(${u(a)}))`;case"null":return`.hasNot('${p}')`;case"notnull":return`.has('${p}')`;case"in":{const f=me(a).map(u);return f.length?`.has('${p}', within(${f.join(", ")}))`:""}case"notin":{const f=me(a).map(u);return f.length?`.has('${p}', without(${f.join(", ")}))`:""}case"between":{const f=me(a);return f.length<2?"":`.has('${p}', between(${u(f[0])}, ${u(f[1])}))`}case"notbetween":{const f=me(a);return f.length<2?"":`.has('${p}', outside(${u(f[0])}, ${u(f[1])}))`}default:return`.has('${p}', ${u(a)})`}},pl=e=>e.startsWith("not")||e.startsWith("doesnot"),hl=(e,t)=>`"${typeof e!="string"||!t?`${e}`:e.replaceAll('"','\\"')}"`,ds=(e,t)=>t?`$not(${e})`:e,gg=e=>`${e}`.replaceAll(/[/$()*+.?[\\\]^{|}]/g,String.raw`\$&`).replaceAll("-",String.raw`\x2d`),Hk=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:s}=e,{escapeQuotes:a,parseNumbers:i,preserveValueOrder:c,quoteFieldNamesWith:d=["",""],fieldIdentifierSeparator:p=""}=t,u=s==="field",f=typeof n=="number"||typeof n=="boolean"||typeof n=="bigint"||be(n,i),h=b=>wn(b,{quoteFieldNamesWith:d,fieldIdentifierSeparator:p}),g=qt(e);if(g===!1)return;if(g){const{mode:b,threshold:v}=g,N=`$count(${h(r)})`,x=`$count($filter(${h(r)}, function($v) {${ag(oo(n,{ruleProcessor:w=>({...w,field:w.field?`$v.${w.field}`:"$v"})}),t)}}))`;switch(b){case"all":return`${x} = ${N}`;case"none":return`${x} = 0`;case"some":return`${x} > 0`;case"atleast":case"atmost":case"exactly":{const w=b==="atleast"?">=":b==="atmost"?"<=":"=";return v>0&&v<1?`${x} ${w} (${N} * ${v})`:`${x} ${w} ${v}`}}}const y=$e(o);switch(y){case"<":case"<=":case"=":case"!=":case">":case">=":return`${h(r)} ${y} ${u?h(Be(n)):f?Be(n):hl(n,a)}`;case"contains":case"doesnotcontain":return ds(`$contains(${h(r)}, ${u?h(Be(n)):hl(n,a)})`,pl(y));case"beginswith":case"doesnotbeginwith":return ds(u?`$substring(${h(r)}, 0, $length(${h(Be(n))})) = ${h(Be(n))}`:`$contains(${h(r)}, /^${gg(n)}/)`,pl(y));case"endswith":case"doesnotendwith":return ds(u?`$substring(${h(r)}, $length(${h(r)}) - $length(${h(Be(n))})) = ${h(Be(n))}`:`$contains(${h(r)}, /${gg(n)}$/)`,pl(y));case"null":return`${h(r)} = null`;case"notnull":return`${h(r)} != null`;case"in":case"notin":{const b=me(n);return ds(`${h(r)} in [${b.map(v=>u?`${h(Be(v))}`:be(v,i)?`${Be(v)}`:hl(v,a)).join(", ")}]`,pl(y))}case"between":case"notbetween":{const b=me(n);if(b.length<2||ro(b[0])||ro(b[1]))return"";const[v,N]=b,x=i!==!1,w=be(v,x)?_e(v,{parseNumbers:x}):NaN,C=be(N,x)?_e(N,{parseNumbers:x}):NaN;let E=Number.isNaN(w)?u?`${v}`:v:w,k=Number.isNaN(C)?u?`${N}`:N:C;if(!c&&E===w&&k===C&&C<w){const I=C;k=w,E=I}const _=be(v,i)&&be(N,i),D=(I,T)=>u?h(I):_?T:hl(T,a),A=`${h(r)} >= ${D(v,E)} and ${h(r)} <= ${D(N,k)}`;return y==="between"?`(${A})`:ds(A,!0)}}return""},jk=e=>e.replace(/^(=)$/,"$1=").replace(/^notnull$/i,"!=").replace(/^null$/i,"=="),us=(e,t)=>e.startsWith("not")||e.startsWith("doesnot")?{"!":t}:t,md=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:s}=e,{parseNumbers:a,preserveValueOrder:i}=t,c=s==="field",d={var:r},p=h=>c?{var:`${h}`}:be(h,a)?_e(h,{parseNumbers:a}):h,u=qt(e);if(u===!1)return!1;if(u){const{mode:h,threshold:g}=u;switch(h){case"all":case"none":case"some":return{[h]:[{var:r},n.rules.length===1&&!ge(n.rules[0])?md(n.rules[0],t):ud(n,t)]};case"atleast":case"atmost":case"exactly":{const y=h==="atleast"?">=":h==="atmost"?"<=":"==",b={reduce:[{filter:[{var:r},n.rules.length===1&&!ge(n.rules[0])?md(n.rules[0],t):ud(n,t)]},{"+":[1,{var:"accumulator"}]},0]};if(g>0&&g<1){const v={reduce:[{var:r},{"+":[1,{var:"accumulator"}]},0]};return{[y]:[b,{"*":[v,g]}]}}return{[y]:[b,g]}}}}const f=$e(o);switch(f){case"<":case"<=":case"=":case"!=":case">":case">=":return{[jk(f)]:[d,p(n)]};case"null":case"notnull":return{[`${f==="notnull"?"!":"="}=`]:[d,null]};case"in":case"notin":{const h=me(n).map(g=>p(g));return us(f,{in:[d,h]})}case"between":case"notbetween":{const h=me(n);if(h.length>=2&&ft(h[0])&&ft(h[1])){let[g,y]=h;const b=a!==!1;if(!c&&be(g,b)&&be(y,b)){const v=_e(g,{parseNumbers:b}),N=_e(y,{parseNumbers:b});if(!i&&N<v){const x=N;y=v,g=x}else g=v,y=N}else c&&(g={var:g},y={var:y});return us(f,{"<=":[g,d,y]})}return!1}case"contains":case"doesnotcontain":{const h={in:[p(n),d]};return us(f,h)}case"beginswith":case"doesnotbeginwith":{const h={startsWith:[d,p(n)]};return us(f,h)}case"endswith":case"doesnotendwith":{const h={endsWith:[d,p(n)]};return us(f,h)}}return!1},Yo=(e,t)=>t?`(!${e})`:`${e}`,so=e=>`${Be(e)}`.replaceAll(/[()&|=<>~*\\/]/g,t=>`\\${t.codePointAt(0).toString(16)}`),qk=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:s}=e,{preserveValueOrder:a}=t,i=$e(o);if(s==="field"||ro(n)&&i!=="null"&&i!=="notnull"||qt(e))return"";switch(i){case"=":case"!=":return Yo(`(${r}=${so(n)})`,i==="!=");case">":case">=":return`(${r}>=${so(n)})`;case"<":case"<=":return`(${r}<=${so(n)})`;case"contains":case"doesnotcontain":return Yo(`(${r}=*${so(n)}*)`,i==="doesnotcontain");case"beginswith":case"doesnotbeginwith":return Yo(`(${r}=${so(n)}*)`,i==="doesnotbeginwith");case"endswith":case"doesnotendwith":return Yo(`(${r}=*${so(n)})`,i==="doesnotendwith");case"null":case"notnull":return Yo(`(${r}=*)`,i==="notnull");case"in":case"notin":{const c=me(n);return Yo(`(|${c.map(d=>`(${r}=${so(d)})`).join("")})`,i==="notin")}case"between":case"notbetween":{const c=me(n);if(c.length<2||ro(c[0])||ro(c[1]))return"";const[d,p]=c,u=be(d,!0)?_e(d,{parseNumbers:!0}):NaN,f=be(p,!0)?_e(p,{parseNumbers:!0}):NaN;let h=Number.isNaN(u)?d:u,g=Number.isNaN(f)?p:f;if(!a&&h===u&&g===f&&f<u){const y=f;g=u,h=y}return Yo(`(&(${r}>=${so(h)})(${r}<=${so(g)}))`,i==="notbetween")}}return""},Yk=(e,t,r)=>r&&typeof e=="string"?e.replaceAll(`${t}`,`${t}${t}`):e,bg=(e,t={})=>{var E;const{escapeQuotes:r,fields:o,parseNumbers:n,quoteFieldNamesWith:s,quoteValuesWith:a,fieldIdentifierSeparator:i,translations:c}=t,d=e.valueSource==="field",p=$e(e.operator),u=a||"'",f=k=>`${u}${k}${u}`,h=k=>Yk(k,u,r),g=k=>f(h(k)),y=k=>wn(k,{quoteFieldNamesWith:s,fieldIdentifierSeparator:i}),b=c??{},v=b.or??"or",N=b.true??"true",x=b.false??"false",w=b.listSeparator??", ",C=!b.listSeparator;switch(p){case"null":case"notnull":return"";case"between":case"notbetween":{if(!d)return is(e,t);const k=me(e.value,{retainEmptyStrings:!0}).slice(0,2).map(_=>{var D;return y(((D=We(o??[],_))==null?void 0:D.label)??_)});return k.length<2||!ft(k[0])||!ft(k[1])?"":is({...e,value:k},t)}case"in":case"notin":{const k=me(e.value);if(k.length===0)return"";const _=k.map(A=>{var I;return d?y(((I=We(o??[],A))==null?void 0:I.label)??A):be(A,n)?`${Be(A)}`:`${g(A)}`});if(_.length===1)return _[0];const D=C&&_.length>2?",":"";return`(${`${_.slice(0,-1).join(w)}${D} ${v} ${_.at(-1)}`})`}}return typeof e.value=="boolean"?e.value?N:x:d?y(((E=We(o??[],e.value))==null?void 0:E.label)??e.value):be(e.value,n)?`${Be(e.value)}`:`${g(e.value)}`},yg={"=":["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"]};/* v8 ignore next -- @preserve */const Qk=()=>[],vg=(e,t={})=>{const{field:r,operator:o,valueSource:n="value"}=e,{getOperators:s=Qk,operatorMap:a=yg}=t,i=new Map(Object.entries(yg));for(const[y,b]of Object.entries(a))i.set($e(y),b);const c=Object.fromEntries(i),d=$e(o);var p=o;const u=me(e.value).length===1;d==="in"&&u?p="=":d==="notin"&&u&&(p="!=");const{value:f,label:h}=We(Gr(s(r,{fieldData:t.fieldData??{name:r,value:r,label:r}})??[]),p)??{value:p,label:p},g=c[f]??c[$e(f)]??[h,h];return typeof g=="string"?g:g[n==="field"?1:0]},Kk=(e,t)=>{var w;const{field:r,operator:o}=e,{fieldData:n,quoteFieldNamesWith:s=["",""],fieldIdentifierSeparator:a="",quoteValuesWith:i="'",operatorProcessor:c=vg,valueProcessor:d=bg,concatOperator:p="||",wordOrder:u="SVO"}=t??{},f=wn((n==null?void 0:n.label)??r,{quoteFieldNamesWith:s,fieldIdentifierSeparator:a}),h=qt(e);if(h===!1)return"";if(h){const{mode:C,threshold:E}=h,k=lg(e.value,{...t,fields:Gr((n==null?void 0:n.subproperties)??[])}),_=(((w=n==null?void 0:n.subproperties)==null?void 0:w.length)??0)>0;switch(C){case"all":return`(${_?"for ":""}every item in ${f}${_?",":""} ${k})`;case"none":return`(${_?"for ":""}no item in ${f}${_?",":""} ${k})`;case"some":return`(${_?"for ":""}at least one item in ${f}${_?",":""} ${k})`;case"atleast":case"atmost":case"exactly":{const D=C.replace("at","at ");return E>0&&E<1?`(${_?"for ":""}${D} ${E*100}% of the items in ${f}${_?",":""} ${k})`:`(${_?"for ":""}${D} ${E} of the items in ${f}${_?",":""} ${k})`}}}const g=d(e,{...t,quoteFieldNamesWith:s,fieldIdentifierSeparator:a,quoteValuesWith:i,concatOperator:p}),y=$e(o);if((y==="in"||y==="notin"||y==="between"||y==="notbetween")&&!g)return"";const b={S:f,V:c(e,t),O:g},v=(t==null?void 0:t.translations)??{},N={S:v.afterSubject??" ",V:v.afterVerb??" ",O:v.afterObject??" "},x=hk(u).filter(C=>b[C]!=="");return x.map((C,E)=>`${b[C]}${E<x.length-1?N[C]:""}`).join("").trim()},fs=e=>$e(dk(e.operator)),ps=(e,t={})=>{const{quoteFieldNamesWith:r=["",""],fieldIdentifierSeparator:o="",quoteValuesWith:n="'",operatorProcessor:s=fs,valueProcessor:a=is,concatOperator:i="||"}=t,c=g=>wn(g,{quoteFieldNamesWith:r,fieldIdentifierSeparator:o}),d=c(e.field),p=qt(e);if(p===!1)return;if(p){if((t==null?void 0:t.preset)!=="postgresql")return"";const{mode:g,threshold:y}=p,b=t.subqueryDepth??0,v=il(b),N=cg(oo(e.value,{ruleProcessor:x=>({...x,field:v})}),{...t,subqueryDepth:b+1});switch(g){case"all":return`(select count(*) from unnest(${d}) as ${c(v)} where ${N}) = array_length(${d}, 1)`;case"none":return`not exists (select 1 from unnest(${d}) as ${c(v)} where ${N})`;case"some":return`exists (select 1 from unnest(${d}) as ${c(v)} where ${N})`;case"atleast":case"atmost":case"exactly":{const x=g==="atleast"?">=":g==="atmost"?"<=":"=";return`(select count(*)${y>0&&y<1?`::float / array_length(${d}, 1)`:""} from unnest(${d}) as ${c(v)} where ${N}) ${x} ${y}`}}}const u=a(e,{...t,quoteFieldNamesWith:r,fieldIdentifierSeparator:o,quoteValuesWith:n,concatOperator:i}),f=s(e,t),h=$e(f);return(h==="in"||h==="not in"||h==="between"||h==="not between")&&!u?"":`${d} ${f} ${u}`.trim()},xg=(e,t,r)=>{const{fieldData:o,format:n,getNextNamedParam:s,parseNumbers:a,paramPrefix:i,paramsKeepPrefix:c,numberedParams:d,quoteFieldNamesWith:p=["",""],fieldIdentifierSeparator:u,concatOperator:f,operatorProcessor:h=fs,valueProcessor:g=is}=t??{},{processedParams:y=[]}=r??{},b=n==="parameterized",v=[],N={},x=F=>b?{sql:F,params:v}:{sql:F,params:N},w=F=>wn(F,{quoteFieldNamesWith:p,fieldIdentifierSeparator:u}),C=w(e.field),E=qt(e);/* v8 ignore start -- @preserve */if(E===!1)return;if(E){if((t==null?void 0:t.preset)!=="postgresql")return x("");const{mode:F,threshold:B}=E,G=t.subqueryDepth??0,z=il(G),{sql:H,params:V}=ig(oo(e.value,{ruleProcessor:W=>({...W,field:z})}),{...t,fields:[],subqueryDepth:G+1});switch(Array.isArray(V)?v.push(...V):Object.assign(N,V),F){case"all":return x(`(select count(*) from unnest(${C}) as ${w(z)} where ${H}) = array_length(${C}, 1)`);case"none":return x(`not exists (select 1 from unnest(${C}) as ${w(z)} where ${H})`);case"some":return x(`exists (select 1 from unnest(${C}) as ${w(z)} where ${H})`);case"atleast":case"atmost":case"exactly":{const W=F==="atleast"?">=":F==="atmost"?"<=":"=";return x(`(select count(*)${B>0&&B<1?`::float / array_length(${C}, 1)`:""} from unnest(${C}) as ${w(z)} where ${H}) ${W} ${B}`)}}}/* v8 ignore stop -- @preserve */const k=g(e,{parseNumbers:a,quoteFieldNamesWith:p,concatOperator:f,fieldData:o,format:n}),_=h(e,t),D=$e(_),[A,I]=p;if((D==="in"||D==="not in"||D==="between"||D==="not between")&&!k)return x("");if(D==="is null"||D==="is not null")return x(`${A}${e.field}${I} ${_}`);if(e.valueSource==="parameter"){const F=B=>{const G=ls(B,i);return b||(N[c?G:ad(B,i)]=null),G};if(D==="between"||D==="not between"){const[B,G]=me(e.value,{retainEmptyStrings:!0}).slice(0,2);return x(`${A}${e.field}${I} ${_} ${F(B)} and ${F(G)}`.trim())}if(D==="in"||D==="not in"){const B=me(e.value);return x(`${A}${e.field}${I} ${_} (${B.map(G=>F(G)).join(", ")})`)}return x(`${A}${e.field}${I} ${_} ${as(F(e.value),$e(e.operator),{concatOperator:f})}`.trim())}else{if(e.valueSource==="field")return x(`${A}${e.field}${I} ${_} ${k}`.trim());if(D==="in"||D==="not in"){const F=me(e.value);if(b){for(const G of F)v.push(be(G,a)?_e(G,{parseNumbers:a}):G);return x(`${A}${e.field}${I} ${_} (${F.map((G,z)=>d?`${i}${y.length+1+F.length-(F.length-z)}`:"?").join(", ")})`)}const B=[];for(const G of F){const z=s(e.field);B.push(`${i}${z}`),N[`${c?i:""}${z}`]=be(G,a)?_e(G,{parseNumbers:a}):G}return x(`${A}${e.field}${I} ${_} (${B.join(", ")})`)}else if(D==="between"||D==="not between"){const[F,B]=me(e.value,{retainEmptyStrings:!0}).slice(0,2).map(H=>be(H,a)?_e(H,{parseNumbers:a}):H);if(b)return v.push(F,B),x(`${A}${e.field}${I} ${_} ${d?`${i}${y.length+1}`:"?"} and ${d?`${i}${y.length+2}`:"?"}`);const G=s(e.field),z=s(e.field);return N[`${c?i:""}${G}`]=F,N[`${c?i:""}${z}`]=B,x(`${A}${e.field}${I} ${_} ${i}${G} and ${i}${z}`)}}let T=e.value;typeof e.value=="string"&&(be(e.value,a)?T=_e(e.value,{parseNumbers:a}):T=/^'.*'$/g.test(k)?k.replaceAll(/(^'|'$)/g,""):k);let L="";return b?v.push(T):(L=s(e.field),N[`${c?i:""}${L}`]=T),x(`${A}${e.field}${I} ${_} ${b?d?`${i}${y.length+1}`:"?":`${i}${L}`}`.trim())},gd=(e,t,r)=>be(e,!!r||typeof e=="bigint")?Number(_e(e,{parseNumbers:!!r})):t,Rk=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:s}=e,{parseNumbers:a,preserveValueOrder:i}=t;if(s==="field"||qt(e))return;const c=$e(o);switch(c){case"=":return{[r]:gd(n,n,a)};case"!=":case"<":case"<=":case">":case">=":{const d=Qm[c];return{[r]:{[d]:gd(n,n,a)}}}case"contains":return{[r]:{contains:n}};case"beginswith":return{[r]:{startsWith:n}};case"endswith":return{[r]:{endsWith:n}};case"doesnotcontain":return{NOT:{[r]:{contains:n}}};case"doesnotbeginwith":return{NOT:{[r]:{startsWith:n}}};case"doesnotendwith":return{NOT:{[r]:{endsWith:n}}};case"null":return{[r]:null};case"notnull":return{[r]:{not:null}};case"in":case"notin":{const d=me(n);return{[r]:{[Qm[c]]:d.map(p=>gd(p,p,a))}}}case"between":case"notbetween":{const d=me(n);if(d.length>=2&&ft(d[0])&&ft(d[1])){const[p,u]=d,f=a!==!1,h=be(p,f)?_e(p,{parseNumbers:a}):NaN,g=be(u,f)?_e(u,{parseNumbers:a}):NaN;let y=Number.isNaN(h)?p:h,b=Number.isNaN(g)?u:g;if(!i&&y===h&&b===g&&g<h){const v=g;b=h,y=v}return c==="between"?{[r]:{gte:y,lte:b}}:{OR:[{[r]:{lt:y}},{[r]:{gt:b}}]}}else return""}}return""},Xk=(e,{parseNumbers:t,preserveValueOrder:r,context:o={}}={})=>{const{sequelizeOperators:n,sequelizeCol:s,sequelizeFn:a}=o;if(qt(e))return;const{field:i,operator:c,value:d,valueSource:p}=e,u=p==="field",f=$e(c);if(!(!n||u&&(!s||!a&&["contains","doesnotcontain","beginswith","doesnotbeginwith","endswith","doesnotendwith"].includes(f))))switch(f){case"=":case"!=":case"<":case"<=":case">":case">=":{const h={"=":n.eq,"!=":n.ne,"<":n.lt,"<=":n.lte,">":n.gt,">=":n.gte}[f];return{[i]:u&&f==="="?{[n.col]:d}:{[h]:u?s(d):be(d,t)?_e(d,{parseNumbers:"strict"}):d}}}case"contains":return{[i]:{[u?n.like:n.substring]:u?a("CONCAT","%",s(d),"%"):`${d}`}};case"beginswith":return{[i]:{[u?n.like:n.startsWith]:u?a("CONCAT",s(d),"%"):`${d}`}};case"endswith":return{[i]:{[u?n.like:n.endsWith]:u?a("CONCAT","%",s(d)):`${d}`}};case"doesnotcontain":return{[i]:{[n.notLike]:u?a("CONCAT","%",s(d),"%"):`%${d}%`}};case"doesnotbeginwith":return{[i]:{[n.notLike]:u?a("CONCAT",s(d),"%"):`${d}%`}};case"doesnotendwith":return{[i]:{[n.notLike]:u?a("CONCAT","%",s(d)):`%${d}`}};case"null":return{[i]:{[n.is]:null}};case"notnull":return{[i]:{[n.not]:null}};case"in":case"notin":{const h=me(d);return{[i]:{[f==="in"?n.in:n.notIn]:h.map(g=>u?s(g):be(g,t)?_e(g,{parseNumbers:"strict"}):g)}}}case"between":case"notbetween":{const h=me(d,{retainEmptyStrings:!0});if(h.length<2||!ft(h[0])||!ft(h[1]))return;const[g,y]=h,b=be(g,t)?_e(g,{parseNumbers:"strict"}):NaN,v=be(y,t)?_e(y,{parseNumbers:"strict"}):NaN,N=Number.isNaN(b)?g:b,x=Number.isNaN(v)?y:v,w=[N,x];return!r&&N===b&&x===v&&v<b&&(w[0]=v,w[1]=b),{[i]:{[f==="between"?n.between:n.notBetween]:u?w.map(C=>s(C)):w.every(C=>be(C,t))?w.map(C=>_e(C,{parseNumbers:"strict"})):w}}}}},Jk=(e,t)=>typeof e!="string"||!t?`${e}`:e.replaceAll('"','\\"'),wg=e=>/^[?<]/.test(e)||e.includes(":")?e:`?${e}`,Zk=(e,t={})=>{const{escapeQuotes:r,parseNumbers:o}=t,{field:n,operator:s,value:a,valueSource:i}=e,c=i==="field",d=s.toLowerCase(),p=wg(n),u=f=>{if(f==null)return'""';if(typeof f=="boolean")return`"${f}"^^xsd:boolean`;if(typeof f=="bigint")return String(f);if(c)return wg(Be(f));if(typeof f=="number"||be(f,o))return Be(f);/* v8 ignore start -- @preserve */const h=typeof f=="string"?f:JSON.stringify(f)??"";/* v8 ignore stop -- @preserve */return h.startsWith("?")||h.startsWith("<")||h.includes(":")?h:`"${Jk(h,r)}"`};switch(d){case"=":case"!=":case"<":case">":case"<=":case">=":return`${p} ${d} ${u(a)}`;case"<>":return`${p} != ${u(a)}`;case"contains":return`CONTAINS(${p}, ${u(a)})`;case"doesnotcontain":return`!CONTAINS(${p}, ${u(a)})`;case"beginswith":return`STRSTARTS(${p}, ${u(a)})`;case"doesnotbeginwith":return`!STRSTARTS(${p}, ${u(a)})`;case"endswith":return`STRENDS(${p}, ${u(a)})`;case"doesnotendwith":return`!STRENDS(${p}, ${u(a)})`;case"null":return`!BOUND(${p})`;case"notnull":return`BOUND(${p})`;case"in":{const f=me(a).map(u);return f.length?`${p} IN (${f.join(", ")})`:""}case"notin":{const f=me(a).map(u);return f.length?`${p} NOT IN (${f.join(", ")})`:""}case"between":{const f=me(a);return f.length<2?"":`${p} >= ${u(f[0])} && ${p} <= ${u(f[1])}`}case"notbetween":{const f=me(a);return f.length<2?"":`(${p} < ${u(f[0])} || ${p} > ${u(f[1])})`}default:return`${p} ${s} ${u(a)}`}},eA=(e,t)=>{const{parseNumbers:r,preserveValueOrder:o,context:n={}}=t??{},s=n.tanStackDbOperators,a=n._tanstackDbRefs,i=n._tanstackDbPrimaryRef;if(!s||!a||!i)return;const{and:c,eq:d,gt:p,gte:u,inArray:f,isNull:h,like:g,lt:y,lte:b,not:v}=s,N=T=>{const L=T.indexOf(".");if(L>0){const F=T.slice(0,L),B=T.slice(L+1);if(a[F])return a[F][B]}return a[i][T]},{field:x,operator:w,value:C,valueSource:E}=e,k=N(x),_=$e(w),D=E==="field",A=T=>D?N(T):T,I=T=>D||!r?A(T):be(T,!0)?_e(T,{parseNumbers:!0}):T;switch(_){case"=":return d(k,I(C));case"!=":return v(d(k,I(C)));case">":return p(k,I(C));case"<":return y(k,I(C));case">=":return u(k,I(C));case"<=":return b(k,I(C));case"beginswith":case"doesnotbeginwith":{const T=g(k,D?void 0:`${C}%`);return _==="doesnotbeginwith"?v(T):T}case"contains":case"doesnotcontain":{const T=g(k,D?void 0:`%${C}%`);return _==="doesnotcontain"?v(T):T}case"endswith":case"doesnotendwith":{const T=g(k,D?void 0:`%${C}`);return _==="doesnotendwith"?v(T):T}case"null":return h(k);case"notnull":return v(h(k));case"in":case"notin":{const T=f(k,me(C).map(L=>I(L)));return _==="notin"?v(T):T}case"between":case"notbetween":{const T=me(C);if(T.length>=2&&ft(T[0])&&ft(T[1])){let[L,F]=T;const B=r!==!1;if(!D&&be(L,B)&&be(F,B)){const z=_e(L,{parseNumbers:B}),H=_e(F,{parseNumbers:B});if(!o&&H<z){const V=H;F=z,L=V}else L=z,F=H}else D&&(L=A(L),F=A(F));const G=c(u(k,L),b(k,F));return _==="notbetween"?v(G):G}return}default:return}},Sg={ansi:{},sqlite:{paramsKeepPrefix:!0},oracle:{},mssql:{concatOperator:"+",quoteFieldNamesWith:["[","]"],fieldIdentifierSeparator:".",paramPrefix:"@"},mysql:{concatOperator:"CONCAT"},postgresql:{quoteFieldNamesWith:'"',numberedParams:!0,paramPrefix:"$"}},Ng={cel:mk,drizzle:Fk,elasticsearch:Bk,json_without_ids:ps,json:ps,jsonata:Hk,jsonlogic:md,ldap:qk,mongodb_query:dl,mongodb:gk,natural_language:Kk,parameterized_named:xg,parameterized:xg,prisma:Rk,sequelize:Xk,spel:bk,sql:ps,tanstack_db:eA,cypher:mg,gql:mg,sparql:Zk,gremlin:Wk,diagnostics:ps};/* v8 ignore next -- @preserve */const pt=e=>e.operator,tA={cel:pt,drizzle:pt,elasticsearch:pt,json_without_ids:pt,json:pt,jsonata:pt,jsonlogic:pt,ldap:pt,mongodb_query:pt,mongodb:pt,natural_language:vg,parameterized_named:fs,parameterized:fs,prisma:pt,sequelize:pt,spel:pt,sql:fs,tanstack_db:pt,cypher:pt,gql:pt,sparql:pt,gremlin:pt,diagnostics:pt},Cg={cel:"1 == 1",ldap:"",mongodb:'"$and":[{"$expr":true}]',natural_language:"1 is 1",sparql:"1 = 1",gremlin:"",spel:"1 == 1",sql:"(1 = 1)"},rA={format:"json",fields:[],quoteFieldNamesWith:["",""],fieldIdentifierSeparator:"",getOperators:()=>[],paramPrefix:":",paramsKeepPrefix:!1,numberedParams:!1,preserveValueOrder:!1,placeholderFieldName:"~",placeholderOperatorName:"~",quoteValuesWith:"'",concatOperator:"||",preset:"ansi",wordOrder:"SVO",translations:{},operatorMap:{}},Eg=new Set(["cel","drizzle","elasticsearch","jsonata","jsonlogic","ldap","mongodb_query","mongodb","prisma","sequelize","spel","tanstack_db"]),oA=new Set(["sql","parameterized","parameterized_named","drizzle","prisma","sequelize"]);function nA(e,t={}){const r=typeof t=="string"?{format:$e(t)}:t,o={...rA,...!r.format||oA.has(r.format)?Sg[r.preset??"ansi"]??null:null,...r,...!r.format&&(Object.keys(Sg).includes(r.preset??"")?{format:"sql"}:null)},n=$e(o.format),{fallbackExpression:s,getOperators:a,operatorProcessor:i,parseNumbers:c,quoteFieldNamesWith:d,ruleGroupProcessor:p,ruleProcessor:u,validator:f,valueProcessor:h,context:g}=o,y=T=>typeof sd({parseNumbers:c,inputType:T})=="string"?!0:typeof c=="boolean"?c:void 0,b=typeof i=="function"?i:tA[n]??pt,v=typeof h=="function"?pk(h)?T=>h(T.field,T.operator,T.value,T.valueSource):h:n==="natural_language"?bg:Eg.has(n)?u??Ng[n]:is,N=(typeof u=="function"?u:null)??(Eg.has(n)&&typeof u!="function"&&h?v:null)??Ng[n]??ps,x=Rm(d),w=Gr(o.fields),C=(T,L)=>Gr(a(T,L)??[]),E=s??Cg[n]??Cg.sql;let k={};if(typeof f=="function"){const T=f(e);if(typeof T=="boolean"){if(!T&&n!=="diagnostics")return n==="parameterized"?{sql:E,params:[]}:n==="parameterized_named"?{sql:E,params:{}}:n==="mongodb"?`{${E}}`:n==="mongodb_query"?id:n==="prisma"?pd:n==="jsonlogic"?!1:n==="elasticsearch"?{}:n==="drizzle"||n==="sequelize"||n==="tanstack_db"?void 0:E}else k=T}const _={},D=nd(w);for(const T of D)typeof T.validator=="function"&&(_[T.value??T.name]=T.validator);const I={...o,fallbackExpression:E,fields:w,format:n,getOperators:C,getParseNumberBoolean:y,quoteFieldNamesWith:x,operatorProcessor:b,ruleProcessor:N,valueProcessor:v,validateRule:T=>{let L,F;if(T.id&&(L=k[T.id]),D.length>0){const B=D.filter(G=>G.name===T.field);if(B.length>0){const G=B[0];typeof G.validator=="function"&&(F=G.validator)}}if(T.valueSource==="parameter"&&typeof o.getParameters=="function"){const B=We(w,T.field);new Set(nd(Gr(o.getParameters(T.field,T.operator,{fieldData:B}))).map(G=>ad(G.value,o.paramPrefix))).has(ad(T.value,o.paramPrefix))||(L=!1)}return[L,F]},validationMap:k,context:g};if(typeof p=="function")return p(e,I);switch(n){case"json":case"json_without_ids":{const T=c?Km(e,I):e;return n==="json_without_ids"?JSON.stringify(T,(L,F)=>L==="id"||L==="path"?void 0:eg(L,F)):JSON.stringify(T,eg,2)}case"sql":return cg(e,I);case"parameterized":case"parameterized_named":return ig(e,I);case"mongodb":return Sk(e,I);case"mongodb_query":return cd(e,I);case"cel":return tg(e,I);case"spel":return rg(e,I);case"jsonata":return ag(e,I);case"jsonlogic":return ud(e,I);case"elasticsearch":return sg(e,I);case"natural_language":return lg(e,I);case"ldap":return wk(e,I);case"prisma":return Nk(e,I);case"drizzle":return ng(e,I);case"tanstack_db":return _k(e,I);case"sequelize":return Ck(e,I);case"cypher":case"gql":return vk(e,I);case"sparql":return Ek(e,I);case"gremlin":return xk(e,I);case"diagnostics":return Ik(e,I);default:return""}}const ht=(e,t)=>{let r=t,o=0;for(;o<e.length&&r&&ge(r);){const n=r.rules[e[o]];r=typeof n=="string"?null:n,o++}return o<e.length?null:r},_g=(e,t)=>{if(t.id===e)return t;for(const r of t.rules)if(typeof r!="string"){if(r.id===e)return r;if(ge(r)){const o=_g(e,r);if(o)return o}}return null},Sn=(e,t)=>{if(t.id===e)return[];const r=t.rules.findIndex(o=>typeof o!="string"&&o.id===e);if(r>=0)return[r];for(const[o,n]of Object.entries(t.rules))if(ge(n)){const s=Sn(e,n);if(Array.isArray(s))return[Number.parseInt(o),...s]}return null},it=e=>e.slice(0,-1),Qo=(e,t)=>e.length===t.length&&e.every((r,o)=>r===t[o]),kg=(e,t)=>{const r=[],o=it(e),n=it(t);let s=0;for(;s<o.length&&s<n.length&&o[s]===n[s];)r.push(n[s]),s++;return r},Nn=(e,t)=>{let r=!!t.disabled,o=t,n=0;for(;n<e.length&&!r&&ge(o);){const s=o.rules[e[n]];wr(s)&&(ge(s)||"field"in s&&s.field)&&(r=!!s.disabled,o=s),n++}return r},sA=e=>Qo([],e.path)?"Query builder":`Rule group at path ${e.path.join("-")}`,hs=globalThis.crypto;let lr=()=>"00-0-4-2-000".replaceAll(/[^-]/g,e=>((Math.random()+Math.trunc(e))*65536>>Number.parseInt(e)).toString(16).padStart(4,"0"));if(hs){if(typeof hs.randomUUID=="function")lr=()=>hs.randomUUID();else if(typeof hs.getRandomValues=="function"){const e="89ab",t=new Uint32Array(32);lr=()=>{hs.getRandomValues(t);let r=(t[0]%16).toString(16);for(let o=1;o<32;o++)o===12?r=`${r}4`:o===16?r=`${r}${e[t[17]%4]}`:r=`${r}${(t[o]%16).toString(16)}`,(o===7||o===11||o===15||o===19)&&(r=`${r}-`);return r}}}const aA={name:"name",value:"name",matchModes:null,label:"label"},lA=(e,t)=>{const r=e?Vr(e):aA;let o=r.matchModes??!1;return!o&&t&&(o=t(r.value,{fieldData:r})),o===!0?Mm:o===!1?[]:sl(o)?Gr(o):(o==null?void 0:o.map(n=>Mm.find(s=>s.value===$e(n))??{name:n,value:n,label:n}))??[]},Ag=(e,t,r)=>{const o=Ct(e);if(t.operator==="between"||t.operator==="notBetween"){const n=[o,o];return r?n:ss(n.map(s=>s??""),",")}return o},iA=(e,t)=>{const{fieldData:r,fields:o,getValueEditorType:n,getValues:s,getDefaultValue:a,getParameters:i,listsAsArrays:c}=t;if((r==null?void 0:r.defaultValue)!==void 0&&r.defaultValue!==null)return r.defaultValue;if(a)return a(e,{fieldData:r});let d="";const p=s(e.field,e.operator,{fieldData:r});if(e.valueSource==="field"){const u=qm(r,o,e.operator);d=u.length>0?Ag(u,e,c):""}else if(e.valueSource==="parameter"){const u=i?i(e.field,e.operator,{fieldData:r}):null;d=u&&u.length>0?Ct(u):""}else if(p.length>0){const u=n(e.field,e.operator,{fieldData:r});u==="multiselect"?d=c?[]:"":(u==="select"||u==="radio")&&(d=Ag(p,e,c))}else n(e.field,e.operator,{fieldData:r})==="checkbox"&&(d=!1);return d},Dg=e=>{const t=typeof e=="boolean"?e:typeof e=="object"&&e!==null?e.valid:null;return typeof t=="boolean"?t?ve.valid:ve.invalid:""},$g=[{name:"value",value:"value",label:"value"}],cA={name:"name",value:"name",valueSources:null,label:"label"},Tg=(e,t,r)=>{const o=e?Vr(e):cA;let n=o.valueSources??!1;return typeof n=="function"&&(n=n(t)),!n&&r&&(n=r(o.value,t,{fieldData:o})),n?sl(n)?Gr(n):n.map(s=>$g.find(a=>a.value===$e(s))??{name:s,value:s,label:s}):$g},Ke=(e,t,r)=>{if(nl(e))return;const o=Bm(t).map(([n,[s,a]])=>{var i;return[n,s??a??((i=r==null?void 0:r[e])==null?void 0:i[n])]}).filter(n=>!nl(n[0])&&!!n[1]);if(o.length>0||r){const n=(r==null?void 0:r[e])??{},s=Object.assign({},n,Object.fromEntries(o));return{[e]:s}}},Ne=(e,t)=>{var o;let r="";for(let n=0;n<t.length;n++){const s=(o=t[n])==null?void 0:o[e];if(!s)continue;const a=typeof s=="string"?s:ze(s);a&&(r=r?`${r} ${a}`:a)}return r},dA=(...e)=>({queryBuilder:Ne("queryBuilder",e),ruleGroup:Ne("ruleGroup",e),header:Ne("header",e),body:Ne("body",e),combinators:Ne("combinators",e),addRule:Ne("addRule",e),addGroup:Ne("addGroup",e),cloneRule:Ne("cloneRule",e),cloneGroup:Ne("cloneGroup",e),removeGroup:Ne("removeGroup",e),rule:Ne("rule",e),fields:Ne("fields",e),operators:Ne("operators",e),value:Ne("value",e),removeRule:Ne("removeRule",e),notToggle:Ne("notToggle",e),shiftActions:Ne("shiftActions",e),dragHandle:Ne("dragHandle",e),lockRule:Ne("lockRule",e),lockGroup:Ne("lockGroup",e),muteRule:Ne("muteRule",e),muteGroup:Ne("muteGroup",e),muted:Ne("muted",e),valueSource:Ne("valueSource",e),actionElement:Ne("actionElement",e),valueSelector:Ne("valueSelector",e),betweenRules:Ne("betweenRules",e),valid:Ne("valid",e),invalid:Ne("invalid",e),dndDragging:Ne("dndDragging",e),dndOver:Ne("dndOver",e),dndCopy:Ne("dndCopy",e),dndGroup:Ne("dndGroup",e),dndDropNotAllowed:Ne("dndDropNotAllowed",e),dndPreviewPosition:Ne("dndPreviewPosition",e),dndHidden:Ne("dndHidden",e),disabled:Ne("disabled",e),valueListItem:Ne("valueListItem",e),matchMode:Ne("matchMode",e),matchThreshold:Ne("matchThreshold",e),branches:Ne("branches",e),hasSubQuery:Ne("hasSubQuery",e),loading:Ne("loading",e),valueDateTimeRelative:Ne("valueDateTimeRelative",e)}),uA=(e,t)=>e===!1?!1:e?!0:t!==!1,fA=(e,t)=>e?!0:e===!1?!1:!!t,Pg=(e,t,r,o)=>o?t??r:e?uA(t,r):fA(t,r),pA=(e={},t={},r)=>Bm(lk).reduce((o,[n,s])=>(o[n]=Pg(s,e[n],t[n],!1),o),{}),Ig=(e,{idGenerator:t=lr}={})=>{const r=!e.id,o=qt(e);return!r&&!o?e:{...e,...r&&{id:t()},...o&&{value:ml(e.value,{idGenerator:t})}}},ml=(e,{idGenerator:t=lr}={})=>{const r=!e.id;let o=!1;const n=[];for(let s=0;s<e.rules.length;s++){const a=e.rules[s];if(typeof a=="string")n.push(a);else{const i=ge(a)?ml(a,{idGenerator:t}):Ig(a,{idGenerator:t});n.push(i),i!==a&&(o=!0)}}return!r&&!o?e:{...e,...r&&{id:t()},rules:n}},Og=(e,{idGenerator:t=lr}={})=>ge(e)?ml(e,{idGenerator:t}):Ig(e,{idGenerator:t}),hA=(e,{idGenerator:t=lr}={})=>structuredClone({...e,id:t()}),bd=(e,{idGenerator:t=lr}={})=>{if(!wr(e))return e;if(!ge(e))return structuredClone({...e,id:t()});const r={...e,id:t()};return Array.isArray(r.rules)&&(r.rules=e.rules.map(o=>typeof o=="string"?o:ge(o)?bd(o,{idGenerator:t}):hA(o,{idGenerator:t}))),r},Mg=(e,t,r,o={})=>os(e,n=>mA(n,t,r,o)),mA=(e,t,r,o={})=>{const{combinators:n=ns,combinatorPreceding:s,idGenerator:a=lr}=o,i=Array.isArray(r)?ht(r,e):_g(r,e);if(!i||!ge(i))return e;if(yn(i)&&i.rules.length>0){const c=i.rules.at(-2);i.rules.push(s??(typeof c=="string"?c:Ct(n)))}return i.rules.push(Og(t,{idGenerator:a})),e},Lg={field:0,operator:1,valueSource:2,value:4},Fg=e=>e.sort((t,r)=>(Lg[t[0]]??3)-(Lg[r[0]]??3)),gA=(e,t,r,o)=>{if(typeof e=="string")return{entries:[[e,t]],pathOrID:r,options:o??{}};if(Array.isArray(e)){const n=t;return{entries:Fg(e.map((s,a)=>[s,n[a]])),pathOrID:r,options:o??{}}}return{entries:Fg(Object.entries(e)),pathOrID:t,options:r??{}}},bA=(e,t,r,o,n)=>{const{entries:s,pathOrID:a,options:i}=gA(t,r,o,n);for(const[c,d]of s)vA(e,c,d,a,i);return e},yA=((e,t,r,o,n)=>os(e,s=>{bA(s,t,r,o,n)})),vA=(e,t,r,o,n={})=>{var N;const{resetOnFieldChange:s=!0,resetOnOperatorChange:a=!1,getRuleDefaultOperator:i=()=>"=",getValueSources:c=()=>["value"],getRuleDefaultValue:d=()=>"",getMatchModes:p=()=>[]}=n;let u=s;const f=Array.isArray(o)?o:Sn(o,e);if(!f)return e;if(t==="combinator"&&!Vt(e)){const x=ht(it(f),e).rules;return f.at(-1)%2===1&&(x[f.at(-1)]=r),e}const h=ht(f,e);if(!h)return e;const g=ge(h);if(h[t]===r||(t!=="valueSource"&&(h[t]=r),g))return e;let y=!1,b=!1;if(t==="field"){const x=p(h.field),w=p(r);if(w.length===0)delete h.match;else{const C=(N=h.match)!=null&&N.mode&&We(w,h.match.mode)?null:Ct(w);C&&(h.match={mode:C,threshold:1})}(x.length>0||w.length>0)&&(u=!0)}u&&t==="field"&&(h.operator=i(r),y=!0,b=!0),a&&t==="operator"&&(y=!0,b=!0);const v=Ct(Tg({name:h.field,value:h.field,label:""},h.operator,c));return(y&&h.valueSource&&v!==h.valueSource||t==="valueSource"&&r!==h.valueSource)&&(b=!!h.valueSource||!h.valueSource&&r!==v,h.valueSource=y?v:r),b&&(h.value=d(h)),e},xA=(e,t)=>os(e,r=>wA(r,t)),wA=(e,t)=>{const r=Array.isArray(t)?t:Sn(t,e);if(!r||r.length===0||!Vt(e)&&!ht(r,e))return e;const o=r.at(-1),n=ht(it(r),e);if(n&&ge(n))if(!Vt(n)&&n.rules.length>1){const s=o===0?0:o-1;n.rules.splice(s,2)}else n.rules.splice(o,1);return e},Vg=(e,t,r)=>{if(Array.isArray(r))return r;const o=yn(e);if(r==="up"){if(Qo(t,[0]))return t;if(t.at(-1)===0){const n=it(t);return[...it(n),Math.max(0,n.at(-1)-(o?1:0))]}else{const n=[...it(t),Math.max(0,t.at(-1)-(o?2:1))],s=ht(n,e);return ge(s)?[...n,s.rules.length]:[...it(t),Math.max(0,t.at(-1)-(o?3:1))]}}else if(r==="down"){if(Qo([e.rules.length-1],t))return t;if(t.at(-1)===ht(it(t),e).rules.length-1){const n=it(t);return[...it(n),n.at(-1)+1]}else{const n=[...it(t),t.at(-1)+(o?2:1)];return ge(ht(n,e))?[...n,0]:[...it(t),t.at(-1)+(o?3:2)]}}return t},SA=(e,t,r,o={})=>os(e,n=>NA(n,t,r,o)),NA=(e,t,r,o={})=>{const{clone:n=!1,combinators:s=ns,idGenerator:a=lr}=o,i=Array.isArray(t)?t:Sn(t,e);if(!i)return e;const c=Vg(e,i,r);if(i.length===0||Qo(i,c)||!ht(it(c),e))return e;const d=ht(i,e);if(!d)return e;const p=n?bd(Lr(d)?ed(d):d,{idGenerator:a}):d,u=yn(e),f=ht(it(i),e),h=i.at(-1),g=u&&h>0?f.rules[h-1]:null,y=u&&h<f.rules.length-1?f.rules[h+1]:null;if(!n){const C=u?Math.max(0,h-1):h,E=u?2:1;f.rules.splice(C,E)}const b=[...c],v=kg(i,c);!n&&i.length===v.length+1&&c[v.length]>i[v.length]&&(b[v.length]-=u?2:1);const N=ht(it(b),e),x=b.at(-1),w=(...C)=>N.rules.splice(x,0,...C);return N.rules.length===0||!u?w(p):x===0?h===0&&y?w(p,y):w(p,N.rules[1]??g??Ct(s)):w(g||(N.rules[x-2]??y??Ct(s)),p),e},CA=(e,t,r,o={})=>os(e,n=>EA(n,t,r,o)),EA=(e,t,r,o={})=>{const{clone:n=!1,combinators:s=ns,idGenerator:a=lr}=o,i=Array.isArray(t)?t:Sn(t,e),c=Array.isArray(r)?r:Sn(r,e);if(!i||!c)return e;const d=Vg(e,i,c);if(i.length===0||Qo(i,d)||!ht(it(d),e))return e;const p=ht(i,e),u=ht(c,e);if(!p||!u)return e;const f=n?bd(Lr(p)?ed(p):p,{idGenerator:a}):p,h=yn(e),g=ht(it(i),e),y=i.at(-1);if(!n){const w=h?Math.max(0,y-1):y,C=h?2:1;g.rules.splice(w,C)}const b=[...d],v=kg(i,d);!n&&i.length===v.length+1&&d[v.length]>i[v.length]&&(b[v.length]-=h?2:1);const N=ht(it(b),e),x=b.at(-1);return N.rules.splice(x,1,Og(h?{rules:[u,Ct(s),f]}:{combinator:Ct(s),rules:[u,f]},{idGenerator:a})),e};function At(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 _A=typeof Symbol=="function"&&Symbol.observable||"@@observable",Gg=_A,yd=()=>Math.random().toString(36).substring(7).split("").join("."),kA={INIT:`@@redux/INIT${yd()}`,REPLACE:`@@redux/REPLACE${yd()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${yd()}`},Ko=kA;function ms(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function AA(e){if(e===void 0)return"undefined";if(e===null)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(TA(e))return"date";if($A(e))return"error";const r=DA(e);switch(r){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return r}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function DA(e){return typeof e.constructor=="function"?e.constructor.name:null}function $A(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function TA(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function xo(e){let t=typeof e;return process.env.NODE_ENV!=="production"&&(t=AA(e)),t}function zg(e,t,r){if(typeof e!="function")throw new Error(process.env.NODE_ENV==="production"?At(2):`Expected the root reducer to be a function. Instead, received: '${xo(e)}'`);if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(process.env.NODE_ENV==="production"?At(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(process.env.NODE_ENV==="production"?At(1):`Expected the enhancer to be a function. Instead, received: '${xo(r)}'`);return r(zg)(e,t)}let o=e,n=t,s=new Map,a=s,i=0,c=!1;function d(){a===s&&(a=new Map,s.forEach((b,v)=>{a.set(v,b)}))}function p(){if(c)throw new Error(process.env.NODE_ENV==="production"?At(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return n}function u(b){if(typeof b!="function")throw new Error(process.env.NODE_ENV==="production"?At(4):`Expected the listener to be a function. Instead, received: '${xo(b)}'`);if(c)throw new Error(process.env.NODE_ENV==="production"?At(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let v=!0;d();const N=i++;return a.set(N,b),function(){if(v){if(c)throw new Error(process.env.NODE_ENV==="production"?At(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");v=!1,d(),a.delete(N),s=null}}}function f(b){if(!ms(b))throw new Error(process.env.NODE_ENV==="production"?At(7):`Actions must be plain objects. Instead, the actual type was: '${xo(b)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(typeof b.type>"u")throw new Error(process.env.NODE_ENV==="production"?At(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(typeof b.type!="string")throw new Error(process.env.NODE_ENV==="production"?At(17):`Action "type" property must be a string. Instead, the actual type was: '${xo(b.type)}'. Value was: '${b.type}' (stringified)`);if(c)throw new Error(process.env.NODE_ENV==="production"?At(9):"Reducers may not dispatch actions.");try{c=!0,n=o(n,b)}finally{c=!1}return(s=a).forEach(N=>{N()}),b}function h(b){if(typeof b!="function")throw new Error(process.env.NODE_ENV==="production"?At(10):`Expected the nextReducer to be a function. Instead, received: '${xo(b)}`);o=b,f({type:Ko.REPLACE})}function g(){const b=u;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(process.env.NODE_ENV==="production"?At(11):`Expected the observer to be an object. Instead, received: '${xo(v)}'`);function N(){const w=v;w.next&&w.next(p())}return N(),{unsubscribe:b(N)}},[Gg](){return this}}}return f({type:Ko.INIT}),{dispatch:f,subscribe:u,getState:p,replaceReducer:h,[Gg]:g}}function Bg(e){typeof console<"u"&&typeof console.error=="function"&&console.error(e);try{throw new Error(e)}catch{}}function PA(e,t,r,o){const n=Object.keys(t),s=r&&r.type===Ko.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(n.length===0)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!ms(e))return`The ${s} has unexpected type of "${xo(e)}". Expected argument to be an object with the following keys: "${n.join('", "')}"`;const a=Object.keys(e).filter(i=>!t.hasOwnProperty(i)&&!o[i]);if(a.forEach(i=>{o[i]=!0}),!(r&&r.type===Ko.REPLACE)&&a.length>0)return`Unexpected ${a.length>1?"keys":"key"} "${a.join('", "')}" found in ${s}. Expected to find one of the known reducer keys instead: "${n.join('", "')}". Unexpected keys will be ignored.`}function IA(e){Object.keys(e).forEach(t=>{const r=e[t];if(typeof r(void 0,{type:Ko.INIT})>"u")throw new Error(process.env.NODE_ENV==="production"?At(12):`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof r(void 0,{type:Ko.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(process.env.NODE_ENV==="production"?At(13):`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${Ko.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)})}function Ug(e){const t=Object.keys(e),r={};for(let a=0;a<t.length;a++){const i=t[a];process.env.NODE_ENV!=="production"&&typeof e[i]>"u"&&Bg(`No reducer provided for key "${i}"`),typeof e[i]=="function"&&(r[i]=e[i])}const o=Object.keys(r);let n;process.env.NODE_ENV!=="production"&&(n={});let s;try{IA(r)}catch(a){s=a}return function(i={},c){if(s)throw s;if(process.env.NODE_ENV!=="production"){const u=PA(i,r,c,n);u&&Bg(u)}let d=!1;const p={};for(let u=0;u<o.length;u++){const f=o[u],h=r[f],g=i[f],y=h(g,c);if(typeof y>"u"){const b=c&&c.type;throw new Error(process.env.NODE_ENV==="production"?At(14):`When called with an action of type ${b?`"${String(b)}"`:"(unknown type)"}, the slice reducer for key "${f}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}p[f]=y,d=d||y!==g}return d=d||o.length!==Object.keys(i).length,d?p:i}}function gl(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...o)=>t(r(...o)))}function OA(...e){return t=>(r,o)=>{const n=t(r,o);let s=()=>{throw new Error(process.env.NODE_ENV==="production"?At(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const a={getState:n.getState,dispatch:(c,...d)=>s(c,...d)},i=e.map(c=>c(a));return s=gl(...i)(n.dispatch),{...n,dispatch:s}}}function Wg(e){return ms(e)&&"type"in e&&typeof e.type=="string"}var Hg=Symbol.for("immer-nothing"),jg=Symbol.for("immer-draftable"),Gt=Symbol.for("immer-state"),MA=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Jt(e,...t){if(process.env.NODE_ENV!=="production"){const r=MA[e],o=Ro(r)?r.apply(null,t):r;throw new Error(`[Immer] ${o}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Zt=Object,Cn=Zt.getPrototypeOf,bl="constructor",yl="prototype",vd="configurable",vl="enumerable",xl="writable",gs="value",ao=e=>!!e&&!!e[Gt];function ir(e){var t;return e?Yg(e)||Nl(e)||!!e[jg]||!!((t=e[bl])!=null&&t[jg])||Cl(e)||El(e):!1}var LA=Zt[yl][bl].toString(),qg=new WeakMap;function Yg(e){if(!e||!Sd(e))return!1;const t=Cn(e);if(t===null||t===Zt[yl])return!0;const r=Zt.hasOwnProperty.call(t,bl)&&t[bl];if(r===Object)return!0;if(!Ro(r))return!1;let o=qg.get(r);return o===void 0&&(o=Function.toString.call(r),qg.set(r,o)),o===LA}function wl(e,t,r=!0){bs(e)===0?(r?Reflect.ownKeys(e):Zt.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((o,n)=>t(n,o,e))}function bs(e){const t=e[Gt];return t?t.type_:Nl(e)?1:Cl(e)?2:El(e)?3:0}var xd=(e,t,r=bs(e))=>r===2?e.has(t):Zt[yl].hasOwnProperty.call(e,t),wd=(e,t,r=bs(e))=>r===2?e.get(t):e[t],Sl=(e,t,r,o=bs(e))=>{o===2?e.set(t,r):o===3?e.add(r):e[t]=r};function FA(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Nl=Array.isArray,Cl=e=>e instanceof Map,El=e=>e instanceof Set,Sd=e=>typeof e=="object",Ro=e=>typeof e=="function",Nd=e=>typeof e=="boolean";function VA(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var lo=e=>e.copy_||e.base_,Cd=e=>e.modified_?e.copy_:e.base_;function Ed(e,t){if(Cl(e))return new Map(e);if(El(e))return new Set(e);if(Nl(e))return Array[yl].slice.call(e);const r=Yg(e);if(t===!0||t==="class_only"&&!r){const o=Zt.getOwnPropertyDescriptors(e);delete o[Gt];let n=Reflect.ownKeys(o);for(let s=0;s<n.length;s++){const a=n[s],i=o[a];i[xl]===!1&&(i[xl]=!0,i[vd]=!0),(i.get||i.set)&&(o[a]={[vd]:!0,[xl]:!0,[vl]:i[vl],[gs]:e[a]})}return Zt.create(Cn(e),o)}else{const o=Cn(e);if(o!==null&&r)return{...e};const n=Zt.create(o);return Zt.assign(n,e)}}function _d(e,t=!1){return kl(e)||ao(e)||!ir(e)||(bs(e)>1&&Zt.defineProperties(e,{set:_l,add:_l,clear:_l,delete:_l}),Zt.freeze(e),t&&wl(e,(r,o)=>{_d(o,!0)},!1)),e}function GA(){Jt(2)}var _l={[gs]:GA};function kl(e){return e===null||!Sd(e)?!0:Zt.isFrozen(e)}var Al="MapSet",kd="Patches",Qg="ArrayMethods",Kg={};function Xo(e){const t=Kg[e];return t||Jt(0,e),t}var Rg=e=>!!Kg[e],ys,Xg=()=>ys,zA=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Rg(Al)?Xo(Al):void 0,arrayMethodsPlugin_:Rg(Qg)?Xo(Qg):void 0});function Jg(e,t){t&&(e.patchPlugin_=Xo(kd),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ad(e){Dd(e),e.drafts_.forEach(BA),e.drafts_=null}function Dd(e){e===ys&&(ys=e.parent_)}var Zg=e=>ys=zA(ys,e);function BA(e){const t=e[Gt];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function eb(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];if(e!==void 0&&e!==r){r[Gt].modified_&&(Ad(t),Jt(4)),ir(e)&&(e=tb(t,e));const{patchPlugin_:n}=t;n&&n.generateReplacementPatches_(r[Gt].base_,e,t)}else e=tb(t,r);return UA(t,e,!0),Ad(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Hg?e:void 0}function tb(e,t){if(kl(t))return t;const r=t[Gt];if(!r)return $l(t,e.handledSet_,e);if(!Dl(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){const{callbacks_:o}=r;if(o)for(;o.length>0;)o.pop()(e);nb(r,e)}return r.copy_}function UA(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&_d(t,r)}function rb(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Dl=(e,t)=>e.scope_===t,WA=[];function ob(e,t,r,o){const n=lo(e),s=e.type_;if(o!==void 0&&wd(n,o,s)===t){Sl(n,o,r,s);return}if(!e.draftLocations_){const i=e.draftLocations_=new Map;wl(n,(c,d)=>{if(ao(d)){const p=i.get(d)||[];p.push(c),i.set(d,p)}})}const a=e.draftLocations_.get(t)??WA;for(const i of a)Sl(n,i,r,s)}function HA(e,t,r){e.callbacks_.push(function(n){var i;const s=t;if(!s||!Dl(s,n))return;(i=n.mapSetPlugin_)==null||i.fixSetContents(s);const a=Cd(s);ob(e,s.draft_??s,a,r),nb(s,n)})}function nb(e,t){var o;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((o=e.assigned_)==null?void 0:o.size)??0)>0)){const{patchPlugin_:n}=t;if(n){const s=n.getPath(e);s&&n.generatePatches_(e,s,t)}rb(e)}}function jA(e,t,r){const{scope_:o}=e;if(ao(r)){const n=r[Gt];Dl(n,o)&&n.callbacks_.push(function(){Pl(e);const a=Cd(n);ob(e,r,a,t)})}else ir(r)&&e.callbacks_.push(function(){const s=lo(e);e.type_===3?s.has(r)&&$l(r,o.handledSet_,o):wd(s,t,e.type_)===r&&o.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&$l(wd(e.copy_,t,e.type_),o.handledSet_,o)})}function $l(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||ao(e)||t.has(e)||!ir(e)||kl(e)||(t.add(e),wl(e,(o,n)=>{if(ao(n)){const s=n[Gt];if(Dl(s,r)){const a=Cd(s);Sl(e,o,a,e.type_),rb(s)}}else ir(n)&&$l(n,t,r)})),e}function qA(e,t){const r=Nl(e),o={type_:r?1:0,scope_:t?t.scope_:Xg(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let n=o,s=Tl;r&&(n=[o],s=vs);const{revoke:a,proxy:i}=Proxy.revocable(n,s);return o.draft_=i,o.revoke_=a,[i,o]}var Tl={get(e,t){if(t===Gt)return e;let r=e.scope_.arrayMethodsPlugin_;const o=e.type_===1&&typeof t=="string";if(o&&r!=null&&r.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);const n=lo(e);if(!xd(n,t,e.type_))return QA(e,n,t);const s=n[t];if(e.finalized_||!ir(s)||o&&e.operationMethod&&(r!=null&&r.isMutatingArrayMethod(e.operationMethod))&&VA(t))return s;if(s===$d(e.base_,t)||YA(e,t,s)){Pl(e);const a=e.type_===1?+t:t,i=Pd(e.scope_,s,e,a);return e.copy_[a]=i}return s},has(e,t){return t in lo(e)},ownKeys(e){return Reflect.ownKeys(lo(e))},set(e,t,r){const o=sb(lo(e),t);if(o!=null&&o.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){const n=$d(lo(e),t),s=n==null?void 0:n[Gt];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_.set(t,!1),!0;if(FA(r,n)&&(r!==void 0||xd(e.base_,t,e.type_)))return!0;Pl(e),Td(e)}return e.copy_[t]===r&&(r!==void 0||xd(e.copy_,t,e.type_))||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),jA(e,t,r)),!0},deleteProperty(e,t){return Pl(e),$d(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Td(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=lo(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{[xl]:!0,[vd]:e.type_!==1||t!=="length",[vl]:o[vl],[gs]:r[t]}},defineProperty(){Jt(11)},getPrototypeOf(e){return Cn(e.base_)},setPrototypeOf(){Jt(12)}},vs={};for(let e in Tl){let t=Tl[e];vs[e]=function(){const r=arguments;return r[0]=r[0][0],t.apply(this,r)}}vs.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Jt(13),vs.set.call(this,e,t,void 0)},vs.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Jt(14),Tl.set.call(this,e[0],t,r,e[0])};function $d(e,t){const r=e[Gt];return(r?lo(r):e)[t]}function YA(e,t,r){var o;return e.type_!==1||!e.allIndicesReassigned_||(o=e.assigned_)!=null&&o.get(t)||!ir(r)||r[Gt]?!1:e.baseRefs_.has(r)}function QA(e,t,r){var n;const o=sb(t,r);return o?gs in o?o[gs]:(n=o.get)==null?void 0:n.call(e.draft_):void 0}function sb(e,t){if(!(t in e))return;let r=Cn(e);for(;r;){const o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=Cn(r)}}function Td(e){e.modified_||(e.modified_=!0,e.parent_&&Td(e.parent_))}function Pl(e){e.copy_||(e.assigned_=new Map,e.copy_=Ed(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var KA=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,r,o)=>{if(Ro(t)&&!Ro(r)){const s=r;r=t;const a=this;return function(c=s,...d){return a.produce(c,p=>r.call(this,p,...d))}}Ro(r)||Jt(6),o!==void 0&&!Ro(o)&&Jt(7);let n;if(ir(t)){const s=Zg(this),a=Pd(s,t,void 0);let i=!0;try{n=r(a),i=!1}finally{i?Ad(s):Dd(s)}return Jg(s,o),eb(n,s)}else if(!t||!Sd(t)){if(n=r(t),n===void 0&&(n=t),n===Hg&&(n=void 0),this.autoFreeze_&&_d(n,!0),o){const s=[],a=[];Xo(kd).generateReplacementPatches_(t,n,{patches_:s,inversePatches_:a}),o(s,a)}return n}else Jt(1,t)},this.produceWithPatches=(t,r)=>{if(Ro(t))return(a,...i)=>this.produceWithPatches(a,c=>t(c,...i));let o,n;return[this.produce(t,r,(a,i)=>{o=a,n=i}),o,n]},Nd(e==null?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Nd(e==null?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Nd(e==null?void 0:e.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ir(e)||Jt(8),ao(e)&&(e=RA(e));const t=Zg(this),r=Pd(t,e,void 0);return r[Gt].isManual_=!0,Dd(t),r}finishDraft(e,t){const r=e&&e[Gt];(!r||!r.isManual_)&&Jt(9);const{scope_:o}=r;return Jg(o,t),eb(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const n=t[r];if(n.path.length===0&&n.op==="replace"){e=n.value;break}}r>-1&&(t=t.slice(r+1));const o=Xo(kd).applyPatches_;return ao(e)?o(e,t):this.produce(e,n=>o(n,t))}};function Pd(e,t,r,o){const[n,s]=Cl(t)?Xo(Al).proxyMap_(t,r):El(t)?Xo(Al).proxySet_(t,r):qA(t,r);return((r==null?void 0:r.scope_)??Xg()).drafts_.push(n),s.callbacks_=(r==null?void 0:r.callbacks_)??[],s.key_=o,r&&o!==void 0?HA(r,s,o):s.callbacks_.push(function(c){var p;(p=c.mapSetPlugin_)==null||p.fixSetContents(s);const{patchPlugin_:d}=c;s.modified_&&d&&d.generatePatches_(s,[],c)}),n}function RA(e){return ao(e)||Jt(10,e),ab(e)}function ab(e){if(!ir(e)||kl(e))return e;const t=e[Gt];let r,o=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Ed(e,t.scope_.immer_.useStrictShallowCopy_),o=t.scope_.immer_.shouldUseStrictIteration()}else r=Ed(e,!0);return wl(r,(n,s)=>{Sl(r,n,ab(s))},o),t&&(t.finalized_=!1),r}var XA=new KA,lb=XA.produce;function ib(e){return({dispatch:r,getState:o})=>n=>s=>typeof s=="function"?s(r,o,e):n(s)}var JA=ib(),ZA=ib,eD=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?gl:gl.apply(null,arguments)},tD=e=>e&&typeof e.match=="function";function cb(e,t){function r(...o){if(t){let n=t(...o);if(!n)throw new Error(process.env.NODE_ENV==="production"?je(0):"prepareAction did not return an object");return{type:e,payload:n.payload,..."meta"in n&&{meta:n.meta},..."error"in n&&{error:n.error}}}return{type:e,payload:o[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=o=>Wg(o)&&o.type===e,r}function rD(e){return typeof e=="function"&&"type"in e&&tD(e)}function oD(e){const t=e?`${e}`.split("/"):[],r=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched.
178
- Make sure you're calling the action creator before dispatching, i.e. \`dispatch(${r}())\` instead of \`dispatch(${r})\`. This is necessary even if the action has no payload.`}function nD(e={}){if(process.env.NODE_ENV==="production")return()=>r=>o=>r(o);const{isActionCreator:t=rD}=e;return()=>r=>o=>(t(o)&&console.warn(oD(o.type)),r(o))}function db(e,t){let r=0;return{measureTime(o){const n=Date.now();try{return o()}finally{const s=Date.now();r+=s-n}},warnIfExceeded(){r>e&&console.warn(`${t} took ${r}ms, which is more than the warning threshold of ${e}ms.
181
+ Would you like to attempt to import anyway? The schema will be sanitized.`)){const W=JSON.parse($),R=xk(W);l(R)}return}const q=G.errors.filter(H=>H.type==="warning");q.length>0&&console.warn("Schema import warnings:",q),l(V)}catch($){console.error("Failed to import schema:",$),alert("Invalid JSON file. Please select a valid form schema.")}},D.readAsText(_)}f.current&&(f.current.value="")},y=new Set((u==null?void 0:u.hideBuiltinActions)??[]);(u==null?void 0:u.showUndoRedo)===!1&&(y.add("undo"),y.add("redo")),(u==null?void 0:u.showModeToggle)===!1&&(y.add("design-mode"),y.add("preview-mode")),(u==null?void 0:u.showImportExport)===!1&&(y.add("import"),y.add("export")),(u==null?void 0:u.showReset)===!1&&y.add("reset");const v=new Map,S=(u==null?void 0:u.actions)??[];S.forEach(k=>{k.override&&v.set(k.override,k)});const x=P.useMemo(()=>{const k={left:[],center:[],right:[]};return S.filter(_=>!_.override&&!Vc(_,h)).forEach(_=>{k[_.position].push(_)}),Object.values(k).forEach(_=>{_.sort((E,D)=>(E.order??0)-(D.order??0))}),k},[S,h]),w=k=>!(y.has(k)||v.has(k)),N=(k,_)=>{if(y.has(k))return null;const E=v.get(k);return E&&!Vc(E,h)?i.jsx(jo,{action:E,context:h},k):_()};return i.jsx(Vs,{children:i.jsxs("div",{className:m("flex items-center justify-between px-4 py-2 bg-card border-b border-border"),children:[i.jsxs("div",{className:m("flex items-center gap-1"),children:[x.left.filter(k=>(k.order??0)<0).map(k=>i.jsx(jo,{action:k,context:h},k.id)),N("undo",()=>w("undo")?i.jsxs(Fr,{children:[i.jsx(Vr,{asChild:!0,children:i.jsx(st,{variant:"ghost",size:"icon",onClick:o,disabled:!t,children:i.jsx(A1,{className:m("h-5 w-5")})})}),i.jsx(Nr,{children:i.jsx("p",{children:"Undo (⌘Z)"})})]},"undo"):null),N("redo",()=>w("redo")?i.jsxs(Fr,{children:[i.jsx(Vr,{asChild:!0,children:i.jsx(st,{variant:"ghost",size:"icon",onClick:n,disabled:!r,children:i.jsx(E1,{className:m("h-5 w-5")})})}),i.jsx(Nr,{children:i.jsx("p",{children:"Redo (⌘⇧Z)"})})]},"redo"):null),x.left.filter(k=>(k.order??0)>=0).map(k=>i.jsx(jo,{action:k,context:h},k.id))]}),i.jsxs("div",{className:m("flex items-center gap-2"),children:[x.center.filter(k=>(k.order??0)<0).map(k=>i.jsx(jo,{action:k,context:h},k.id)),(u==null?void 0:u.showModeToggle)!==!1&&tr.getVisible().length>0&&i.jsx("div",{className:m("flex items-center bg-muted rounded-lg p-1"),children:tr.getVisible().map(k=>{const _=`${k.id}-mode`;if(y.has(_))return null;const E=k.icon,D=d===k.id;return i.jsxs(Fr,{children:[i.jsx(Vr,{asChild:!0,children:i.jsx(st,{variant:D?"secondary":"ghost",size:"icon",onClick:()=>p(k.id),className:m(D&&"bg-background shadow-sm"),children:i.jsx(E,{className:m("h-5 w-5")})})}),i.jsx(Nr,{children:i.jsx("p",{children:k.description??k.label})})]},k.id)})}),x.center.filter(k=>(k.order??0)>=0).map(k=>i.jsx(jo,{action:k,context:h},k.id))]}),i.jsxs("div",{className:m("flex items-center gap-1"),children:[x.right.filter(k=>(k.order??0)<0).map(k=>i.jsx(jo,{action:k,context:h},k.id)),i.jsx("input",{ref:f,type:"file",accept:".json",onChange:g,className:m("hidden")}),N("import",()=>w("import")?i.jsxs(Fr,{children:[i.jsx(Vr,{asChild:!0,children:i.jsx(st,{variant:"ghost",size:"icon",onClick:b,children:i.jsx(_1,{className:m("h-5 w-5")})})}),i.jsx(Nr,{children:i.jsx("p",{children:"Import"})})]},"import"):null),N("export",()=>w("export")?i.jsxs(Fr,{children:[i.jsx(Vr,{asChild:!0,children:i.jsx(st,{variant:"ghost",size:"icon",onClick:a,children:i.jsx(C1,{className:m("h-5 w-5")})})}),i.jsx(Nr,{children:i.jsx("p",{children:"Export"})})]},"export"):null),N("reset",()=>w("reset")?i.jsxs(Fr,{children:[i.jsx(Vr,{asChild:!0,children:i.jsx(st,{variant:"ghost",size:"icon",className:m("text-destructive hover:text-destructive hover:bg-destructive/10"),onClick:c,children:i.jsx(mc,{className:m("h-5 w-5")})})}),i.jsx(Nr,{children:i.jsx("p",{children:"Reset"})})]},"reset"):null),x.right.filter(k=>(k.order??0)>=0).map(k=>i.jsx(jo,{action:k,context:h},k.id))]})]})})},Zn=({containerId:e,stepId:t,label:r="Drop elements here",children:o,isEmpty:n=!0})=>{const[a,s]=P.useState(!1),l=P.useRef(null),c=ie(h=>h.addElementToContainer),d=ie(h=>h.setDraggedElementType),p=h=>{h.preventDefault();const g=h.currentTarget.querySelectorAll("[data-drop-zone]");for(const y of g){const v=y.getBoundingClientRect();if(h.clientX>=v.left&&h.clientX<=v.right&&h.clientY>=v.top&&h.clientY<=v.bottom){s(!1);return}}h.stopPropagation(),s(!0)},u=h=>{h.preventDefault();const b=h.relatedTarget,g=h.currentTarget;if(b&&g.contains(b)){const y=b.closest("[data-drop-zone]");y&&y!==g&&s(!1);return}h.stopPropagation(),s(!1)},f=h=>{h.preventDefault();const g=h.currentTarget.querySelectorAll("[data-drop-zone]");for(const v of g){const S=v.getBoundingClientRect();if(h.clientX>=S.left&&h.clientX<=S.right&&h.clientY>=S.top&&h.clientY<=S.bottom){s(!1);return}}h.stopPropagation(),s(!1);const y=h.dataTransfer.getData("elementType");y&&(c(y,e,t),d(null))};return i.jsx("div",{ref:l,"data-drop-zone":e,"data-step-id":t,onDragOver:p,onDragLeave:u,onDrop:f,className:m("min-h-[60px] rounded transition-all",a?"border-2 border-blue-400 border-dashed bg-blue-50":n?"border-2 border-dashed border-gray-300 bg-gray-50/50":"border border-dashed border-gray-200"),style:{pointerEvents:"auto"},children:n?i.jsx("div",{className:m("flex items-center justify-center h-full min-h-[60px] text-gray-400 text-sm pointer-events-none"),children:a?"Release to drop":r}):i.jsx("div",{className:m("space-y-2 p-2"),children:o})})},pm=e=>{const t=Eh(e);if(!t)return"📋";if(typeof t=="string")return t;const r=t;return i.jsx(r,{className:m("w-4 h-4 inline-block")})},Gs=({element:e,isSelected:t,isHovered:r,onSelect:o,onHover:n,onDelete:a})=>{const s=()=>e.type==="group"?i.jsx(hm,{element:e}):e.type==="grid"?i.jsx(mm,{element:e}):e.type==="repeatGroup"?i.jsx(bm,{element:e}):i.jsx(Ms,{element:e,isSelected:t}),l=e.type==="group"||e.type==="grid"||e.type==="repeatGroup";return i.jsxs("div",{onClick:c=>{c.stopPropagation(),o()},onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),className:m("relative p-3 rounded-lg border transition-all",l?"cursor-default":"cursor-pointer",t?"border-blue-500 bg-blue-50/50 shadow-sm":r?"border-blue-300 bg-gray-50":"border-gray-200 hover:border-gray-300"),children:[(t||r)&&i.jsxs("div",{className:m("absolute -top-2 left-2 px-1.5 py-0.5 bg-blue-500 text-white text-xs rounded-full shadow-sm flex items-center gap-1"),children:[pm(e.type)," ",yc(e.type)]}),(t||r)&&i.jsx("button",{onClick:c=>{c.stopPropagation(),a()},className:m("absolute -top-2 right-2 w-5 h-5 bg-red-500 text-white rounded-full flex items-center justify-center text-xs hover:bg-red-600 shadow-sm"),children:"×"}),s()]})},$k=({element:e,index:t,isSelected:r,isHovered:o,onSelect:n,onHover:a,onDelete:s,onDuplicate:l,onDragStart:c,onDragOver:d,onDragEnd:p,isDragTarget:u})=>{const f=()=>e.type==="group"?i.jsx(hm,{element:e}):e.type==="grid"?i.jsx(mm,{element:e}):e.type==="repeatGroup"?i.jsx(bm,{element:e}):e.type==="pages"?i.jsx(Pk,{element:e}):i.jsx(Ms,{element:e,isSelected:r}),h=y=>{y.dataTransfer.effectAllowed="move",y.dataTransfer.setData("elementId",e.id),c(t)},b=y=>{y.preventDefault(),y.dataTransfer.dropEffect="move",d(t)},g=()=>{p()};return i.jsxs("div",{draggable:!0,onDragStart:h,onDragOver:b,onDragEnd:g,onClick:n,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),className:m("relative p-4 rounded-lg border-2 transition-all cursor-grab active:cursor-grabbing",u?"border-blue-500 border-dashed bg-blue-50":r?"border-blue-500 bg-blue-50/30 shadow-sm":o?"border-blue-300 bg-gray-50/50":"border-gray-200 bg-white hover:border-gray-300"),children:[u&&i.jsx("div",{className:m("absolute -top-1 left-0 right-0 h-0.5 bg-blue-500 rounded")}),(r||o)&&i.jsxs("div",{className:m("absolute -top-3 left-3 px-2 py-0.5 bg-blue-500 text-white text-xs rounded-full shadow-sm flex items-center gap-1"),children:[pm(e.type)," ",yc(e.type)]}),(r||o)&&i.jsxs("div",{className:m("absolute -top-3 right-3 flex gap-1"),children:[i.jsx("button",{onClick:y=>{y.stopPropagation(),l()},className:m("p-1 bg-white border border-gray-200 rounded shadow-sm hover:bg-gray-50 text-xs"),title:"Duplicate",children:"📋"}),i.jsx("button",{onClick:y=>{y.stopPropagation(),s()},className:m("p-1 bg-white border border-gray-200 rounded shadow-sm hover:bg-red-50 hover:border-red-200 text-xs"),title:"Delete",children:"🗑️"})]}),f(),(r||o)&&i.jsxs("div",{className:m("absolute left-1 top-1/2 -translate-y-1/2 flex flex-col gap-0.5 cursor-grab"),title:"Drag to reorder",children:[i.jsx("div",{className:m("w-4 h-0.5 bg-gray-400 rounded")}),i.jsx("div",{className:m("w-4 h-0.5 bg-gray-400 rounded")}),i.jsx("div",{className:m("w-4 h-0.5 bg-gray-400 rounded")})]})]})},hm=({element:e})=>{var p;const t=e.properties.label||"Group",r=e.properties.description,o=ie(u=>u.schema.elements),n=ie(u=>u.selectedElementId),a=ie(u=>u.hoveredElementId),s=ie(u=>u.selectElement),l=ie(u=>u.setHoveredElementId),c=ie(u=>u.deleteElement),d=o.filter(u=>u.parentId===e.id).sort((u,f)=>u.order-f.order);return i.jsxs("div",{className:m("border border-gray-200 rounded-lg overflow-hidden"),style:{padding:((p=e.config)==null?void 0:p.padding)||16},children:[i.jsxs("div",{className:m("mb-3"),children:[i.jsx("h3",{className:m("font-medium text-gray-800"),children:t}),r&&i.jsx("p",{className:m("text-sm text-gray-500"),children:r})]}),i.jsx(Zn,{containerId:e.id,label:"Drop elements into this group",isEmpty:d.length===0,children:d.map(u=>i.jsx(Gs,{element:u,isSelected:n===u.id,isHovered:a===u.id,onSelect:()=>s(u.id),onHover:f=>l(f?u.id:null),onDelete:()=>c(u.id)},u.id))})]})},mm=({element:e})=>{var p,u;const t=e.properties.label,r=((p=e.config)==null?void 0:p.gridColumns)||2,o=ie(f=>f.schema.elements),n=ie(f=>f.selectedElementId),a=ie(f=>f.hoveredElementId),s=ie(f=>f.selectElement),l=ie(f=>f.setHoveredElementId),c=ie(f=>f.deleteElement),d=o.filter(f=>f.parentId===e.id).sort((f,h)=>f.order-h.order);return i.jsxs("div",{className:m("border border-gray-200 rounded-lg p-4"),children:[t&&i.jsx("div",{className:m("mb-3"),children:i.jsx("h3",{className:m("font-medium text-gray-800"),children:t})}),i.jsx("div",{className:m("grid"),style:{gridTemplateColumns:`repeat(${r}, 1fr)`,gap:((u=e.config)==null?void 0:u.gridGap)||16},children:d.length===0?Array.from({length:r}).map((f,h)=>i.jsx(Zn,{containerId:e.id,label:`Column ${h+1}`},h)):d.map(f=>i.jsx(Gs,{element:f,isSelected:n===f.id,isHovered:a===f.id,onSelect:()=>s(f.id),onHover:h=>l(h?f.id:null),onDelete:()=>c(f.id)},f.id))}),d.length>0&&d.length<r*3&&i.jsx("div",{className:m("mt-3"),children:i.jsx(Zn,{containerId:e.id,label:"Add more elements"})})]})},bm=({element:e})=>{var p,u,f;const t=e.properties.label||"Repeat Group",r=e.properties.description,o=ie(h=>h.schema.elements),n=ie(h=>h.selectedElementId),a=ie(h=>h.hoveredElementId),s=ie(h=>h.selectElement),l=ie(h=>h.setHoveredElementId),c=ie(h=>h.deleteElement),d=o.filter(h=>h.parentId===e.id).sort((h,b)=>h.order-b.order);return i.jsxs("div",{className:m("border border-gray-200 rounded-lg p-4"),children:[i.jsxs("div",{className:m("mb-3"),children:[i.jsxs("div",{className:m("flex items-center gap-2"),children:[i.jsx("span",{className:m("text-lg"),children:"🔄"}),i.jsx("h3",{className:m("font-medium text-gray-800"),children:t})]}),r&&i.jsx("p",{className:m("text-sm text-gray-500"),children:r})]}),i.jsxs("div",{className:m("border border-dashed border-gray-300 rounded-lg p-3 bg-gray-50/50"),children:[i.jsx("div",{className:m("text-xs text-gray-500 mb-2 font-medium"),children:"📋 Item Template (will repeat)"}),i.jsx(Zn,{containerId:e.id,label:"Drop elements to create the repeatable template",isEmpty:d.length===0,children:d.map(h=>i.jsx(Gs,{element:h,isSelected:n===h.id,isHovered:a===h.id,onSelect:()=>s(h.id),onHover:b=>l(b?h.id:null),onDelete:()=>c(h.id)},h.id))})]}),i.jsx("div",{className:m("mt-3"),children:i.jsxs("button",{disabled:!0,className:m("text-sm text-blue-600 hover:text-blue-700 flex items-center gap-1 opacity-70"),children:["➕ ",((p=e.config)==null?void 0:p.addButtonText)||"Add Item"]})}),i.jsxs("div",{className:m("mt-3 text-xs text-gray-500 bg-gray-100 rounded p-2"),children:["ℹ️ Min: ",((u=e.config)==null?void 0:u.minItems)||1,", Max:"," ",((f=e.config)==null?void 0:f.maxItems)||10," items"]})]})},Pk=({element:e})=>{var w,N,k,_;const t=ie(E=>E.schema.elements),r=ie(E=>E.selectedElementId),o=ie(E=>E.hoveredElementId),n=ie(E=>E.selectElement),a=ie(E=>E.setHoveredElementId),s=ie(E=>E.deleteElement),l=ie(E=>E.addWizardStep),c=ie(E=>E.updateWizardStep),d=ie(E=>E.removeWizardStep),p=ie(E=>E.setActiveWizardStep),u=((w=e.config)==null?void 0:w.steps)||[],f=((N=e.config)==null?void 0:N.activeStepId)||((k=u[0])==null?void 0:k.id),h=u.findIndex(E=>E.id===f),b=u[h],g=h===u.length-1,y=t.filter(E=>{var D;return E.parentId?E.parentId===`${e.id}:${f}`||E.parentId===e.id&&((D=E.config)==null?void 0:D.wizardStepId)===f:!1}).sort((E,D)=>E.order-D.order),v=()=>{const E={id:Ka(),label:`Step ${u.length+1}`,description:""};l(e.id,E)},S=()=>{h>0&&p(e.id,u[h-1].id)},x=()=>{h<u.length-1&&p(e.id,u[h+1].id)};return i.jsxs("div",{className:m("border border-gray-200 rounded-lg overflow-hidden"),children:[i.jsxs("div",{className:m("bg-gray-50 border-b border-gray-200 p-3"),children:[i.jsxs("div",{className:m("flex items-center gap-2 mb-2"),children:[i.jsx("span",{className:m("text-lg"),children:"📑"}),i.jsx("h3",{className:m("font-medium text-gray-800"),children:e.properties.label||"Multi-Step Form"})]}),i.jsxs("div",{className:m("flex gap-1 flex-wrap"),children:[u.map((E,D)=>i.jsxs("button",{onClick:()=>p(e.id,E.id),className:m("px-3 py-1.5 text-sm rounded transition-colors",E.id===f?"bg-blue-500 text-white":"bg-white border border-gray-200 hover:bg-gray-100"),children:[D+1,". ",E.label]},E.id)),i.jsx("button",{onClick:v,className:m("px-3 py-1.5 text-sm border border-dashed border-gray-300 rounded hover:bg-gray-100 text-gray-500"),children:"+ Add Step"})]}),((_=e.config)==null?void 0:_.showProgressBar)&&i.jsxs("div",{className:m("mt-3"),children:[i.jsx("div",{className:m("h-2 bg-gray-200 rounded-full overflow-hidden"),children:i.jsx("div",{className:m("h-full bg-blue-500 transition-all"),style:{width:`${(h+1)/u.length*100}%`}})}),i.jsxs("div",{className:m("text-xs text-gray-500 mt-1"),children:["Step ",h+1," of ",u.length]})]})]}),i.jsx("div",{className:m("p-4"),children:b&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:m("mb-4"),children:[i.jsx("input",{type:"text",value:b.label,onChange:E=>c(e.id,f,{label:E.target.value}),className:m("text-lg font-semibold text-gray-800 border-none bg-transparent w-full focus:outline-none focus:ring-0"),placeholder:"Step title"}),i.jsx("input",{type:"text",value:b.description||"",onChange:E=>c(e.id,f,{description:E.target.value}),className:m("text-sm text-gray-500 border-none bg-transparent w-full focus:outline-none focus:ring-0"),placeholder:"Step description (optional)"})]}),i.jsx(Zn,{containerId:e.id,stepId:f,label:"Drop elements for this step",isEmpty:y.length===0,children:y.map(E=>i.jsx(Gs,{element:E,isSelected:r===E.id,isHovered:o===E.id,onSelect:()=>n(E.id),onHover:D=>a(D?E.id:null),onDelete:()=>s(E.id)},E.id))}),i.jsxs("div",{className:m("flex justify-between mt-4 pt-4 border-t border-gray-200"),children:[i.jsx("button",{disabled:h===0,onClick:S,className:m("px-4 py-2 text-sm border border-gray-300 rounded hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"),children:"← Previous"}),i.jsxs("div",{className:m("flex gap-2"),children:[u.length>1&&i.jsx("button",{onClick:()=>d(e.id,f),className:m("px-3 py-2 text-sm text-red-600 hover:bg-red-50 rounded"),children:"🗑️ Delete Step"}),i.jsx("button",{disabled:g,onClick:x,className:m("px-4 py-2 text-sm bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed"),children:"Next →"})]})]})]})}),i.jsx("div",{className:m("px-4 pb-4"),children:i.jsxs("div",{className:m("text-xs text-gray-500 bg-gray-50 rounded p-2"),children:["ℹ️ This wizard has ",u.length," step(s). Click on step tabs to switch between them and add elements. The Submit button will only appear on the last step during form submission."]})})]})},Mk=()=>i.jsxs("div",{className:m("flex flex-col items-center justify-center h-full text-muted-foreground"),children:[i.jsx("div",{className:m("text-6xl mb-4"),children:"📝"}),i.jsx("h3",{className:m("text-lg font-medium text-foreground/70 mb-2"),children:"Start Building Your Form"}),i.jsx("p",{className:m("text-sm text-center max-w-md"),children:"Drag elements from the left sidebar or click them to add to your form. Click on any element to configure its properties."})]}),Ok=({toolbarConfig:e})=>{const t=ie(Q=>Q.schema),r=ie(Q=>Q.selectedElementId),o=ie(Q=>Q.hoveredElementId),n=ie(Q=>Q.addElement),a=ie(Q=>Q.selectElement),s=ie(Q=>Q.deleteElement),l=ie(Q=>Q.duplicateElement),c=ie(Q=>Q.reorderElements),d=ie(Q=>Q.setHoveredElementId),p=ie(Q=>Q.undo),u=ie(Q=>Q.redo),f=ie(Q=>Q.canUndo),h=ie(Q=>Q.canRedo),b=ie(Q=>Q.exportSchema),g=ie(Q=>Q.loadSchema),y=ie(Q=>Q.resetForm),v=ie(Q=>Q.mode),S=ie(Q=>Q.setMode),x=ie(Q=>Q.hasWizard),[w,N]=P.useState(!1),[k,_]=P.useState(null),[E,D]=P.useState(null),T=x(),O=Q=>{if(Q.preventDefault(),T){Q.dataTransfer.dropEffect="none";return}Q.dataTransfer.dropEffect="copy",N(!0)},$=Q=>{Q.currentTarget.contains(Q.relatedTarget)||N(!1)},V=Q=>{if(Q.preventDefault(),N(!1),T)return;const te=Q.dataTransfer.getData("elementType");te&&n(te)},G=()=>{const Q=b(),te=new Blob([JSON.stringify(Q,null,2)],{type:"application/json"}),De=URL.createObjectURL(te),de=document.createElement("a");de.href=De,de.download=`${t.title.replace(/\s+/g,"-").toLowerCase()}-schema.json`,document.body.appendChild(de),de.click(),document.body.removeChild(de),URL.revokeObjectURL(De)},q=Q=>{g(Q)},H=()=>{(t.elements.length===0||window.confirm("Are you sure you want to reset the form? This will delete all elements."))&&y()},Y=Q=>{Q.target===Q.currentTarget&&a(null)},J=[...t.elements].filter(Q=>!Q.parentId).sort((Q,te)=>Q.order-te.order),W=Q=>{_(Q)},R=Q=>{k!==null&&k!==Q&&D(Q)},we=()=>{k!==null&&E!==null&&k!==E&&c(k,E),_(null),D(null)};return i.jsxs("div",{className:m("flex-1 flex flex-col bg-gray-100 overflow-hidden"),children:[i.jsx(Dk,{schema:t,canUndo:f(),canRedo:h(),onUndo:p,onRedo:u,onExport:G,exportSchema:b,onImport:q,onReset:H,mode:v,onModeChange:S,toolbarConfig:e}),i.jsx("div",{className:m("flex-1 overflow-auto p-4",w&&!T?"bg-blue-50":""),onDragOver:O,onDragLeave:$,onDrop:V,onClick:Y,children:i.jsxs("div",{className:m("max-w-4xl mx-auto p-2"),children:[i.jsx("div",{className:m("mb-0 text-center"),children:t.description&&i.jsx("p",{className:m("text-gray-500"),children:t.description})}),i.jsx("div",{className:m("bg-white rounded-xl shadow-sm border-2 transition-colors",w&&!T?"border-blue-400 border-dashed":"border-gray-200"),children:J.length===0?i.jsx("div",{className:m("p-2"),children:i.jsx(Mk,{})}):i.jsx("div",{className:m("p-4 space-y-2"),children:J.map((Q,te)=>i.jsx($k,{element:Q,index:te,isSelected:r===Q.id,isHovered:o===Q.id,onSelect:()=>a(Q.id),onHover:De=>d(De?Q.id:null),onDelete:()=>s(Q.id),onDuplicate:()=>l(Q.id),onDragStart:W,onDragOver:R,onDragEnd:we,isDragTarget:E===te},Q.id))})}),w&&!T&&i.jsx("div",{className:m("mt-4 p-4 border-2 border-dashed border-blue-400 rounded-lg text-center text-blue-500 bg-blue-50/50"),children:"Drop element here"}),T&&w&&i.jsx("div",{className:m("mt-4 p-4 border-2 border-dashed border-orange-400 rounded-lg text-center text-orange-600 bg-orange-50/50"),children:"⚠️ Drop elements inside wizard steps, not here"})]})})]})},Gc=[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],Ik=e=>e.replace(new RegExp("\\p{Nd}","gu"),t=>{const r=t.codePointAt(0);if(r<=57)return t;let o=0,n=Gc.length-1;for(;o<n;){const a=o+n+1>>>1;Gc[a]<=r?o=a:n=a-1}return String(r-Gc[o])}),Lk={"⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9"},Fk=/[⁰¹²³⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅₆₇₈₉]/g,Vk={"¼":"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/"},Gk=/^(?=[-+]?\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)*)?$/,zk=/^(?=[-+]?\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/].*)?/,Bk=/([¼½¾⅐⅑⅒⅓⅔⅕⅖⅗⅘⅙⅚⅛⅜⅝⅞⅟}])/g,zs={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},Uk={"Ⅰ":"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"},Wk=/([ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿ])/gi,Hk=/^(?=[MDCLXVI])(M{0,3})(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$/i,gm={round:3,allowTrailingInvalid:!1,romanNumerals:!1,bigIntOnOverflow:!1,decimalSeparator:".",allowCurrency:!1,percentage:!1,verbose:!1},jk=e=>{const t=`${e}`.replace(Wk,(l,c)=>Uk[c]).toUpperCase(),r=Hk.exec(t);if(!r)return NaN;const[,o,n,a,s]=r;return(zs[o]??0)+(zs[n]??0)+(zs[a]??0)+(zs[s]??0)},qk=/^\s*\//,Yk=new RegExp("^([-+]?)\\s*(\\p{Sc}+)\\s*","u"),Qk=new RegExp("\\s*(\\p{Sc}+)$","u"),Kk=/%$/;function Rk(e,t=gm){const r={...gm,...t},o=typeof e=="string"?e:`${e}`;let n,a,s,l,c,d,p,u;const f=T=>{const O={value:T,input:o};return n&&(O.currencyPrefix=n),a&&(O.currencySuffix=a),s&&(O.percentageSuffix=s),l&&(O.trailingInvalid=l),c&&(O.sign=c),d!==void 0&&(O.whole=d),p!==void 0&&(O.numerator=p),u!==void 0&&(O.denominator=u),O},h=T=>r.verbose?f(T):T;if(typeof e=="number"||typeof e=="bigint")return h(e);let b=NaN,g=o;if(r.allowCurrency){const T=Yk.exec(g);T&&T[2]&&(n=T[2],g=(T[1]||"")+g.slice(T[0].length))}if(r.allowCurrency){const T=Qk.exec(g);T&&(a=T[1],g=g.slice(0,-T[0].length))}r.percentage&&Kk.test(g)&&(s=!0,g=g.slice(0,-1));const y=Ik(g.replace(Bk,(T,O)=>` ${Vk[O]}`).replace(Fk,T=>Lk[T]).replace("⁄","/").trim());if(y.length===0)return h(NaN);let v=y;if(r.decimalSeparator===","){const T=(y.match(/,/g)||[]).length;if(T===1)v=y.replaceAll(".","_").replace(",",".");else if(T>1){if(!r.allowTrailingInvalid)return h(NaN);const O=y.indexOf(","),$=y.indexOf(",",O+1),V=y.substring(0,$).replaceAll(".","_").replace(",","."),G=y.substring($+1);v=r.allowTrailingInvalid?V+"&"+G:V}else v=y.replaceAll(".","_")}const S=zk.exec(v);if(!S)return h(r.romanNumerals?jk(y):NaN);const x=(S[7]||v.slice(S[0].length)).trim();if(x&&(l=x,!r.allowTrailingInvalid))return h(NaN);const[,w,N,k]=S;(w==="-"||w==="+")&&(c=w);const _=N.replaceAll(",","").replaceAll("_",""),E=k==null?void 0:k.replaceAll(",","").replaceAll("_","");if(!_&&E&&E.startsWith("."))b=0;else{if(r.bigIntOnOverflow){const T=BigInt(w==="-"?`-${_}`:_);if(T>BigInt(Number.MAX_SAFE_INTEGER)||T<BigInt(Number.MIN_SAFE_INTEGER))return h(T)}b=parseInt(_)}if(!E)return b=w==="-"?b*-1:b,s&&r.percentage!=="number"&&(b=b/100),h(b);const D=r.round===!1?NaN:parseFloat(`1e${Math.floor(Math.max(0,r.round))}`);if(E.startsWith(".")||E.startsWith("e")||E.startsWith("E")){const T=parseFloat(`${b}${E}`);b=isNaN(D)?T:Math.round(T*D)/D}else if(qk.test(E)){const T=parseInt(_),O=parseInt(E.replace("/",""));p=T,u=O,b=isNaN(D)?T/O:Math.round(T*D/O)/D}else{const[T,O]=E.split("/").map($=>parseInt($));d=b,p=T,u=O,b+=isNaN(D)?T/O:Math.round(T*D/O)/D}return b=w==="-"?b*-1:b,s&&r.percentage!=="number"&&(b=isNaN(D)?b/100:Math.round(b/100*D)/D),h(b)}var ym=Symbol.for("immer-nothing"),vm=Symbol.for("immer-draftable"),zt=Symbol.for("immer-state"),Xk=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function rr(e,...t){if(process.env.NODE_ENV!=="production"){const r=Xk[e],o=qo(r)?r.apply(null,t):r;throw new Error(`[Immer] ${o}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var or=Object,xn=or.getPrototypeOf,Bs="constructor",Us="prototype",zc="configurable",Ws="enumerable",Hs="writable",ea="value",Gr=e=>!!e&&!!e[zt];function zr(e){var t;return e?xm(e)||Ys(e)||!!e[vm]||!!((t=e[Bs])!=null&&t[vm])||Qs(e)||Ks(e):!1}var Jk=or[Us][Bs].toString(),wm=new WeakMap;function xm(e){if(!e||!Wc(e))return!1;const t=xn(e);if(t===null||t===or[Us])return!0;const r=or.hasOwnProperty.call(t,Bs)&&t[Bs];if(r===Object)return!0;if(!qo(r))return!1;let o=wm.get(r);return o===void 0&&(o=Function.toString.call(r),wm.set(r,o)),o===Jk}function js(e,t,r=!0){ta(e)===0?(r?Reflect.ownKeys(e):or.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((o,n)=>t(n,o,e))}function ta(e){const t=e[zt];return t?t.type_:Ys(e)?1:Qs(e)?2:Ks(e)?3:0}var Bc=(e,t,r=ta(e))=>r===2?e.has(t):or[Us].hasOwnProperty.call(e,t),Uc=(e,t,r=ta(e))=>r===2?e.get(t):e[t],qs=(e,t,r,o=ta(e))=>{o===2?e.set(t,r):o===3?e.add(r):e[t]=r};function Zk(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Ys=Array.isArray,Qs=e=>e instanceof Map,Ks=e=>e instanceof Set,Wc=e=>typeof e=="object",qo=e=>typeof e=="function",Hc=e=>typeof e=="boolean";function eA(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var oo=e=>e.copy_||e.base_,jc=e=>e.modified_?e.copy_:e.base_;function qc(e,t){if(Qs(e))return new Map(e);if(Ks(e))return new Set(e);if(Ys(e))return Array[Us].slice.call(e);const r=xm(e);if(t===!0||t==="class_only"&&!r){const o=or.getOwnPropertyDescriptors(e);delete o[zt];let n=Reflect.ownKeys(o);for(let a=0;a<n.length;a++){const s=n[a],l=o[s];l[Hs]===!1&&(l[Hs]=!0,l[zc]=!0),(l.get||l.set)&&(o[s]={[zc]:!0,[Hs]:!0,[Ws]:l[Ws],[ea]:e[s]})}return or.create(xn(e),o)}else{const o=xn(e);if(o!==null&&r)return{...e};const n=or.create(o);return or.assign(n,e)}}function Yc(e,t=!1){return Xs(e)||Gr(e)||!zr(e)||(ta(e)>1&&or.defineProperties(e,{set:Rs,add:Rs,clear:Rs,delete:Rs}),or.freeze(e),t&&js(e,(r,o)=>{Yc(o,!0)},!1)),e}function tA(){rr(2)}var Rs={[ea]:tA};function Xs(e){return e===null||!Wc(e)?!0:or.isFrozen(e)}var Js="MapSet",Qc="Patches",Cm="ArrayMethods",Sm={};function Yo(e){const t=Sm[e];return t||rr(0,e),t}var Nm=e=>!!Sm[e],ra,Em=()=>ra,rA=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Nm(Js)?Yo(Js):void 0,arrayMethodsPlugin_:Nm(Cm)?Yo(Cm):void 0});function km(e,t){t&&(e.patchPlugin_=Yo(Qc),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Kc(e){Rc(e),e.drafts_.forEach(oA),e.drafts_=null}function Rc(e){e===ra&&(ra=e.parent_)}var Am=e=>ra=rA(ra,e);function oA(e){const t=e[zt];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function _m(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];if(e!==void 0&&e!==r){r[zt].modified_&&(Kc(t),rr(4)),zr(e)&&(e=Tm(t,e));const{patchPlugin_:n}=t;n&&n.generateReplacementPatches_(r[zt].base_,e,t)}else e=Tm(t,r);return nA(t,e,!0),Kc(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ym?e:void 0}function Tm(e,t){if(Xs(t))return t;const r=t[zt];if(!r)return el(t,e.handledSet_,e);if(!Zs(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){const{callbacks_:o}=r;if(o)for(;o.length>0;)o.pop()(e);Pm(r,e)}return r.copy_}function nA(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Yc(t,r)}function Dm(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Zs=(e,t)=>e.scope_===t,aA=[];function $m(e,t,r,o){const n=oo(e),a=e.type_;if(o!==void 0&&Uc(n,o,a)===t){qs(n,o,r,a);return}if(!e.draftLocations_){const l=e.draftLocations_=new Map;js(n,(c,d)=>{if(Gr(d)){const p=l.get(d)||[];p.push(c),l.set(d,p)}})}const s=e.draftLocations_.get(t)??aA;for(const l of s)qs(n,l,r,a)}function sA(e,t,r){e.callbacks_.push(function(n){var l;const a=t;if(!a||!Zs(a,n))return;(l=n.mapSetPlugin_)==null||l.fixSetContents(a);const s=jc(a);$m(e,a.draft_??a,s,r),Pm(a,n)})}function Pm(e,t){var o;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((o=e.assigned_)==null?void 0:o.size)??0)>0)){const{patchPlugin_:n}=t;if(n){const a=n.getPath(e);a&&n.generatePatches_(e,a,t)}Dm(e)}}function lA(e,t,r){const{scope_:o}=e;if(Gr(r)){const n=r[zt];Zs(n,o)&&n.callbacks_.push(function(){rl(e);const s=jc(n);$m(e,r,s,t)})}else zr(r)&&e.callbacks_.push(function(){const a=oo(e);e.type_===3?a.has(r)&&el(r,o.handledSet_,o):Uc(a,t,e.type_)===r&&o.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&el(Uc(e.copy_,t,e.type_),o.handledSet_,o)})}function el(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||Gr(e)||t.has(e)||!zr(e)||Xs(e)||(t.add(e),js(e,(o,n)=>{if(Gr(n)){const a=n[zt];if(Zs(a,r)){const s=jc(a);qs(e,o,s,e.type_),Dm(a)}}else zr(n)&&el(n,t,r)})),e}function iA(e,t){const r=Ys(e),o={type_:r?1:0,scope_:t?t.scope_:Em(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let n=o,a=tl;r&&(n=[o],a=oa);const{revoke:s,proxy:l}=Proxy.revocable(n,a);return o.draft_=l,o.revoke_=s,[l,o]}var tl={get(e,t){if(t===zt)return e;let r=e.scope_.arrayMethodsPlugin_;const o=e.type_===1&&typeof t=="string";if(o&&r!=null&&r.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);const n=oo(e);if(!Bc(n,t,e.type_))return dA(e,n,t);const a=n[t];if(e.finalized_||!zr(a)||o&&e.operationMethod&&(r!=null&&r.isMutatingArrayMethod(e.operationMethod))&&eA(t))return a;if(a===Xc(e.base_,t)||cA(e,t,a)){rl(e);const s=e.type_===1?+t:t,l=Zc(e.scope_,a,e,s);return e.copy_[s]=l}return a},has(e,t){return t in oo(e)},ownKeys(e){return Reflect.ownKeys(oo(e))},set(e,t,r){const o=Mm(oo(e),t);if(o!=null&&o.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){const n=Xc(oo(e),t),a=n==null?void 0:n[zt];if(a&&a.base_===r)return e.copy_[t]=r,e.assigned_.set(t,!1),!0;if(Zk(r,n)&&(r!==void 0||Bc(e.base_,t,e.type_)))return!0;rl(e),Jc(e)}return e.copy_[t]===r&&(r!==void 0||Bc(e.copy_,t,e.type_))||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),lA(e,t,r)),!0},deleteProperty(e,t){return rl(e),Xc(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),Jc(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=oo(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{[Hs]:!0,[zc]:e.type_!==1||t!=="length",[Ws]:o[Ws],[ea]:r[t]}},defineProperty(){rr(11)},getPrototypeOf(e){return xn(e.base_)},setPrototypeOf(){rr(12)}},oa={};for(let e in tl){let t=tl[e];oa[e]=function(){const r=arguments;return r[0]=r[0][0],t.apply(this,r)}}oa.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&rr(13),oa.set.call(this,e,t,void 0)},oa.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&rr(14),tl.set.call(this,e[0],t,r,e[0])};function Xc(e,t){const r=e[zt];return(r?oo(r):e)[t]}function cA(e,t,r){var o;return e.type_!==1||!e.allIndicesReassigned_||(o=e.assigned_)!=null&&o.get(t)||!zr(r)||r[zt]?!1:e.baseRefs_.has(r)}function dA(e,t,r){var n;const o=Mm(t,r);return o?ea in o?o[ea]:(n=o.get)==null?void 0:n.call(e.draft_):void 0}function Mm(e,t){if(!(t in e))return;let r=xn(e);for(;r;){const o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=xn(r)}}function Jc(e){e.modified_||(e.modified_=!0,e.parent_&&Jc(e.parent_))}function rl(e){e.copy_||(e.assigned_=new Map,e.copy_=qc(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var uA=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(r,o,n)=>{if(qo(r)&&!qo(o)){const s=o;o=r;const l=this;return function(d=s,...p){return l.produce(d,u=>o.call(this,u,...p))}}qo(o)||rr(6),n!==void 0&&!qo(n)&&rr(7);let a;if(zr(r)){const s=Am(this),l=Zc(s,r,void 0);let c=!0;try{a=o(l),c=!1}finally{c?Kc(s):Rc(s)}return km(s,n),_m(a,s)}else if(!r||!Wc(r)){if(a=o(r),a===void 0&&(a=r),a===ym&&(a=void 0),this.autoFreeze_&&Yc(a,!0),n){const s=[],l=[];Yo(Qc).generateReplacementPatches_(r,a,{patches_:s,inversePatches_:l}),n(s,l)}return a}else rr(1,r)},this.produceWithPatches=(r,o)=>{if(qo(r))return(l,...c)=>this.produceWithPatches(l,d=>r(d,...c));let n,a;return[this.produce(r,o,(l,c)=>{n=l,a=c}),n,a]},Hc(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),Hc(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),Hc(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){zr(t)||rr(8),Gr(t)&&(t=ed(t));const r=Am(this),o=Zc(r,t,void 0);return o[zt].isManual_=!0,Rc(r),o}finishDraft(t,r){const o=t&&t[zt];(!o||!o.isManual_)&&rr(9);const{scope_:n}=o;return km(n,r),_m(void 0,n)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,r){let o;for(o=r.length-1;o>=0;o--){const a=r[o];if(a.path.length===0&&a.op==="replace"){t=a.value;break}}o>-1&&(r=r.slice(o+1));const n=Yo(Qc).applyPatches_;return Gr(t)?n(t,r):this.produce(t,a=>n(a,r))}};function Zc(e,t,r,o){const[n,a]=Qs(t)?Yo(Js).proxyMap_(t,r):Ks(t)?Yo(Js).proxySet_(t,r):iA(t,r);return((r==null?void 0:r.scope_)??Em()).drafts_.push(n),a.callbacks_=(r==null?void 0:r.callbacks_)??[],a.key_=o,r&&o!==void 0?sA(r,a,o):a.callbacks_.push(function(c){var p;(p=c.mapSetPlugin_)==null||p.fixSetContents(a);const{patchPlugin_:d}=c;a.modified_&&d&&d.generatePatches_(a,[],c)}),n}function ed(e){return Gr(e)||rr(10,e),Om(e)}function Om(e){if(!zr(e)||Xs(e))return e;const t=e[zt];let r,o=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=qc(e,t.scope_.immer_.useStrictShallowCopy_),o=t.scope_.immer_.shouldUseStrictIteration()}else r=qc(e,!0);return js(r,(n,a)=>{qs(r,n,Om(a))},o),t&&(t.finalized_=!1),r}var fA=new uA,na=fA.produce;const wo="------",ot={fields:{title:"Field",placeholderName:"~",placeholderLabel:wo,placeholderGroupLabel:wo},operators:{title:"Operator",placeholderName:"~",placeholderLabel:wo,placeholderGroupLabel:wo},values:{title:"Values",placeholderName:"~",placeholderLabel:wo,placeholderGroupLabel:wo},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"},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"}},Im={"=":"=","!=":"!=","<":"<",">":">","<=":"<=",">=":">=",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"},pA={and:"AND",or:"OR",xor:"XOR"},hA=[{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"}],aa=[{name:"and",value:"and",label:"AND"},{name:"or",value:"or",label:"OR"}];[...aa];const Lm=[{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"}],_e={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",dndDragging:"dndDragging",dndOver:"dndOver",dndCopy:"dndCopy",dndGroup:"dndGroup",dndDropNotAllowed:"dndDropNotAllowed",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",hasSubQuery:"rule-hasSubQuery"},Te={rule:"rule",ruleGroup:"rule-group",inlineCombinator:"inline-combinator",addGroup:"add-group",removeGroup:"remove-group",cloneGroup:"clone-group",cloneRule:"clone-rule",addRule:"add-rule",removeRule:"remove-rule",combinators:"combinators",fields:"fields",operators:"operators",valueEditor:"value-editor",notToggle:"not-toggle",shiftActions:"shift-actions",dragHandle:"drag-handle",lockRule:"lock-rule",lockGroup:"lock-group",muteRule:"mute-rule",muteGroup:"mute-group",valueSourceSelector:"value-source-selector",matchModeEditor:"match-mode-editor"},Et={parentPathDisabled:"action aborted: parent path disabled",pathDisabled:"action aborted: path is disabled",onAddRuleFalse:"onAddRule callback returned false",onAddGroupFalse:"onAddGroup callback returned false",onGroupRuleFalse:"onGroupRule callback returned false",onGroupGroupFalse:"onGroupGroup callback returned false",onMoveRuleFalse:"onMoveRule callback returned false",onMoveGroupFalse:"onMoveGroup callback returned false",onRemoveFalse:"onRemove callback returned false",add:"rule or group added",remove:"rule or group removed",update:"rule or group updated",move:"rule or group moved",group:"rule or group grouped with another"},Fm=[],mA={addRuleToNewGroups:!1,autoSelectField:!0,autoSelectOperator:!0,autoSelectValue:!1,debugMode:!1,enableDragAndDrop:!1,enableMountQueryChange:!0,listsAsArrays:!1,resetOnFieldChange:!0,resetOnOperatorChange:!1,showCloneButtons:!1,showCombinatorsBetweenRules:!1,showLockButtons:!1,showMuteButtons:!1,showNotToggle:!1,showShiftActions:!1,suppressStandardClassnames:!1},Vm=(e,t=",")=>typeof e=="string"?e.split(`\\${t}`).map(r=>r.split(t)).reduce((r,o,n)=>n===0?o:[...r.slice(0,-1),`${r.at(-1)}${t}${o[0]}`,...o.slice(1)],[]):[],sa=(e,t=",")=>e.map(r=>`${r??""}`.replaceAll(t[0],`\\${t[0]}`)).join(t),Ke=e=>typeof e=="string"?e.trim():e,Ee=(e,{retainEmptyStrings:t}={})=>Array.isArray(e)?e.map(Ke):typeof e=="string"?Vm(e,",").filter(t?()=>!0:r=>!/^\s*$/.test(r)).map(r=>r.trim()):typeof e=="number"?[e]:[];function Gm(e){var t,r,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(t=0;t<n;t++)e[t]&&(r=Gm(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}function Qe(){for(var e,t,r=0,o="",n=arguments.length;r<n;r++)(e=arguments[r])&&(t=Gm(e))&&(o&&(o+=" "),o+=t);return o}const Ge=e=>typeof e=="string"?e.toLowerCase():e,zm=new RegExp(Gk.source.replace(/^\^/,String.raw`^\s*`).replace(/\$$/,String.raw`\s*$`)),Er=e=>e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype,no=e=>e==null||e==="",ke=e=>Er(e)&&Array.isArray(e.rules),Bt=e=>ke(e)&&typeof e.combinator=="string",Cn=e=>ke(e)&&e.combinator===void 0,Bm=["or","xor","and"],bA=(e,t)=>Ge(e)===t,ol=(e,t=0)=>{const r=Bm[t];if(!e.rules.includes(r))return t<Bm.length-2?ol(e,t+1):e;const o=[...e.rules];let n=0;for(;n<o.length-2;){if(bA(o[n+1],r)){n+=2;continue}let a=-1;for(let s=n+2;s<o.length;s++)if(typeof o[s]=="string"&&Ge(o[s])===r){a=s;break}if(a===-1){o.splice(n,o.length,ol({rules:o.slice(n)},t+1));break}else o.splice(n,a-n,ol({rules:o.slice(n,a)},t+1))}return{...e,rules:o}},kr=e=>{if(Bt(e))return e;const t=ol(e),r=[];let o="and";for(const[n,a]of t.rules.entries())typeof a=="string"?n===1&&(o=a):r.push(ke(a)?kr(a):a);return{...t,combinator:o,rules:r}},gA=Object.keys,Um=Object.entries,nl=e=>e==="__proto__"||e==="constructor"||e==="prototype",td=e=>Er(e)&&"name"in e&&typeof e.name=="string",rd=e=>Er(e)&&"value"in e&&typeof e.value=="string";function Br(e,t,r){if(typeof e=="string")return{...t,name:e,value:e,label:(r==null?void 0:r[e])??e};const o={};let n=!!t;return td(e)&&!rd(e)?(o.value=e.name,n=!0):!td(e)&&rd(e)&&(o.name=e.value,n=!0),n?Object.assign({},t,e,o):e}function Ur(e,t,r){if(!Array.isArray(e))return[];const o=e;return xo(o)?o.map(n=>({...n,options:n.options.map(a=>Br(a,t,r))})):o.map(n=>Br(n,t,r))}function Wm(e,t){return Object.fromEntries(Object.entries(e).map(([r,o])=>[r,Br(o,t)]))}const od=e=>{const t=new Set,r=[];for(const o of e)t.has(o.value??o.name)||(t.add(o.value??o.name),r.push(o));return e.length===r.length?e:r},Hm=e=>Array.isArray(e)&&e.length>0&&Er(e[0])&&"options"in e[0]&&Array.isArray(e[0].options),al=e=>{let t=!1;if(Array.isArray(e))for(const r of e)if(td(r)||rd(r))t=!0;else return!1;return t},xo=(e,{allowEmpty:t=!1}={})=>{let r=!1;if(Array.isArray(e))for(const o of e)if(Er(o)&&"options"in o&&(al(o.options)||t&&Array.isArray(o.options)&&o.options.length===0))r=!0;else return!1;return r};function Xe(e,t){return(xo(e,{allowEmpty:!0})?e.flatMap(r=>r.options):e).find(r=>r.value===t||r.name===t)}function Pt(e){if(!Array.isArray(e)||e.length===0)return null;if(xo(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 nd=e=>od(Hm(e)?e.flatMap(t=>t.options):e),jm=e=>{const t=new Set,r=new Set,o=[];for(const n of e)if(!t.has(n.label)){t.add(n.label);const a=[];for(const s of n.options)r.has(s.value??s.name)||(r.add(s.value??s.name),a.push(Br(s)));o.push({...n,options:a})}return o},Sn=e=>{const{optionList:t,baseOption:r={},labelMap:o={},placeholder:{placeholderName:n="~",placeholderLabel:a=wo,placeholderGroupLabel:s=wo}={},autoSelectOption:l=!0}=e,c={id:n,name:n,value:n,label:a},d=t??[c];let p;const u=Array.isArray(d)?Ur(d,r,o):gA(Wm(d,r)).map(h=>({...d[h],name:h,value:h})).sort((h,b)=>h.label.localeCompare(b.label));xo(u)?p=jm(l?u:[{label:s,options:[c]},...u]):p=od(l?u:[c,...u]);let f={};if(Array.isArray(d))if(xo(p))for(const h of p)for(const b of h.options)f[b.value??b.name]=Br(b,r);else for(const h of p)f[h.value??h.name]=Br(h,r);else{const h=Wm(d,r);f=l?h:{...h,[n]:c}}return{defaultOption:c,optionList:p,optionsMap:f}},qm=(e,t,r)=>{var a;const o=Br(e),n=Br(r);return o.value===n.value?!1:typeof o.comparator=="string"?o[o.comparator]===n[o.comparator]:((a=o.comparator)==null?void 0:a.call(o,n,t))??!1},Ym=(e,t,r)=>{if(!e.comparator){const o=n=>(n.value??n.name)!==(e.value??e.name);return xo(t)?t.map(n=>({...n,options:n.options.filter(a=>o(a))})):t.filter(n=>o(n))}return xo(t)?t.map(o=>({...o,options:o.options.filter(n=>qm(e,r,n))})).filter(o=>o.options.length>0):t.filter(o=>qm(e,r,o))},Le=(e,{parseNumbers:t,bigIntOnOverflow:r}={})=>{if(!t||typeof e=="bigint"||typeof e=="number")return e;if(t==="native")return Number.parseFloat(e);const o=Rk(e,{allowTrailingInvalid:t==="enhanced",bigIntOnOverflow:r,romanNumerals:!1,round:!1});return typeof o=="bigint"||!Number.isNaN(o)?o:e},Qm=(e,t,r)=>{const o={};for(const n in e){if(nl(n))continue;const a=t[n];a!==!1&&(a&&n!==a?(nl(a)||(o[a]=e[n]),r||(o[n]=e[n])):o[n]=e[n])}return o};function ao(e,t={}){const{ruleProcessor:r=p=>p,ruleGroupProcessor:o=p=>p,propertyMap:n={},combinatorMap:a={},operatorMap:s={},omitPath:l=!1,deleteRemappedProperties:c=!0}=t,d=p=>({...o(Qm({...p,...Bt(p)?{combinator:a[p.combinator]??p.combinator}:{}},n,c)),...n.rules===!1?null:{[n.rules??"rules"]:p.rules.map((u,f)=>{const h=l?null:{path:[...p.path,f]};return typeof u=="string"?a[u]??u:ke(u)?d({...u,...h}):r(Qm({...u,...h,..."operator"in u?{operator:s[u.operator]??u.operator}:{}},n,c))})}});return d({...e,...l?null:{path:[]}})}const Nn=e=>Er(e)&&typeof e.valid=="boolean",ze=(e,t,r)=>{if(e.muted)return!1;if(typeof t=="boolean")return t;if(Nn(t))return t.valid;if(typeof r=="function"&&!ke(e)){const o=r(e);if(typeof o=="boolean")return o;if(Nn(o))return o.valid}return!0},ad=({parseNumbers:e,inputType:t})=>{if(typeof e=="string"){const[r,o]=e.split("-");return o==="limited"?t==="number"?r:!1:r}return e?"strict":!1},yA=e=>{switch(Ge(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}},vA=(e="||")=>(...t)=>e.toUpperCase()==="CONCAT"?`CONCAT(${t.join(", ")})`:t.join(` ${e} `),wA=e=>{switch(e){case"contains":case"doesnotcontain":return["%","%"];case"beginswith":case"doesnotbeginwith":return["","%"];case"endswith":case"doesnotendwith":return["%",""];default:return["",""]}},la=(e,t,{concatOperator:r="||",quoteValuesWith:o,wrapValueWith:n=["",""]}={})=>{const[a,s]=wA(t),l=o||"'",c=p=>`${n[0]}${l}${p}${l}${n[1]}`,d=[a&&c(a),e,s&&c(s)].filter(Boolean);return d.length>1?vA(r)(...d):e},Qo={"=":"$eq","!=":"$ne","<":"$lt","<=":"$lte",">":"$gt",">=":"$gte",in:"$in",notin:"$nin",notIn:"$nin"},Km={"=":"equals","!=":"not","<":"lt","<=":"lte",">":"gt",">=":"gte",in:"in",notin:"notIn"},sl={and:"&&",or:"||"},Rm=(e,t)=>({...e,rules:e.rules.map(r=>{if(typeof r=="string")return r;if(ke(r))return Rm(r,t);const o=Xe(t.fields,r.field),n=ad({parseNumbers:t.parseNumbers,inputType:o==null?void 0:o.inputType});if(Array.isArray(r.value))return{...r,value:r.value.map(s=>Le(s,{parseNumbers:n}))};const a=Ee(r.value,{retainEmptyStrings:!0}).map(s=>Le(s,{parseNumbers:n}));if(a.every(s=>typeof s=="number")){if(a.length>1)return{...r,value:a};if(a.length===1)return{...r,value:a[0]}}return r})}),wt=e=>typeof e=="string"&&e.length>0||typeof e=="number"&&!Number.isNaN(e)||typeof e!="string"&&typeof e!="number",Ae=(e,t)=>!!t&&(typeof e=="number"||typeof e=="bigint"||typeof e=="string"&&zm.test(e)),xA=e=>e.length>=3,Xm=(e=["",""])=>Array.isArray(e)?e:typeof e=="string"?[e,e]:e??["",""],En=(e,{quoteFieldNamesWith:t,fieldIdentifierSeparator:r})=>{const[o,n]=Xm(t);return typeof r=="string"&&r.length>0?sa(Vm(e,r).map(a=>`${o}${a}${n}`),r):`${o}${e}${n}`},Jm=["S","V","O"],CA=e=>{const t=[],r=new Set(Jm);for(const o of e.toUpperCase())if(r.has(o)&&(t.push(o),r.delete(o),r.size===0))break;for(const o of Jm)r.has(o)&&t.push(o);return t},ia=(e,t=":")=>{const r=`${e??""}`;return t&&r.startsWith(t)?r:`${t}${r}`},sd=(e,t=":")=>{const r=`${e??""}`;return t&&r.startsWith(t)?r.slice(t.length):r},ld={groupPrefix:"",groupPrefix_not_xor:"either zero or more than one of",groupPrefix_xor:"exactly one of",groupSuffix:"is true",groupSuffix_not:"is not true"},Zm=(e,t,r)=>t.startsWith(e)&&r.every(o=>{var n;return t.includes(`_${o}`)&&((n=t.match(/_/g))==null?void 0:n.length)===r.length}),ll=(e,t,r=[])=>{var o,n;return r.length===0?t[e]??ld[e]??"":((o=Object.entries(t).find(([a])=>Zm(e,a,r)))==null?void 0:o[1])??((n=Object.entries(ld).find(([a])=>Zm(e,a,r)))==null?void 0:n[1])??ld[e]??""},Rt=e=>{const{mode:t,threshold:r}=e.match??{};if(!t)return null;if(!ke(e.value))return!1;const o=Ge(t),n=o==="atleast"&&r===1?"some":o==="atmost"&&r===0?"none":o;return(n==="atleast"||n==="atmost"||n==="exactly")&&(typeof r!="number"||r<0)?!1:{mode:n,threshold:r}},eb="elem_alias",il=(e=0)=>e>0?`${eb}_${e}`:eb,tb=(e,t)=>typeof t=="bigint"?{$bigint:t.toString()}:t,rb=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:a,placeholderOperatorName:s,placeholderValueName:l,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!ze(f,p[f.id??""]))return h?o:"";const b=[];let g="",y=!0;for(const w of f.rules){if(typeof w=="string"){g=sl[w];continue}if(ke(w)){const D=u(w);D&&(!y&&g&&(b.push(g),g=""),y=!1,b.push(D));continue}const[N,k]=d(w);if(!ze(w,N,k)||w.field===a||w.operator===s||l!==void 0&&w.value===l)continue;const _=Xe(r,w.field),E=c(w,{...t,parseNumbers:n(_==null?void 0:_.inputType),escapeQuotes:(w.valueSource??"value")==="value",fieldData:_});E&&(!y&&g&&(b.push(g),g=""),y=!1,b.push(E))}const v=b.join(Bt(f)?` ${sl[f.combinator]} `:" "),[S,x]=f.not||!h?[`${f.not?"!":""}(`,")"]:["",""];return v?`${S}${v}${x}`:o};return u(e,!0)},cl=e=>e.startsWith("not")||e.startsWith("doesnot"),Ko=(e,t)=>typeof e!="string"||!t?`${e}`:e.replaceAll('"','\\"'),SA=(e,t={})=>{const{escapeQuotes:r,parseNumbers:o,preserveValueOrder:n}=t,{field:a,operator:s,value:l,valueSource:c}=e,d=c==="field"||c==="parameter",p=Ge(s==="="?"==":s),u=typeof l=="number"||typeof l=="boolean"||typeof l=="bigint"||Ae(l,o),f=Rt(e);if(f===!1)return"";if(f){const{mode:h,threshold:b}=f,g=t.subqueryDepth??0,y=il(g),v=rb(ao(e.value,{ruleProcessor:S=>({...S,field:`${y}${S.field?`.${S.field}`:""}`})}),{...t,subqueryDepth:g+1});switch(h){case"all":return`${a}.all(${y}, ${v})`;case"none":case"some":return`${h==="none"?"!":""}${a}.exists(${y}, ${v})`;case"atleast":case"atmost":case"exactly":{const S=`double(${a}.size())`,x=`${a}.filter(${y}, ${v}).size()`,w=h==="atleast"?">=":h==="atmost"?"<=":"==";return b>0&&b<1?`double(${x}) ${w} (${S} * ${b})`:`${x} ${w} ${b}`}}}switch(p){case"<":case"<=":case"==":case"!=":case">":case">=":return`${a} ${p} ${d||u?Ke(l):`"${Ko(l,r)}"`}`;case"contains":case"doesnotcontain":return`${cl(p)?"!":""}${a}.contains(${d?Ke(l):`"${Ko(l,r)}"`})`;case"beginswith":case"doesnotbeginwith":return`${cl(p)?"!":""}${a}.startsWith(${d?Ke(l):`"${Ko(l,r)}"`})`;case"endswith":case"doesnotendwith":return`${cl(p)?"!":""}${a}.endsWith(${d?Ke(l):`"${Ko(l,r)}"`})`;case"null":return`${a} == null`;case"notnull":return`${a} != null`;case"in":case"notin":{const[h,b]=cl(p)?["!(",")"]:["",""];return`${h}${a} in [${Ee(l).map(g=>d||Ae(g,o)?`${Ke(g)}`:`"${Ko(g,r)}"`).join(", ")}]${b}`}case"between":case"notbetween":{const h=Ee(l);if(h.length>=2&&!no(h[0])&&!no(h[1])){const[b,g]=h,y=o!==!1,v=Ae(b,y)?Le(b,{parseNumbers:y}):NaN,S=Ae(g,y)?Le(g,{parseNumbers:y}):NaN;let x=Number.isNaN(v)?d?`${b}`:`"${Ko(b,r)}"`:v,w=Number.isNaN(S)?d?`${g}`:`"${Ko(g,r)}"`:S;if(!n&&x===v&&w===S&&S<v){const N=S;w=v,x=N}return p==="between"?`(${a} >= ${x} && ${a} <= ${w})`:`(${a} < ${x} || ${a} > ${w})`}else return""}}return""},id={$and:[{$expr:!0}]},cd=(e,t,r)=>{const{context:o,fields:n,getParseNumberBoolean:a,placeholderFieldName:s,placeholderOperatorName:l,placeholderValueName:c,ruleProcessor:d,validateRule:p,validationMap:u}=t,{inExpressionContext:f}=o??{},h=(b,g)=>{if(!ze(b,u[b.id??""]))return g?id:!1;const y=`$${Ge(b.combinator)}`;let v=!1;const S=b.rules.map(w=>{if(ke(w)){const E=h(w);return E?(v=!0,E):!1}const[N,k]=p(w);if(!ze(w,N,k)||w.field===s||w.operator===l||c!==void 0&&w.value===c)return!1;const _=Xe(n,w.field);return d(w,{...t,parseNumbers:a(_==null?void 0:_.inputType),fieldData:_},r)}).filter(Boolean),x=S.length>0?S.length===1&&!v?S[0]:{[y]:S}:id;return b.not?f?{$not:x}:{$nor:[x]}:x};return h(kr(e),!0)},so=(e,t,r=!1)=>Ae(e,r||typeof e=="bigint")?Number(Le(e,{parseNumbers:"strict"})):t,dl=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:a}=e,{parseNumbers:s,preserveValueOrder:l,context:c}=t,d=a==="field",{avoidFieldsAsKeys:p}=c??{},u=Rt(e);if(u===!1)return;if(u){const{mode:h,threshold:b}=u,g={$size:{$ifNull:[`$${r}`,[]]}},y=cd(ao(n,{ruleProcessor:x=>({...x,field:x.field?`${r}.${x.field}`:r})}),{...t,ruleProcessor:dl,context:{...t.context,avoidFieldsAsKeys:!1}}),v=cd(ao(n,{ruleProcessor:x=>({...x,field:x.field?`$item.${x.field}`:"$item"})}),{...t,ruleProcessor:dl,context:{...t.context,avoidFieldsAsKeys:!0,inExpressionContext:!0}}),S={$size:{$ifNull:[{$filter:{input:`$${r}`,as:"item",cond:{$and:[v]}}},[]]}};switch(h){case"all":return{$expr:{$eq:[S,g]}};case"none":return{$nor:[y]};case"some":return y;case"atleast":case"atmost":case"exactly":{const x=h==="atleast"?Qo[">="]:h==="atmost"?Qo["<="]:Qo["="];return b>0&&b<1?{$expr:{[x]:[S,{$multiply:[g,b]}]}}:{$expr:{[x]:[S,b]}}}}}if(o==="="&&!d)return p?{$eq:[`$${r}`,so(n,n,s)]}:{[r]:so(n,n,s)};const f=Ge(o);switch(f){case"<":case"<=":case"=":case"!=":case">":case">=":{const h=Qo[f];return d?{[h]:[`$${r}`,`$${n}`]}:p?{$and:[{$ne:[`$${r}`,null]},{[h]:[`$${r}`,so(n,n,s)]}]}:{[r]:{[h]:so(n,n,s)}}}case"contains":return d?{$where:`this.${r}.includes(this.${n})`}:p?{$regexMatch:{input:`$${r}`,regex:n}}:{[r]:{$regex:n}};case"beginswith":return d?{$where:`this.${r}.startsWith(this.${n})`}:p?{$regexMatch:{input:`$${r}`,regex:`^${n}`}}:{[r]:{$regex:`^${n}`}};case"endswith":return d?{$where:`this.${r}.endsWith(this.${n})`}:p?{$regexMatch:{input:`$${r}`,regex:`${n}$`}}:{[r]:{$regex:`${n}$`}};case"doesnotcontain":return d?{$where:`!this.${r}.includes(this.${n})`}:p?{$not:{$regexMatch:{input:`$${r}`,regex:n}}}:{[r]:{$not:{$regex:n}}};case"doesnotbeginwith":return d?{$where:`!this.${r}.startsWith(this.${n})`}:p?{$not:{$regexMatch:{input:`$${r}`,regex:`^${n}`}}}:{[r]:{$not:{$regex:`^${n}`}}};case"doesnotendwith":return d?{$where:`!this.${r}.endsWith(this.${n})`}:p?{$not:{$regexMatch:{input:`$${r}`,regex:`${n}$`}}}:{[r]:{$not:{$regex:`${n}$`}}};case"null":return p?{$eq:[`$${r}`,null]}:{[r]:null};case"notnull":return p?{$ne:[`$${r}`,null]}:{[r]:{$ne:null}};case"in":case"notin":{const h=Ee(n);return d?{$where:`${f==="notin"?"!":""}[${h.map(b=>`this.${b}`).join(",")}].includes(this.${r})`}:p?f==="notin"?{$not:{[Qo.in]:[`$${r}`,h.map(b=>so(b,b,s))]}}:{[Qo[f]]:[`$${r}`,h.map(b=>so(b,b,s))]}:{[r]:{[Qo[f]]:h.map(b=>so(b,b,s))}}}case"between":case"notbetween":{const h=Ee(n);if(h.length>=2&&wt(h[0])&&wt(h[1])){const[b,g]=h,y=so(b,NaN,!0),v=so(g,NaN,!0);let S=d||Number.isNaN(y)?b:y,x=d||Number.isNaN(v)?g:v;if(!l&&S===y&&x===v&&v<y){const w=v;x=y,S=w}return f==="between"?d?{$gte:[`$${r}`,`$${S}`],$lte:[`$${r}`,`$${x}`]}:p?{$and:[{$gte:[`$${r}`,S]},{$lte:[`$${r}`,x]}]}:{[r]:{$gte:S,$lte:x}}:d?{$or:[{$lt:[`$${r}`,`$${S}`]},{$gt:[`$${r}`,`$${x}`]}]}:p?{$or:[{$lt:[`$${r}`,S]},{$gt:[`$${r}`,x]}]}:{$or:[{[r]:{$lt:S}},{[r]:{$gt:x}}]}}else return""}}return""},NA=(e,t)=>{const r=dl(e,t);return r?JSON.stringify(r):""},ob=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:a,placeholderOperatorName:s,placeholderValueName:l,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!ze(f,p[f.id??""]))return h?o:"";const b=[];let g="",y=!0;for(const w of f.rules){if(typeof w=="string"){g=w;continue}if(ke(w)){const D=u(w);D&&(!y&&g&&(b.push(g),g=""),y=!1,b.push(D));continue}const[N,k]=d(w);if(!ze(w,N,k)||w.field===a||w.operator===s||l!==void 0&&w.value===l)continue;const _=Xe(r,w.field),E=c(w,{...t,parseNumbers:n(_==null?void 0:_.inputType),escapeQuotes:(w.valueSource??"value")==="value",fieldData:_});E&&(!y&&g&&(b.push(g),g=""),y=!1,b.push(E))}const v=b.join(Bt(f)?` ${f.combinator} `:" "),[S,x]=f.not||!h?[`${f.not?"!":""}(`,")"]:["",""];return v?`${S}${v}${x}`:o};return u(e,!0)},ul=e=>e.startsWith("not")||e.startsWith("doesnot"),dd=(e,t)=>t?`!(${e})`:e,Ro=(e,t)=>typeof e!="string"||!t?`${e}`:e.replaceAll("'","\\'"),EA=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:a}=e,{escapeQuotes:s,parseNumbers:l,preserveValueOrder:c}=t,d=a==="field"||a==="parameter",p=Ge(o==="="?"==":o),u=typeof n=="number"||typeof n=="boolean"||typeof n=="bigint"||Ae(n,l),f=Rt(e);if(f===!1)return"";if(f){const{mode:h,threshold:b}=f,g=ob(ao(e.value,{ruleProcessor:S=>({...S,field:S.field||"#this"})}),t),y=`${r}.size()`,v=`${r}.?[${g}].size()`;switch(h){case"all":return`${v} == ${y}`;case"none":return`${v} == 0`;case"some":return`${v} >= 1`;case"atleast":case"atmost":case"exactly":{const S=h==="atleast"?">=":h==="atmost"?"<=":"==";return b>0&&b<1?`${v} ${S} (${y} * ${b})`:`${v} ${S} ${b}`}}}switch(p){case"<":case"<=":case"==":case"!=":case">":case">=":return`${r} ${p} ${d||u?Ke(n):`'${Ro(n,s)}'`}`;case"contains":case"doesnotcontain":{const h=d?`'.*'.concat(${Ke(n)}).concat('.*')`:`'.*${Ro(n,s)}.*'`;return dd(`${r} matches ${h}`,ul(p))}case"beginswith":case"doesnotbeginwith":{const h=d?`'^'.concat(${Ke(n)}).concat('.*')`:`'${typeof n=="string"&&!n.startsWith("^")||u?"^":""}${Ro(n,s)}.*'`;return dd(`${r} matches ${h}`,ul(p))}case"endswith":case"doesnotendwith":{const h=d?`'.*'.concat(${Ke(n)}).concat('$')`:`'.*${Ro(n,s)}${typeof n=="string"&&!n.endsWith("$")||u?"$":""}'`;return dd(`${r} matches ${h}`,ul(p))}case"null":return`${r} == null`;case"notnull":return`${r} != null`;case"in":case"notin":{const h=ul(p)?"!":"",b=Ee(n);return b.length>0?`${h}(${b.map(g=>`${r} == ${d||Ae(g,l)?`${Ke(g)}`:`'${Ro(g,s)}'`}`).join(" or ")})`:""}case"between":case"notbetween":{const h=Ee(n);if(h.length>=2&&!no(h[0])&&!no(h[1])){const[b,g]=h,y=l!==!1,v=Ae(b,y)?Le(b,{parseNumbers:y}):NaN,S=Ae(g,y)?Le(g,{parseNumbers:y}):NaN;let x=Number.isNaN(v)?d?`${b}`:`'${Ro(b,s)}'`:v,w=Number.isNaN(S)?d?`${g}`:`'${Ro(g,s)}'`:S;if(!c&&x===v&&w===S&&S<v){const N=S;w=v,x=N}return p==="between"?`(${r} >= ${x} and ${r} <= ${w})`:`(${r} < ${x} or ${r} > ${w})`}else return""}}return""},kA=(e,t,r)=>r&&typeof e=="string"?e.replaceAll(`${t}`,`${t}${t}`):e,ca=({operator:e,value:t,valueSource:r},{escapeQuotes:o,parseNumbers:n,preserveValueOrder:a,quoteFieldNamesWith:s,quoteValuesWith:l,concatOperator:c="||",fieldIdentifierSeparator:d,paramPrefix:p,wrapValueWith:u=["",""],translations:f}={})=>{if(r==="parameter"){const N=Ge(e);if(N==="between"||N==="notbetween"){const _=Ee(t,{retainEmptyStrings:!0});if(_.length<2||!wt(_[0])||!wt(_[1]))return"";const[E,D]=_;return[ia(E,p),ia(D,p)].join(` ${(f==null?void 0:f.betweenAnd)??(f==null?void 0:f.and)??"and"} `)}if(N==="in"||N==="notin"){const _=Ee(t);return _.length===0?"":`(${_.map(E=>ia(E,p)).join(", ")})`}const k=ia(t,p);switch(N){case"contains":case"doesnotcontain":case"beginswith":case"doesnotbeginwith":case"endswith":case"doesnotendwith":return la(k,N,{concatOperator:c,quoteValuesWith:l,wrapValueWith:u})}return k}const h=r==="field",b=Ge(e),g=l||"'",y=N=>`${u[0]}${g}${N}${g}${u[1]}`,v=N=>kA(N,g,o),S=N=>y(v(N)),x=N=>En(N,{quoteFieldNamesWith:s,fieldIdentifierSeparator:d}),w={concatOperator:c,quoteValuesWith:l,wrapValueWith:u};switch(b){case"null":case"notnull":return"";case"in":case"notin":{const N=Ee(t);return N.length>0?`(${N.map(k=>h?x(k):Ae(k,n)?`${Ke(k)}`:`${S(k)}`).join(", ")})`:""}case"between":case"notbetween":{const N=Ee(t,{retainEmptyStrings:!0});if(N.length<2||!wt(N[0])||!wt(N[1]))return"";const[k,_]=N,E=Ae(k,n)?Le(k,{parseNumbers:"strict"}):NaN,D=Ae(_,n)?Le(_,{parseNumbers:"strict"}):NaN,T=Number.isNaN(E)?h?`${k}`:k:E,O=Number.isNaN(D)?h?`${_}`:_:D,$=[T,O];return!a&&T===E&&O===D&&D<E&&($[0]=D,$[1]=E),(h?$.map(V=>x(V)):$.every(V=>Ae(V,n))?$.map(V=>Le(V,{parseNumbers:"strict"})):$.map(V=>S(V))).join(` ${(f==null?void 0:f.betweenAnd)??(f==null?void 0:f.and)??"and"} `)}case"contains":case"doesnotcontain":return h?la(x(t),b,w):y(`%${v(t)}%`);case"beginswith":case"doesnotbeginwith":return h?la(x(t),b,w):y(`${v(t)}%`);case"endswith":case"doesnotendwith":return h?la(x(t),b,w):y(`%${v(t)}`)}return typeof t=="boolean"?t?"TRUE":"FALSE":h?x(t):Ae(t,n)?`${Ke(t)}`:`${S(t)}`},nb={and:"AND",or:"OR"},AA=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:a,placeholderOperatorName:s,placeholderValueName:l,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!ze(f,p[f.id??""]))return h?o:"";const b=[];let g="",y=!0;for(const w of f.rules){if(typeof w=="string"){g=nb[w];continue}if(ke(w)){const D=u(w);D&&(!y&&g&&(b.push(g),g=""),y=!1,b.push(D));continue}const[N,k]=d(w);if(!ze(w,N,k)||w.field===a||w.operator===s||l!==void 0&&w.value===l)continue;const _=Xe(r,w.field),E=c(w,{...t,parseNumbers:n(_==null?void 0:_.inputType),escapeQuotes:(w.valueSource??"value")==="value",fieldData:_});E&&(!y&&g&&(b.push(g),g=""),y=!1,b.push(E))}const v=b.join(Bt(f)?` ${nb[f.combinator]} `:" "),[S,x]=f.not||!h?[`${f.not?"NOT ":""}(`,")"]:["",""];return v?`${S}${v}${x}`:o};return u(e,!0)},ab=(e,t,r)=>(o,n)=>{const{fields:a,getParseNumberBoolean:s,placeholderFieldName:l,placeholderOperatorName:c,placeholderValueName:d,validateRule:p,validationMap:u,ruleProcessor:f}=t;if(!o||!n)return;const{and:h,not:b,or:g}=n,y=(v,S)=>{if(!ze(v,u[v.id??""]))return;const x=v.rules.map(N=>{if(ke(N))return y(N);const[k,_]=p(N);if(!ze(N,k,_)||N.field===l||N.operator===c||d!==void 0&&N.value===d)return;const E=Xe(a,N.field);return f(N,{...t,parseNumbers:s(E==null?void 0:E.inputType),fieldData:E,context:{...t.context,columns:o,drizzleOperators:n}})}).filter(Boolean);if(x.length===0)return;const w=v.combinator==="or"?g(...x):h(...x);return v.not?b(w):w};return y(kr(e))},sb=(e,t)=>{const{fields:r,getParseNumberBoolean:o,placeholderFieldName:n,placeholderOperatorName:a,placeholderValueName:s,ruleProcessor:l,validateRule:c,validationMap:d}=t,p=f=>{if(!ze(f,d[f.id??""]))return!1;const h=f.rules.map(b=>{if(ke(b))return p(b);const[g,y]=c(b);if(!ze(b,g,y)||b.field===n||b.operator===a||s!==void 0&&b.value===s)return!1;const v=Xe(r,b.field);return l(b,{...t,parseNumbers:o(v==null?void 0:v.inputType),fieldData:v})}).filter(Boolean);return h.length===0?!1:{bool:f.not?{must_not:/^or$/i.test(f.combinator)?{bool:{should:h}}:h}:{[/^or$/i.test(f.combinator)?"should":"must"]:h}}},u=p(kr(e));return u===!1?{}:u},_A=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:a,placeholderOperatorName:s,placeholderValueName:l,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=b=>{// v8 ignore next -- @preserve
182
+ if(typeof b=="string"||ke(b))return;const[g,y]=d(b);if(!ze(b,g,y)||b.field===a||b.operator===s||l!==void 0&&b.value===l)return;const v=Xe(r,b.field);return c(b,{...t,parseNumbers:n(v==null?void 0:v.inputType),escapeQuotes:(b.valueSource??"value")==="value",fieldData:v})},f=b=>{if(!ze(b,p[b.id??""]))return"";const g=[];for(const S of b.rules){if(typeof S=="string")continue;if(ke(S)){const w=f(S);w&&g.push(w);continue}const x=u(S);x&&g.push(x)}if(g.length===0)return"";const y=b.combinator??"and",v=b.not?"not":y;return g.length===1&&!b.not?g[0]:`.${v}(${g.map(S=>S.startsWith(".")?`__${S}`:S).join(", ")})`};if(!ze(e,p[e.id??""]))return o;const h=[];for(const b of e.rules){if(typeof b=="string")continue;if(ke(b)){const y=f(b);y&&h.push(y);continue}const g=u(b);g&&h.push(g)}return h.length===0?o:h.join("")},lb=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:a,placeholderOperatorName:s,placeholderValueName:l,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!ze(f,p[f.id??""]))return h?o:"";const b=[];let g="",y=!0;for(const w of f.rules){if(typeof w=="string"){g=w;continue}if(ke(w)){const D=u(w);D&&(!y&&g&&(b.push(g),g=""),y=!1,b.push(D));continue}const[N,k]=d(w);if(!ze(w,N,k)||w.field===a||w.operator===s||l!==void 0&&w.value===l)continue;const _=Xe(r,w.field),E=c(w,{...t,parseNumbers:n(_==null?void 0:_.inputType),escapeQuotes:(w.valueSource??"value")==="value",fieldData:_});E&&(!y&&g&&(b.push(g),g=""),y=!1,b.push(E))}const v=b.join(Bt(f)?` ${f.combinator} `:" "),[S,x]=f.not||!h?[`${f.not?"$not":""}(`,")"]:["",""];return v?`${S}${v}${x}`:o};return u(e,!0)},ud=(e,t)=>{const{fields:r,getParseNumberBoolean:o,placeholderFieldName:n,placeholderOperatorName:a,placeholderValueName:s,ruleProcessor:l,validateRule:c,validationMap:d}=t,p=kr(e),u=(f,h)=>{if(!ze(f,d[f.id??""]))return!1;const b=f.rules.map(y=>{if(ke(y))return u(y);const[v,S]=c(y);if(!ze(y,v,S)||y.field===n||y.operator===a||s!==void 0&&y.value===s)return!1;const x=Xe(r,y.field);return l(y,{...t,parseNumbers:o(x==null?void 0:x.inputType),fieldData:x})}).filter(Boolean);if(b.length===0)return!1;const g={[f.combinator]:b};return f.not?{"!":g}:g};return u(p)},TA=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:a,placeholderOperatorName:s,placeholderValueName:l,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!ze(f,p[f.id??""]))return h?o:"";const b=f.rules.map(w=>{if(ke(w))return u(w);const[N,k]=d(w);if(!ze(w,N,k)||w.field===a||w.operator===s||l!==void 0&&w.value===l)return"";const _=Xe(r,w.field);return c(w,{...t,parseNumbers:n(_==null?void 0:_.inputType),escapeQuotes:(w.valueSource??"value")==="value",fieldData:_})}).filter(Boolean),g=b.join(""),[y,v]=f.not?["(!",")"]:["",""],[S,x]=b.length>1?[`${y}(${f.combinator==="or"?"|":"&"}`,`)${v}`]:[y,v];return g?`${S}${g}${x}`:o};return u(kr(e),!0)},fd=e=>e.startsWith("{")&&e.endsWith("}"),DA=(e,t,r)=>{const{fields:o,fallbackExpression:n,getParseNumberBoolean:a,placeholderFieldName:s,placeholderOperatorName:l,placeholderValueName:c,ruleProcessor:d,validateRule:p,validationMap:u}=t,f=(b,g)=>{if(!ze(b,u[b.id??""]))return g?n:"";const y=`"$${Ge(b.combinator)}"`;let v=!1;const S=b.rules.map(w=>{if(ke(w)){const E=f(w);return E?(v=!0,fd(E)?E:`{${E}}`):""}const[N,k]=p(w);if(!ze(w,N,k)||w.field===s||w.operator===l||c!==void 0&&w.value===c)return"";const _=Xe(o,w.field);return d(w,{...t,parseNumbers:a(_==null?void 0:_.inputType),fieldData:_},r)}).filter(Boolean),x=S.length>0?S.length===1&&!v?S[0]:`${y}:[${S.join(",")}]`:n;return b.not?`"$nor":[${fd(x)?x:`{${x}}`}]`:x},h=f(kr(e),!0);return fd(h)?h:`{${h}}`},ib=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:a,placeholderOperatorName:s,placeholderValueName:l,ruleProcessor:c,translations:d,validateRule:p,validationMap:u}=t,f=(h,b)=>{if(!ze(h,u[h.id??""]))return b?o:"";const g=Cn(h)&&h.rules.some(O=>typeof O=="string"&&Ge(O)==="xor")?kr(h):h,y=[];let v="",S=!0;for(const O of g.rules){if(typeof O=="string"){v=`${d.ruleSeparator??", "}${d[O]??O} `;continue}if(ke(O)){const Y=f(O,g.rules.length===1&&!(g.not||/^xor$/i.test(g.combinator??"")));Y&&(!S&&v&&(y.push(v),v=""),S=!1,y.push(Y));continue}const[$,V]=p(O);if(!ze(O,$,V)||O.field===a||O.operator===s||l!==void 0&&O.value===l)continue;const G=(O.valueSource??"value")==="value",q=Xe(r,O.field),H=c(O,{...t,parseNumbers:n(q==null?void 0:q.inputType),escapeQuotes:G,fieldData:q});H&&(!S&&v&&(y.push(v),v=""),S=!1,y.push(H))}if(y.length===0)return o;const x=Ge(g.combinator??"")==="xor",w=x?g.combinator.slice(1):g.combinator,N=g.not||!b||x&&y.length>1,[k,_]=["groupPrefix","groupSuffix"].map(O=>g.not?x?ll(O,d,["not","xor"]):ll(O,d,["not"]):x?ll(O,d,["xor"]):ll(O,d)),E=N?`${k} (`.trim():"",D=N?`) ${_}`.trim():"",T=d.ruleSeparator??", ";return`${E}${y.join(Bt(g)?`${T}${d[w]??w} `:"")}${D}`};return f(e,!0)},cb=(e,t)=>{const{format:r,fields:o,fallbackExpression:n,getParseNumberBoolean:a,placeholderFieldName:s,placeholderOperatorName:l,placeholderValueName:c,ruleProcessor:d,validateRule:p,validationMap:u}=t,f=r==="parameterized",h=[],b={},g=new Map,y=x=>{g.has(x)||g.set(x,new Set);const w=`${x}_${g.get(x).size+1}`;return g.get(x).add(w),w},v=x=>{var O;const[w,N]=p(x);if(!ze(x,w,N)||x.field===s||x.operator===l||c!==void 0&&x.value===c)return"";const k=Xe(o,x.field),_=Object.fromEntries([...g.entries()].map(([$,V])=>[$,[...V]])),E=d(x,{...t,parseNumbers:a(k==null?void 0:k.inputType),getNextNamedParam:y,fieldParamNames:_,fieldData:k},{processedParams:h});if(!Er(E))return"";const{sql:D,params:T}=E;if(typeof D!="string"||!D)return"";if(r==="parameterized"&&Array.isArray(T))h.push(...T);else if(r==="parameterized_named"&&Er(T)){Object.assign(b,T);for(const $ of Object.keys(T))(O=g.get(x.field))==null||O.add($)}return D},S=(x,w)=>{if(!ze(x,u[x.id??""]))return w?n:"";const N=[];let k="",_=!0;for(const E of x.rules){if(typeof E=="string"){k=E;continue}if(ke(E)){const T=S(E,x.rules.length===1);T&&(!_&&k&&(N.push(k),k=""),_=!1,N.push(T));continue}const D=v(E);D&&(!_&&k&&(N.push(k),k=""),_=!1,N.push(D))}return N.length===0?n:`${x.not?"NOT ":""}(${N.join(Bt(x)?` ${x.combinator} `:" ")})`};return f?{sql:S(e,!0),params:h}:{sql:S(e,!0),params:b}},pd={},$A=(e,t)=>{const{fields:r,getParseNumberBoolean:o,placeholderFieldName:n,placeholderOperatorName:a,placeholderValueName:s,ruleProcessor:l,validateRule:c,validationMap:d}=t,p=(f,h)=>{if(!ze(f,d[f.id??""]))return h?pd:void 0;const b=f.combinator.toUpperCase();let g=!1;const y=f.rules.map(v=>{if(ke(v)){const N=p(v);return N?(g=!0,N):void 0}const[S,x]=c(v);if(!ze(v,S,x)||v.field===n||v.operator===a||s!==void 0&&v.value===s)return;const w=Xe(r,v.field);return l(v,{...t,parseNumbers:o(w==null?void 0:w.inputType),fieldData:w})}).filter(Boolean);return y.length>0?y.length===1&&!g?y[0]:{[b]:y}:pd},u=p(kr(e),!0);return e.not?{NOT:u}:u},PA=(e,t)=>{const{fields:r,getParseNumberBoolean:o,placeholderFieldName:n,placeholderOperatorName:a,placeholderValueName:s,ruleProcessor:l,validateRule:c,validationMap:d,context:p={}}=t,{sequelizeOperators:u}=p;if(!u)return;const f=(h,b)=>{if(!ze(h,d[h.id??""]))return;const g=h.combinator.toUpperCase();let y=!1;const v=h.rules.map(x=>{if(ke(x)){const _=f(x);return _?(y=!0,_):void 0}const[w,N]=c(x);if(!ze(x,w,N)||x.field===n||x.operator===a||s!==void 0&&x.value===s)return;const k=Xe(r,x.field);return l(x,{...t,parseNumbers:o(k==null?void 0:k.inputType),fieldData:k})}).filter(Boolean);if(v.length===0)return;const S=v.length===1&&!y?v[0]:{[Ge(g)==="or"?u.or:u.and]:v};return h.not?{[u.not]:S}:S};return f(kr(e))},MA=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:a,placeholderOperatorName:s,placeholderValueName:l,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!ze(f,p[f.id??""]))return h?o:"";const b=[];let g="",y=!0;for(const w of f.rules){if(typeof w=="string"){g=sl[w];continue}if(ke(w)){const D=u(w);D&&(!y&&g&&(b.push(g),g=""),y=!1,b.push(D));continue}const[N,k]=d(w);if(!ze(w,N,k)||w.field===a||w.operator===s||l!==void 0&&w.value===l)continue;const _=Xe(r,w.field),E=c(w,{...t,parseNumbers:n(_==null?void 0:_.inputType),escapeQuotes:(w.valueSource??"value")==="value",fieldData:_});E&&(!y&&g&&(b.push(g),g=""),y=!1,b.push(E))}const v=b.join(Bt(f)?` ${sl[f.combinator]} `:" "),[S,x]=f.not||!h?[`${f.not?"!":""}(`,")"]:["",""];return v?`${S}${v}${x}`:o};return u(e,!0)},db=(e,t)=>{const{fields:r,fallbackExpression:o,getParseNumberBoolean:n,placeholderFieldName:a,placeholderOperatorName:s,placeholderValueName:l,ruleProcessor:c,validateRule:d,validationMap:p}=t,u=(f,h)=>{if(!ze(f,p[f.id??""]))return h?o:"";const b=[];let g="",y=!0;for(const v of f.rules){if(typeof v=="string"){g=v;continue}if(ke(v)){const _=u(v,f.rules.length===1);_&&(!y&&g&&(b.push(g),g=""),y=!1,b.push(_));continue}const[S,x]=d(v);if(!ze(v,S,x)||v.field===a||v.operator===s||l!==void 0&&v.value===l)continue;const w=(v.valueSource??"value")==="value",N=Xe(r,v.field),k=c(v,{...t,parseNumbers:n(N==null?void 0:N.inputType),escapeQuotes:w,fieldData:N});k&&(!y&&g&&(b.push(g),g=""),y=!1,b.push(k))}return b.length===0?o:`${f.not?"NOT ":""}(${b.join(Bt(f)?` ${f.combinator} `:" ")})`};return u(e,!0)},OA=(e,t)=>r=>{const{fields:o,getParseNumberBoolean:n,placeholderFieldName:a,placeholderOperatorName:s,placeholderValueName:l,validateRule:c,validationMap:d,context:p={},ruleProcessor:u}=t,f=p.tanStackDbOperators;if(!f)return;const{and:h,eq:b,not:g,or:y}=f,v=b(1,1),S=Object.keys(r);/* v8 ignore next -- @preserve */if(S.length===0)return v;const x=w=>{if(!ze(w,d[w.id??""]))return;const N=w.rules.map(_=>{if(ke(_))return x(_);const[E,D]=c(_);if(!ze(_,E,D)||_.field===a||_.operator===s||l!==void 0&&_.value===l)return;const T=Xe(o,_.field);return u(_,{...t,parseNumbers:n(T==null?void 0:T.inputType),fieldData:T,context:{...p,_tanstackDbRefs:r,_tanstackDbPrimaryRef:S[0]}})}).filter(Boolean);if(N.length===0)return v;const k=N.length===1?N[0]:w.combinator==="or"?y(...N):h(...N);return w.not?g(k):k};return x(kr(e))??v},IA=new Set(["number","range","bigint"]),ub=/^\d{4}-\d{2}-\d{2}$/,fb=/^\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/,LA=/^\d{4}-\d{2}$/,FA=/^\d{4}-W\d{2}$/,VA=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,GA=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,pb=(e,t,r)=>{const o=new Date(Date.UTC(e,t-1,r));return o.getUTCFullYear()===e&&o.getUTCMonth()===t-1&&o.getUTCDate()===r},hb=e=>{const t=e.split(":"),r=Number(t[0]),o=Number(t[1]),n=t[2]?Number.parseFloat(t[2]):0;return r>=0&&r<=23&&o>=0&&o<=59&&n>=0&&n<60},zA=(e,t)=>{if(!(e==null||e==="")){if(IA.has(t)){const r=typeof e=="string"?e.trim():e;return typeof r=="number"||typeof r=="bigint"||typeof r=="string"&&zm.test(r)?void 0:"VALUE_TYPE_MISMATCH"}if(t==="date"){if(typeof e!="string")return"VALUE_TYPE_MISMATCH";const r=e.trim();if(!ub.test(r))return"VALUE_TYPE_MISMATCH";const[o,n,a]=r.split("-").map(Number);return pb(o,n,a)?void 0:"VALUE_TYPE_MISMATCH"}if(t==="datetime-local"){if(typeof e!="string")return"VALUE_TYPE_MISMATCH";const r=e.trim().replace(/(Z|[+-]\d{2}:?\d{2}|[+-]\d{2})$/,""),o=r.indexOf("T");if(o===-1)return"VALUE_TYPE_MISMATCH";const n=r.slice(0,o),a=r.slice(o+1);if(!ub.test(n)||!fb.test(a))return"VALUE_TYPE_MISMATCH";const[s,l,c]=n.split("-").map(Number);return pb(s,l,c)&&hb(a)?void 0:"VALUE_TYPE_MISMATCH"}if(t==="time"){if(typeof e!="string")return"VALUE_TYPE_MISMATCH";const r=e.trim();return fb.test(r)&&hb(r)?void 0:"VALUE_TYPE_MISMATCH"}if(t==="month"){if(typeof e!="string")return"VALUE_TYPE_MISMATCH";const r=e.trim();if(!LA.test(r))return"VALUE_TYPE_MISMATCH";const o=Number(r.slice(5));return o>=1&&o<=12?void 0:"VALUE_TYPE_MISMATCH"}if(t==="week"){if(typeof e!="string")return"VALUE_TYPE_MISMATCH";const r=e.trim();if(!FA.test(r))return"VALUE_TYPE_MISMATCH";const o=Number(r.slice(6));return o>=1&&o<=53?void 0:"VALUE_TYPE_MISMATCH"}if(t==="color")return typeof e!="string"?"VALUE_TYPE_MISMATCH":VA.test(e.trim())?void 0:"VALUE_TYPE_MISMATCH";if(t==="url"){if(typeof e!="string")return"VALUE_TYPE_MISMATCH";try{new URL(e.trim());return}catch{return"VALUE_TYPE_MISMATCH"}}if(t==="email")return typeof e!="string"?"VALUE_TYPE_MISMATCH":GA.test(e.trim())?void 0:"VALUE_TYPE_MISMATCH"}},BA=(e,t)=>{const{fields:r,placeholderFieldName:o,placeholderOperatorName:n,placeholderValueName:a,validateRule:s,validationMap:l}=t,c=[],d={totalRules:0,totalGroups:0,validRules:0,invalidRules:0,validGroups:0,invalidGroups:0},p={},u=nd(r),f=new Map;for(const y of u)f.set(y.name,y);const h=f.size>0,b=(y,v)=>{d.totalGroups++;const S=v.length,x=l[y.id??""],w=ze(y,x),N=mb(x);y.muted?c.push({id:y.id??"",path:v,code:"MUTED",message:"Group is muted",source:"muted"}):!w&&x!==void 0&&c.push({id:y.id??"",path:v,code:"CUSTOM_VALIDATOR",message:N?`Invalid: ${N.join(", ")}`:"Group failed validation",source:"query-validator"});let k=!0,_=0;const E=[];for(const T of y.rules){if(typeof T=="string"){E.push(T),_++;continue}const O=[...v,_];if(ke(T)){const W=b(T,O);W.valid||(k=!1),E.push(W),_++;continue}d.totalRules++;const $=O.length,[V,G]=s(T),q=ze(T,V,G)&&T.field!==o&&T.operator!==n&&!(a!==void 0&&T.value===a);UA(T,O,V,G,q,c,o,n,a,h,f),q?d.validRules++:(k=!1,d.invalidRules++);const H=T.field;p[H]||(p[H]={ruleCount:0,invalidCount:0}),p[H].ruleCount++,q||p[H].invalidCount++;const Y=mb(V)??WA(T,G),J={...T,valid:q,...Y?{reasons:Y}:null,path:O,level:$};E.push(J),_++}const D=w&&k;return D?d.validGroups++:d.invalidGroups++,Bt(y)?{...y,valid:D,...N?{reasons:N}:null,path:v,level:S,rules:E}:{...y,valid:D,...N?{reasons:N}:null,path:v,level:S,rules:E}},g=b(e,[]);if(h){const y=new Set(Object.keys(p));for(const[v]of f)y.has(v)||c.push({id:"",path:[],code:"UNREFERENCED_FIELD",message:`Field "${v}" is defined in the fields config but not used in the query`,source:"field-check"})}return{query:g,diagnostics:c,stats:d,fieldSummary:p}},UA=(e,t,r,o,n,a,s,l,c,d,p)=>{const u=e.id??"";if(e.muted&&a.push({id:u,path:t,code:"MUTED",message:"Rule is muted",source:"muted"}),e.field===s&&a.push({id:u,path:t,code:"PLACEHOLDER_FIELD",message:"Rule has a placeholder field",source:"placeholder"}),e.operator===l&&a.push({id:u,path:t,code:"PLACEHOLDER_OPERATOR",message:"Rule has a placeholder operator",source:"placeholder"}),c!==void 0&&e.value===c&&a.push({id:u,path:t,code:"PLACEHOLDER_VALUE",message:"Rule has a placeholder value",source:"placeholder"}),!e.muted&&e.field!==s&&e.operator!==l&&!(c!==void 0&&e.value===c)){if(typeof r=="boolean"&&!r)a.push({id:u,path:t,code:"CUSTOM_VALIDATOR",message:"Rule failed validation",source:"query-validator"});else if(typeof r!="boolean"&&Nn(r)&&!r.valid){const f=r.reasons;a.push({id:u,path:t,code:"CUSTOM_VALIDATOR",message:f?`Invalid: ${f.join(", ")}`:"Rule failed validation",source:"query-validator"})}else if(!n&&typeof o=="function"){const f=o(e),h=typeof f!="boolean"&&Nn(f)&&!f.valid?f.reasons:void 0;a.push({id:u,path:t,code:"CUSTOM_VALIDATOR",message:h?`Invalid: ${h.join(", ")}`:"Rule failed field validation",source:"field-validator"})}}if(d&&!p.has(e.field)&&e.field!==s&&a.push({id:u,path:t,code:"UNDEFINED_FIELD",message:`Field "${e.field}" is not defined in the fields config`,source:"field-check"}),d){const f=p.get(e.field);if(f!=null&&f.inputType){const h=zA(e.value,f.inputType);h&&a.push({id:u,path:t,code:h,message:`Value "${e.value}" is not compatible with input type "${f.inputType}"`,source:"type-check"})}}},mb=e=>{if(typeof e!="boolean"&&Nn(e)&&!e.valid&&e.reasons)return e.reasons},WA=(e,t)=>{if(typeof t=="function"){const r=t(e);if(typeof r!="boolean"&&Nn(r)&&!r.valid&&r.reasons)return r.reasons}},HA=(e,t)=>typeof e!="string"||!t?`${e}`:e.replaceAll("'","\\'"),bb=(e,t={})=>{const{escapeQuotes:r,parseNumbers:o}=t,{field:n,operator:a,value:s,valueSource:l}=e,c=l==="field",d=a.toLowerCase(),p=u=>u==null?"null":typeof u=="boolean"||typeof u=="bigint"?String(u):c||typeof u=="number"||Ae(u,o)?Ke(u):`'${HA(u,r)}'`;switch(d){case"=":return`${n} = ${p(s)}`;case"!=":case"<>":return`${n} <> ${p(s)}`;case"<":case">":case"<=":case">=":return`${n} ${d} ${p(s)}`;case"contains":return`${n} CONTAINS ${p(s)}`;case"doesnotcontain":return`NOT ${n} CONTAINS ${p(s)}`;case"beginswith":return`${n} STARTS WITH ${p(s)}`;case"doesnotbeginwith":return`NOT ${n} STARTS WITH ${p(s)}`;case"endswith":return`${n} ENDS WITH ${p(s)}`;case"doesnotendwith":return`NOT ${n} ENDS WITH ${p(s)}`;case"null":return`${n} IS NULL`;case"notnull":return`${n} IS NOT NULL`;case"in":case"notin":{const u=Ee(s).map(p);return u.length?`${d==="notin"?"NOT ":""}${n} IN [${u.join(", ")}]`:""}case"between":case"notbetween":{const u=Ee(s);if(u.length<2)return"";const[f,h]=[p(u[0]),p(u[1])],b=`${f} <= ${n} AND ${n} <= ${h}`;return d==="notbetween"?`NOT (${b})`:b}default:return`${n} ${a} ${p(s)}`}},jA=(e,t)=>{const r=t??{},{parseNumbers:o,preserveValueOrder:n,context:a={}}=r,{columns:s,drizzleOperators:l,useRawFields:c}=a;if(!s||!l)return;const{between:d,eq:p,gt:u,gte:f,inArray:h,isNotNull:b,isNull:g,like:y,lt:v,lte:S,ne:x,notBetween:w,notInArray:N,notLike:k,sql:_}=l,{field:E,operator:D,value:T,valueSource:O}=e,$=c&&/^[a-z_][a-z0-9_.]*$/i.test(E)?_.raw(E):s[E],V=Ge(D),G=O==="field",q=J=>G?s[J]:J,H=J=>G||!o?q(J):Ae(J,!0)?Le(J,{parseNumbers:!0}):J;if(!$)return;const Y=Rt(e);if(Y!==!1){if(Y){if(r.preset!=="postgresql")return;const{mode:J,threshold:W}=Y,R=r.subqueryDepth??0,we=il(R),Q=ab(ao(e.value,{ruleProcessor:te=>({...te,field:we})}),{...r,context:{...r.context,useRawFields:!0},subqueryDepth:R+1});switch(J){case"all":return _`(select count(*) from unnest(${$}) as ${_.raw(we)} where ${Q({},l)}) = array_length(${$}, 1)`;case"none":return _`not exists (select 1 from unnest(${$}) as ${_.raw(we)} where ${Q({},l)})`;case"some":return _`exists (select 1 from unnest(${$}) as ${_.raw(we)} where ${Q({},l)})`;case"atleast":case"atmost":case"exactly":{const te=J==="atleast"?">=":J==="atmost"?"<=":"=";return W>0&&W<1?_`(select count(*)::float / array_length(${$}, 1) from unnest(${$}) as ${_.raw(we)} where ${Q({},l)}) ${_.raw(`${te} ${W}`)}`:_`(select count(*) from unnest(${$}) as ${_.raw(we)} where ${Q({},l)}) ${_.raw(`${te} ${W}`)}`}}}switch(V){case"=":return p($,H(T));case"!=":return x($,H(T));case">":return u($,H(T));case"<":return v($,H(T));case">=":return f($,H(T));case"<=":return S($,H(T));case"beginswith":case"doesnotbeginwith":return(V==="doesnotbeginwith"?k:y)($,G?_`${q(T)} || '%'`:`${T}%`);case"contains":case"doesnotcontain":return(V==="doesnotcontain"?k:y)($,G?_`'%' || ${q(T)} || '%'`:`%${T}%`);case"endswith":case"doesnotendwith":return(V==="doesnotendwith"?k:y)($,G?_`'%' || ${q(T)}`:`%${T}`);case"null":return g($);case"notnull":return b($);case"in":case"notin":{const J=Ee(T).map(W=>H(W));return V==="notin"?N($,J):h($,J)}case"between":case"notbetween":{const J=Ee(T);if(J.length>=2&&wt(J[0])&&wt(J[1])){let[W,R]=J;const we=o!==!1;if(!G&&Ae(W,we)&&Ae(R,we)){const Q=Le(W,{parseNumbers:we}),te=Le(R,{parseNumbers:we});if(!n&&te<Q){const De=te;R=Q,W=De}else W=Q,R=te}else G&&(W=q(W),R=q(R));return V==="notbetween"?w($,W,R):d($,W,R)}return}default:return}}},qA={"<":"lt","<=":"lte",">":"gt",">=":"gte"},fl=(e,t)=>e.startsWith("not")||e.startsWith("doesnot")?{bool:{must_not:t}}:t,hd=e=>e==null?void 0:e.replace(/('|\\)/g,"\\$1"),YA={beginswith:"startsWith",doesnotbeginwith:"startsWith",doesnotcontain:"contains",doesnotendwith:"endsWith",endswith:"endsWith"},QA=(e,t,r)=>{const o=`doc['${e}'].value.${YA[t]??t}(doc['${r}'].value)`;return t.startsWith("d")?`!${o}`:o},da=(e,t)=>typeof e=="boolean"?e:Ae(e,t)?Le(e,{parseNumbers:t}):e,KA=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:a}=e,{parseNumbers:s,preserveValueOrder:l}=t,c=Ge(o),d=Rt(e);if(d===!1)return!1;if(d){const{mode:p}=d,u=sb(ao(e.value,{ruleProcessor:f=>({...f,field:f.field?`${r}.${f.field}`:r})}),t);if(Object.keys(u).length===0)return!1;switch(p){case"some":return{nested:{path:r,query:u}};case"none":return{bool:{must_not:{nested:{path:r,query:u}}}};case"all":case"atleast":case"atmost":case"exactly":return!1}}if(a==="field"){if(Ee(n).some(u=>typeof u!="string"))return!1;const p=hd(r);switch(c){case"=":case"!=":case">":case">=":case"<":case"<=":{const u=c==="="?"==":c,f=hd(n);return f?{bool:{filter:{script:{script:`doc['${p}'].value ${u} doc['${f}'].value`}}}}:!1}case"in":case"notin":{const u=Ee(n);if(u.length>0){const f=u.map(h=>({bool:{filter:{script:{script:`doc['${p}'].value == doc['${h}'].value`}}}}));return{bool:c==="in"?{should:f}:{must_not:f}}}return!1}case"between":case"notbetween":{const u=Ee(n);if(u.length>=2&&u[0]&&u[1]){const f=`doc['${p}'].value >= doc['${u[0]}'].value && doc['${p}'].value <= doc['${u[1]}'].value`;return{bool:{filter:{script:{script:c==="notbetween"?`!(${f})`:f}}}}}return!1}case"contains":case"doesnotcontain":case"beginswith":case"doesnotbeginwith":case"endswith":case"doesnotendwith":{const u=hd(n);return u?{bool:{filter:{script:{script:QA(p,c,u)}}}}:!1}}}switch(c){case"<":case"<=":case">":case">=":return{range:{[r]:{[qA[c]]:da(n,s)}}};case"=":return{term:{[r]:da(n,s)}};case"!=":return{bool:{must_not:{term:{[r]:da(n,s)}}}};case"null":return{bool:{must_not:{exists:{field:r}}}};case"notnull":return{exists:{field:r}};case"in":case"notin":{const p=Ee(n).map(u=>da(u,s));if(p.length>0){const u=p.map(f=>({term:{[r]:da(f,s)}}));return{bool:c==="in"?{should:u}:{must_not:u}}}return!1}case"between":case"notbetween":{const p=Ee(n);if(p.length>=2&&wt(p[0])&&wt(p[1])){let[u,f]=p;const h=s!==!1;if(Ae(u,h)&&Ae(f,h)){const b=Le(u,{parseNumbers:h}),g=Le(f,{parseNumbers:h});if(!l&&g<b){const y=g;f=b,u=y}else u=b,f=g}return fl(c,{range:{[r]:{gte:u,lte:f}}})}return!1}case"contains":case"doesnotcontain":return fl(c,{regexp:{[r]:{value:`.*${n}.*`}}});case"beginswith":case"doesnotbeginwith":return fl(c,{regexp:{[r]:{value:`${n}.*`}}});case"endswith":case"doesnotendwith":return fl(c,{regexp:{[r]:{value:`.*${n}`}}})}return!1},RA=(e,t)=>typeof e!="string"||!t?`${e}`:e.replaceAll("'","\\'"),XA=(e,t={})=>{const{escapeQuotes:r,parseNumbers:o}=t,{field:n,operator:a,value:s,valueSource:l}=e,c=l==="field",d=a.toLowerCase(),p=n.includes(".")?n.split(".").pop():n,u=f=>f==null?"null":typeof f=="boolean"||typeof f=="bigint"?String(f):c||typeof f=="number"||Ae(f,o)?Ke(f):`'${RA(f,r)}'`;switch(d){case"=":return`.has('${p}', ${u(s)})`;case"!=":case"<>":return`.has('${p}', neq(${u(s)}))`;case"<":return`.has('${p}', lt(${u(s)}))`;case">":return`.has('${p}', gt(${u(s)}))`;case"<=":return`.has('${p}', lte(${u(s)}))`;case">=":return`.has('${p}', gte(${u(s)}))`;case"contains":return`.has('${p}', containing(${u(s)}))`;case"doesnotcontain":return`.has('${p}', notContaining(${u(s)}))`;case"beginswith":return`.has('${p}', startingWith(${u(s)}))`;case"doesnotbeginwith":return`.has('${p}', notStartingWith(${u(s)}))`;case"endswith":return`.has('${p}', endingWith(${u(s)}))`;case"doesnotendwith":return`.has('${p}', notEndingWith(${u(s)}))`;case"null":return`.hasNot('${p}')`;case"notnull":return`.has('${p}')`;case"in":{const f=Ee(s).map(u);return f.length?`.has('${p}', within(${f.join(", ")}))`:""}case"notin":{const f=Ee(s).map(u);return f.length?`.has('${p}', without(${f.join(", ")}))`:""}case"between":{const f=Ee(s);return f.length<2?"":`.has('${p}', between(${u(f[0])}, ${u(f[1])}))`}case"notbetween":{const f=Ee(s);return f.length<2?"":`.has('${p}', outside(${u(f[0])}, ${u(f[1])}))`}default:return`.has('${p}', ${u(s)})`}},pl=e=>e.startsWith("not")||e.startsWith("doesnot"),hl=(e,t)=>`"${typeof e!="string"||!t?`${e}`:e.replaceAll('"','\\"')}"`,ua=(e,t)=>t?`$not(${e})`:e,gb=e=>`${e}`.replaceAll(/[/$()*+.?[\\\]^{|}]/g,String.raw`\$&`).replaceAll("-",String.raw`\x2d`),JA=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:a}=e,{escapeQuotes:s,parseNumbers:l,preserveValueOrder:c,quoteFieldNamesWith:d=["",""],fieldIdentifierSeparator:p=""}=t,u=a==="field",f=typeof n=="number"||typeof n=="boolean"||typeof n=="bigint"||Ae(n,l),h=y=>En(y,{quoteFieldNamesWith:d,fieldIdentifierSeparator:p}),b=Rt(e);if(b===!1)return;if(b){const{mode:y,threshold:v}=b,S=`$count(${h(r)})`,x=`$count($filter(${h(r)}, function($v) {${lb(ao(n,{ruleProcessor:w=>({...w,field:w.field?`$v.${w.field}`:"$v"})}),t)}}))`;switch(y){case"all":return`${x} = ${S}`;case"none":return`${x} = 0`;case"some":return`${x} > 0`;case"atleast":case"atmost":case"exactly":{const w=y==="atleast"?">=":y==="atmost"?"<=":"=";return v>0&&v<1?`${x} ${w} (${S} * ${v})`:`${x} ${w} ${v}`}}}const g=Ge(o);switch(g){case"<":case"<=":case"=":case"!=":case">":case">=":return`${h(r)} ${g} ${u?h(Ke(n)):f?Ke(n):hl(n,s)}`;case"contains":case"doesnotcontain":return ua(`$contains(${h(r)}, ${u?h(Ke(n)):hl(n,s)})`,pl(g));case"beginswith":case"doesnotbeginwith":return ua(u?`$substring(${h(r)}, 0, $length(${h(Ke(n))})) = ${h(Ke(n))}`:`$contains(${h(r)}, /^${gb(n)}/)`,pl(g));case"endswith":case"doesnotendwith":return ua(u?`$substring(${h(r)}, $length(${h(r)}) - $length(${h(Ke(n))})) = ${h(Ke(n))}`:`$contains(${h(r)}, /${gb(n)}$/)`,pl(g));case"null":return`${h(r)} = null`;case"notnull":return`${h(r)} != null`;case"in":case"notin":{const y=Ee(n);return ua(`${h(r)} in [${y.map(v=>u?`${h(Ke(v))}`:Ae(v,l)?`${Ke(v)}`:hl(v,s)).join(", ")}]`,pl(g))}case"between":case"notbetween":{const y=Ee(n);if(y.length<2||no(y[0])||no(y[1]))return"";const[v,S]=y,x=l!==!1,w=Ae(v,x)?Le(v,{parseNumbers:x}):NaN,N=Ae(S,x)?Le(S,{parseNumbers:x}):NaN;let k=Number.isNaN(w)?u?`${v}`:v:w,_=Number.isNaN(N)?u?`${S}`:S:N;if(!c&&k===w&&_===N&&N<w){const O=N;_=w,k=O}const E=Ae(v,l)&&Ae(S,l),D=(O,$)=>u?h(O):E?$:hl($,s),T=`${h(r)} >= ${D(v,k)} and ${h(r)} <= ${D(S,_)}`;return g==="between"?`(${T})`:ua(T,!0)}}return""},ZA=e=>e.replace(/^(=)$/,"$1=").replace(/^notnull$/i,"!=").replace(/^null$/i,"=="),fa=(e,t)=>e.startsWith("not")||e.startsWith("doesnot")?{"!":t}:t,md=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:a}=e,{parseNumbers:s,preserveValueOrder:l}=t,c=a==="field",d={var:r},p=h=>c?{var:`${h}`}:Ae(h,s)?Le(h,{parseNumbers:s}):h,u=Rt(e);if(u===!1)return!1;if(u){const{mode:h,threshold:b}=u;switch(h){case"all":case"none":case"some":return{[h]:[{var:r},n.rules.length===1&&!ke(n.rules[0])?md(n.rules[0],t):ud(n,t)]};case"atleast":case"atmost":case"exactly":{const g=h==="atleast"?">=":h==="atmost"?"<=":"==",y={reduce:[{filter:[{var:r},n.rules.length===1&&!ke(n.rules[0])?md(n.rules[0],t):ud(n,t)]},{"+":[1,{var:"accumulator"}]},0]};if(b>0&&b<1){const v={reduce:[{var:r},{"+":[1,{var:"accumulator"}]},0]};return{[g]:[y,{"*":[v,b]}]}}return{[g]:[y,b]}}}}const f=Ge(o);switch(f){case"<":case"<=":case"=":case"!=":case">":case">=":return{[ZA(f)]:[d,p(n)]};case"null":case"notnull":return{[`${f==="notnull"?"!":"="}=`]:[d,null]};case"in":case"notin":{const h=Ee(n).map(b=>p(b));return fa(f,{in:[d,h]})}case"between":case"notbetween":{const h=Ee(n);if(h.length>=2&&wt(h[0])&&wt(h[1])){let[b,g]=h;const y=s!==!1;if(!c&&Ae(b,y)&&Ae(g,y)){const v=Le(b,{parseNumbers:y}),S=Le(g,{parseNumbers:y});if(!l&&S<v){const x=S;g=v,b=x}else b=v,g=S}else c&&(b={var:b},g={var:g});return fa(f,{"<=":[b,d,g]})}return!1}case"contains":case"doesnotcontain":{const h={in:[p(n),d]};return fa(f,h)}case"beginswith":case"doesnotbeginwith":{const h={startsWith:[d,p(n)]};return fa(f,h)}case"endswith":case"doesnotendwith":{const h={endsWith:[d,p(n)]};return fa(f,h)}}return!1},Xo=(e,t)=>t?`(!${e})`:`${e}`,lo=e=>`${Ke(e)}`.replaceAll(/[()&|=<>~*\\/]/g,t=>`\\${t.codePointAt(0).toString(16)}`),e_=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:a}=e,{preserveValueOrder:s}=t,l=Ge(o);if(a==="field"||no(n)&&l!=="null"&&l!=="notnull"||Rt(e))return"";switch(l){case"=":case"!=":return Xo(`(${r}=${lo(n)})`,l==="!=");case">":case">=":return`(${r}>=${lo(n)})`;case"<":case"<=":return`(${r}<=${lo(n)})`;case"contains":case"doesnotcontain":return Xo(`(${r}=*${lo(n)}*)`,l==="doesnotcontain");case"beginswith":case"doesnotbeginwith":return Xo(`(${r}=${lo(n)}*)`,l==="doesnotbeginwith");case"endswith":case"doesnotendwith":return Xo(`(${r}=*${lo(n)})`,l==="doesnotendwith");case"null":case"notnull":return Xo(`(${r}=*)`,l==="notnull");case"in":case"notin":{const c=Ee(n);return Xo(`(|${c.map(d=>`(${r}=${lo(d)})`).join("")})`,l==="notin")}case"between":case"notbetween":{const c=Ee(n);if(c.length<2||no(c[0])||no(c[1]))return"";const[d,p]=c,u=Ae(d,!0)?Le(d,{parseNumbers:!0}):NaN,f=Ae(p,!0)?Le(p,{parseNumbers:!0}):NaN;let h=Number.isNaN(u)?d:u,b=Number.isNaN(f)?p:f;if(!s&&h===u&&b===f&&f<u){const g=f;b=u,h=g}return Xo(`(&(${r}>=${lo(h)})(${r}<=${lo(b)}))`,l==="notbetween")}}return""},t_=(e,t,r)=>r&&typeof e=="string"?e.replaceAll(`${t}`,`${t}${t}`):e,yb=(e,t={})=>{var k;const{escapeQuotes:r,fields:o,parseNumbers:n,quoteFieldNamesWith:a,quoteValuesWith:s,fieldIdentifierSeparator:l,translations:c}=t,d=e.valueSource==="field",p=Ge(e.operator),u=s||"'",f=_=>`${u}${_}${u}`,h=_=>t_(_,u,r),b=_=>f(h(_)),g=_=>En(_,{quoteFieldNamesWith:a,fieldIdentifierSeparator:l}),y=c??{},v=y.or??"or",S=y.true??"true",x=y.false??"false",w=y.listSeparator??", ",N=!y.listSeparator;switch(p){case"null":case"notnull":return"";case"between":case"notbetween":{if(!d)return ca(e,t);const _=Ee(e.value,{retainEmptyStrings:!0}).slice(0,2).map(E=>{var D;return g(((D=Xe(o??[],E))==null?void 0:D.label)??E)});return _.length<2||!wt(_[0])||!wt(_[1])?"":ca({...e,value:_},t)}case"in":case"notin":{const _=Ee(e.value);if(_.length===0)return"";const E=_.map(T=>{var O;return d?g(((O=Xe(o??[],T))==null?void 0:O.label)??T):Ae(T,n)?`${Ke(T)}`:`${b(T)}`});if(E.length===1)return E[0];const D=N&&E.length>2?",":"";return`(${`${E.slice(0,-1).join(w)}${D} ${v} ${E.at(-1)}`})`}}return typeof e.value=="boolean"?e.value?S:x:d?g(((k=Xe(o??[],e.value))==null?void 0:k.label)??e.value):Ae(e.value,n)?`${Ke(e.value)}`:`${b(e.value)}`},vb={"=":["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"]};/* v8 ignore next -- @preserve */const r_=()=>[],wb=(e,t={})=>{const{field:r,operator:o,valueSource:n="value"}=e,{getOperators:a=r_,operatorMap:s=vb}=t,l=new Map(Object.entries(vb));for(const[g,y]of Object.entries(s))l.set(Ge(g),y);const c=Object.fromEntries(l),d=Ge(o);var p=o;const u=Ee(e.value).length===1;d==="in"&&u?p="=":d==="notin"&&u&&(p="!=");const{value:f,label:h}=Xe(Ur(a(r,{fieldData:t.fieldData??{name:r,value:r,label:r}})??[]),p)??{value:p,label:p},b=c[f]??c[Ge(f)]??[h,h];return typeof b=="string"?b:b[n==="field"?1:0]},o_=(e,t)=>{var w;const{field:r,operator:o}=e,{fieldData:n,quoteFieldNamesWith:a=["",""],fieldIdentifierSeparator:s="",quoteValuesWith:l="'",operatorProcessor:c=wb,valueProcessor:d=yb,concatOperator:p="||",wordOrder:u="SVO"}=t??{},f=En((n==null?void 0:n.label)??r,{quoteFieldNamesWith:a,fieldIdentifierSeparator:s}),h=Rt(e);if(h===!1)return"";if(h){const{mode:N,threshold:k}=h,_=ib(e.value,{...t,fields:Ur((n==null?void 0:n.subproperties)??[])}),E=(((w=n==null?void 0:n.subproperties)==null?void 0:w.length)??0)>0;switch(N){case"all":return`(${E?"for ":""}every item in ${f}${E?",":""} ${_})`;case"none":return`(${E?"for ":""}no item in ${f}${E?",":""} ${_})`;case"some":return`(${E?"for ":""}at least one item in ${f}${E?",":""} ${_})`;case"atleast":case"atmost":case"exactly":{const D=N.replace("at","at ");return k>0&&k<1?`(${E?"for ":""}${D} ${k*100}% of the items in ${f}${E?",":""} ${_})`:`(${E?"for ":""}${D} ${k} of the items in ${f}${E?",":""} ${_})`}}}const b=d(e,{...t,quoteFieldNamesWith:a,fieldIdentifierSeparator:s,quoteValuesWith:l,concatOperator:p}),g=Ge(o);if((g==="in"||g==="notin"||g==="between"||g==="notbetween")&&!b)return"";const y={S:f,V:c(e,t),O:b},v=(t==null?void 0:t.translations)??{},S={S:v.afterSubject??" ",V:v.afterVerb??" ",O:v.afterObject??" "},x=CA(u).filter(N=>y[N]!=="");return x.map((N,k)=>`${y[N]}${k<x.length-1?S[N]:""}`).join("").trim()},pa=e=>Ge(yA(e.operator)),ha=(e,t={})=>{const{quoteFieldNamesWith:r=["",""],fieldIdentifierSeparator:o="",quoteValuesWith:n="'",operatorProcessor:a=pa,valueProcessor:s=ca,concatOperator:l="||"}=t,c=b=>En(b,{quoteFieldNamesWith:r,fieldIdentifierSeparator:o}),d=c(e.field),p=Rt(e);if(p===!1)return;if(p){if((t==null?void 0:t.preset)!=="postgresql")return"";const{mode:b,threshold:g}=p,y=t.subqueryDepth??0,v=il(y),S=db(ao(e.value,{ruleProcessor:x=>({...x,field:v})}),{...t,subqueryDepth:y+1});switch(b){case"all":return`(select count(*) from unnest(${d}) as ${c(v)} where ${S}) = array_length(${d}, 1)`;case"none":return`not exists (select 1 from unnest(${d}) as ${c(v)} where ${S})`;case"some":return`exists (select 1 from unnest(${d}) as ${c(v)} where ${S})`;case"atleast":case"atmost":case"exactly":{const x=b==="atleast"?">=":b==="atmost"?"<=":"=";return`(select count(*)${g>0&&g<1?`::float / array_length(${d}, 1)`:""} from unnest(${d}) as ${c(v)} where ${S}) ${x} ${g}`}}}const u=s(e,{...t,quoteFieldNamesWith:r,fieldIdentifierSeparator:o,quoteValuesWith:n,concatOperator:l}),f=a(e,t),h=Ge(f);return(h==="in"||h==="not in"||h==="between"||h==="not between")&&!u?"":`${d} ${f} ${u}`.trim()},xb=(e,t,r)=>{const{fieldData:o,format:n,getNextNamedParam:a,parseNumbers:s,paramPrefix:l,paramsKeepPrefix:c,numberedParams:d,quoteFieldNamesWith:p=["",""],fieldIdentifierSeparator:u,concatOperator:f,operatorProcessor:h=pa,valueProcessor:b=ca}=t??{},{processedParams:g=[]}=r??{},y=n==="parameterized",v=[],S={},x=G=>y?{sql:G,params:v}:{sql:G,params:S},w=G=>En(G,{quoteFieldNamesWith:p,fieldIdentifierSeparator:u}),N=w(e.field),k=Rt(e);/* v8 ignore start -- @preserve */if(k===!1)return;if(k){if((t==null?void 0:t.preset)!=="postgresql")return x("");const{mode:G,threshold:q}=k,H=t.subqueryDepth??0,Y=il(H),{sql:J,params:W}=cb(ao(e.value,{ruleProcessor:R=>({...R,field:Y})}),{...t,fields:[],subqueryDepth:H+1});switch(Array.isArray(W)?v.push(...W):Object.assign(S,W),G){case"all":return x(`(select count(*) from unnest(${N}) as ${w(Y)} where ${J}) = array_length(${N}, 1)`);case"none":return x(`not exists (select 1 from unnest(${N}) as ${w(Y)} where ${J})`);case"some":return x(`exists (select 1 from unnest(${N}) as ${w(Y)} where ${J})`);case"atleast":case"atmost":case"exactly":{const R=G==="atleast"?">=":G==="atmost"?"<=":"=";return x(`(select count(*)${q>0&&q<1?`::float / array_length(${N}, 1)`:""} from unnest(${N}) as ${w(Y)} where ${J}) ${R} ${q}`)}}}/* v8 ignore stop -- @preserve */const _=b(e,{parseNumbers:s,quoteFieldNamesWith:p,concatOperator:f,fieldData:o,format:n}),E=h(e,t),D=Ge(E),[T,O]=p;if((D==="in"||D==="not in"||D==="between"||D==="not between")&&!_)return x("");if(D==="is null"||D==="is not null")return x(`${T}${e.field}${O} ${E}`);if(e.valueSource==="parameter"){const G=q=>{const H=ia(q,l);return y||(S[c?H:sd(q,l)]=null),H};if(D==="between"||D==="not between"){const[q,H]=Ee(e.value,{retainEmptyStrings:!0}).slice(0,2);return x(`${T}${e.field}${O} ${E} ${G(q)} and ${G(H)}`.trim())}if(D==="in"||D==="not in"){const q=Ee(e.value);return x(`${T}${e.field}${O} ${E} (${q.map(H=>G(H)).join(", ")})`)}return x(`${T}${e.field}${O} ${E} ${la(G(e.value),Ge(e.operator),{concatOperator:f})}`.trim())}else{if(e.valueSource==="field")return x(`${T}${e.field}${O} ${E} ${_}`.trim());if(D==="in"||D==="not in"){const G=Ee(e.value);if(y){for(const H of G)v.push(Ae(H,s)?Le(H,{parseNumbers:s}):H);return x(`${T}${e.field}${O} ${E} (${G.map((H,Y)=>d?`${l}${g.length+1+G.length-(G.length-Y)}`:"?").join(", ")})`)}const q=[];for(const H of G){const Y=a(e.field);q.push(`${l}${Y}`),S[`${c?l:""}${Y}`]=Ae(H,s)?Le(H,{parseNumbers:s}):H}return x(`${T}${e.field}${O} ${E} (${q.join(", ")})`)}else if(D==="between"||D==="not between"){const[G,q]=Ee(e.value,{retainEmptyStrings:!0}).slice(0,2).map(J=>Ae(J,s)?Le(J,{parseNumbers:s}):J);if(y)return v.push(G,q),x(`${T}${e.field}${O} ${E} ${d?`${l}${g.length+1}`:"?"} and ${d?`${l}${g.length+2}`:"?"}`);const H=a(e.field),Y=a(e.field);return S[`${c?l:""}${H}`]=G,S[`${c?l:""}${Y}`]=q,x(`${T}${e.field}${O} ${E} ${l}${H} and ${l}${Y}`)}}let $=e.value;typeof e.value=="string"&&(Ae(e.value,s)?$=Le(e.value,{parseNumbers:s}):$=/^'.*'$/g.test(_)?_.replaceAll(/(^'|'$)/g,""):_);let V="";return y?v.push($):(V=a(e.field),S[`${c?l:""}${V}`]=$),x(`${T}${e.field}${O} ${E} ${y?d?`${l}${g.length+1}`:"?":`${l}${V}`}`.trim())},bd=(e,t,r)=>Ae(e,!!r||typeof e=="bigint")?Number(Le(e,{parseNumbers:!!r})):t,n_=(e,t={})=>{const{field:r,operator:o,value:n,valueSource:a}=e,{parseNumbers:s,preserveValueOrder:l}=t;if(a==="field"||Rt(e))return;const c=Ge(o);switch(c){case"=":return{[r]:bd(n,n,s)};case"!=":case"<":case"<=":case">":case">=":{const d=Km[c];return{[r]:{[d]:bd(n,n,s)}}}case"contains":return{[r]:{contains:n}};case"beginswith":return{[r]:{startsWith:n}};case"endswith":return{[r]:{endsWith:n}};case"doesnotcontain":return{NOT:{[r]:{contains:n}}};case"doesnotbeginwith":return{NOT:{[r]:{startsWith:n}}};case"doesnotendwith":return{NOT:{[r]:{endsWith:n}}};case"null":return{[r]:null};case"notnull":return{[r]:{not:null}};case"in":case"notin":{const d=Ee(n);return{[r]:{[Km[c]]:d.map(p=>bd(p,p,s))}}}case"between":case"notbetween":{const d=Ee(n);if(d.length>=2&&wt(d[0])&&wt(d[1])){const[p,u]=d,f=s!==!1,h=Ae(p,f)?Le(p,{parseNumbers:s}):NaN,b=Ae(u,f)?Le(u,{parseNumbers:s}):NaN;let g=Number.isNaN(h)?p:h,y=Number.isNaN(b)?u:b;if(!l&&g===h&&y===b&&b<h){const v=b;y=h,g=v}return c==="between"?{[r]:{gte:g,lte:y}}:{OR:[{[r]:{lt:g}},{[r]:{gt:y}}]}}else return""}}return""},a_=(e,{parseNumbers:t,preserveValueOrder:r,context:o={}}={})=>{const{sequelizeOperators:n,sequelizeCol:a,sequelizeFn:s}=o;if(Rt(e))return;const{field:l,operator:c,value:d,valueSource:p}=e,u=p==="field",f=Ge(c);if(!(!n||u&&(!a||!s&&["contains","doesnotcontain","beginswith","doesnotbeginwith","endswith","doesnotendwith"].includes(f))))switch(f){case"=":case"!=":case"<":case"<=":case">":case">=":{const h={"=":n.eq,"!=":n.ne,"<":n.lt,"<=":n.lte,">":n.gt,">=":n.gte}[f];return{[l]:u&&f==="="?{[n.col]:d}:{[h]:u?a(d):Ae(d,t)?Le(d,{parseNumbers:"strict"}):d}}}case"contains":return{[l]:{[u?n.like:n.substring]:u?s("CONCAT","%",a(d),"%"):`${d}`}};case"beginswith":return{[l]:{[u?n.like:n.startsWith]:u?s("CONCAT",a(d),"%"):`${d}`}};case"endswith":return{[l]:{[u?n.like:n.endsWith]:u?s("CONCAT","%",a(d)):`${d}`}};case"doesnotcontain":return{[l]:{[n.notLike]:u?s("CONCAT","%",a(d),"%"):`%${d}%`}};case"doesnotbeginwith":return{[l]:{[n.notLike]:u?s("CONCAT",a(d),"%"):`${d}%`}};case"doesnotendwith":return{[l]:{[n.notLike]:u?s("CONCAT","%",a(d)):`%${d}`}};case"null":return{[l]:{[n.is]:null}};case"notnull":return{[l]:{[n.not]:null}};case"in":case"notin":{const h=Ee(d);return{[l]:{[f==="in"?n.in:n.notIn]:h.map(b=>u?a(b):Ae(b,t)?Le(b,{parseNumbers:"strict"}):b)}}}case"between":case"notbetween":{const h=Ee(d,{retainEmptyStrings:!0});if(h.length<2||!wt(h[0])||!wt(h[1]))return;const[b,g]=h,y=Ae(b,t)?Le(b,{parseNumbers:"strict"}):NaN,v=Ae(g,t)?Le(g,{parseNumbers:"strict"}):NaN,S=Number.isNaN(y)?b:y,x=Number.isNaN(v)?g:v,w=[S,x];return!r&&S===y&&x===v&&v<y&&(w[0]=v,w[1]=y),{[l]:{[f==="between"?n.between:n.notBetween]:u?w.map(N=>a(N)):w.every(N=>Ae(N,t))?w.map(N=>Le(N,{parseNumbers:"strict"})):w}}}}},s_=(e,t)=>typeof e!="string"||!t?`${e}`:e.replaceAll('"','\\"'),Cb=e=>/^[?<]/.test(e)||e.includes(":")?e:`?${e}`,l_=(e,t={})=>{const{escapeQuotes:r,parseNumbers:o}=t,{field:n,operator:a,value:s,valueSource:l}=e,c=l==="field",d=a.toLowerCase(),p=Cb(n),u=f=>{if(f==null)return'""';if(typeof f=="boolean")return`"${f}"^^xsd:boolean`;if(typeof f=="bigint")return String(f);if(c)return Cb(Ke(f));if(typeof f=="number"||Ae(f,o))return Ke(f);/* v8 ignore start -- @preserve */const h=typeof f=="string"?f:JSON.stringify(f)??"";/* v8 ignore stop -- @preserve */return h.startsWith("?")||h.startsWith("<")||h.includes(":")?h:`"${s_(h,r)}"`};switch(d){case"=":case"!=":case"<":case">":case"<=":case">=":return`${p} ${d} ${u(s)}`;case"<>":return`${p} != ${u(s)}`;case"contains":return`CONTAINS(${p}, ${u(s)})`;case"doesnotcontain":return`!CONTAINS(${p}, ${u(s)})`;case"beginswith":return`STRSTARTS(${p}, ${u(s)})`;case"doesnotbeginwith":return`!STRSTARTS(${p}, ${u(s)})`;case"endswith":return`STRENDS(${p}, ${u(s)})`;case"doesnotendwith":return`!STRENDS(${p}, ${u(s)})`;case"null":return`!BOUND(${p})`;case"notnull":return`BOUND(${p})`;case"in":{const f=Ee(s).map(u);return f.length?`${p} IN (${f.join(", ")})`:""}case"notin":{const f=Ee(s).map(u);return f.length?`${p} NOT IN (${f.join(", ")})`:""}case"between":{const f=Ee(s);return f.length<2?"":`${p} >= ${u(f[0])} && ${p} <= ${u(f[1])}`}case"notbetween":{const f=Ee(s);return f.length<2?"":`(${p} < ${u(f[0])} || ${p} > ${u(f[1])})`}default:return`${p} ${a} ${u(s)}`}},i_=(e,t)=>{const{parseNumbers:r,preserveValueOrder:o,context:n={}}=t??{},a=n.tanStackDbOperators,s=n._tanstackDbRefs,l=n._tanstackDbPrimaryRef;if(!a||!s||!l)return;const{and:c,eq:d,gt:p,gte:u,inArray:f,isNull:h,like:b,lt:g,lte:y,not:v}=a,S=$=>{const V=$.indexOf(".");if(V>0){const G=$.slice(0,V),q=$.slice(V+1);if(s[G])return s[G][q]}return s[l][$]},{field:x,operator:w,value:N,valueSource:k}=e,_=S(x),E=Ge(w),D=k==="field",T=$=>D?S($):$,O=$=>D||!r?T($):Ae($,!0)?Le($,{parseNumbers:!0}):$;switch(E){case"=":return d(_,O(N));case"!=":return v(d(_,O(N)));case">":return p(_,O(N));case"<":return g(_,O(N));case">=":return u(_,O(N));case"<=":return y(_,O(N));case"beginswith":case"doesnotbeginwith":{const $=b(_,D?void 0:`${N}%`);return E==="doesnotbeginwith"?v($):$}case"contains":case"doesnotcontain":{const $=b(_,D?void 0:`%${N}%`);return E==="doesnotcontain"?v($):$}case"endswith":case"doesnotendwith":{const $=b(_,D?void 0:`%${N}`);return E==="doesnotendwith"?v($):$}case"null":return h(_);case"notnull":return v(h(_));case"in":case"notin":{const $=f(_,Ee(N).map(V=>O(V)));return E==="notin"?v($):$}case"between":case"notbetween":{const $=Ee(N);if($.length>=2&&wt($[0])&&wt($[1])){let[V,G]=$;const q=r!==!1;if(!D&&Ae(V,q)&&Ae(G,q)){const Y=Le(V,{parseNumbers:q}),J=Le(G,{parseNumbers:q});if(!o&&J<Y){const W=J;G=Y,V=W}else V=Y,G=J}else D&&(V=T(V),G=T(G));const H=c(u(_,V),y(_,G));return E==="notbetween"?v(H):H}return}default:return}},Sb={ansi:{},sqlite:{paramsKeepPrefix:!0},oracle:{},mssql:{concatOperator:"+",quoteFieldNamesWith:["[","]"],fieldIdentifierSeparator:".",paramPrefix:"@"},mysql:{concatOperator:"CONCAT"},postgresql:{quoteFieldNamesWith:'"',numberedParams:!0,paramPrefix:"$"}},Nb={cel:SA,drizzle:jA,elasticsearch:KA,json_without_ids:ha,json:ha,jsonata:JA,jsonlogic:md,ldap:e_,mongodb_query:dl,mongodb:NA,natural_language:o_,parameterized_named:xb,parameterized:xb,prisma:n_,sequelize:a_,spel:EA,sql:ha,tanstack_db:i_,cypher:bb,gql:bb,sparql:l_,gremlin:XA,diagnostics:ha};/* v8 ignore next -- @preserve */const xt=e=>e.operator,c_={cel:xt,drizzle:xt,elasticsearch:xt,json_without_ids:xt,json:xt,jsonata:xt,jsonlogic:xt,ldap:xt,mongodb_query:xt,mongodb:xt,natural_language:wb,parameterized_named:pa,parameterized:pa,prisma:xt,sequelize:xt,spel:xt,sql:pa,tanstack_db:xt,cypher:xt,gql:xt,sparql:xt,gremlin:xt,diagnostics:xt},Eb={cel:"1 == 1",ldap:"",mongodb:'"$and":[{"$expr":true}]',natural_language:"1 is 1",sparql:"1 = 1",gremlin:"",spel:"1 == 1",sql:"(1 = 1)"},d_={format:"json",fields:[],quoteFieldNamesWith:["",""],fieldIdentifierSeparator:"",getOperators:()=>[],paramPrefix:":",paramsKeepPrefix:!1,numberedParams:!1,preserveValueOrder:!1,placeholderFieldName:"~",placeholderOperatorName:"~",quoteValuesWith:"'",concatOperator:"||",preset:"ansi",wordOrder:"SVO",translations:{},operatorMap:{}},kb=new Set(["cel","drizzle","elasticsearch","jsonata","jsonlogic","ldap","mongodb_query","mongodb","prisma","sequelize","spel","tanstack_db"]),u_=new Set(["sql","parameterized","parameterized_named","drizzle","prisma","sequelize"]);function f_(e,t={}){const r=typeof t=="string"?{format:Ge(t)}:t,o={...d_,...!r.format||u_.has(r.format)?Sb[r.preset??"ansi"]??null:null,...r,...!r.format&&(Object.keys(Sb).includes(r.preset??"")?{format:"sql"}:null)},n=Ge(o.format),{fallbackExpression:a,getOperators:s,operatorProcessor:l,parseNumbers:c,quoteFieldNamesWith:d,ruleGroupProcessor:p,ruleProcessor:u,validator:f,valueProcessor:h,context:b}=o,g=$=>typeof ad({parseNumbers:c,inputType:$})=="string"?!0:typeof c=="boolean"?c:void 0,y=typeof l=="function"?l:c_[n]??xt,v=typeof h=="function"?xA(h)?$=>h($.field,$.operator,$.value,$.valueSource):h:n==="natural_language"?yb:kb.has(n)?u??Nb[n]:ca,S=(typeof u=="function"?u:null)??(kb.has(n)&&typeof u!="function"&&h?v:null)??Nb[n]??ha,x=Xm(d),w=Ur(o.fields),N=($,V)=>Ur(s($,V)??[]),k=a??Eb[n]??Eb.sql;let _={};if(typeof f=="function"){const $=f(e);if(typeof $=="boolean"){if(!$&&n!=="diagnostics")return n==="parameterized"?{sql:k,params:[]}:n==="parameterized_named"?{sql:k,params:{}}:n==="mongodb"?`{${k}}`:n==="mongodb_query"?id:n==="prisma"?pd:n==="jsonlogic"?!1:n==="elasticsearch"?{}:n==="drizzle"||n==="sequelize"||n==="tanstack_db"?void 0:k}else _=$}const E={},D=nd(w);for(const $ of D)typeof $.validator=="function"&&(E[$.value??$.name]=$.validator);const O={...o,fallbackExpression:k,fields:w,format:n,getOperators:N,getParseNumberBoolean:g,quoteFieldNamesWith:x,operatorProcessor:y,ruleProcessor:S,valueProcessor:v,validateRule:$=>{let V,G;if($.id&&(V=_[$.id]),D.length>0){const q=D.filter(H=>H.name===$.field);if(q.length>0){const H=q[0];typeof H.validator=="function"&&(G=H.validator)}}if($.valueSource==="parameter"&&typeof o.getParameters=="function"){const q=Xe(w,$.field);new Set(nd(Ur(o.getParameters($.field,$.operator,{fieldData:q}))).map(H=>sd(H.value,o.paramPrefix))).has(sd($.value,o.paramPrefix))||(V=!1)}return[V,G]},validationMap:_,context:b};if(typeof p=="function")return p(e,O);switch(n){case"json":case"json_without_ids":{const $=c?Rm(e,O):e;return n==="json_without_ids"?JSON.stringify($,(V,G)=>V==="id"||V==="path"?void 0:tb(V,G)):JSON.stringify($,tb,2)}case"sql":return db(e,O);case"parameterized":case"parameterized_named":return cb(e,O);case"mongodb":return DA(e,O);case"mongodb_query":return cd(e,O);case"cel":return rb(e,O);case"spel":return ob(e,O);case"jsonata":return lb(e,O);case"jsonlogic":return ud(e,O);case"elasticsearch":return sb(e,O);case"natural_language":return ib(e,O);case"ldap":return TA(e,O);case"prisma":return $A(e,O);case"drizzle":return ab(e,O);case"tanstack_db":return OA(e,O);case"sequelize":return PA(e,O);case"cypher":case"gql":return AA(e,O);case"sparql":return MA(e,O);case"gremlin":return _A(e,O);case"diagnostics":return BA(e,O);default:return""}}const Ct=(e,t)=>{let r=t,o=0;for(;o<e.length&&r&&ke(r);){const n=r.rules[e[o]];r=typeof n=="string"?null:n,o++}return o<e.length?null:r},Ab=(e,t)=>{if(t.id===e)return t;for(const r of t.rules)if(typeof r!="string"){if(r.id===e)return r;if(ke(r)){const o=Ab(e,r);if(o)return o}}return null},kn=(e,t)=>{if(t.id===e)return[];const r=t.rules.findIndex(o=>typeof o!="string"&&o.id===e);if(r>=0)return[r];for(const[o,n]of Object.entries(t.rules))if(ke(n)){const a=kn(e,n);if(Array.isArray(a))return[Number.parseInt(o),...a]}return null},mt=e=>e.slice(0,-1),Jo=(e,t)=>e.length===t.length&&e.every((r,o)=>r===t[o]),_b=(e,t)=>{const r=[],o=mt(e),n=mt(t);let a=0;for(;a<o.length&&a<n.length&&o[a]===n[a];)r.push(n[a]),a++;return r},An=(e,t)=>{let r=!!t.disabled,o=t,n=0;for(;n<e.length&&!r&&ke(o);){const a=o.rules[e[n]];Er(a)&&(ke(a)||"field"in a&&a.field)&&(r=!!a.disabled,o=a),n++}return r},p_=e=>Jo([],e.path)?"Query builder":`Rule group at path ${e.path.join("-")}`,ma=globalThis.crypto;let pr=()=>"00-0-4-2-000".replaceAll(/[^-]/g,e=>((Math.random()+Math.trunc(e))*65536>>Number.parseInt(e)).toString(16).padStart(4,"0"));if(ma){if(typeof ma.randomUUID=="function")pr=()=>ma.randomUUID();else if(typeof ma.getRandomValues=="function"){const e="89ab",t=new Uint32Array(32);pr=()=>{ma.getRandomValues(t);let r=(t[0]%16).toString(16);for(let o=1;o<32;o++)o===12?r=`${r}4`:o===16?r=`${r}${e[t[17]%4]}`:r=`${r}${(t[o]%16).toString(16)}`,(o===7||o===11||o===15||o===19)&&(r=`${r}-`);return r}}}const h_={name:"name",value:"name",matchModes:null,label:"label"},m_=(e,t)=>{const r=e?Br(e):h_;let o=r.matchModes??!1;return!o&&t&&(o=t(r.value,{fieldData:r})),o===!0?Lm:o===!1?[]:al(o)?Ur(o):(o==null?void 0:o.map(n=>Lm.find(a=>a.value===Ge(n))??{name:n,value:n,label:n}))??[]},Tb=(e,t,r)=>{const o=Pt(e);if(t.operator==="between"||t.operator==="notBetween"){const n=[o,o];return r?n:sa(n.map(a=>a??""),",")}return o},b_=(e,t)=>{const{fieldData:r,fields:o,getValueEditorType:n,getValues:a,getDefaultValue:s,getParameters:l,listsAsArrays:c}=t;if((r==null?void 0:r.defaultValue)!==void 0&&r.defaultValue!==null)return r.defaultValue;if(s)return s(e,{fieldData:r});let d="";const p=a(e.field,e.operator,{fieldData:r});if(e.valueSource==="field"){const u=Ym(r,o,e.operator);d=u.length>0?Tb(u,e,c):""}else if(e.valueSource==="parameter"){const u=l?l(e.field,e.operator,{fieldData:r}):null;d=u&&u.length>0?Pt(u):""}else if(p.length>0){const u=n(e.field,e.operator,{fieldData:r});u==="multiselect"?d=c?[]:"":(u==="select"||u==="radio")&&(d=Tb(p,e,c))}else n(e.field,e.operator,{fieldData:r})==="checkbox"&&(d=!1);return d},Db=e=>{const t=typeof e=="boolean"?e:typeof e=="object"&&e!==null?e.valid:null;return typeof t=="boolean"?t?_e.valid:_e.invalid:""},$b=[{name:"value",value:"value",label:"value"}],g_={name:"name",value:"name",valueSources:null,label:"label"},Pb=(e,t,r)=>{const o=e?Br(e):g_;let n=o.valueSources??!1;return typeof n=="function"&&(n=n(t)),!n&&r&&(n=r(o.value,t,{fieldData:o})),n?al(n)?Ur(n):n.map(a=>$b.find(s=>s.value===Ge(a))??{name:a,value:a,label:a}):$b},nt=(e,t,r)=>{if(nl(e))return;const o=Um(t).map(([n,[a,s]])=>{var l;return[n,a??s??((l=r==null?void 0:r[e])==null?void 0:l[n])]}).filter(n=>!nl(n[0])&&!!n[1]);if(o.length>0||r){const n=(r==null?void 0:r[e])??{},a=Object.assign({},n,Object.fromEntries(o));return{[e]:a}}},Me=(e,t)=>{var o;let r="";for(let n=0;n<t.length;n++){const a=(o=t[n])==null?void 0:o[e];if(!a)continue;const s=typeof a=="string"?a:Qe(a);s&&(r=r?`${r} ${s}`:s)}return r},y_=(...e)=>({queryBuilder:Me("queryBuilder",e),ruleGroup:Me("ruleGroup",e),header:Me("header",e),body:Me("body",e),combinators:Me("combinators",e),addRule:Me("addRule",e),addGroup:Me("addGroup",e),cloneRule:Me("cloneRule",e),cloneGroup:Me("cloneGroup",e),removeGroup:Me("removeGroup",e),rule:Me("rule",e),fields:Me("fields",e),operators:Me("operators",e),value:Me("value",e),removeRule:Me("removeRule",e),notToggle:Me("notToggle",e),shiftActions:Me("shiftActions",e),dragHandle:Me("dragHandle",e),lockRule:Me("lockRule",e),lockGroup:Me("lockGroup",e),muteRule:Me("muteRule",e),muteGroup:Me("muteGroup",e),muted:Me("muted",e),valueSource:Me("valueSource",e),actionElement:Me("actionElement",e),valueSelector:Me("valueSelector",e),betweenRules:Me("betweenRules",e),valid:Me("valid",e),invalid:Me("invalid",e),dndDragging:Me("dndDragging",e),dndOver:Me("dndOver",e),dndCopy:Me("dndCopy",e),dndGroup:Me("dndGroup",e),dndDropNotAllowed:Me("dndDropNotAllowed",e),dndPreviewPosition:Me("dndPreviewPosition",e),dndHidden:Me("dndHidden",e),disabled:Me("disabled",e),valueListItem:Me("valueListItem",e),matchMode:Me("matchMode",e),matchThreshold:Me("matchThreshold",e),branches:Me("branches",e),hasSubQuery:Me("hasSubQuery",e),loading:Me("loading",e),valueDateTimeRelative:Me("valueDateTimeRelative",e)}),v_=(e,t)=>e===!1?!1:e?!0:t!==!1,w_=(e,t)=>e?!0:e===!1?!1:!!t,Mb=(e,t,r,o)=>o?t??r:e?v_(t,r):w_(t,r),x_=(e={},t={},r)=>Um(mA).reduce((o,[n,a])=>(o[n]=Mb(a,e[n],t[n],!1),o),{}),Ob=(e,{idGenerator:t=pr}={})=>{const r=!e.id,o=Rt(e);return!r&&!o?e:{...e,...r&&{id:t()},...o&&{value:ml(e.value,{idGenerator:t})}}},ml=(e,{idGenerator:t=pr}={})=>{const r=!e.id;let o=!1;const n=[];for(let a=0;a<e.rules.length;a++){const s=e.rules[a];if(typeof s=="string")n.push(s);else{const l=ke(s)?ml(s,{idGenerator:t}):Ob(s,{idGenerator:t});n.push(l),l!==s&&(o=!0)}}return!r&&!o?e:{...e,...r&&{id:t()},rules:n}},Ib=(e,{idGenerator:t=pr}={})=>ke(e)?ml(e,{idGenerator:t}):Ob(e,{idGenerator:t}),C_=(e,{idGenerator:t=pr}={})=>structuredClone({...e,id:t()}),gd=(e,{idGenerator:t=pr}={})=>{if(!Er(e))return e;if(!ke(e))return structuredClone({...e,id:t()});const r={...e,id:t()};return Array.isArray(r.rules)&&(r.rules=e.rules.map(o=>typeof o=="string"?o:ke(o)?gd(o,{idGenerator:t}):C_(o,{idGenerator:t}))),r},Lb=(e,t,r,o={})=>na(e,n=>S_(n,t,r,o)),S_=(e,t,r,o={})=>{const{combinators:n=aa,combinatorPreceding:a,idGenerator:s=pr}=o,l=Array.isArray(r)?Ct(r,e):Ab(r,e);if(!l||!ke(l))return e;if(Cn(l)&&l.rules.length>0){const c=l.rules.at(-2);l.rules.push(a??(typeof c=="string"?c:Pt(n)))}return l.rules.push(Ib(t,{idGenerator:s})),e},Fb={field:0,operator:1,valueSource:2,value:4},Vb=e=>e.sort((t,r)=>(Fb[t[0]]??3)-(Fb[r[0]]??3)),N_=(e,t,r,o)=>{if(typeof e=="string")return{entries:[[e,t]],pathOrID:r,options:o??{}};if(Array.isArray(e)){const n=t;return{entries:Vb(e.map((a,s)=>[a,n[s]])),pathOrID:r,options:o??{}}}return{entries:Vb(Object.entries(e)),pathOrID:t,options:r??{}}},E_=(e,t,r,o,n)=>{const{entries:a,pathOrID:s,options:l}=N_(t,r,o,n);for(const[c,d]of a)A_(e,c,d,s,l);return e},k_=((e,t,r,o,n)=>na(e,a=>{E_(a,t,r,o,n)})),A_=(e,t,r,o,n={})=>{var S;const{resetOnFieldChange:a=!0,resetOnOperatorChange:s=!1,getRuleDefaultOperator:l=()=>"=",getValueSources:c=()=>["value"],getRuleDefaultValue:d=()=>"",getMatchModes:p=()=>[]}=n;let u=a;const f=Array.isArray(o)?o:kn(o,e);if(!f)return e;if(t==="combinator"&&!Bt(e)){const x=Ct(mt(f),e).rules;return f.at(-1)%2===1&&(x[f.at(-1)]=r),e}const h=Ct(f,e);if(!h)return e;const b=ke(h);if(h[t]===r||(t!=="valueSource"&&(h[t]=r),b))return e;let g=!1,y=!1;if(t==="field"){const x=p(h.field),w=p(r);if(w.length===0)delete h.match;else{const N=(S=h.match)!=null&&S.mode&&Xe(w,h.match.mode)?null:Pt(w);N&&(h.match={mode:N,threshold:1})}(x.length>0||w.length>0)&&(u=!0)}u&&t==="field"&&(h.operator=l(r),g=!0,y=!0),s&&t==="operator"&&(g=!0,y=!0);const v=Pt(Pb({name:h.field,value:h.field,label:""},h.operator,c));return(g&&h.valueSource&&v!==h.valueSource||t==="valueSource"&&r!==h.valueSource)&&(y=!!h.valueSource||!h.valueSource&&r!==v,h.valueSource=g?v:r),y&&(h.value=d(h)),e},__=(e,t)=>na(e,r=>T_(r,t)),T_=(e,t)=>{const r=Array.isArray(t)?t:kn(t,e);if(!r||r.length===0||!Bt(e)&&!Ct(r,e))return e;const o=r.at(-1),n=Ct(mt(r),e);if(n&&ke(n))if(!Bt(n)&&n.rules.length>1){const a=o===0?0:o-1;n.rules.splice(a,2)}else n.rules.splice(o,1);return e},Gb=(e,t,r)=>{if(Array.isArray(r))return r;const o=Cn(e);if(r==="up"){if(Jo(t,[0]))return t;if(t.at(-1)===0){const n=mt(t);return[...mt(n),Math.max(0,n.at(-1)-(o?1:0))]}else{const n=[...mt(t),Math.max(0,t.at(-1)-(o?2:1))],a=Ct(n,e);return ke(a)?[...n,a.rules.length]:[...mt(t),Math.max(0,t.at(-1)-(o?3:1))]}}else if(r==="down"){if(Jo([e.rules.length-1],t))return t;if(t.at(-1)===Ct(mt(t),e).rules.length-1){const n=mt(t);return[...mt(n),n.at(-1)+1]}else{const n=[...mt(t),t.at(-1)+(o?2:1)];return ke(Ct(n,e))?[...n,0]:[...mt(t),t.at(-1)+(o?3:2)]}}return t},D_=(e,t,r,o={})=>na(e,n=>$_(n,t,r,o)),$_=(e,t,r,o={})=>{const{clone:n=!1,combinators:a=aa,idGenerator:s=pr}=o,l=Array.isArray(t)?t:kn(t,e);if(!l)return e;const c=Gb(e,l,r);if(l.length===0||Jo(l,c)||!Ct(mt(c),e))return e;const d=Ct(l,e);if(!d)return e;const p=n?gd(Gr(d)?ed(d):d,{idGenerator:s}):d,u=Cn(e),f=Ct(mt(l),e),h=l.at(-1),b=u&&h>0?f.rules[h-1]:null,g=u&&h<f.rules.length-1?f.rules[h+1]:null;if(!n){const N=u?Math.max(0,h-1):h,k=u?2:1;f.rules.splice(N,k)}const y=[...c],v=_b(l,c);!n&&l.length===v.length+1&&c[v.length]>l[v.length]&&(y[v.length]-=u?2:1);const S=Ct(mt(y),e),x=y.at(-1),w=(...N)=>S.rules.splice(x,0,...N);return S.rules.length===0||!u?w(p):x===0?h===0&&g?w(p,g):w(p,S.rules[1]??b??Pt(a)):w(b||(S.rules[x-2]??g??Pt(a)),p),e},P_=(e,t,r,o={})=>na(e,n=>M_(n,t,r,o)),M_=(e,t,r,o={})=>{const{clone:n=!1,combinators:a=aa,idGenerator:s=pr}=o,l=Array.isArray(t)?t:kn(t,e),c=Array.isArray(r)?r:kn(r,e);if(!l||!c)return e;const d=Gb(e,l,c);if(l.length===0||Jo(l,d)||!Ct(mt(d),e))return e;const p=Ct(l,e),u=Ct(c,e);if(!p||!u)return e;const f=n?gd(Gr(p)?ed(p):p,{idGenerator:s}):p,h=Cn(e),b=Ct(mt(l),e),g=l.at(-1);if(!n){const w=h?Math.max(0,g-1):g,N=h?2:1;b.rules.splice(w,N)}const y=[...d],v=_b(l,d);!n&&l.length===v.length+1&&d[v.length]>l[v.length]&&(y[v.length]-=h?2:1);const S=Ct(mt(y),e),x=y.at(-1);return S.rules.splice(x,1,Ib(h?{rules:[u,Pt(a),f]}:{combinator:Pt(a),rules:[u,f]},{idGenerator:s})),e};function It(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 O_=typeof Symbol=="function"&&Symbol.observable||"@@observable",zb=O_,yd=()=>Math.random().toString(36).substring(7).split("").join("."),I_={INIT:`@@redux/INIT${yd()}`,REPLACE:`@@redux/REPLACE${yd()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${yd()}`},Zo=I_;function ba(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function L_(e){if(e===void 0)return"undefined";if(e===null)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(G_(e))return"date";if(V_(e))return"error";const r=F_(e);switch(r){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return r}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function F_(e){return typeof e.constructor=="function"?e.constructor.name:null}function V_(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function G_(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function Co(e){let t=typeof e;return process.env.NODE_ENV!=="production"&&(t=L_(e)),t}function Bb(e,t,r){if(typeof e!="function")throw new Error(process.env.NODE_ENV==="production"?It(2):`Expected the root reducer to be a function. Instead, received: '${Co(e)}'`);if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(process.env.NODE_ENV==="production"?It(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(process.env.NODE_ENV==="production"?It(1):`Expected the enhancer to be a function. Instead, received: '${Co(r)}'`);return r(Bb)(e,t)}let o=e,n=t,a=new Map,s=a,l=0,c=!1;function d(){s===a&&(s=new Map,a.forEach((y,v)=>{s.set(v,y)}))}function p(){if(c)throw new Error(process.env.NODE_ENV==="production"?It(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return n}function u(y){if(typeof y!="function")throw new Error(process.env.NODE_ENV==="production"?It(4):`Expected the listener to be a function. Instead, received: '${Co(y)}'`);if(c)throw new Error(process.env.NODE_ENV==="production"?It(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let v=!0;d();const S=l++;return s.set(S,y),function(){if(v){if(c)throw new Error(process.env.NODE_ENV==="production"?It(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");v=!1,d(),s.delete(S),a=null}}}function f(y){if(!ba(y))throw new Error(process.env.NODE_ENV==="production"?It(7):`Actions must be plain objects. Instead, the actual type was: '${Co(y)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(typeof y.type>"u")throw new Error(process.env.NODE_ENV==="production"?It(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(typeof y.type!="string")throw new Error(process.env.NODE_ENV==="production"?It(17):`Action "type" property must be a string. Instead, the actual type was: '${Co(y.type)}'. Value was: '${y.type}' (stringified)`);if(c)throw new Error(process.env.NODE_ENV==="production"?It(9):"Reducers may not dispatch actions.");try{c=!0,n=o(n,y)}finally{c=!1}return(a=s).forEach(S=>{S()}),y}function h(y){if(typeof y!="function")throw new Error(process.env.NODE_ENV==="production"?It(10):`Expected the nextReducer to be a function. Instead, received: '${Co(y)}`);o=y,f({type:Zo.REPLACE})}function b(){const y=u;return{subscribe(v){if(typeof v!="object"||v===null)throw new Error(process.env.NODE_ENV==="production"?It(11):`Expected the observer to be an object. Instead, received: '${Co(v)}'`);function S(){const w=v;w.next&&w.next(p())}return S(),{unsubscribe:y(S)}},[zb](){return this}}}return f({type:Zo.INIT}),{dispatch:f,subscribe:u,getState:p,replaceReducer:h,[zb]:b}}function Ub(e){typeof console<"u"&&typeof console.error=="function"&&console.error(e);try{throw new Error(e)}catch{}}function z_(e,t,r,o){const n=Object.keys(t),a=r&&r.type===Zo.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(n.length===0)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!ba(e))return`The ${a} has unexpected type of "${Co(e)}". Expected argument to be an object with the following keys: "${n.join('", "')}"`;const s=Object.keys(e).filter(l=>!t.hasOwnProperty(l)&&!o[l]);if(s.forEach(l=>{o[l]=!0}),!(r&&r.type===Zo.REPLACE)&&s.length>0)return`Unexpected ${s.length>1?"keys":"key"} "${s.join('", "')}" found in ${a}. Expected to find one of the known reducer keys instead: "${n.join('", "')}". Unexpected keys will be ignored.`}function B_(e){Object.keys(e).forEach(t=>{const r=e[t];if(typeof r(void 0,{type:Zo.INIT})>"u")throw new Error(process.env.NODE_ENV==="production"?It(12):`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof r(void 0,{type:Zo.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(process.env.NODE_ENV==="production"?It(13):`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${Zo.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)})}function Wb(e){const t=Object.keys(e),r={};for(let s=0;s<t.length;s++){const l=t[s];process.env.NODE_ENV!=="production"&&typeof e[l]>"u"&&Ub(`No reducer provided for key "${l}"`),typeof e[l]=="function"&&(r[l]=e[l])}const o=Object.keys(r);let n;process.env.NODE_ENV!=="production"&&(n={});let a;try{B_(r)}catch(s){a=s}return function(l={},c){if(a)throw a;if(process.env.NODE_ENV!=="production"){const u=z_(l,r,c,n);u&&Ub(u)}let d=!1;const p={};for(let u=0;u<o.length;u++){const f=o[u],h=r[f],b=l[f],g=h(b,c);if(typeof g>"u"){const y=c&&c.type;throw new Error(process.env.NODE_ENV==="production"?It(14):`When called with an action of type ${y?`"${String(y)}"`:"(unknown type)"}, the slice reducer for key "${f}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}p[f]=g,d=d||g!==b}return d=d||o.length!==Object.keys(l).length,d?p:l}}function bl(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...o)=>t(r(...o)))}function U_(...e){return t=>(r,o)=>{const n=t(r,o);let a=()=>{throw new Error(process.env.NODE_ENV==="production"?It(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:n.getState,dispatch:(c,...d)=>a(c,...d)},l=e.map(c=>c(s));return a=bl(...l)(n.dispatch),{...n,dispatch:a}}}function Hb(e){return ba(e)&&"type"in e&&typeof e.type=="string"}var jb=Symbol.for("immer-nothing"),qb=Symbol.for("immer-draftable"),Ut=Symbol.for("immer-state"),W_=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function nr(e,...t){if(process.env.NODE_ENV!=="production"){const r=W_[e],o=en(r)?r.apply(null,t):r;throw new Error(`[Immer] ${o}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var ar=Object,_n=ar.getPrototypeOf,gl="constructor",yl="prototype",vd="configurable",vl="enumerable",wl="writable",ga="value",io=e=>!!e&&!!e[Ut];function hr(e){var t;return e?Qb(e)||Sl(e)||!!e[qb]||!!((t=e[gl])!=null&&t[qb])||Nl(e)||El(e):!1}var H_=ar[yl][gl].toString(),Yb=new WeakMap;function Qb(e){if(!e||!Cd(e))return!1;const t=_n(e);if(t===null||t===ar[yl])return!0;const r=ar.hasOwnProperty.call(t,gl)&&t[gl];if(r===Object)return!0;if(!en(r))return!1;let o=Yb.get(r);return o===void 0&&(o=Function.toString.call(r),Yb.set(r,o)),o===H_}function xl(e,t,r=!0){ya(e)===0?(r?Reflect.ownKeys(e):ar.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((o,n)=>t(n,o,e))}function ya(e){const t=e[Ut];return t?t.type_:Sl(e)?1:Nl(e)?2:El(e)?3:0}var wd=(e,t,r=ya(e))=>r===2?e.has(t):ar[yl].hasOwnProperty.call(e,t),xd=(e,t,r=ya(e))=>r===2?e.get(t):e[t],Cl=(e,t,r,o=ya(e))=>{o===2?e.set(t,r):o===3?e.add(r):e[t]=r};function j_(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Sl=Array.isArray,Nl=e=>e instanceof Map,El=e=>e instanceof Set,Cd=e=>typeof e=="object",en=e=>typeof e=="function",Sd=e=>typeof e=="boolean";function q_(e){const t=+e;return Number.isInteger(t)&&String(t)===e}var co=e=>e.copy_||e.base_,Nd=e=>e.modified_?e.copy_:e.base_;function Ed(e,t){if(Nl(e))return new Map(e);if(El(e))return new Set(e);if(Sl(e))return Array[yl].slice.call(e);const r=Qb(e);if(t===!0||t==="class_only"&&!r){const o=ar.getOwnPropertyDescriptors(e);delete o[Ut];let n=Reflect.ownKeys(o);for(let a=0;a<n.length;a++){const s=n[a],l=o[s];l[wl]===!1&&(l[wl]=!0,l[vd]=!0),(l.get||l.set)&&(o[s]={[vd]:!0,[wl]:!0,[vl]:l[vl],[ga]:e[s]})}return ar.create(_n(e),o)}else{const o=_n(e);if(o!==null&&r)return{...e};const n=ar.create(o);return ar.assign(n,e)}}function kd(e,t=!1){return Al(e)||io(e)||!hr(e)||(ya(e)>1&&ar.defineProperties(e,{set:kl,add:kl,clear:kl,delete:kl}),ar.freeze(e),t&&xl(e,(r,o)=>{kd(o,!0)},!1)),e}function Y_(){nr(2)}var kl={[ga]:Y_};function Al(e){return e===null||!Cd(e)?!0:ar.isFrozen(e)}var _l="MapSet",Ad="Patches",Kb="ArrayMethods",Rb={};function tn(e){const t=Rb[e];return t||nr(0,e),t}var Xb=e=>!!Rb[e],va,Jb=()=>va,Q_=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Xb(_l)?tn(_l):void 0,arrayMethodsPlugin_:Xb(Kb)?tn(Kb):void 0});function Zb(e,t){t&&(e.patchPlugin_=tn(Ad),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function _d(e){Td(e),e.drafts_.forEach(K_),e.drafts_=null}function Td(e){e===va&&(va=e.parent_)}var eg=e=>va=Q_(va,e);function K_(e){const t=e[Ut];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function tg(e,t){t.unfinalizedDrafts_=t.drafts_.length;const r=t.drafts_[0];if(e!==void 0&&e!==r){r[Ut].modified_&&(_d(t),nr(4)),hr(e)&&(e=rg(t,e));const{patchPlugin_:n}=t;n&&n.generateReplacementPatches_(r[Ut].base_,e,t)}else e=rg(t,r);return R_(t,e,!0),_d(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==jb?e:void 0}function rg(e,t){if(Al(t))return t;const r=t[Ut];if(!r)return Dl(t,e.handledSet_,e);if(!Tl(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){const{callbacks_:o}=r;if(o)for(;o.length>0;)o.pop()(e);ag(r,e)}return r.copy_}function R_(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&kd(t,r)}function og(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Tl=(e,t)=>e.scope_===t,X_=[];function ng(e,t,r,o){const n=co(e),a=e.type_;if(o!==void 0&&xd(n,o,a)===t){Cl(n,o,r,a);return}if(!e.draftLocations_){const l=e.draftLocations_=new Map;xl(n,(c,d)=>{if(io(d)){const p=l.get(d)||[];p.push(c),l.set(d,p)}})}const s=e.draftLocations_.get(t)??X_;for(const l of s)Cl(n,l,r,a)}function J_(e,t,r){e.callbacks_.push(function(n){var l;const a=t;if(!a||!Tl(a,n))return;(l=n.mapSetPlugin_)==null||l.fixSetContents(a);const s=Nd(a);ng(e,a.draft_??a,s,r),ag(a,n)})}function ag(e,t){var o;if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(((o=e.assigned_)==null?void 0:o.size)??0)>0)){const{patchPlugin_:n}=t;if(n){const a=n.getPath(e);a&&n.generatePatches_(e,a,t)}og(e)}}function Z_(e,t,r){const{scope_:o}=e;if(io(r)){const n=r[Ut];Tl(n,o)&&n.callbacks_.push(function(){Pl(e);const s=Nd(n);ng(e,r,s,t)})}else hr(r)&&e.callbacks_.push(function(){const a=co(e);e.type_===3?a.has(r)&&Dl(r,o.handledSet_,o):xd(a,t,e.type_)===r&&o.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Dl(xd(e.copy_,t,e.type_),o.handledSet_,o)})}function Dl(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||io(e)||t.has(e)||!hr(e)||Al(e)||(t.add(e),xl(e,(o,n)=>{if(io(n)){const a=n[Ut];if(Tl(a,r)){const s=Nd(a);Cl(e,o,s,e.type_),og(a)}}else hr(n)&&Dl(n,t,r)})),e}function eT(e,t){const r=Sl(e),o={type_:r?1:0,scope_:t?t.scope_:Jb(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let n=o,a=$l;r&&(n=[o],a=wa);const{revoke:s,proxy:l}=Proxy.revocable(n,a);return o.draft_=l,o.revoke_=s,[l,o]}var $l={get(e,t){if(t===Ut)return e;let r=e.scope_.arrayMethodsPlugin_;const o=e.type_===1&&typeof t=="string";if(o&&r!=null&&r.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);const n=co(e);if(!wd(n,t,e.type_))return rT(e,n,t);const a=n[t];if(e.finalized_||!hr(a)||o&&e.operationMethod&&(r!=null&&r.isMutatingArrayMethod(e.operationMethod))&&q_(t))return a;if(a===Dd(e.base_,t)||tT(e,t,a)){Pl(e);const s=e.type_===1?+t:t,l=Pd(e.scope_,a,e,s);return e.copy_[s]=l}return a},has(e,t){return t in co(e)},ownKeys(e){return Reflect.ownKeys(co(e))},set(e,t,r){const o=sg(co(e),t);if(o!=null&&o.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){const n=Dd(co(e),t),a=n==null?void 0:n[Ut];if(a&&a.base_===r)return e.copy_[t]=r,e.assigned_.set(t,!1),!0;if(j_(r,n)&&(r!==void 0||wd(e.base_,t,e.type_)))return!0;Pl(e),$d(e)}return e.copy_[t]===r&&(r!==void 0||wd(e.copy_,t,e.type_))||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),Z_(e,t,r)),!0},deleteProperty(e,t){return Pl(e),Dd(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),$d(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const r=co(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{[wl]:!0,[vd]:e.type_!==1||t!=="length",[vl]:o[vl],[ga]:r[t]}},defineProperty(){nr(11)},getPrototypeOf(e){return _n(e.base_)},setPrototypeOf(){nr(12)}},wa={};for(let e in $l){let t=$l[e];wa[e]=function(){const r=arguments;return r[0]=r[0][0],t.apply(this,r)}}wa.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&nr(13),wa.set.call(this,e,t,void 0)},wa.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&nr(14),$l.set.call(this,e[0],t,r,e[0])};function Dd(e,t){const r=e[Ut];return(r?co(r):e)[t]}function tT(e,t,r){var o;return e.type_!==1||!e.allIndicesReassigned_||(o=e.assigned_)!=null&&o.get(t)||!hr(r)||r[Ut]?!1:e.baseRefs_.has(r)}function rT(e,t,r){var n;const o=sg(t,r);return o?ga in o?o[ga]:(n=o.get)==null?void 0:n.call(e.draft_):void 0}function sg(e,t){if(!(t in e))return;let r=_n(e);for(;r;){const o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=_n(r)}}function $d(e){e.modified_||(e.modified_=!0,e.parent_&&$d(e.parent_))}function Pl(e){e.copy_||(e.assigned_=new Map,e.copy_=Ed(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var oT=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,r,o)=>{if(en(t)&&!en(r)){const a=r;r=t;const s=this;return function(c=a,...d){return s.produce(c,p=>r.call(this,p,...d))}}en(r)||nr(6),o!==void 0&&!en(o)&&nr(7);let n;if(hr(t)){const a=eg(this),s=Pd(a,t,void 0);let l=!0;try{n=r(s),l=!1}finally{l?_d(a):Td(a)}return Zb(a,o),tg(n,a)}else if(!t||!Cd(t)){if(n=r(t),n===void 0&&(n=t),n===jb&&(n=void 0),this.autoFreeze_&&kd(n,!0),o){const a=[],s=[];tn(Ad).generateReplacementPatches_(t,n,{patches_:a,inversePatches_:s}),o(a,s)}return n}else nr(1,t)},this.produceWithPatches=(t,r)=>{if(en(t))return(s,...l)=>this.produceWithPatches(s,c=>t(c,...l));let o,n;return[this.produce(t,r,(s,l)=>{o=s,n=l}),o,n]},Sd(e==null?void 0:e.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Sd(e==null?void 0:e.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Sd(e==null?void 0:e.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){hr(e)||nr(8),io(e)&&(e=nT(e));const t=eg(this),r=Pd(t,e,void 0);return r[Ut].isManual_=!0,Td(t),r}finishDraft(e,t){const r=e&&e[Ut];(!r||!r.isManual_)&&nr(9);const{scope_:o}=r;return Zb(o,t),tg(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){const n=t[r];if(n.path.length===0&&n.op==="replace"){e=n.value;break}}r>-1&&(t=t.slice(r+1));const o=tn(Ad).applyPatches_;return io(e)?o(e,t):this.produce(e,n=>o(n,t))}};function Pd(e,t,r,o){const[n,a]=Nl(t)?tn(_l).proxyMap_(t,r):El(t)?tn(_l).proxySet_(t,r):eT(t,r);return((r==null?void 0:r.scope_)??Jb()).drafts_.push(n),a.callbacks_=(r==null?void 0:r.callbacks_)??[],a.key_=o,r&&o!==void 0?J_(r,a,o):a.callbacks_.push(function(c){var p;(p=c.mapSetPlugin_)==null||p.fixSetContents(a);const{patchPlugin_:d}=c;a.modified_&&d&&d.generatePatches_(a,[],c)}),n}function nT(e){return io(e)||nr(10,e),lg(e)}function lg(e){if(!hr(e)||Al(e))return e;const t=e[Ut];let r,o=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Ed(e,t.scope_.immer_.useStrictShallowCopy_),o=t.scope_.immer_.shouldUseStrictIteration()}else r=Ed(e,!0);return xl(r,(n,a)=>{Cl(r,n,lg(a))},o),t&&(t.finalized_=!1),r}var aT=new oT,ig=aT.produce;function cg(e){return({dispatch:r,getState:o})=>n=>a=>typeof a=="function"?a(r,o,e):n(a)}var sT=cg(),lT=cg,iT=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?bl:bl.apply(null,arguments)},cT=e=>e&&typeof e.match=="function";function dg(e,t){function r(...o){if(t){let n=t(...o);if(!n)throw new Error(process.env.NODE_ENV==="production"?Ze(0):"prepareAction did not return an object");return{type:e,payload:n.payload,..."meta"in n&&{meta:n.meta},..."error"in n&&{error:n.error}}}return{type:e,payload:o[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=o=>Hb(o)&&o.type===e,r}function dT(e){return typeof e=="function"&&"type"in e&&cT(e)}function uT(e){const t=e?`${e}`.split("/"):[],r=t[t.length-1]||"actionCreator";return`Detected an action creator with type "${e||"unknown"}" being dispatched.
183
+ Make sure you're calling the action creator before dispatching, i.e. \`dispatch(${r}())\` instead of \`dispatch(${r})\`. This is necessary even if the action has no payload.`}function fT(e={}){if(process.env.NODE_ENV==="production")return()=>r=>o=>r(o);const{isActionCreator:t=dT}=e;return()=>r=>o=>(t(o)&&console.warn(uT(o.type)),r(o))}function ug(e,t){let r=0;return{measureTime(o){const n=Date.now();try{return o()}finally{const a=Date.now();r+=a-n}},warnIfExceeded(){r>e&&console.warn(`${t} took ${r}ms, which is more than the warning threshold of ${e}ms.
179
184
  If your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.
180
- It is disabled in production builds, so you don't need to worry about that.`)}}}var ub=class zs extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,zs.prototype)}static get[Symbol.species](){return zs}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new zs(...t[0].concat(this)):new zs(...t.concat(this))}};function fb(e){return ir(e)?lb(e,()=>{}):e}function xs(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}function sD(e){return typeof e!="object"||e==null||Object.isFrozen(e)}function aD(e,t,r){const o=pb(e,t,r);return{detectMutations(){return hb(e,t,o,r)}}}function pb(e,t=[],r,o="",n=new Set){const s={value:r};if(!e(r)&&!n.has(r)){n.add(r),s.children={};const a=t.length>0;for(const i in r){const c=o?o+"."+i:i;a&&t.some(p=>p instanceof RegExp?p.test(c):c===p)||(s.children[i]=pb(e,t,r[i],c))}}return s}function hb(e,t=[],r,o,n=!1,s=""){const a=r?r.value:void 0,i=a===o;if(n&&!i&&!Number.isNaN(o))return{wasMutated:!0,path:s};if(e(a)||e(o))return{wasMutated:!1};const c={};for(let p in r.children)c[p]=!0;for(let p in o)c[p]=!0;const d=t.length>0;for(let p in c){const u=s?s+"."+p:p;if(d&&t.some(g=>g instanceof RegExp?g.test(u):u===g))continue;const f=hb(e,t,r.children[p],o[p],i,u);if(f.wasMutated)return f}return{wasMutated:!1}}function lD(e={}){if(process.env.NODE_ENV==="production")return()=>t=>r=>t(r);{let t=function(i,c,d,p){return JSON.stringify(i,r(c,p),d)},r=function(i,c){let d=[],p=[];return c||(c=function(u,f){return d[0]===f?"[Circular ~]":"[Circular ~."+p.slice(0,d.indexOf(f)).join(".")+"]"}),function(u,f){if(d.length>0){var h=d.indexOf(this);~h?d.splice(h+1):d.push(this),~h?p.splice(h,1/0,u):p.push(u),~d.indexOf(f)&&(f=c.call(this,u,f))}else d.push(f);return i==null?f:i.call(this,u,f)}},{isImmutable:o=sD,ignoredPaths:n,warnAfter:s=32}=e;const a=aD.bind(null,o,n);return({getState:i})=>{let c=i(),d=a(c),p;return u=>f=>{const h=db(s,"ImmutableStateInvariantMiddleware");h.measureTime(()=>{if(c=i(),p=d.detectMutations(),d=a(c),p.wasMutated)throw new Error(process.env.NODE_ENV==="production"?je(19):`A state mutation was detected between dispatches, in the path '${p.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)});const g=u(f);return h.measureTime(()=>{if(c=i(),p=d.detectMutations(),d=a(c),p.wasMutated)throw new Error(process.env.NODE_ENV==="production"?je(20):`A state mutation was detected inside a dispatch, in the path: ${p.path||""}. Take a look at the reducer(s) handling the action ${t(f)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}),h.warnIfExceeded(),g}}}}function mb(e){const t=typeof e;return e==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(e)||ms(e)}function Id(e,t="",r=mb,o,n=[],s){let a;if(!r(e))return{keyPath:t||"<root>",value:e};if(typeof e!="object"||e===null||s!=null&&s.has(e))return!1;const i=o!=null?o(e):Object.entries(e),c=n.length>0;for(const[d,p]of i){const u=t?t+"."+d:d;if(!(c&&n.some(h=>h instanceof RegExp?h.test(u):u===h))){if(!r(p))return{keyPath:u,value:p};if(typeof p=="object"&&(a=Id(p,u,r,o,n,s),a))return a}}return s&&gb(e)&&s.add(e),!1}function gb(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if(!(typeof t!="object"||t===null)&&!gb(t))return!1;return!0}function iD(e={}){if(process.env.NODE_ENV==="production")return()=>t=>r=>t(r);{const{isSerializable:t=mb,getEntries:r,ignoredActions:o=[],ignoredActionPaths:n=["meta.arg","meta.baseQueryMeta"],ignoredPaths:s=[],warnAfter:a=32,ignoreState:i=!1,ignoreActions:c=!1,disableCache:d=!1}=e,p=!d&&WeakSet?new WeakSet:void 0;return u=>f=>h=>{if(!Wg(h))return f(h);const g=f(h),y=db(a,"SerializableStateInvariantMiddleware");return!c&&!(o.length&&o.indexOf(h.type)!==-1)&&y.measureTime(()=>{const b=Id(h,"",t,r,n,p);if(b){const{keyPath:v,value:N}=b;console.error(`A non-serializable value was detected in an action, in the path: \`${v}\`. Value:`,N,`
185
+ It is disabled in production builds, so you don't need to worry about that.`)}}}var fg=class za extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,za.prototype)}static get[Symbol.species](){return za}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new za(...t[0].concat(this)):new za(...t.concat(this))}};function pg(e){return hr(e)?ig(e,()=>{}):e}function xa(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}function pT(e){return typeof e!="object"||e==null||Object.isFrozen(e)}function hT(e,t,r){const o=hg(e,t,r);return{detectMutations(){return mg(e,t,o,r)}}}function hg(e,t=[],r,o="",n=new Set){const a={value:r};if(!e(r)&&!n.has(r)){n.add(r),a.children={};const s=t.length>0;for(const l in r){const c=o?o+"."+l:l;s&&t.some(p=>p instanceof RegExp?p.test(c):c===p)||(a.children[l]=hg(e,t,r[l],c))}}return a}function mg(e,t=[],r,o,n=!1,a=""){const s=r?r.value:void 0,l=s===o;if(n&&!l&&!Number.isNaN(o))return{wasMutated:!0,path:a};if(e(s)||e(o))return{wasMutated:!1};const c={};for(let p in r.children)c[p]=!0;for(let p in o)c[p]=!0;const d=t.length>0;for(let p in c){const u=a?a+"."+p:p;if(d&&t.some(b=>b instanceof RegExp?b.test(u):u===b))continue;const f=mg(e,t,r.children[p],o[p],l,u);if(f.wasMutated)return f}return{wasMutated:!1}}function mT(e={}){if(process.env.NODE_ENV==="production")return()=>t=>r=>t(r);{let t=function(l,c,d,p){return JSON.stringify(l,r(c,p),d)},r=function(l,c){let d=[],p=[];return c||(c=function(u,f){return d[0]===f?"[Circular ~]":"[Circular ~."+p.slice(0,d.indexOf(f)).join(".")+"]"}),function(u,f){if(d.length>0){var h=d.indexOf(this);~h?d.splice(h+1):d.push(this),~h?p.splice(h,1/0,u):p.push(u),~d.indexOf(f)&&(f=c.call(this,u,f))}else d.push(f);return l==null?f:l.call(this,u,f)}},{isImmutable:o=pT,ignoredPaths:n,warnAfter:a=32}=e;const s=hT.bind(null,o,n);return({getState:l})=>{let c=l(),d=s(c),p;return u=>f=>{const h=ug(a,"ImmutableStateInvariantMiddleware");h.measureTime(()=>{if(c=l(),p=d.detectMutations(),d=s(c),p.wasMutated)throw new Error(process.env.NODE_ENV==="production"?Ze(19):`A state mutation was detected between dispatches, in the path '${p.path||""}'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)});const b=u(f);return h.measureTime(()=>{if(c=l(),p=d.detectMutations(),d=s(c),p.wasMutated)throw new Error(process.env.NODE_ENV==="production"?Ze(20):`A state mutation was detected inside a dispatch, in the path: ${p.path||""}. Take a look at the reducer(s) handling the action ${t(f)}. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)`)}),h.warnIfExceeded(),b}}}}function bg(e){const t=typeof e;return e==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(e)||ba(e)}function Md(e,t="",r=bg,o,n=[],a){let s;if(!r(e))return{keyPath:t||"<root>",value:e};if(typeof e!="object"||e===null||a!=null&&a.has(e))return!1;const l=o!=null?o(e):Object.entries(e),c=n.length>0;for(const[d,p]of l){const u=t?t+"."+d:d;if(!(c&&n.some(h=>h instanceof RegExp?h.test(u):u===h))){if(!r(p))return{keyPath:u,value:p};if(typeof p=="object"&&(s=Md(p,u,r,o,n,a),s))return s}}return a&&gg(e)&&a.add(e),!1}function gg(e){if(!Object.isFrozen(e))return!1;for(const t of Object.values(e))if(!(typeof t!="object"||t===null)&&!gg(t))return!1;return!0}function bT(e={}){if(process.env.NODE_ENV==="production")return()=>t=>r=>t(r);{const{isSerializable:t=bg,getEntries:r,ignoredActions:o=[],ignoredActionPaths:n=["meta.arg","meta.baseQueryMeta"],ignoredPaths:a=[],warnAfter:s=32,ignoreState:l=!1,ignoreActions:c=!1,disableCache:d=!1}=e,p=!d&&WeakSet?new WeakSet:void 0;return u=>f=>h=>{if(!Hb(h))return f(h);const b=f(h),g=ug(s,"SerializableStateInvariantMiddleware");return!c&&!(o.length&&o.indexOf(h.type)!==-1)&&g.measureTime(()=>{const y=Md(h,"",t,r,n,p);if(y){const{keyPath:v,value:S}=y;console.error(`A non-serializable value was detected in an action, in the path: \`${v}\`. Value:`,S,`
181
186
  Take a look at the logic that dispatched this action: `,h,`
182
187
  (See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)`,`
183
- (To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)`)}}),i||(y.measureTime(()=>{const b=u.getState(),v=Id(b,"",t,r,s,p);if(v){const{keyPath:N,value:x}=v;console.error(`A non-serializable value was detected in the state, in the path: \`${N}\`. Value:`,x,`
188
+ (To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)`)}}),l||(g.measureTime(()=>{const y=u.getState(),v=Md(y,"",t,r,a,p);if(v){const{keyPath:S,value:x}=v;console.error(`A non-serializable value was detected in the state, in the path: \`${S}\`. Value:`,x,`
184
189
  Take a look at the reducer(s) handling this action type: ${h.type}.
185
- (See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}}),y.warnIfExceeded()),g}}}function Il(e){return typeof e=="boolean"}var cD=()=>function(t){const{thunk:r=!0,immutableCheck:o=!0,serializableCheck:n=!0,actionCreatorCheck:s=!0}=t??{};let a=new ub;if(r&&(Il(r)?a.push(JA):a.push(ZA(r.extraArgument))),process.env.NODE_ENV!=="production"){if(o){let i={};Il(o)||(i=o),a.unshift(lD(i))}if(n){let i={};Il(n)||(i=n),a.push(iD(i))}if(s){let i={};Il(s)||(i=s),a.unshift(nD(i))}}return a},dD="RTK_autoBatch",bb=e=>t=>{setTimeout(t,e)},uD=(e,t)=>r=>{let o=!1;const n=()=>{o||(o=!0,cancelAnimationFrame(s),clearTimeout(a),r())},s=e(n),a=setTimeout(n,t)},fD=(e={type:"raf"})=>t=>(...r)=>{const o=t(...r);let n=!0,s=!1,a=!1;const i=new Set,c=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?uD(window.requestAnimationFrame,100):bb(10):e.type==="callback"?e.queueNotification:bb(e.timeout),d=()=>{a=!1,s&&(s=!1,i.forEach(p=>p()))};return Object.assign({},o,{subscribe(p){const u=()=>n&&p(),f=o.subscribe(u);return i.add(p),()=>{f(),i.delete(p)}},dispatch(p){var u;try{return n=!((u=p==null?void 0:p.meta)!=null&&u[dD]),s=!n,s&&(a||(a=!0,c(d))),o.dispatch(p)}finally{n=!0}}})},pD=e=>function(r){const{autoBatch:o=!0}=r??{};let n=new ub(e);return o&&n.push(fD(typeof o=="object"?o:void 0)),n};function hD(e){const t=cD(),{reducer:r=void 0,middleware:o,devTools:n=!0,duplicateMiddlewareCheck:s=!0,preloadedState:a=void 0,enhancers:i=void 0}=e||{};let c;if(typeof r=="function")c=r;else if(ms(r))c=Ug(r);else throw new Error(process.env.NODE_ENV==="production"?je(1):"`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");if(process.env.NODE_ENV!=="production"&&o&&typeof o!="function")throw new Error(process.env.NODE_ENV==="production"?je(2):"`middleware` field must be a callback");let d;if(typeof o=="function"){if(d=o(t),process.env.NODE_ENV!=="production"&&!Array.isArray(d))throw new Error(process.env.NODE_ENV==="production"?je(3):"when using a middleware builder function, an array of middleware must be returned")}else d=t();if(process.env.NODE_ENV!=="production"&&d.some(y=>typeof y!="function"))throw new Error(process.env.NODE_ENV==="production"?je(4):"each middleware provided to configureStore must be a function");if(process.env.NODE_ENV!=="production"&&s){let y=new Set;d.forEach(b=>{if(y.has(b))throw new Error(process.env.NODE_ENV==="production"?je(42):"Duplicate middleware references found when creating the store. Ensure that each middleware is only included once.");y.add(b)})}let p=gl;n&&(p=eD({trace:process.env.NODE_ENV!=="production",...typeof n=="object"&&n}));const u=OA(...d),f=pD(u);if(process.env.NODE_ENV!=="production"&&i&&typeof i!="function")throw new Error(process.env.NODE_ENV==="production"?je(5):"`enhancers` field must be a callback");let h=typeof i=="function"?i(f):f();if(process.env.NODE_ENV!=="production"&&!Array.isArray(h))throw new Error(process.env.NODE_ENV==="production"?je(6):"`enhancers` callback must return an array");if(process.env.NODE_ENV!=="production"&&h.some(y=>typeof y!="function"))throw new Error(process.env.NODE_ENV==="production"?je(7):"each enhancer provided to configureStore must be a function");process.env.NODE_ENV!=="production"&&d.length&&!h.includes(u)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");const g=p(...h);return zg(c,a,g)}function yb(e){const t={},r=[];let o;const n={addCase(s,a){if(process.env.NODE_ENV!=="production"){if(r.length>0)throw new Error(process.env.NODE_ENV==="production"?je(26):"`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error(process.env.NODE_ENV==="production"?je(27):"`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const i=typeof s=="string"?s:s.type;if(!i)throw new Error(process.env.NODE_ENV==="production"?je(28):"`builder.addCase` cannot be called with an empty action type");if(i in t)throw new Error(process.env.NODE_ENV==="production"?je(29):`\`builder.addCase\` cannot be called with two reducers for the same action type '${i}'`);return t[i]=a,n},addAsyncThunk(s,a){if(process.env.NODE_ENV!=="production"&&o)throw new Error(process.env.NODE_ENV==="production"?je(43):"`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");return a.pending&&(t[s.pending.type]=a.pending),a.rejected&&(t[s.rejected.type]=a.rejected),a.fulfilled&&(t[s.fulfilled.type]=a.fulfilled),a.settled&&r.push({matcher:s.settled,reducer:a.settled}),n},addMatcher(s,a){if(process.env.NODE_ENV!=="production"&&o)throw new Error(process.env.NODE_ENV==="production"?je(30):"`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return r.push({matcher:s,reducer:a}),n},addDefaultCase(s){if(process.env.NODE_ENV!=="production"&&o)throw new Error(process.env.NODE_ENV==="production"?je(31):"`builder.addDefaultCase` can only be called once");return o=s,n}};return e(n),[t,r,o]}function mD(e){return typeof e=="function"}function gD(e,t){if(process.env.NODE_ENV!=="production"&&typeof t=="object")throw new Error(process.env.NODE_ENV==="production"?je(8):"The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let[r,o,n]=yb(t),s;if(mD(e))s=()=>fb(e());else{const i=fb(e);s=()=>i}function a(i=s(),c){let d=[r[c.type],...o.filter(({matcher:p})=>p(c)).map(({reducer:p})=>p)];return d.filter(p=>!!p).length===0&&(d=[n]),d.reduce((p,u)=>{if(u)if(ao(p)){const h=u(p,c);return h===void 0?p:h}else{if(ir(p))return lb(p,f=>u(f,c));{const f=u(p,c);if(f===void 0){if(p===null)return p;throw Error("A case reducer on a non-draftable value must not return undefined")}return f}}return p},i)}return a.getInitialState=s,a}var bD="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",yD=(e=21)=>{let t="",r=e;for(;r--;)t+=bD[Math.random()*64|0];return t},vD=Symbol.for("rtk-slice-createasyncthunk");function xD(e,t){return`${e}/${t}`}function wD({creators:e}={}){var r;const t=(r=e==null?void 0:e.asyncThunk)==null?void 0:r[vD];return function(n){const{name:s,reducerPath:a=s}=n;if(!s)throw new Error(process.env.NODE_ENV==="production"?je(11):"`name` is a required option for createSlice");typeof process<"u"&&process.env.NODE_ENV==="development"&&n.initialState===void 0&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const i=(typeof n.reducers=="function"?n.reducers(ND()):n.reducers)||{},c=Object.keys(i),d={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},p={addCase(w,C){const E=typeof w=="string"?w:w.type;if(!E)throw new Error(process.env.NODE_ENV==="production"?je(12):"`context.addCase` cannot be called with an empty action type");if(E in d.sliceCaseReducersByType)throw new Error(process.env.NODE_ENV==="production"?je(13):"`context.addCase` cannot be called with two reducers for the same action type: "+E);return d.sliceCaseReducersByType[E]=C,p},addMatcher(w,C){return d.sliceMatchers.push({matcher:w,reducer:C}),p},exposeAction(w,C){return d.actionCreators[w]=C,p},exposeCaseReducer(w,C){return d.sliceCaseReducersByName[w]=C,p}};c.forEach(w=>{const C=i[w],E={reducerName:w,type:xD(s,w),createNotation:typeof n.reducers=="function"};ED(C)?kD(E,C,p,t):CD(E,C,p)});function u(){if(process.env.NODE_ENV!=="production"&&typeof n.extraReducers=="object")throw new Error(process.env.NODE_ENV==="production"?je(14):"The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[w={},C=[],E=void 0]=typeof n.extraReducers=="function"?yb(n.extraReducers):[n.extraReducers],k={...w,...d.sliceCaseReducersByType};return gD(n.initialState,_=>{for(let D in k)_.addCase(D,k[D]);for(let D of d.sliceMatchers)_.addMatcher(D.matcher,D.reducer);for(let D of C)_.addMatcher(D.matcher,D.reducer);E&&_.addDefaultCase(E)})}const f=w=>w,h=new Map,g=new WeakMap;let y;function b(w,C){return y||(y=u()),y(w,C)}function v(){return y||(y=u()),y.getInitialState()}function N(w,C=!1){function E(_){let D=_[w];if(typeof D>"u"){if(C)D=xs(g,E,v);else if(process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV==="production"?je(15):"selectSlice returned undefined for an uninjected slice reducer")}return D}function k(_=f){const D=xs(h,C,()=>new WeakMap);return xs(D,_,()=>{const A={};for(const[I,T]of Object.entries(n.selectors??{}))A[I]=SD(T,_,()=>xs(g,_,v),C);return A})}return{reducerPath:w,getSelectors:k,get selectors(){return k(E)},selectSlice:E}}const x={name:s,reducer:b,actions:d.actionCreators,caseReducers:d.sliceCaseReducersByName,getInitialState:v,...N(a),injectInto(w,{reducerPath:C,...E}={}){const k=C??a;return w.inject({reducerPath:k,reducer:b},E),{...x,...N(k,!0)}}};return x}}function SD(e,t,r,o){function n(s,...a){let i=t(s);if(typeof i>"u"){if(o)i=r();else if(process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV==="production"?je(16):"selectState returned undefined for an uninjected slice reducer")}return e(i,...a)}return n.unwrapped=e,n}var vb=wD();function ND(){function e(t,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...r}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...r){return t(...r)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:r}},asyncThunk:e}}function CD({type:e,reducerName:t,createNotation:r},o,n){let s,a;if("reducer"in o){if(r&&!_D(o))throw new Error(process.env.NODE_ENV==="production"?je(17):"Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");s=o.reducer,a=o.prepare}else s=o;n.addCase(e,s).exposeCaseReducer(t,s).exposeAction(t,a?cb(e,a):cb(e))}function ED(e){return e._reducerDefinitionType==="asyncThunk"}function _D(e){return e._reducerDefinitionType==="reducerWithPrepare"}function kD({type:e,reducerName:t},r,o,n){if(!n)throw new Error(process.env.NODE_ENV==="production"?je(18):"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:s,fulfilled:a,pending:i,rejected:c,settled:d,options:p}=r,u=n(e,s,p);o.exposeAction(t,u),a&&o.addCase(u.fulfilled,a),i&&o.addCase(u.pending,i),c&&o.addCase(u.rejected,c),d&&o.addMatcher(u.settled,d),o.exposeCaseReducer(t,{fulfilled:a||Ol,pending:i||Ol,rejected:c||Ol,settled:d||Ol})}function Ol(){}var AD=e=>"reducerPath"in e&&typeof e.reducerPath=="string",DD=e=>e.flatMap(t=>AD(t)?[[t.reducerPath,t.reducer]]:Object.entries(t)),Od=Symbol.for("rtk-state-proxy-original"),$D=e=>!!e&&!!e[Od],TD=new WeakMap,PD=(e,t,r)=>xs(TD,e,()=>new Proxy(e,{get:(o,n,s)=>{if(n===Od)return o;const a=Reflect.get(o,n,s);if(typeof a>"u"){const i=r[n];if(typeof i<"u")return i;const c=t[n];if(c){const d=c(void 0,{type:yD()});if(typeof d>"u")throw new Error(process.env.NODE_ENV==="production"?je(24):`The slice reducer for key "${n.toString()}" returned undefined when called for selector(). If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);return r[n]=d,d}}return a}})),ID=e=>{if(!$D(e))throw new Error(process.env.NODE_ENV==="production"?je(25):"original must be used on state Proxy");return e[Od]},OD={},MD=(e=OD)=>e;function LD(...e){const t=Object.fromEntries(DD(e)),r=()=>Object.keys(t).length?Ug(t):MD;let o=r();function n(c,d){return o(c,d)}n.withLazyLoadedSlices=()=>n;const s={},a=(c,d={})=>{const{reducerPath:p,reducer:u}=c,f=t[p];return!d.overrideExisting&&f&&f!==u?(typeof process<"u"&&process.env.NODE_ENV==="development"&&console.error(`called \`inject\` to override already-existing reducer ${p} without specifying \`overrideExisting: true\``),n):(d.overrideExisting&&f!==u&&delete s[p],t[p]=u,o=r(),n)},i=Object.assign(function(d,p){return function(f,...h){return d(PD(p?p(f,...h):f,t,s),...h)}},{original:ID});return Object.assign(n,{inject:a,selector:i})}function je(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. `}var Ml={exports:{}},Md={};/**
190
+ (See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}}),g.warnIfExceeded()),b}}}function Ml(e){return typeof e=="boolean"}var gT=()=>function(t){const{thunk:r=!0,immutableCheck:o=!0,serializableCheck:n=!0,actionCreatorCheck:a=!0}=t??{};let s=new fg;if(r&&(Ml(r)?s.push(sT):s.push(lT(r.extraArgument))),process.env.NODE_ENV!=="production"){if(o){let l={};Ml(o)||(l=o),s.unshift(mT(l))}if(n){let l={};Ml(n)||(l=n),s.push(bT(l))}if(a){let l={};Ml(a)||(l=a),s.unshift(fT(l))}}return s},yT="RTK_autoBatch",yg=e=>t=>{setTimeout(t,e)},vT=(e,t)=>r=>{let o=!1;const n=()=>{o||(o=!0,cancelAnimationFrame(a),clearTimeout(s),r())},a=e(n),s=setTimeout(n,t)},wT=(e={type:"raf"})=>t=>(...r)=>{const o=t(...r);let n=!0,a=!1,s=!1;const l=new Set,c=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?vT(window.requestAnimationFrame,100):yg(10):e.type==="callback"?e.queueNotification:yg(e.timeout),d=()=>{s=!1,a&&(a=!1,l.forEach(p=>p()))};return Object.assign({},o,{subscribe(p){const u=()=>n&&p(),f=o.subscribe(u);return l.add(p),()=>{f(),l.delete(p)}},dispatch(p){var u;try{return n=!((u=p==null?void 0:p.meta)!=null&&u[yT]),a=!n,a&&(s||(s=!0,c(d))),o.dispatch(p)}finally{n=!0}}})},xT=e=>function(r){const{autoBatch:o=!0}=r??{};let n=new fg(e);return o&&n.push(wT(typeof o=="object"?o:void 0)),n};function CT(e){const t=gT(),{reducer:r=void 0,middleware:o,devTools:n=!0,duplicateMiddlewareCheck:a=!0,preloadedState:s=void 0,enhancers:l=void 0}=e||{};let c;if(typeof r=="function")c=r;else if(ba(r))c=Wb(r);else throw new Error(process.env.NODE_ENV==="production"?Ze(1):"`reducer` is a required argument, and must be a function or an object of functions that can be passed to combineReducers");if(process.env.NODE_ENV!=="production"&&o&&typeof o!="function")throw new Error(process.env.NODE_ENV==="production"?Ze(2):"`middleware` field must be a callback");let d;if(typeof o=="function"){if(d=o(t),process.env.NODE_ENV!=="production"&&!Array.isArray(d))throw new Error(process.env.NODE_ENV==="production"?Ze(3):"when using a middleware builder function, an array of middleware must be returned")}else d=t();if(process.env.NODE_ENV!=="production"&&d.some(g=>typeof g!="function"))throw new Error(process.env.NODE_ENV==="production"?Ze(4):"each middleware provided to configureStore must be a function");if(process.env.NODE_ENV!=="production"&&a){let g=new Set;d.forEach(y=>{if(g.has(y))throw new Error(process.env.NODE_ENV==="production"?Ze(42):"Duplicate middleware references found when creating the store. Ensure that each middleware is only included once.");g.add(y)})}let p=bl;n&&(p=iT({trace:process.env.NODE_ENV!=="production",...typeof n=="object"&&n}));const u=U_(...d),f=xT(u);if(process.env.NODE_ENV!=="production"&&l&&typeof l!="function")throw new Error(process.env.NODE_ENV==="production"?Ze(5):"`enhancers` field must be a callback");let h=typeof l=="function"?l(f):f();if(process.env.NODE_ENV!=="production"&&!Array.isArray(h))throw new Error(process.env.NODE_ENV==="production"?Ze(6):"`enhancers` callback must return an array");if(process.env.NODE_ENV!=="production"&&h.some(g=>typeof g!="function"))throw new Error(process.env.NODE_ENV==="production"?Ze(7):"each enhancer provided to configureStore must be a function");process.env.NODE_ENV!=="production"&&d.length&&!h.includes(u)&&console.error("middlewares were provided, but middleware enhancer was not included in final enhancers - make sure to call `getDefaultEnhancers`");const b=p(...h);return Bb(c,s,b)}function vg(e){const t={},r=[];let o;const n={addCase(a,s){if(process.env.NODE_ENV!=="production"){if(r.length>0)throw new Error(process.env.NODE_ENV==="production"?Ze(26):"`builder.addCase` should only be called before calling `builder.addMatcher`");if(o)throw new Error(process.env.NODE_ENV==="production"?Ze(27):"`builder.addCase` should only be called before calling `builder.addDefaultCase`")}const l=typeof a=="string"?a:a.type;if(!l)throw new Error(process.env.NODE_ENV==="production"?Ze(28):"`builder.addCase` cannot be called with an empty action type");if(l in t)throw new Error(process.env.NODE_ENV==="production"?Ze(29):`\`builder.addCase\` cannot be called with two reducers for the same action type '${l}'`);return t[l]=s,n},addAsyncThunk(a,s){if(process.env.NODE_ENV!=="production"&&o)throw new Error(process.env.NODE_ENV==="production"?Ze(43):"`builder.addAsyncThunk` should only be called before calling `builder.addDefaultCase`");return s.pending&&(t[a.pending.type]=s.pending),s.rejected&&(t[a.rejected.type]=s.rejected),s.fulfilled&&(t[a.fulfilled.type]=s.fulfilled),s.settled&&r.push({matcher:a.settled,reducer:s.settled}),n},addMatcher(a,s){if(process.env.NODE_ENV!=="production"&&o)throw new Error(process.env.NODE_ENV==="production"?Ze(30):"`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return r.push({matcher:a,reducer:s}),n},addDefaultCase(a){if(process.env.NODE_ENV!=="production"&&o)throw new Error(process.env.NODE_ENV==="production"?Ze(31):"`builder.addDefaultCase` can only be called once");return o=a,n}};return e(n),[t,r,o]}function ST(e){return typeof e=="function"}function NT(e,t){if(process.env.NODE_ENV!=="production"&&typeof t=="object")throw new Error(process.env.NODE_ENV==="production"?Ze(8):"The object notation for `createReducer` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");let[r,o,n]=vg(t),a;if(ST(e))a=()=>pg(e());else{const l=pg(e);a=()=>l}function s(l=a(),c){let d=[r[c.type],...o.filter(({matcher:p})=>p(c)).map(({reducer:p})=>p)];return d.filter(p=>!!p).length===0&&(d=[n]),d.reduce((p,u)=>{if(u)if(io(p)){const h=u(p,c);return h===void 0?p:h}else{if(hr(p))return ig(p,f=>u(f,c));{const f=u(p,c);if(f===void 0){if(p===null)return p;throw Error("A case reducer on a non-draftable value must not return undefined")}return f}}return p},l)}return s.getInitialState=a,s}var ET="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",kT=(e=21)=>{let t="",r=e;for(;r--;)t+=ET[Math.random()*64|0];return t},AT=Symbol.for("rtk-slice-createasyncthunk");function _T(e,t){return`${e}/${t}`}function TT({creators:e}={}){var r;const t=(r=e==null?void 0:e.asyncThunk)==null?void 0:r[AT];return function(n){const{name:a,reducerPath:s=a}=n;if(!a)throw new Error(process.env.NODE_ENV==="production"?Ze(11):"`name` is a required option for createSlice");typeof process<"u"&&process.env.NODE_ENV==="development"&&n.initialState===void 0&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");const l=(typeof n.reducers=="function"?n.reducers($T()):n.reducers)||{},c=Object.keys(l),d={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},p={addCase(w,N){const k=typeof w=="string"?w:w.type;if(!k)throw new Error(process.env.NODE_ENV==="production"?Ze(12):"`context.addCase` cannot be called with an empty action type");if(k in d.sliceCaseReducersByType)throw new Error(process.env.NODE_ENV==="production"?Ze(13):"`context.addCase` cannot be called with two reducers for the same action type: "+k);return d.sliceCaseReducersByType[k]=N,p},addMatcher(w,N){return d.sliceMatchers.push({matcher:w,reducer:N}),p},exposeAction(w,N){return d.actionCreators[w]=N,p},exposeCaseReducer(w,N){return d.sliceCaseReducersByName[w]=N,p}};c.forEach(w=>{const N=l[w],k={reducerName:w,type:_T(a,w),createNotation:typeof n.reducers=="function"};MT(N)?IT(k,N,p,t):PT(k,N,p)});function u(){if(process.env.NODE_ENV!=="production"&&typeof n.extraReducers=="object")throw new Error(process.env.NODE_ENV==="production"?Ze(14):"The object notation for `createSlice.extraReducers` has been removed. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");const[w={},N=[],k=void 0]=typeof n.extraReducers=="function"?vg(n.extraReducers):[n.extraReducers],_={...w,...d.sliceCaseReducersByType};return NT(n.initialState,E=>{for(let D in _)E.addCase(D,_[D]);for(let D of d.sliceMatchers)E.addMatcher(D.matcher,D.reducer);for(let D of N)E.addMatcher(D.matcher,D.reducer);k&&E.addDefaultCase(k)})}const f=w=>w,h=new Map,b=new WeakMap;let g;function y(w,N){return g||(g=u()),g(w,N)}function v(){return g||(g=u()),g.getInitialState()}function S(w,N=!1){function k(E){let D=E[w];if(typeof D>"u"){if(N)D=xa(b,k,v);else if(process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV==="production"?Ze(15):"selectSlice returned undefined for an uninjected slice reducer")}return D}function _(E=f){const D=xa(h,N,()=>new WeakMap);return xa(D,E,()=>{const T={};for(const[O,$]of Object.entries(n.selectors??{}))T[O]=DT($,E,()=>xa(b,E,v),N);return T})}return{reducerPath:w,getSelectors:_,get selectors(){return _(k)},selectSlice:k}}const x={name:a,reducer:y,actions:d.actionCreators,caseReducers:d.sliceCaseReducersByName,getInitialState:v,...S(s),injectInto(w,{reducerPath:N,...k}={}){const _=N??s;return w.inject({reducerPath:_,reducer:y},k),{...x,...S(_,!0)}}};return x}}function DT(e,t,r,o){function n(a,...s){let l=t(a);if(typeof l>"u"){if(o)l=r();else if(process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV==="production"?Ze(16):"selectState returned undefined for an uninjected slice reducer")}return e(l,...s)}return n.unwrapped=e,n}var wg=TT();function $T(){function e(t,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...r}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...r){return t(...r)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:r}},asyncThunk:e}}function PT({type:e,reducerName:t,createNotation:r},o,n){let a,s;if("reducer"in o){if(r&&!OT(o))throw new Error(process.env.NODE_ENV==="production"?Ze(17):"Please use the `create.preparedReducer` notation for prepared action creators with the `create` notation.");a=o.reducer,s=o.prepare}else a=o;n.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,s?dg(e,s):dg(e))}function MT(e){return e._reducerDefinitionType==="asyncThunk"}function OT(e){return e._reducerDefinitionType==="reducerWithPrepare"}function IT({type:e,reducerName:t},r,o,n){if(!n)throw new Error(process.env.NODE_ENV==="production"?Ze(18):"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.");const{payloadCreator:a,fulfilled:s,pending:l,rejected:c,settled:d,options:p}=r,u=n(e,a,p);o.exposeAction(t,u),s&&o.addCase(u.fulfilled,s),l&&o.addCase(u.pending,l),c&&o.addCase(u.rejected,c),d&&o.addMatcher(u.settled,d),o.exposeCaseReducer(t,{fulfilled:s||Ol,pending:l||Ol,rejected:c||Ol,settled:d||Ol})}function Ol(){}var LT=e=>"reducerPath"in e&&typeof e.reducerPath=="string",FT=e=>e.flatMap(t=>LT(t)?[[t.reducerPath,t.reducer]]:Object.entries(t)),Od=Symbol.for("rtk-state-proxy-original"),VT=e=>!!e&&!!e[Od],GT=new WeakMap,zT=(e,t,r)=>xa(GT,e,()=>new Proxy(e,{get:(o,n,a)=>{if(n===Od)return o;const s=Reflect.get(o,n,a);if(typeof s>"u"){const l=r[n];if(typeof l<"u")return l;const c=t[n];if(c){const d=c(void 0,{type:kT()});if(typeof d>"u")throw new Error(process.env.NODE_ENV==="production"?Ze(24):`The slice reducer for key "${n.toString()}" returned undefined when called for selector(). If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);return r[n]=d,d}}return s}})),BT=e=>{if(!VT(e))throw new Error(process.env.NODE_ENV==="production"?Ze(25):"original must be used on state Proxy");return e[Od]},UT={},WT=(e=UT)=>e;function HT(...e){const t=Object.fromEntries(FT(e)),r=()=>Object.keys(t).length?Wb(t):WT;let o=r();function n(c,d){return o(c,d)}n.withLazyLoadedSlices=()=>n;const a={},s=(c,d={})=>{const{reducerPath:p,reducer:u}=c,f=t[p];return!d.overrideExisting&&f&&f!==u?(typeof process<"u"&&process.env.NODE_ENV==="development"&&console.error(`called \`inject\` to override already-existing reducer ${p} without specifying \`overrideExisting: true\``),n):(d.overrideExisting&&f!==u&&delete a[p],t[p]=u,o=r(),n)},l=Object.assign(function(d,p){return function(f,...h){return d(zT(p?p(f,...h):f,t,a),...h)}},{original:BT});return Object.assign(n,{inject:s,selector:l})}function Ze(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. `}var Il={exports:{}},Id={};/**
186
191
  * @license React
187
192
  * use-sync-external-store-with-selector.production.js
188
193
  *
@@ -190,7 +195,7 @@ Take a look at the reducer(s) handling this action type: ${h.type}.
190
195
  *
191
196
  * This source code is licensed under the MIT license found in the
192
197
  * LICENSE file in the root directory of this source tree.
193
- */var xb;function FD(){if(xb)return Md;xb=1;var e=P;function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:t,o=e.useSyncExternalStore,n=e.useRef,s=e.useEffect,a=e.useMemo,i=e.useDebugValue;return Md.useSyncExternalStoreWithSelector=function(c,d,p,u,f){var h=n(null);if(h.current===null){var g={hasValue:!1,value:null};h.current=g}else g=h.current;h=a(function(){function b(C){if(!v){if(v=!0,N=C,C=u(C),f!==void 0&&g.hasValue){var E=g.value;if(f(E,C))return x=E}return x=C}if(E=x,r(N,C))return E;var k=u(C);return f!==void 0&&f(E,k)?(N=C,E):(N=C,x=k)}var v=!1,N,x,w=p===void 0?null:p;return[function(){return b(d())},w===null?void 0:function(){return b(w())}]},[d,p,u,f]);var y=o(c,h[0],h[1]);return s(function(){g.hasValue=!0,g.value=y},[y]),i(y),y},Md}var Ld={};/**
198
+ */var xg;function jT(){if(xg)return Id;xg=1;var e=P;function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:t,o=e.useSyncExternalStore,n=e.useRef,a=e.useEffect,s=e.useMemo,l=e.useDebugValue;return Id.useSyncExternalStoreWithSelector=function(c,d,p,u,f){var h=n(null);if(h.current===null){var b={hasValue:!1,value:null};h.current=b}else b=h.current;h=s(function(){function y(N){if(!v){if(v=!0,S=N,N=u(N),f!==void 0&&b.hasValue){var k=b.value;if(f(k,N))return x=k}return x=N}if(k=x,r(S,N))return k;var _=u(N);return f!==void 0&&f(k,_)?(S=N,k):(S=N,x=_)}var v=!1,S,x,w=p===void 0?null:p;return[function(){return y(d())},w===null?void 0:function(){return y(w())}]},[d,p,u,f]);var g=o(c,h[0],h[1]);return a(function(){b.hasValue=!0,b.value=g},[g]),l(g),g},Id}var Ld={};/**
194
199
  * @license React
195
200
  * use-sync-external-store-with-selector.development.js
196
201
  *
@@ -198,7 +203,7 @@ Take a look at the reducer(s) handling this action type: ${h.type}.
198
203
  *
199
204
  * This source code is licensed under the MIT license found in the
200
205
  * LICENSE file in the root directory of this source tree.
201
- */var wb;function VD(){return wb||(wb=1,process.env.NODE_ENV!=="production"&&(function(){function e(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=P,r=typeof Object.is=="function"?Object.is:e,o=t.useSyncExternalStore,n=t.useRef,s=t.useEffect,a=t.useMemo,i=t.useDebugValue;Ld.useSyncExternalStoreWithSelector=function(c,d,p,u,f){var h=n(null);if(h.current===null){var g={hasValue:!1,value:null};h.current=g}else g=h.current;h=a(function(){function b(C){if(!v){if(v=!0,N=C,C=u(C),f!==void 0&&g.hasValue){var E=g.value;if(f(E,C))return x=E}return x=C}if(E=x,r(N,C))return E;var k=u(C);return f!==void 0&&f(E,k)?(N=C,E):(N=C,x=k)}var v=!1,N,x,w=p===void 0?null:p;return[function(){return b(d())},w===null?void 0:function(){return b(w())}]},[d,p,u,f]);var y=o(c,h[0],h[1]);return s(function(){g.hasValue=!0,g.value=y},[y]),i(y),y},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Ld}var Sb;function GD(){return Sb||(Sb=1,process.env.NODE_ENV==="production"?Ml.exports=FD():Ml.exports=VD()),Ml.exports}var zD=GD();function BD(e){e()}function UD(){let e=null,t=null;return{clear(){e=null,t=null},notify(){BD(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let o=e;for(;o;)r.push(o),o=o.next;return r},subscribe(r){let o=!0;const n=t={callback:r,next:null,prev:t};return n.prev?n.prev.next=n:e=n,function(){!o||e===null||(o=!1,n.next?n.next.prev=n.prev:t=n.prev,n.prev?n.prev.next=n.next:e=n.next)}}}}var Nb={notify(){},get:()=>[]};function WD(e,t){let r,o=Nb,n=0,s=!1;function a(y){p();const b=o.subscribe(y);let v=!1;return()=>{v||(v=!0,b(),u())}}function i(){o.notify()}function c(){g.onStateChange&&g.onStateChange()}function d(){return s}function p(){n++,r||(r=e.subscribe(c),o=UD())}function u(){n--,r&&n===0&&(r(),r=void 0,o.clear(),o=Nb)}function f(){s||(s=!0,p())}function h(){s&&(s=!1,u())}const g={addNestedSub:a,notifyNestedSubs:i,handleChangeWrapper:c,isSubscribed:d,trySubscribe:f,tryUnsubscribe:h,getListeners:()=>o};return g}var HD=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",jD=HD(),qD=()=>typeof navigator<"u"&&navigator.product==="ReactNative",YD=qD(),QD=()=>jD||YD?S.useLayoutEffect:S.useEffect,KD=QD(),Fd=Symbol.for("react-redux-context"),Vd=typeof globalThis<"u"?globalThis:{};function RD(){if(!S.createContext)return{};const e=Vd[Fd]??(Vd[Fd]=new Map);let t=e.get(S.createContext);return t||(t=S.createContext(null),process.env.NODE_ENV!=="production"&&(t.displayName="ReactRedux"),e.set(S.createContext,t)),t}var wo=RD();function XD(e){const{children:t,context:r,serverState:o,store:n}=e,s=S.useMemo(()=>{const c=WD(n),d={store:n,subscription:c,getServerState:o?()=>o:void 0};if(process.env.NODE_ENV==="production")return d;{const{identityFunctionCheck:p="once",stabilityCheck:u="once"}=e;return Object.assign(d,{stabilityCheck:u,identityFunctionCheck:p})}},[n,o]),a=S.useMemo(()=>n.getState(),[n]);KD(()=>{const{subscription:c}=s;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),a!==n.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[s,a]);const i=r||wo;return S.createElement(i.Provider,{value:s},t)}var JD=XD;function Gd(e=wo){return function(){const r=S.useContext(e);if(process.env.NODE_ENV!=="production"&&!r)throw new Error("could not find react-redux context value; please ensure the component is wrapped in a <Provider>");return r}}var Cb=Gd();function zd(e=wo){const t=e===wo?Cb:Gd(e),r=()=>{const{store:o}=t();return o};return Object.assign(r,{withTypes:()=>r}),r}var ZD=zd();function e$(e=wo){const t=e===wo?ZD:zd(e),r=()=>t().dispatch;return Object.assign(r,{withTypes:()=>r}),r}var t$=(e,t)=>e===t;function r$(e=wo){const t=e===wo?Cb:Gd(e),r=(o,n={})=>{const{equalityFn:s=t$}=typeof n=="function"?{equalityFn:n}:n;if(process.env.NODE_ENV!=="production"){if(!o)throw new Error("You must pass a selector to useSelector");if(typeof o!="function")throw new Error("You must pass a function as a selector to useSelector");if(typeof s!="function")throw new Error("You must pass a function as an equality function to useSelector")}const a=t(),{store:i,subscription:c,getServerState:d}=a,p=S.useRef(!0),u=S.useCallback({[o.name](h){const g=o(h);if(process.env.NODE_ENV!=="production"){const{devModeChecks:y={}}=typeof n=="function"?{}:n,{identityFunctionCheck:b,stabilityCheck:v}=a,{identityFunctionCheck:N,stabilityCheck:x}={stabilityCheck:v,identityFunctionCheck:b,...y};if(x==="always"||x==="once"&&p.current){const w=o(h);if(!s(g,w)){let C;try{throw new Error}catch(E){({stack:C}=E)}console.warn("Selector "+(o.name||"unknown")+` returned a different result when called with the same parameters. This can lead to unnecessary rerenders.
202
- Selectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization`,{state:h,selected:g,selected2:w,stack:C})}}if((N==="always"||N==="once"&&p.current)&&g===h){let w;try{throw new Error}catch(C){({stack:w}=C)}console.warn("Selector "+(o.name||"unknown")+` returned the root state when called. This can lead to unnecessary rerenders.
203
- Selectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.`,{stack:w})}p.current&&(p.current=!1)}return g}}[o.name],[o]),f=zD.useSyncExternalStoreWithSelector(c.addNestedSub,i.getState,d||i.getState,u,s);return S.useDebugValue(f),f};return Object.assign(r,{withTypes:()=>r}),r}const Nr=e=>S.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),o$=P.forwardRef((e,t)=>S.createElement("span",{...e.dragHandleAttributes,"data-testid":e.testID,ref:t,className:e.className,title:e.title},e.label)),n$=e=>{const{component:t,...r}=e,o=ze(r.schema.suppressStandardClassnames||ve.betweenRules,r.schema.classNames.betweenRules);return S.createElement("div",{className:o,"data-testid":xe.inlineCombinator},S.createElement(t,{...r,testID:xe.combinators}))},Eb={name:"",value:"",label:""},_b=e=>["atleast","atmost","exactly"].includes($e(e)??""),kb=[],s$=e=>{const{match:t,options:r,title:o,className:n,disabled:s,testID:a,schema:i,thresholdPlaceholder:c,selectorComponent:d=e.schema.controls.valueSelector,numericEditorComponent:p=e.schema.controls.valueEditor}=e,{thresholdNum:u,thresholdRule:f,thresholdSchema:h,handleChangeMode:g,handleChangeThreshold:y}=a$(e),b=P.useMemo(()=>c?{...Eb,placeholder:c}:Eb,[c]);return S.createElement(S.Fragment,null,S.createElement(d,{schema:i,testID:a,className:n,title:o,handleOnChange:g,disabled:s,value:t.mode,options:r,multiple:!1,listsAsArrays:!1,path:kb,level:0}),_b(t.mode)&&S.createElement(p,{skipHook:!0,testID:a,inputType:"number",title:o,className:n,disabled:s,handleOnChange:y,field:"",operator:"",value:u,valueSource:"value",fieldData:b,schema:h,path:kb,level:0,rule:f}))},a$=e=>{const{match:t,handleOnChange:r}=e,o=S.useMemo(()=>typeof t.threshold=="number"?Math.max(0,t.threshold):1,[t.threshold]);return{thresholdNum:o,thresholdRule:S.useMemo(()=>({field:"",operator:"=",value:o}),[o]),thresholdSchema:S.useMemo(()=>({...e.schema,parseNumbers:!0}),[e.schema]),handleChangeMode:P.useCallback(n=>{_b(n)&&typeof t.threshold!="number"?r({...t,mode:n,threshold:1}):r({...t,mode:n})},[r,t]),handleChangeThreshold:P.useCallback(n=>{r({...t,threshold:_e(n,{parseNumbers:!0})})},[r,t])}},l$=e=>{const t=S.useId();return S.createElement("label",{"data-testid":e.testID,className:e.className,title:e.title,htmlFor:t},S.createElement("input",{id:t,type:"checkbox",onChange:r=>e.handleOnChange(r.target.checked),checked:!!e.checked,disabled:e.disabled}),e.label)},Dt={errorInvalidIndependentCombinatorsProp:"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",errorUnnecessaryIndependentCombinatorsProp:"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",errorDeprecatedRuleGroupProps:"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.",errorDeprecatedRuleProps:"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.",errorBothQueryDefaultQuery:"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",errorUncontrolledToControlled:"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",errorControlledToUncontrolled:"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",errorEnabledDndWithoutReactDnD:"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.",errorDeprecatedDebugImport:"Importing from react-querybuilder/debug is deprecated. To enable Redux DevTools for React Query Builder's internal store, set globalThis.__RQB_DEVTOOLS__ = true."},ws=vb({name:"queries",initialState:{},reducers:{setQueryState:(e,{payload:{qbId:t,query:r}})=>{e[t]=r}},selectors:{getQuerySelectorById:(e,t)=>e[t]}}),Ab=S.createContext(null),Bd=vb({name:"warnings",initialState:{[Dt.errorInvalidIndependentCombinatorsProp]:!1,[Dt.errorUnnecessaryIndependentCombinatorsProp]:!1,[Dt.errorDeprecatedRuleGroupProps]:!1,[Dt.errorDeprecatedRuleProps]:!1,[Dt.errorBothQueryDefaultQuery]:!1,[Dt.errorUncontrolledToControlled]:!1,[Dt.errorControlledToUncontrolled]:!1,[Dt.errorEnabledDndWithoutReactDnD]:!1,[Dt.errorDeprecatedDebugImport]:!1},reducers:{rqbWarn:(e,{payload:t})=>{e[t]||(console.error(t),e[t]=!0)}}}),Db=LD(ws,Bd).withLazyLoadedSlices(),i$=e=>e$(e),c$=e=>zd(e),d$=e=>r$(e),u$=e=>({useRQB_INTERNAL_QueryBuilderDispatch:i$(e),useRQB_INTERNAL_QueryBuilderStore:c$(e),useRQB_INTERNAL_QueryBuilderSelector:d$(e)}),Ud=({payload:e,onQueryChange:t})=>r=>{r(ws.actions.setQueryState(e)),typeof t=="function"&&t(e.query)},Wd=u$(Ab),Hd=Wd.useRQB_INTERNAL_QueryBuilderDispatch,f$=Wd.useRQB_INTERNAL_QueryBuilderStore,p$=Wd.useRQB_INTERNAL_QueryBuilderSelector,{rqbWarn:h$}=Bd.actions,Jo=e=>t=>{setTimeout(()=>t(h$(e)))},m$={reducer:Db,preloadedState:{queries:ws.getInitialState(),warnings:Bd.getInitialState()},middleware:e=>e({serializableCheck:{ignoredActions:[ws.actions.setQueryState.type],ignoredPaths:[/^queries\b.*\.rules\.\d+\.value$/]}})},g$=e=>{const[t,r]=P.useState(e),[o,n]=P.useState(null);return e!==t&&(n(t),r(e)),o},b$=e=>{const t=Hd(),{defaultQuery:r,queryProp:o}=e,n=g$(!!o);process.env.NODE_ENV!=="production"&&(o&&r?t(Jo(Dt.errorBothQueryDefaultQuery)):n===!0&&!o&&r?t(Jo(Dt.errorControlledToUncontrolled)):n===!1&&o&&!r&&t(Jo(Dt.errorUncontrolledToControlled)))};function jd(e,t,r){const o=Hd();process.env.NODE_ENV!=="production"&&t&&(e==="independentCombinators"&&(r==="invalid"&&o(Jo(Dt.errorInvalidIndependentCombinatorsProp)),r==="unnecessary"&&o(Jo(Dt.errorUnnecessaryIndependentCombinatorsProp))),e==="rule"&&o(Jo(Dt.errorDeprecatedRuleProps)),e==="ruleGroup"&&o(Jo(Dt.errorDeprecatedRuleGroupProps)))}const $b=e=>{const{optionList:t,optionsMap:r,defaultOption:o}=P.useMemo(()=>vn({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:r,defaultField:o}},y$=e=>{const t=hD({...m$,devTools:e?{name:"React Query Builder"}:!1});return t.addSlice=r=>{Db.inject(r),t.dispatch({type:crypto.randomUUID().slice(0,8),meta:`Initializing state for slice "${r.name}"`})},t};let qd=null;function Tb(e){return qd||(qd=y$(globalThis==null?void 0:globalThis.__RQB_DEVTOOLS__)),qd}const Zo=e=>t=>ws.selectors.getQuerySelectorById({queries:t.queries},e),v$=(e,t)=>{const r=S.useContext(Yd);return p$(e,t)??(r==null?void 0:r.initialQuery)},x$={},w$={},S$=[],N$={},C$=()=>null,Pb=()=>"",en=()=>!0,E$=(...e)=>{console.log(...e)};function _$(e,t){const{query:r,defaultQuery:o,getValueEditorSeparator:n=C$,getRuleClassname:s=Pb,getRuleGroupClassname:a=Pb,onAddRule:i=en,onAddGroup:c=en,onMoveRule:d=en,onMoveGroup:p=en,onGroupRule:u=en,onGroupGroup:f=en,onRemove:h=en,onQueryChange:g,showCombinatorsBetweenRules:y=!1,showNotToggle:b=!1,showShiftActions:v=!1,showCloneButtons:N=!1,showLockButtons:x=!1,showMuteButtons:w=!1,suppressStandardClassnames:C=!1,resetOnFieldChange:E=!0,resetOnOperatorChange:k=!1,autoSelectField:_=!0,autoSelectOperator:D=!0,autoSelectValue:A=!0,addRuleToNewGroups:I=!1,listsAsArrays:T=!1,parseNumbers:L=!1,disabled:F=!1,validator:B,onLog:G=E$,idGenerator:z,accessibleDescriptionGenerator:H=sA}=e,{qbId:V,rqbContext:W,fields:pe,fieldMap:U,combinators:Q,getParameters:Ce,getOperatorsMain:oe,getMatchModesMain:ye,getRuleDefaultOperator:R,getSubQueryBuilderPropsMain:ce,getValueEditorTypeMain:re,getValueSourcesMain:Ae,getValuesMain:we,getRuleDefaultValue:ue,getInputTypeMain:J,createRule:ne,createRuleGroup:fe}=t,{controlClassnames:ke,controlElements:Re,debugMode:rt,enableDragAndDrop:st,enableMountQueryChange:Xe,translations:Ee}=W,yt=!!y,fr=!!b,Yt=!!v,It=!!N,Me=!!x,Et=!!w,Ot=!!E,Hr=!!k,rr=!!_,$=!!D,O=!!A,M=!!I,Y=!!T,q=!!C,Z=(e.maxLevels??0)>0?Number(e.maxLevels):1/0,j=P.useCallback((...he)=>{rt&&G(...he)},[rt,G]);b$({defaultQuery:o,queryProp:r});const X=f$(),ie=Hd(),Oe=P.useMemo(()=>Zo(V),[V]),qe=v$(Oe),Mt=P.useCallback(()=>Oe(X.getState()),[X,Oe]),Pe=P.useMemo(()=>fe(),[fe]),et=r??qe??o??Pe,lt=et.id?et:ml(et,{idGenerator:z}),[_r]=P.useState(lt),kn=P.useMemo(()=>({...W,initialQuery:_r}),[W,_r]);P.useEffect(()=>{r&&!Object.is(r,qe)&&ie(Ud({payload:{qbId:V,query:r},onQueryChange:void 0}))},[r,V,qe,ie]);const pr=P.useMemo(()=>yn(lt),[lt]),An=!!e.independentCombinators&&!pr;jd("independentCombinators",An||!An&&(e.independentCombinators??"not present")!=="not present",An?"invalid":"unnecessary");const As=P.useRef(!1);P.useEffect(()=>{As.current||(As.current=!0,ie(Ud({payload:{qbId:V,query:lt},onQueryChange:Xe&&typeof g=="function"?g:void 0})))},[Xe,g,V,ie,lt]);const Lt=P.useCallback(he=>{ie(Ud({payload:{qbId:V,query:he},onQueryChange:g}))},[g,V,ie]),Dn=Array.isArray(F)&&F||S$,vt=F===!0,Rl=lt.disabled||Dn.some(he=>he.length===0),Ds=P.useCallback((he,Fe,He)=>{const Ge=Zo(V)(X.getState());if(!Ge)return;if(Nn(Fe,Ge)||vt){j({qbId:V,type:bt.parentPathDisabled,rule:he,parentPath:Fe,query:Ge});return}const Ve=i(he,Fe,Ge,He);if(!Ve){j({qbId:V,type:bt.onAddRuleFalse,rule:he,parentPath:Fe,query:Ge});return}const _t=Ve===!0?he:Ve,zt=Mg(Ge,_t,Fe,{combinators:Q,combinatorPreceding:_t.combinatorPreceding??void 0,idGenerator:z});j({qbId:V,type:bt.add,query:Ge,newQuery:zt,newRule:_t,parentPath:Fe}),Lt(zt)},[Q,Lt,z,j,i,V,X,vt]),$s=P.useCallback((he,Fe,He)=>{if(Fe.length>=Z)return;const Ge=Zo(V)(X.getState());if(!Ge)return;if(Nn(Fe,Ge)||vt){j({qbId:V,type:bt.parentPathDisabled,ruleGroup:he,parentPath:Fe,query:Ge});return}const Ve=c(he,Fe,Ge,He);if(!Ve){j({qbId:V,type:bt.onAddGroupFalse,ruleGroup:he,parentPath:Fe,query:Ge});return}const _t=Ve===!0?he:Ve,zt=Mg(Ge,_t,Fe,{combinators:Q,combinatorPreceding:_t.combinatorPreceding??void 0,idGenerator:z});j({qbId:V,type:bt.add,query:Ge,newQuery:zt,newGroup:_t,parentPath:Fe}),Lt(zt)},[Q,Lt,z,j,Z,c,V,X,vt]),Ts=P.useCallback((he,Fe,He)=>{const Ge=Zo(V)(X.getState());if(!Ge)return;if(Nn(He,Ge)&&he!=="disabled"||vt){j({qbId:V,type:bt.pathDisabled,path:He,prop:he,value:Fe,query:Ge});return}const Ve=yA(Ge,he,Fe,He,{resetOnFieldChange:Ot,resetOnOperatorChange:Hr,getRuleDefaultOperator:R,getValueSources:Ae,getRuleDefaultValue:ue,getMatchModes:ye});j({qbId:V,type:bt.update,query:Ge,newQuery:Ve,prop:he,value:Fe,path:He}),Lt(Ve)},[Lt,ye,R,ue,Ae,j,V,X,vt,Ot,Hr]),$n=P.useCallback((he,Fe)=>{const He=Zo(V)(X.getState());if(!He)return;if(Nn(he,He)||vt){j({qbId:V,type:bt.pathDisabled,path:he,query:He});return}const Ge=ht(he,He);if(Ge)if(h(Ge,he,He,Fe)){const Ve=xA(He,he);j({qbId:V,type:bt.remove,query:He,newQuery:Ve,path:he,ruleOrGroup:Ge}),Lt(Ve)}else j({qbId:V,type:bt.onRemoveFalse,ruleOrGroup:Ge,path:he,query:He})},[Lt,j,h,V,X,vt]),Ps=P.useCallback((he,Fe,He,Ge)=>{const Ve=Zo(V)(X.getState());if(!Ve)return;if(Nn(he,Ve)||vt){j({qbId:V,type:bt.pathDisabled,oldPath:he,newPath:Fe,query:Ve});return}const _t=SA(Ve,he,Fe,{clone:He,combinators:Q,idGenerator:z}),zt=ht(he,Ve),Co=ge(zt),jr=(Co?p:d)(zt,he,Fe,Ve,_t,{clone:He,combinators:Q},Ge);if(!jr){j({qbId:V,type:Co?bt.onMoveGroupFalse:bt.onMoveRuleFalse,ruleOrGroup:zt,oldPath:he,newPath:Fe,clone:He,query:Ve,nextQuery:_t});return}const Eo=ge(jr)?jr:_t;j({qbId:V,type:bt.move,query:Ve,newQuery:Eo,oldPath:he,newPath:Fe,clone:He}),Lt(Eo)},[Q,Lt,z,j,p,d,V,X,vt]),Is=P.useCallback((he,Fe,He,Ge)=>{const Ve=Zo(V)(X.getState());if(!Ve)return;if(Nn(he,Ve)||vt){j({qbId:V,type:bt.pathDisabled,sourcePath:he,targetPath:Fe,query:Ve});return}const _t=CA(Ve,he,Fe,{clone:He,combinators:Q,idGenerator:z}),zt=ht(he,Ve),Co=ge(zt),jr=(Co?f:u)(zt,he,Fe,Ve,_t,{clone:He,combinators:Q},Ge);if(!jr){j({qbId:V,type:Co?bt.onGroupGroupFalse:bt.onGroupRuleFalse,ruleOrGroup:zt,sourcePath:he,targetPath:Fe,clone:He,query:Ve,nextQuery:_t});return}const Eo=ge(jr)?jr:_t;j({qbId:V,type:bt.group,query:Ve,newQuery:Eo,sourcePath:he,targetPath:Fe,clone:He}),Lt(Eo)},[Q,Lt,z,j,f,u,V,X,vt]),{validationResult:hr,validationMap:Os}=P.useMemo(()=>{const he=typeof B=="function"&&lt?B(lt):x$;return{validationResult:he,validationMap:typeof he=="boolean"?w$:he}},[lt,B]),Xl=st?"enabled":"disabled",Jl=pr||yt?"enabled":"disabled",Zl=P.useMemo(()=>typeof lt.combinator=="string"?{combinator:lt.combinator}:N$,[lt.combinator]),ei=P.useMemo(()=>ze(q||ve.queryBuilder,ze(ke.queryBuilder),vt&&ke.disabled,typeof hr=="boolean"&&hr&&ke.valid,typeof hr=="boolean"&&!hr&&ke.invalid,q||{[ve.disabled]:vt,[ve.valid]:typeof hr=="boolean"&&hr,[ve.invalid]:typeof hr=="boolean"&&!hr}),[ke.disabled,ke.invalid,ke.queryBuilder,ke.valid,vt,q,hr]),Ms=P.useCallback(he=>fe(he??pr),[fe,pr]),ti=P.useMemo(()=>({addRuleToNewGroups:M,accessibleDescriptionGenerator:H,autoSelectField:rr,autoSelectOperator:$,autoSelectValue:O,classNames:ke,combinators:Q,getParameters:Ce,controls:Re,createRule:ne,createRuleGroup:Ms,disabledPaths:Dn,enableDragAndDrop:st,fieldMap:U,fields:pe,dispatchQuery:Lt,getQuery:Mt,getInputType:J,getOperators:oe,getMatchModes:ye,getRuleClassname:s,getRuleDefaultOperator:R,getRuleDefaultValue:ue,getRuleGroupClassname:a,getSubQueryBuilderProps:ce,getValueEditorSeparator:n,getValueEditorType:re,getValues:we,getValueSources:Ae,independentCombinators:pr,listsAsArrays:Y,maxLevels:Z,parseNumbers:L,qbId:V,resetOnFieldChange:Ot,resetOnOperatorChange:Hr,showCloneButtons:It,showCombinatorsBetweenRules:yt,showLockButtons:Me,showMuteButtons:Et,showNotToggle:fr,showShiftActions:Yt,suppressStandardClassnames:q,validationMap:Os}),[H,M,rr,$,O,Q,ke,Re,ne,Ms,Dn,Lt,st,U,pe,J,oe,ye,Mt,s,R,ue,a,ce,n,re,we,Ae,Ce,pr,Y,Z,L,V,Ot,Hr,It,yt,Me,Et,fr,Yt,q,Os]);return{actions:P.useMemo(()=>({moveRule:Ps,onGroupAdd:$s,onGroupRemove:$n,onPropChange:Ts,onRuleAdd:Ds,onRuleRemove:$n,groupRule:Is}),[Is,Ps,$s,Ts,Ds,$n]),rootGroup:lt,rootGroupDisabled:Rl,queryDisabled:vt,rqbContext:kn,schema:ti,translations:Ee,wrapperClassName:ei,dndEnabledAttr:Xl,inlineCombinatorsAttr:Jl,combinatorPropObject:Zl}}const k$=e=>{const[t]=P.useState(lr),{fields:r,baseField:o,operators:n,baseOperator:s,combinators:a,baseCombinator:i,getParameters:c,translations:d,enableMountQueryChange:p=!0,controlClassnames:u,controlElements:f,getDefaultField:h,getDefaultOperator:g,getDefaultValue:y,getMatchModes:b,getOperators:v,getSubQueryBuilderProps:N,getValueEditorType:x,getValueSources:w,getInputType:C,getValues:E,autoSelectField:k=!0,autoSelectOperator:_=!0,autoSelectValue:D=!0,addRuleToNewGroups:A=!1,enableDragAndDrop:I,listsAsArrays:T=!1,debugMode:L=!1,idGenerator:F=lr}=e,[B]=P.useState(e.query??e.defaultQuery),G=z$({controlClassnames:u,controlElements:f,debugMode:L,enableDragAndDrop:I,enableMountQueryChange:p,translations:d,initialQuery:B,qbId:t,finalize:!0}),{translations:z}=G,{fields:H,fieldMap:V}=$b({fields:r,baseField:o,autoSelectField:k,translations:z}),{optionList:W}=P.useMemo(()=>vn({optionList:a??ns,labelMap:sk,baseOption:i,autoSelectOption:!0}),[i,a]),pe=P.useCallback((J,ne,fe)=>vn({optionList:(c==null?void 0:c(J,ne,fe))??[],autoSelectOption:!0}).optionList,[c]),{optionList:U}=P.useMemo(()=>vn({optionList:n??ak,placeholder:z.operators,labelMap:Om,baseOption:s,autoSelectOption:_}),[_,s,n,z.operators]),Q=P.useCallback((J,{fieldData:ne})=>vn({optionList:(ne==null?void 0:ne.operators)??(v==null?void 0:v(J,{fieldData:ne}))??U,placeholder:z.operators,baseOption:s,labelMap:Om,autoSelectOption:_}).optionList,[_,s,v,U,z.operators]),Ce=P.useCallback(J=>{const ne=V[J];return ne!=null&&ne.defaultOperator?ne.defaultOperator:g?typeof g=="function"?g(J,{fieldData:ne}):g:Ct(Q(J,{fieldData:ne})??[])??""},[V,g,Q]),oe=P.useCallback((J,ne,{fieldData:fe})=>fe.valueEditorType?typeof fe.valueEditorType=="function"?fe.valueEditorType(ne):fe.valueEditorType:(x==null?void 0:x(J,ne,{fieldData:fe}))??"text",[x]),ye=P.useCallback((J,ne,fe)=>Tg(V[J],ne,w),[V,w]),R=P.useCallback((J,ne)=>lA(V[J],b),[V,b]),ce=P.useCallback((J,ne)=>(N==null?void 0:N(J,ne))??{},[N]),re=P.useCallback((J,ne,{fieldData:fe})=>vn({optionList:(fe==null?void 0:fe.values)??(E==null?void 0:E(J,ne,{fieldData:fe}))??[],placeholder:z.values,autoSelectOption:D}).optionList,[D,E,z.values]),Ae=P.useCallback(J=>iA(J,{fieldData:V[J.field]??{},fields:H,getParameters:(ne,fe,ke)=>pe(ne,fe,ke),listsAsArrays:T,getValueEditorType:(ne,fe,ke)=>oe(ne,fe,ke),getValues:(ne,fe,ke)=>re(ne,fe,ke),getDefaultValue:y&&((ne,fe)=>y(ne,fe))}),[V,H,y,oe,re,T,pe]),we=P.useCallback((J,ne,{fieldData:fe})=>{if(C){const ke=C(J,ne,{fieldData:fe});if(ke)return ke}return"text"},[C]),ue=P.useCallback(()=>{let J="";const ne=H;/* v8 ignore else -- @preserve */if((ne==null?void 0:ne.length)>0&&ne[0]){const Xe=Ct(ne);/* v8 ignore else -- @preserve */Xe&&(J=Xe)}if(h)if(typeof h=="function"){const Xe=h(ne);/* v8 ignore else -- @preserve */Xe&&(J=Xe)}else J=h;const fe=Ce(J),ke=Ct(ye(J,fe,{fieldData:We(ne,J)}))??"value",Re=Ct(R(J,{fieldData:We(ne,J)})),rt={id:F(),field:J,operator:fe,valueSource:ke,value:"",...Re?{match:{mode:Re,threshold:1}}:null},st=Ae(rt);return{...rt,value:st}},[H,h,R,Ce,Ae,ye,F]);return{qbId:t,rqbContext:G,fields:H,fieldMap:V,combinators:W,getParameters:pe,getMatchModesMain:R,getOperatorsMain:Q,getRuleDefaultOperator:Ce,getSubQueryBuilderPropsMain:ce,getValueEditorTypeMain:oe,getValueSourcesMain:ye,getValuesMain:re,getRuleDefaultValue:Ae,getInputTypeMain:we,createRule:ue,createRuleGroup:P.useCallback(J=>J?{id:F(),rules:A?[ue()]:[],not:!1}:{id:F(),rules:A?[ue()]:[],combinator:Ct(W)??"",not:!1},[A,W,ue,F])}},Ib=e=>_$(e,k$(e)),Yd=P.createContext({}),A$=S.memo(function(t){const r=Ob(t),{previewRef:o,dropRef:n,schema:{controls:{ruleGroupBodyElements:s,ruleGroupHeaderElements:a}}}=r,i=ct(r.addRule),c=ct(r.addGroup),d=ct(r.cloneGroup),p=ct(r.toggleLockGroup),u=ct(r.toggleMuteGroup),f=ct(r.removeGroup),h=ct(r.shiftGroupUp),g=ct(r.shiftGroupDown),y=P.useMemo(()=>({addRule:i,addGroup:c,cloneGroup:d,toggleLockGroup:p,toggleMuteGroup:u,removeGroup:f,shiftGroupUp:h,shiftGroupDown:g}),[i,c,d,p,u,f,h,g]);return S.createElement("div",{ref:o,title:r.accessibleDescription,className:r.outerClassName,"data-testid":xe.ruleGroup,"data-not":r.ruleGroup.not?"true":void 0,"data-dragmonitorid":r.dragMonitorId,"data-dropmonitorid":r.dropMonitorId,"data-rule-group-id":r.id,"data-level":r.path.length,"data-path":JSON.stringify(r.path)},S.createElement("div",{ref:n,className:r.classNames.header},S.createElement(a,{...r,...y})),S.createElement("div",{className:r.classNames.body},S.createElement(s,{...r,...y})))}),D$=S.memo(function(t){const{dragRef:r,schema:{controls:{shiftActions:o,dragHandle:n,combinatorSelector:s,notToggle:a,addRuleAction:i,addGroupAction:c,cloneGroupAction:d,lockGroupAction:p,muteGroupAction:u,removeGroupAction:f}}}=t,h=P.useMemo(()=>({level:t.path.length,path:t.path,disabled:t.disabled,context:t.context,validation:t.validationResult,schema:t.schema}),[t.path,t.disabled,t.context,t.validationResult,t.schema]),g=P.useMemo(()=>t.schema.showShiftActions?{shiftUp:t.translations.shiftActionUp.title,shiftDown:t.translations.shiftActionDown.title}:void 0,[t.schema.showShiftActions,t.translations]),y=P.useMemo(()=>t.schema.showShiftActions?{shiftUp:t.translations.shiftActionUp.label,shiftDown:t.translations.shiftActionDown.label}:void 0,[t.schema.showShiftActions,t.translations]);return S.createElement(P.Fragment,null,t.schema.showShiftActions&&t.path.length>0&&S.createElement(o,{key:xe.shiftActions,...h,testID:xe.shiftActions,titles:g,labels:y,className:t.classNames.shiftActions,shiftUp:t.shiftGroupUp,shiftDown:t.shiftGroupDown,shiftUpDisabled:t.shiftUpDisabled,shiftDownDisabled:t.shiftDownDisabled,ruleOrGroup:t.ruleGroup}),t.path.length>0&&t.schema.enableDragAndDrop&&S.createElement(n,{key:xe.dragHandle,...h,testID:xe.dragHandle,ref:r,title:t.translations.dragHandle.title,label:t.translations.dragHandle.label,className:t.classNames.dragHandle,dragHandleAttributes:t.dragHandleAttributes,ruleOrGroup:t.ruleGroup}),!t.schema.showCombinatorsBetweenRules&&!t.schema.independentCombinators&&S.createElement(s,{key:xe.combinators,...h,testID:xe.combinators,options:t.schema.combinators,value:t.combinator,title:t.translations.combinators.title,className:t.classNames.combinators,handleOnChange:t.onCombinatorChange,rules:t.ruleGroup.rules,ruleGroup:t.ruleGroup}),t.schema.showNotToggle&&S.createElement(a,{key:xe.notToggle,...h,testID:xe.notToggle,className:t.classNames.notToggle,title:t.translations.notToggle.title,label:t.translations.notToggle.label,checked:t.ruleGroup.not,handleOnChange:t.onNotToggleChange,ruleGroup:t.ruleGroup}),S.createElement(i,{key:xe.addRule,...h,testID:xe.addRule,label:t.translations.addRule.label,title:t.translations.addRule.title,className:t.classNames.addRule,handleOnClick:t.addRule,rules:t.ruleGroup.rules,ruleOrGroup:t.ruleGroup}),t.schema.maxLevels>t.path.length&&S.createElement(c,{key:xe.addGroup,...h,testID:xe.addGroup,label:t.translations.addGroup.label,title:t.translations.addGroup.title,className:t.classNames.addGroup,handleOnClick:t.addGroup,rules:t.ruleGroup.rules,ruleOrGroup:t.ruleGroup}),t.schema.showCloneButtons&&t.path.length>0&&S.createElement(d,{key:xe.cloneGroup,...h,testID:xe.cloneGroup,label:t.translations.cloneRuleGroup.label,title:t.translations.cloneRuleGroup.title,className:t.classNames.cloneGroup,handleOnClick:t.cloneGroup,rules:t.ruleGroup.rules,ruleOrGroup:t.ruleGroup}),t.schema.showLockButtons&&S.createElement(p,{key:xe.lockGroup,...h,testID:xe.lockGroup,label:t.translations.lockGroup.label,title:t.translations.lockGroup.title,className:t.classNames.lockGroup,handleOnClick:t.toggleLockGroup,rules:t.ruleGroup.rules,disabledTranslation:t.parentDisabled?void 0:t.translations.lockGroupDisabled,ruleOrGroup:t.ruleGroup}),t.schema.showMuteButtons&&S.createElement(u,{key:xe.muteGroup,...h,testID:xe.muteGroup,label:t.ruleGroup.muted?t.translations.unmuteGroup.label:t.translations.muteGroup.label,title:t.ruleGroup.muted?t.translations.unmuteGroup.title:t.translations.muteGroup.title,className:t.classNames.muteGroup,handleOnClick:t.toggleMuteGroup,rules:t.ruleGroup.rules,ruleOrGroup:t.ruleGroup}),t.path.length>0&&S.createElement(f,{key:xe.removeGroup,...h,testID:xe.removeGroup,label:t.translations.removeGroup.label,title:t.translations.removeGroup.title,className:t.classNames.removeGroup,handleOnClick:t.removeGroup,rules:t.ruleGroup.rules,ruleOrGroup:t.ruleGroup}))}),$$=S.memo(function(t){const{schema:{controls:{combinatorSelector:r,inlineCombinator:o,ruleGroup:n,rule:s}}}=t;return S.createElement(P.Fragment,null,t.ruleGroup.rules.map((a,i,{length:c})=>{const d=t.pathsMemo[i],p=d.path,u=d.disabled||typeof a!="string"&&a.disabled,f=Qo([0],p),h=t.path.length===0&&i===c-1,g=typeof a=="string"?[...p,a].join("-"):a.id;return S.createElement(P.Fragment,{key:g},i>0&&!t.schema.independentCombinators&&t.schema.showCombinatorsBetweenRules&&S.createElement(o,{key:xe.inlineCombinator,options:t.schema.combinators,value:t.combinator,title:t.translations.combinators.title,className:t.classNames.combinators,handleOnChange:t.onCombinatorChange,rules:t.ruleGroup.rules,level:t.path.length,context:t.context,validation:t.validationResult,component:r,path:p,disabled:t.disabled,schema:t.schema,ruleGroup:t.ruleGroup}),typeof a=="string"?S.createElement(o,{key:`${xe.inlineCombinator}-independent`,options:t.schema.combinators,value:a,title:t.translations.combinators.title,className:t.classNames.combinators,handleOnChange:y=>t.onIndependentCombinatorChange(y,i),rules:t.ruleGroup.rules,level:t.path.length,context:t.context,validation:t.validationResult,component:r,path:p,disabled:u,schema:t.schema,ruleGroup:t.ruleGroup}):ge(a)?S.createElement(n,{key:xe.ruleGroup,id:a.id,schema:t.schema,actions:t.actions,path:p,translations:t.translations,ruleGroup:a,rules:a.rules,combinator:Vt(a)?a.combinator:void 0,not:!!a.not,disabled:u,parentDisabled:t.parentDisabled||t.disabled,parentMuted:t.parentMuted||t.muted,shiftUpDisabled:f,shiftDownDisabled:h,context:t.context}):S.createElement(s,{key:xe.rule,id:a.id,rule:a,field:a.field,operator:a.operator,value:a.value,valueSource:a.valueSource,schema:t.schema,actions:t.actions,path:p,disabled:u,parentDisabled:t.parentDisabled||t.disabled,parentMuted:t.parentMuted||t.muted,translations:t.translations,shiftUpDisabled:f,shiftDownDisabled:h,context:t.context}))}))}),Ob=e=>{const{id:t,path:r,ruleGroup:o,schema:{qbId:n,accessibleDescriptionGenerator:s,classNames:a,combinators:i,createRule:c,createRuleGroup:d,disabledPaths:p,independentCombinators:u,validationMap:f,enableDragAndDrop:h,getRuleGroupClassname:g,suppressStandardClassnames:y},actions:{onGroupAdd:b,onGroupRemove:v,onPropChange:N,onRuleAdd:x,moveRule:w},disabled:C,parentDisabled:E,parentMuted:k,shiftUpDisabled:_,shiftDownDisabled:D,combinator:A,rules:I,not:T,dropEffect:L="move",groupItems:F=!1,dragMonitorId:B="",dropMonitorId:G="",previewRef:z=null,dragRef:H=null,dropRef:V=null,isDragging:W=!1,isOver:pe=!1,dropNotAllowed:U=!1}=e;jd("ruleGroup",!o),Lb(h,!!(B||G||z||H||V));const Q=!!E||!!C,Ce=!!k||!!(o!=null&&o.muted),oe=P.useMemo(()=>o&&Vt(o)?o.combinator:o?Ct(i):A??Ct(i),[A,i,o]),ye=P.useMemo(()=>{if(o){if(o.combinator===oe||u)return o;const Me=structuredClone(o);return Me.combinator=oe,Me}return{rules:I,not:T}},[oe,u,T,o,I]),R=P.useMemo(()=>({header:ze(y||ve.header,a.header,pe&&L==="copy"&&a.dndCopy,U&&a.dndDropNotAllowed,y||{[ve.dndOver]:pe,[ve.dndCopy]:pe&&L==="copy",[ve.dndDropNotAllowed]:U}),shiftActions:ze(y||ve.shiftActions,a.shiftActions),dragHandle:ze(y||ve.dragHandle,a.dragHandle),combinators:ze(y||ve.combinators,a.valueSelector,a.combinators),notToggle:ze(y||ve.notToggle,a.notToggle),addRule:ze(y||ve.addRule,a.actionElement,a.addRule),addGroup:ze(y||ve.addGroup,a.actionElement,a.addGroup),cloneGroup:ze(y||ve.cloneGroup,a.actionElement,a.cloneGroup),lockGroup:ze(y||ve.lockGroup,a.actionElement,a.lockGroup),muteGroup:ze(y||ve.muteGroup,a.actionElement,a.muteGroup),removeGroup:ze(y||ve.removeGroup,a.actionElement,a.removeGroup),body:ze(y||ve.body,a.body)}),[a.actionElement,a.addGroup,a.addRule,a.body,a.cloneGroup,a.combinators,a.dndCopy,a.dndDropNotAllowed,a.dragHandle,a.header,a.lockGroup,a.muteGroup,a.notToggle,a.removeGroup,a.shiftActions,a.valueSelector,L,U,pe,y]),ce=P.useCallback(Me=>{Q||N("combinator",Me,r)},[Q,N,r]),re=P.useCallback((Me,Et,Ot)=>{Q||N("combinator",Me,[...r,Et])},[Q,N,r]),Ae=P.useCallback((Me,Et)=>{Q||N("not",Me,r)},[Q,N,r]),we=P.useCallback((Me,Et)=>{if(!Q){const Ot=c();x(Ot,r,Et)}},[c,Q,x,r]),ue=P.useCallback((Me,Et)=>{if(!Q){const Ot=d();b(Ot,r,Et)}},[d,Q,b,r]),J=P.useCallback(()=>{if(!Q){const Me=[...it(r),r.at(-1)+1];w(r,Me,!0)}},[Q,w,r]),ne=P.useCallback((Me,Et)=>{!Q&&!_&&w(r,"up",Me==null?void 0:Me.altKey)},[Q,w,r,_]),fe=P.useCallback((Me,Et)=>{!Q&&!D&&w(r,"down",Me==null?void 0:Me.altKey)},[Q,w,r,D]),ke=P.useCallback(()=>{N("disabled",!Q,r)},[Q,N,r]),Re=P.useCallback(()=>{N("muted",!ye.muted,r)},[ye.muted,N,r]),rt=P.useCallback(()=>{Q||v(r)},[Q,v,r]),st=f[t??""],Xe=P.useMemo(()=>Dg(st),[st]),Ee=P.useMemo(()=>{var Me;return u?null:((Me=We(i,oe))==null?void 0:Me.className)??""},[oe,i,u]),yt=P.useMemo(()=>g(ye),[g,ye]),fr=P.useMemo(()=>ze(yt,Ee,y||ve.ruleGroup,a.ruleGroup,Q&&a.disabled,Ce&&a.muted,W&&a.dndDragging,pe&&F&&a.dndGroup,y||{[ve.disabled]:Q,[ve.muted]:Ce,[ve.dndDragging]:W,[ve.dndGroup]:pe&&F},Xe),[a.disabled,a.muted,a.dndDragging,a.dndGroup,a.ruleGroup,Ee,Q,Ce,F,W,pe,yt,y,Xe]),Yt=B$({disabled:Q,disabledPaths:p,path:r,nestedArray:ye.rules}),It=P.useMemo(()=>s({path:r,qbId:n}),[s,r,n]);return{...e,addGroup:ue,addRule:we,accessibleDescription:It,classNames:R,cloneGroup:J,combinator:oe,disabled:Q,dragMonitorId:B,dragRef:H,dropMonitorId:G,dropRef:V,isDragging:W,isOver:pe,muted:Ce,onCombinatorChange:ce,onGroupAdd:b,onIndependentCombinatorChange:re,onNotToggleChange:Ae,outerClassName:fr,parentDisabled:E,pathsMemo:Yt,previewRef:z,removeGroup:rt,ruleGroup:ye,shiftGroupUp:ne,shiftGroupDown:fe,toggleLockGroup:ke,toggleMuteGroup:Re,validationClassName:Xe,validationResult:st}},T$=e=>{var t,r,o,n;return S.createElement("div",{"data-testid":e.testID,className:e.className},S.createElement("button",{type:"button",disabled:e.disabled||e.shiftUpDisabled,onClick:e.shiftUp,title:(t=e.titles)==null?void 0:t.shiftUp},(r=e.labels)==null?void 0:r.shiftUp),S.createElement("button",{type:"button",disabled:e.disabled||e.shiftDownDisabled,onClick:e.shiftDown,title:(o=e.titles)==null?void 0:o.shiftDown},(n=e.labels)==null?void 0:n.shiftDown))},P$=({name:e,disabled:t,checked:r,label:o,handleOnChange:n})=>{const s=S.useId();return S.createElement("label",{htmlFor:s},S.createElement("input",{id:s,type:"radio",value:e,disabled:t,checked:r,onChange:a=>n(a.target.value)}),o)},I$=e=>{const{operator:t,value:r,handleOnChange:o,title:n,className:s,type:a="text",inputType:i,values:c=[],listsAsArrays:d,fieldData:p,disabled:u,separator:f=null,testID:h,selectorComponent:g=e.schema.controls.valueSelector,parseNumbers:y,skipHook:b,valueSource:v,...N}=e,{valueAsArray:x,multiValueHandler:w,bigIntValueHandler:C,parseNumberMethod:E,valueListItemClassName:k,inputTypeCoerced:_}=O$(e);if(t==="null"||t==="notNull")return null;const D=(p==null?void 0:p.placeholder)??"";if((t==="between"||t==="notBetween")&&(a==="select"||a==="text")){const A=["from","to"].map((I,T)=>a==="text"?S.createElement("input",{key:I,type:_,placeholder:D,value:x[T]??"",className:k,disabled:u,onChange:L=>w(L.target.value,T)}):S.createElement(g,{key:I,...N,schema:e.schema,className:k,handleOnChange:L=>w(L,T),disabled:u,value:x[T]??Ct(c),options:c,listsAsArrays:d}));return S.createElement("span",{"data-testid":h,className:s,title:n},A[0],f,A[1])}switch(a){case"select":case"multiselect":return S.createElement(g,{...N,schema:e.schema,testID:h,className:s,title:n,handleOnChange:o,disabled:u,value:r,options:c,multiple:a==="multiselect",listsAsArrays:d});case"textarea":return S.createElement("textarea",{"data-testid":h,placeholder:D,value:r,title:n,className:s,disabled:u,onChange:A=>o(A.target.value)});case"switch":case"checkbox":return S.createElement("input",{"data-testid":h,type:"checkbox",className:s,title:n,onChange:A=>o(A.target.checked),checked:!!r,disabled:u});case"radio":return S.createElement("span",{"data-testid":h,className:s,title:n},c.map(A=>S.createElement(P$,{key:A.name,name:A.name,disabled:u,checked:r===A.name,handleOnChange:o,label:A.label})))}return i==="bigint"?S.createElement("input",{"data-testid":h,type:_,placeholder:D,value:`${r}`,title:n,className:s,disabled:u,onChange:A=>C(A.target.value)}):S.createElement("input",{"data-testid":h,type:_,placeholder:D,value:r,title:n,className:s,disabled:u,onChange:A=>o(_e(A.target.value,{parseNumbers:E}))})},O$=e=>{const{handleOnChange:t,inputType:r,operator:o,value:n,listsAsArrays:s,parseNumbers:a,values:i,type:c,skipHook:d,schema:{classNames:p,suppressStandardClassnames:u}}=e;P.useEffect(()=>{!d&&c!=="multiselect"&&!["between","notBetween","in","notIn"].includes(o)&&(Array.isArray(n)||r==="number"&&typeof n=="string"&&n.includes(","))&&t(me(n,{retainEmptyStrings:!0})[0]??"")},[t,r,o,d,c,n]);const f=P.useMemo(()=>me(n,{retainEmptyStrings:!0}),[n]),h=P.useMemo(()=>sd({parseNumbers:a,inputType:r}),[r,a]);return{valueAsArray:f,multiValueHandler:P.useCallback((g,y)=>{const b=_e(g,{parseNumbers:h}),v=y===0&&(o==="between"||o==="notBetween")&&(f.length<2||f[1]===void 0);if(f[y]===b&&!v){t(s?f:ss(f,","));return}const N=[...f];N[y]=b,v&&(N[1]=Ct(i)),t(s?N:ss(N,","))},[t,s,o,h,f,i]),bigIntValueHandler:P.useCallback(g=>{const y=_e(g,{parseNumbers:h,bigIntOnOverflow:!0});let b;try{b=BigInt(y)}catch{t(y);return}t(b)},[t,h]),parseNumberMethod:h,valueListItemClassName:ze(u||ve.valueListItem,p==null?void 0:p.valueListItem),inputTypeCoerced:r==="bigint"||o==="in"||o==="notIn"?"text":r||"text"}},M$=e=>{const{multiple:t,onChange:r}=e;return P.useMemo(()=>t?o=>r(Array.from(o.target.selectedOptions).map(n=>n.value)):o=>r(o.target.value),[t,r])},L$=e=>Wm(e)?e.map(t=>S.createElement("optgroup",{key:t.label,label:t.label},t.options.map(r=>S.createElement("option",{key:r.name,value:r.name,disabled:r.disabled},r.label)))):Array.isArray(e)?e.map(t=>S.createElement("option",{key:t.name,value:t.name,disabled:t.disabled},t.label)):null,Ss=e=>{const{onChange:t,val:r}=F$(e),o=M$({multiple:e.multiple,onChange:t});return S.createElement("select",{"data-testid":e.testID,className:e.className,value:r,title:e.title,disabled:e.disabled,multiple:!!e.multiple,onChange:o},L$(e.options))},F$=e=>{const{handleOnChange:t,listsAsArrays:r=!1,multiple:o=!1,value:n}=e;return{onChange:P.useCallback(s=>{if(o){const a=me(s);t(r?a:ss(a,","))}else t(s)},[t,r,o]),val:P.useMemo(()=>o?me(n).map(String):n,[o,n])}},V$=({props:e})=>{const t=Ib(e),r=t.schema.controls.ruleGroup,o=Yd;return S.createElement(o.Provider,{key:t.dndEnabledAttr,value:t.rqbContext},S.createElement("div",{role:"form",className:t.wrapperClassName,"data-dnd":t.dndEnabledAttr,"data-inlinecombinators":t.inlineCombinatorsAttr},S.createElement(r,{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:Lm,disabled:t.rootGroupDisabled,shiftUpDisabled:!0,shiftDownDisabled:!0,parentDisabled:t.queryDisabled,context:e.context})))},Ll=()=>null,G$=P.forwardRef(Ll),Fl={},z$=({finalize:e,...t})=>{var g,y,b,v,N,x,w,C,E,k,_,D,A,I,T,L,F,B,G,z,H,V,W,pe,U,Q,Ce,oe,ye,R,ce,re,Ae,we,ue,J,ne,fe,ke,Re,rt,st,Xe,Ee,yt,fr,Yt,It,Me,Et,Ot,Hr,rr,$,O,M,Y,q,Z,j,X,ie,Oe,qe,Mt,Pe,et,lt,_r,kn,pr,An,As,Lt,Dn,vt,Rl,Ds,$s,Ts,$n,Ps,Is,hr,Os,Xl,Jl,Zl,ei,Ms,ti,he,Fe,He,Ge,Ve,_t,zt,Co,jr,Eo,ov,nv,sv,av,lv,iv,cv;const r=P.useContext(Yd),o=P.useMemo(()=>pA(t,r),[t,r,e]),n=e?r.enableDragAndDrop!==!1&&Pg(!1,t.enableDragAndDrop,r.enableDragAndDrop):t.enableDragAndDrop??r.enableDragAndDrop,s=P.useMemo(()=>dA(r.controlClassnames,t.controlClassnames),[r.controlClassnames,t.controlClassnames]),a=P.useMemo(()=>({actionElement:s.actionElement,addGroup:s.addGroup,addRule:s.addRule,body:s.body,cloneGroup:s.cloneGroup,cloneRule:s.cloneRule,combinators:s.combinators,dragHandle:s.dragHandle,fields:s.fields,header:s.header,lockGroup:s.lockGroup,lockRule:s.lockRule,muteGroup:s.muteGroup,muteRule:s.muteRule,muted:s.muted,notToggle:s.notToggle,operators:s.operators,queryBuilder:s.queryBuilder,removeGroup:s.removeGroup,removeRule:s.removeRule,rule:s.rule,ruleGroup:s.ruleGroup,shiftActions:s.shiftActions,value:s.value,valueSelector:s.valueSelector,valueSource:s.valueSource,betweenRules:s.betweenRules,valid:s.valid,invalid:s.invalid,dndDragging:s.dndDragging,dndOver:s.dndOver,dndCopy:s.dndCopy,dndGroup:s.dndGroup,dndDropNotAllowed:s.dndDropNotAllowed,dndPreviewPosition:s.dndPreviewPosition,dndHidden:s.dndHidden,disabled:s.disabled,valueListItem:s.valueListItem,matchMode:s.matchMode,matchThreshold:s.matchThreshold,branches:s.branches,hasSubQuery:s.hasSubQuery,loading:s.loading,valueDateTimeRelative:s.valueDateTimeRelative}),[s.actionElement,s.addGroup,s.addRule,s.betweenRules,s.body,s.branches,s.cloneGroup,s.cloneRule,s.combinators,s.disabled,s.dndCopy,s.dndDropNotAllowed,s.dndPreviewPosition,s.dndHidden,s.dndGroup,s.dndDragging,s.dndOver,s.dragHandle,s.fields,s.hasSubQuery,s.header,s.invalid,s.loading,s.lockGroup,s.lockRule,s.muteGroup,s.muteRule,s.muted,s.matchMode,s.matchThreshold,s.notToggle,s.operators,s.queryBuilder,s.removeGroup,s.removeRule,s.rule,s.ruleGroup,s.shiftActions,s.valid,s.value,s.valueDateTimeRelative,s.valueListItem,s.valueSelector,s.valueSource]),i=r.controlElements??Fl,c=t.controlElements??Fl,d=P.useCallback((kr,Ls,Fs)=>{const Vs=kr==="dragHandle"?G$:Ll,ri=(kr.endsWith("Action")&&c.actionElement?c.actionElement:void 0)??(kr.endsWith("Selector")&&c.valueSelector?c.valueSelector:void 0),oi=(kr.endsWith("Action")&&i.actionElement?i.actionElement:void 0)??(kr.endsWith("Selector")&&i.valueSelector?i.valueSelector:void 0),Gs=Ls===null?Vs:Ls??ri??(Fs===null?Vs:Fs??oi);return Gs?{[kr]:Gs}:{[kr]:Vl[kr]}},[i.actionElement,i.valueSelector,e,c.actionElement,c.valueSelector]),p=P.useMemo(()=>Object.assign({},d("addGroupAction",c.addGroupAction,i.addGroupAction),d("addRuleAction",c.addRuleAction,i.addRuleAction),d("cloneGroupAction",c.cloneGroupAction,i.cloneGroupAction),d("cloneRuleAction",c.cloneRuleAction,i.cloneRuleAction),d("combinatorSelector",c.combinatorSelector,i.combinatorSelector),d("dragHandle",c.dragHandle,i.dragHandle),d("fieldSelector",c.fieldSelector,i.fieldSelector),d("inlineCombinator",c.inlineCombinator,i.inlineCombinator),d("lockGroupAction",c.lockGroupAction,i.lockGroupAction),d("lockRuleAction",c.lockRuleAction,i.lockRuleAction),d("muteGroupAction",c.muteGroupAction,i.muteGroupAction),d("muteRuleAction",c.muteRuleAction,i.muteRuleAction),d("notToggle",c.notToggle,i.notToggle),d("operatorSelector",c.operatorSelector,i.operatorSelector),d("removeGroupAction",c.removeGroupAction,i.removeGroupAction),d("removeRuleAction",c.removeRuleAction,i.removeRuleAction),d("shiftActions",c.shiftActions,i.shiftActions),{valueEditor:c.valueEditor===null?Ll:c.valueEditor??(i.valueEditor===null?Ll:i.valueEditor)??Vl.valueEditor},d("valueSourceSelector",c.valueSourceSelector,i.valueSourceSelector),d("matchModeEditor",c.matchModeEditor,i.matchModeEditor),d("rule",c.rule,i.rule),d("ruleGroup",c.ruleGroup,i.ruleGroup),d("ruleGroupBodyElements",c.ruleGroupBodyElements,i.ruleGroupBodyElements),d("ruleGroupHeaderElements",c.ruleGroupHeaderElements,i.ruleGroupHeaderElements),{actionElement:c.actionElement??i.actionElement??Vl.actionElement},{valueSelector:c.valueSelector??i.valueSelector??Vl.valueSelector}),[i.actionElement,i.addGroupAction,i.addRuleAction,i.cloneGroupAction,i.cloneRuleAction,i.combinatorSelector,i.dragHandle,i.fieldSelector,i.inlineCombinator,i.lockGroupAction,i.lockRuleAction,i.muteGroupAction,i.muteRuleAction,i.matchModeEditor,i.notToggle,i.operatorSelector,i.removeGroupAction,i.removeRuleAction,i.rule,i.ruleGroup,i.ruleGroupBodyElements,i.ruleGroupHeaderElements,i.shiftActions,i.valueEditor,i.valueSelector,i.valueSourceSelector,d,e,c.actionElement,c.addGroupAction,c.addRuleAction,c.cloneGroupAction,c.cloneRuleAction,c.combinatorSelector,c.dragHandle,c.fieldSelector,c.inlineCombinator,c.lockGroupAction,c.lockRuleAction,c.muteGroupAction,c.muteRuleAction,c.matchModeEditor,c.notToggle,c.operatorSelector,c.removeGroupAction,c.removeRuleAction,c.rule,c.ruleGroup,c.ruleGroupBodyElements,c.ruleGroupHeaderElements,c.shiftActions,c.valueEditor,c.valueSelector,c.valueSourceSelector]),u=t.translations??Fl,f=r.translations??Fl,h=P.useMemo(()=>{var kr,Ls,Fs,Vs,ri,oi,Gs,dv,uv,fv,pv,hv,mv,gv,bv,yv,vv,xv,wv,Sv,Nv,Cv,Ev,_v,kv,Av,Dv,$v,Tv,Pv,Iv,Ov,Mv,Lv,Fv,Vv,Gv,zv,Bv,Uv,Wv,Hv,jv,qv,Yv,Qv,Kv,Rv,Xv,Jv,Zv,ex,tx,rx,ox,nx,sx,ax,lx,ix,cx,dx,ux,fx,px,hx,mx,gx,bx,yx,vx,xx,wx,Sx,Nx,Cx,Ex,_x,kx,Ax,Dx,$x,Tx,Px,Ix,Ox,Mx,Lx,Fx,Vx,Gx,zx,Bx,Ux,Wx,Hx,jx,qx,Yx,Qx,Kx,Rx,Xx,Jx,Zx,ew,tw,rw;return Object.assign({},Ke("addGroup",{label:[(kr=u.addGroup)==null?void 0:kr.label,(Ls=f.addGroup)==null?void 0:Ls.label],title:[(Fs=u.addGroup)==null?void 0:Fs.title,(Vs=f.addGroup)==null?void 0:Vs.title]},Qe),Ke("addRule",{label:[(ri=u.addRule)==null?void 0:ri.label,(oi=f.addRule)==null?void 0:oi.label],title:[(Gs=u.addRule)==null?void 0:Gs.title,(dv=f.addRule)==null?void 0:dv.title]},Qe),Ke("cloneRule",{label:[(uv=u.cloneRule)==null?void 0:uv.label,(fv=f.cloneRule)==null?void 0:fv.label],title:[(pv=u.cloneRule)==null?void 0:pv.title,(hv=f.cloneRule)==null?void 0:hv.title]},Qe),Ke("cloneRuleGroup",{label:[(mv=u.cloneRuleGroup)==null?void 0:mv.label,(gv=f.cloneRuleGroup)==null?void 0:gv.label],title:[(bv=u.cloneRuleGroup)==null?void 0:bv.title,(yv=f.cloneRuleGroup)==null?void 0:yv.title]},Qe),Ke("combinators",{title:[(vv=u.combinators)==null?void 0:vv.title,(xv=f.combinators)==null?void 0:xv.title]},Qe),Ke("dragHandle",{label:[(wv=u.dragHandle)==null?void 0:wv.label,(Sv=f.dragHandle)==null?void 0:Sv.label],title:[(Nv=u.dragHandle)==null?void 0:Nv.title,(Cv=f.dragHandle)==null?void 0:Cv.title]},Qe),Ke("fields",{placeholderGroupLabel:[(Ev=u.fields)==null?void 0:Ev.placeholderGroupLabel,(_v=f.fields)==null?void 0:_v.placeholderGroupLabel],placeholderLabel:[(kv=u.fields)==null?void 0:kv.placeholderLabel,(Av=f.fields)==null?void 0:Av.placeholderLabel],placeholderName:[(Dv=u.fields)==null?void 0:Dv.placeholderName,($v=f.fields)==null?void 0:$v.placeholderName],title:[(Tv=u.fields)==null?void 0:Tv.title,(Pv=f.fields)==null?void 0:Pv.title]},Qe),Ke("lockGroup",{label:[(Iv=u.lockGroup)==null?void 0:Iv.label,(Ov=f.lockGroup)==null?void 0:Ov.label],title:[(Mv=u.lockGroup)==null?void 0:Mv.title,(Lv=f.lockGroup)==null?void 0:Lv.title]},Qe),Ke("lockGroupDisabled",{label:[(Fv=u.lockGroupDisabled)==null?void 0:Fv.label,(Vv=f.lockGroupDisabled)==null?void 0:Vv.label],title:[(Gv=u.lockGroupDisabled)==null?void 0:Gv.title,(zv=f.lockGroupDisabled)==null?void 0:zv.title]},Qe),Ke("lockRule",{label:[(Bv=u.lockRule)==null?void 0:Bv.label,(Uv=f.lockRule)==null?void 0:Uv.label],title:[(Wv=u.lockRule)==null?void 0:Wv.title,(Hv=f.lockRule)==null?void 0:Hv.title]},Qe),Ke("lockRuleDisabled",{label:[(jv=u.lockRuleDisabled)==null?void 0:jv.label,(qv=f.lockRuleDisabled)==null?void 0:qv.label],title:[(Yv=u.lockRuleDisabled)==null?void 0:Yv.title,(Qv=f.lockRuleDisabled)==null?void 0:Qv.title]},Qe),Ke("muteGroup",{label:[(Kv=u.muteGroup)==null?void 0:Kv.label,(Rv=f.muteGroup)==null?void 0:Rv.label],title:[(Xv=u.muteGroup)==null?void 0:Xv.title,(Jv=f.muteGroup)==null?void 0:Jv.title]},Qe),Ke("unmuteGroup",{label:[(Zv=u.unmuteGroup)==null?void 0:Zv.label,(ex=f.unmuteGroup)==null?void 0:ex.label],title:[(tx=u.unmuteGroup)==null?void 0:tx.title,(rx=f.unmuteGroup)==null?void 0:rx.title]},Qe),Ke("muteRule",{label:[(ox=u.muteRule)==null?void 0:ox.label,(nx=f.muteRule)==null?void 0:nx.label],title:[(sx=u.muteRule)==null?void 0:sx.title,(ax=f.muteRule)==null?void 0:ax.title]},Qe),Ke("unmuteRule",{label:[(lx=u.unmuteRule)==null?void 0:lx.label,(ix=f.unmuteRule)==null?void 0:ix.label],title:[(cx=u.unmuteRule)==null?void 0:cx.title,(dx=f.unmuteRule)==null?void 0:dx.title]},Qe),Ke("notToggle",{label:[(ux=u.notToggle)==null?void 0:ux.label,(fx=f.notToggle)==null?void 0:fx.label],title:[(px=u.notToggle)==null?void 0:px.title,(hx=f.notToggle)==null?void 0:hx.title]},Qe),Ke("operators",{placeholderGroupLabel:[(mx=u.operators)==null?void 0:mx.placeholderGroupLabel,(gx=f.operators)==null?void 0:gx.placeholderGroupLabel],placeholderLabel:[(bx=u.operators)==null?void 0:bx.placeholderLabel,(yx=f.operators)==null?void 0:yx.placeholderLabel],placeholderName:[(vx=u.operators)==null?void 0:vx.placeholderName,(xx=f.operators)==null?void 0:xx.placeholderName],title:[(wx=u.operators)==null?void 0:wx.title,(Sx=f.operators)==null?void 0:Sx.title]},Qe),Ke("values",{placeholderGroupLabel:[(Nx=u.values)==null?void 0:Nx.placeholderGroupLabel,(Cx=f.values)==null?void 0:Cx.placeholderGroupLabel],placeholderLabel:[(Ex=u.values)==null?void 0:Ex.placeholderLabel,(_x=f.values)==null?void 0:_x.placeholderLabel],placeholderName:[(kx=u.values)==null?void 0:kx.placeholderName,(Ax=f.values)==null?void 0:Ax.placeholderName],title:[(Dx=u.values)==null?void 0:Dx.title,($x=f.values)==null?void 0:$x.title]},Qe),Ke("removeGroup",{label:[(Tx=u.removeGroup)==null?void 0:Tx.label,(Px=f.removeGroup)==null?void 0:Px.label],title:[(Ix=u.removeGroup)==null?void 0:Ix.title,(Ox=f.removeGroup)==null?void 0:Ox.title]},Qe),Ke("removeRule",{label:[(Mx=u.removeRule)==null?void 0:Mx.label,(Lx=f.removeRule)==null?void 0:Lx.label],title:[(Fx=u.removeRule)==null?void 0:Fx.title,(Vx=f.removeRule)==null?void 0:Vx.title]},Qe),Ke("shiftActionDown",{label:[(Gx=u.shiftActionDown)==null?void 0:Gx.label,(zx=f.shiftActionDown)==null?void 0:zx.label],title:[(Bx=u.shiftActionDown)==null?void 0:Bx.title,(Ux=f.shiftActionDown)==null?void 0:Ux.title]},Qe),Ke("shiftActionUp",{label:[(Wx=u.shiftActionUp)==null?void 0:Wx.label,(Hx=f.shiftActionUp)==null?void 0:Hx.label],title:[(jx=u.shiftActionUp)==null?void 0:jx.title,(qx=f.shiftActionUp)==null?void 0:qx.title]},Qe),Ke("matchMode",{title:[(Yx=u.matchMode)==null?void 0:Yx.title,(Qx=f.matchMode)==null?void 0:Qx.title]},Qe),Ke("matchThreshold",{title:[(Kx=u.matchThreshold)==null?void 0:Kx.title,(Rx=f.matchThreshold)==null?void 0:Rx.title],placeholderName:[(Xx=u.matchThreshold)==null?void 0:Xx.placeholderName,(Jx=f.matchThreshold)==null?void 0:Jx.placeholderName]},Qe),Ke("value",{title:[(Zx=u.value)==null?void 0:Zx.title,(ew=f.value)==null?void 0:ew.title]},Qe),Ke("valueSourceSelector",{title:[(tw=u.valueSourceSelector)==null?void 0:tw.title,(rw=f.valueSourceSelector)==null?void 0:rw.title]},Qe))},[(g=f.addGroup)==null?void 0:g.label,(y=f.addGroup)==null?void 0:y.title,(b=f.addRule)==null?void 0:b.label,(v=f.addRule)==null?void 0:v.title,(N=f.cloneRule)==null?void 0:N.label,(x=f.cloneRule)==null?void 0:x.title,(w=f.cloneRuleGroup)==null?void 0:w.label,(C=f.cloneRuleGroup)==null?void 0:C.title,(E=f.combinators)==null?void 0:E.title,(k=f.dragHandle)==null?void 0:k.label,(_=f.dragHandle)==null?void 0:_.title,(D=f.fields)==null?void 0:D.placeholderGroupLabel,(A=f.fields)==null?void 0:A.placeholderLabel,(I=f.fields)==null?void 0:I.placeholderName,(T=f.fields)==null?void 0:T.title,(L=f.lockGroup)==null?void 0:L.label,(F=f.lockGroup)==null?void 0:F.title,(B=f.lockGroupDisabled)==null?void 0:B.label,(G=f.lockGroupDisabled)==null?void 0:G.title,(z=f.lockRule)==null?void 0:z.label,(H=f.lockRule)==null?void 0:H.title,(V=f.lockRuleDisabled)==null?void 0:V.label,(W=f.lockRuleDisabled)==null?void 0:W.title,(pe=f.muteGroup)==null?void 0:pe.label,(U=f.muteGroup)==null?void 0:U.title,(Q=f.unmuteGroup)==null?void 0:Q.label,(Ce=f.unmuteGroup)==null?void 0:Ce.title,(oe=f.muteRule)==null?void 0:oe.label,(ye=f.muteRule)==null?void 0:ye.title,(R=f.unmuteRule)==null?void 0:R.label,(ce=f.unmuteRule)==null?void 0:ce.title,(re=f.matchMode)==null?void 0:re.title,(Ae=f.matchThreshold)==null?void 0:Ae.title,(we=f.matchThreshold)==null?void 0:we.placeholderName,(ue=f.notToggle)==null?void 0:ue.label,(J=f.notToggle)==null?void 0:J.title,(ne=f.operators)==null?void 0:ne.placeholderGroupLabel,(fe=f.operators)==null?void 0:fe.placeholderLabel,(ke=f.operators)==null?void 0:ke.placeholderName,(Re=f.operators)==null?void 0:Re.title,(rt=f.removeGroup)==null?void 0:rt.label,(st=f.removeGroup)==null?void 0:st.title,(Xe=f.removeRule)==null?void 0:Xe.label,(Ee=f.removeRule)==null?void 0:Ee.title,(yt=f.shiftActionDown)==null?void 0:yt.label,(fr=f.shiftActionDown)==null?void 0:fr.title,(Yt=f.shiftActionUp)==null?void 0:Yt.label,(It=f.shiftActionUp)==null?void 0:It.title,(Me=f.value)==null?void 0:Me.title,(Et=f.values)==null?void 0:Et.placeholderGroupLabel,(Ot=f.values)==null?void 0:Ot.placeholderLabel,(Hr=f.values)==null?void 0:Hr.placeholderName,(rr=f.values)==null?void 0:rr.title,($=f.valueSourceSelector)==null?void 0:$.title,e,(O=u.addGroup)==null?void 0:O.label,(M=u.addGroup)==null?void 0:M.title,(Y=u.addRule)==null?void 0:Y.label,(q=u.addRule)==null?void 0:q.title,(Z=u.cloneRule)==null?void 0:Z.label,(j=u.cloneRule)==null?void 0:j.title,(X=u.cloneRuleGroup)==null?void 0:X.label,(ie=u.cloneRuleGroup)==null?void 0:ie.title,(Oe=u.combinators)==null?void 0:Oe.title,(qe=u.dragHandle)==null?void 0:qe.label,(Mt=u.dragHandle)==null?void 0:Mt.title,(Pe=u.fields)==null?void 0:Pe.placeholderGroupLabel,(et=u.fields)==null?void 0:et.placeholderLabel,(lt=u.fields)==null?void 0:lt.placeholderName,(_r=u.fields)==null?void 0:_r.title,(kn=u.lockGroup)==null?void 0:kn.label,(pr=u.lockGroup)==null?void 0:pr.title,(An=u.lockGroupDisabled)==null?void 0:An.label,(As=u.lockGroupDisabled)==null?void 0:As.title,(Lt=u.lockRule)==null?void 0:Lt.label,(Dn=u.lockRule)==null?void 0:Dn.title,(vt=u.lockRuleDisabled)==null?void 0:vt.label,(Rl=u.lockRuleDisabled)==null?void 0:Rl.title,(Ds=u.muteGroup)==null?void 0:Ds.label,($s=u.muteGroup)==null?void 0:$s.title,(Ts=u.unmuteGroup)==null?void 0:Ts.label,($n=u.unmuteGroup)==null?void 0:$n.title,(Ps=u.muteRule)==null?void 0:Ps.label,(Is=u.muteRule)==null?void 0:Is.title,(hr=u.unmuteRule)==null?void 0:hr.label,(Os=u.unmuteRule)==null?void 0:Os.title,(Xl=u.matchMode)==null?void 0:Xl.title,(Jl=u.matchThreshold)==null?void 0:Jl.title,(Zl=u.matchThreshold)==null?void 0:Zl.placeholderName,(ei=u.notToggle)==null?void 0:ei.label,(Ms=u.notToggle)==null?void 0:Ms.title,(ti=u.operators)==null?void 0:ti.placeholderGroupLabel,(he=u.operators)==null?void 0:he.placeholderLabel,(Fe=u.operators)==null?void 0:Fe.placeholderName,(He=u.operators)==null?void 0:He.title,(Ge=u.removeGroup)==null?void 0:Ge.label,(Ve=u.removeGroup)==null?void 0:Ve.title,(_t=u.removeRule)==null?void 0:_t.label,(zt=u.removeRule)==null?void 0:zt.title,(Co=u.shiftActionDown)==null?void 0:Co.label,(jr=u.shiftActionDown)==null?void 0:jr.title,(Eo=u.shiftActionUp)==null?void 0:Eo.label,(ov=u.shiftActionUp)==null?void 0:ov.title,(nv=u.value)==null?void 0:nv.title,(sv=u.values)==null?void 0:sv.placeholderGroupLabel,(av=u.values)==null?void 0:av.placeholderLabel,(lv=u.values)==null?void 0:lv.placeholderName,(iv=u.values)==null?void 0:iv.title,(cv=u.valueSourceSelector)==null?void 0:cv.title]);return{...o,controlClassnames:a,controlElements:p,enableDragAndDrop:n,translations:h,initialQuery:t.initialQuery,qbId:t.qbId}},B$=({disabled:e,path:t,nestedArray:r,disabledPaths:o})=>{const n=r.length;return P.useMemo(()=>{const s=[];for(let a=0;a<n;a++){const i=[...t,a];s[a]={path:i,disabled:e||o.some(c=>Qo(i,c))}}return s},[e,t,n,o])};let Mb=!1;const Lb=(e,t)=>{process.env.NODE_ENV!=="production"&&!Mb&&e&&!t&&(console.error(Dt.errorEnabledDndWithoutReactDnD),Mb=!0)},ct=e=>P.useCallback((t,r)=>{t==null||t.preventDefault(),t==null||t.stopPropagation(),e(t,r)},[e]),U$={mode:"all"},W$=[{name:"",value:"",label:""}],H$=S.memo(function(t){const r=Y$(t),{dndRef:o}=r,n=ct(r.cloneRule),s=ct(r.toggleLockRule),a=ct(r.toggleMuteRule),i=ct(r.removeRule),c=ct(r.shiftRuleUp),d=ct(r.shiftRuleDown),p=P.useMemo(()=>({cloneRule:n,toggleLockRule:s,toggleMuteRule:a,removeRule:i,shiftRuleUp:c,shiftRuleDown:d}),[n,i,d,c,s,a]);return S.createElement("div",{ref:o,"data-testid":xe.rule,"data-dragmonitorid":r.dragMonitorId,"data-dropmonitorid":r.dropMonitorId,className:r.outerClassName,"data-rule-id":r.id,"data-level":r.path.length,"data-path":JSON.stringify(r.path)},r.matchModes.length>0?S.createElement(q$,{...r,...p}):S.createElement(Fb,{...r,...p}))}),Fb=S.memo(function(t){const{dragRef:r,schema:{controls:{shiftActions:o,dragHandle:n,fieldSelector:s,matchModeEditor:a,operatorSelector:i,valueSourceSelector:c,valueEditor:d,cloneRuleAction:p,lockRuleAction:u,muteRuleAction:f,removeRuleAction:h,ruleGroupBodyElements:g,ruleGroupHeaderElements:y}},groupComponentsWrapper:b=S.Fragment}=t,v=P.useMemo(()=>({level:t.path.length,path:t.path,disabled:t.disabled,context:t.context,validation:t.validationResult,schema:t.schema,rule:t.rule}),[t.path,t.disabled,t.context,t.validationResult,t.schema,t.rule]),N=P.useMemo(()=>!(t.schema.fields.length===1&&wr(t.schema.fields[0])&&"value"in t.schema.fields[0]&&t.schema.fields[0].value===""),[t.schema.fields]),x=P.useMemo(()=>t.schema.showShiftActions?{shiftUp:t.translations.shiftActionUp.title,shiftDown:t.translations.shiftActionDown.title}:void 0,[t.schema.showShiftActions,t.translations]),w=P.useMemo(()=>t.schema.showShiftActions?{shiftUp:t.translations.shiftActionUp.label,shiftDown:t.translations.shiftActionDown.label}:void 0,[t.schema.showShiftActions,t.translations]);return S.createElement(S.Fragment,null,t.schema.showShiftActions&&S.createElement(o,{key:xe.shiftActions,...v,testID:xe.shiftActions,titles:x,labels:w,className:t.classNames.shiftActions,ruleOrGroup:t.rule,shiftUp:t.shiftRuleUp,shiftDown:t.shiftRuleDown,shiftUpDisabled:t.shiftUpDisabled,shiftDownDisabled:t.shiftDownDisabled}),t.schema.enableDragAndDrop&&S.createElement(n,{key:xe.dragHandle,...v,testID:xe.dragHandle,ref:r,title:t.translations.dragHandle.title,label:t.translations.dragHandle.label,className:t.classNames.dragHandle,dragHandleAttributes:t.dragHandleAttributes,ruleOrGroup:t.rule}),N&&S.createElement(s,{key:xe.fields,...v,testID:xe.fields,options:t.schema.fields,title:t.translations.fields.title,value:t.rule.field,operator:t.rule.operator,className:t.classNames.fields,handleOnChange:t.onChangeField}),(t.schema.autoSelectField||t.rule.field!==t.translations.fields.placeholderName)&&(t.subQuery?S.createElement(a,{key:xe.matchModeEditor,...v,testID:xe.matchModeEditor,field:t.rule.field,fieldData:t.fieldData,title:t.translations.matchMode.title,options:t.matchModes,thresholdPlaceholder:t.translations.matchThreshold.placeholderName,match:t.rule.match??U$,className:t.classNames.matchMode,classNames:t.classNames,handleOnChange:t.onChangeMatchMode}):S.createElement(S.Fragment,null,S.createElement(i,{key:xe.operators,...v,testID:xe.operators,field:t.rule.field,fieldData:t.fieldData,title:t.translations.operators.title,options:t.operators,value:t.rule.operator,className:t.classNames.operators,handleOnChange:t.onChangeOperator}),(t.schema.autoSelectOperator||t.rule.operator!==t.translations.operators.placeholderName)&&!t.hideValueControls&&S.createElement(S.Fragment,null,!["null","notnull"].includes($e(`${t.rule.operator}`))&&t.valueSources.length>1&&S.createElement(c,{key:xe.valueSourceSelector,...v,testID:xe.valueSourceSelector,field:t.rule.field,fieldData:t.fieldData,title:t.translations.valueSourceSelector.title,options:t.valueSourceOptions,value:t.rule.valueSource??"value",className:t.classNames.valueSource,handleOnChange:t.onChangeValueSource}),S.createElement(d,{key:xe.valueEditor,...v,testID:xe.valueEditor,field:t.rule.field,fieldData:t.fieldData,title:t.translations.value.title,operator:t.rule.operator,value:t.rule.value,valueSource:t.rule.valueSource??"value",type:t.valueEditorType,inputType:t.inputType,values:t.values,listsAsArrays:t.schema.listsAsArrays,parseNumbers:t.schema.parseNumbers,separator:t.valueEditorSeparator,className:t.classNames.value,handleOnChange:t.onChangeValue})))),t.subQuery&&S.createElement(b,{className:t.subQuery.classNames.header},S.createElement(y,t.subQuery)),t.schema.showCloneButtons&&S.createElement(p,{key:xe.cloneRule,...v,testID:xe.cloneRule,label:t.translations.cloneRule.label,title:t.translations.cloneRule.title,className:t.classNames.cloneRule,ruleOrGroup:t.rule,handleOnClick:t.cloneRule}),t.schema.showLockButtons&&S.createElement(u,{key:xe.lockRule,...v,testID:xe.lockRule,label:t.translations.lockRule.label,title:t.translations.lockRule.title,className:t.classNames.lockRule,ruleOrGroup:t.rule,handleOnClick:t.toggleLockRule,disabledTranslation:t.parentDisabled?void 0:t.translations.lockRuleDisabled}),t.schema.showMuteButtons&&S.createElement(f,{key:xe.muteRule,...v,testID:xe.muteRule,label:t.rule.muted?t.translations.unmuteRule.label:t.translations.muteRule.label,title:t.rule.muted?t.translations.unmuteRule.title:t.translations.muteRule.title,className:t.classNames.muteRule,ruleOrGroup:t.rule,handleOnClick:t.toggleMuteRule}),S.createElement(h,{key:xe.removeRule,...v,testID:xe.removeRule,label:t.translations.removeRule.label,title:t.translations.removeRule.title,className:t.classNames.removeRule,ruleOrGroup:t.rule,handleOnClick:t.removeRule}),t.subQuery&&S.createElement(b,{className:t.subQuery.classNames.body},S.createElement(g,t.subQuery)))}),j$=e=>S.createElement("div",e),q$=S.memo(function(t){const r=P.useMemo(()=>t.schema.createRuleGroup(),[t.schema]),o=Ib({...t.subQueryBuilderProps,enableDragAndDrop:!1,disabled:t.disabled,fields:t.subproperties.fields,enableMountQueryChange:!ge(t.rule.value)||!t.rule.value.id,query:ge(t.rule.value)?t.rule.value:r,onQueryChange:t.onChangeValue}),n=Ob({...o,ruleGroup:o.rootGroup,path:Lm,disabled:t.disabled,parentDisabled:o.queryDisabled,id:o.rootGroup.id,shiftUpDisabled:!0,shiftDownDisabled:!0}),s=ct(n.addRule),a=ct(n.addGroup),i=ct(n.cloneGroup),c=ct(n.toggleLockGroup),d=ct(n.removeGroup),p=ct(n.shiftGroupUp),u=ct(n.shiftGroupDown),f=P.useMemo(()=>({...n,addGroup:a,addRule:s,cloneGroup:i,removeGroup:d,shiftGroupDown:u,shiftGroupUp:p,toggleLockGroup:c}),[a,s,i,d,u,p,n,c]);return S.createElement(Fb,{...t,groupComponentsWrapper:t.groupComponentsWrapper??j$,subQuery:f})}),Y$=e=>{const{id:t,path:r,rule:o,schema:{classNames:n,fields:s,fieldMap:a,getParameters:i,getInputType:c,getMatchModes:d,getOperators:p,getSubQueryBuilderProps:u,getValueEditorType:f,getValueEditorSeparator:h,getValueSources:g,getValues:y,validationMap:b,enableDragAndDrop:v,getRuleClassname:N,suppressStandardClassnames:x},actions:{moveRule:w,onPropChange:C,onRuleRemove:E},disabled:k,parentDisabled:_,parentMuted:D,shiftUpDisabled:A,shiftDownDisabled:I,field:T,operator:L,value:F,valueSource:B,dropEffect:G="move",groupItems:z=!1,dragMonitorId:H="",dropMonitorId:V="",dndRef:W=null,dragRef:pe=null,isDragging:U=!1,isOver:Q=!1,dropNotAllowed:Ce=!1}=e;jd("rule",!o),Lb(v,!!(H||V||W||pe));const oe=!!_||!!k,ye=!!D||!!(o!=null&&o.muted),R=P.useMemo(()=>o??{id:t,field:T??"",operator:L??"",value:F,valueSource:B},[T,t,L,o,F,B]),ce=P.useMemo(()=>({shiftActions:ze(x||ve.shiftActions,n.shiftActions),dragHandle:ze(x||ve.dragHandle,n.dragHandle),fields:ze(x||ve.fields,n.valueSelector,n.fields),matchMode:ze(x||ve.matchMode,n.valueSelector,n.matchMode),matchThreshold:ze(x||ve.matchThreshold,n.valueSelector,n.matchThreshold),operators:ze(x||ve.operators,n.valueSelector,n.operators),valueSource:ze(x||ve.valueSource,n.valueSelector,n.valueSource),value:ze(x||ve.value,n.value),cloneRule:ze(x||ve.cloneRule,n.actionElement,n.cloneRule),lockRule:ze(x||ve.lockRule,n.actionElement,n.lockRule),muteRule:ze(x||ve.muteRule,n.actionElement,n.muteRule),removeRule:ze(x||ve.removeRule,n.actionElement,n.removeRule),valueListItem:ze(x||ve.valueListItem,n.valueListItem)}),[n.shiftActions,n.dragHandle,n.valueSelector,n.fields,n.matchMode,n.matchThreshold,n.operators,n.valueSource,n.value,n.actionElement,n.cloneRule,n.lockRule,n.muteRule,n.removeRule,n.valueListItem,x]),re=P.useCallback(Pe=>(et,lt)=>{oe||C(Pe,et,r,lt)},[oe,C,r]),Ae=P.useMemo(()=>re("field"),[re]),we=P.useMemo(()=>re("operator"),[re]),ue=P.useMemo(()=>re("match"),[re]),J=P.useMemo(()=>re("valueSource"),[re]),ne=P.useMemo(()=>re("value"),[re]),fe=P.useCallback((Pe,et)=>{if(!oe){const lt=[...it(r),r.at(-1)+1];w(r,lt,!0,et)}},[oe,w,r]),ke=P.useCallback((Pe,et)=>C("disabled",!oe,r,et),[oe,C,r]),Re=P.useCallback((Pe,et)=>C("muted",!R.muted,r,et),[R.muted,C,r]),rt=P.useCallback((Pe,et)=>{oe||E(r)},[oe,E,r]),st=P.useCallback((Pe,et)=>{!oe&&!A&&w(r,"up",Pe==null?void 0:Pe.altKey,et)},[oe,w,r,A]),Xe=P.useCallback((Pe,et)=>{!oe&&!I&&w(r,"down",Pe==null?void 0:Pe.altKey,et)},[oe,w,r,I]),Ee=P.useMemo(()=>(a==null?void 0:a[R.field])??{name:R.field,value:R.field,label:R.field},[a,R.field]),yt=P.useMemo(()=>Ee.inputType??c(R.field,R.operator,{fieldData:Ee}),[Ee,c,R.field,R.operator]),fr=P.useMemo(()=>d(R.field,{fieldData:Ee}),[Ee,d,R.field]),Yt=P.useMemo(()=>p(R.field,{fieldData:Ee}),[Ee,p,R.field]),It=P.useMemo(()=>We(Yt,R.operator),[Yt,R.operator]),Me=It==null?void 0:It.arity,Et=typeof Me=="string"&&Me==="unary"||typeof Me=="number"&&Me<2,Ot=P.useMemo(()=>{const Pe=g(R.field,R.operator,{fieldData:Ee});return R.valueSource&&!We(Pe,R.valueSource)?[...Pe,{name:R.valueSource,value:R.valueSource,label:R.valueSource}]:Pe},[Ee,g,R.field,R.operator,R.valueSource]),Hr=P.useMemo(()=>Ot.map(({value:Pe})=>Pe),[Ot]),rr=P.useMemo(()=>i(R.field,R.operator,{fieldData:Ee}),[Ee,i,R.field,R.operator]),$=P.useMemo(()=>rr&&rr.length>0?rr:null,[rr]),O=P.useMemo(()=>R.valueSource==="field"?"select":R.valueSource==="parameter"?$?$e(R.operator)==="in"||$e(R.operator)==="notin"?"multiselect":"select":"text":f(R.field,R.operator,{fieldData:Ee}),[Ee,f,$,R.field,R.operator,R.valueSource]),M=P.useMemo(()=>h(R.field,R.operator,{fieldData:Ee}),[Ee,h,R.field,R.operator]),Y=P.useMemo(()=>{const Pe=R.valueSource==="field"?qm(Ee,s,R.operator):R.valueSource==="parameter"?$??[]:y(R.field,R.operator,{fieldData:Ee});return sl(Pe)||vo(Pe)?Gr(Pe):Pe},[Ee,s,y,$,R.field,R.operator,R.valueSource]),q=P.useMemo(()=>u(R.field,{fieldData:Ee}),[Ee,u,R.field]),Z=$b({translations:e.translations,fields:Ee.subproperties??q.fields??W$,autoSelectField:e.schema.autoSelectField||!!Ee.subproperties}),j=P.useMemo(()=>b[t??""]??(typeof Ee.validator=="function"?Ee.validator(R):null),[Ee,t,R,b]),X=P.useMemo(()=>Dg(j),[j]),ie=(Ee==null?void 0:Ee.className)??"",Oe=(It==null?void 0:It.className)??"",qe=fr.length>0,Mt=P.useMemo(()=>ze(N(R,{fieldData:Ee}),ie,Oe,x||ve.rule,n.rule,oe&&n.disabled,ye&&n.muted,U&&n.dndDragging,Q&&n.dndOver,Q&&G==="copy"&&n.dndCopy,Q&&z&&n.dndGroup,Ce&&n.dndDropNotAllowed,qe&&n.hasSubQuery,x||{[ve.disabled]:oe,[ve.muted]:ye,[ve.dndDragging]:U,[ve.dndOver]:Q,[ve.dndCopy]:Q&&G==="copy",[ve.dndGroup]:Q&&z,[ve.dndDropNotAllowed]:Ce,[ve.hasSubQuery]:qe},X),[n.disabled,n.muted,n.dndCopy,n.dndDragging,n.dndGroup,n.dndOver,n.dndDropNotAllowed,n.hasSubQuery,n.rule,oe,G,Ce,ye,ie,Ee,N,z,qe,U,Q,Oe,R,x,X]);return{...e,classNames:ce,cloneRule:fe,disabled:oe,dndRef:W,dragMonitorId:H,dragRef:pe,dropMonitorId:V,fieldData:Ee,generateOnChangeHandler:re,onChangeField:Ae,onChangeMatchMode:ue,onChangeOperator:we,onChangeValueSource:J,onChangeValue:ne,hideValueControls:Et,inputType:yt,matchModes:fr,muted:ye,operators:Yt,outerClassName:Mt,removeRule:rt,rule:R,shiftRuleUp:st,shiftRuleDown:Xe,subproperties:Z,subQueryBuilderProps:q,toggleLockRule:ke,toggleMuteRule:Re,validationResult:j,valueEditorSeparator:M,valueEditorType:O,values:Y,valueSourceOptions:Ot,valueSources:Hr}},Vl={actionElement:Nr,addGroupAction:Nr,addRuleAction:Nr,cloneGroupAction:Nr,cloneRuleAction:Nr,combinatorSelector:Ss,dragHandle:o$,fieldSelector:Ss,inlineCombinator:n$,lockGroupAction:Nr,lockRuleAction:Nr,matchModeEditor:s$,muteGroupAction:Nr,muteRuleAction:Nr,notToggle:l$,operatorSelector:Ss,removeGroupAction:Nr,removeRuleAction:Nr,rule:H$,ruleGroup:A$,ruleGroupBodyElements:$$,ruleGroupHeaderElements:D$,shiftActions:T$,valueEditor:I$,valueSelector:Ss,valueSourceSelector:Ss};Tb();const Q$=e=>S.createElement(JD,{context:Ab,store:Tb()},e.children),K$=e=>S.createElement(Q$,null,S.createElement(V$,{props:e}));function Vb(e,t,r){var n,s;const o={visible:!0,required:((n=e.validation)==null?void 0:n.required)??!1,disabled:((s=e.properties)==null?void 0:s.disabled)??!1};return e.logic&&(o.visible=R$(e.logic,t,r),e.logic.requireWhen&&(o.required=Gl(e.logic.requireWhen,t,r)),e.logic.disableWhen&&(o.disabled=Gl(e.logic.disableWhen,t,r))),o}function R$(e,t,r){const{showWhen:o,hideWhen:n}=e;let s=!0;if(o&&o.rules&&o.rules.length>0&&(s=Gl(o,t,r)),n&&n.rules&&n.rules.length>0){const a=Gl(n,t,r);s=s&&!a}return s}function Gl(e,t,r){if(!e||!e.rules||e.rules.length===0)return!0;const{combinator:o,rules:n}=e,s=n.map(a=>{const i=r.find(p=>p.id===a.field||p.attributes.name===a.field),c=(i==null?void 0:i.attributes.name)||a.field,d=t[c];return X$(d,a.operator,a.value)});return o==="and"?s.every(a=>a):s.some(a=>a)}function X$(e,t,r){const o=e??"";switch(t){case"equals":case"=":case"==":return o===r;case"notEquals":case"!=":case"<>":return o!==r;case"contains":return String(o).toLowerCase().includes(String(r).toLowerCase());case"notContains":case"doesNotContain":return!String(o).toLowerCase().includes(String(r).toLowerCase());case"startsWith":case"beginsWith":return String(o).toLowerCase().startsWith(String(r).toLowerCase());case"endsWith":return String(o).toLowerCase().endsWith(String(r).toLowerCase());case"matches":try{return new RegExp(r,"i").test(String(o))}catch{return!1}case"isEmpty":case"null":return o===""||o===null||o===void 0||Array.isArray(o)&&o.length===0;case"isNotEmpty":case"notNull":return o!==""&&o!==null&&o!==void 0&&!(Array.isArray(o)&&o.length===0);case"greaterThan":case">":return Number(o)>Number(r);case"greaterThanOrEquals":case">=":return Number(o)>=Number(r);case"lessThan":case"<":return Number(o)<Number(r);case"lessThanOrEquals":case"<=":return Number(o)<=Number(r);case"between":if(Array.isArray(r)&&r.length===2){const n=Number(o);return n>=Number(r[0])&&n<=Number(r[1])}return!1;case"notBetween":if(Array.isArray(r)&&r.length===2){const n=Number(o);return n<Number(r[0])||n>Number(r[1])}return!0;case"in":return Array.isArray(r)?r.includes(o):!1;case"notIn":return Array.isArray(r)?!r.includes(o):!0;case"isTrue":return o===!0||o==="true"||o===1;case"isFalse":return o===!1||o==="false"||o===0;case"hasLength":return Array.isArray(o)&&o.length===Number(r);case"hasMinLength":return Array.isArray(o)&&o.length>=Number(r);case"hasMaxLength":return Array.isArray(o)&&o.length<=Number(r);case"includes":case"arrayContains":return Array.isArray(o)&&o.includes(r);case"notIncludes":case"arrayNotContains":return!Array.isArray(o)||!o.includes(r);default:return console.warn(`Unknown operator: ${t}`),!0}}function J$(e){const t=[{name:"isEmpty",label:"is empty"},{name:"isNotEmpty",label:"is not empty"}],r=[{name:"equals",label:"equals"},{name:"notEquals",label:"does not equal"}],o=[...r,{name:"contains",label:"contains"},{name:"notContains",label:"does not contain"},{name:"startsWith",label:"starts with"},{name:"endsWith",label:"ends with"},...t],n=[...r,{name:"greaterThan",label:"is greater than"},{name:"greaterThanOrEquals",label:"is greater than or equal to"},{name:"lessThan",label:"is less than"},{name:"lessThanOrEquals",label:"is less than or equal to"},{name:"between",label:"is between"},...t],s=[{name:"isTrue",label:"is checked"},{name:"isFalse",label:"is not checked"}],a=[...r,{name:"in",label:"is one of"},{name:"notIn",label:"is not one of"},...t],i=[{name:"includes",label:"includes"},{name:"notIncludes",label:"does not include"},{name:"hasLength",label:"has exactly"},{name:"hasMinLength",label:"has at least"},{name:"hasMaxLength",label:"has at most"},...t];switch(e){case"shortText":case"longText":case"multiLineInput":case"textEditor":case"email":case"phone":case"url":case"password":case"location":return o;case"number":case"slider":case"rangeSlider":return n;case"decisionBox":case"toggleSwitch":return s;case"singleChoice":case"dropdown":return a;case"multipleChoice":case"tags":return i;case"date":case"time":case"dateTime":case"dateRange":case"multipleDates":return[...r,{name:"greaterThan",label:"is after"},{name:"lessThan",label:"is before"},{name:"between",label:"is between"},...t];case"fileUpload":case"imageUpload":case"multiFileUpload":case"multiImageUpload":return t;case"singleChoiceMatrix":case"multipleChoiceMatrix":case"matrixTable":return t;default:return[...r,...t]}}function Z$(e){switch(e){case"number":case"slider":case"rangeSlider":return"number";case"decisionBox":case"toggleSwitch":return"checkbox";case"date":case"dateRange":case"multipleDates":return"date";case"time":return"time";case"dateTime":return"datetime-local";case"singleChoice":case"dropdown":case"multipleChoice":case"tags":return"select";case"email":return"email";default:return"text"}}function eT(e){var t;if((t=e.config)!=null&&t.options&&Array.isArray(e.config.options))return e.config.options.map(r=>({name:r.value,label:r.label}))}function Gb(e){return!e||!e.rules||e.rules.length===0?{combinator:"and",rules:[]}:{combinator:e.combinator,rules:e.rules.map(t=>({field:t.field,operator:t.operator,value:t.value}))}}function tT(e){return{combinator:e.combinator,rules:e.rules.filter(t=>"field"in t).map(t=>"field"in t?{field:t.field,operator:t.operator,value:t.value}:null).filter(Boolean)}}function zb(e,t){return e.filter(r=>r.id!==t).filter(r=>!["divider","spacer","paragraph","image","link","formHeading","sectionHeading","subheading","submit"].includes(r.type)).map(r=>{var a;const o=J$(r.type),n=Z$(r.type),s=eT(r);return{name:r.id,label:r.properties.label||r.attributes.name||`Field ${r.order+1}`,inputType:n,operators:o.map(i=>({name:i.name,label:i.label})),values:s==null?void 0:s.map(i=>({name:i.name,label:i.label})),defaultOperator:((a=o[0])==null?void 0:a.name)||"equals"}})}const rT={queryBuilder:"qb-lite",ruleGroup:"p-2 rounded border border-border",combinators:"px-2 py-1 border border-input rounded text-sm bg-background",addRule:"px-2 py-1 bg-primary text-primary-foreground rounded text-xs hover:bg-primary/90",addGroup:"px-2 py-1 bg-secondary text-secondary-foreground rounded text-xs hover:bg-secondary/80 ml-1",removeGroup:"px-2 py-1 bg-destructive/10 text-destructive rounded text-xs hover:bg-destructive/20",removeRule:"px-1 py-1 text-destructive hover:text-destructive/80",fields:"px-2 py-1 border border-input rounded text-sm min-w-[120px] bg-background",operators:"px-2 py-1 border border-input rounded text-sm mx-1 bg-background",value:"px-2 py-1 border border-input rounded text-sm bg-background"};function oT(e,t){const r=Gb(e);if(r.rules.length===0)return"";const o={};for(const n of t)for(const s of Gr(n.operators??[]))if("options"in s)for(const a of s.options)o[a.name]=a.label;else o[s.name]=s.label;return nA(r,{format:"natural_language",fields:t,operatorMap:o,valueProcessor:n=>{const s=n.value;return s==null||s===""?"":Array.isArray(s)?s.join(", "):String(s)}})}var nT=Object.defineProperty,cr=(e,t)=>nT(e,"name",{value:t,configurable:!0}),Qd="Dialog",[Bb,AO]=sr(Qd),[sT,zr]=Bb(Qd),aT=cr(e=>{const{__scopeDialog:t,children:r,open:o,defaultOpen:n,onOpenChange:s,modal:a=!0}=e,i=S.useRef(null),c=S.useRef(null),[d,p]=yr({prop:o,defaultProp:n??!1,onChange:s,caller:Qd}),[u,f]=S.useState(0),[h,g]=S.useState(0);return l.jsx(sT,{scope:t,triggerRef:i,contentRef:c,contentId:br(),titleId:br(),descriptionId:br(),titlePresent:u>0,descriptionPresent:h>0,setTitleCount:f,setDescriptionCount:g,open:d,onOpenChange:p,onOpenToggle:S.useCallback(()=>p(y=>!y),[p]),modal:a,children:r})},"Dialog"),Ub="DialogPortal",[lT,Wb]=Bb(Ub,{forceMount:void 0}),iT=cr(e=>{const{__scopeDialog:t,forceMount:r,children:o,container:n}=e,s=zr(Ub,t);return l.jsx(lT,{scope:t,forceMount:r,children:S.Children.map(o,a=>l.jsx(eo,{present:r||s.open,children:l.jsx(tc,{asChild:!0,container:n,children:a})}))})},"DialogPortal"),Kd="DialogOverlay",Hb=S.forwardRef(cr(function(t,r){const o=Wb(Kd,t.__scopeDialog),{forceMount:n=o.forceMount,...s}=t,a=zr(Kd,t.__scopeDialog);return a.modal?l.jsx(eo,{present:n||a.open,children:l.jsx(dT,{...s,ref:r})}):null},"DialogOverlay")),cT=Yr("DialogOverlay.RemoveScroll"),dT=S.forwardRef(cr(function(t,r){const{__scopeDialog:o,...n}=t,s=zr(Kd,o),a=Ff(),i=Ue(r,a);return l.jsx(ic,{as:cT,allowPinchZoom:!0,shards:[s.contentRef],children:l.jsx(Ie.div,{"data-state":Rd(s.open),...n,ref:i,style:{pointerEvents:"auto",...n.style}})})},"DialogOverlayImpl")),Ns="DialogContent",jb=S.forwardRef(cr(function(t,r){const o=Wb(Ns,t.__scopeDialog),{forceMount:n=o.forceMount,...s}=t,a=zr(Ns,t.__scopeDialog);return l.jsx(eo,{present:n||a.open,children:a.modal?l.jsx(uT,{...s,ref:r}):l.jsx(fT,{...s,ref:r})})},"DialogContent")),uT=S.forwardRef(cr(function(t,r){const o=zr(Ns,t.__scopeDialog),n=S.useRef(null),s=Ue(r,o.contentRef,n);return S.useEffect(()=>{const a=n.current;if(a)return Fp(a)},[]),l.jsx(qb,{...t,ref:s,trapFocus:o.open,disableOutsidePointerEvents:o.open,onCloseAutoFocus:Se(t.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=o.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Se(t.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:Se(t.onFocusOutside,a=>a.preventDefault())})},"DialogContentModal")),fT=S.forwardRef(cr(function(t,r){const o=zr(Ns,t.__scopeDialog),n=S.useRef(!1),s=S.useRef(!1);return l.jsx(qb,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,c;(i=t.onCloseAutoFocus)==null||i.call(t,a),a.defaultPrevented||(n.current||(c=o.triggerRef.current)==null||c.focus(),a.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:a=>{var d,p;(d=t.onInteractOutside)==null||d.call(t,a),a.defaultPrevented||(n.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=a.target;((p=o.triggerRef.current)==null?void 0:p.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})},"DialogContentNonModal")),qb=S.forwardRef(cr(function(t,r){const{__scopeDialog:o,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:a,...i}=t,c=zr(Ns,o);return la(),l.jsx(l.Fragment,{children:l.jsx(Bf,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:a,children:l.jsx(Ii,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":Rd(c.open),...i,ref:r,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},"DialogContentImpl")),pT="DialogTitle",Yb=S.forwardRef(cr(function(t,r){const{__scopeDialog:o,...n}=t,s=zr(pT,o),{setTitleCount:a}=s;return ot(()=>(a(i=>i+1),()=>a(i=>i-1)),[a]),l.jsx(Ie.h2,{id:s.titleId,...n,ref:r})},"DialogTitle")),hT="DialogDescription",Qb=S.forwardRef(cr(function(t,r){const{__scopeDialog:o,...n}=t,s=zr(hT,o),{setDescriptionCount:a}=s;return ot(()=>(a(i=>i+1),()=>a(i=>i-1)),[a]),l.jsx(Ie.p,{id:s.descriptionId,...n,ref:r})},"DialogDescription")),mT="DialogClose",Kb=S.forwardRef(cr(function(t,r){const{__scopeDialog:o,...n}=t,s=zr(mT,o);return l.jsx(Ie.button,{type:"button",...n,ref:r,onClick:Se(t.onClick,()=>s.onOpenChange(!1))})},"DialogClose"));function Rd(e){return e?"open":"closed"}cr(Rd,"getState");const gT=aT,bT=iT,yT=Kb,Rb=S.forwardRef(({className:e,...t},r)=>l.jsx(Hb,{ref:r,className:m("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Rb.displayName=Hb.displayName;const Xb=S.forwardRef(({className:e,children:t,...r},o)=>l.jsxs(bT,{children:[l.jsx(Rb,{}),l.jsxs(jb,{ref:o,className:m("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[t,l.jsxs(Kb,{className:m("absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"),children:[l.jsx(Wn,{className:m("h-4 w-4")}),l.jsx("span",{className:m("sr-only"),children:"Close"})]})]})]}));Xb.displayName=jb.displayName;const Jb=({className:e,...t})=>l.jsx("div",{className:m("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Jb.displayName="DialogHeader";const Zb=({className:e,...t})=>l.jsx("div",{className:m("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Zb.displayName="DialogFooter";const ey=S.forwardRef(({className:e,...t},r)=>l.jsx(Yb,{ref:r,className:m("text-lg font-semibold leading-none tracking-tight",e),...t}));ey.displayName=Yb.displayName;const ty=S.forwardRef(({className:e,...t},r)=>l.jsx(Qb,{ref:r,className:m("text-sm text-muted-foreground",e),...t}));ty.displayName=Qb.displayName;const ry=[{key:"showWhen",label:"Show When",description:"This element will only be visible when these conditions are met."},{key:"hideWhen",label:"Hide When",description:"This element will be hidden when these conditions are met."},{key:"requireWhen",label:"Require When",description:"This element will be required when these conditions are met."},{key:"disableWhen",label:"Disable When",description:"This element will be disabled when these conditions are met."}],vT=({open:e,onOpenChange:t,element:r,elements:o,onUpdate:n})=>{const s=P.useMemo(()=>zb(o,r.id),[o,r.id]),a=P.useCallback((i,c)=>{const d=tT(c),p={...r.logic,[i]:d.rules.length>0?d:void 0};n({logic:p})},[r.logic,n]);return l.jsx(gT,{open:e,onOpenChange:t,children:l.jsxs(Xb,{className:"max-w-3xl max-h-[85vh] flex flex-col gap-4",children:[l.jsxs(Jb,{children:[l.jsx(ey,{children:"Conditional Logic"}),l.jsx(ty,{children:"Configure when this element is shown, hidden, required, or disabled based on other fields in the form."})]}),l.jsxs(zh,{defaultValue:"showWhen",className:"flex flex-col flex-1 min-h-0",children:[l.jsx(Dc,{className:"grid w-full grid-cols-4",children:ry.map(i=>{var d,p,u;const c=((u=(p=(d=r.logic)==null?void 0:d[i.key])==null?void 0:p.rules)==null?void 0:u.length)??0;return l.jsxs(Yn,{value:i.key,className:"text-xs",children:[i.label,c>0&&` (${c})`]},i.key)})}),ry.map(i=>{var c;return l.jsxs(Qn,{value:i.key,className:"flex-1 min-h-0 overflow-y-auto",children:[l.jsx("p",{className:m("text-xs text-muted-foreground mb-2"),children:i.description}),l.jsx("div",{className:m("query-builder-wrapper"),style:{"--rqb-background-color":"transparent"},children:l.jsx(K$,{fields:s,query:Gb((c=r.logic)==null?void 0:c[i.key]),onQueryChange:d=>a(i.key,d),controlClassnames:rT})})]},i.key)})]}),l.jsx(Zb,{children:l.jsx(yT,{asChild:!0,children:l.jsx(Je,{children:"Done"})})})]})})},xT=({title:e,children:t,defaultOpen:r=!1,badge:o})=>{const[n,s]=P.useState(r);return l.jsxs(qh,{open:n,onOpenChange:s,className:m("border border-border rounded-lg overflow-hidden"),children:[l.jsx(Yh,{asChild:!0,children:l.jsxs(Je,{variant:"ghost",className:m("w-full flex items-center justify-between px-3 py-2 h-auto bg-muted/50 hover:bg-muted rounded-none"),children:[l.jsxs("span",{className:m("flex items-center gap-2 text-sm font-medium text-foreground"),children:[e,o&&l.jsx(vc,{variant:"secondary",className:m("text-xs"),children:o})]}),l.jsx(mn,{className:m("h-4 w-4 transition-transform",n&&"rotate-180")})]})}),l.jsx(Qh,{children:l.jsx("div",{className:m("p-3 bg-card"),children:t})})]})},zl=({title:e,description:t,rule:r,fields:o,defaultOpen:n=!1,badge:s})=>{const a=oT(r,o);return l.jsxs(xT,{title:e,defaultOpen:n,badge:s,children:[l.jsx("p",{className:m("text-xs text-muted-foreground mb-2"),children:t}),a?l.jsx("div",{className:m("rounded-md border border-border bg-muted/40 px-3 py-2 text-sm text-foreground"),children:a}):l.jsx("p",{className:m("text-sm text-muted-foreground/70"),children:"No conditions set"})]})},wT=({element:e,elements:t,onUpdate:r})=>{var d,p,u,f,h,g,y,b,v,N,x,w,C,E,k,_,D,A,I,T,L,F,B,G,z,H,V,W,pe,U,Q,Ce,oe,ye,R,ce,re,Ae,we,ue,J,ne,fe,ke,Re,rt,st,Xe;const[o,n]=P.useState(!1),s=P.useMemo(()=>zb(t,e.id),[t,e.id]),a=P.useCallback(()=>{r({logic:void 0})},[r]),i=e.logic&&((((p=(d=e.logic.showWhen)==null?void 0:d.rules)==null?void 0:p.length)??0)>0||(((f=(u=e.logic.hideWhen)==null?void 0:u.rules)==null?void 0:f.length)??0)>0||(((g=(h=e.logic.requireWhen)==null?void 0:h.rules)==null?void 0:g.length)??0)>0||(((b=(y=e.logic.disableWhen)==null?void 0:y.rules)==null?void 0:b.length)??0)>0),c=(((x=(N=(v=e.logic)==null?void 0:v.showWhen)==null?void 0:N.rules)==null?void 0:x.length)??0)+(((E=(C=(w=e.logic)==null?void 0:w.hideWhen)==null?void 0:C.rules)==null?void 0:E.length)??0)+(((D=(_=(k=e.logic)==null?void 0:k.requireWhen)==null?void 0:_.rules)==null?void 0:D.length)??0)+(((T=(I=(A=e.logic)==null?void 0:A.disableWhen)==null?void 0:I.rules)==null?void 0:T.length)??0);return s.length===0?l.jsxs("div",{className:m("text-sm text-muted-foreground p-4 text-center bg-muted/50 rounded-lg"),children:[l.jsx(yh,{className:m("w-8 h-8 mx-auto mb-2 text-muted-foreground/50")}),l.jsx("p",{children:"Add more fields to enable conditional logic."}),l.jsx("p",{className:m("text-xs mt-1"),children:"Logic rules require other fields to reference."})]}):l.jsxs("div",{className:m("space-y-3"),children:[l.jsxs("div",{className:m("space-y-1"),children:[l.jsxs("div",{className:m("flex items-center gap-1"),children:[i&&l.jsxs(Je,{variant:"ghost",size:"sm",className:m("text-destructive hover:text-destructive hover:bg-destructive/10"),onClick:a,children:[l.jsx(mc,{className:m("h-3 w-3 mr-1")}),"Clear all"]}),l.jsxs(Je,{variant:"outline",size:"sm",onClick:()=>n(!0),children:[l.jsx(vh,{className:m("h-3 w-3 mr-1")}),"Configure"]})]}),l.jsx("div",{className:m("text-sm text-muted-foreground"),children:i?l.jsxs("span",{className:m("flex items-center gap-2"),children:[l.jsx("span",{className:m("w-2 h-2 bg-primary rounded-full")}),c," rule",c!==1?"s":""," ","configured"]}):l.jsx("span",{className:m("text-muted-foreground/70"),children:"No logic configured"})})]}),l.jsx(zl,{title:"Show When",description:"This element will only be visible when these conditions are met.",rule:(L=e.logic)==null?void 0:L.showWhen,fields:s,defaultOpen:!!((G=(B=(F=e.logic)==null?void 0:F.showWhen)==null?void 0:B.rules)!=null&&G.length),badge:(V=(H=(z=e.logic)==null?void 0:z.showWhen)==null?void 0:H.rules)!=null&&V.length?String(e.logic.showWhen.rules.length):void 0}),l.jsx(zl,{title:"Hide When",description:"This element will be hidden when these conditions are met.",rule:(W=e.logic)==null?void 0:W.hideWhen,fields:s,defaultOpen:!!((Q=(U=(pe=e.logic)==null?void 0:pe.hideWhen)==null?void 0:U.rules)!=null&&Q.length),badge:(ye=(oe=(Ce=e.logic)==null?void 0:Ce.hideWhen)==null?void 0:oe.rules)!=null&&ye.length?String(e.logic.hideWhen.rules.length):void 0}),l.jsx(zl,{title:"Required When",description:"This element will be required when these conditions are met.",rule:(R=e.logic)==null?void 0:R.requireWhen,fields:s,defaultOpen:!!((Ae=(re=(ce=e.logic)==null?void 0:ce.requireWhen)==null?void 0:re.rules)!=null&&Ae.length),badge:(J=(ue=(we=e.logic)==null?void 0:we.requireWhen)==null?void 0:ue.rules)!=null&&J.length?String(e.logic.requireWhen.rules.length):void 0}),l.jsx(zl,{title:"Disabled When",description:"This element will be disabled when these conditions are met.",rule:(ne=e.logic)==null?void 0:ne.disableWhen,fields:s,defaultOpen:!!((Re=(ke=(fe=e.logic)==null?void 0:fe.disableWhen)==null?void 0:ke.rules)!=null&&Re.length),badge:(Xe=(st=(rt=e.logic)==null?void 0:rt.disableWhen)==null?void 0:st.rules)!=null&&Xe.length?String(e.logic.disableWhen.rules.length):void 0}),l.jsx(vT,{open:o,onOpenChange:n,element:e,elements:t,onUpdate:r})]})};var ST=Object.defineProperty,NT=(e,t)=>ST(e,"name",{value:t,configurable:!0}),CT=S.forwardRef(NT(function(t,r){return l.jsx(Ie.label,{...t,ref:r,onMouseDown:o=>{var s;o.target.closest("button, input, select, textarea")||((s=t.onMouseDown)==null||s.call(t,o),!o.defaultPrevented&&o.detail>1&&o.preventDefault())}})},"Label")),oy=CT;const ET=Ma("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),dr=S.forwardRef(({className:e,...t},r)=>l.jsx(oy,{ref:r,className:m(ET(),e),...t}));dr.displayName=oy.displayName;const Xd=S.forwardRef(({className:e,...t},r)=>l.jsx("textarea",{className:m("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...t}));Xd.displayName="Textarea";var _T=Object.defineProperty,io=(e,t)=>_T(e,"name",{value:t,configurable:!0}),Jd="Checkbox",[kT,DO]=sr(Jd),[AT,Zd]=kT(Jd);function ny(e){const{__scopeCheckbox:t,checked:r,children:o,defaultChecked:n,disabled:s,form:a,name:i,onCheckedChange:c,required:d,value:p="on",internal_do_not_use_render:u}=e,[f,h]=yr({prop:r,defaultProp:n??!1,onChange:c,caller:Jd}),[g,y]=S.useState(null),[b,v]=S.useState(null),N=S.useRef(!1),[x,w]=S.useReducer(k=>k+1,0),C=g?!!a||!!g.closest("form"):!0,E={checked:f,disabled:s,setChecked:h,control:g,setControl:y,name:i,form:a,value:p,hasConsumerStoppedPropagationRef:N,userInteractionCount:x,onUserInteraction:w,required:d,defaultChecked:co(n)?!1:n,isFormControl:C,bubbleInput:b,setBubbleInput:v};return l.jsx(AT,{scope:t,...E,children:ay(u)?u(E):o})}io(ny,"CheckboxProvider");var DT="CheckboxTrigger",$T=S.forwardRef(io(function({__scopeCheckbox:t,onKeyDown:r,onClick:o,...n},s){const{control:a,value:i,disabled:c,checked:d,required:p,setControl:u,setChecked:f,hasConsumerStoppedPropagationRef:h,onUserInteraction:g,isFormControl:y,bubbleInput:b}=Zd(DT,t),v=Ue(s,u),N=S.useRef(d);return S.useEffect(()=>{const x=a==null?void 0:a.form;if(x){const w=io(()=>f(N.current),"reset");return x.addEventListener("reset",w),()=>x.removeEventListener("reset",w)}},[a,f]),l.jsx(Ie.button,{type:"button",role:"checkbox","aria-checked":co(d)?"mixed":d,"aria-required":p,"data-state":eu(d),"data-disabled":c?"":void 0,disabled:c,value:i,...n,ref:v,onKeyDown:Se(r,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Se(o,x=>{g(),f(w=>co(w)?!0:!w),b&&y&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})})},"CheckboxTrigger")),sy=S.forwardRef(io(function(t,r){const{__scopeCheckbox:o,name:n,checked:s,defaultChecked:a,required:i,disabled:c,value:d,onCheckedChange:p,form:u,...f}=t;return l.jsx(ny,{__scopeCheckbox:o,checked:s,defaultChecked:a,disabled:c,required:i,onCheckedChange:p,name:n,form:u,value:d,internal_do_not_use_render:({isFormControl:h})=>l.jsxs(l.Fragment,{children:[l.jsx($T,{...f,ref:r,__scopeCheckbox:o}),h&&l.jsx(OT,{__scopeCheckbox:o})]})})},"Checkbox")),TT="CheckboxIndicator",PT=S.forwardRef(io(function(t,r){const{__scopeCheckbox:o,forceMount:n,...s}=t,a=Zd(TT,o);return l.jsx(eo,{present:n||co(a.checked)||a.checked===!0,children:l.jsx(Ie.span,{"data-state":eu(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:r,style:{pointerEvents:"none",...t.style}})})},"CheckboxIndicator")),IT="CheckboxBubbleInput",OT=S.forwardRef(io(function({__scopeCheckbox:t,onClick:r,...o},n){const{control:s,hasConsumerStoppedPropagationRef:a,userInteractionCount:i,checked:c,defaultChecked:d,required:p,disabled:u,name:f,value:h,form:g,bubbleInput:y,setBubbleInput:b}=Zd(IT,t),v=Ue(n,b),N=ec(s),x=S.useRef(!1),w=S.useRef(c),C=S.useRef(i);S.useEffect(()=>{const k=y;if(!k)return;const _=window.HTMLInputElement.prototype,A=Object.getOwnPropertyDescriptor(_,"checked").set,I=i!==C.current;C.current=i;const T=w.current!==c;w.current=c;const L=!(I&&a.current);if(T&&A){x.current=!I;const F=new Event("click",{bubbles:L});k.indeterminate=co(c),A.call(k,co(c)?!1:c),k.dispatchEvent(F),x.current=!1}},[y,c,a,i]);const E=S.useRef(co(c)?!1:c);return l.jsx(Ie.input,{type:"checkbox","aria-hidden":!0,defaultChecked:d??E.current,required:p,disabled:u,name:f,value:h,form:g,...o,tabIndex:-1,ref:v,onClick:Se(r,k=>{x.current&&k.stopPropagation()}),style:{...o.style,...N,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function ay(e){return typeof e=="function"}io(ay,"isFunction");function co(e){return e==="indeterminate"}io(co,"isIndeterminate");function eu(e){return co(e)?"indeterminate":e?"checked":"unchecked"}io(eu,"getState");const tu=S.forwardRef(({className:e,...t},r)=>l.jsx(sy,{ref:r,className:m("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:l.jsx(PT,{className:m("grid place-content-center text-current"),children:l.jsx(mh,{className:m("h-4 w-4")})})}));tu.displayName=sy.displayName;var MT=Object.defineProperty,er=(e,t)=>MT(e,"name",{value:t,configurable:!0}),Br="Accordion",LT=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[ru,FT,VT]=na(Br),[Bl,$O]=sr(Br,[VT,Bh]),ou=Bh(),GT=S.forwardRef(er(function(t,r){const{type:o,...n}=t,s=n,a=n;return l.jsx(ru.Provider,{scope:t.__scopeAccordion,children:o==="multiple"?l.jsx(WT,{...a,ref:r}):l.jsx(UT,{...s,ref:r})})},"Accordion")),[ly,zT]=Bl(Br),[iy,BT]=Bl(Br,{collapsible:!1}),UT=S.forwardRef(er(function(t,r){const{value:o,defaultValue:n,onValueChange:s=er(()=>{},"onValueChange"),collapsible:a=!1,...i}=t,[c,d]=yr({prop:o,defaultProp:n??"",onChange:s,caller:Br});return l.jsx(ly,{scope:t.__scopeAccordion,value:S.useMemo(()=>c?[c]:[],[c]),onItemOpen:d,onItemClose:S.useCallback(()=>a&&d(""),[a,d]),children:l.jsx(iy,{scope:t.__scopeAccordion,collapsible:a,children:l.jsx(cy,{...i,ref:r})})})},"AccordionImplSingle")),WT=S.forwardRef(er(function(t,r){const{value:o,defaultValue:n,onValueChange:s=er(()=>{},"onValueChange"),...a}=t,[i,c]=yr({prop:o,defaultProp:n??[],onChange:s,caller:Br}),d=S.useCallback(u=>c((f=[])=>[...f,u]),[c]),p=S.useCallback(u=>c((f=[])=>f.filter(h=>h!==u)),[c]);return l.jsx(ly,{scope:t.__scopeAccordion,value:i,onItemOpen:d,onItemClose:p,children:l.jsx(iy,{scope:t.__scopeAccordion,collapsible:!0,children:l.jsx(cy,{...a,ref:r})})})},"AccordionImplMultiple")),[HT,Ul]=Bl(Br),cy=S.forwardRef(er(function(t,r){const{__scopeAccordion:o,disabled:n,dir:s,orientation:a="vertical",...i}=t,c=S.useRef(null),d=Ue(c,r),p=FT(o),f=Vn(s)==="ltr",h=Se(t.onKeyDown,g=>{var D;if(!LT.includes(g.key))return;const y=g.target,b=p().filter(A=>{var I;return!((I=A.ref.current)!=null&&I.disabled)}),v=b.findIndex(A=>A.ref.current===y),N=b.length;if(v===-1)return;g.preventDefault();let x=v;const w=0,C=N-1,E=er(()=>{x=v+1,x>C&&(x=w)},"moveNext"),k=er(()=>{x=v-1,x<w&&(x=C)},"movePrev");switch(g.key){case"Home":x=w;break;case"End":x=C;break;case"ArrowRight":a==="horizontal"&&(f?E():k());break;case"ArrowDown":a==="vertical"&&E();break;case"ArrowLeft":a==="horizontal"&&(f?k():E());break;case"ArrowUp":a==="vertical"&&k();break}const _=x%N;(D=b[_].ref.current)==null||D.focus()});return l.jsx(HT,{scope:o,disabled:n,direction:s,orientation:a,children:l.jsx(ru.Slot,{scope:o,children:l.jsx(Ie.div,{...i,"data-orientation":a,ref:d,onKeyDown:n?void 0:h})})})},"AccordionImpl")),nu="AccordionItem",[jT,su]=Bl(nu),qT=S.forwardRef(er(function(t,r){const{__scopeAccordion:o,value:n,...s}=t,a=Ul(nu,o),i=zT(nu,o),c=ou(o),d=br(),p=n&&i.value.includes(n)||!1,u=a.disabled||t.disabled;return l.jsx(jT,{scope:o,open:p,disabled:u,triggerId:d,children:l.jsx(jh,{"data-orientation":a.orientation,"data-state":au(p),...c,...s,ref:r,disabled:u,open:p,onOpenChange:f=>{f?i.onItemOpen(n):i.onItemClose(n)}})})},"AccordionItem")),YT="AccordionHeader",QT=S.forwardRef(er(function(t,r){const{__scopeAccordion:o,...n}=t,s=Ul(Br,o),a=su(YT,o);return l.jsx(Ie.h3,{"data-orientation":s.orientation,"data-state":au(a.open),"data-disabled":a.disabled?"":void 0,...n,ref:r})},"AccordionHeader")),dy="AccordionTrigger",KT=S.forwardRef(er(function(t,r){const{__scopeAccordion:o,...n}=t,s=Ul(Br,o),a=su(dy,o),i=BT(dy,o),c=ou(o);return l.jsx(ru.ItemSlot,{scope:o,children:l.jsx(L1,{"aria-disabled":a.open&&!i.collapsible||void 0,"data-orientation":s.orientation,id:a.triggerId,...c,...n,ref:r})})},"AccordionTrigger")),RT="AccordionContent",XT=S.forwardRef(er(function(t,r){const{__scopeAccordion:o,...n}=t,s=Ul(Br,o),a=su(RT,o),i=ou(o);return l.jsx(F1,{role:"region","aria-labelledby":a.triggerId,"data-orientation":s.orientation,...i,...n,ref:r,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...t.style}})},"AccordionContent"));function au(e){return e?"open":"closed"}er(au,"getState");var JT=GT,ZT=qT,eP=QT,uy=KT,fy=XT;const py=JT,lu=S.forwardRef(({className:e,...t},r)=>l.jsx(ZT,{ref:r,className:m("border-b",e),...t}));lu.displayName="AccordionItem";const iu=S.forwardRef(({className:e,children:t,...r},o)=>l.jsx(eP,{className:m("flex"),children:l.jsxs(uy,{ref:o,className:m("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",e),...r,children:[t,l.jsx(mn,{className:m("h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200")})]})}));iu.displayName=uy.displayName;const cu=S.forwardRef(({className:e,children:t,...r},o)=>l.jsx(fy,{ref:o,className:m("overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"),...r,children:l.jsx("div",{className:m("pb-4 pt-0",e),children:t})}));cu.displayName=fy.displayName;function du(e,t,r){var o,n,s,a;switch(t){case"properties":return(o=e.properties)==null?void 0:o[r];case"config":return(n=e.config)==null?void 0:n[r];case"layout":return(s=e.layout)==null?void 0:s[r];case"validation":return(a=e.validation)==null?void 0:a[r];default:return}}function tP(e,t,r,o){switch(e){case"properties":return{properties:{...t.properties,[r]:o}};case"config":return{config:{...t.config,[r]:o}};case"layout":return{layout:{...t.layout,[r]:o}};case"validation":return{validation:{...t.validation,[r]:o}};default:return{}}}function rP(e,t,r){const{field:o,value:n}=r;if(o.includes(".")){const[a,...i]=o.split("."),c=i.join(".");return du(e,a,c)===n}return du(e,t.section,o)===n}const hy=({field:e,element:t,onUpdate:r})=>{var s;const o=du(t,e.section,e.key)??e.defaultValue,n=a=>{r(tP(e.section,t,e.key,a))};switch(e.type){case"text":case"url":case"color":return l.jsxs("div",{className:m("space-y-1.5"),children:[l.jsx(dr,{className:m("text-xs font-medium text-muted-foreground"),children:e.label}),l.jsx(ar,{type:e.type==="color"?"color":e.type==="url"?"url":"text",value:o??"",onChange:a=>n(a.target.value),placeholder:e.placeholder}),e.description&&l.jsx("p",{className:m("text-[11px] text-muted-foreground"),children:e.description})]});case"textarea":return l.jsxs("div",{className:m("space-y-1.5"),children:[l.jsx(dr,{className:m("text-xs font-medium text-muted-foreground"),children:e.label}),l.jsx(Xd,{value:o??"",onChange:a=>n(a.target.value),placeholder:e.placeholder,rows:e.rows??3}),e.description&&l.jsx("p",{className:m("text-[11px] text-muted-foreground"),children:e.description})]});case"number":return l.jsxs("div",{className:m("space-y-1.5"),children:[l.jsx(dr,{className:m("text-xs font-medium text-muted-foreground"),children:e.label}),l.jsx(ar,{type:"number",value:o??"",onChange:a=>{const i=a.target.value;n(i?Number.isInteger(e.min)||Number.isInteger(e.max)?parseInt(i,10):parseFloat(i):void 0)},placeholder:e.placeholder,min:e.min,max:e.max}),e.description&&l.jsx("p",{className:m("text-[11px] text-muted-foreground"),children:e.description})]});case"checkbox":return l.jsxs("div",{className:m("flex items-start space-x-2"),children:[l.jsx(tu,{id:`ds-${e.section}-${e.key}`,checked:!!o,onCheckedChange:a=>n(!!a)}),l.jsxs("div",{className:m("space-y-0.5 leading-none"),children:[l.jsx(dr,{htmlFor:`ds-${e.section}-${e.key}`,className:m("text-xs font-medium text-foreground cursor-pointer"),children:e.label}),e.description&&l.jsx("p",{className:m("text-[11px] text-muted-foreground"),children:e.description})]})]});case"select":return l.jsxs("div",{className:m("space-y-1.5"),children:[l.jsx(dr,{className:m("text-xs font-medium text-muted-foreground"),children:e.label}),l.jsxs(Ta,{value:o!=null?String(o):"",onValueChange:a=>{var c;const i=(c=e.options)==null?void 0:c.find(d=>typeof d.value=="number"&&String(d.value)===a);n(i?i.value:a)},children:[l.jsx(Hn,{children:l.jsx(Pa,{placeholder:e.placeholder||"Select..."})}),l.jsx(jn,{children:(s=e.options)==null?void 0:s.map(a=>l.jsx(Vo,{value:String(a.value),children:a.label},String(a.value)))})]}),e.description&&l.jsx("p",{className:m("text-[11px] text-muted-foreground"),children:e.description})]});default:return null}},oP=({title:e,icon:t,defaultOpen:r=!0,children:o})=>l.jsx(py,{type:"single",collapsible:!0,defaultValue:r?"item":void 0,children:l.jsxs(lu,{value:"item",className:m("border-b border-border"),children:[l.jsx(iu,{className:m("px-4 py-3 hover:bg-muted/50 hover:no-underline"),children:l.jsxs("span",{className:m("text-sm font-medium text-foreground flex items-center gap-2"),children:[t&&l.jsx("span",{children:t}),e]})}),l.jsx(cu,{className:m("px-4 pb-4 mb-4"),children:l.jsx("div",{className:m("space-y-4"),children:o})})]})}),nP=({element:e,schema:t,onUpdate:r})=>{const o=t.fields.filter(c=>c.showWhen?rP(e,c,c.showWhen):!0),n=[];let s=[];const a=()=>{s.length>0&&(n.push(s),s=[])};for(const c of o)c.colSpan===1?(s.push(c),s.length===2&&a()):(a(),n.push([c]));a();const{configSection:i}=t;return l.jsx(oP,{title:(i==null?void 0:i.title)??"Settings",icon:i==null?void 0:i.icon,defaultOpen:!1,children:n.map((c,d)=>{if(!c.every(u=>u.colSpan===1)){const u=c[0];return l.jsx(hy,{field:u,element:e,onUpdate:r},`${u.section}.${u.key}`)}return l.jsx("div",{className:m("grid grid-cols-2 gap-2"),children:c.map(u=>l.jsx(hy,{field:u,element:e,onUpdate:r},`${u.section}.${u.key}`))},`row-${d}`)})})},So=({title:e,children:t,defaultOpen:r=!0,icon:o})=>l.jsx(py,{type:"single",collapsible:!0,defaultValue:r?"item":void 0,children:l.jsxs(lu,{value:"item",className:m("border-b border-border"),children:[l.jsx(iu,{className:m("px-4 py-3 hover:bg-muted/50 hover:no-underline"),children:l.jsxs("span",{className:m("text-sm font-medium text-foreground flex items-center gap-2"),children:[o&&l.jsx("span",{children:o}),e]})}),l.jsx(cu,{className:m("px-4 pb-4 mb-4"),children:l.jsx("div",{className:m("space-y-4"),children:t})})]})}),Ye=({label:e,value:t,onChange:r,type:o="text",placeholder:n,rows:s=3,min:a,max:i,step:c,helpText:d})=>l.jsxs("div",{className:m("space-y-1.5"),children:[l.jsx(dr,{className:m("text-sm font-medium"),children:e}),o==="textarea"?l.jsx(Xd,{value:t??"",onChange:p=>r(p.target.value),placeholder:n,rows:s,className:m("resize-none")}):o==="color"?l.jsxs("div",{className:m("flex gap-2"),children:[l.jsx("input",{type:"color",value:(t==null?void 0:t.toString())||"#000000",onChange:p=>r(p.target.value),className:m("w-10 h-9 border border-input rounded-md cursor-pointer")}),l.jsx(ar,{type:"text",value:t??"",onChange:p=>r(p.target.value),placeholder:n||"#000000",className:m("flex-1")})]}):l.jsx(ar,{type:o,value:t??"",onChange:p=>r(p.target.value),placeholder:n,min:a,max:i,step:c}),d&&l.jsx("p",{className:m("text-xs text-muted-foreground"),children:d})]}),my=({label:e,checked:t,onChange:r,description:o})=>l.jsxs("div",{className:m("flex items-start gap-3"),children:[l.jsx(tu,{id:e,checked:t||!1,onCheckedChange:n=>r(n===!0),className:m("mt-0.5")}),l.jsxs("div",{className:m("grid gap-0.5 leading-none"),children:[l.jsx(dr,{htmlFor:e,className:m("text-sm font-medium cursor-pointer"),children:e}),o&&l.jsx("p",{className:m("text-xs text-muted-foreground"),children:o})]})]}),uu=({label:e,value:t,onChange:r,options:o,helpText:n})=>l.jsxs("div",{className:m("space-y-1.5"),children:[l.jsx(dr,{className:m("text-sm font-medium"),children:e}),l.jsxs(Ta,{value:(t==null?void 0:t.toString())??"",onValueChange:r,children:[l.jsx(Hn,{className:m("w-full"),children:l.jsx(Pa,{placeholder:"Select..."})}),l.jsx(jn,{children:o.map(s=>l.jsx(Vo,{value:s.value,children:s.label},s.value))})]}),n&&l.jsx("p",{className:m("text-xs text-muted-foreground"),children:n})]}),sP=({options:e,onChange:t})=>{const r=(a,i,c)=>{const d=[...e];if(d[a]={...d[a],[i]:c},i==="label"){const p=d[a].value,u=e[a].label;(!p||p===mi(u))&&(d[a].value=mi(c))}t(d)},o=()=>{const a=e.length+1;t([...e,{label:`Option ${a}`,value:`option${a}`}])},n=a=>{e.length>1&&t(e.filter((i,c)=>c!==a))},s=(a,i)=>{const c=i==="up"?a-1:a+1;if(c<0||c>=e.length)return;const d=[...e];[d[a],d[c]]=[d[c],d[a]],t(d)};return l.jsxs("div",{className:m("space-y-2"),children:[l.jsx(dr,{className:m("text-sm font-medium"),children:"Options"}),l.jsx("div",{className:m("space-y-2"),children:e.map((a,i)=>l.jsxs("div",{className:m("flex items-center gap-1"),children:[l.jsxs("div",{className:m("flex flex-col gap-0.5"),children:[l.jsx(Je,{variant:"ghost",size:"icon",className:m("h-5 w-5"),onClick:()=>s(i,"up"),disabled:i===0,children:l.jsx(gh,{className:m("h-3 w-3")})}),l.jsx(Je,{variant:"ghost",size:"icon",className:m("h-5 w-5"),onClick:()=>s(i,"down"),disabled:i===e.length-1,children:l.jsx(mn,{className:m("h-3 w-3")})})]}),l.jsx(ar,{type:"text",value:a.label,onChange:c=>r(i,"label",c.target.value),placeholder:"Label",className:m("flex-1 h-8")}),l.jsx(ar,{type:"text",value:a.value,onChange:c=>r(i,"value",c.target.value),placeholder:"Value",className:m("w-20 h-8 text-muted-foreground")}),l.jsx(Va,{children:l.jsxs(Or,{children:[l.jsx(Mr,{asChild:!0,children:l.jsx(Je,{variant:"ghost",size:"icon",className:m("h-8 w-8"),onClick:()=>n(i),disabled:e.length<=1,children:l.jsx(Wn,{className:m("h-4 w-4")})})}),l.jsx(xr,{children:"Remove option"})]})})]},i))}),l.jsxs(Je,{variant:"ghost",size:"sm",className:m("text-primary"),onClick:o,children:[l.jsx(hc,{className:m("h-4 w-4 mr-1")}),"Add option"]})]})},aP=({rows:e,columns:t,onRowsChange:r,onColumnsChange:o,showColumnType:n=!1})=>{const s=()=>{const u=`row${e.length+1}`;r([...e,{id:u,label:`Row ${e.length+1}`}])},a=u=>{e.length>1&&r(e.filter((f,h)=>h!==u))},i=(u,f,h)=>{const g=[...e];g[u]={...g[u],[f]:h},r(g)},c=()=>{const u=`col${t.length+1}`;o([...t,{id:u,label:`Column ${t.length+1}`,type:"text"}])},d=u=>{t.length>1&&o(t.filter((f,h)=>h!==u))},p=(u,f,h)=>{const g=[...t];g[u]={...g[u],[f]:h},o(g)};return l.jsxs("div",{className:m("space-y-4"),children:[l.jsxs("div",{className:m("space-y-2"),children:[l.jsx(dr,{className:m("text-sm font-medium"),children:"Rows"}),l.jsx("div",{className:m("space-y-2"),children:e.map((u,f)=>l.jsxs("div",{className:m("flex items-center gap-2"),children:[l.jsx(ar,{type:"text",value:u.id,onChange:h=>i(f,"id",h.target.value),placeholder:"Row ID",className:m("w-24 h-8 font-mono text-xs")}),l.jsx(ar,{type:"text",value:u.label,onChange:h=>i(f,"label",h.target.value),placeholder:"Row label",className:m("flex-1 h-8")}),l.jsx(Je,{variant:"ghost",size:"icon",className:m("h-8 w-8"),onClick:()=>a(f),disabled:e.length<=1,children:l.jsx(Wn,{className:m("h-4 w-4")})})]},f))}),l.jsxs(Je,{variant:"ghost",size:"sm",className:m("text-primary"),onClick:s,children:[l.jsx(hc,{className:m("h-4 w-4 mr-1")}),"Add row"]})]}),l.jsxs("div",{className:m("space-y-2"),children:[l.jsx(dr,{className:m("text-sm font-medium"),children:"Columns"}),l.jsx("div",{className:m("space-y-2"),children:t.map((u,f)=>l.jsxs("div",{className:m("flex items-center gap-2"),children:[l.jsx(ar,{type:"text",value:u.id,onChange:h=>p(f,"id",h.target.value),placeholder:"Column ID",className:m("w-24 h-8 font-mono text-xs")}),l.jsx(ar,{type:"text",value:u.label,onChange:h=>p(f,"label",h.target.value),placeholder:"Column label",className:m("flex-1 h-8")}),n&&l.jsxs(Ta,{value:u.type||"text",onValueChange:h=>p(f,"type",h),children:[l.jsx(Hn,{className:m("w-24 h-8"),children:l.jsx(Pa,{})}),l.jsxs(jn,{children:[l.jsx(Vo,{value:"text",children:"Text"}),l.jsx(Vo,{value:"number",children:"Number"}),l.jsx(Vo,{value:"dropdown",children:"Dropdown"})]})]}),l.jsx(Je,{variant:"ghost",size:"icon",className:m("h-8 w-8"),onClick:()=>d(f),disabled:t.length<=1,children:l.jsx(Wn,{className:m("h-4 w-4")})})]},f))}),l.jsxs(Je,{variant:"ghost",size:"sm",className:m("text-primary"),onClick:c,children:[l.jsx(hc,{className:m("h-4 w-4 mr-1")}),"Add column"]})]})]})},lP=({element:e,onUpdate:t})=>{const r=(c,d)=>{t({properties:{...e.properties,[c]:d}})},o=["shortText","longText","multiLineInput","textEditor","number","email","phone","url","location","password","dropdown","tags","date","time","dateTime","multipleDates","dateRange"].includes(e.type),n=!["divider","spacer","paragraph","image","link"].includes(e.type),s=["paragraph"].includes(e.type),a=["link"].includes(e.type),i=["image"].includes(e.type);return l.jsxs(So,{title:"Properties",icon:"📝",children:[!["divider","spacer"].includes(e.type)&&l.jsx(Ye,{label:"Label",value:e.properties.label,onChange:c=>r("label",c),placeholder:"Enter label..."}),o&&l.jsx(Ye,{label:"Placeholder",value:e.properties.placeholder,onChange:c=>r("placeholder",c),placeholder:"Enter placeholder..."}),n&&l.jsx(Ye,{label:"Description",value:e.properties.description,onChange:c=>r("description",c),type:"textarea",placeholder:"Enter description...",rows:2}),s&&l.jsx(Ye,{label:"Content",value:e.properties.content,onChange:c=>r("content",c),type:"textarea",placeholder:"Enter paragraph text...",rows:4}),a&&l.jsxs(l.Fragment,{children:[l.jsx(Ye,{label:"Link Text",value:e.properties.content,onChange:c=>r("content",c),placeholder:"Click here"}),l.jsx(Ye,{label:"URL",value:e.properties.href,onChange:c=>r("href",c),type:"url",placeholder:"https://example.com"}),l.jsx(uu,{label:"Target",value:e.properties.target,onChange:c=>r("target",c),options:[{value:"_blank",label:"New Tab"},{value:"_self",label:"Same Tab"}]})]}),i&&l.jsxs(l.Fragment,{children:[l.jsx(Ye,{label:"Image URL",value:e.properties.src,onChange:c=>r("src",c),type:"url",placeholder:"https://example.com/image.jpg"}),l.jsx(Ye,{label:"Alt Text",value:e.properties.alt,onChange:c=>r("alt",c),placeholder:"Image description"})]}),["shortText","number"].includes(e.type)&&l.jsxs("div",{className:m("grid grid-cols-2 gap-2"),children:[l.jsx(Ye,{label:"Prefix",value:e.properties.prefix,onChange:c=>r("prefix",c),placeholder:"$"}),l.jsx(Ye,{label:"Suffix",value:e.properties.suffix,onChange:c=>r("suffix",c),placeholder:".00"})]})]})},iP=({element:e,onUpdate:t})=>{const r=(n,s)=>{t({layout:{...e.layout,[n]:s}})},o=!["divider","spacer","formHeading","sectionHeading","subheading","paragraph","image","link","captcha","decisionBox"].includes(e.type);return l.jsxs(So,{title:"Layout",icon:"📐",defaultOpen:!1,children:[o&&l.jsx(uu,{label:"Label Position",value:e.layout.labelPosition,onChange:n=>r("labelPosition",n),options:[{value:"top",label:"Top"},{value:"left",label:"Left"},{value:"hidden",label:"Hidden"}]}),l.jsx(uu,{label:"Size",value:e.layout.size,onChange:n=>r("size",n),options:[{value:"small",label:"Small"},{value:"default",label:"Default"},{value:"medium",label:"Medium"},{value:"large",label:"Large"},{value:"full",label:"Full Width"}]}),l.jsx(Ye,{label:"Custom Width",value:e.layout.width,onChange:n=>r("width",n),placeholder:"e.g., 50%, 300px"}),l.jsx(Ye,{label:"CSS Class",value:e.layout.className,onChange:n=>r("className",n),placeholder:"custom-class",helpText:"Additional CSS classes"})]})},cP=({element:e,onUpdate:t})=>{var c,d,p,u,f,h,g,y,b,v,N;const r=(x,w)=>{t({validation:{...e.validation,[x]:w}})},o=Aw(e.type),n=["shortText","longText","multiLineInput","textEditor","password"].includes(e.type),s=["number","slider","rangeSlider"].includes(e.type),a=["multiFileUpload","multiImageUpload"].includes(e.type),i=["multipleDates"].includes(e.type);return l.jsxs(So,{title:"Validation",icon:"✅",defaultOpen:!1,children:[o.supportsRequired&&l.jsx(my,{label:"Required",checked:(c=e.validation)==null?void 0:c.required,onChange:x=>r("required",x),description:"Field must be filled"}),n&&l.jsxs("div",{className:m("grid grid-cols-2 gap-2"),children:[l.jsx(Ye,{label:"Min Length",value:(d=e.validation)==null?void 0:d.minLength,onChange:x=>r("minLength",x?parseInt(x):void 0),type:"number",placeholder:"0",min:0}),l.jsx(Ye,{label:"Max Length",value:(p=e.validation)==null?void 0:p.maxLength,onChange:x=>r("maxLength",x?parseInt(x):void 0),type:"number",placeholder:"255",min:0})]}),s&&l.jsxs("div",{className:m("grid grid-cols-2 gap-2"),children:[l.jsx(Ye,{label:"Min Value",value:(u=e.validation)==null?void 0:u.min,onChange:x=>r("min",x?parseFloat(x):void 0),type:"number"}),l.jsx(Ye,{label:"Max Value",value:(f=e.validation)==null?void 0:f.max,onChange:x=>r("max",x?parseFloat(x):void 0),type:"number"})]}),o.supportsPattern&&l.jsx(Ye,{label:"Pattern (Regex)",value:(h=e.validation)==null?void 0:h.pattern,onChange:x=>r("pattern",x),placeholder:"^[a-zA-Z]+$",helpText:"Regular expression for validation"}),a&&l.jsxs("div",{className:m("grid grid-cols-2 gap-2"),children:[l.jsx(Ye,{label:"Min Files",value:(g=e.validation)==null?void 0:g.minFiles,onChange:x=>r("minFiles",x?parseInt(x):void 0),type:"number",min:0}),l.jsx(Ye,{label:"Max Files",value:(y=e.validation)==null?void 0:y.maxFiles,onChange:x=>r("maxFiles",x?parseInt(x):void 0),type:"number",min:1})]}),i&&l.jsxs("div",{className:m("grid grid-cols-2 gap-2"),children:[l.jsx(Ye,{label:"Min Dates",value:(b=e.validation)==null?void 0:b.minDates,onChange:x=>r("minDates",x?parseInt(x):void 0),type:"number",min:0}),l.jsx(Ye,{label:"Max Dates",value:(v=e.validation)==null?void 0:v.maxDates,onChange:x=>r("maxDates",x?parseInt(x):void 0),type:"number",min:1})]}),l.jsx(Ye,{label:"Error Message",value:(N=e.validation)==null?void 0:N.errorMessage,onChange:x=>r("errorMessage",x),placeholder:"Custom error message..."})]})},dP=({element:e,onUpdate:t,existingNames:r})=>{const[o,n]=P.useState(null),s=(a,i)=>{{const c=new Set(r);c.delete(e.attributes.name),c.has(i)?n("This field name already exists"):!i||i.trim()===""?n("Field name is required"):/^[a-zA-Z][a-zA-Z0-9_]*$/.test(i)?n(null):n("Must start with letter, only letters/numbers/underscores")}t({attributes:{...e.attributes,[a]:i}})};return l.jsx(So,{title:"Attributes",icon:"🏷️",defaultOpen:!1,children:l.jsxs("div",{children:[l.jsx("label",{className:m("block text-sm font-medium text-gray-700 mb-1"),children:"Field Name"}),l.jsx("input",{type:"text",value:e.attributes.name||"",onChange:a=>s("name",a.target.value),placeholder:"fieldName",className:m("w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:border-transparent",o?"border-red-500 focus:ring-red-500":"border-gray-300 focus:ring-blue-500")}),o&&l.jsx("p",{className:m("mt-1 text-xs text-red-600"),children:o}),l.jsx("p",{className:m("mt-1 text-xs text-gray-500"),children:"Used as the key in JSON output"})]})})},uP=({element:e,onUpdate:t})=>{var n,s,a,i;const r=c=>{t({config:{...e.config,options:c}})},o=(c,d)=>{t({config:{...e.config,[c]:d}})};return l.jsxs(So,{title:"Options",icon:"📋",children:[l.jsx(sP,{options:((n=e.config)==null?void 0:n.options)||[],onChange:r}),l.jsx(my,{label:"Allow 'Other' option",checked:(s=e.config)==null?void 0:s.allowOther,onChange:c=>o("allowOther",c),description:"Let users enter custom value"}),((a=e.config)==null?void 0:a.allowOther)&&l.jsx(Ye,{label:"Other Label",value:(i=e.config)==null?void 0:i.otherLabel,onChange:c=>o("otherLabel",c),placeholder:"Other..."})]})},fP=({element:e,onUpdate:t})=>{var o,n;const r=(s,a)=>{t({config:{...e.config,[s]:a}})};return l.jsx(So,{title:"Matrix Configuration",icon:"📊",children:l.jsx(aP,{rows:((o=e.config)==null?void 0:o.matrixRows)||[],columns:((n=e.config)==null?void 0:n.matrixColumns)||[],onRowsChange:s=>r("matrixRows",s),onColumnsChange:s=>r("matrixColumns",s),showColumnType:e.type==="matrixTable"})})},pP=()=>l.jsxs("div",{className:m("flex flex-col items-center justify-center h-full text-center px-6 py-12"),children:[l.jsx("div",{className:m("w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4"),children:l.jsx(vh,{className:m("w-6 h-6 text-muted-foreground")})}),l.jsx("h3",{className:m("text-sm font-medium text-foreground mb-1"),children:"No element selected"}),l.jsx("p",{className:m("text-xs text-muted-foreground"),children:"Click on an element in the canvas to edit its properties"})]}),hP=({element:e,onUpdate:t,propertyConfig:r})=>{const o=(p,u)=>{t({properties:{...e.properties,[p]:u}})},n=r??{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!1,showSuffix:!1},s=n.showLabel!==!1,a=n.showPlaceholder===!0,i=n.showDescription!==!1,c=n.showPrefix===!0,d=n.showSuffix===!0;return!s&&!a&&!i&&!c&&!d?null:l.jsxs(So,{title:"Properties",icon:"📝",children:[s&&l.jsx(Ye,{label:"Label",value:e.properties.label,onChange:p=>o("label",p),placeholder:"Enter label..."}),a&&l.jsx(Ye,{label:"Placeholder",value:e.properties.placeholder,onChange:p=>o("placeholder",p),placeholder:"Enter placeholder..."}),i&&l.jsx(Ye,{label:"Description",value:e.properties.description,onChange:p=>o("description",p),type:"textarea",placeholder:"Enter description...",rows:2}),(c||d)&&l.jsxs("div",{className:m("grid grid-cols-2 gap-2"),children:[c&&l.jsx(Ye,{label:"Prefix",value:e.properties.prefix,onChange:p=>o("prefix",p),placeholder:"$"}),d&&l.jsx(Ye,{label:"Suffix",value:e.properties.suffix,onChange:p=>o("suffix",p),placeholder:".00"})]})]})},mP=()=>{const e=Pw(),t=te(g=>g.updateElement),r=te(g=>g.deleteElement),o=te(g=>g.duplicateElement),n=te(g=>g.schema.elements),s=P.useMemo(()=>new Set(n.map(g=>g.attributes.name).filter(Boolean)),[n]);if(!e)return l.jsx("div",{className:m("w-72 bg-card border-l border-border flex-col h-full hidden"),children:l.jsx(pP,{})});const a=g=>{t(e.id,g)},i=ut.get(e.type),c=!!(i!=null&&i.renderSettings),d=i==null?void 0:i.settingsSchema,p=c||!!d,u=i!=null&&i.icon&&typeof i.icon=="string"?i.icon:bc[e.type],f=(i==null?void 0:i.label)??gc[e.type],h=d==null?void 0:d.showSections;return l.jsxs("div",{className:m("w-72 bg-card border-l border-border flex flex-col h-full flex-shrink-0"),children:[l.jsxs("div",{className:m("p-4 border-b border-border"),children:[l.jsxs("div",{className:m("flex items-center gap-2 mb-1"),children:[l.jsx("span",{className:m("text-xl"),children:u}),l.jsx("h2",{className:m("text-lg font-semibold text-foreground"),children:f})]}),l.jsxs("div",{className:m("flex gap-2 mt-3"),children:[l.jsxs(Je,{variant:"secondary",size:"sm",className:m("flex-1"),onClick:()=>o(e.id),children:[l.jsx(pE,{className:m("h-3 w-3 mr-1")}),"Duplicate"]}),l.jsxs(Je,{variant:"destructive",size:"sm",className:m("flex-1"),onClick:()=>{window.confirm("Are you sure you want to delete this element?")&&r(e.id)},children:[l.jsx(mc,{className:m("h-3 w-3 mr-1")}),"Delete"]})]})]}),l.jsxs(Fc,{className:m("flex-1"),children:[c&&i.renderSettings({element:e,onUpdate:a}),!c&&l.jsxs(l.Fragment,{children:[(h==null?void 0:h.properties)!==!1&&(p?l.jsx(hP,{element:e,onUpdate:a,propertyConfig:d==null?void 0:d.properties}):l.jsx(lP,{element:e,onUpdate:a})),(h==null?void 0:h.options)!==!1&&XE(e.type)&&l.jsx(uP,{element:e,onUpdate:a}),(h==null?void 0:h.matrix)!==!1&&ZE(e.type)&&l.jsx(fP,{element:e,onUpdate:a}),d&&l.jsx(nP,{element:e,schema:d,onUpdate:a}),(h==null?void 0:h.layout)!==!1&&l.jsx(iP,{element:e,onUpdate:a}),(h==null?void 0:h.validation)!==!1&&((i==null?void 0:i.supportsValidation)??JE(e.type))&&!bi(e.type)&&l.jsx(cP,{element:e,onUpdate:a}),(h==null?void 0:h.attributes)!==!1&&((i==null?void 0:i.structure)==="field"||YE(e.type))&&!bi(e.type)&&l.jsx(dP,{element:e,onUpdate:a,existingNames:s}),(h==null?void 0:h.logic)!==!1&&!bi(e.type)&&l.jsx(So,{title:"Conditional Logic",icon:"⚡",children:l.jsx(wT,{element:e,elements:n,onUpdate:a})})]})]})]})};var Cs=e=>e.type==="checkbox",Wl=e=>e.type==="file",No=e=>e instanceof Date,$t=e=>e==null;const fu=e=>typeof e=="object";var nt=e=>!$t(e)&&!Array.isArray(e)&&fu(e)&&!No(e),gP=e=>nt(e)&&e.target?Cs(e.target)?e.target.checked:Wl(e.target)?e.target.files:e.target.value:e,bP=(e,t)=>t.split(".").some((r,o,n)=>!isNaN(Number(r))&&e.has(n.slice(0,o).join("."))),gy=e=>{const t=e.constructor&&e.constructor.prototype;return nt(t)&&t.hasOwnProperty("isPrototypeOf")},Hl=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function at(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Hl&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(nt(e)&&gy(e)))return e;const o=r?[]:Object.create(Object.getPrototypeOf(e));for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(o[n]=at(e[n]));return o}const En={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},Cr={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Er={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},by="root",pu=["__proto__","constructor","prototype"],yP=/^\w*$/;var Es=e=>yP.test(e),tt=e=>e===void 0;const vP=/[.[\]'"]/;var jl=e=>e.split(vP).filter(Boolean),ae=(e,t,r)=>{if(!t||!nt(e))return r;const o=Es(t)?[t]:jl(t);if(o.some(s=>pu.includes(s)))return r;const n=o.reduce((s,a)=>$t(s)?void 0:s[a],e);return tt(n)||n===e?tt(e[t])?r:e[t]:n},Ur=e=>typeof e=="boolean",ur=e=>typeof e=="function",Ze=(e,t,r)=>{let o=-1;const n=Es(t)?[t]:jl(t),s=n.length,a=s-1;for(;++o<s;){const i=n[o];let c=r;if(o!==a){const d=e[i];c=nt(d)||Array.isArray(d)?d:isNaN(+n[o+1])?{}:[]}if(pu.includes(i))return;e[i]=c,e=e[i]}};const yy=P.createContext(null);yy.displayName="HookFormControlContext";var xP=(e,t,r,o=!0)=>{const n={};for(const s in e)Object.defineProperty(n,s,{get:()=>{const a=s;return t._proxyFormState[a]!==Cr.all&&(t._proxyFormState[a]=!o||Cr.all),e[a]}});return n};const wP=Hl?P.useLayoutEffect:P.useEffect;var Tt=e=>typeof e=="string",SP=(e,t,r,o,n)=>Tt(e)?(o&&t.watch.add(e),ae(r,e,n)):Array.isArray(e)?e.map(s=>(o&&t.watch.add(s),ae(r,s))):(o&&(t.watchAll=!0),r),hu=e=>$t(e)||!fu(e);const vy=(e,t)=>t.length===0&&!Array.isArray(e)&&!gy(e);function Wr(e,t,r=new WeakMap){if(e===t)return!0;if(hu(e)||hu(t))return Object.is(e,t);if(No(e)&&No(t))return Object.is(e.getTime(),t.getTime());const o=Object.keys(e),n=Object.keys(t);if(o.length!==n.length)return!1;if(vy(e,o)||vy(t,n))return Object.is(e,t);if(!o.length&&Array.isArray(e)!==Array.isArray(t))return!1;const s=r.get(e);if(s&&s.has(t))return!0;if(s)s.add(t);else{const a=new WeakSet;a.add(t),r.set(e,a)}for(const a of o){const i=e[a];if(!(a in t))return!1;if(a!=="ref"){const c=t[a];if(No(i)&&No(c)||(nt(i)||Array.isArray(i))&&(nt(c)||Array.isArray(c))?!Wr(i,c,r):!Object.is(i,c))return!1}}return!0}var ql=e=>({isOnSubmit:!e||e===Cr.onSubmit,isOnBlur:e===Cr.onBlur,isOnChange:e===Cr.onChange,isOnAll:e===Cr.all,isOnTouch:e===Cr.onTouched}),mu=(e,t,r)=>{if(r)return!1;if(t.watchAll||t.watch.has(e))return!0;for(const o of t.watch)if(e.startsWith(o)&&e.charAt(o.length)===".")return!0;return!1};const _s=(e,t,r,o)=>{for(const n of r||Object.keys(e)){if(n==="_f")continue;const s=r?ae(e,n):e[n];if(s){const{_f:a}=s;if(a){if(a.refs&&a.refs[0]&&t(a.refs[0],n)&&!o)return!0;if(a.ref&&t(a.ref,a.name)&&!o)return!0;if(_s(s,t))break}else if((nt(s)||Array.isArray(s))&&_s(s,t))break}}};var xy=(e,t,r)=>{const o=ae(e,r),n=Array.isArray(o)?o:[];return Ze(n,by,t[r]),Ze(e,r,n),e},Pt=e=>nt(e)&&!Object.keys(e).length,Yl=e=>{if(!Hl)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},gu=e=>e.type==="radio",Ql=e=>e instanceof RegExp,NP=(e,t,r,o,n)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[o]:n||!0}}:{};const wy={value:!1,isValid:!1},Sy={value:!0,isValid:!0};var Ny=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!tt(e[0].attributes.value)?tt(e[0].value)||e[0].value===""?Sy:{value:e[0].value,isValid:!0}:Sy:wy}return wy};const Cy={isValid:!1,value:null};var Ey=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,Cy):Cy;function _y(e,t,r="validate"){if(Tt(e)||Array.isArray(e)&&e.every(Tt)||Ur(e)&&!e)return{type:r,message:Tt(e)?e:"",ref:t}}var _n=e=>nt(e)&&!Ql(e)?e:{value:e,message:""},ky=async(e,t,r,o,n,s)=>{const{ref:a,refs:i,required:c,maxLength:d,minLength:p,min:u,max:f,pattern:h,validate:g,name:y,valueAsNumber:b,mount:v}=e._f,N=ae(r,y);if(!v||t.has(y))return{};const x=i?i[0]:a,w=T=>{if(n&&x.reportValidity){const L=Ur(T)?"":T||"";i?i.forEach(F=>F.setCustomValidity(L)):x.setCustomValidity(L),x.reportValidity()}},C={},E=gu(a),k=Cs(a),_=E||k,D=(b||Wl(a))&&tt(a.value)&&tt(N)||Yl(a)&&a.value===""||N===""||Array.isArray(N)&&!N.length,A=NP.bind(null,y,o,C),I=(T,L,F,B=Er.maxLength,G=Er.minLength)=>{const z=T?L:F;C[y]={type:T?B:G,message:z,ref:a,...A(T?B:G,z)}};if(s?!Array.isArray(N)||!N.length:c&&(!_&&(D||$t(N))||Ur(N)&&!N||k&&!Ny(i).isValid||E&&!Ey(i).isValid)){const{value:T,message:L}=Tt(c)?{value:!!c,message:c}:_n(c);if(T&&(C[y]={type:Er.required,message:L,ref:x,...A(Er.required,L)},!o))return w(L),C}if(!D&&(!$t(u)||!$t(f))){let T,L;const F=_n(f),B=_n(u);if(!$t(N)&&!isNaN(N)){const G=a.valueAsNumber||N&&+N;$t(F.value)||(T=G>F.value),$t(B.value)||(L=G<B.value)}else{const G=a.valueAsDate||new Date(N),z=W=>new Date(new Date().toDateString()+" "+W),H=a.type=="time",V=a.type=="week";Tt(F.value)&&N&&(T=H?z(N)>z(F.value):V?N>F.value:G>new Date(F.value)),Tt(B.value)&&N&&(L=H?z(N)<z(B.value):V?N<B.value:G<new Date(B.value))}if((T||L)&&(I(!!T,F.message,B.message,Er.max,Er.min),!o))return w(C[y].message),C}if((d||p)&&!D&&(Tt(N)||s&&Array.isArray(N))){const T=_n(d),L=_n(p),F=!$t(T.value)&&N.length>+T.value,B=!$t(L.value)&&N.length<+L.value;if((F||B)&&(I(F,T.message,L.message),!o))return w(C[y].message),C}if(h&&!D&&Tt(N)){const{value:T,message:L}=_n(h);if(Ql(T)&&!N.match(T)&&(C[y]={type:Er.pattern,message:L,ref:a,...A(Er.pattern,L)},!o))return w(L),C}if(g){if(ur(g)){const T=await g(N,r),L=_y(T,x);if(L&&(C[y]={...L,...A(Er.validate,L.message)},!o))return w(L.message),C}else if(nt(g)){let T={};for(const L in g){if(!Pt(T)&&!o)break;const F=_y(await g[L](N,r),x,L);F&&(T={...F,...A(L,F.message)},w(F.message),o&&(C[y]=T))}if(!Pt(T)&&(C[y]={ref:x,...T},!o))return C}}return w(!0),C},Kl=e=>Array.isArray(e)?e:[e],Ay=e=>Array.isArray(e)?e.filter(Boolean):[];function CP(e,t){const r=t.length-1;let o=0;for(;o<r;){if($t(e)){e=void 0;break}e=e[t[o]],o++}return e}function EP(e){for(const t in e)if(e.hasOwnProperty(t)&&!tt(e[t]))return!1;return!0}function dt(e,t){if(Tt(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const r=Array.isArray(t)?t:Es(t)?[t]:jl(t);if(r.some(a=>pu.includes(String(a))))return e;const o=r.length===1?e:CP(e,r),n=r.length-1,s=r[n];return o&&delete o[s],n!==0&&(nt(o)&&Pt(o)||Array.isArray(o)&&EP(o))&&dt(e,r.slice(0,-1)),e}const Dy=e=>{const t={};for(const r of Object.keys(e))if(fu(e[r])&&e[r]!==null&&!No(e[r])){const o=Dy(e[r]);for(const n of Object.keys(o))t[`${r}.${n}`]=o[n]}else t[r]=e[r];return t},bu=P.createContext(null);bu.displayName="HookFormContext";const yu=()=>P.useContext(bu),$y=({children:e,watch:t,getValues:r,getFieldState:o,setError:n,clearErrors:s,setValue:a,setValues:i,trigger:c,formState:d,resetField:p,reset:u,resetDefaultValues:f,handleSubmit:h,unregister:g,control:y,register:b,setFocus:v,subscribe:N})=>{const x=P.useMemo(()=>({watch:t,getValues:r,getFieldState:o,setError:n,clearErrors:s,setValue:a,setValues:i,trigger:c,formState:d,resetField:p,reset:u,resetDefaultValues:f,handleSubmit:h,unregister:g,control:y,register:b,setFocus:v,subscribe:N}),[s,y,d,o,r,h,b,u,f,p,n,v,a,i,N,c,g,t]);return P.createElement(bu.Provider,{value:x},P.createElement(yy.Provider,{value:x.control},e))};var Ty=()=>{let e=[];return{get observers(){return e},next:n=>{for(const s of e)s.next&&s.next(n)},subscribe:n=>(e.push(n),{unsubscribe:()=>{e=e.filter(s=>s!==n)}}),unsubscribe:()=>{e=[]}}};function Py(e,t){const r={};for(const o in e)if(e.hasOwnProperty(o)){const n=e[o],s=t[o];if(n&&nt(n)&&s){const a=Py(n,s);nt(a)&&(r[o]=a)}else e[o]&&(r[o]=s)}return r}var Iy=e=>e.type==="select-multiple",_P=e=>gu(e)||Cs(e),vu=e=>Yl(e)&&e.isConnected;function Oy(e){return Array.isArray(e)||nt(e)}function My(e,t,r="",o=[]){for(const n in e){const s=r?`${r}.${n}`:n,a=e[n];Oy(a)&&Oy(ae(t,s))?My(a,t,s,o):o.push(s)}return o}var kP=e=>{for(const t in e)if(ur(e[t]))return!0;return!1};function Ly(e){return Array.isArray(e)||nt(e)&&!kP(e)}function Fy(e){return!!(e&&"_f"in e)}function Vy(e){return Array.isArray(e)?!e.some(t=>!tt(t)):!Object.keys(e).length}function xu(e,t){Array.isArray(e)?e[t]=void 0:delete e[t]}function wu(e,t={},r){for(const o in e){const n=e[o],s=r&&r[o];Ly(n)&&(!Array.isArray(n)||!Fy(s))?(t[o]=Array.isArray(n)?[]:{},wu(n,t[o],s),Vy(t[o])&&xu(t,o)):tt(n)||(t[o]=!0)}return t}function tn(e,t,r,o){r||(r=wu(t,{},o));for(const n in e){const s=e[n],a=o&&o[n];Ly(s)&&(!Array.isArray(s)||!Fy(a))?(tt(t)||hu(r[n])?r[n]=wu(s,Array.isArray(s)?[]:{},a):tn(s,$t(t)?{}:t[n],r[n],a),Vy(r[n])&&xu(r,n)):Wr(s,t[n])?xu(r,n):r[n]=!0}return r}var Gy=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:o})=>tt(e)?e:t?e===""?NaN:e&&+e:r&&Tt(e)?new Date(e):o?o(e):e;function zy(e){const t=e.ref;return Wl(t)?t.files:gu(t)?Ey(e.refs).value:Iy(t)?[...t.selectedOptions].map(({value:r})=>r):Cs(t)?Ny(e.refs).value:Gy(t.value,e)}var AP=(e,t,r,o)=>{const n={};for(const s of e){const a=ae(t,s);a&&Ze(n,s,a._f)}return{criteriaMode:r,names:[...e],fields:n,shouldUseNativeValidation:o}},ks=e=>tt(e)?e:Ql(e)?e.source:nt(e)?Ql(e.value)?e.value.source:e.value:e;const By="AsyncFunction";var DP=e=>{if(!e||!e.validate)return!1;if(ur(e.validate))return e.validate.constructor.name===By;if(nt(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===By)return!0}return!1},$P=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Uy(e,t,r){const o=ae(e,r);if(o||Es(r))return{error:o,name:r};const n=r.split(".");for(;n.length;){const s=n.join("."),a=ae(t,s),i=ae(e,s);if(a&&!Array.isArray(a)&&r!==s)return{name:r};if(i&&i.type)return{name:s,error:i};if(i&&i.root&&i.root.type)return{name:`${s}.root`,error:i.root};n.pop()}return{name:r}}var TP=(e,t,r,o)=>{r(e);const n=Object.keys(e).filter(s=>s!=="name");return!n.length||o&&n.length>=Object.keys(t).length||n.find(s=>t[s]===(!o||Cr.all))},PP=(e,t,r)=>!e||!t||e===t||Kl(e).some(o=>o&&(r?o===t||o.startsWith(t+"."):o.startsWith(t)||t.startsWith(o))),IP=(e,t,r,o,n)=>n.isOnAll?!1:!r&&n.isOnTouch?!(t||e):(r?o.isOnBlur:n.isOnBlur)?!e:(r?o.isOnChange:n.isOnChange)?e:!0,OP=(e,t)=>!Ay(ae(e,t)).length&&dt(e,t);const MP={mode:Cr.onSubmit,reValidateMode:Cr.onChange,shouldFocusError:!0},Su="form",LP=(e,t)=>{for(const r in e)r in t||delete e[r];Object.assign(e,t)},Wy={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function FP(e={}){let t={...MP,...e},r={...at(Wy),isLoading:ur(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},o={},n=nt(t.defaultValues)||nt(t.values)?at(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:at(n),a={action:!1,mount:!1,watch:!1,keepIsValid:!1},i={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const c={},d={};let p=0,u=ql(t.mode),f=ql(t.reValidateMode);const h={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},g={...h};let y={...g};const b={array:Ty(),state:Ty()};let v=0;const N=t.criteriaMode===Cr.all,x=($,O)=>M=>{clearTimeout(d[$]),d[$]=setTimeout(O,M)},w=async $=>{if(!a.keepIsValid&&!t.disabled&&(g.isValid||y.isValid||$)){const O=++v;let M;t.resolver?(M=Pt((await F()).errors),O===v&&C()):M=await z({fields:o,onlyCheckValid:!0,eventType:En.VALID}),O===v&&M!==r.isValid&&b.state.next({isValid:M})}},C=($,O)=>{!t.disabled&&(g.isValidating||g.validatingFields||y.isValidating||y.validatingFields)&&(($||Array.from(i.mount)).forEach(M=>{M&&(O?Ze(r.validatingFields,M,O):dt(r.validatingFields,M))}),b.state.next({validatingFields:r.validatingFields,isValidating:!Pt(r.validatingFields)}))},E=()=>{r.dirtyFields=tn(n,s,void 0,o)},k=($,O=[],M,Y,q=!0,Z=!0)=>{if(Y&&M&&!t.disabled){if(a.action=!0,Z&&Array.isArray(ae(o,$))){const j=M(ae(o,$),Y.argA,Y.argB);q&&Ze(o,$,j)}if(Z&&Array.isArray(ae(r.errors,$))){const j=M(ae(r.errors,$),Y.argA,Y.argB);q&&Ze(r.errors,$,j),OP(r.errors,$)}if((g.touchedFields||y.touchedFields)&&Z&&Array.isArray(ae(r.touchedFields,$))){const j=M(ae(r.touchedFields,$),Y.argA,Y.argB);q&&Ze(r.touchedFields,$,j)}(g.dirtyFields||y.dirtyFields)&&E(),b.state.next({name:$,isDirty:V($,O),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Ze(s,$,O)},_=($,O)=>{Ze(r.errors,$,O),r.errors={...r.errors},b.state.next({errors:r.errors})},D=$=>{r.errors=$,b.state.next({errors:r.errors,isValid:!1})},A=$=>{const O=Es($)?[$]:jl($);let M=s,Y=n;for(let q=0;q<O.length-1;q++){const Z=O[q];if(M=$t(M)?M:M[Z],Y=$t(Y)?Y:Y[Z],M===null&&Y!==null)return!0}return!1},I=($,O,M,Y)=>{const q=ae(o,$);if(q){if(A($))return;const Z=tt(ae(s,$)),j=ae(s,$,tt(M)?ae(n,$):M);tt(j)||Y&&Y.defaultChecked||O?Ze(s,$,O?j:zy(q._f)):U($,j),a.mount&&!a.action&&(w(),Z&&r.isDirty&&(g.isDirty||y.isDirty)&&(V()||(r.isDirty=!1,b.state.next({...r}))),e.shouldUnregister&&Z&&!tt(ae(s,$))&&mu($,i)&&(a.watch=!0))}},T=($,O,M,Y,q)=>{let Z=!1,j=!1;const X={name:$};if(!t.disabled||Y===!0){if(!M||Y){const ie=Wr(ae(n,$),O);(g.isDirty||y.isDirty)&&(j=r.isDirty,r.isDirty=X.isDirty=!ie||V(),Z=j!==X.isDirty),j=!!ae(r.dirtyFields,$),ie!==r.isDirty?LP(r.dirtyFields,tn(n,s,void 0,o)):ie?dt(r.dirtyFields,$):Ze(r.dirtyFields,$,!0),X.dirtyFields=r.dirtyFields,Z=Z||(g.dirtyFields||y.dirtyFields)&&j!==!ie}if(M){const ie=ae(r.touchedFields,$);ie||(Ze(r.touchedFields,$,M),X.touchedFields=r.touchedFields,Z=Z||(g.touchedFields||y.touchedFields)&&ie!==M)}Z&&q&&b.state.next(X)}return Z?X:{}},L=($,O,M,Y)=>{const q=ae(r.errors,$),Z=(g.isValid||y.isValid)&&Ur(O)&&r.isValid!==O;if(t.delayError&&M?(c[$]=x($,()=>_($,M)),c[$](t.delayError)):(clearTimeout(d[$]),delete c[$],M?Ze(r.errors,$,M):dt(r.errors,$),r.errors={...r.errors}),(M?!Wr(q,M):q)||!Pt(Y)||Z){const j={...Y,...Z&&Ur(O)?{isValid:O}:{},errors:r.errors,name:$};r={...r,...j},b.state.next(j)}},F=async $=>(C($,!0),await t.resolver(s,t.context,AP($||i.mount,o,t.criteriaMode,t.shouldUseNativeValidation))),B=async $=>{const{errors:O}=await F($);if(C($),$){for(const M of $){const Y=ae(O,M);Y?i.array.has(M)&&nt(Y)&&!Object.keys(Y).some(q=>!Number.isNaN(Number(q)))?xy(r.errors,{[M]:Y},M):Ze(r.errors,M,Y):dt(r.errors,M)}r.errors={...r.errors}}else r.errors=O;return O},G=async({name:$,eventType:O})=>{if(e.validate){const M=await e.validate({formValues:s,formState:r,name:$,eventType:O});if(nt(M))for(const Y in M){const q=M[Y];q&&J(`${Su}.${Y}`,{message:Tt(q.message)?q.message:"",type:q.type||Er.validate})}else Tt(M)||!M?J(Su,{message:M||"",type:Er.validate}):ue(Su);return M}return!0},z=async({fields:$,onlyCheckValid:O,name:M,eventType:Y,context:q={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(q.runRootValidation=!0,!await G({name:M,eventType:Y})&&(q.valid=!1,O)))return q.valid;for(const Z in $){const j=$[Z];if(j){const{_f:X,...ie}=j;if(X){const Oe=i.array.has(X.name),qe=j._f&&DP(j._f),Mt=g.validatingFields||g.isValidating||y.validatingFields||y.isValidating;qe&&Mt&&C([X.name],!0);const Pe=await ky(j,i.disabled,s,N,t.shouldUseNativeValidation&&!O,Oe);if(qe&&Mt&&C([X.name]),Pe[X.name]&&(q.valid=!1,O)||(!O&&(ae(Pe,X.name)?Oe?xy(r.errors,Pe,X.name):Ze(r.errors,X.name,Pe[X.name]):dt(r.errors,X.name)),e.shouldUseNativeValidation&&Pe[X.name]))break}!Pt(ie)&&await z({context:q,onlyCheckValid:O,fields:ie,name:Z,eventType:Y})}}return q.valid},H=()=>{for(const $ of i.unMount){const O=ae(o,$);O&&(O._f.refs?O._f.refs.every(M=>!vu(M)):!vu(O._f.ref))&&Re($)}i.unMount=new Set},V=($,O)=>($&&O&&Ze(s,$,O),!Wr(a.mount?s:n,n)),W=($,O,M)=>SP($,i,{...a.mount?s:tt(O)?n:Tt($)?{[$]:O}:O},M,O),pe=$=>Ay(ae(a.mount?s:n,$,t.shouldUnregister?ae(n,$,[]):[])),U=($,O,M={},Y=!1,q=!1)=>{const Z=ae(o,$);let j=O;if(Z){const X=Z._f;X&&(!X.disabled&&Ze(s,$,Gy(O,X)),j=Yl(X.ref)&&$t(O)?"":O,Iy(X.ref)?[...X.ref.options].forEach(ie=>ie.selected=j.includes(ie.value)):X.refs?Cs(X.ref)?X.refs.forEach(ie=>{(!ie.defaultChecked||!ie.disabled)&&(Array.isArray(j)?ie.checked=!!j.find(Oe=>Oe===ie.value):ie.checked=j===ie.value||!!j)}):X.refs.forEach(ie=>ie.checked=ie.value===j):Wl(X.ref)?X.ref.value="":(X.ref.value=j,!X.ref.type&&!q&&b.state.next({name:$,values:Y?s:at(s)})))}(M.shouldDirty||M.shouldTouch)&&T($,j,M.shouldTouch,M.shouldDirty,!q),M.shouldValidate&&re($,{delayError:M.delayError})},Q=($,O,M,Y=!1,q=!1)=>{i.array.has($)&&b.array.next({name:$,values:Y?s:at(s)});for(const Z in O){if(!O.hasOwnProperty(Z))return;const j=O[Z],X=$+"."+Z,ie=ae(o,X);(i.array.has($)||nt(j)||ie&&!ie._f)&&!No(j)?Q(X,j,M,Y,q):U(X,j,M,Y,q)}},Ce=($,O,M,Y,q=!1)=>{const Z=ae(o,$),j=i.array.has($),X=Y?O:at(O),ie=ae(s,$),Oe=Wr(ie,X);if(Oe||Ze(s,$,X),j)b.array.next({name:$,values:Y?s:at(s)}),(g.isDirty||g.dirtyFields||y.isDirty||y.dirtyFields)&&M.shouldDirty&&(E(),q||b.state.next({name:$,dirtyFields:r.dirtyFields,isDirty:V($,X)}));else{const qe=Array.isArray(X)&&!X.length||Pt(X);!Z||Z._f||$t(X)||qe?U($,X,M,Y,q):Q($,X,M,Y,q)}if(!Oe&&!q){const qe=mu($,i),Mt=Y?s:at(s);b.state.next({...qe&&r,name:a.mount||qe?$:void 0,values:Mt})}},oe=($,O,M={})=>Ce($,O,M,!1),ye=($,O={})=>{const M=ur($)?$(s):$;if(!Wr(s,M)){s={...s,...M};const Y=Dy(M);for(const q of i.mount)q in Y&&Ce(q,Y[q],O,!0,!0);b.state.next({...r,name:void 0,type:void 0,...p?{values:s}:{}}),O.shouldValidate&&w()}},R=async $=>{a.mount=!0;const O=$.target;let M=O.name,Y=!0;const q=ae(o,M),Z=j=>{Y=Number.isNaN(j)||No(j)&&isNaN(j.getTime())||Wr(j,ae(s,M,j))};if(q){let j,X;const ie=O.type?zy(q._f):gP($),Oe=$.type===En.BLUR||$.type===En.FOCUS_OUT,qe=!$P(q._f)&&!e.validate&&!t.resolver&&!ae(r.errors,M)&&!q._f.deps,Mt=qe||IP(Oe,ae(r.touchedFields,M),r.isSubmitted,f,u),Pe=mu(M,i,Oe);if(Ze(s,M,ie),Oe){if(!O||!O.readOnly){q._f.onBlur&&q._f.onBlur($);const _r=c[M];_r&&_r(0)}}else q._f.onChange&&q._f.onChange($);const et=T(M,ie,Oe),lt=!Pt(et)||Pe;if(!Oe&&b.state.next({name:M,type:$.type,...p?{values:at(s)}:{}}),Mt)return(!qe||!r.isValid)&&(g.isValid||y.isValid)&&(t.mode==="onBlur"?Oe&&w():Oe||w()),lt&&b.state.next({name:M,...Pe?{}:et});if(!t.resolver&&e.validate&&await G({name:M,eventType:$.type}),!Oe&&Pe&&b.state.next({...r}),t.resolver){const{errors:_r}=await F([M]);if(C([M]),Z(ie),!Y){!Pt(et)&&b.state.next(et);return}const kn=Uy(r.errors,o,M),pr=Uy(_r,o,kn.name||M);j=pr.error,M=pr.name,X=Pt(_r)}else C([M],!0),j=(await ky(q,i.disabled,s,N,t.shouldUseNativeValidation))[M],C([M]),Z(ie),Y&&(j?X=!1:(g.isValid||y.isValid)&&(X=await z({fields:o,onlyCheckValid:!0,name:M,eventType:$.type})));Y&&(q._f.deps&&(!Array.isArray(q._f.deps)||q._f.deps.length>0)&&re(q._f.deps),L(M,X,j,et))}},ce=($,O)=>{if(ae(r.errors,O)&&$.focus)return $.focus(),1},re=async($,O={})=>{let M,Y;const q=Kl($);if(t.resolver){const Z=await B(tt($)?$:q);M=Pt(Z),Y=$?!q.some(j=>ae(Z,j)):M}else $?(Y=(await Promise.all(q.map(async Z=>{const j=ae(o,Z);return await z({fields:j&&j._f?{[Z]:j}:j,eventType:En.TRIGGER})}))).every(Boolean),!(!Y&&!r.isValid)&&w()):Y=M=await z({fields:o,name:$,eventType:En.TRIGGER});if(O.delayError&&t.delayError&&Tt($)){const Z=ae(r.errors,$);Z?(dt(r.errors,$),c[$]=x($,()=>_($,Z)),c[$](t.delayError)):(clearTimeout(d[$]),delete c[$])}return b.state.next({...!Tt($)||(g.isValid||y.isValid)&&M!==r.isValid?{}:{name:$},...t.resolver||!$?{isValid:M}:{},errors:r.errors}),O.shouldFocus&&!Y&&_s(o,ce,$?q:i.mount),Y},Ae=($,O)=>{let M={...a.mount?s:n};return O&&(M=Py(O.dirtyFields?r.dirtyFields:r.touchedFields,M)),tt($)?M:Tt($)?ae(M,$):$.map(Y=>ae(M,Y))},we=($,O)=>({invalid:!!ae((O||r).errors,$),isDirty:!!ae((O||r).dirtyFields,$),error:ae((O||r).errors,$),isValidating:!!ae(r.validatingFields,$),isTouched:!!ae((O||r).touchedFields,$)}),ue=$=>{const O=$?Kl($):void 0;O==null||O.forEach(M=>dt(r.errors,M)),O?O.forEach(M=>{b.state.next({name:M,errors:r.errors})}):(r.errors={},b.state.next({errors:r.errors}))},J=($,O,M)=>{const Y=(ae(o,$,{_f:{}})._f||{}).ref,q=ae(r.errors,$)||{},{ref:Z,message:j,type:X,...ie}=q;Ze(r.errors,$,{...ie,...O,ref:Y}),b.state.next({name:$,errors:r.errors,isValid:!1}),M&&M.shouldFocus&&Y&&Y.focus&&Y.focus()},ne=($,O)=>{if(ur($)){p++;const{unsubscribe:M}=b.state.subscribe({next:q=>"values"in q&&$(q.values||W(void 0,O),q)});let Y=!1;return{unsubscribe:()=>{Y||(Y=!0,p--,M())}}}return W($,O,!0)},fe=$=>{var O;const M=!!(!((O=$.formState)===null||O===void 0)&&O.values);M&&p++;const{unsubscribe:Y}=b.state.subscribe({next:Z=>{if(PP($.name,Z.name,$.exact)&&TP(Z,$.formState||g,Et,$.reRenderRoot)){const j={...s};$.callback({values:j,...r,...Z,defaultValues:n})}}});if(!M)return Y;let q=!1;return()=>{q||(q=!0,p--,Y())}},ke=$=>(a.mount=!0,y={...y,...$.formState},fe({...$,formState:{...h,...$.formState}})),Re=($,O={})=>{for(const M of $?Kl($):i.mount)i.mount.delete(M),i.array.delete(M),O.keepValue||(dt(o,M),dt(s,M)),!O.keepError&&dt(r.errors,M),!O.keepDirty&&dt(r.dirtyFields,M),!O.keepTouched&&dt(r.touchedFields,M),!O.keepIsValidating&&dt(r.validatingFields,M),!t.shouldUnregister&&!O.keepDefaultValue&&dt(n,M);b.state.next({values:at(s)}),b.state.next({...r,...O.keepDirty?{isDirty:V()}:{}}),!O.keepIsValid&&w()},rt=({disabled:$,name:O})=>{if(Ur($)&&a.mount||$||i.disabled.has(O)){const q=i.disabled.has(O)!==!!$;$?i.disabled.add(O):i.disabled.delete(O),q&&a.mount&&!a.action&&w()}},st=($,O={})=>{let M=ae(o,$);const Y=Ur(O.disabled)||Ur(t.disabled),q=!i.registerName.has($)&&M&&M._f&&!M._f.mount;return Ze(o,$,{...M||{},_f:{...M&&M._f?M._f:{ref:{name:$}},name:$,mount:!0,...O}}),i.mount.add($),M&&!q?rt({disabled:Ur(O.disabled)?O.disabled:t.disabled,name:$}):I($,!0,O.value),{...Y?{disabled:O.disabled||t.disabled}:{},...t.progressive?{required:!!O.required,min:ks(O.min),max:ks(O.max),minLength:ks(O.minLength),maxLength:ks(O.maxLength),pattern:ks(O.pattern)}:{},name:$,onChange:R,onBlur:R,ref:Z=>{if(Z){i.registerName.add($),st($,O),i.registerName.delete($),M=ae(o,$);const j=tt(Z.value)&&Z.querySelectorAll&&Z.querySelectorAll("input,select,textarea")[0]||Z,X=_P(j),ie=M._f.refs||[];if(X?ie.find(qe=>qe===j):j===M._f.ref)return;const Oe={...M._f};X?(Oe.refs=[...ie.filter(vu),j,...Array.isArray(ae(n,$))?[{}]:[]],Oe.ref={type:j.type,name:$}):(Oe.ref=j,delete Oe.refs),Ze(o,$,{_f:Oe}),I($,!1,void 0,j)}else M=ae(o,$,{}),M._f&&(M._f.mount=!1),(t.shouldUnregister||O.shouldUnregister)&&!(bP(i.array,$)&&a.action)&&i.unMount.add($)}}},Xe=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&_s(o,ce,i.mount),Ee=$=>{Ur($)&&(b.state.next({disabled:$}),_s(o,(O,M)=>{const Y=ae(o,M);Y&&(O.disabled=Y._f.disabled||$,Array.isArray(Y._f.refs)&&Y._f.refs.forEach(q=>{q.disabled=Y._f.disabled||$}))},0,!1))},yt=($,O)=>async M=>{let Y,q;M&&(M.preventDefault&&M.preventDefault(),M.persist&&M.persist());let Z=at(s);if(b.state.next({isSubmitting:!0}),t.resolver){const{errors:j,values:X}=await F();C(),r.errors=j,Z=at(X)}else await z({fields:o,eventType:En.SUBMIT});if(i.disabled.size)for(const j of i.disabled)dt(Z,j);if(dt(r.errors,by),Pt(r.errors)){b.state.next({errors:{}});try{Y=await $(Z,M)}catch(j){q=j}}else O&&await O({...r.errors},M),Xe(),setTimeout(Xe);if(b.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Pt(r.errors)&&!q,submitCount:r.submitCount+1,errors:r.errors}),q)throw q;return Y},fr=($,O={})=>{ae(o,$)&&(tt(O.defaultValue)?oe($,at(ae(n,$))):(oe($,O.defaultValue),Ze(n,$,at(O.defaultValue))),O.keepTouched||dt(r.touchedFields,$),O.keepDirty||(dt(r.dirtyFields,$),r.isDirty=O.defaultValue?V($,at(ae(n,$))):V()),O.keepError||(dt(r.errors,$),g.isValid&&w()),b.state.next({...r}))},Yt=($,O={})=>{const M=$?at($):n,Y=at(M),q=Pt($),Z=Y,j=o;if(O.keepDefaultValues||(n=M),!O.keepValues){if(O.keepDirtyValues){const X=new Set([...i.mount,...My(tn(n,s,void 0,j),r.dirtyFields)]);for(const ie of Array.from(X)){const Oe=ae(r.dirtyFields,ie),qe=ae(s,ie),Mt=ae(Z,ie);Oe&&!tt(qe)?Ze(Z,ie,qe):!Oe&&!tt(Mt)&&oe(ie,Mt)}}else{if(Hl&&tt($))for(const X of i.mount){const ie=ae(o,X);if(ie&&ie._f){const Oe=Array.isArray(ie._f.refs)?ie._f.refs[0]:ie._f.ref;if(Yl(Oe)){const qe=Oe.closest("form");if(qe){qe.reset();break}}}}if(O.keepFieldsRef)for(const X of i.mount)oe(X,ae(Z,X));else o={}}if(t.shouldUnregister){if(s=O.keepDefaultValues?at(n):{},O.keepFieldsRef)for(const X of i.mount)Ze(s,X,ae(Z,X))}else s=at(Z);b.array.next({values:{...Z}}),b.state.next({name:void 0,type:void 0,values:{...Z}})}i={mount:O.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},a.mount=!g.isValid||!!O.keepIsValid||!!O.keepDirtyValues||!t.shouldUnregister&&!Pt(Z),a.watch=!!t.shouldUnregister,a.keepIsValid=!!O.keepIsValid,a.action=!1,O.keepErrors||(r.errors={}),b.state.next({submitCount:O.keepSubmitCount?r.submitCount:0,isDirty:q?!1:O.keepDirty?r.isDirty:O.keepValues?V():!!(O.keepDefaultValues&&!Wr($,n)),isSubmitted:O.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:q?{}:O.keepDirtyValues?O.keepDefaultValues&&s?tn(n,s,void 0,j):r.dirtyFields:O.keepDefaultValues&&$?tn(n,$,void 0,j):O.keepDirty?r.dirtyFields:{},touchedFields:O.keepTouched?r.touchedFields:{},errors:O.keepErrors?r.errors:{},isSubmitSuccessful:O.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:n})},It=($,O)=>Yt(ur($)?$(s):$,{...t.resetOptions,...O}),Me=($,O={})=>{const M=ae(o,$),Y=M&&M._f;if(Y){const q=Y.refs?Y.refs[0]:Y.ref;q.focus&&setTimeout(()=>{q.focus(),O.shouldSelect&&ur(q.select)&&q.select()})}},Et=$=>{const{name:O,type:M,values:Y,...q}=$;r={...r,...q}},rr={control:{register:st,unregister:Re,getFieldState:we,handleSubmit:yt,setError:J,_subscribe:fe,_runSchema:F,_updateIsValidating:C,_focusError:Xe,_getWatch:W,_getDirty:V,_setValid:w,_setFieldArray:k,_setDisabledField:rt,_setErrors:D,_getFieldArray:pe,_reset:Yt,_resetDefaultValues:()=>ur(t.defaultValues)&&t.defaultValues().then($=>{It($,t.resetOptions),b.state.next({isLoading:!1})}),_removeUnmounted:H,_disableForm:Ee,_subjects:b,_proxyFormState:g,get _fields(){return o},get _formValues(){return s},get _state(){return a},set _state($){a=$},get _defaultValues(){return n},get _names(){return i},set _names($){i=$},get _formState(){return r},get _options(){return t},set _options($){t={...t,...$},u=ql(t.mode),f=ql(t.reValidateMode)}},subscribe:ke,trigger:re,register:st,handleSubmit:yt,watch:ne,setValue:oe,setValues:ye,getValues:Ae,reset:It,resetField:fr,resetDefaultValues:($,O={})=>{if(n=at($),!O.keepDirty){const M=tn(n,s,void 0,o);r.dirtyFields=M,r.isDirty=!Pt(M)}O.keepIsValid||w(),b.state.next({...r,defaultValues:n})},clearErrors:ue,unregister:Re,setError:J,setFocus:Me,getFieldState:we};return{...rr,formControl:rr}}function Hy(e={}){const t=P.useRef(void 0),r=P.useRef(void 0),o=P.useRef(e.formControl),[n,s]=P.useState(()=>({...at(Wy),isLoading:ur(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ur(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&o.current!==e.formControl)if(o.current=e.formControl,e.formControl)t.current={...e.formControl,formState:n},e.defaultValues&&!ur(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:i,...c}=FP(e);t.current={...c,formState:n}}const a=t.current.control;return a._options=e,wP(()=>{const i=a._subscribe({formState:a._proxyFormState,callback:()=>s({...a._formState,defaultValues:a._defaultValues}),reRenderRoot:!0});return s(c=>({...c,isReady:!0})),a._formState.isReady=!0,i},[a]),P.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),P.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),P.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),P.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),P.useEffect(()=>{if(a._proxyFormState.isDirty){const i=a._getDirty();i!==n.isDirty&&a._subjects.state.next({isDirty:i})}},[a,n.isDirty]),P.useEffect(()=>{var i;e.values&&!Wr(e.values,r.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),!((i=a._options.resetOptions)===null||i===void 0)&&i.keepIsValid||a._setValid(),r.current=e.values,s(c=>({...c}))):a._resetDefaultValues()},[a,e.values]),P.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=P.useMemo(()=>xP(n,a),[a,n]),t.current}function jy(e){return["divider","paragraph","heading","link","image"].includes(e.type)?"layout":["submit","button"].includes(e.type)?"action":["pages","group","repeatGroup"].includes(e.type)?"container":"field"}function qy(e,t){var s,a;const r=[],o=new Map,n=new Map;for(const i of t){const c=((s=i.attributes)==null?void 0:s.name)||i.id;o.set(c,i),n.set(i.id,i)}for(const[i,c]of Object.entries(e)){const d=o.get(i);if(d){if(d.parentId){const u=n.get(d.parentId);if(u&&(u.type==="repeatGroup"||u.type==="repeatElement")&&e[((a=u.attributes)==null?void 0:a.name)||u.id]!==void 0)continue}const p=jy(d);if(p==="layout"||p==="action")continue;r.push({id:i,value:c,type:d.type,category:p})}else r.push({id:i,value:c,type:"unknown",category:"field"})}return r}function Nu(e,t,r="keyValue"){return r==="array"?qy(e,t):e}function VP(e,t){var s,a;const r={},o=new Map,n=new Map;for(const i of t){const c=((s=i.attributes)==null?void 0:s.name)||i.id;o.set(c,i),n.set(i.id,i)}for(const[i,c]of Object.entries(e)){const d=o.get(i);if(d){if(d.parentId){const u=n.get(d.parentId);if(u&&(u.type==="repeatGroup"||u.type==="repeatElement")&&e[((a=u.attributes)==null?void 0:a.name)||u.id]!==void 0)continue}const p=jy(d);(p==="field"||p==="container")&&(r[i]=c)}else r[i]=c}return r}const GP=({currentPage:e,totalPages:t,pages:r,showStepNumbers:o,onPageClick:n})=>{const s=(e+1)/t*100;return l.jsxs("div",{className:m("mb-8"),children:[l.jsx("div",{className:m("h-2 bg-gray-200 rounded-full overflow-hidden"),children:l.jsx("div",{className:m("h-full bg-blue-600 transition-all duration-300 ease-out"),style:{width:`${s}%`}})}),o&&l.jsx("div",{className:m("flex justify-between mt-4"),children:r.map((a,i)=>{const c=i<e,d=i===e;return l.jsxs("button",{type:"button",onClick:()=>n==null?void 0:n(i),disabled:i>e,className:m(`flex flex-col items-center ${n&&i<=e?"cursor-pointer":"cursor-default"}`),children:[l.jsx("div",{className:m(`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors ${c?"bg-blue-600 text-white":d?"bg-blue-600 text-white ring-4 ring-blue-100":"bg-gray-200 text-gray-500"}`),children:c?l.jsx("svg",{className:m("w-4 h-4"),fill:"currentColor",viewBox:"0 0 20 20",children:l.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):i+1}),l.jsx("span",{className:m(`mt-2 text-xs font-medium ${d?"text-blue-600":"text-gray-500"}`),children:a.title})]},a.id)})})]})},zP=({page:e,pageIndex:t,totalPages:r})=>l.jsxs("div",{className:m("mb-6"),children:[l.jsxs("div",{className:m("flex items-center justify-between mb-2"),children:[l.jsx("h2",{className:m("text-xl font-semibold text-gray-900"),children:e.title}),l.jsxs("span",{className:m("text-sm text-gray-500"),children:["Step ",t+1," of ",r]})]}),e.description&&l.jsx("p",{className:m("text-gray-600"),children:e.description})]}),BP=({currentPage:e,totalPages:t,allowSkip:r,isSubmitting:o,nextButtonLabel:n,onPrevious:s,onNext:a,onSkip:i})=>{const c=e===0,d=e===t-1;return l.jsxs("div",{className:m("flex items-center justify-between mt-8 pt-6 border-t border-gray-200"),children:[l.jsx("div",{children:!c&&l.jsx("button",{type:"button",onClick:s,className:m("px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"),children:"← Previous"})}),l.jsxs("div",{className:m("flex gap-3"),children:[r&&!d&&l.jsx("button",{type:"button",onClick:i,className:m("px-4 py-2 text-sm font-medium text-gray-500 hover:text-gray-700"),children:"Skip"}),d?l.jsx("button",{type:"submit",disabled:o,className:m("px-6 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"),children:o?"Submitting...":"Submit"}):l.jsxs("button",{type:"button",onClick:a,className:m("px-6 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500"),children:[n," →"]})]})]})},Yy=({element:e,elements:t})=>{const{setValue:r,watch:o,register:n,unregister:s}=yu(),a=o(),{visible:i,required:c,disabled:d}=P.useMemo(()=>Vb(e,a,t),[e,a,t]),p=e.attributes.name;if(P.useEffect(()=>{var C,E,k,_,D,A;if(p){if(!i){s(p,{keepValue:!0});return}return n(p,{required:c?((C=e.validation)==null?void 0:C.errorMessage)||"This field is required":void 0,minLength:(E=e.validation)==null?void 0:E.minLength,maxLength:(k=e.validation)==null?void 0:k.maxLength,min:(_=e.validation)==null?void 0:_.min,max:(D=e.validation)==null?void 0:D.max,pattern:WP((A=e.validation)==null?void 0:A.pattern),disabled:d||e.properties.disabled||void 0}),()=>s(p,{keepValue:!0})}},[p,i,c,d,e.validation,e.properties.disabled,n,s]),!i)return null;const u=o(p),f=d||e.properties.disabled||!1,h={small:"max-w-xs",medium:"max-w-md",large:"max-w-lg",full:"w-full",default:"max-w-md"},g=h[e.layout.size||"default"]||h.default,y=ut.get(e.type),b=(C,E)=>{const k=t.filter(_=>_.parentId===C).sort((_,D)=>_.order-D.order);return l.jsx("div",{className:m("space-y-4"),children:k.map(_=>l.jsx(Yy,{element:{..._,attributes:{..._.attributes,name:E?`${E}.${_.attributes.name}`:_.attributes.name}},elements:t},_.id))})},v={element:e,properties:e.properties,layout:e.layout,validation:{...e.validation,required:c},logic:e.logic,config:e.config,mode:"render",value:u,onChange:C=>r(p,C),errors:[],formValues:a,readOnly:!1,disabled:f,allElements:t,renderChildren:b},N=()=>y!=null&&y.render?y.render(v):l.jsxs("div",{className:m("p-3 bg-yellow-50 border border-yellow-200 rounded-md text-sm text-yellow-700"),children:[l.jsxs("p",{className:m("font-medium"),children:["Unknown element type: ",e.type]}),l.jsxs("p",{className:m("text-xs mt-1"),children:["This element is not registered in the element registry. Please register it using ",l.jsx("code",{children:"registerElement()"}),"."]})]});return(y==null?void 0:y.structure)==="page"&&["heading","layout","special"].includes(y.subCategory||"")||["paragraph","image","link","formHeading","sectionHeading","subheading","divider","spacer","captcha","submit"].includes(e.type)?l.jsx("div",{className:m(g,"mb-4"),children:N()}):l.jsx("div",{className:m(g,"mb-4"),children:N()})};function UP(e){var o,n,s;if(e.attributes.defaultValue!==void 0)return e.attributes.defaultValue;const t=ut.get(e.type);switch(t==null?void 0:t.dataType){case"array":return[];case"boolean":return!1;case"number":return((o=e.config)==null?void 0:o.min)??0;case"object":return e.type==="rangeSlider"?[((n=e.config)==null?void 0:n.min)??0,((s=e.config)==null?void 0:s.max)??100]:e.type==="dateRange"?{start:"",end:""}:{};default:return""}}function WP(e){if(e)try{return new RegExp(e)}catch{return}}function HP(e){const t={};return e.forEach(r=>{var o;(o=r.attributes)!=null&&o.name&&(t[r.attributes.name]=UP(r))}),t}function jP(e,t){const r=[],o=n=>{var s;for(const a of n)(s=a.attributes)!=null&&s.name&&r.push(a.attributes.name),o(t.filter(i=>i.parentId===a.id))};return o(e),r}const Cu=({schema:e,onSubmit:t,initialValues:r,onPageChange:o,submissionFormat:n="keyValue",debug:s=!1})=>{const[a,i]=P.useState(0),[c,d]=P.useState(!1),[p,u]=P.useState(null),f=P.useMemo(()=>e.elements.find(I=>I.type==="pages"),[e.elements]),h=P.useMemo(()=>{var I,T,L,F,B,G;return{showProgressBar:((I=f==null?void 0:f.config)==null?void 0:I.showProgressBar)??!0,showStepNumbers:((T=f==null?void 0:f.config)==null?void 0:T.showStepNumbers)??!0,allowSkip:((L=f==null?void 0:f.config)==null?void 0:L.allowSkip)??!1,validateOnNext:((F=f==null?void 0:f.config)==null?void 0:F.validateOnNext)??!0,nextButtonLabel:((B=f==null?void 0:f.config)==null?void 0:B.nextButtonLabel)??"Next",steps:((G=f==null?void 0:f.config)==null?void 0:G.steps)||[{id:"step1",label:"Step 1"}]}},[f]),g=P.useMemo(()=>f?h.steps.map(T=>{const L=e.elements.filter(F=>{var B;return F.parentId===`${f.id}:${T.id}`||F.parentId===f.id&&((B=F.config)==null?void 0:B.wizardStepId)===T.id});return{id:T.id,title:T.label,description:T.description,elements:L.sort((F,B)=>F.order-B.order)}}):[],[f,h.steps,e.elements]),y=P.useMemo(()=>e.elements.filter(I=>I.type!=="pages"),[e.elements]),b=P.useMemo(()=>r||HP(y),[r,y]),v=Hy({defaultValues:b,mode:"onChange"}),{handleSubmit:N,trigger:x}=v,w=P.useCallback(I=>{I>=0&&I<g.length&&(i(I),o==null||o(I))},[g.length,o]),C=P.useCallback(()=>{w(a-1)},[a,w]),E=P.useCallback(async()=>{if(h.validateOnNext){const I=jP(g[a].elements,e.elements);if(!await x(I))return}w(a+1)},[a,h.validateOnNext,g,e.elements,x,w]),k=P.useCallback(()=>{w(a+1)},[a,w]),_=P.useCallback(async I=>{d(!0);try{const T=Nu(I,e.elements,n);console.log("Wizard form submitted:",T),s?u(T):await(t==null?void 0:t(T))}catch(T){console.error("Form submission error:",T)}finally{d(!1)}},[t,e.elements,n,s]),D=P.useCallback(I=>{if(a<g.length-1){I.preventDefault(),E();return}N(_)(I)},[a,g.length,E,N,_]),A=g[a];return A?l.jsxs("div",{className:m("max-w-3xl mx-auto"),children:[l.jsx($y,{...v,children:l.jsxs("form",{onSubmit:D,className:m("space-y-1"),children:[h.showProgressBar&&l.jsx(GP,{currentPage:a,totalPages:g.length,pages:g,showStepNumbers:h.showStepNumbers,onPageClick:h.allowSkip?w:void 0}),l.jsx(zP,{page:A,pageIndex:a,totalPages:g.length}),l.jsx("div",{className:m("space-y-4"),children:A.elements.map(I=>l.jsx(Yy,{element:I,elements:e.elements},I.id))}),l.jsx(BP,{currentPage:a,totalPages:g.length,allowSkip:h.allowSkip,isSubmitting:c,nextButtonLabel:h.nextButtonLabel,onPrevious:C,onNext:E,onSkip:k})]})}),s&&p&&l.jsxs("div",{className:m("mt-8 p-4 bg-green-50 border border-green-200 rounded-lg"),children:[l.jsx("h3",{className:m("text-lg font-medium text-green-800 mb-2"),children:"Submitted Data:"}),l.jsx("pre",{className:m("text-sm text-green-700 overflow-x-auto"),children:JSON.stringify(p,null,2)})]})]}):l.jsxs("div",{className:m("p-8 text-center text-gray-500"),children:[l.jsx("p",{children:"No wizard steps configured."}),l.jsx("p",{className:m("text-sm mt-2"),children:"Add steps to the wizard element to create a multi-page form."})]})};function qP(e){var o,n,s;if(e.attributes.defaultValue!==void 0)return e.attributes.defaultValue;const t=ut.get(e.type);switch(t==null?void 0:t.dataType){case"array":return[];case"boolean":return!1;case"number":return((o=e.config)==null?void 0:o.min)??0;case"object":return e.type==="rangeSlider"?[((n=e.config)==null?void 0:n.min)??0,((s=e.config)==null?void 0:s.max)??100]:e.type==="dateRange"?{start:"",end:""}:{};default:return""}}function YP(e){const t={};return e.forEach(r=>{var o;(o=r.attributes)!=null&&o.name&&(t[r.attributes.name]=qP(r))}),t}const Qy=({element:e,elements:t})=>{const{watch:r}=yu(),o=r(),{visible:n,required:s,disabled:a}=P.useMemo(()=>Vb(e,o,t),[e,o,t]);return n?l.jsx(QP,{element:e,elements:t,dynamicRequired:s,dynamicDisabled:a}):null},QP=({element:e,elements:t,dynamicRequired:r,dynamicDisabled:o})=>{const{setValue:n,watch:s}=yu(),a=e.attributes.name,i=s(a),c=o||e.properties.disabled||!1,d=r,p={small:"max-w-xs",medium:"max-w-md",large:"max-w-lg",full:"w-full",default:"max-w-md"},u=p[e.layout.size||"default"]||p.default,f=ut.get(e.type),h=(N,x)=>{const w=t.filter(C=>C.parentId===N).sort((C,E)=>C.order-E.order);return l.jsx("div",{className:m("space-y-4"),children:w.map(C=>l.jsx(Qy,{element:{...C,attributes:{...C.attributes,name:x?`${x}.${C.attributes.name}`:C.attributes.name}},elements:t},C.id))})},g={element:e,properties:e.properties,layout:e.layout,validation:{...e.validation,required:d},logic:e.logic,config:e.config,mode:"render",value:i,onChange:N=>n(a,N),errors:[],formValues:s(),readOnly:!1,disabled:c,allElements:t,renderChildren:h},y=()=>f!=null&&f.render?f.render(g):l.jsxs("div",{className:m("p-3 bg-yellow-50 border border-yellow-200 rounded-md text-sm text-yellow-700"),children:[l.jsxs("p",{className:m("font-medium"),children:["Unknown element type: ",e.type]}),l.jsxs("p",{className:m("text-xs mt-1"),children:["This element is not registered in the element registry. Please register it using ",l.jsx("code",{children:"registerElement()"}),"."]})]});return(f==null?void 0:f.structure)==="page"&&["heading","layout","special"].includes(f.subCategory||"")||["paragraph","image","link","formHeading","sectionHeading","subheading","divider","spacer","captcha","submit"].includes(e.type)?l.jsx("div",{className:m(u,"mb-4"),children:y()}):l.jsx("div",{className:m(u,"mb-4"),children:y()})},Ky=({schema:e,onSubmit:t,initialValues:r,submissionFormat:o="keyValue",debug:n=!1})=>{const[s,a]=P.useState(null);if(P.useMemo(()=>e.elements.some(h=>h.type==="pages"),[e.elements]))return l.jsx(Cu,{schema:e,onSubmit:t,initialValues:r,submissionFormat:o,debug:n});const c=P.useMemo(()=>e.elements.filter(h=>!h.parentId),[e.elements]),d=P.useMemo(()=>r||YP(c),[r,c]),p=Hy({defaultValues:d,mode:"onChange"}),u=P.useCallback(h=>{const g=Nu(h,e.elements,o);console.log("Form submitted:",g),n?a(g):t==null||t(g)},[t,e.elements,o,n]),f=P.useMemo(()=>[...c].sort((h,g)=>h.order-g.order),[c]);return l.jsxs("div",{className:m("max-w-3xl mx-auto"),children:[l.jsx($y,{...p,children:l.jsxs("form",{onSubmit:p.handleSubmit(u),className:m("space-y-1"),children:[l.jsx("div",{className:m(""),children:e.description&&l.jsx("p",{className:m("mt-2 text-gray-600"),children:e.description})}),l.jsx("div",{className:m("space-y-4"),children:f.map(h=>l.jsx(Qy,{element:h,elements:e.elements},h.id))})]})}),n&&s&&l.jsxs("div",{className:m("mt-8 p-4 bg-green-50 border border-green-200 rounded-lg"),children:[l.jsx("h3",{className:m("text-lg font-medium text-green-800 mb-2"),children:"Submitted Data:"}),l.jsx("pre",{className:m("text-sm text-green-700 overflow-x-auto"),children:JSON.stringify(s,null,2)})]})]})},Ry=S.forwardRef(({className:e,...t},r)=>l.jsx("div",{ref:r,className:m("rounded-xl border bg-card text-card-foreground shadow",e),...t}));Ry.displayName="Card";const KP=S.forwardRef(({className:e,...t},r)=>l.jsx("div",{ref:r,className:m("flex flex-col space-y-1.5 p-6",e),...t}));KP.displayName="CardHeader";const RP=S.forwardRef(({className:e,...t},r)=>l.jsx("div",{ref:r,className:m("font-semibold leading-none tracking-tight",e),...t}));RP.displayName="CardTitle";const XP=S.forwardRef(({className:e,...t},r)=>l.jsx("div",{ref:r,className:m("text-sm text-muted-foreground",e),...t}));XP.displayName="CardDescription";const Xy=S.forwardRef(({className:e,...t},r)=>l.jsx("div",{ref:r,className:m("p-6 pt-0",e),...t}));Xy.displayName="CardContent";const JP=S.forwardRef(({className:e,...t},r)=>l.jsx("div",{ref:r,className:m("flex items-center p-6 pt-0",e),...t}));JP.displayName="CardFooter";const ZP=Ma("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Jy=S.forwardRef(({className:e,variant:t,...r},o)=>l.jsx("div",{ref:o,role:"alert",className:m(ZP({variant:t}),e),...r}));Jy.displayName="Alert";const Zy=S.forwardRef(({className:e,...t},r)=>l.jsx("h5",{ref:r,className:m("mb-1 font-medium leading-none tracking-tight",e),...t}));Zy.displayName="AlertTitle";const ev=S.forwardRef(({className:e,...t},r)=>l.jsx("div",{ref:r,className:m("text-sm [&_p]:leading-relaxed",e),...t}));ev.displayName="AlertDescription";const eI={id:"design",label:"Design Mode",icon:gE,order:0,keyboardShortcut:"d",description:"Edit your form layout and properties",renderContent:(e,t)=>l.jsxs(l.Fragment,{children:[t==null?void 0:t.ElementSidebar,t==null?void 0:t.Canvas,t==null?void 0:t.PropertyPanel]})},tI={id:"preview",label:"Preview Mode",icon:bh,order:10,keyboardShortcut:"p",description:"Preview your form as an end user",renderContent:(e,t)=>{const{schema:r,setMode:o,submissionFormat:n,onSubmit:s}=e,a=r.elements.some(c=>c.type==="pages"),i=c=>{console.log("Form submitted:",c),s==null||s(c)};return l.jsx("div",{className:m("flex-1 overflow-y-auto bg-muted/30"),children:l.jsxs("div",{className:m("py-8 px-4"),children:[l.jsx("div",{className:m("max-w-3xl mx-auto mb-6"),children:l.jsxs("div",{className:m("flex items-center justify-between"),children:[l.jsxs("div",{className:m("flex items-center gap-2 text-sm text-muted-foreground"),children:[l.jsx(bh,{className:m("h-4","w-4")}),l.jsx("span",{children:"Preview Mode"}),a&&l.jsx(vc,{variant:"secondary",children:"Wizard Form"})]}),l.jsxs(Je,{variant:"ghost",size:"sm",onClick:()=>o("design"),children:[l.jsx(fE,{className:m("h-4","w-4","mr-1")}),"Back to Editor"]})]})}),l.jsx(Ry,{className:m("max-w-3xl mx-auto"),children:l.jsx(Xy,{className:m("p-8"),children:r.elements.length===0?l.jsxs("div",{className:m("text-center py-12 text-muted-foreground"),children:[l.jsx(mE,{className:m("h-12","w-12","mx-auto","mb-4","text-muted-foreground/50")}),l.jsx("p",{className:m("text-lg font-medium mb-2"),children:"No elements to preview"}),l.jsx("p",{className:m("text-sm"),children:"Switch to Design mode and add some elements to your form."})]}):a?l.jsx(Cu,{schema:r,onSubmit:i,submissionFormat:n}):l.jsx(Ky,{schema:r,onSubmit:i,submissionFormat:n})})}),r.elements.some(c=>c.logic)&&l.jsx("div",{className:m("max-w-3xl mx-auto mt-6"),children:l.jsxs(Jy,{children:[l.jsx(yh,{className:m("h-4","w-4")}),l.jsx(Zy,{children:"Conditional Logic Active"}),l.jsx(ev,{children:"This form has conditional logic rules. Some fields may show/hide based on your input."})]})})]})})}};function tv(){Kt.has("design")||Kt.register(eI),Kt.has("preview")||Kt.register(tI)}tv();const rv=({initialSchema:e,onSchemaChange:t,toolbarActions:r,toolbarConfig:o,sidebarTabs:n,sidebarConfig:s,onPreviewSubmit:a,showElementSidebar:i=!0,showPropertyPanel:c=!0,submissionFormat:d="array",className:p})=>{const u=te(w=>w.mode),f=te(w=>w.setMode),h=te(w=>w.schema),g=te(w=>w.loadSchema);P.useEffect(()=>Tw(),[]),P.useEffect(()=>{e&&g(e)},[e,g]),P.useEffect(()=>{t&&t(h)},[h,t]);const y=r||o?{...o,actions:[...(o==null?void 0:o.actions)??[],...r??[]]}:void 0,b=n||s!=null&&s.tabs?[...(s==null?void 0:s.tabs)??[],...n??[]]:void 0,v=Kt.get(u),N=P.useMemo(()=>({schema:h,currentMode:u,setMode:f,submissionFormat:d,onSubmit:a,showElementSidebar:i,showPropertyPanel:c,loadSchema:g}),[h,u,f,d,a,i,c,g]),x=P.useMemo(()=>({ElementSidebar:i?l.jsx(a_,{sidebarTabs:b}):void 0,Canvas:l.jsx(__,{toolbarConfig:y}),PropertyPanel:c?l.jsx(mP,{}):void 0}),[i,b,y,c]);return l.jsx("div",{className:m("ep-main-layout h-screen flex flex-col bg-muted/50",p),children:l.jsx("div",{className:m("flex-1 flex overflow-hidden"),children:v?v.renderContent(N,x):null})})};ee.AffixInput=Ni,ee.CanvasElementRenderer=Ia,ee.CanvasPreviewWrapper=$0,ee.ElementDescription=ra,ee.ElementLabel=ta,ee.EmptyState=T0,ee.EntryPulse=rv,ee.ErrorMessages=Fn,ee.FieldWrapper=D0,ee.FormElementRenderer=Nh,ee.FormPreview=Ky,ee.IconInput=To,ee.InputWrapper=de,ee.WizardForm=Cu,ee.builtInElements=Sh,ee.createSidebarTab=sm,ee.createSidebarTabs=n_,ee.createToolbarAction=dm,ee.createToolbarActions=m_,ee.default=rv,ee.elementRegistry=ut,ee.extractContextValues=K,ee.filterFieldData=VP,ee.getButtonClassName=P0,ee.getCanvasInputClassName=kt,ee.getElementDefinition=Fw,ee.getElementIcon=Ch,ee.getElementLabel=yc,ee.getInputClassName=Ut,ee.getModeDefinition=x_,ee.hasElement=Vw,ee.hasMode=w_,ee.isActionDisabled=um,ee.isActionHidden=Vc,ee.isElementRegistered=e1,ee.isSidebarTabDisabled=am,ee.isSidebarTabHidden=lm,ee.modeRegistry=Kt,ee.registerBuiltInElements=LE,ee.registerBuiltinModes=tv,ee.registerElement=Ow,ee.registerElements=Mw,ee.registerMode=b_,ee.registerModes=y_,ee.renderElement=r1,ee.renderElementOnCanvas=t1,ee.transformSubmissionData=Nu,ee.transformToArrayFormat=qy,ee.unregisterElement=Lw,ee.unregisterMode=v_,ee.useFormStore=te,Object.defineProperties(ee,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
206
+ */var Cg;function qT(){return Cg||(Cg=1,process.env.NODE_ENV!=="production"&&(function(){function e(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=P,r=typeof Object.is=="function"?Object.is:e,o=t.useSyncExternalStore,n=t.useRef,a=t.useEffect,s=t.useMemo,l=t.useDebugValue;Ld.useSyncExternalStoreWithSelector=function(c,d,p,u,f){var h=n(null);if(h.current===null){var b={hasValue:!1,value:null};h.current=b}else b=h.current;h=s(function(){function y(N){if(!v){if(v=!0,S=N,N=u(N),f!==void 0&&b.hasValue){var k=b.value;if(f(k,N))return x=k}return x=N}if(k=x,r(S,N))return k;var _=u(N);return f!==void 0&&f(k,_)?(S=N,k):(S=N,x=_)}var v=!1,S,x,w=p===void 0?null:p;return[function(){return y(d())},w===null?void 0:function(){return y(w())}]},[d,p,u,f]);var g=o(c,h[0],h[1]);return a(function(){b.hasValue=!0,b.value=g},[g]),l(g),g},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Ld}var Sg;function YT(){return Sg||(Sg=1,process.env.NODE_ENV==="production"?Il.exports=jT():Il.exports=qT()),Il.exports}var QT=YT();function KT(e){e()}function RT(){let e=null,t=null;return{clear(){e=null,t=null},notify(){KT(()=>{let r=e;for(;r;)r.callback(),r=r.next})},get(){const r=[];let o=e;for(;o;)r.push(o),o=o.next;return r},subscribe(r){let o=!0;const n=t={callback:r,next:null,prev:t};return n.prev?n.prev.next=n:e=n,function(){!o||e===null||(o=!1,n.next?n.next.prev=n.prev:t=n.prev,n.prev?n.prev.next=n.next:e=n.next)}}}}var Ng={notify(){},get:()=>[]};function XT(e,t){let r,o=Ng,n=0,a=!1;function s(g){p();const y=o.subscribe(g);let v=!1;return()=>{v||(v=!0,y(),u())}}function l(){o.notify()}function c(){b.onStateChange&&b.onStateChange()}function d(){return a}function p(){n++,r||(r=e.subscribe(c),o=RT())}function u(){n--,r&&n===0&&(r(),r=void 0,o.clear(),o=Ng)}function f(){a||(a=!0,p())}function h(){a&&(a=!1,u())}const b={addNestedSub:s,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:d,trySubscribe:f,tryUnsubscribe:h,getListeners:()=>o};return b}var JT=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ZT=JT(),eD=()=>typeof navigator<"u"&&navigator.product==="ReactNative",tD=eD(),rD=()=>ZT||tD?C.useLayoutEffect:C.useEffect,oD=rD(),Fd=Symbol.for("react-redux-context"),Vd=typeof globalThis<"u"?globalThis:{};function nD(){if(!C.createContext)return{};const e=Vd[Fd]??(Vd[Fd]=new Map);let t=e.get(C.createContext);return t||(t=C.createContext(null),process.env.NODE_ENV!=="production"&&(t.displayName="ReactRedux"),e.set(C.createContext,t)),t}var So=nD();function aD(e){const{children:t,context:r,serverState:o,store:n}=e,a=C.useMemo(()=>{const c=XT(n),d={store:n,subscription:c,getServerState:o?()=>o:void 0};if(process.env.NODE_ENV==="production")return d;{const{identityFunctionCheck:p="once",stabilityCheck:u="once"}=e;return Object.assign(d,{stabilityCheck:u,identityFunctionCheck:p})}},[n,o]),s=C.useMemo(()=>n.getState(),[n]);oD(()=>{const{subscription:c}=a;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),s!==n.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[a,s]);const l=r||So;return C.createElement(l.Provider,{value:a},t)}var sD=aD;function Gd(e=So){return function(){const r=C.useContext(e);if(process.env.NODE_ENV!=="production"&&!r)throw new Error("could not find react-redux context value; please ensure the component is wrapped in a <Provider>");return r}}var Eg=Gd();function zd(e=So){const t=e===So?Eg:Gd(e),r=()=>{const{store:o}=t();return o};return Object.assign(r,{withTypes:()=>r}),r}var lD=zd();function iD(e=So){const t=e===So?lD:zd(e),r=()=>t().dispatch;return Object.assign(r,{withTypes:()=>r}),r}var cD=(e,t)=>e===t;function dD(e=So){const t=e===So?Eg:Gd(e),r=(o,n={})=>{const{equalityFn:a=cD}=typeof n=="function"?{equalityFn:n}:n;if(process.env.NODE_ENV!=="production"){if(!o)throw new Error("You must pass a selector to useSelector");if(typeof o!="function")throw new Error("You must pass a function as a selector to useSelector");if(typeof a!="function")throw new Error("You must pass a function as an equality function to useSelector")}const s=t(),{store:l,subscription:c,getServerState:d}=s,p=C.useRef(!0),u=C.useCallback({[o.name](h){const b=o(h);if(process.env.NODE_ENV!=="production"){const{devModeChecks:g={}}=typeof n=="function"?{}:n,{identityFunctionCheck:y,stabilityCheck:v}=s,{identityFunctionCheck:S,stabilityCheck:x}={stabilityCheck:v,identityFunctionCheck:y,...g};if(x==="always"||x==="once"&&p.current){const w=o(h);if(!a(b,w)){let N;try{throw new Error}catch(k){({stack:N}=k)}console.warn("Selector "+(o.name||"unknown")+` returned a different result when called with the same parameters. This can lead to unnecessary rerenders.
207
+ Selectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization`,{state:h,selected:b,selected2:w,stack:N})}}if((S==="always"||S==="once"&&p.current)&&b===h){let w;try{throw new Error}catch(N){({stack:w}=N)}console.warn("Selector "+(o.name||"unknown")+` returned the root state when called. This can lead to unnecessary rerenders.
208
+ Selectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.`,{stack:w})}p.current&&(p.current=!1)}return b}}[o.name],[o]),f=QT.useSyncExternalStoreWithSelector(c.addNestedSub,l.getState,d||l.getState,u,a);return C.useDebugValue(f),f};return Object.assign(r,{withTypes:()=>r}),r}const Ar=e=>C.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),uD=P.forwardRef((e,t)=>C.createElement("span",{...e.dragHandleAttributes,"data-testid":e.testID,ref:t,className:e.className,title:e.title},e.label)),fD=e=>{const{component:t,...r}=e,o=Qe(r.schema.suppressStandardClassnames||_e.betweenRules,r.schema.classNames.betweenRules);return C.createElement("div",{className:o,"data-testid":Te.inlineCombinator},C.createElement(t,{...r,testID:Te.combinators}))},kg={name:"",value:"",label:""},Ag=e=>["atleast","atmost","exactly"].includes(Ge(e)??""),_g=[],pD=e=>{const{match:t,options:r,title:o,className:n,disabled:a,testID:s,schema:l,thresholdPlaceholder:c,selectorComponent:d=e.schema.controls.valueSelector,numericEditorComponent:p=e.schema.controls.valueEditor}=e,{thresholdNum:u,thresholdRule:f,thresholdSchema:h,handleChangeMode:b,handleChangeThreshold:g}=hD(e),y=P.useMemo(()=>c?{...kg,placeholder:c}:kg,[c]);return C.createElement(C.Fragment,null,C.createElement(d,{schema:l,testID:s,className:n,title:o,handleOnChange:b,disabled:a,value:t.mode,options:r,multiple:!1,listsAsArrays:!1,path:_g,level:0}),Ag(t.mode)&&C.createElement(p,{skipHook:!0,testID:s,inputType:"number",title:o,className:n,disabled:a,handleOnChange:g,field:"",operator:"",value:u,valueSource:"value",fieldData:y,schema:h,path:_g,level:0,rule:f}))},hD=e=>{const{match:t,handleOnChange:r}=e,o=C.useMemo(()=>typeof t.threshold=="number"?Math.max(0,t.threshold):1,[t.threshold]);return{thresholdNum:o,thresholdRule:C.useMemo(()=>({field:"",operator:"=",value:o}),[o]),thresholdSchema:C.useMemo(()=>({...e.schema,parseNumbers:!0}),[e.schema]),handleChangeMode:P.useCallback(n=>{Ag(n)&&typeof t.threshold!="number"?r({...t,mode:n,threshold:1}):r({...t,mode:n})},[r,t]),handleChangeThreshold:P.useCallback(n=>{r({...t,threshold:Le(n,{parseNumbers:!0})})},[r,t])}},mD=e=>{const t=C.useId();return C.createElement("label",{"data-testid":e.testID,className:e.className,title:e.title,htmlFor:t},C.createElement("input",{id:t,type:"checkbox",onChange:r=>e.handleOnChange(r.target.checked),checked:!!e.checked,disabled:e.disabled}),e.label)},Lt={errorInvalidIndependentCombinatorsProp:"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",errorUnnecessaryIndependentCombinatorsProp:"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",errorDeprecatedRuleGroupProps:"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.",errorDeprecatedRuleProps:"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.",errorBothQueryDefaultQuery:"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",errorUncontrolledToControlled:"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",errorControlledToUncontrolled:"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",errorEnabledDndWithoutReactDnD:"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.",errorDeprecatedDebugImport:"Importing from react-querybuilder/debug is deprecated. To enable Redux DevTools for React Query Builder's internal store, set globalThis.__RQB_DEVTOOLS__ = true."},Ca=wg({name:"queries",initialState:{},reducers:{setQueryState:(e,{payload:{qbId:t,query:r}})=>{e[t]=r}},selectors:{getQuerySelectorById:(e,t)=>e[t]}}),Tg=C.createContext(null),Bd=wg({name:"warnings",initialState:{[Lt.errorInvalidIndependentCombinatorsProp]:!1,[Lt.errorUnnecessaryIndependentCombinatorsProp]:!1,[Lt.errorDeprecatedRuleGroupProps]:!1,[Lt.errorDeprecatedRuleProps]:!1,[Lt.errorBothQueryDefaultQuery]:!1,[Lt.errorUncontrolledToControlled]:!1,[Lt.errorControlledToUncontrolled]:!1,[Lt.errorEnabledDndWithoutReactDnD]:!1,[Lt.errorDeprecatedDebugImport]:!1},reducers:{rqbWarn:(e,{payload:t})=>{e[t]||(console.error(t),e[t]=!0)}}}),Dg=HT(Ca,Bd).withLazyLoadedSlices(),bD=e=>iD(e),gD=e=>zd(e),yD=e=>dD(e),vD=e=>({useRQB_INTERNAL_QueryBuilderDispatch:bD(e),useRQB_INTERNAL_QueryBuilderStore:gD(e),useRQB_INTERNAL_QueryBuilderSelector:yD(e)}),Ud=({payload:e,onQueryChange:t})=>r=>{r(Ca.actions.setQueryState(e)),typeof t=="function"&&t(e.query)},Wd=vD(Tg),Hd=Wd.useRQB_INTERNAL_QueryBuilderDispatch,wD=Wd.useRQB_INTERNAL_QueryBuilderStore,xD=Wd.useRQB_INTERNAL_QueryBuilderSelector,{rqbWarn:CD}=Bd.actions,rn=e=>t=>{setTimeout(()=>t(CD(e)))},SD={reducer:Dg,preloadedState:{queries:Ca.getInitialState(),warnings:Bd.getInitialState()},middleware:e=>e({serializableCheck:{ignoredActions:[Ca.actions.setQueryState.type],ignoredPaths:[/^queries\b.*\.rules\.\d+\.value$/]}})},ND=e=>{const[t,r]=P.useState(e),[o,n]=P.useState(null);return e!==t&&(n(t),r(e)),o},ED=e=>{const t=Hd(),{defaultQuery:r,queryProp:o}=e,n=ND(!!o);process.env.NODE_ENV!=="production"&&(o&&r?t(rn(Lt.errorBothQueryDefaultQuery)):n===!0&&!o&&r?t(rn(Lt.errorControlledToUncontrolled)):n===!1&&o&&!r&&t(rn(Lt.errorUncontrolledToControlled)))};function jd(e,t,r){const o=Hd();process.env.NODE_ENV!=="production"&&t&&(e==="independentCombinators"&&(r==="invalid"&&o(rn(Lt.errorInvalidIndependentCombinatorsProp)),r==="unnecessary"&&o(rn(Lt.errorUnnecessaryIndependentCombinatorsProp))),e==="rule"&&o(rn(Lt.errorDeprecatedRuleProps)),e==="ruleGroup"&&o(rn(Lt.errorDeprecatedRuleGroupProps)))}const $g=e=>{const{optionList:t,optionsMap:r,defaultOption:o}=P.useMemo(()=>Sn({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:r,defaultField:o}},kD=e=>{const t=CT({...SD,devTools:e?{name:"React Query Builder"}:!1});return t.addSlice=r=>{Dg.inject(r),t.dispatch({type:crypto.randomUUID().slice(0,8),meta:`Initializing state for slice "${r.name}"`})},t};let qd=null;function Pg(e){return qd||(qd=kD(globalThis==null?void 0:globalThis.__RQB_DEVTOOLS__)),qd}const on=e=>t=>Ca.selectors.getQuerySelectorById({queries:t.queries},e),AD=(e,t)=>{const r=C.useContext(Yd);return xD(e,t)??(r==null?void 0:r.initialQuery)},_D={},TD={},DD=[],$D={},PD=()=>null,Mg=()=>"",nn=()=>!0,MD=(...e)=>{console.log(...e)};function OD(e,t){const{query:r,defaultQuery:o,getValueEditorSeparator:n=PD,getRuleClassname:a=Mg,getRuleGroupClassname:s=Mg,onAddRule:l=nn,onAddGroup:c=nn,onMoveRule:d=nn,onMoveGroup:p=nn,onGroupRule:u=nn,onGroupGroup:f=nn,onRemove:h=nn,onQueryChange:b,showCombinatorsBetweenRules:g=!1,showNotToggle:y=!1,showShiftActions:v=!1,showCloneButtons:S=!1,showLockButtons:x=!1,showMuteButtons:w=!1,suppressStandardClassnames:N=!1,resetOnFieldChange:k=!0,resetOnOperatorChange:_=!1,autoSelectField:E=!0,autoSelectOperator:D=!0,autoSelectValue:T=!0,addRuleToNewGroups:O=!1,listsAsArrays:$=!1,parseNumbers:V=!1,disabled:G=!1,validator:q,onLog:H=MD,idGenerator:Y,accessibleDescriptionGenerator:J=p_}=e,{qbId:W,rqbContext:R,fields:we,fieldMap:Q,combinators:te,getParameters:De,getOperatorsMain:de,getMatchModesMain:Se,getRuleDefaultOperator:re,getSubQueryBuilderPropsMain:me,getValueEditorTypeMain:ce,getValueSourcesMain:Ie,getValuesMain:xe,getRuleDefaultValue:be,getInputTypeMain:ae,createRule:ue,createRuleGroup:ve}=t,{controlClassnames:Oe,controlElements:et,debugMode:at,enableDragAndDrop:it,enableMountQueryChange:tt,translations:$e}=R,yt=!!g,Xt=!!y,Wt=!!v,I=!!S,F=!!x,K=!!w,j=!!k,Z=!!_,se=!!E,A=!!D,M=!!T,L=!!O,B=!!$,U=!!N,X=(e.maxLevels??0)>0?Number(e.maxLevels):1/0,z=P.useCallback((...Ne)=>{at&&H(...Ne)},[at,H]);ED({defaultQuery:o,queryProp:r});const ee=wD(),ne=Hd(),Ce=P.useMemo(()=>on(W),[W]),Fe=AD(Ce),Ue=P.useCallback(()=>Ce(ee.getState()),[ee,Ce]),ye=P.useMemo(()=>ve(),[ve]),We=r??Fe??o??ye,ct=We.id?We:ml(We,{idGenerator:Y}),[Jt]=P.useState(ct),ko=P.useMemo(()=>({...R,initialQuery:Jt}),[R,Jt]);P.useEffect(()=>{r&&!Object.is(r,Fe)&&ne(Ud({payload:{qbId:W,query:r},onQueryChange:void 0}))},[r,W,Fe,ne]);const Zt=P.useMemo(()=>Cn(ct),[ct]),pt=!!e.independentCombinators&&!Zt;jd("independentCombinators",pt||!pt&&(e.independentCombinators??"not present")!=="not present",pt?"invalid":"unnecessary");const ir=P.useRef(!1);P.useEffect(()=>{ir.current||(ir.current=!0,ne(Ud({payload:{qbId:W,query:ct},onQueryChange:tt&&typeof b=="function"?b:void 0})))},[tt,b,W,ne,ct]);const kt=P.useCallback(Ne=>{ne(Ud({payload:{qbId:W,query:Ne},onQueryChange:b}))},[b,W,ne]),Ao=Array.isArray(G)&&G||DD,At=G===!0,Rl=ct.disabled||Ao.some(Ne=>Ne.length===0),Ta=P.useCallback((Ne,je,Je)=>{const Ye=on(W)(ee.getState());if(!Ye)return;if(An(je,Ye)||At){z({qbId:W,type:Et.parentPathDisabled,rule:Ne,parentPath:je,query:Ye});return}const qe=l(Ne,je,Ye,Je);if(!qe){z({qbId:W,type:Et.onAddRuleFalse,rule:Ne,parentPath:je,query:Ye});return}const Mt=qe===!0?Ne:qe,Ht=Lb(Ye,Mt,je,{combinators:te,combinatorPreceding:Mt.combinatorPreceding??void 0,idGenerator:Y});z({qbId:W,type:Et.add,query:Ye,newQuery:Ht,newRule:Mt,parentPath:je}),kt(Ht)},[te,kt,Y,z,l,W,ee,At]),Da=P.useCallback((Ne,je,Je)=>{if(je.length>=X)return;const Ye=on(W)(ee.getState());if(!Ye)return;if(An(je,Ye)||At){z({qbId:W,type:Et.parentPathDisabled,ruleGroup:Ne,parentPath:je,query:Ye});return}const qe=c(Ne,je,Ye,Je);if(!qe){z({qbId:W,type:Et.onAddGroupFalse,ruleGroup:Ne,parentPath:je,query:Ye});return}const Mt=qe===!0?Ne:qe,Ht=Lb(Ye,Mt,je,{combinators:te,combinatorPreceding:Mt.combinatorPreceding??void 0,idGenerator:Y});z({qbId:W,type:Et.add,query:Ye,newQuery:Ht,newGroup:Mt,parentPath:je}),kt(Ht)},[te,kt,Y,z,X,c,W,ee,At]),$a=P.useCallback((Ne,je,Je)=>{const Ye=on(W)(ee.getState());if(!Ye)return;if(An(Je,Ye)&&Ne!=="disabled"||At){z({qbId:W,type:Et.pathDisabled,path:Je,prop:Ne,value:je,query:Ye});return}const qe=k_(Ye,Ne,je,Je,{resetOnFieldChange:j,resetOnOperatorChange:Z,getRuleDefaultOperator:re,getValueSources:Ie,getRuleDefaultValue:be,getMatchModes:Se});z({qbId:W,type:Et.update,query:Ye,newQuery:qe,prop:Ne,value:je,path:Je}),kt(qe)},[kt,Se,re,be,Ie,z,W,ee,At,j,Z]),$n=P.useCallback((Ne,je)=>{const Je=on(W)(ee.getState());if(!Je)return;if(An(Ne,Je)||At){z({qbId:W,type:Et.pathDisabled,path:Ne,query:Je});return}const Ye=Ct(Ne,Je);if(Ye)if(h(Ye,Ne,Je,je)){const qe=__(Je,Ne);z({qbId:W,type:Et.remove,query:Je,newQuery:qe,path:Ne,ruleOrGroup:Ye}),kt(qe)}else z({qbId:W,type:Et.onRemoveFalse,ruleOrGroup:Ye,path:Ne,query:Je})},[kt,z,h,W,ee,At]),Pa=P.useCallback((Ne,je,Je,Ye)=>{const qe=on(W)(ee.getState());if(!qe)return;if(An(Ne,qe)||At){z({qbId:W,type:Et.pathDisabled,oldPath:Ne,newPath:je,query:qe});return}const Mt=D_(qe,Ne,je,{clone:Je,combinators:te,idGenerator:Y}),Ht=Ct(Ne,qe),_o=ke(Ht),Yr=(_o?p:d)(Ht,Ne,je,qe,Mt,{clone:Je,combinators:te},Ye);if(!Yr){z({qbId:W,type:_o?Et.onMoveGroupFalse:Et.onMoveRuleFalse,ruleOrGroup:Ht,oldPath:Ne,newPath:je,clone:Je,query:qe,nextQuery:Mt});return}const To=ke(Yr)?Yr:Mt;z({qbId:W,type:Et.move,query:qe,newQuery:To,oldPath:Ne,newPath:je,clone:Je}),kt(To)},[te,kt,Y,z,p,d,W,ee,At]),Ma=P.useCallback((Ne,je,Je,Ye)=>{const qe=on(W)(ee.getState());if(!qe)return;if(An(Ne,qe)||At){z({qbId:W,type:Et.pathDisabled,sourcePath:Ne,targetPath:je,query:qe});return}const Mt=P_(qe,Ne,je,{clone:Je,combinators:te,idGenerator:Y}),Ht=Ct(Ne,qe),_o=ke(Ht),Yr=(_o?f:u)(Ht,Ne,je,qe,Mt,{clone:Je,combinators:te},Ye);if(!Yr){z({qbId:W,type:_o?Et.onGroupGroupFalse:Et.onGroupRuleFalse,ruleOrGroup:Ht,sourcePath:Ne,targetPath:je,clone:Je,query:qe,nextQuery:Mt});return}const To=ke(Yr)?Yr:Mt;z({qbId:W,type:Et.group,query:qe,newQuery:To,sourcePath:Ne,targetPath:je,clone:Je}),kt(To)},[te,kt,Y,z,f,u,W,ee,At]),{validationResult:yr,validationMap:Oa}=P.useMemo(()=>{const Ne=typeof q=="function"&&ct?q(ct):_D;return{validationResult:Ne,validationMap:typeof Ne=="boolean"?TD:Ne}},[ct,q]),Xl=it?"enabled":"disabled",Jl=Zt||yt?"enabled":"disabled",Zl=P.useMemo(()=>typeof ct.combinator=="string"?{combinator:ct.combinator}:$D,[ct.combinator]),ei=P.useMemo(()=>Qe(U||_e.queryBuilder,Qe(Oe.queryBuilder),At&&Oe.disabled,typeof yr=="boolean"&&yr&&Oe.valid,typeof yr=="boolean"&&!yr&&Oe.invalid,U||{[_e.disabled]:At,[_e.valid]:typeof yr=="boolean"&&yr,[_e.invalid]:typeof yr=="boolean"&&!yr}),[Oe.disabled,Oe.invalid,Oe.queryBuilder,Oe.valid,At,U,yr]),Ia=P.useCallback(Ne=>ve(Ne??Zt),[ve,Zt]),ti=P.useMemo(()=>({addRuleToNewGroups:L,accessibleDescriptionGenerator:J,autoSelectField:se,autoSelectOperator:A,autoSelectValue:M,classNames:Oe,combinators:te,getParameters:De,controls:et,createRule:ue,createRuleGroup:Ia,disabledPaths:Ao,enableDragAndDrop:it,fieldMap:Q,fields:we,dispatchQuery:kt,getQuery:Ue,getInputType:ae,getOperators:de,getMatchModes:Se,getRuleClassname:a,getRuleDefaultOperator:re,getRuleDefaultValue:be,getRuleGroupClassname:s,getSubQueryBuilderProps:me,getValueEditorSeparator:n,getValueEditorType:ce,getValues:xe,getValueSources:Ie,independentCombinators:Zt,listsAsArrays:B,maxLevels:X,parseNumbers:V,qbId:W,resetOnFieldChange:j,resetOnOperatorChange:Z,showCloneButtons:I,showCombinatorsBetweenRules:yt,showLockButtons:F,showMuteButtons:K,showNotToggle:Xt,showShiftActions:Wt,suppressStandardClassnames:U,validationMap:Oa}),[J,L,se,A,M,te,Oe,et,ue,Ia,Ao,kt,it,Q,we,ae,de,Se,Ue,a,re,be,s,me,n,ce,xe,Ie,De,Zt,B,X,V,W,j,Z,I,yt,F,K,Xt,Wt,U,Oa]);return{actions:P.useMemo(()=>({moveRule:Pa,onGroupAdd:Da,onGroupRemove:$n,onPropChange:$a,onRuleAdd:Ta,onRuleRemove:$n,groupRule:Ma}),[Ma,Pa,Da,$a,Ta,$n]),rootGroup:ct,rootGroupDisabled:Rl,queryDisabled:At,rqbContext:ko,schema:ti,translations:$e,wrapperClassName:ei,dndEnabledAttr:Xl,inlineCombinatorsAttr:Jl,combinatorPropObject:Zl}}const ID=e=>{const[t]=P.useState(pr),{fields:r,baseField:o,operators:n,baseOperator:a,combinators:s,baseCombinator:l,getParameters:c,translations:d,enableMountQueryChange:p=!0,controlClassnames:u,controlElements:f,getDefaultField:h,getDefaultOperator:b,getDefaultValue:g,getMatchModes:y,getOperators:v,getSubQueryBuilderProps:S,getValueEditorType:x,getValueSources:w,getInputType:N,getValues:k,autoSelectField:_=!0,autoSelectOperator:E=!0,autoSelectValue:D=!0,addRuleToNewGroups:T=!1,enableDragAndDrop:O,listsAsArrays:$=!1,debugMode:V=!1,idGenerator:G=pr}=e,[q]=P.useState(e.query??e.defaultQuery),H=QD({controlClassnames:u,controlElements:f,debugMode:V,enableDragAndDrop:O,enableMountQueryChange:p,translations:d,initialQuery:q,qbId:t,finalize:!0}),{translations:Y}=H,{fields:J,fieldMap:W}=$g({fields:r,baseField:o,autoSelectField:_,translations:Y}),{optionList:R}=P.useMemo(()=>Sn({optionList:s??aa,labelMap:pA,baseOption:l,autoSelectOption:!0}),[l,s]),we=P.useCallback((ae,ue,ve)=>Sn({optionList:(c==null?void 0:c(ae,ue,ve))??[],autoSelectOption:!0}).optionList,[c]),{optionList:Q}=P.useMemo(()=>Sn({optionList:n??hA,placeholder:Y.operators,labelMap:Im,baseOption:a,autoSelectOption:E}),[E,a,n,Y.operators]),te=P.useCallback((ae,{fieldData:ue})=>Sn({optionList:(ue==null?void 0:ue.operators)??(v==null?void 0:v(ae,{fieldData:ue}))??Q,placeholder:Y.operators,baseOption:a,labelMap:Im,autoSelectOption:E}).optionList,[E,a,v,Q,Y.operators]),De=P.useCallback(ae=>{const ue=W[ae];return ue!=null&&ue.defaultOperator?ue.defaultOperator:b?typeof b=="function"?b(ae,{fieldData:ue}):b:Pt(te(ae,{fieldData:ue})??[])??""},[W,b,te]),de=P.useCallback((ae,ue,{fieldData:ve})=>ve.valueEditorType?typeof ve.valueEditorType=="function"?ve.valueEditorType(ue):ve.valueEditorType:(x==null?void 0:x(ae,ue,{fieldData:ve}))??"text",[x]),Se=P.useCallback((ae,ue,ve)=>Pb(W[ae],ue,w),[W,w]),re=P.useCallback((ae,ue)=>m_(W[ae],y),[W,y]),me=P.useCallback((ae,ue)=>(S==null?void 0:S(ae,ue))??{},[S]),ce=P.useCallback((ae,ue,{fieldData:ve})=>Sn({optionList:(ve==null?void 0:ve.values)??(k==null?void 0:k(ae,ue,{fieldData:ve}))??[],placeholder:Y.values,autoSelectOption:D}).optionList,[D,k,Y.values]),Ie=P.useCallback(ae=>b_(ae,{fieldData:W[ae.field]??{},fields:J,getParameters:(ue,ve,Oe)=>we(ue,ve,Oe),listsAsArrays:$,getValueEditorType:(ue,ve,Oe)=>de(ue,ve,Oe),getValues:(ue,ve,Oe)=>ce(ue,ve,Oe),getDefaultValue:g&&((ue,ve)=>g(ue,ve))}),[W,J,g,de,ce,$,we]),xe=P.useCallback((ae,ue,{fieldData:ve})=>{if(N){const Oe=N(ae,ue,{fieldData:ve});if(Oe)return Oe}return"text"},[N]),be=P.useCallback(()=>{let ae="";const ue=J;/* v8 ignore else -- @preserve */if((ue==null?void 0:ue.length)>0&&ue[0]){const tt=Pt(ue);/* v8 ignore else -- @preserve */tt&&(ae=tt)}if(h)if(typeof h=="function"){const tt=h(ue);/* v8 ignore else -- @preserve */tt&&(ae=tt)}else ae=h;const ve=De(ae),Oe=Pt(Se(ae,ve,{fieldData:Xe(ue,ae)}))??"value",et=Pt(re(ae,{fieldData:Xe(ue,ae)})),at={id:G(),field:ae,operator:ve,valueSource:Oe,value:"",...et?{match:{mode:et,threshold:1}}:null},it=Ie(at);return{...at,value:it}},[J,h,re,De,Ie,Se,G]);return{qbId:t,rqbContext:H,fields:J,fieldMap:W,combinators:R,getParameters:we,getMatchModesMain:re,getOperatorsMain:te,getRuleDefaultOperator:De,getSubQueryBuilderPropsMain:me,getValueEditorTypeMain:de,getValueSourcesMain:Se,getValuesMain:ce,getRuleDefaultValue:Ie,getInputTypeMain:xe,createRule:be,createRuleGroup:P.useCallback(ae=>ae?{id:G(),rules:T?[be()]:[],not:!1}:{id:G(),rules:T?[be()]:[],combinator:Pt(R)??"",not:!1},[T,R,be,G])}},Og=e=>OD(e,ID(e)),Yd=P.createContext({}),LD=C.memo(function(t){const r=Ig(t),{previewRef:o,dropRef:n,schema:{controls:{ruleGroupBodyElements:a,ruleGroupHeaderElements:s}}}=r,l=bt(r.addRule),c=bt(r.addGroup),d=bt(r.cloneGroup),p=bt(r.toggleLockGroup),u=bt(r.toggleMuteGroup),f=bt(r.removeGroup),h=bt(r.shiftGroupUp),b=bt(r.shiftGroupDown),g=P.useMemo(()=>({addRule:l,addGroup:c,cloneGroup:d,toggleLockGroup:p,toggleMuteGroup:u,removeGroup:f,shiftGroupUp:h,shiftGroupDown:b}),[l,c,d,p,u,f,h,b]);return C.createElement("div",{ref:o,title:r.accessibleDescription,className:r.outerClassName,"data-testid":Te.ruleGroup,"data-not":r.ruleGroup.not?"true":void 0,"data-dragmonitorid":r.dragMonitorId,"data-dropmonitorid":r.dropMonitorId,"data-rule-group-id":r.id,"data-level":r.path.length,"data-path":JSON.stringify(r.path)},C.createElement("div",{ref:n,className:r.classNames.header},C.createElement(s,{...r,...g})),C.createElement("div",{className:r.classNames.body},C.createElement(a,{...r,...g})))}),FD=C.memo(function(t){const{dragRef:r,schema:{controls:{shiftActions:o,dragHandle:n,combinatorSelector:a,notToggle:s,addRuleAction:l,addGroupAction:c,cloneGroupAction:d,lockGroupAction:p,muteGroupAction:u,removeGroupAction:f}}}=t,h=P.useMemo(()=>({level:t.path.length,path:t.path,disabled:t.disabled,context:t.context,validation:t.validationResult,schema:t.schema}),[t.path,t.disabled,t.context,t.validationResult,t.schema]),b=P.useMemo(()=>t.schema.showShiftActions?{shiftUp:t.translations.shiftActionUp.title,shiftDown:t.translations.shiftActionDown.title}:void 0,[t.schema.showShiftActions,t.translations]),g=P.useMemo(()=>t.schema.showShiftActions?{shiftUp:t.translations.shiftActionUp.label,shiftDown:t.translations.shiftActionDown.label}:void 0,[t.schema.showShiftActions,t.translations]);return C.createElement(P.Fragment,null,t.schema.showShiftActions&&t.path.length>0&&C.createElement(o,{key:Te.shiftActions,...h,testID:Te.shiftActions,titles:b,labels:g,className:t.classNames.shiftActions,shiftUp:t.shiftGroupUp,shiftDown:t.shiftGroupDown,shiftUpDisabled:t.shiftUpDisabled,shiftDownDisabled:t.shiftDownDisabled,ruleOrGroup:t.ruleGroup}),t.path.length>0&&t.schema.enableDragAndDrop&&C.createElement(n,{key:Te.dragHandle,...h,testID:Te.dragHandle,ref:r,title:t.translations.dragHandle.title,label:t.translations.dragHandle.label,className:t.classNames.dragHandle,dragHandleAttributes:t.dragHandleAttributes,ruleOrGroup:t.ruleGroup}),!t.schema.showCombinatorsBetweenRules&&!t.schema.independentCombinators&&C.createElement(a,{key:Te.combinators,...h,testID:Te.combinators,options:t.schema.combinators,value:t.combinator,title:t.translations.combinators.title,className:t.classNames.combinators,handleOnChange:t.onCombinatorChange,rules:t.ruleGroup.rules,ruleGroup:t.ruleGroup}),t.schema.showNotToggle&&C.createElement(s,{key:Te.notToggle,...h,testID:Te.notToggle,className:t.classNames.notToggle,title:t.translations.notToggle.title,label:t.translations.notToggle.label,checked:t.ruleGroup.not,handleOnChange:t.onNotToggleChange,ruleGroup:t.ruleGroup}),C.createElement(l,{key:Te.addRule,...h,testID:Te.addRule,label:t.translations.addRule.label,title:t.translations.addRule.title,className:t.classNames.addRule,handleOnClick:t.addRule,rules:t.ruleGroup.rules,ruleOrGroup:t.ruleGroup}),t.schema.maxLevels>t.path.length&&C.createElement(c,{key:Te.addGroup,...h,testID:Te.addGroup,label:t.translations.addGroup.label,title:t.translations.addGroup.title,className:t.classNames.addGroup,handleOnClick:t.addGroup,rules:t.ruleGroup.rules,ruleOrGroup:t.ruleGroup}),t.schema.showCloneButtons&&t.path.length>0&&C.createElement(d,{key:Te.cloneGroup,...h,testID:Te.cloneGroup,label:t.translations.cloneRuleGroup.label,title:t.translations.cloneRuleGroup.title,className:t.classNames.cloneGroup,handleOnClick:t.cloneGroup,rules:t.ruleGroup.rules,ruleOrGroup:t.ruleGroup}),t.schema.showLockButtons&&C.createElement(p,{key:Te.lockGroup,...h,testID:Te.lockGroup,label:t.translations.lockGroup.label,title:t.translations.lockGroup.title,className:t.classNames.lockGroup,handleOnClick:t.toggleLockGroup,rules:t.ruleGroup.rules,disabledTranslation:t.parentDisabled?void 0:t.translations.lockGroupDisabled,ruleOrGroup:t.ruleGroup}),t.schema.showMuteButtons&&C.createElement(u,{key:Te.muteGroup,...h,testID:Te.muteGroup,label:t.ruleGroup.muted?t.translations.unmuteGroup.label:t.translations.muteGroup.label,title:t.ruleGroup.muted?t.translations.unmuteGroup.title:t.translations.muteGroup.title,className:t.classNames.muteGroup,handleOnClick:t.toggleMuteGroup,rules:t.ruleGroup.rules,ruleOrGroup:t.ruleGroup}),t.path.length>0&&C.createElement(f,{key:Te.removeGroup,...h,testID:Te.removeGroup,label:t.translations.removeGroup.label,title:t.translations.removeGroup.title,className:t.classNames.removeGroup,handleOnClick:t.removeGroup,rules:t.ruleGroup.rules,ruleOrGroup:t.ruleGroup}))}),VD=C.memo(function(t){const{schema:{controls:{combinatorSelector:r,inlineCombinator:o,ruleGroup:n,rule:a}}}=t;return C.createElement(P.Fragment,null,t.ruleGroup.rules.map((s,l,{length:c})=>{const d=t.pathsMemo[l],p=d.path,u=d.disabled||typeof s!="string"&&s.disabled,f=Jo([0],p),h=t.path.length===0&&l===c-1,b=typeof s=="string"?[...p,s].join("-"):s.id;return C.createElement(P.Fragment,{key:b},l>0&&!t.schema.independentCombinators&&t.schema.showCombinatorsBetweenRules&&C.createElement(o,{key:Te.inlineCombinator,options:t.schema.combinators,value:t.combinator,title:t.translations.combinators.title,className:t.classNames.combinators,handleOnChange:t.onCombinatorChange,rules:t.ruleGroup.rules,level:t.path.length,context:t.context,validation:t.validationResult,component:r,path:p,disabled:t.disabled,schema:t.schema,ruleGroup:t.ruleGroup}),typeof s=="string"?C.createElement(o,{key:`${Te.inlineCombinator}-independent`,options:t.schema.combinators,value:s,title:t.translations.combinators.title,className:t.classNames.combinators,handleOnChange:g=>t.onIndependentCombinatorChange(g,l),rules:t.ruleGroup.rules,level:t.path.length,context:t.context,validation:t.validationResult,component:r,path:p,disabled:u,schema:t.schema,ruleGroup:t.ruleGroup}):ke(s)?C.createElement(n,{key:Te.ruleGroup,id:s.id,schema:t.schema,actions:t.actions,path:p,translations:t.translations,ruleGroup:s,rules:s.rules,combinator:Bt(s)?s.combinator:void 0,not:!!s.not,disabled:u,parentDisabled:t.parentDisabled||t.disabled,parentMuted:t.parentMuted||t.muted,shiftUpDisabled:f,shiftDownDisabled:h,context:t.context}):C.createElement(a,{key:Te.rule,id:s.id,rule:s,field:s.field,operator:s.operator,value:s.value,valueSource:s.valueSource,schema:t.schema,actions:t.actions,path:p,disabled:u,parentDisabled:t.parentDisabled||t.disabled,parentMuted:t.parentMuted||t.muted,translations:t.translations,shiftUpDisabled:f,shiftDownDisabled:h,context:t.context}))}))}),Ig=e=>{const{id:t,path:r,ruleGroup:o,schema:{qbId:n,accessibleDescriptionGenerator:a,classNames:s,combinators:l,createRule:c,createRuleGroup:d,disabledPaths:p,independentCombinators:u,validationMap:f,enableDragAndDrop:h,getRuleGroupClassname:b,suppressStandardClassnames:g},actions:{onGroupAdd:y,onGroupRemove:v,onPropChange:S,onRuleAdd:x,moveRule:w},disabled:N,parentDisabled:k,parentMuted:_,shiftUpDisabled:E,shiftDownDisabled:D,combinator:T,rules:O,not:$,dropEffect:V="move",groupItems:G=!1,dragMonitorId:q="",dropMonitorId:H="",previewRef:Y=null,dragRef:J=null,dropRef:W=null,isDragging:R=!1,isOver:we=!1,dropNotAllowed:Q=!1}=e;jd("ruleGroup",!o),Fg(h,!!(q||H||Y||J||W));const te=!!k||!!N,De=!!_||!!(o!=null&&o.muted),de=P.useMemo(()=>o&&Bt(o)?o.combinator:o?Pt(l):T??Pt(l),[T,l,o]),Se=P.useMemo(()=>{if(o){if(o.combinator===de||u)return o;const F=structuredClone(o);return F.combinator=de,F}return{rules:O,not:$}},[de,u,$,o,O]),re=P.useMemo(()=>({header:Qe(g||_e.header,s.header,we&&V==="copy"&&s.dndCopy,Q&&s.dndDropNotAllowed,g||{[_e.dndOver]:we,[_e.dndCopy]:we&&V==="copy",[_e.dndDropNotAllowed]:Q}),shiftActions:Qe(g||_e.shiftActions,s.shiftActions),dragHandle:Qe(g||_e.dragHandle,s.dragHandle),combinators:Qe(g||_e.combinators,s.valueSelector,s.combinators),notToggle:Qe(g||_e.notToggle,s.notToggle),addRule:Qe(g||_e.addRule,s.actionElement,s.addRule),addGroup:Qe(g||_e.addGroup,s.actionElement,s.addGroup),cloneGroup:Qe(g||_e.cloneGroup,s.actionElement,s.cloneGroup),lockGroup:Qe(g||_e.lockGroup,s.actionElement,s.lockGroup),muteGroup:Qe(g||_e.muteGroup,s.actionElement,s.muteGroup),removeGroup:Qe(g||_e.removeGroup,s.actionElement,s.removeGroup),body:Qe(g||_e.body,s.body)}),[s.actionElement,s.addGroup,s.addRule,s.body,s.cloneGroup,s.combinators,s.dndCopy,s.dndDropNotAllowed,s.dragHandle,s.header,s.lockGroup,s.muteGroup,s.notToggle,s.removeGroup,s.shiftActions,s.valueSelector,V,Q,we,g]),me=P.useCallback(F=>{te||S("combinator",F,r)},[te,S,r]),ce=P.useCallback((F,K,j)=>{te||S("combinator",F,[...r,K])},[te,S,r]),Ie=P.useCallback((F,K)=>{te||S("not",F,r)},[te,S,r]),xe=P.useCallback((F,K)=>{if(!te){const j=c();x(j,r,K)}},[c,te,x,r]),be=P.useCallback((F,K)=>{if(!te){const j=d();y(j,r,K)}},[d,te,y,r]),ae=P.useCallback(()=>{if(!te){const F=[...mt(r),r.at(-1)+1];w(r,F,!0)}},[te,w,r]),ue=P.useCallback((F,K)=>{!te&&!E&&w(r,"up",F==null?void 0:F.altKey)},[te,w,r,E]),ve=P.useCallback((F,K)=>{!te&&!D&&w(r,"down",F==null?void 0:F.altKey)},[te,w,r,D]),Oe=P.useCallback(()=>{S("disabled",!te,r)},[te,S,r]),et=P.useCallback(()=>{S("muted",!Se.muted,r)},[Se.muted,S,r]),at=P.useCallback(()=>{te||v(r)},[te,v,r]),it=f[t??""],tt=P.useMemo(()=>Db(it),[it]),$e=P.useMemo(()=>{var F;return u?null:((F=Xe(l,de))==null?void 0:F.className)??""},[de,l,u]),yt=P.useMemo(()=>b(Se),[b,Se]),Xt=P.useMemo(()=>Qe(yt,$e,g||_e.ruleGroup,s.ruleGroup,te&&s.disabled,De&&s.muted,R&&s.dndDragging,we&&G&&s.dndGroup,g||{[_e.disabled]:te,[_e.muted]:De,[_e.dndDragging]:R,[_e.dndGroup]:we&&G},tt),[s.disabled,s.muted,s.dndDragging,s.dndGroup,s.ruleGroup,$e,te,De,G,R,we,yt,g,tt]),Wt=KD({disabled:te,disabledPaths:p,path:r,nestedArray:Se.rules}),I=P.useMemo(()=>a({path:r,qbId:n}),[a,r,n]);return{...e,addGroup:be,addRule:xe,accessibleDescription:I,classNames:re,cloneGroup:ae,combinator:de,disabled:te,dragMonitorId:q,dragRef:J,dropMonitorId:H,dropRef:W,isDragging:R,isOver:we,muted:De,onCombinatorChange:me,onGroupAdd:y,onIndependentCombinatorChange:ce,onNotToggleChange:Ie,outerClassName:Xt,parentDisabled:k,pathsMemo:Wt,previewRef:Y,removeGroup:at,ruleGroup:Se,shiftGroupUp:ue,shiftGroupDown:ve,toggleLockGroup:Oe,toggleMuteGroup:et,validationClassName:tt,validationResult:it}},GD=e=>{var t,r,o,n;return C.createElement("div",{"data-testid":e.testID,className:e.className},C.createElement("button",{type:"button",disabled:e.disabled||e.shiftUpDisabled,onClick:e.shiftUp,title:(t=e.titles)==null?void 0:t.shiftUp},(r=e.labels)==null?void 0:r.shiftUp),C.createElement("button",{type:"button",disabled:e.disabled||e.shiftDownDisabled,onClick:e.shiftDown,title:(o=e.titles)==null?void 0:o.shiftDown},(n=e.labels)==null?void 0:n.shiftDown))},zD=({name:e,disabled:t,checked:r,label:o,handleOnChange:n})=>{const a=C.useId();return C.createElement("label",{htmlFor:a},C.createElement("input",{id:a,type:"radio",value:e,disabled:t,checked:r,onChange:s=>n(s.target.value)}),o)},BD=e=>{const{operator:t,value:r,handleOnChange:o,title:n,className:a,type:s="text",inputType:l,values:c=[],listsAsArrays:d,fieldData:p,disabled:u,separator:f=null,testID:h,selectorComponent:b=e.schema.controls.valueSelector,parseNumbers:g,skipHook:y,valueSource:v,...S}=e,{valueAsArray:x,multiValueHandler:w,bigIntValueHandler:N,parseNumberMethod:k,valueListItemClassName:_,inputTypeCoerced:E}=UD(e);if(t==="null"||t==="notNull")return null;const D=(p==null?void 0:p.placeholder)??"";if((t==="between"||t==="notBetween")&&(s==="select"||s==="text")){const T=["from","to"].map((O,$)=>s==="text"?C.createElement("input",{key:O,type:E,placeholder:D,value:x[$]??"",className:_,disabled:u,onChange:V=>w(V.target.value,$)}):C.createElement(b,{key:O,...S,schema:e.schema,className:_,handleOnChange:V=>w(V,$),disabled:u,value:x[$]??Pt(c),options:c,listsAsArrays:d}));return C.createElement("span",{"data-testid":h,className:a,title:n},T[0],f,T[1])}switch(s){case"select":case"multiselect":return C.createElement(b,{...S,schema:e.schema,testID:h,className:a,title:n,handleOnChange:o,disabled:u,value:r,options:c,multiple:s==="multiselect",listsAsArrays:d});case"textarea":return C.createElement("textarea",{"data-testid":h,placeholder:D,value:r,title:n,className:a,disabled:u,onChange:T=>o(T.target.value)});case"switch":case"checkbox":return C.createElement("input",{"data-testid":h,type:"checkbox",className:a,title:n,onChange:T=>o(T.target.checked),checked:!!r,disabled:u});case"radio":return C.createElement("span",{"data-testid":h,className:a,title:n},c.map(T=>C.createElement(zD,{key:T.name,name:T.name,disabled:u,checked:r===T.name,handleOnChange:o,label:T.label})))}return l==="bigint"?C.createElement("input",{"data-testid":h,type:E,placeholder:D,value:`${r}`,title:n,className:a,disabled:u,onChange:T=>N(T.target.value)}):C.createElement("input",{"data-testid":h,type:E,placeholder:D,value:r,title:n,className:a,disabled:u,onChange:T=>o(Le(T.target.value,{parseNumbers:k}))})},UD=e=>{const{handleOnChange:t,inputType:r,operator:o,value:n,listsAsArrays:a,parseNumbers:s,values:l,type:c,skipHook:d,schema:{classNames:p,suppressStandardClassnames:u}}=e;P.useEffect(()=>{!d&&c!=="multiselect"&&!["between","notBetween","in","notIn"].includes(o)&&(Array.isArray(n)||r==="number"&&typeof n=="string"&&n.includes(","))&&t(Ee(n,{retainEmptyStrings:!0})[0]??"")},[t,r,o,d,c,n]);const f=P.useMemo(()=>Ee(n,{retainEmptyStrings:!0}),[n]),h=P.useMemo(()=>ad({parseNumbers:s,inputType:r}),[r,s]);return{valueAsArray:f,multiValueHandler:P.useCallback((b,g)=>{const y=Le(b,{parseNumbers:h}),v=g===0&&(o==="between"||o==="notBetween")&&(f.length<2||f[1]===void 0);if(f[g]===y&&!v){t(a?f:sa(f,","));return}const S=[...f];S[g]=y,v&&(S[1]=Pt(l)),t(a?S:sa(S,","))},[t,a,o,h,f,l]),bigIntValueHandler:P.useCallback(b=>{const g=Le(b,{parseNumbers:h,bigIntOnOverflow:!0});let y;try{y=BigInt(g)}catch{t(g);return}t(y)},[t,h]),parseNumberMethod:h,valueListItemClassName:Qe(u||_e.valueListItem,p==null?void 0:p.valueListItem),inputTypeCoerced:r==="bigint"||o==="in"||o==="notIn"?"text":r||"text"}},WD=e=>{const{multiple:t,onChange:r}=e;return P.useMemo(()=>t?o=>r(Array.from(o.target.selectedOptions).map(n=>n.value)):o=>r(o.target.value),[t,r])},HD=e=>Hm(e)?e.map(t=>C.createElement("optgroup",{key:t.label,label:t.label},t.options.map(r=>C.createElement("option",{key:r.name,value:r.name,disabled:r.disabled},r.label)))):Array.isArray(e)?e.map(t=>C.createElement("option",{key:t.name,value:t.name,disabled:t.disabled},t.label)):null,Sa=e=>{const{onChange:t,val:r}=jD(e),o=WD({multiple:e.multiple,onChange:t});return C.createElement("select",{"data-testid":e.testID,className:e.className,value:r,title:e.title,disabled:e.disabled,multiple:!!e.multiple,onChange:o},HD(e.options))},jD=e=>{const{handleOnChange:t,listsAsArrays:r=!1,multiple:o=!1,value:n}=e;return{onChange:P.useCallback(a=>{if(o){const s=Ee(a);t(r?s:sa(s,","))}else t(a)},[t,r,o]),val:P.useMemo(()=>o?Ee(n).map(String):n,[o,n])}},qD=({props:e})=>{const t=Og(e),r=t.schema.controls.ruleGroup,o=Yd;return C.createElement(o.Provider,{key:t.dndEnabledAttr,value:t.rqbContext},C.createElement("div",{role:"form",className:t.wrapperClassName,"data-dnd":t.dndEnabledAttr,"data-inlinecombinators":t.inlineCombinatorsAttr},C.createElement(r,{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:Fm,disabled:t.rootGroupDisabled,shiftUpDisabled:!0,shiftDownDisabled:!0,parentDisabled:t.queryDisabled,context:e.context})))},Ll=()=>null,YD=P.forwardRef(Ll),Fl={},QD=({finalize:e,...t})=>{var b,g,y,v,S,x,w,N,k,_,E,D,T,O,$,V,G,q,H,Y,J,W,R,we,Q,te,De,de,Se,re,me,ce,Ie,xe,be,ae,ue,ve,Oe,et,at,it,tt,$e,yt,Xt,Wt,I,F,K,j,Z,se,A,M,L,B,U,X,z,ee,ne,Ce,Fe,Ue,ye,We,ct,Jt,ko,Zt,pt,ir,kt,Ao,At,Rl,Ta,Da,$a,$n,Pa,Ma,yr,Oa,Xl,Jl,Zl,ei,Ia,ti,Ne,je,Je,Ye,qe,Mt,Ht,_o,Yr,To,nv,av,sv,lv,iv,cv,dv;const r=P.useContext(Yd),o=P.useMemo(()=>x_(t,r),[t,r,e]),n=e?r.enableDragAndDrop!==!1&&Mb(!1,t.enableDragAndDrop,r.enableDragAndDrop):t.enableDragAndDrop??r.enableDragAndDrop,a=P.useMemo(()=>y_(r.controlClassnames,t.controlClassnames),[r.controlClassnames,t.controlClassnames]),s=P.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,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.valid,a.value,a.valueDateTimeRelative,a.valueListItem,a.valueSelector,a.valueSource]),l=r.controlElements??Fl,c=t.controlElements??Fl,d=P.useCallback((Dr,La,Fa)=>{const Va=Dr==="dragHandle"?YD:Ll,ri=(Dr.endsWith("Action")&&c.actionElement?c.actionElement:void 0)??(Dr.endsWith("Selector")&&c.valueSelector?c.valueSelector:void 0),oi=(Dr.endsWith("Action")&&l.actionElement?l.actionElement:void 0)??(Dr.endsWith("Selector")&&l.valueSelector?l.valueSelector:void 0),Ga=La===null?Va:La??ri??(Fa===null?Va:Fa??oi);return Ga?{[Dr]:Ga}:{[Dr]:Vl[Dr]}},[l.actionElement,l.valueSelector,e,c.actionElement,c.valueSelector]),p=P.useMemo(()=>Object.assign({},d("addGroupAction",c.addGroupAction,l.addGroupAction),d("addRuleAction",c.addRuleAction,l.addRuleAction),d("cloneGroupAction",c.cloneGroupAction,l.cloneGroupAction),d("cloneRuleAction",c.cloneRuleAction,l.cloneRuleAction),d("combinatorSelector",c.combinatorSelector,l.combinatorSelector),d("dragHandle",c.dragHandle,l.dragHandle),d("fieldSelector",c.fieldSelector,l.fieldSelector),d("inlineCombinator",c.inlineCombinator,l.inlineCombinator),d("lockGroupAction",c.lockGroupAction,l.lockGroupAction),d("lockRuleAction",c.lockRuleAction,l.lockRuleAction),d("muteGroupAction",c.muteGroupAction,l.muteGroupAction),d("muteRuleAction",c.muteRuleAction,l.muteRuleAction),d("notToggle",c.notToggle,l.notToggle),d("operatorSelector",c.operatorSelector,l.operatorSelector),d("removeGroupAction",c.removeGroupAction,l.removeGroupAction),d("removeRuleAction",c.removeRuleAction,l.removeRuleAction),d("shiftActions",c.shiftActions,l.shiftActions),{valueEditor:c.valueEditor===null?Ll:c.valueEditor??(l.valueEditor===null?Ll:l.valueEditor)??Vl.valueEditor},d("valueSourceSelector",c.valueSourceSelector,l.valueSourceSelector),d("matchModeEditor",c.matchModeEditor,l.matchModeEditor),d("rule",c.rule,l.rule),d("ruleGroup",c.ruleGroup,l.ruleGroup),d("ruleGroupBodyElements",c.ruleGroupBodyElements,l.ruleGroupBodyElements),d("ruleGroupHeaderElements",c.ruleGroupHeaderElements,l.ruleGroupHeaderElements),{actionElement:c.actionElement??l.actionElement??Vl.actionElement},{valueSelector:c.valueSelector??l.valueSelector??Vl.valueSelector}),[l.actionElement,l.addGroupAction,l.addRuleAction,l.cloneGroupAction,l.cloneRuleAction,l.combinatorSelector,l.dragHandle,l.fieldSelector,l.inlineCombinator,l.lockGroupAction,l.lockRuleAction,l.muteGroupAction,l.muteRuleAction,l.matchModeEditor,l.notToggle,l.operatorSelector,l.removeGroupAction,l.removeRuleAction,l.rule,l.ruleGroup,l.ruleGroupBodyElements,l.ruleGroupHeaderElements,l.shiftActions,l.valueEditor,l.valueSelector,l.valueSourceSelector,d,e,c.actionElement,c.addGroupAction,c.addRuleAction,c.cloneGroupAction,c.cloneRuleAction,c.combinatorSelector,c.dragHandle,c.fieldSelector,c.inlineCombinator,c.lockGroupAction,c.lockRuleAction,c.muteGroupAction,c.muteRuleAction,c.matchModeEditor,c.notToggle,c.operatorSelector,c.removeGroupAction,c.removeRuleAction,c.rule,c.ruleGroup,c.ruleGroupBodyElements,c.ruleGroupHeaderElements,c.shiftActions,c.valueEditor,c.valueSelector,c.valueSourceSelector]),u=t.translations??Fl,f=r.translations??Fl,h=P.useMemo(()=>{var Dr,La,Fa,Va,ri,oi,Ga,uv,fv,pv,hv,mv,bv,gv,yv,vv,wv,xv,Cv,Sv,Nv,Ev,kv,Av,_v,Tv,Dv,$v,Pv,Mv,Ov,Iv,Lv,Fv,Vv,Gv,zv,Bv,Uv,Wv,Hv,jv,qv,Yv,Qv,Kv,Rv,Xv,Jv,Zv,e0,t0,r0,o0,n0,a0,s0,l0,i0,c0,d0,u0,f0,p0,h0,m0,b0,g0,y0,v0,w0,x0,C0,S0,N0,E0,k0,A0,_0,T0,D0,$0,P0,M0,O0,I0,L0,F0,V0,G0,z0,B0,U0,W0,H0,j0,q0,Y0,Q0,K0,R0,X0,J0,Z0,ew,tw,rw,ow;return Object.assign({},nt("addGroup",{label:[(Dr=u.addGroup)==null?void 0:Dr.label,(La=f.addGroup)==null?void 0:La.label],title:[(Fa=u.addGroup)==null?void 0:Fa.title,(Va=f.addGroup)==null?void 0:Va.title]},ot),nt("addRule",{label:[(ri=u.addRule)==null?void 0:ri.label,(oi=f.addRule)==null?void 0:oi.label],title:[(Ga=u.addRule)==null?void 0:Ga.title,(uv=f.addRule)==null?void 0:uv.title]},ot),nt("cloneRule",{label:[(fv=u.cloneRule)==null?void 0:fv.label,(pv=f.cloneRule)==null?void 0:pv.label],title:[(hv=u.cloneRule)==null?void 0:hv.title,(mv=f.cloneRule)==null?void 0:mv.title]},ot),nt("cloneRuleGroup",{label:[(bv=u.cloneRuleGroup)==null?void 0:bv.label,(gv=f.cloneRuleGroup)==null?void 0:gv.label],title:[(yv=u.cloneRuleGroup)==null?void 0:yv.title,(vv=f.cloneRuleGroup)==null?void 0:vv.title]},ot),nt("combinators",{title:[(wv=u.combinators)==null?void 0:wv.title,(xv=f.combinators)==null?void 0:xv.title]},ot),nt("dragHandle",{label:[(Cv=u.dragHandle)==null?void 0:Cv.label,(Sv=f.dragHandle)==null?void 0:Sv.label],title:[(Nv=u.dragHandle)==null?void 0:Nv.title,(Ev=f.dragHandle)==null?void 0:Ev.title]},ot),nt("fields",{placeholderGroupLabel:[(kv=u.fields)==null?void 0:kv.placeholderGroupLabel,(Av=f.fields)==null?void 0:Av.placeholderGroupLabel],placeholderLabel:[(_v=u.fields)==null?void 0:_v.placeholderLabel,(Tv=f.fields)==null?void 0:Tv.placeholderLabel],placeholderName:[(Dv=u.fields)==null?void 0:Dv.placeholderName,($v=f.fields)==null?void 0:$v.placeholderName],title:[(Pv=u.fields)==null?void 0:Pv.title,(Mv=f.fields)==null?void 0:Mv.title]},ot),nt("lockGroup",{label:[(Ov=u.lockGroup)==null?void 0:Ov.label,(Iv=f.lockGroup)==null?void 0:Iv.label],title:[(Lv=u.lockGroup)==null?void 0:Lv.title,(Fv=f.lockGroup)==null?void 0:Fv.title]},ot),nt("lockGroupDisabled",{label:[(Vv=u.lockGroupDisabled)==null?void 0:Vv.label,(Gv=f.lockGroupDisabled)==null?void 0:Gv.label],title:[(zv=u.lockGroupDisabled)==null?void 0:zv.title,(Bv=f.lockGroupDisabled)==null?void 0:Bv.title]},ot),nt("lockRule",{label:[(Uv=u.lockRule)==null?void 0:Uv.label,(Wv=f.lockRule)==null?void 0:Wv.label],title:[(Hv=u.lockRule)==null?void 0:Hv.title,(jv=f.lockRule)==null?void 0:jv.title]},ot),nt("lockRuleDisabled",{label:[(qv=u.lockRuleDisabled)==null?void 0:qv.label,(Yv=f.lockRuleDisabled)==null?void 0:Yv.label],title:[(Qv=u.lockRuleDisabled)==null?void 0:Qv.title,(Kv=f.lockRuleDisabled)==null?void 0:Kv.title]},ot),nt("muteGroup",{label:[(Rv=u.muteGroup)==null?void 0:Rv.label,(Xv=f.muteGroup)==null?void 0:Xv.label],title:[(Jv=u.muteGroup)==null?void 0:Jv.title,(Zv=f.muteGroup)==null?void 0:Zv.title]},ot),nt("unmuteGroup",{label:[(e0=u.unmuteGroup)==null?void 0:e0.label,(t0=f.unmuteGroup)==null?void 0:t0.label],title:[(r0=u.unmuteGroup)==null?void 0:r0.title,(o0=f.unmuteGroup)==null?void 0:o0.title]},ot),nt("muteRule",{label:[(n0=u.muteRule)==null?void 0:n0.label,(a0=f.muteRule)==null?void 0:a0.label],title:[(s0=u.muteRule)==null?void 0:s0.title,(l0=f.muteRule)==null?void 0:l0.title]},ot),nt("unmuteRule",{label:[(i0=u.unmuteRule)==null?void 0:i0.label,(c0=f.unmuteRule)==null?void 0:c0.label],title:[(d0=u.unmuteRule)==null?void 0:d0.title,(u0=f.unmuteRule)==null?void 0:u0.title]},ot),nt("notToggle",{label:[(f0=u.notToggle)==null?void 0:f0.label,(p0=f.notToggle)==null?void 0:p0.label],title:[(h0=u.notToggle)==null?void 0:h0.title,(m0=f.notToggle)==null?void 0:m0.title]},ot),nt("operators",{placeholderGroupLabel:[(b0=u.operators)==null?void 0:b0.placeholderGroupLabel,(g0=f.operators)==null?void 0:g0.placeholderGroupLabel],placeholderLabel:[(y0=u.operators)==null?void 0:y0.placeholderLabel,(v0=f.operators)==null?void 0:v0.placeholderLabel],placeholderName:[(w0=u.operators)==null?void 0:w0.placeholderName,(x0=f.operators)==null?void 0:x0.placeholderName],title:[(C0=u.operators)==null?void 0:C0.title,(S0=f.operators)==null?void 0:S0.title]},ot),nt("values",{placeholderGroupLabel:[(N0=u.values)==null?void 0:N0.placeholderGroupLabel,(E0=f.values)==null?void 0:E0.placeholderGroupLabel],placeholderLabel:[(k0=u.values)==null?void 0:k0.placeholderLabel,(A0=f.values)==null?void 0:A0.placeholderLabel],placeholderName:[(_0=u.values)==null?void 0:_0.placeholderName,(T0=f.values)==null?void 0:T0.placeholderName],title:[(D0=u.values)==null?void 0:D0.title,($0=f.values)==null?void 0:$0.title]},ot),nt("removeGroup",{label:[(P0=u.removeGroup)==null?void 0:P0.label,(M0=f.removeGroup)==null?void 0:M0.label],title:[(O0=u.removeGroup)==null?void 0:O0.title,(I0=f.removeGroup)==null?void 0:I0.title]},ot),nt("removeRule",{label:[(L0=u.removeRule)==null?void 0:L0.label,(F0=f.removeRule)==null?void 0:F0.label],title:[(V0=u.removeRule)==null?void 0:V0.title,(G0=f.removeRule)==null?void 0:G0.title]},ot),nt("shiftActionDown",{label:[(z0=u.shiftActionDown)==null?void 0:z0.label,(B0=f.shiftActionDown)==null?void 0:B0.label],title:[(U0=u.shiftActionDown)==null?void 0:U0.title,(W0=f.shiftActionDown)==null?void 0:W0.title]},ot),nt("shiftActionUp",{label:[(H0=u.shiftActionUp)==null?void 0:H0.label,(j0=f.shiftActionUp)==null?void 0:j0.label],title:[(q0=u.shiftActionUp)==null?void 0:q0.title,(Y0=f.shiftActionUp)==null?void 0:Y0.title]},ot),nt("matchMode",{title:[(Q0=u.matchMode)==null?void 0:Q0.title,(K0=f.matchMode)==null?void 0:K0.title]},ot),nt("matchThreshold",{title:[(R0=u.matchThreshold)==null?void 0:R0.title,(X0=f.matchThreshold)==null?void 0:X0.title],placeholderName:[(J0=u.matchThreshold)==null?void 0:J0.placeholderName,(Z0=f.matchThreshold)==null?void 0:Z0.placeholderName]},ot),nt("value",{title:[(ew=u.value)==null?void 0:ew.title,(tw=f.value)==null?void 0:tw.title]},ot),nt("valueSourceSelector",{title:[(rw=u.valueSourceSelector)==null?void 0:rw.title,(ow=f.valueSourceSelector)==null?void 0:ow.title]},ot))},[(b=f.addGroup)==null?void 0:b.label,(g=f.addGroup)==null?void 0:g.title,(y=f.addRule)==null?void 0:y.label,(v=f.addRule)==null?void 0:v.title,(S=f.cloneRule)==null?void 0:S.label,(x=f.cloneRule)==null?void 0:x.title,(w=f.cloneRuleGroup)==null?void 0:w.label,(N=f.cloneRuleGroup)==null?void 0:N.title,(k=f.combinators)==null?void 0:k.title,(_=f.dragHandle)==null?void 0:_.label,(E=f.dragHandle)==null?void 0:E.title,(D=f.fields)==null?void 0:D.placeholderGroupLabel,(T=f.fields)==null?void 0:T.placeholderLabel,(O=f.fields)==null?void 0:O.placeholderName,($=f.fields)==null?void 0:$.title,(V=f.lockGroup)==null?void 0:V.label,(G=f.lockGroup)==null?void 0:G.title,(q=f.lockGroupDisabled)==null?void 0:q.label,(H=f.lockGroupDisabled)==null?void 0:H.title,(Y=f.lockRule)==null?void 0:Y.label,(J=f.lockRule)==null?void 0:J.title,(W=f.lockRuleDisabled)==null?void 0:W.label,(R=f.lockRuleDisabled)==null?void 0:R.title,(we=f.muteGroup)==null?void 0:we.label,(Q=f.muteGroup)==null?void 0:Q.title,(te=f.unmuteGroup)==null?void 0:te.label,(De=f.unmuteGroup)==null?void 0:De.title,(de=f.muteRule)==null?void 0:de.label,(Se=f.muteRule)==null?void 0:Se.title,(re=f.unmuteRule)==null?void 0:re.label,(me=f.unmuteRule)==null?void 0:me.title,(ce=f.matchMode)==null?void 0:ce.title,(Ie=f.matchThreshold)==null?void 0:Ie.title,(xe=f.matchThreshold)==null?void 0:xe.placeholderName,(be=f.notToggle)==null?void 0:be.label,(ae=f.notToggle)==null?void 0:ae.title,(ue=f.operators)==null?void 0:ue.placeholderGroupLabel,(ve=f.operators)==null?void 0:ve.placeholderLabel,(Oe=f.operators)==null?void 0:Oe.placeholderName,(et=f.operators)==null?void 0:et.title,(at=f.removeGroup)==null?void 0:at.label,(it=f.removeGroup)==null?void 0:it.title,(tt=f.removeRule)==null?void 0:tt.label,($e=f.removeRule)==null?void 0:$e.title,(yt=f.shiftActionDown)==null?void 0:yt.label,(Xt=f.shiftActionDown)==null?void 0:Xt.title,(Wt=f.shiftActionUp)==null?void 0:Wt.label,(I=f.shiftActionUp)==null?void 0:I.title,(F=f.value)==null?void 0:F.title,(K=f.values)==null?void 0:K.placeholderGroupLabel,(j=f.values)==null?void 0:j.placeholderLabel,(Z=f.values)==null?void 0:Z.placeholderName,(se=f.values)==null?void 0:se.title,(A=f.valueSourceSelector)==null?void 0:A.title,e,(M=u.addGroup)==null?void 0:M.label,(L=u.addGroup)==null?void 0:L.title,(B=u.addRule)==null?void 0:B.label,(U=u.addRule)==null?void 0:U.title,(X=u.cloneRule)==null?void 0:X.label,(z=u.cloneRule)==null?void 0:z.title,(ee=u.cloneRuleGroup)==null?void 0:ee.label,(ne=u.cloneRuleGroup)==null?void 0:ne.title,(Ce=u.combinators)==null?void 0:Ce.title,(Fe=u.dragHandle)==null?void 0:Fe.label,(Ue=u.dragHandle)==null?void 0:Ue.title,(ye=u.fields)==null?void 0:ye.placeholderGroupLabel,(We=u.fields)==null?void 0:We.placeholderLabel,(ct=u.fields)==null?void 0:ct.placeholderName,(Jt=u.fields)==null?void 0:Jt.title,(ko=u.lockGroup)==null?void 0:ko.label,(Zt=u.lockGroup)==null?void 0:Zt.title,(pt=u.lockGroupDisabled)==null?void 0:pt.label,(ir=u.lockGroupDisabled)==null?void 0:ir.title,(kt=u.lockRule)==null?void 0:kt.label,(Ao=u.lockRule)==null?void 0:Ao.title,(At=u.lockRuleDisabled)==null?void 0:At.label,(Rl=u.lockRuleDisabled)==null?void 0:Rl.title,(Ta=u.muteGroup)==null?void 0:Ta.label,(Da=u.muteGroup)==null?void 0:Da.title,($a=u.unmuteGroup)==null?void 0:$a.label,($n=u.unmuteGroup)==null?void 0:$n.title,(Pa=u.muteRule)==null?void 0:Pa.label,(Ma=u.muteRule)==null?void 0:Ma.title,(yr=u.unmuteRule)==null?void 0:yr.label,(Oa=u.unmuteRule)==null?void 0:Oa.title,(Xl=u.matchMode)==null?void 0:Xl.title,(Jl=u.matchThreshold)==null?void 0:Jl.title,(Zl=u.matchThreshold)==null?void 0:Zl.placeholderName,(ei=u.notToggle)==null?void 0:ei.label,(Ia=u.notToggle)==null?void 0:Ia.title,(ti=u.operators)==null?void 0:ti.placeholderGroupLabel,(Ne=u.operators)==null?void 0:Ne.placeholderLabel,(je=u.operators)==null?void 0:je.placeholderName,(Je=u.operators)==null?void 0:Je.title,(Ye=u.removeGroup)==null?void 0:Ye.label,(qe=u.removeGroup)==null?void 0:qe.title,(Mt=u.removeRule)==null?void 0:Mt.label,(Ht=u.removeRule)==null?void 0:Ht.title,(_o=u.shiftActionDown)==null?void 0:_o.label,(Yr=u.shiftActionDown)==null?void 0:Yr.title,(To=u.shiftActionUp)==null?void 0:To.label,(nv=u.shiftActionUp)==null?void 0:nv.title,(av=u.value)==null?void 0:av.title,(sv=u.values)==null?void 0:sv.placeholderGroupLabel,(lv=u.values)==null?void 0:lv.placeholderLabel,(iv=u.values)==null?void 0:iv.placeholderName,(cv=u.values)==null?void 0:cv.title,(dv=u.valueSourceSelector)==null?void 0:dv.title]);return{...o,controlClassnames:s,controlElements:p,enableDragAndDrop:n,translations:h,initialQuery:t.initialQuery,qbId:t.qbId}},KD=({disabled:e,path:t,nestedArray:r,disabledPaths:o})=>{const n=r.length;return P.useMemo(()=>{const a=[];for(let s=0;s<n;s++){const l=[...t,s];a[s]={path:l,disabled:e||o.some(c=>Jo(l,c))}}return a},[e,t,n,o])};let Lg=!1;const Fg=(e,t)=>{process.env.NODE_ENV!=="production"&&!Lg&&e&&!t&&(console.error(Lt.errorEnabledDndWithoutReactDnD),Lg=!0)},bt=e=>P.useCallback((t,r)=>{t==null||t.preventDefault(),t==null||t.stopPropagation(),e(t,r)},[e]),RD={mode:"all"},XD=[{name:"",value:"",label:""}],JD=C.memo(function(t){const r=t$(t),{dndRef:o}=r,n=bt(r.cloneRule),a=bt(r.toggleLockRule),s=bt(r.toggleMuteRule),l=bt(r.removeRule),c=bt(r.shiftRuleUp),d=bt(r.shiftRuleDown),p=P.useMemo(()=>({cloneRule:n,toggleLockRule:a,toggleMuteRule:s,removeRule:l,shiftRuleUp:c,shiftRuleDown:d}),[n,l,d,c,a,s]);return C.createElement("div",{ref:o,"data-testid":Te.rule,"data-dragmonitorid":r.dragMonitorId,"data-dropmonitorid":r.dropMonitorId,className:r.outerClassName,"data-rule-id":r.id,"data-level":r.path.length,"data-path":JSON.stringify(r.path)},r.matchModes.length>0?C.createElement(e$,{...r,...p}):C.createElement(Vg,{...r,...p}))}),Vg=C.memo(function(t){const{dragRef:r,schema:{controls:{shiftActions:o,dragHandle:n,fieldSelector:a,matchModeEditor:s,operatorSelector:l,valueSourceSelector:c,valueEditor:d,cloneRuleAction:p,lockRuleAction:u,muteRuleAction:f,removeRuleAction:h,ruleGroupBodyElements:b,ruleGroupHeaderElements:g}},groupComponentsWrapper:y=C.Fragment}=t,v=P.useMemo(()=>({level:t.path.length,path:t.path,disabled:t.disabled,context:t.context,validation:t.validationResult,schema:t.schema,rule:t.rule}),[t.path,t.disabled,t.context,t.validationResult,t.schema,t.rule]),S=P.useMemo(()=>!(t.schema.fields.length===1&&Er(t.schema.fields[0])&&"value"in t.schema.fields[0]&&t.schema.fields[0].value===""),[t.schema.fields]),x=P.useMemo(()=>t.schema.showShiftActions?{shiftUp:t.translations.shiftActionUp.title,shiftDown:t.translations.shiftActionDown.title}:void 0,[t.schema.showShiftActions,t.translations]),w=P.useMemo(()=>t.schema.showShiftActions?{shiftUp:t.translations.shiftActionUp.label,shiftDown:t.translations.shiftActionDown.label}:void 0,[t.schema.showShiftActions,t.translations]);return C.createElement(C.Fragment,null,t.schema.showShiftActions&&C.createElement(o,{key:Te.shiftActions,...v,testID:Te.shiftActions,titles:x,labels:w,className:t.classNames.shiftActions,ruleOrGroup:t.rule,shiftUp:t.shiftRuleUp,shiftDown:t.shiftRuleDown,shiftUpDisabled:t.shiftUpDisabled,shiftDownDisabled:t.shiftDownDisabled}),t.schema.enableDragAndDrop&&C.createElement(n,{key:Te.dragHandle,...v,testID:Te.dragHandle,ref:r,title:t.translations.dragHandle.title,label:t.translations.dragHandle.label,className:t.classNames.dragHandle,dragHandleAttributes:t.dragHandleAttributes,ruleOrGroup:t.rule}),S&&C.createElement(a,{key:Te.fields,...v,testID:Te.fields,options:t.schema.fields,title:t.translations.fields.title,value:t.rule.field,operator:t.rule.operator,className:t.classNames.fields,handleOnChange:t.onChangeField}),(t.schema.autoSelectField||t.rule.field!==t.translations.fields.placeholderName)&&(t.subQuery?C.createElement(s,{key:Te.matchModeEditor,...v,testID:Te.matchModeEditor,field:t.rule.field,fieldData:t.fieldData,title:t.translations.matchMode.title,options:t.matchModes,thresholdPlaceholder:t.translations.matchThreshold.placeholderName,match:t.rule.match??RD,className:t.classNames.matchMode,classNames:t.classNames,handleOnChange:t.onChangeMatchMode}):C.createElement(C.Fragment,null,C.createElement(l,{key:Te.operators,...v,testID:Te.operators,field:t.rule.field,fieldData:t.fieldData,title:t.translations.operators.title,options:t.operators,value:t.rule.operator,className:t.classNames.operators,handleOnChange:t.onChangeOperator}),(t.schema.autoSelectOperator||t.rule.operator!==t.translations.operators.placeholderName)&&!t.hideValueControls&&C.createElement(C.Fragment,null,!["null","notnull"].includes(Ge(`${t.rule.operator}`))&&t.valueSources.length>1&&C.createElement(c,{key:Te.valueSourceSelector,...v,testID:Te.valueSourceSelector,field:t.rule.field,fieldData:t.fieldData,title:t.translations.valueSourceSelector.title,options:t.valueSourceOptions,value:t.rule.valueSource??"value",className:t.classNames.valueSource,handleOnChange:t.onChangeValueSource}),C.createElement(d,{key:Te.valueEditor,...v,testID:Te.valueEditor,field:t.rule.field,fieldData:t.fieldData,title:t.translations.value.title,operator:t.rule.operator,value:t.rule.value,valueSource:t.rule.valueSource??"value",type:t.valueEditorType,inputType:t.inputType,values:t.values,listsAsArrays:t.schema.listsAsArrays,parseNumbers:t.schema.parseNumbers,separator:t.valueEditorSeparator,className:t.classNames.value,handleOnChange:t.onChangeValue})))),t.subQuery&&C.createElement(y,{className:t.subQuery.classNames.header},C.createElement(g,t.subQuery)),t.schema.showCloneButtons&&C.createElement(p,{key:Te.cloneRule,...v,testID:Te.cloneRule,label:t.translations.cloneRule.label,title:t.translations.cloneRule.title,className:t.classNames.cloneRule,ruleOrGroup:t.rule,handleOnClick:t.cloneRule}),t.schema.showLockButtons&&C.createElement(u,{key:Te.lockRule,...v,testID:Te.lockRule,label:t.translations.lockRule.label,title:t.translations.lockRule.title,className:t.classNames.lockRule,ruleOrGroup:t.rule,handleOnClick:t.toggleLockRule,disabledTranslation:t.parentDisabled?void 0:t.translations.lockRuleDisabled}),t.schema.showMuteButtons&&C.createElement(f,{key:Te.muteRule,...v,testID:Te.muteRule,label:t.rule.muted?t.translations.unmuteRule.label:t.translations.muteRule.label,title:t.rule.muted?t.translations.unmuteRule.title:t.translations.muteRule.title,className:t.classNames.muteRule,ruleOrGroup:t.rule,handleOnClick:t.toggleMuteRule}),C.createElement(h,{key:Te.removeRule,...v,testID:Te.removeRule,label:t.translations.removeRule.label,title:t.translations.removeRule.title,className:t.classNames.removeRule,ruleOrGroup:t.rule,handleOnClick:t.removeRule}),t.subQuery&&C.createElement(y,{className:t.subQuery.classNames.body},C.createElement(b,t.subQuery)))}),ZD=e=>C.createElement("div",e),e$=C.memo(function(t){const r=P.useMemo(()=>t.schema.createRuleGroup(),[t.schema]),o=Og({...t.subQueryBuilderProps,enableDragAndDrop:!1,disabled:t.disabled,fields:t.subproperties.fields,enableMountQueryChange:!ke(t.rule.value)||!t.rule.value.id,query:ke(t.rule.value)?t.rule.value:r,onQueryChange:t.onChangeValue}),n=Ig({...o,ruleGroup:o.rootGroup,path:Fm,disabled:t.disabled,parentDisabled:o.queryDisabled,id:o.rootGroup.id,shiftUpDisabled:!0,shiftDownDisabled:!0}),a=bt(n.addRule),s=bt(n.addGroup),l=bt(n.cloneGroup),c=bt(n.toggleLockGroup),d=bt(n.removeGroup),p=bt(n.shiftGroupUp),u=bt(n.shiftGroupDown),f=P.useMemo(()=>({...n,addGroup:s,addRule:a,cloneGroup:l,removeGroup:d,shiftGroupDown:u,shiftGroupUp:p,toggleLockGroup:c}),[s,a,l,d,u,p,n,c]);return C.createElement(Vg,{...t,groupComponentsWrapper:t.groupComponentsWrapper??ZD,subQuery:f})}),t$=e=>{const{id:t,path:r,rule:o,schema:{classNames:n,fields:a,fieldMap:s,getParameters:l,getInputType:c,getMatchModes:d,getOperators:p,getSubQueryBuilderProps:u,getValueEditorType:f,getValueEditorSeparator:h,getValueSources:b,getValues:g,validationMap:y,enableDragAndDrop:v,getRuleClassname:S,suppressStandardClassnames:x},actions:{moveRule:w,onPropChange:N,onRuleRemove:k},disabled:_,parentDisabled:E,parentMuted:D,shiftUpDisabled:T,shiftDownDisabled:O,field:$,operator:V,value:G,valueSource:q,dropEffect:H="move",groupItems:Y=!1,dragMonitorId:J="",dropMonitorId:W="",dndRef:R=null,dragRef:we=null,isDragging:Q=!1,isOver:te=!1,dropNotAllowed:De=!1}=e;jd("rule",!o),Fg(v,!!(J||W||R||we));const de=!!E||!!_,Se=!!D||!!(o!=null&&o.muted),re=P.useMemo(()=>o??{id:t,field:$??"",operator:V??"",value:G,valueSource:q},[$,t,V,o,G,q]),me=P.useMemo(()=>({shiftActions:Qe(x||_e.shiftActions,n.shiftActions),dragHandle:Qe(x||_e.dragHandle,n.dragHandle),fields:Qe(x||_e.fields,n.valueSelector,n.fields),matchMode:Qe(x||_e.matchMode,n.valueSelector,n.matchMode),matchThreshold:Qe(x||_e.matchThreshold,n.valueSelector,n.matchThreshold),operators:Qe(x||_e.operators,n.valueSelector,n.operators),valueSource:Qe(x||_e.valueSource,n.valueSelector,n.valueSource),value:Qe(x||_e.value,n.value),cloneRule:Qe(x||_e.cloneRule,n.actionElement,n.cloneRule),lockRule:Qe(x||_e.lockRule,n.actionElement,n.lockRule),muteRule:Qe(x||_e.muteRule,n.actionElement,n.muteRule),removeRule:Qe(x||_e.removeRule,n.actionElement,n.removeRule),valueListItem:Qe(x||_e.valueListItem,n.valueListItem)}),[n.shiftActions,n.dragHandle,n.valueSelector,n.fields,n.matchMode,n.matchThreshold,n.operators,n.valueSource,n.value,n.actionElement,n.cloneRule,n.lockRule,n.muteRule,n.removeRule,n.valueListItem,x]),ce=P.useCallback(ye=>(We,ct)=>{de||N(ye,We,r,ct)},[de,N,r]),Ie=P.useMemo(()=>ce("field"),[ce]),xe=P.useMemo(()=>ce("operator"),[ce]),be=P.useMemo(()=>ce("match"),[ce]),ae=P.useMemo(()=>ce("valueSource"),[ce]),ue=P.useMemo(()=>ce("value"),[ce]),ve=P.useCallback((ye,We)=>{if(!de){const ct=[...mt(r),r.at(-1)+1];w(r,ct,!0,We)}},[de,w,r]),Oe=P.useCallback((ye,We)=>N("disabled",!de,r,We),[de,N,r]),et=P.useCallback((ye,We)=>N("muted",!re.muted,r,We),[re.muted,N,r]),at=P.useCallback((ye,We)=>{de||k(r)},[de,k,r]),it=P.useCallback((ye,We)=>{!de&&!T&&w(r,"up",ye==null?void 0:ye.altKey,We)},[de,w,r,T]),tt=P.useCallback((ye,We)=>{!de&&!O&&w(r,"down",ye==null?void 0:ye.altKey,We)},[de,w,r,O]),$e=P.useMemo(()=>(s==null?void 0:s[re.field])??{name:re.field,value:re.field,label:re.field},[s,re.field]),yt=P.useMemo(()=>$e.inputType??c(re.field,re.operator,{fieldData:$e}),[$e,c,re.field,re.operator]),Xt=P.useMemo(()=>d(re.field,{fieldData:$e}),[$e,d,re.field]),Wt=P.useMemo(()=>p(re.field,{fieldData:$e}),[$e,p,re.field]),I=P.useMemo(()=>Xe(Wt,re.operator),[Wt,re.operator]),F=I==null?void 0:I.arity,K=typeof F=="string"&&F==="unary"||typeof F=="number"&&F<2,j=P.useMemo(()=>{const ye=b(re.field,re.operator,{fieldData:$e});return re.valueSource&&!Xe(ye,re.valueSource)?[...ye,{name:re.valueSource,value:re.valueSource,label:re.valueSource}]:ye},[$e,b,re.field,re.operator,re.valueSource]),Z=P.useMemo(()=>j.map(({value:ye})=>ye),[j]),se=P.useMemo(()=>l(re.field,re.operator,{fieldData:$e}),[$e,l,re.field,re.operator]),A=P.useMemo(()=>se&&se.length>0?se:null,[se]),M=P.useMemo(()=>re.valueSource==="field"?"select":re.valueSource==="parameter"?A?Ge(re.operator)==="in"||Ge(re.operator)==="notin"?"multiselect":"select":"text":f(re.field,re.operator,{fieldData:$e}),[$e,f,A,re.field,re.operator,re.valueSource]),L=P.useMemo(()=>h(re.field,re.operator,{fieldData:$e}),[$e,h,re.field,re.operator]),B=P.useMemo(()=>{const ye=re.valueSource==="field"?Ym($e,a,re.operator):re.valueSource==="parameter"?A??[]:g(re.field,re.operator,{fieldData:$e});return al(ye)||xo(ye)?Ur(ye):ye},[$e,a,g,A,re.field,re.operator,re.valueSource]),U=P.useMemo(()=>u(re.field,{fieldData:$e}),[$e,u,re.field]),X=$g({translations:e.translations,fields:$e.subproperties??U.fields??XD,autoSelectField:e.schema.autoSelectField||!!$e.subproperties}),z=P.useMemo(()=>y[t??""]??(typeof $e.validator=="function"?$e.validator(re):null),[$e,t,re,y]),ee=P.useMemo(()=>Db(z),[z]),ne=($e==null?void 0:$e.className)??"",Ce=(I==null?void 0:I.className)??"",Fe=Xt.length>0,Ue=P.useMemo(()=>Qe(S(re,{fieldData:$e}),ne,Ce,x||_e.rule,n.rule,de&&n.disabled,Se&&n.muted,Q&&n.dndDragging,te&&n.dndOver,te&&H==="copy"&&n.dndCopy,te&&Y&&n.dndGroup,De&&n.dndDropNotAllowed,Fe&&n.hasSubQuery,x||{[_e.disabled]:de,[_e.muted]:Se,[_e.dndDragging]:Q,[_e.dndOver]:te,[_e.dndCopy]:te&&H==="copy",[_e.dndGroup]:te&&Y,[_e.dndDropNotAllowed]:De,[_e.hasSubQuery]:Fe},ee),[n.disabled,n.muted,n.dndCopy,n.dndDragging,n.dndGroup,n.dndOver,n.dndDropNotAllowed,n.hasSubQuery,n.rule,de,H,De,Se,ne,$e,S,Y,Fe,Q,te,Ce,re,x,ee]);return{...e,classNames:me,cloneRule:ve,disabled:de,dndRef:R,dragMonitorId:J,dragRef:we,dropMonitorId:W,fieldData:$e,generateOnChangeHandler:ce,onChangeField:Ie,onChangeMatchMode:be,onChangeOperator:xe,onChangeValueSource:ae,onChangeValue:ue,hideValueControls:K,inputType:yt,matchModes:Xt,muted:Se,operators:Wt,outerClassName:Ue,removeRule:at,rule:re,shiftRuleUp:it,shiftRuleDown:tt,subproperties:X,subQueryBuilderProps:U,toggleLockRule:Oe,toggleMuteRule:et,validationResult:z,valueEditorSeparator:L,valueEditorType:M,values:B,valueSourceOptions:j,valueSources:Z}},Vl={actionElement:Ar,addGroupAction:Ar,addRuleAction:Ar,cloneGroupAction:Ar,cloneRuleAction:Ar,combinatorSelector:Sa,dragHandle:uD,fieldSelector:Sa,inlineCombinator:fD,lockGroupAction:Ar,lockRuleAction:Ar,matchModeEditor:pD,muteGroupAction:Ar,muteRuleAction:Ar,notToggle:mD,operatorSelector:Sa,removeGroupAction:Ar,removeRuleAction:Ar,rule:JD,ruleGroup:LD,ruleGroupBodyElements:VD,ruleGroupHeaderElements:FD,shiftActions:GD,valueEditor:BD,valueSelector:Sa,valueSourceSelector:Sa};Pg();const r$=e=>C.createElement(sD,{context:Tg,store:Pg()},e.children),o$=e=>C.createElement(r$,null,C.createElement(qD,{props:e}));function Gg(e,t,r){var n,a;const o={visible:!0,required:((n=e.validation)==null?void 0:n.required)??!1,disabled:((a=e.properties)==null?void 0:a.disabled)??!1};return e.logic&&(o.visible=n$(e.logic,t,r),e.logic.requireWhen&&(o.required=Gl(e.logic.requireWhen,t,r)),e.logic.disableWhen&&(o.disabled=Gl(e.logic.disableWhen,t,r))),o}function n$(e,t,r){const{showWhen:o,hideWhen:n}=e;let a=!0;if(o&&o.rules&&o.rules.length>0&&(a=Gl(o,t,r)),n&&n.rules&&n.rules.length>0){const s=Gl(n,t,r);a=a&&!s}return a}function Gl(e,t,r){if(!e||!e.rules||e.rules.length===0)return!0;const{combinator:o,rules:n}=e,a=n.map(s=>{const l=r.find(p=>p.id===s.field||p.attributes.name===s.field),c=(l==null?void 0:l.attributes.name)||s.field,d=t[c];return a$(d,s.operator,s.value)});return o==="and"?a.every(s=>s):a.some(s=>s)}function a$(e,t,r){const o=e??"";switch(t){case"equals":case"=":case"==":return o===r;case"notEquals":case"!=":case"<>":return o!==r;case"contains":return String(o).toLowerCase().includes(String(r).toLowerCase());case"notContains":case"doesNotContain":return!String(o).toLowerCase().includes(String(r).toLowerCase());case"startsWith":case"beginsWith":return String(o).toLowerCase().startsWith(String(r).toLowerCase());case"endsWith":return String(o).toLowerCase().endsWith(String(r).toLowerCase());case"matches":try{return new RegExp(r,"i").test(String(o))}catch{return!1}case"isEmpty":case"null":return o===""||o===null||o===void 0||Array.isArray(o)&&o.length===0;case"isNotEmpty":case"notNull":return o!==""&&o!==null&&o!==void 0&&!(Array.isArray(o)&&o.length===0);case"greaterThan":case">":return Number(o)>Number(r);case"greaterThanOrEquals":case">=":return Number(o)>=Number(r);case"lessThan":case"<":return Number(o)<Number(r);case"lessThanOrEquals":case"<=":return Number(o)<=Number(r);case"between":if(Array.isArray(r)&&r.length===2){const n=Number(o);return n>=Number(r[0])&&n<=Number(r[1])}return!1;case"notBetween":if(Array.isArray(r)&&r.length===2){const n=Number(o);return n<Number(r[0])||n>Number(r[1])}return!0;case"in":return Array.isArray(r)?r.includes(o):!1;case"notIn":return Array.isArray(r)?!r.includes(o):!0;case"isTrue":return o===!0||o==="true"||o===1;case"isFalse":return o===!1||o==="false"||o===0;case"hasLength":return Array.isArray(o)&&o.length===Number(r);case"hasMinLength":return Array.isArray(o)&&o.length>=Number(r);case"hasMaxLength":return Array.isArray(o)&&o.length<=Number(r);case"includes":case"arrayContains":return Array.isArray(o)&&o.includes(r);case"notIncludes":case"arrayNotContains":return!Array.isArray(o)||!o.includes(r);default:return console.warn(`Unknown operator: ${t}`),!0}}function s$(e){const t=[{name:"isEmpty",label:"is empty"},{name:"isNotEmpty",label:"is not empty"}],r=[{name:"equals",label:"equals"},{name:"notEquals",label:"does not equal"}],o=[...r,{name:"contains",label:"contains"},{name:"notContains",label:"does not contain"},{name:"startsWith",label:"starts with"},{name:"endsWith",label:"ends with"},...t],n=[...r,{name:"greaterThan",label:"is greater than"},{name:"greaterThanOrEquals",label:"is greater than or equal to"},{name:"lessThan",label:"is less than"},{name:"lessThanOrEquals",label:"is less than or equal to"},{name:"between",label:"is between"},...t],a=[{name:"isTrue",label:"is checked"},{name:"isFalse",label:"is not checked"}],s=[...r,{name:"in",label:"is one of"},{name:"notIn",label:"is not one of"},...t],l=[{name:"includes",label:"includes"},{name:"notIncludes",label:"does not include"},{name:"hasLength",label:"has exactly"},{name:"hasMinLength",label:"has at least"},{name:"hasMaxLength",label:"has at most"},...t];switch(e){case"shortText":case"longText":case"multiLineInput":case"textEditor":case"email":case"phone":case"url":case"password":case"location":return o;case"number":case"slider":case"rangeSlider":return n;case"decisionBox":case"toggleSwitch":return a;case"singleChoice":case"dropdown":return s;case"multipleChoice":case"tags":return l;case"date":case"time":case"dateTime":case"dateRange":case"multipleDates":return[...r,{name:"greaterThan",label:"is after"},{name:"lessThan",label:"is before"},{name:"between",label:"is between"},...t];case"fileUpload":case"imageUpload":case"multiFileUpload":case"multiImageUpload":return t;case"singleChoiceMatrix":case"multipleChoiceMatrix":case"matrixTable":return t;default:return[...r,...t]}}function l$(e){switch(e){case"number":case"slider":case"rangeSlider":return"number";case"decisionBox":case"toggleSwitch":return"checkbox";case"date":case"dateRange":case"multipleDates":return"date";case"time":return"time";case"dateTime":return"datetime-local";case"singleChoice":case"dropdown":case"multipleChoice":case"tags":return"select";case"email":return"email";default:return"text"}}function i$(e){var t;if((t=e.config)!=null&&t.options&&Array.isArray(e.config.options))return e.config.options.map(r=>({name:r.value,label:r.label}))}function zg(e){return!e||!e.rules||e.rules.length===0?{combinator:"and",rules:[]}:{combinator:e.combinator,rules:e.rules.map(t=>({field:t.field,operator:t.operator,value:t.value}))}}function c$(e){return{combinator:e.combinator,rules:e.rules.filter(t=>"field"in t).map(t=>"field"in t?{field:t.field,operator:t.operator,value:t.value}:null).filter(Boolean)}}function Bg(e,t){return e.filter(r=>r.id!==t).filter(r=>!["divider","spacer","paragraph","image","link","formHeading","sectionHeading","subheading","submit"].includes(r.type)).map(r=>{var s;const o=s$(r.type),n=l$(r.type),a=i$(r);return{name:r.id,label:r.properties.label||r.attributes.name||`Field ${r.order+1}`,inputType:n,operators:o.map(l=>({name:l.name,label:l.label})),values:a==null?void 0:a.map(l=>({name:l.name,label:l.label})),defaultOperator:((s=o[0])==null?void 0:s.name)||"equals"}})}const d$={queryBuilder:"qb-lite",ruleGroup:"p-2 rounded border border-border",combinators:"px-2 py-1 border border-input rounded text-sm bg-background",addRule:"px-2 py-1 bg-primary text-primary-foreground rounded text-xs hover:bg-primary/90",addGroup:"px-2 py-1 bg-secondary text-secondary-foreground rounded text-xs hover:bg-secondary/80 ml-1",removeGroup:"px-2 py-1 bg-destructive/10 text-destructive rounded text-xs hover:bg-destructive/20",removeRule:"px-1 py-1 text-destructive hover:text-destructive/80",fields:"px-2 py-1 border border-input rounded text-sm min-w-[120px] bg-background",operators:"px-2 py-1 border border-input rounded text-sm mx-1 bg-background",value:"px-2 py-1 border border-input rounded text-sm bg-background"};function u$(e,t){const r=zg(e);if(r.rules.length===0)return"";const o={};for(const n of t)for(const a of Ur(n.operators??[]))if("options"in a)for(const s of a.options)o[s.name]=s.label;else o[a.name]=a.label;return f_(r,{format:"natural_language",fields:t,operatorMap:o,valueProcessor:n=>{const a=n.value;return a==null||a===""?"":Array.isArray(a)?a.join(", "):String(a)}})}var f$=Object.defineProperty,mr=(e,t)=>f$(e,"name",{value:t,configurable:!0}),Qd="Dialog",[Ug,MM]=ur(Qd),[p$,Wr]=Ug(Qd),h$=mr(e=>{const{__scopeDialog:t,children:r,open:o,defaultOpen:n,onOpenChange:a,modal:s=!0}=e,l=C.useRef(null),c=C.useRef(null),[d,p]=Cr({prop:o,defaultProp:n??!1,onChange:a,caller:Qd}),[u,f]=C.useState(0),[h,b]=C.useState(0);return i.jsx(p$,{scope:t,triggerRef:l,contentRef:c,contentId:xr(),titleId:xr(),descriptionId:xr(),titlePresent:u>0,descriptionPresent:h>0,setTitleCount:f,setDescriptionCount:b,open:d,onOpenChange:p,onOpenToggle:C.useCallback(()=>p(g=>!g),[p]),modal:s,children:r})},"Dialog"),Wg="DialogPortal",[m$,Hg]=Ug(Wg,{forceMount:void 0}),b$=mr(e=>{const{__scopeDialog:t,forceMount:r,children:o,container:n}=e,a=Wr(Wg,t);return i.jsx(m$,{scope:t,forceMount:r,children:C.Children.map(o,s=>i.jsx(ro,{present:r||a.open,children:i.jsx(tc,{asChild:!0,container:n,children:s})}))})},"DialogPortal"),Kd="DialogOverlay",jg=C.forwardRef(mr(function(t,r){const o=Hg(Kd,t.__scopeDialog),{forceMount:n=o.forceMount,...a}=t,s=Wr(Kd,t.__scopeDialog);return s.modal?i.jsx(ro,{present:n||s.open,children:i.jsx(y$,{...a,ref:r})}):null},"DialogOverlay")),g$=Kr("DialogOverlay.RemoveScroll"),y$=C.forwardRef(mr(function(t,r){const{__scopeDialog:o,...n}=t,a=Wr(Kd,o),s=Vf(),l=Re(r,s);return i.jsx(ic,{as:g$,allowPinchZoom:!0,shards:[a.contentRef],children:i.jsx(Be.div,{"data-state":Rd(a.open),...n,ref:l,style:{pointerEvents:"auto",...n.style}})})},"DialogOverlayImpl")),Na="DialogContent",qg=C.forwardRef(mr(function(t,r){const o=Hg(Na,t.__scopeDialog),{forceMount:n=o.forceMount,...a}=t,s=Wr(Na,t.__scopeDialog);return i.jsx(ro,{present:n||s.open,children:s.modal?i.jsx(v$,{...a,ref:r}):i.jsx(w$,{...a,ref:r})})},"DialogContent")),v$=C.forwardRef(mr(function(t,r){const o=Wr(Na,t.__scopeDialog),n=C.useRef(null),a=Re(r,o.contentRef,n);return C.useEffect(()=>{const s=n.current;if(s)return Vp(s)},[]),i.jsx(Yg,{...t,ref:a,trapFocus:o.open,disableOutsidePointerEvents:o.open,onCloseAutoFocus:Pe(t.onCloseAutoFocus,s=>{var l;s.preventDefault(),(l=o.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Pe(t.onPointerDownOutside,s=>{const l=s.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&s.preventDefault()}),onFocusOutside:Pe(t.onFocusOutside,s=>s.preventDefault())})},"DialogContentModal")),w$=C.forwardRef(mr(function(t,r){const o=Wr(Na,t.__scopeDialog),n=C.useRef(!1),a=C.useRef(!1);return i.jsx(Yg,{...t,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var l,c;(l=t.onCloseAutoFocus)==null||l.call(t,s),s.defaultPrevented||(n.current||(c=o.triggerRef.current)==null||c.focus(),s.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:s=>{var d,p;(d=t.onInteractOutside)==null||d.call(t,s),s.defaultPrevented||(n.current=!0,s.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=s.target;((p=o.triggerRef.current)==null?void 0:p.contains(l))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&a.current&&s.preventDefault()}})},"DialogContentNonModal")),Yg=C.forwardRef(mr(function(t,r){const{__scopeDialog:o,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:s,...l}=t,c=Wr(Na,o);return ls(),i.jsx(i.Fragment,{children:i.jsx(Uf,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:s,children:i.jsx(Mi,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionPresent?c.descriptionId:void 0,"aria-labelledby":c.titlePresent?c.titleId:void 0,"data-state":Rd(c.open),...l,ref:r,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})},"DialogContentImpl")),x$="DialogTitle",Qg=C.forwardRef(mr(function(t,r){const{__scopeDialog:o,...n}=t,a=Wr(x$,o),{setTitleCount:s}=a;return ut(()=>(s(l=>l+1),()=>s(l=>l-1)),[s]),i.jsx(Be.h2,{id:a.titleId,...n,ref:r})},"DialogTitle")),C$="DialogDescription",Kg=C.forwardRef(mr(function(t,r){const{__scopeDialog:o,...n}=t,a=Wr(C$,o),{setDescriptionCount:s}=a;return ut(()=>(s(l=>l+1),()=>s(l=>l-1)),[s]),i.jsx(Be.p,{id:a.descriptionId,...n,ref:r})},"DialogDescription")),S$="DialogClose",Rg=C.forwardRef(mr(function(t,r){const{__scopeDialog:o,...n}=t,a=Wr(S$,o);return i.jsx(Be.button,{type:"button",...n,ref:r,onClick:Pe(t.onClick,()=>a.onOpenChange(!1))})},"DialogClose"));function Rd(e){return e?"open":"closed"}mr(Rd,"getState");const N$=h$,E$=b$,k$=Rg,Xg=C.forwardRef(({className:e,...t},r)=>i.jsx(jg,{ref:r,className:m("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Xg.displayName=jg.displayName;const Jg=C.forwardRef(({className:e,children:t,...r},o)=>i.jsxs(E$,{children:[i.jsx(Xg,{}),i.jsxs(qg,{ref:o,className:m("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[t,i.jsxs(Rg,{className:m("absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"),children:[i.jsx(Hn,{className:m("h-4 w-4")}),i.jsx("span",{className:m("sr-only"),children:"Close"})]})]})]}));Jg.displayName=qg.displayName;const Zg=({className:e,...t})=>i.jsx("div",{className:m("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Zg.displayName="DialogHeader";const ey=({className:e,...t})=>i.jsx("div",{className:m("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});ey.displayName="DialogFooter";const ty=C.forwardRef(({className:e,...t},r)=>i.jsx(Qg,{ref:r,className:m("text-lg font-semibold leading-none tracking-tight",e),...t}));ty.displayName=Qg.displayName;const ry=C.forwardRef(({className:e,...t},r)=>i.jsx(Kg,{ref:r,className:m("text-sm text-muted-foreground",e),...t}));ry.displayName=Kg.displayName;const oy=[{key:"showWhen",label:"Show When",description:"This element will only be visible when these conditions are met."},{key:"hideWhen",label:"Hide When",description:"This element will be hidden when these conditions are met."},{key:"requireWhen",label:"Require When",description:"This element will be required when these conditions are met."},{key:"disableWhen",label:"Disable When",description:"This element will be disabled when these conditions are met."}],A$=({open:e,onOpenChange:t,element:r,elements:o,onUpdate:n})=>{const a=P.useMemo(()=>Bg(o,r.id),[o,r.id]),s=P.useCallback((l,c)=>{const d=c$(c),p={...r.logic,[l]:d.rules.length>0?d:void 0};n({logic:p})},[r.logic,n]);return i.jsx(N$,{open:e,onOpenChange:t,children:i.jsxs(Jg,{className:"max-w-3xl max-h-[85vh] flex flex-col gap-4",children:[i.jsxs(Zg,{children:[i.jsx(ty,{children:"Conditional Logic"}),i.jsx(ry,{children:"Configure when this element is shown, hidden, required, or disabled based on other fields in the form."})]}),i.jsxs(Bh,{defaultValue:"showWhen",className:"flex flex-col flex-1 min-h-0",children:[i.jsx(Tc,{className:"grid w-full grid-cols-4",children:oy.map(l=>{var d,p,u;const c=((u=(p=(d=r.logic)==null?void 0:d[l.key])==null?void 0:p.rules)==null?void 0:u.length)??0;return i.jsxs(Qn,{value:l.key,className:"text-xs",children:[l.label,c>0&&` (${c})`]},l.key)})}),oy.map(l=>{var c;return i.jsxs(Kn,{value:l.key,className:"flex-1 min-h-0 overflow-y-auto",children:[i.jsx("p",{className:m("text-xs text-muted-foreground mb-2"),children:l.description}),i.jsx("div",{className:m("query-builder-wrapper"),style:{"--rqb-background-color":"transparent"},children:i.jsx(o$,{fields:a,query:zg((c=r.logic)==null?void 0:c[l.key]),onQueryChange:d=>s(l.key,d),controlClassnames:d$})})]},l.key)})]}),i.jsx(ey,{children:i.jsx(k$,{asChild:!0,children:i.jsx(st,{children:"Done"})})})]})})},_$=({title:e,children:t,defaultOpen:r=!1,badge:o})=>{const[n,a]=P.useState(r);return i.jsxs(Yh,{open:n,onOpenChange:a,className:m("border border-border rounded-lg overflow-hidden"),children:[i.jsx(Qh,{asChild:!0,children:i.jsxs(st,{variant:"ghost",className:m("w-full flex items-center justify-between px-3 py-2 h-auto bg-muted/50 hover:bg-muted rounded-none"),children:[i.jsxs("span",{className:m("flex items-center gap-2 text-sm font-medium text-foreground"),children:[e,o&&i.jsx(vc,{variant:"secondary",className:m("text-xs"),children:o})]}),i.jsx(vn,{className:m("h-4 w-4 transition-transform",n&&"rotate-180")})]})}),i.jsx(Kh,{children:i.jsx("div",{className:m("p-3 bg-card"),children:t})})]})},zl=({title:e,description:t,rule:r,fields:o,defaultOpen:n=!1,badge:a})=>{const s=u$(r,o);return i.jsxs(_$,{title:e,defaultOpen:n,badge:a,children:[i.jsx("p",{className:m("text-xs text-muted-foreground mb-2"),children:t}),s?i.jsx("div",{className:m("rounded-md border border-border bg-muted/40 px-3 py-2 text-sm text-foreground"),children:s}):i.jsx("p",{className:m("text-sm text-muted-foreground/70"),children:"No conditions set"})]})},T$=({element:e,elements:t,onUpdate:r})=>{var d,p,u,f,h,b,g,y,v,S,x,w,N,k,_,E,D,T,O,$,V,G,q,H,Y,J,W,R,we,Q,te,De,de,Se,re,me,ce,Ie,xe,be,ae,ue,ve,Oe,et,at,it,tt;const[o,n]=P.useState(!1),a=P.useMemo(()=>Bg(t,e.id),[t,e.id]),s=P.useCallback(()=>{r({logic:void 0})},[r]),l=e.logic&&((((p=(d=e.logic.showWhen)==null?void 0:d.rules)==null?void 0:p.length)??0)>0||(((f=(u=e.logic.hideWhen)==null?void 0:u.rules)==null?void 0:f.length)??0)>0||(((b=(h=e.logic.requireWhen)==null?void 0:h.rules)==null?void 0:b.length)??0)>0||(((y=(g=e.logic.disableWhen)==null?void 0:g.rules)==null?void 0:y.length)??0)>0),c=(((x=(S=(v=e.logic)==null?void 0:v.showWhen)==null?void 0:S.rules)==null?void 0:x.length)??0)+(((k=(N=(w=e.logic)==null?void 0:w.hideWhen)==null?void 0:N.rules)==null?void 0:k.length)??0)+(((D=(E=(_=e.logic)==null?void 0:_.requireWhen)==null?void 0:E.rules)==null?void 0:D.length)??0)+((($=(O=(T=e.logic)==null?void 0:T.disableWhen)==null?void 0:O.rules)==null?void 0:$.length)??0);return a.length===0?i.jsxs("div",{className:m("text-sm text-muted-foreground p-4 text-center bg-muted/50 rounded-lg"),children:[i.jsx(vh,{className:m("w-8 h-8 mx-auto mb-2 text-muted-foreground/50")}),i.jsx("p",{children:"Add more fields to enable conditional logic."}),i.jsx("p",{className:m("text-xs mt-1"),children:"Logic rules require other fields to reference."})]}):i.jsxs("div",{className:m("space-y-3"),children:[i.jsxs("div",{className:m("space-y-1"),children:[i.jsxs("div",{className:m("flex items-center gap-1"),children:[l&&i.jsxs(st,{variant:"ghost",size:"sm",className:m("text-destructive hover:text-destructive hover:bg-destructive/10"),onClick:s,children:[i.jsx(mc,{className:m("h-3 w-3 mr-1")}),"Clear all"]}),i.jsxs(st,{variant:"outline",size:"sm",onClick:()=>n(!0),children:[i.jsx(wh,{className:m("h-3 w-3 mr-1")}),"Configure"]})]}),i.jsx("div",{className:m("text-sm text-muted-foreground"),children:l?i.jsxs("span",{className:m("flex items-center gap-2"),children:[i.jsx("span",{className:m("w-2 h-2 bg-primary rounded-full")}),c," rule",c!==1?"s":""," ","configured"]}):i.jsx("span",{className:m("text-muted-foreground/70"),children:"No logic configured"})})]}),i.jsx(zl,{title:"Show When",description:"This element will only be visible when these conditions are met.",rule:(V=e.logic)==null?void 0:V.showWhen,fields:a,defaultOpen:!!((H=(q=(G=e.logic)==null?void 0:G.showWhen)==null?void 0:q.rules)!=null&&H.length),badge:(W=(J=(Y=e.logic)==null?void 0:Y.showWhen)==null?void 0:J.rules)!=null&&W.length?String(e.logic.showWhen.rules.length):void 0}),i.jsx(zl,{title:"Hide When",description:"This element will be hidden when these conditions are met.",rule:(R=e.logic)==null?void 0:R.hideWhen,fields:a,defaultOpen:!!((te=(Q=(we=e.logic)==null?void 0:we.hideWhen)==null?void 0:Q.rules)!=null&&te.length),badge:(Se=(de=(De=e.logic)==null?void 0:De.hideWhen)==null?void 0:de.rules)!=null&&Se.length?String(e.logic.hideWhen.rules.length):void 0}),i.jsx(zl,{title:"Required When",description:"This element will be required when these conditions are met.",rule:(re=e.logic)==null?void 0:re.requireWhen,fields:a,defaultOpen:!!((Ie=(ce=(me=e.logic)==null?void 0:me.requireWhen)==null?void 0:ce.rules)!=null&&Ie.length),badge:(ae=(be=(xe=e.logic)==null?void 0:xe.requireWhen)==null?void 0:be.rules)!=null&&ae.length?String(e.logic.requireWhen.rules.length):void 0}),i.jsx(zl,{title:"Disabled When",description:"This element will be disabled when these conditions are met.",rule:(ue=e.logic)==null?void 0:ue.disableWhen,fields:a,defaultOpen:!!((et=(Oe=(ve=e.logic)==null?void 0:ve.disableWhen)==null?void 0:Oe.rules)!=null&&et.length),badge:(tt=(it=(at=e.logic)==null?void 0:at.disableWhen)==null?void 0:it.rules)!=null&&tt.length?String(e.logic.disableWhen.rules.length):void 0}),i.jsx(A$,{open:o,onOpenChange:n,element:e,elements:t,onUpdate:r})]})};var D$=Object.defineProperty,$$=(e,t)=>D$(e,"name",{value:t,configurable:!0}),P$=C.forwardRef($$(function(t,r){return i.jsx(Be.label,{...t,ref:r,onMouseDown:o=>{var a;o.target.closest("button, input, select, textarea")||((a=t.onMouseDown)==null||a.call(t,o),!o.defaultPrevented&&o.detail>1&&o.preventDefault())}})},"Label")),ny=P$;const M$=Is("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),br=C.forwardRef(({className:e,...t},r)=>i.jsx(ny,{ref:r,className:m(M$(),e),...t}));br.displayName=ny.displayName;const Xd=C.forwardRef(({className:e,...t},r)=>i.jsx("textarea",{className:m("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...t}));Xd.displayName="Textarea";var O$=Object.defineProperty,uo=(e,t)=>O$(e,"name",{value:t,configurable:!0}),Jd="Checkbox",[I$,OM]=ur(Jd),[L$,Zd]=I$(Jd);function ay(e){const{__scopeCheckbox:t,checked:r,children:o,defaultChecked:n,disabled:a,form:s,name:l,onCheckedChange:c,required:d,value:p="on",internal_do_not_use_render:u}=e,[f,h]=Cr({prop:r,defaultProp:n??!1,onChange:c,caller:Jd}),[b,g]=C.useState(null),[y,v]=C.useState(null),S=C.useRef(!1),[x,w]=C.useReducer(_=>_+1,0),N=b?!!s||!!b.closest("form"):!0,k={checked:f,disabled:a,setChecked:h,control:b,setControl:g,name:l,form:s,value:p,hasConsumerStoppedPropagationRef:S,userInteractionCount:x,onUserInteraction:w,required:d,defaultChecked:fo(n)?!1:n,isFormControl:N,bubbleInput:y,setBubbleInput:v};return i.jsx(L$,{scope:t,...k,children:ly(u)?u(k):o})}uo(ay,"CheckboxProvider");var F$="CheckboxTrigger",V$=C.forwardRef(uo(function({__scopeCheckbox:t,onKeyDown:r,onClick:o,...n},a){const{control:s,value:l,disabled:c,checked:d,required:p,setControl:u,setChecked:f,hasConsumerStoppedPropagationRef:h,onUserInteraction:b,isFormControl:g,bubbleInput:y}=Zd(F$,t),v=Re(a,u),S=C.useRef(d);return C.useEffect(()=>{const x=s==null?void 0:s.form;if(x){const w=uo(()=>f(S.current),"reset");return x.addEventListener("reset",w),()=>x.removeEventListener("reset",w)}},[s,f]),i.jsx(Be.button,{type:"button",role:"checkbox","aria-checked":fo(d)?"mixed":d,"aria-required":p,"data-state":eu(d),"data-disabled":c?"":void 0,disabled:c,value:l,...n,ref:v,onKeyDown:Pe(r,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Pe(o,x=>{b(),f(w=>fo(w)?!0:!w),y&&g&&(h.current=x.isPropagationStopped(),h.current||x.stopPropagation())})})},"CheckboxTrigger")),sy=C.forwardRef(uo(function(t,r){const{__scopeCheckbox:o,name:n,checked:a,defaultChecked:s,required:l,disabled:c,value:d,onCheckedChange:p,form:u,...f}=t;return i.jsx(ay,{__scopeCheckbox:o,checked:a,defaultChecked:s,disabled:c,required:l,onCheckedChange:p,name:n,form:u,value:d,internal_do_not_use_render:({isFormControl:h})=>i.jsxs(i.Fragment,{children:[i.jsx(V$,{...f,ref:r,__scopeCheckbox:o}),h&&i.jsx(U$,{__scopeCheckbox:o})]})})},"Checkbox")),G$="CheckboxIndicator",z$=C.forwardRef(uo(function(t,r){const{__scopeCheckbox:o,forceMount:n,...a}=t,s=Zd(G$,o);return i.jsx(ro,{present:n||fo(s.checked)||s.checked===!0,children:i.jsx(Be.span,{"data-state":eu(s.checked),"data-disabled":s.disabled?"":void 0,...a,ref:r,style:{pointerEvents:"none",...t.style}})})},"CheckboxIndicator")),B$="CheckboxBubbleInput",U$=C.forwardRef(uo(function({__scopeCheckbox:t,onClick:r,...o},n){const{control:a,hasConsumerStoppedPropagationRef:s,userInteractionCount:l,checked:c,defaultChecked:d,required:p,disabled:u,name:f,value:h,form:b,bubbleInput:g,setBubbleInput:y}=Zd(B$,t),v=Re(n,y),S=ec(a),x=C.useRef(!1),w=C.useRef(c),N=C.useRef(l);C.useEffect(()=>{const _=g;if(!_)return;const E=window.HTMLInputElement.prototype,T=Object.getOwnPropertyDescriptor(E,"checked").set,O=l!==N.current;N.current=l;const $=w.current!==c;w.current=c;const V=!(O&&s.current);if($&&T){x.current=!O;const G=new Event("click",{bubbles:V});_.indeterminate=fo(c),T.call(_,fo(c)?!1:c),_.dispatchEvent(G),x.current=!1}},[g,c,s,l]);const k=C.useRef(fo(c)?!1:c);return i.jsx(Be.input,{type:"checkbox","aria-hidden":!0,defaultChecked:d??k.current,required:p,disabled:u,name:f,value:h,form:b,...o,tabIndex:-1,ref:v,onClick:Pe(r,_=>{x.current&&_.stopPropagation()}),style:{...o.style,...S,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"CheckboxBubbleInput"));function ly(e){return typeof e=="function"}uo(ly,"isFunction");function fo(e){return e==="indeterminate"}uo(fo,"isIndeterminate");function eu(e){return fo(e)?"indeterminate":e?"checked":"unchecked"}uo(eu,"getState");const tu=C.forwardRef(({className:e,...t},r)=>i.jsx(sy,{ref:r,className:m("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:i.jsx(z$,{className:m("grid place-content-center text-current"),children:i.jsx(bh,{className:m("h-4 w-4")})})}));tu.displayName=sy.displayName;var W$=Object.defineProperty,sr=(e,t)=>W$(e,"name",{value:t,configurable:!0}),Hr="Accordion",H$=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[ru,j$,q$]=ns(Hr),[Bl,IM]=ur(Hr,[q$,Uh]),ou=Uh(),Y$=C.forwardRef(sr(function(t,r){const{type:o,...n}=t,a=n,s=n;return i.jsx(ru.Provider,{scope:t.__scopeAccordion,children:o==="multiple"?i.jsx(X$,{...s,ref:r}):i.jsx(R$,{...a,ref:r})})},"Accordion")),[iy,Q$]=Bl(Hr),[cy,K$]=Bl(Hr,{collapsible:!1}),R$=C.forwardRef(sr(function(t,r){const{value:o,defaultValue:n,onValueChange:a=sr(()=>{},"onValueChange"),collapsible:s=!1,...l}=t,[c,d]=Cr({prop:o,defaultProp:n??"",onChange:a,caller:Hr});return i.jsx(iy,{scope:t.__scopeAccordion,value:C.useMemo(()=>c?[c]:[],[c]),onItemOpen:d,onItemClose:C.useCallback(()=>s&&d(""),[s,d]),children:i.jsx(cy,{scope:t.__scopeAccordion,collapsible:s,children:i.jsx(dy,{...l,ref:r})})})},"AccordionImplSingle")),X$=C.forwardRef(sr(function(t,r){const{value:o,defaultValue:n,onValueChange:a=sr(()=>{},"onValueChange"),...s}=t,[l,c]=Cr({prop:o,defaultProp:n??[],onChange:a,caller:Hr}),d=C.useCallback(u=>c((f=[])=>[...f,u]),[c]),p=C.useCallback(u=>c((f=[])=>f.filter(h=>h!==u)),[c]);return i.jsx(iy,{scope:t.__scopeAccordion,value:l,onItemOpen:d,onItemClose:p,children:i.jsx(cy,{scope:t.__scopeAccordion,collapsible:!0,children:i.jsx(dy,{...s,ref:r})})})},"AccordionImplMultiple")),[J$,Ul]=Bl(Hr),dy=C.forwardRef(sr(function(t,r){const{__scopeAccordion:o,disabled:n,dir:a,orientation:s="vertical",...l}=t,c=C.useRef(null),d=Re(c,r),p=j$(o),f=Gn(a)==="ltr",h=Pe(t.onKeyDown,b=>{var D;if(!H$.includes(b.key))return;const g=b.target,y=p().filter(T=>{var O;return!((O=T.ref.current)!=null&&O.disabled)}),v=y.findIndex(T=>T.ref.current===g),S=y.length;if(v===-1)return;b.preventDefault();let x=v;const w=0,N=S-1,k=sr(()=>{x=v+1,x>N&&(x=w)},"moveNext"),_=sr(()=>{x=v-1,x<w&&(x=N)},"movePrev");switch(b.key){case"Home":x=w;break;case"End":x=N;break;case"ArrowRight":s==="horizontal"&&(f?k():_());break;case"ArrowDown":s==="vertical"&&k();break;case"ArrowLeft":s==="horizontal"&&(f?_():k());break;case"ArrowUp":s==="vertical"&&_();break}const E=x%S;(D=y[E].ref.current)==null||D.focus()});return i.jsx(J$,{scope:o,disabled:n,direction:a,orientation:s,children:i.jsx(ru.Slot,{scope:o,children:i.jsx(Be.div,{...l,"data-orientation":s,ref:d,onKeyDown:n?void 0:h})})})},"AccordionImpl")),nu="AccordionItem",[Z$,au]=Bl(nu),eP=C.forwardRef(sr(function(t,r){const{__scopeAccordion:o,value:n,...a}=t,s=Ul(nu,o),l=Q$(nu,o),c=ou(o),d=xr(),p=n&&l.value.includes(n)||!1,u=s.disabled||t.disabled;return i.jsx(Z$,{scope:o,open:p,disabled:u,triggerId:d,children:i.jsx(qh,{"data-orientation":s.orientation,"data-state":su(p),...c,...a,ref:r,disabled:u,open:p,onOpenChange:f=>{f?l.onItemOpen(n):l.onItemClose(n)}})})},"AccordionItem")),tP="AccordionHeader",rP=C.forwardRef(sr(function(t,r){const{__scopeAccordion:o,...n}=t,a=Ul(Hr,o),s=au(tP,o);return i.jsx(Be.h3,{"data-orientation":a.orientation,"data-state":su(s.open),"data-disabled":s.disabled?"":void 0,...n,ref:r})},"AccordionHeader")),uy="AccordionTrigger",oP=C.forwardRef(sr(function(t,r){const{__scopeAccordion:o,...n}=t,a=Ul(Hr,o),s=au(uy,o),l=K$(uy,o),c=ou(o);return i.jsx(ru.ItemSlot,{scope:o,children:i.jsx(HE,{"aria-disabled":s.open&&!l.collapsible||void 0,"data-orientation":a.orientation,id:s.triggerId,...c,...n,ref:r})})},"AccordionTrigger")),nP="AccordionContent",aP=C.forwardRef(sr(function(t,r){const{__scopeAccordion:o,...n}=t,a=Ul(Hr,o),s=au(nP,o),l=ou(o);return i.jsx(jE,{role:"region","aria-labelledby":s.triggerId,"data-orientation":a.orientation,...l,...n,ref:r,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...t.style}})},"AccordionContent"));function su(e){return e?"open":"closed"}sr(su,"getState");var sP=Y$,lP=eP,iP=rP,fy=oP,py=aP;const hy=sP,lu=C.forwardRef(({className:e,...t},r)=>i.jsx(lP,{ref:r,className:m("border-b",e),...t}));lu.displayName="AccordionItem";const iu=C.forwardRef(({className:e,children:t,...r},o)=>i.jsx(iP,{className:m("flex"),children:i.jsxs(fy,{ref:o,className:m("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",e),...r,children:[t,i.jsx(vn,{className:m("h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200")})]})}));iu.displayName=fy.displayName;const cu=C.forwardRef(({className:e,children:t,...r},o)=>i.jsx(py,{ref:o,className:m("overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"),...r,children:i.jsx("div",{className:m("pb-4 pt-0",e),children:t})}));cu.displayName=py.displayName;function du(e,t,r){var o,n,a,s;switch(t){case"properties":return(o=e.properties)==null?void 0:o[r];case"config":return(n=e.config)==null?void 0:n[r];case"layout":return(a=e.layout)==null?void 0:a[r];case"validation":return(s=e.validation)==null?void 0:s[r];default:return}}function cP(e,t,r,o){switch(e){case"properties":return{properties:{...t.properties,[r]:o}};case"config":return{config:{...t.config,[r]:o}};case"layout":return{layout:{...t.layout,[r]:o}};case"validation":return{validation:{...t.validation,[r]:o}};default:return{}}}function dP(e,t,r){const{field:o,value:n}=r;if(o.includes(".")){const[s,...l]=o.split("."),c=l.join(".");return du(e,s,c)===n}return du(e,t.section,o)===n}const my=({field:e,element:t,onUpdate:r})=>{var a;const o=du(t,e.section,e.key)??e.defaultValue,n=s=>{r(cP(e.section,t,e.key,s))};switch(e.type){case"text":case"url":case"color":return i.jsxs("div",{className:m("space-y-1.5"),children:[i.jsx(br,{className:m("text-xs font-medium text-muted-foreground"),children:e.label}),i.jsx(fr,{type:e.type==="color"?"color":e.type==="url"?"url":"text",value:o??"",onChange:s=>n(s.target.value),placeholder:e.placeholder}),e.description&&i.jsx("p",{className:m("text-[11px] text-muted-foreground"),children:e.description})]});case"textarea":return i.jsxs("div",{className:m("space-y-1.5"),children:[i.jsx(br,{className:m("text-xs font-medium text-muted-foreground"),children:e.label}),i.jsx(Xd,{value:o??"",onChange:s=>n(s.target.value),placeholder:e.placeholder,rows:e.rows??3}),e.description&&i.jsx("p",{className:m("text-[11px] text-muted-foreground"),children:e.description})]});case"number":return i.jsxs("div",{className:m("space-y-1.5"),children:[i.jsx(br,{className:m("text-xs font-medium text-muted-foreground"),children:e.label}),i.jsx(fr,{type:"number",value:o??"",onChange:s=>{const l=s.target.value;n(l?Number.isInteger(e.min)||Number.isInteger(e.max)?parseInt(l,10):parseFloat(l):void 0)},placeholder:e.placeholder,min:e.min,max:e.max}),e.description&&i.jsx("p",{className:m("text-[11px] text-muted-foreground"),children:e.description})]});case"checkbox":return i.jsxs("div",{className:m("flex items-start space-x-2"),children:[i.jsx(tu,{id:`ds-${e.section}-${e.key}`,checked:!!o,onCheckedChange:s=>n(!!s)}),i.jsxs("div",{className:m("space-y-0.5 leading-none"),children:[i.jsx(br,{htmlFor:`ds-${e.section}-${e.key}`,className:m("text-xs font-medium text-foreground cursor-pointer"),children:e.label}),e.description&&i.jsx("p",{className:m("text-[11px] text-muted-foreground"),children:e.description})]})]});case"select":return i.jsxs("div",{className:m("space-y-1.5"),children:[i.jsx(br,{className:m("text-xs font-medium text-muted-foreground"),children:e.label}),i.jsxs($s,{value:o!=null?String(o):"",onValueChange:s=>{var c;const l=(c=e.options)==null?void 0:c.find(d=>typeof d.value=="number"&&String(d.value)===s);n(l?l.value:s)},children:[i.jsx(jn,{children:i.jsx(Ps,{placeholder:e.placeholder||"Select..."})}),i.jsx(qn,{children:(a=e.options)==null?void 0:a.map(s=>i.jsx(Uo,{value:String(s.value),children:s.label},String(s.value)))})]}),e.description&&i.jsx("p",{className:m("text-[11px] text-muted-foreground"),children:e.description})]});default:return null}},uP=({title:e,icon:t,defaultOpen:r=!0,children:o})=>i.jsx(hy,{type:"single",collapsible:!0,defaultValue:r?"item":void 0,children:i.jsxs(lu,{value:"item",className:m("border-b border-border"),children:[i.jsx(iu,{className:m("px-4 py-3 hover:bg-muted/50 hover:no-underline"),children:i.jsxs("span",{className:m("text-sm font-medium text-foreground flex items-center gap-2"),children:[t&&i.jsx("span",{children:t}),e]})}),i.jsx(cu,{className:m("px-4 pb-4 mb-4"),children:i.jsx("div",{className:m("space-y-4"),children:o})})]})}),fP=({element:e,schema:t,onUpdate:r})=>{const o=t.fields.filter(c=>c.showWhen?dP(e,c,c.showWhen):!0),n=[];let a=[];const s=()=>{a.length>0&&(n.push(a),a=[])};for(const c of o)c.colSpan===1?(a.push(c),a.length===2&&s()):(s(),n.push([c]));s();const{configSection:l}=t;return i.jsx(uP,{title:(l==null?void 0:l.title)??"Settings",icon:l==null?void 0:l.icon,defaultOpen:!1,children:n.map((c,d)=>{if(!c.every(u=>u.colSpan===1)){const u=c[0];return i.jsx(my,{field:u,element:e,onUpdate:r},`${u.section}.${u.key}`)}return i.jsx("div",{className:m("grid grid-cols-2 gap-2"),children:c.map(u=>i.jsx(my,{field:u,element:e,onUpdate:r},`${u.section}.${u.key}`))},`row-${d}`)})})},No=({title:e,children:t,defaultOpen:r=!0,icon:o})=>i.jsx(hy,{type:"single",collapsible:!0,defaultValue:r?"item":void 0,children:i.jsxs(lu,{value:"item",className:m("border-b border-border"),children:[i.jsx(iu,{className:m("px-4 py-3 hover:bg-muted/50 hover:no-underline"),children:i.jsxs("span",{className:m("text-sm font-medium text-foreground flex items-center gap-2"),children:[o&&i.jsx("span",{children:o}),e]})}),i.jsx(cu,{className:m("px-4 pb-4 mb-4"),children:i.jsx("div",{className:m("space-y-4"),children:t})})]})}),rt=({label:e,value:t,onChange:r,type:o="text",placeholder:n,rows:a=3,min:s,max:l,step:c,helpText:d})=>i.jsxs("div",{className:m("space-y-1.5"),children:[i.jsx(br,{className:m("text-sm font-medium"),children:e}),o==="textarea"?i.jsx(Xd,{value:t??"",onChange:p=>r(p.target.value),placeholder:n,rows:a,className:m("resize-none")}):o==="color"?i.jsxs("div",{className:m("flex gap-2"),children:[i.jsx("input",{type:"color",value:(t==null?void 0:t.toString())||"#000000",onChange:p=>r(p.target.value),className:m("w-10 h-9 border border-input rounded-md cursor-pointer")}),i.jsx(fr,{type:"text",value:t??"",onChange:p=>r(p.target.value),placeholder:n||"#000000",className:m("flex-1")})]}):i.jsx(fr,{type:o,value:t??"",onChange:p=>r(p.target.value),placeholder:n,min:s,max:l,step:c}),d&&i.jsx("p",{className:m("text-xs text-muted-foreground"),children:d})]}),by=({label:e,checked:t,onChange:r,description:o})=>i.jsxs("div",{className:m("flex items-start gap-3"),children:[i.jsx(tu,{id:e,checked:t||!1,onCheckedChange:n=>r(n===!0),className:m("mt-0.5")}),i.jsxs("div",{className:m("grid gap-0.5 leading-none"),children:[i.jsx(br,{htmlFor:e,className:m("text-sm font-medium cursor-pointer"),children:e}),o&&i.jsx("p",{className:m("text-xs text-muted-foreground"),children:o})]})]}),uu=({label:e,value:t,onChange:r,options:o,helpText:n})=>i.jsxs("div",{className:m("space-y-1.5"),children:[i.jsx(br,{className:m("text-sm font-medium"),children:e}),i.jsxs($s,{value:(t==null?void 0:t.toString())??"",onValueChange:r,children:[i.jsx(jn,{className:m("w-full"),children:i.jsx(Ps,{placeholder:"Select..."})}),i.jsx(qn,{children:o.map(a=>i.jsx(Uo,{value:a.value,children:a.label},a.value))})]}),n&&i.jsx("p",{className:m("text-xs text-muted-foreground"),children:n})]}),pP=({options:e,onChange:t})=>{const r=(s,l,c)=>{const d=[...e];if(d[s]={...d[s],[l]:c},l==="label"){const p=d[s].value,u=e[s].label;(!p||p===mi(u))&&(d[s].value=mi(c))}t(d)},o=()=>{const s=e.length+1;t([...e,{label:`Option ${s}`,value:`option${s}`}])},n=s=>{e.length>1&&t(e.filter((l,c)=>c!==s))},a=(s,l)=>{const c=l==="up"?s-1:s+1;if(c<0||c>=e.length)return;const d=[...e];[d[s],d[c]]=[d[c],d[s]],t(d)};return i.jsxs("div",{className:m("space-y-2"),children:[i.jsx(br,{className:m("text-sm font-medium"),children:"Options"}),i.jsx("div",{className:m("space-y-2"),children:e.map((s,l)=>i.jsxs("div",{className:m("flex items-center gap-1"),children:[i.jsxs("div",{className:m("flex flex-col gap-0.5"),children:[i.jsx(st,{variant:"ghost",size:"icon",className:m("h-5 w-5"),onClick:()=>a(l,"up"),disabled:l===0,children:i.jsx(gh,{className:m("h-3 w-3")})}),i.jsx(st,{variant:"ghost",size:"icon",className:m("h-5 w-5"),onClick:()=>a(l,"down"),disabled:l===e.length-1,children:i.jsx(vn,{className:m("h-3 w-3")})})]}),i.jsx(fr,{type:"text",value:s.label,onChange:c=>r(l,"label",c.target.value),placeholder:"Label",className:m("flex-1 h-8")}),i.jsx(fr,{type:"text",value:s.value,onChange:c=>r(l,"value",c.target.value),placeholder:"Value",className:m("w-20 h-8 text-muted-foreground")}),i.jsx(Vs,{children:i.jsxs(Fr,{children:[i.jsx(Vr,{asChild:!0,children:i.jsx(st,{variant:"ghost",size:"icon",className:m("h-8 w-8"),onClick:()=>n(l),disabled:e.length<=1,children:i.jsx(Hn,{className:m("h-4 w-4")})})}),i.jsx(Nr,{children:"Remove option"})]})})]},l))}),i.jsxs(st,{variant:"ghost",size:"sm",className:m("text-primary"),onClick:o,children:[i.jsx(hc,{className:m("h-4 w-4 mr-1")}),"Add option"]})]})},hP=({rows:e,columns:t,onRowsChange:r,onColumnsChange:o,showColumnType:n=!1})=>{const a=()=>{const u=`row${e.length+1}`;r([...e,{id:u,label:`Row ${e.length+1}`}])},s=u=>{e.length>1&&r(e.filter((f,h)=>h!==u))},l=(u,f,h)=>{const b=[...e];b[u]={...b[u],[f]:h},r(b)},c=()=>{const u=`col${t.length+1}`;o([...t,{id:u,label:`Column ${t.length+1}`,type:"text"}])},d=u=>{t.length>1&&o(t.filter((f,h)=>h!==u))},p=(u,f,h)=>{const b=[...t];b[u]={...b[u],[f]:h},o(b)};return i.jsxs("div",{className:m("space-y-4"),children:[i.jsxs("div",{className:m("space-y-2"),children:[i.jsx(br,{className:m("text-sm font-medium"),children:"Rows"}),i.jsx("div",{className:m("space-y-2"),children:e.map((u,f)=>i.jsxs("div",{className:m("flex items-center gap-2"),children:[i.jsx(fr,{type:"text",value:u.id,onChange:h=>l(f,"id",h.target.value),placeholder:"Row ID",className:m("w-24 h-8 font-mono text-xs")}),i.jsx(fr,{type:"text",value:u.label,onChange:h=>l(f,"label",h.target.value),placeholder:"Row label",className:m("flex-1 h-8")}),i.jsx(st,{variant:"ghost",size:"icon",className:m("h-8 w-8"),onClick:()=>s(f),disabled:e.length<=1,children:i.jsx(Hn,{className:m("h-4 w-4")})})]},f))}),i.jsxs(st,{variant:"ghost",size:"sm",className:m("text-primary"),onClick:a,children:[i.jsx(hc,{className:m("h-4 w-4 mr-1")}),"Add row"]})]}),i.jsxs("div",{className:m("space-y-2"),children:[i.jsx(br,{className:m("text-sm font-medium"),children:"Columns"}),i.jsx("div",{className:m("space-y-2"),children:t.map((u,f)=>i.jsxs("div",{className:m("flex items-center gap-2"),children:[i.jsx(fr,{type:"text",value:u.id,onChange:h=>p(f,"id",h.target.value),placeholder:"Column ID",className:m("w-24 h-8 font-mono text-xs")}),i.jsx(fr,{type:"text",value:u.label,onChange:h=>p(f,"label",h.target.value),placeholder:"Column label",className:m("flex-1 h-8")}),n&&i.jsxs($s,{value:u.type||"text",onValueChange:h=>p(f,"type",h),children:[i.jsx(jn,{className:m("w-24 h-8"),children:i.jsx(Ps,{})}),i.jsxs(qn,{children:[i.jsx(Uo,{value:"text",children:"Text"}),i.jsx(Uo,{value:"number",children:"Number"}),i.jsx(Uo,{value:"dropdown",children:"Dropdown"})]})]}),i.jsx(st,{variant:"ghost",size:"icon",className:m("h-8 w-8"),onClick:()=>d(f),disabled:t.length<=1,children:i.jsx(Hn,{className:m("h-4 w-4")})})]},f))}),i.jsxs(st,{variant:"ghost",size:"sm",className:m("text-primary"),onClick:c,children:[i.jsx(hc,{className:m("h-4 w-4 mr-1")}),"Add column"]})]})]})},mP=({element:e,onUpdate:t})=>{const r=(c,d)=>{t({properties:{...e.properties,[c]:d}})},o=["shortText","longText","multiLineInput","textEditor","number","email","phone","url","location","password","dropdown","tags","date","time","dateTime","multipleDates","dateRange"].includes(e.type),n=!["divider","spacer","paragraph","image","link"].includes(e.type),a=["paragraph"].includes(e.type),s=["link"].includes(e.type),l=["image"].includes(e.type);return i.jsxs(No,{title:"Properties",icon:"📝",children:[!["divider","spacer"].includes(e.type)&&i.jsx(rt,{label:"Label",value:e.properties.label,onChange:c=>r("label",c),placeholder:"Enter label..."}),o&&i.jsx(rt,{label:"Placeholder",value:e.properties.placeholder,onChange:c=>r("placeholder",c),placeholder:"Enter placeholder..."}),n&&i.jsx(rt,{label:"Description",value:e.properties.description,onChange:c=>r("description",c),type:"textarea",placeholder:"Enter description...",rows:2}),a&&i.jsx(rt,{label:"Content",value:e.properties.content,onChange:c=>r("content",c),type:"textarea",placeholder:"Enter paragraph text...",rows:4}),s&&i.jsxs(i.Fragment,{children:[i.jsx(rt,{label:"Link Text",value:e.properties.content,onChange:c=>r("content",c),placeholder:"Click here"}),i.jsx(rt,{label:"URL",value:e.properties.href,onChange:c=>r("href",c),type:"url",placeholder:"https://example.com"}),i.jsx(uu,{label:"Target",value:e.properties.target,onChange:c=>r("target",c),options:[{value:"_blank",label:"New Tab"},{value:"_self",label:"Same Tab"}]})]}),l&&i.jsxs(i.Fragment,{children:[i.jsx(rt,{label:"Image URL",value:e.properties.src,onChange:c=>r("src",c),type:"url",placeholder:"https://example.com/image.jpg"}),i.jsx(rt,{label:"Alt Text",value:e.properties.alt,onChange:c=>r("alt",c),placeholder:"Image description"})]}),["shortText","number"].includes(e.type)&&i.jsxs("div",{className:m("grid grid-cols-2 gap-2"),children:[i.jsx(rt,{label:"Prefix",value:e.properties.prefix,onChange:c=>r("prefix",c),placeholder:"$"}),i.jsx(rt,{label:"Suffix",value:e.properties.suffix,onChange:c=>r("suffix",c),placeholder:".00"})]})]})},bP=({element:e,onUpdate:t})=>{const r=(n,a)=>{t({layout:{...e.layout,[n]:a}})},o=!["divider","spacer","formHeading","sectionHeading","subheading","paragraph","image","link","captcha","decisionBox"].includes(e.type);return i.jsxs(No,{title:"Layout",icon:"📐",defaultOpen:!1,children:[o&&i.jsx(uu,{label:"Label Position",value:e.layout.labelPosition,onChange:n=>r("labelPosition",n),options:[{value:"top",label:"Top"},{value:"left",label:"Left"},{value:"hidden",label:"Hidden"}]}),i.jsx(uu,{label:"Size",value:e.layout.size,onChange:n=>r("size",n),options:[{value:"small",label:"Small"},{value:"default",label:"Default"},{value:"medium",label:"Medium"},{value:"large",label:"Large"},{value:"full",label:"Full Width"}]}),i.jsx(rt,{label:"Custom Width",value:e.layout.width,onChange:n=>r("width",n),placeholder:"e.g., 50%, 300px"}),i.jsx(rt,{label:"CSS Class",value:e.layout.className,onChange:n=>r("className",n),placeholder:"custom-class",helpText:"Additional CSS classes"})]})},gP=({element:e,onUpdate:t})=>{var c,d,p,u,f,h,b,g,y,v,S;const r=(x,w)=>{t({validation:{...e.validation,[x]:w}})},o=Tw(e.type),n=["shortText","longText","multiLineInput","textEditor","password"].includes(e.type),a=["number","slider","rangeSlider"].includes(e.type),s=["multiFileUpload","multiImageUpload"].includes(e.type),l=["multipleDates"].includes(e.type);return i.jsxs(No,{title:"Validation",icon:"✅",defaultOpen:!1,children:[o.supportsRequired&&i.jsx(by,{label:"Required",checked:(c=e.validation)==null?void 0:c.required,onChange:x=>r("required",x),description:"Field must be filled"}),n&&i.jsxs("div",{className:m("grid grid-cols-2 gap-2"),children:[i.jsx(rt,{label:"Min Length",value:(d=e.validation)==null?void 0:d.minLength,onChange:x=>r("minLength",x?parseInt(x):void 0),type:"number",placeholder:"0",min:0}),i.jsx(rt,{label:"Max Length",value:(p=e.validation)==null?void 0:p.maxLength,onChange:x=>r("maxLength",x?parseInt(x):void 0),type:"number",placeholder:"255",min:0})]}),a&&i.jsxs("div",{className:m("grid grid-cols-2 gap-2"),children:[i.jsx(rt,{label:"Min Value",value:(u=e.validation)==null?void 0:u.min,onChange:x=>r("min",x?parseFloat(x):void 0),type:"number"}),i.jsx(rt,{label:"Max Value",value:(f=e.validation)==null?void 0:f.max,onChange:x=>r("max",x?parseFloat(x):void 0),type:"number"})]}),o.supportsPattern&&i.jsx(rt,{label:"Pattern (Regex)",value:(h=e.validation)==null?void 0:h.pattern,onChange:x=>r("pattern",x),placeholder:"^[a-zA-Z]+$",helpText:"Regular expression for validation"}),s&&i.jsxs("div",{className:m("grid grid-cols-2 gap-2"),children:[i.jsx(rt,{label:"Min Files",value:(b=e.validation)==null?void 0:b.minFiles,onChange:x=>r("minFiles",x?parseInt(x):void 0),type:"number",min:0}),i.jsx(rt,{label:"Max Files",value:(g=e.validation)==null?void 0:g.maxFiles,onChange:x=>r("maxFiles",x?parseInt(x):void 0),type:"number",min:1})]}),l&&i.jsxs("div",{className:m("grid grid-cols-2 gap-2"),children:[i.jsx(rt,{label:"Min Dates",value:(y=e.validation)==null?void 0:y.minDates,onChange:x=>r("minDates",x?parseInt(x):void 0),type:"number",min:0}),i.jsx(rt,{label:"Max Dates",value:(v=e.validation)==null?void 0:v.maxDates,onChange:x=>r("maxDates",x?parseInt(x):void 0),type:"number",min:1})]}),i.jsx(rt,{label:"Error Message",value:(S=e.validation)==null?void 0:S.errorMessage,onChange:x=>r("errorMessage",x),placeholder:"Custom error message..."})]})},yP=({element:e,onUpdate:t,existingNames:r})=>{const[o,n]=P.useState(null),a=(s,l)=>{{const c=new Set(r);c.delete(e.attributes.name),c.has(l)?n("This field name already exists"):!l||l.trim()===""?n("Field name is required"):/^[a-zA-Z][a-zA-Z0-9_]*$/.test(l)?n(null):n("Must start with letter, only letters/numbers/underscores")}t({attributes:{...e.attributes,[s]:l}})};return i.jsx(No,{title:"Attributes",icon:"🏷️",defaultOpen:!1,children:i.jsxs("div",{children:[i.jsx("label",{className:m("block text-sm font-medium text-gray-700 mb-1"),children:"Field Name"}),i.jsx("input",{type:"text",value:e.attributes.name||"",onChange:s=>a("name",s.target.value),placeholder:"fieldName",className:m("w-full px-3 py-2 border rounded-md text-sm focus:outline-none focus:ring-2 focus:border-transparent",o?"border-red-500 focus:ring-red-500":"border-gray-300 focus:ring-blue-500")}),o&&i.jsx("p",{className:m("mt-1 text-xs text-red-600"),children:o}),i.jsx("p",{className:m("mt-1 text-xs text-gray-500"),children:"Used as the key in JSON output"})]})})},vP=({element:e,onUpdate:t})=>{var n,a,s,l;const r=c=>{t({config:{...e.config,options:c}})},o=(c,d)=>{t({config:{...e.config,[c]:d}})};return i.jsxs(No,{title:"Options",icon:"📋",children:[i.jsx(pP,{options:((n=e.config)==null?void 0:n.options)||[],onChange:r}),i.jsx(by,{label:"Allow 'Other' option",checked:(a=e.config)==null?void 0:a.allowOther,onChange:c=>o("allowOther",c),description:"Let users enter custom value"}),((s=e.config)==null?void 0:s.allowOther)&&i.jsx(rt,{label:"Other Label",value:(l=e.config)==null?void 0:l.otherLabel,onChange:c=>o("otherLabel",c),placeholder:"Other..."})]})},wP=({element:e,onUpdate:t})=>{var o,n;const r=(a,s)=>{t({config:{...e.config,[a]:s}})};return i.jsx(No,{title:"Matrix Configuration",icon:"📊",children:i.jsx(hP,{rows:((o=e.config)==null?void 0:o.matrixRows)||[],columns:((n=e.config)==null?void 0:n.matrixColumns)||[],onRowsChange:a=>r("matrixRows",a),onColumnsChange:a=>r("matrixColumns",a),showColumnType:e.type==="matrixTable"})})},xP=()=>i.jsxs("div",{className:m("flex flex-col items-center justify-center h-full text-center px-6 py-12"),children:[i.jsx("div",{className:m("w-12 h-12 bg-muted rounded-full flex items-center justify-center mb-4"),children:i.jsx(wh,{className:m("w-6 h-6 text-muted-foreground")})}),i.jsx("h3",{className:m("text-sm font-medium text-foreground mb-1"),children:"No element selected"}),i.jsx("p",{className:m("text-xs text-muted-foreground"),children:"Click on an element in the canvas to edit its properties"})]}),CP=({element:e,onUpdate:t,propertyConfig:r})=>{const o=(p,u)=>{t({properties:{...e.properties,[p]:u}})},n=r??{showLabel:!0,showPlaceholder:!0,showDescription:!0,showPrefix:!1,showSuffix:!1},a=n.showLabel!==!1,s=n.showPlaceholder===!0,l=n.showDescription!==!1,c=n.showPrefix===!0,d=n.showSuffix===!0;return!a&&!s&&!l&&!c&&!d?null:i.jsxs(No,{title:"Properties",icon:"📝",children:[a&&i.jsx(rt,{label:"Label",value:e.properties.label,onChange:p=>o("label",p),placeholder:"Enter label..."}),s&&i.jsx(rt,{label:"Placeholder",value:e.properties.placeholder,onChange:p=>o("placeholder",p),placeholder:"Enter placeholder..."}),l&&i.jsx(rt,{label:"Description",value:e.properties.description,onChange:p=>o("description",p),type:"textarea",placeholder:"Enter description...",rows:2}),(c||d)&&i.jsxs("div",{className:m("grid grid-cols-2 gap-2"),children:[c&&i.jsx(rt,{label:"Prefix",value:e.properties.prefix,onChange:p=>o("prefix",p),placeholder:"$"}),d&&i.jsx(rt,{label:"Suffix",value:e.properties.suffix,onChange:p=>o("suffix",p),placeholder:".00"})]})]})},SP=()=>{const e=Mw(),t=ie(b=>b.updateElement),r=ie(b=>b.deleteElement),o=ie(b=>b.duplicateElement),n=ie(b=>b.schema.elements),a=P.useMemo(()=>new Set(n.map(b=>b.attributes.name).filter(Boolean)),[n]);if(!e)return i.jsx("div",{className:m("w-72 bg-card border-l border-border flex-col h-full hidden"),children:i.jsx(xP,{})});const s=b=>{t(e.id,b)},l=vt.get(e.type),c=!!(l!=null&&l.renderSettings),d=l==null?void 0:l.settingsSchema,p=c||!!d,u=l!=null&&l.icon&&typeof l.icon=="string"?l.icon:gc[e.type],f=(l==null?void 0:l.label)??bc[e.type],h=d==null?void 0:d.showSections;return i.jsxs("div",{className:m("w-72 bg-card border-l border-border flex flex-col h-full flex-shrink-0"),children:[i.jsxs("div",{className:m("p-4 border-b border-border"),children:[i.jsxs("div",{className:m("flex items-center gap-2 mb-1"),children:[i.jsx("span",{className:m("text-xl"),children:u}),i.jsx("h2",{className:m("text-lg font-semibold text-foreground"),children:f})]}),i.jsxs("div",{className:m("flex gap-2 mt-3"),children:[i.jsxs(st,{variant:"secondary",size:"sm",className:m("flex-1"),onClick:()=>o(e.id),children:[i.jsx(x1,{className:m("h-3 w-3 mr-1")}),"Duplicate"]}),i.jsxs(st,{variant:"destructive",size:"sm",className:m("flex-1"),onClick:()=>{window.confirm("Are you sure you want to delete this element?")&&r(e.id)},children:[i.jsx(mc,{className:m("h-3 w-3 mr-1")}),"Delete"]})]})]}),i.jsxs(Fc,{className:m("flex-1"),children:[c&&l.renderSettings({element:e,onUpdate:s}),!c&&i.jsxs(i.Fragment,{children:[(h==null?void 0:h.properties)!==!1&&(p?i.jsx(CP,{element:e,onUpdate:s,propertyConfig:d==null?void 0:d.properties}):i.jsx(mP,{element:e,onUpdate:s})),(h==null?void 0:h.options)!==!1&&aE(e.type)&&i.jsx(vP,{element:e,onUpdate:s}),(h==null?void 0:h.matrix)!==!1&&lE(e.type)&&i.jsx(wP,{element:e,onUpdate:s}),d&&i.jsx(fP,{element:e,schema:d,onUpdate:s}),(h==null?void 0:h.layout)!==!1&&i.jsx(bP,{element:e,onUpdate:s}),(h==null?void 0:h.validation)!==!1&&((l==null?void 0:l.supportsValidation)??sE(e.type))&&!gi(e.type)&&i.jsx(gP,{element:e,onUpdate:s}),(h==null?void 0:h.attributes)!==!1&&((l==null?void 0:l.structure)==="field"||tE(e.type))&&!gi(e.type)&&i.jsx(yP,{element:e,onUpdate:s,existingNames:a}),(h==null?void 0:h.logic)!==!1&&!gi(e.type)&&i.jsx(No,{title:"Conditional Logic",icon:"⚡",children:i.jsx(T$,{element:e,elements:n,onUpdate:s})})]})]})]})};var Ea=e=>e.type==="checkbox",Wl=e=>e.type==="file",Eo=e=>e instanceof Date,Ft=e=>e==null;const fu=e=>typeof e=="object";var ft=e=>!Ft(e)&&!Array.isArray(e)&&fu(e)&&!Eo(e),NP=e=>ft(e)&&e.target?Ea(e.target)?e.target.checked:Wl(e.target)?e.target.files:e.target.value:e,EP=(e,t)=>t.split(".").some((r,o,n)=>!isNaN(Number(r))&&e.has(n.slice(0,o).join("."))),gy=e=>{const t=e.constructor&&e.constructor.prototype;return ft(t)&&t.hasOwnProperty("isPrototypeOf")},Hl=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function ht(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(Hl&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(ft(e)&&gy(e)))return e;const o=r?[]:Object.create(Object.getPrototypeOf(e));for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(o[n]=ht(e[n]));return o}const Tn={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},_r={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Tr={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},yy="root",pu=["__proto__","constructor","prototype"],kP=/^\w*$/;var ka=e=>kP.test(e),dt=e=>e===void 0;const AP=/[.[\]'"]/;var jl=e=>e.split(AP).filter(Boolean),pe=(e,t,r)=>{if(!t||!ft(e))return r;const o=ka(t)?[t]:jl(t);if(o.some(a=>pu.includes(a)))return r;const n=o.reduce((a,s)=>Ft(a)?void 0:a[s],e);return dt(n)||n===e?dt(e[t])?r:e[t]:n},jr=e=>typeof e=="boolean",gr=e=>typeof e=="function",lt=(e,t,r)=>{let o=-1;const n=ka(t)?[t]:jl(t),a=n.length,s=a-1;for(;++o<a;){const l=n[o];let c=r;if(o!==s){const d=e[l];c=ft(d)||Array.isArray(d)?d:isNaN(+n[o+1])?{}:[]}if(pu.includes(l))return;e[l]=c,e=e[l]}};const vy=P.createContext(null);vy.displayName="HookFormControlContext";var _P=(e,t,r,o=!0)=>{const n={};for(const a in e)Object.defineProperty(n,a,{get:()=>{const s=a;return t._proxyFormState[s]!==_r.all&&(t._proxyFormState[s]=!o||_r.all),e[s]}});return n};const TP=Hl?P.useLayoutEffect:P.useEffect;var Vt=e=>typeof e=="string",DP=(e,t,r,o,n)=>Vt(e)?(o&&t.watch.add(e),pe(r,e,n)):Array.isArray(e)?e.map(a=>(o&&t.watch.add(a),pe(r,a))):(o&&(t.watchAll=!0),r),hu=e=>Ft(e)||!fu(e);const wy=(e,t)=>t.length===0&&!Array.isArray(e)&&!gy(e);function qr(e,t,r=new WeakMap){if(e===t)return!0;if(hu(e)||hu(t))return Object.is(e,t);if(Eo(e)&&Eo(t))return Object.is(e.getTime(),t.getTime());const o=Object.keys(e),n=Object.keys(t);if(o.length!==n.length)return!1;if(wy(e,o)||wy(t,n))return Object.is(e,t);if(!o.length&&Array.isArray(e)!==Array.isArray(t))return!1;const a=r.get(e);if(a&&a.has(t))return!0;if(a)a.add(t);else{const s=new WeakSet;s.add(t),r.set(e,s)}for(const s of o){const l=e[s];if(!(s in t))return!1;if(s!=="ref"){const c=t[s];if(Eo(l)&&Eo(c)||(ft(l)||Array.isArray(l))&&(ft(c)||Array.isArray(c))?!qr(l,c,r):!Object.is(l,c))return!1}}return!0}var ql=e=>({isOnSubmit:!e||e===_r.onSubmit,isOnBlur:e===_r.onBlur,isOnChange:e===_r.onChange,isOnAll:e===_r.all,isOnTouch:e===_r.onTouched}),mu=(e,t,r)=>{if(r)return!1;if(t.watchAll||t.watch.has(e))return!0;for(const o of t.watch)if(e.startsWith(o)&&e.charAt(o.length)===".")return!0;return!1};const Aa=(e,t,r,o)=>{for(const n of r||Object.keys(e)){if(n==="_f")continue;const a=r?pe(e,n):e[n];if(a){const{_f:s}=a;if(s){if(s.refs&&s.refs[0]&&t(s.refs[0],n)&&!o)return!0;if(s.ref&&t(s.ref,s.name)&&!o)return!0;if(Aa(a,t))break}else if((ft(a)||Array.isArray(a))&&Aa(a,t))break}}};var xy=(e,t,r)=>{const o=pe(e,r),n=Array.isArray(o)?o:[];return lt(n,yy,t[r]),lt(e,r,n),e},Gt=e=>ft(e)&&!Object.keys(e).length,Yl=e=>{if(!Hl)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},bu=e=>e.type==="radio",Ql=e=>e instanceof RegExp,$P=(e,t,r,o,n)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[o]:n||!0}}:{};const Cy={value:!1,isValid:!1},Sy={value:!0,isValid:!0};var Ny=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!dt(e[0].attributes.value)?dt(e[0].value)||e[0].value===""?Sy:{value:e[0].value,isValid:!0}:Sy:Cy}return Cy};const Ey={isValid:!1,value:null};var ky=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,Ey):Ey;function Ay(e,t,r="validate"){if(Vt(e)||Array.isArray(e)&&e.every(Vt)||jr(e)&&!e)return{type:r,message:Vt(e)?e:"",ref:t}}var Dn=e=>ft(e)&&!Ql(e)?e:{value:e,message:""},_y=async(e,t,r,o,n,a)=>{const{ref:s,refs:l,required:c,maxLength:d,minLength:p,min:u,max:f,pattern:h,validate:b,name:g,valueAsNumber:y,mount:v}=e._f,S=pe(r,g);if(!v||t.has(g))return{};const x=l?l[0]:s,w=$=>{if(n&&x.reportValidity){const V=jr($)?"":$||"";l?l.forEach(G=>G.setCustomValidity(V)):x.setCustomValidity(V),x.reportValidity()}},N={},k=bu(s),_=Ea(s),E=k||_,D=(y||Wl(s))&&dt(s.value)&&dt(S)||Yl(s)&&s.value===""||S===""||Array.isArray(S)&&!S.length,T=$P.bind(null,g,o,N),O=($,V,G,q=Tr.maxLength,H=Tr.minLength)=>{const Y=$?V:G;N[g]={type:$?q:H,message:Y,ref:s,...T($?q:H,Y)}};if(a?!Array.isArray(S)||!S.length:c&&(!E&&(D||Ft(S))||jr(S)&&!S||_&&!Ny(l).isValid||k&&!ky(l).isValid)){const{value:$,message:V}=Vt(c)?{value:!!c,message:c}:Dn(c);if($&&(N[g]={type:Tr.required,message:V,ref:x,...T(Tr.required,V)},!o))return w(V),N}if(!D&&(!Ft(u)||!Ft(f))){let $,V;const G=Dn(f),q=Dn(u);if(!Ft(S)&&!isNaN(S)){const H=s.valueAsNumber||S&&+S;Ft(G.value)||($=H>G.value),Ft(q.value)||(V=H<q.value)}else{const H=s.valueAsDate||new Date(S),Y=R=>new Date(new Date().toDateString()+" "+R),J=s.type=="time",W=s.type=="week";Vt(G.value)&&S&&($=J?Y(S)>Y(G.value):W?S>G.value:H>new Date(G.value)),Vt(q.value)&&S&&(V=J?Y(S)<Y(q.value):W?S<q.value:H<new Date(q.value))}if(($||V)&&(O(!!$,G.message,q.message,Tr.max,Tr.min),!o))return w(N[g].message),N}if((d||p)&&!D&&(Vt(S)||a&&Array.isArray(S))){const $=Dn(d),V=Dn(p),G=!Ft($.value)&&S.length>+$.value,q=!Ft(V.value)&&S.length<+V.value;if((G||q)&&(O(G,$.message,V.message),!o))return w(N[g].message),N}if(h&&!D&&Vt(S)){const{value:$,message:V}=Dn(h);if(Ql($)&&!S.match($)&&(N[g]={type:Tr.pattern,message:V,ref:s,...T(Tr.pattern,V)},!o))return w(V),N}if(b){if(gr(b)){const $=await b(S,r),V=Ay($,x);if(V&&(N[g]={...V,...T(Tr.validate,V.message)},!o))return w(V.message),N}else if(ft(b)){let $={};for(const V in b){if(!Gt($)&&!o)break;const G=Ay(await b[V](S,r),x,V);G&&($={...G,...T(V,G.message)},w(G.message),o&&(N[g]=$))}if(!Gt($)&&(N[g]={ref:x,...$},!o))return N}}return w(!0),N},Kl=e=>Array.isArray(e)?e:[e],Ty=e=>Array.isArray(e)?e.filter(Boolean):[];function PP(e,t){const r=t.length-1;let o=0;for(;o<r;){if(Ft(e)){e=void 0;break}e=e[t[o]],o++}return e}function MP(e){for(const t in e)if(e.hasOwnProperty(t)&&!dt(e[t]))return!1;return!0}function gt(e,t){if(Vt(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const r=Array.isArray(t)?t:ka(t)?[t]:jl(t);if(r.some(s=>pu.includes(String(s))))return e;const o=r.length===1?e:PP(e,r),n=r.length-1,a=r[n];return o&&delete o[a],n!==0&&(ft(o)&&Gt(o)||Array.isArray(o)&&MP(o))&&gt(e,r.slice(0,-1)),e}const Dy=e=>{const t={};for(const r of Object.keys(e))if(fu(e[r])&&e[r]!==null&&!Eo(e[r])){const o=Dy(e[r]);for(const n of Object.keys(o))t[`${r}.${n}`]=o[n]}else t[r]=e[r];return t},gu=P.createContext(null);gu.displayName="HookFormContext";const yu=()=>P.useContext(gu),$y=({children:e,watch:t,getValues:r,getFieldState:o,setError:n,clearErrors:a,setValue:s,setValues:l,trigger:c,formState:d,resetField:p,reset:u,resetDefaultValues:f,handleSubmit:h,unregister:b,control:g,register:y,setFocus:v,subscribe:S})=>{const x=P.useMemo(()=>({watch:t,getValues:r,getFieldState:o,setError:n,clearErrors:a,setValue:s,setValues:l,trigger:c,formState:d,resetField:p,reset:u,resetDefaultValues:f,handleSubmit:h,unregister:b,control:g,register:y,setFocus:v,subscribe:S}),[a,g,d,o,r,h,y,u,f,p,n,v,s,l,S,c,b,t]);return P.createElement(gu.Provider,{value:x},P.createElement(vy.Provider,{value:x.control},e))};var Py=()=>{let e=[];return{get observers(){return e},next:n=>{for(const a of e)a.next&&a.next(n)},subscribe:n=>(e.push(n),{unsubscribe:()=>{e=e.filter(a=>a!==n)}}),unsubscribe:()=>{e=[]}}};function My(e,t){const r={};for(const o in e)if(e.hasOwnProperty(o)){const n=e[o],a=t[o];if(n&&ft(n)&&a){const s=My(n,a);ft(s)&&(r[o]=s)}else e[o]&&(r[o]=a)}return r}var Oy=e=>e.type==="select-multiple",OP=e=>bu(e)||Ea(e),vu=e=>Yl(e)&&e.isConnected;function Iy(e){return Array.isArray(e)||ft(e)}function Ly(e,t,r="",o=[]){for(const n in e){const a=r?`${r}.${n}`:n,s=e[n];Iy(s)&&Iy(pe(t,a))?Ly(s,t,a,o):o.push(a)}return o}var IP=e=>{for(const t in e)if(gr(e[t]))return!0;return!1};function Fy(e){return Array.isArray(e)||ft(e)&&!IP(e)}function Vy(e){return!!(e&&"_f"in e)}function Gy(e){return Array.isArray(e)?!e.some(t=>!dt(t)):!Object.keys(e).length}function wu(e,t){Array.isArray(e)?e[t]=void 0:delete e[t]}function xu(e,t={},r){for(const o in e){const n=e[o],a=r&&r[o];Fy(n)&&(!Array.isArray(n)||!Vy(a))?(t[o]=Array.isArray(n)?[]:{},xu(n,t[o],a),Gy(t[o])&&wu(t,o)):dt(n)||(t[o]=!0)}return t}function an(e,t,r,o){r||(r=xu(t,{},o));for(const n in e){const a=e[n],s=o&&o[n];Fy(a)&&(!Array.isArray(a)||!Vy(s))?(dt(t)||hu(r[n])?r[n]=xu(a,Array.isArray(a)?[]:{},s):an(a,Ft(t)?{}:t[n],r[n],s),Gy(r[n])&&wu(r,n)):qr(a,t[n])?wu(r,n):r[n]=!0}return r}var zy=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:o})=>dt(e)?e:t?e===""?NaN:e&&+e:r&&Vt(e)?new Date(e):o?o(e):e;function By(e){const t=e.ref;return Wl(t)?t.files:bu(t)?ky(e.refs).value:Oy(t)?[...t.selectedOptions].map(({value:r})=>r):Ea(t)?Ny(e.refs).value:zy(t.value,e)}var LP=(e,t,r,o)=>{const n={};for(const a of e){const s=pe(t,a);s&&lt(n,a,s._f)}return{criteriaMode:r,names:[...e],fields:n,shouldUseNativeValidation:o}},_a=e=>dt(e)?e:Ql(e)?e.source:ft(e)?Ql(e.value)?e.value.source:e.value:e;const Uy="AsyncFunction";var FP=e=>{if(!e||!e.validate)return!1;if(gr(e.validate))return e.validate.constructor.name===Uy;if(ft(e.validate)){for(const t in e.validate)if(e.validate[t].constructor.name===Uy)return!0}return!1},VP=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function Wy(e,t,r){const o=pe(e,r);if(o||ka(r))return{error:o,name:r};const n=r.split(".");for(;n.length;){const a=n.join("."),s=pe(t,a),l=pe(e,a);if(s&&!Array.isArray(s)&&r!==a)return{name:r};if(l&&l.type)return{name:a,error:l};if(l&&l.root&&l.root.type)return{name:`${a}.root`,error:l.root};n.pop()}return{name:r}}var GP=(e,t,r,o)=>{r(e);const n=Object.keys(e).filter(a=>a!=="name");return!n.length||o&&n.length>=Object.keys(t).length||n.find(a=>t[a]===(!o||_r.all))},zP=(e,t,r)=>!e||!t||e===t||Kl(e).some(o=>o&&(r?o===t||o.startsWith(t+"."):o.startsWith(t)||t.startsWith(o))),BP=(e,t,r,o,n)=>n.isOnAll?!1:!r&&n.isOnTouch?!(t||e):(r?o.isOnBlur:n.isOnBlur)?!e:(r?o.isOnChange:n.isOnChange)?e:!0,UP=(e,t)=>!Ty(pe(e,t)).length&&gt(e,t);const WP={mode:_r.onSubmit,reValidateMode:_r.onChange,shouldFocusError:!0},Cu="form",HP=(e,t)=>{for(const r in e)r in t||delete e[r];Object.assign(e,t)},Hy={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function jP(e={}){let t={...WP,...e},r={...ht(Hy),isLoading:gr(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},o={},n=ft(t.defaultValues)||ft(t.values)?ht(t.defaultValues||t.values)||{}:{},a=t.shouldUnregister?{}:ht(n),s={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const c={},d={};let p=0,u=ql(t.mode),f=ql(t.reValidateMode);const h={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},b={...h};let g={...b};const y={array:Py(),state:Py()};let v=0;const S=t.criteriaMode===_r.all,x=(A,M)=>L=>{clearTimeout(d[A]),d[A]=setTimeout(M,L)},w=async A=>{if(!s.keepIsValid&&!t.disabled&&(b.isValid||g.isValid||A)){const M=++v;let L;t.resolver?(L=Gt((await G()).errors),M===v&&N()):L=await Y({fields:o,onlyCheckValid:!0,eventType:Tn.VALID}),M===v&&L!==r.isValid&&y.state.next({isValid:L})}},N=(A,M)=>{!t.disabled&&(b.isValidating||b.validatingFields||g.isValidating||g.validatingFields)&&((A||Array.from(l.mount)).forEach(L=>{L&&(M?lt(r.validatingFields,L,M):gt(r.validatingFields,L))}),y.state.next({validatingFields:r.validatingFields,isValidating:!Gt(r.validatingFields)}))},k=()=>{r.dirtyFields=an(n,a,void 0,o)},_=(A,M=[],L,B,U=!0,X=!0)=>{if(B&&L&&!t.disabled){if(s.action=!0,X&&Array.isArray(pe(o,A))){const z=L(pe(o,A),B.argA,B.argB);U&&lt(o,A,z)}if(X&&Array.isArray(pe(r.errors,A))){const z=L(pe(r.errors,A),B.argA,B.argB);U&&lt(r.errors,A,z),UP(r.errors,A)}if((b.touchedFields||g.touchedFields)&&X&&Array.isArray(pe(r.touchedFields,A))){const z=L(pe(r.touchedFields,A),B.argA,B.argB);U&&lt(r.touchedFields,A,z)}(b.dirtyFields||g.dirtyFields)&&k(),y.state.next({name:A,isDirty:W(A,M),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else lt(a,A,M)},E=(A,M)=>{lt(r.errors,A,M),r.errors={...r.errors},y.state.next({errors:r.errors})},D=A=>{r.errors=A,y.state.next({errors:r.errors,isValid:!1})},T=A=>{const M=ka(A)?[A]:jl(A);let L=a,B=n;for(let U=0;U<M.length-1;U++){const X=M[U];if(L=Ft(L)?L:L[X],B=Ft(B)?B:B[X],L===null&&B!==null)return!0}return!1},O=(A,M,L,B)=>{const U=pe(o,A);if(U){if(T(A))return;const X=dt(pe(a,A)),z=pe(a,A,dt(L)?pe(n,A):L);dt(z)||B&&B.defaultChecked||M?lt(a,A,M?z:By(U._f)):Q(A,z),s.mount&&!s.action&&(w(),X&&r.isDirty&&(b.isDirty||g.isDirty)&&(W()||(r.isDirty=!1,y.state.next({...r}))),e.shouldUnregister&&X&&!dt(pe(a,A))&&mu(A,l)&&(s.watch=!0))}},$=(A,M,L,B,U)=>{let X=!1,z=!1;const ee={name:A};if(!t.disabled||B===!0){if(!L||B){const ne=qr(pe(n,A),M);(b.isDirty||g.isDirty)&&(z=r.isDirty,r.isDirty=ee.isDirty=!ne||W(),X=z!==ee.isDirty),z=!!pe(r.dirtyFields,A),ne!==r.isDirty?HP(r.dirtyFields,an(n,a,void 0,o)):ne?gt(r.dirtyFields,A):lt(r.dirtyFields,A,!0),ee.dirtyFields=r.dirtyFields,X=X||(b.dirtyFields||g.dirtyFields)&&z!==!ne}if(L){const ne=pe(r.touchedFields,A);ne||(lt(r.touchedFields,A,L),ee.touchedFields=r.touchedFields,X=X||(b.touchedFields||g.touchedFields)&&ne!==L)}X&&U&&y.state.next(ee)}return X?ee:{}},V=(A,M,L,B)=>{const U=pe(r.errors,A),X=(b.isValid||g.isValid)&&jr(M)&&r.isValid!==M;if(t.delayError&&L?(c[A]=x(A,()=>E(A,L)),c[A](t.delayError)):(clearTimeout(d[A]),delete c[A],L?lt(r.errors,A,L):gt(r.errors,A),r.errors={...r.errors}),(L?!qr(U,L):U)||!Gt(B)||X){const z={...B,...X&&jr(M)?{isValid:M}:{},errors:r.errors,name:A};r={...r,...z},y.state.next(z)}},G=async A=>(N(A,!0),await t.resolver(a,t.context,LP(A||l.mount,o,t.criteriaMode,t.shouldUseNativeValidation))),q=async A=>{const{errors:M}=await G(A);if(N(A),A){for(const L of A){const B=pe(M,L);B?l.array.has(L)&&ft(B)&&!Object.keys(B).some(U=>!Number.isNaN(Number(U)))?xy(r.errors,{[L]:B},L):lt(r.errors,L,B):gt(r.errors,L)}r.errors={...r.errors}}else r.errors=M;return M},H=async({name:A,eventType:M})=>{if(e.validate){const L=await e.validate({formValues:a,formState:r,name:A,eventType:M});if(ft(L))for(const B in L){const U=L[B];U&&ae(`${Cu}.${B}`,{message:Vt(U.message)?U.message:"",type:U.type||Tr.validate})}else Vt(L)||!L?ae(Cu,{message:L||"",type:Tr.validate}):be(Cu);return L}return!0},Y=async({fields:A,onlyCheckValid:M,name:L,eventType:B,context:U={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(U.runRootValidation=!0,!await H({name:L,eventType:B})&&(U.valid=!1,M)))return U.valid;for(const X in A){const z=A[X];if(z){const{_f:ee,...ne}=z;if(ee){const Ce=l.array.has(ee.name),Fe=z._f&&FP(z._f),Ue=b.validatingFields||b.isValidating||g.validatingFields||g.isValidating;Fe&&Ue&&N([ee.name],!0);const ye=await _y(z,l.disabled,a,S,t.shouldUseNativeValidation&&!M,Ce);if(Fe&&Ue&&N([ee.name]),ye[ee.name]&&(U.valid=!1,M)||(!M&&(pe(ye,ee.name)?Ce?xy(r.errors,ye,ee.name):lt(r.errors,ee.name,ye[ee.name]):gt(r.errors,ee.name)),e.shouldUseNativeValidation&&ye[ee.name]))break}!Gt(ne)&&await Y({context:U,onlyCheckValid:M,fields:ne,name:X,eventType:B})}}return U.valid},J=()=>{for(const A of l.unMount){const M=pe(o,A);M&&(M._f.refs?M._f.refs.every(L=>!vu(L)):!vu(M._f.ref))&&et(A)}l.unMount=new Set},W=(A,M)=>(A&&M&&lt(a,A,M),!qr(s.mount?a:n,n)),R=(A,M,L)=>DP(A,l,{...s.mount?a:dt(M)?n:Vt(A)?{[A]:M}:M},L,M),we=A=>Ty(pe(s.mount?a:n,A,t.shouldUnregister?pe(n,A,[]):[])),Q=(A,M,L={},B=!1,U=!1)=>{const X=pe(o,A);let z=M;if(X){const ee=X._f;ee&&(!ee.disabled&&lt(a,A,zy(M,ee)),z=Yl(ee.ref)&&Ft(M)?"":M,Oy(ee.ref)?[...ee.ref.options].forEach(ne=>ne.selected=z.includes(ne.value)):ee.refs?Ea(ee.ref)?ee.refs.forEach(ne=>{(!ne.defaultChecked||!ne.disabled)&&(Array.isArray(z)?ne.checked=!!z.find(Ce=>Ce===ne.value):ne.checked=z===ne.value||!!z)}):ee.refs.forEach(ne=>ne.checked=ne.value===z):Wl(ee.ref)?ee.ref.value="":(ee.ref.value=z,!ee.ref.type&&!U&&y.state.next({name:A,values:B?a:ht(a)})))}(L.shouldDirty||L.shouldTouch)&&$(A,z,L.shouldTouch,L.shouldDirty,!U),L.shouldValidate&&ce(A,{delayError:L.delayError})},te=(A,M,L,B=!1,U=!1)=>{l.array.has(A)&&y.array.next({name:A,values:B?a:ht(a)});for(const X in M){if(!M.hasOwnProperty(X))return;const z=M[X],ee=A+"."+X,ne=pe(o,ee);(l.array.has(A)||ft(z)||ne&&!ne._f)&&!Eo(z)?te(ee,z,L,B,U):Q(ee,z,L,B,U)}},De=(A,M,L,B,U=!1)=>{const X=pe(o,A),z=l.array.has(A),ee=B?M:ht(M),ne=pe(a,A),Ce=qr(ne,ee);if(Ce||lt(a,A,ee),z)y.array.next({name:A,values:B?a:ht(a)}),(b.isDirty||b.dirtyFields||g.isDirty||g.dirtyFields)&&L.shouldDirty&&(k(),U||y.state.next({name:A,dirtyFields:r.dirtyFields,isDirty:W(A,ee)}));else{const Fe=Array.isArray(ee)&&!ee.length||Gt(ee);!X||X._f||Ft(ee)||Fe?Q(A,ee,L,B,U):te(A,ee,L,B,U)}if(!Ce&&!U){const Fe=mu(A,l),Ue=B?a:ht(a);y.state.next({...Fe&&r,name:s.mount||Fe?A:void 0,values:Ue})}},de=(A,M,L={})=>De(A,M,L,!1),Se=(A,M={})=>{const L=gr(A)?A(a):A;if(!qr(a,L)){a={...a,...L};const B=Dy(L);for(const U of l.mount)U in B&&De(U,B[U],M,!0,!0);y.state.next({...r,name:void 0,type:void 0,...p?{values:a}:{}}),M.shouldValidate&&w()}},re=async A=>{s.mount=!0;const M=A.target;let L=M.name,B=!0;const U=pe(o,L),X=z=>{B=Number.isNaN(z)||Eo(z)&&isNaN(z.getTime())||qr(z,pe(a,L,z))};if(U){let z,ee;const ne=M.type?By(U._f):NP(A),Ce=A.type===Tn.BLUR||A.type===Tn.FOCUS_OUT,Fe=!VP(U._f)&&!e.validate&&!t.resolver&&!pe(r.errors,L)&&!U._f.deps,Ue=Fe||BP(Ce,pe(r.touchedFields,L),r.isSubmitted,f,u),ye=mu(L,l,Ce);if(lt(a,L,ne),Ce){if(!M||!M.readOnly){U._f.onBlur&&U._f.onBlur(A);const Jt=c[L];Jt&&Jt(0)}}else U._f.onChange&&U._f.onChange(A);const We=$(L,ne,Ce),ct=!Gt(We)||ye;if(!Ce&&y.state.next({name:L,type:A.type,...p?{values:ht(a)}:{}}),Ue)return(!Fe||!r.isValid)&&(b.isValid||g.isValid)&&(t.mode==="onBlur"?Ce&&w():Ce||w()),ct&&y.state.next({name:L,...ye?{}:We});if(!t.resolver&&e.validate&&await H({name:L,eventType:A.type}),!Ce&&ye&&y.state.next({...r}),t.resolver){const{errors:Jt}=await G([L]);if(N([L]),X(ne),!B){!Gt(We)&&y.state.next(We);return}const ko=Wy(r.errors,o,L),Zt=Wy(Jt,o,ko.name||L);z=Zt.error,L=Zt.name,ee=Gt(Jt)}else N([L],!0),z=(await _y(U,l.disabled,a,S,t.shouldUseNativeValidation))[L],N([L]),X(ne),B&&(z?ee=!1:(b.isValid||g.isValid)&&(ee=await Y({fields:o,onlyCheckValid:!0,name:L,eventType:A.type})));B&&(U._f.deps&&(!Array.isArray(U._f.deps)||U._f.deps.length>0)&&ce(U._f.deps),V(L,ee,z,We))}},me=(A,M)=>{if(pe(r.errors,M)&&A.focus)return A.focus(),1},ce=async(A,M={})=>{let L,B;const U=Kl(A);if(t.resolver){const X=await q(dt(A)?A:U);L=Gt(X),B=A?!U.some(z=>pe(X,z)):L}else A?(B=(await Promise.all(U.map(async X=>{const z=pe(o,X);return await Y({fields:z&&z._f?{[X]:z}:z,eventType:Tn.TRIGGER})}))).every(Boolean),!(!B&&!r.isValid)&&w()):B=L=await Y({fields:o,name:A,eventType:Tn.TRIGGER});if(M.delayError&&t.delayError&&Vt(A)){const X=pe(r.errors,A);X?(gt(r.errors,A),c[A]=x(A,()=>E(A,X)),c[A](t.delayError)):(clearTimeout(d[A]),delete c[A])}return y.state.next({...!Vt(A)||(b.isValid||g.isValid)&&L!==r.isValid?{}:{name:A},...t.resolver||!A?{isValid:L}:{},errors:r.errors}),M.shouldFocus&&!B&&Aa(o,me,A?U:l.mount),B},Ie=(A,M)=>{let L={...s.mount?a:n};return M&&(L=My(M.dirtyFields?r.dirtyFields:r.touchedFields,L)),dt(A)?L:Vt(A)?pe(L,A):A.map(B=>pe(L,B))},xe=(A,M)=>({invalid:!!pe((M||r).errors,A),isDirty:!!pe((M||r).dirtyFields,A),error:pe((M||r).errors,A),isValidating:!!pe(r.validatingFields,A),isTouched:!!pe((M||r).touchedFields,A)}),be=A=>{const M=A?Kl(A):void 0;M==null||M.forEach(L=>gt(r.errors,L)),M?M.forEach(L=>{y.state.next({name:L,errors:r.errors})}):(r.errors={},y.state.next({errors:r.errors}))},ae=(A,M,L)=>{const B=(pe(o,A,{_f:{}})._f||{}).ref,U=pe(r.errors,A)||{},{ref:X,message:z,type:ee,...ne}=U;lt(r.errors,A,{...ne,...M,ref:B}),y.state.next({name:A,errors:r.errors,isValid:!1}),L&&L.shouldFocus&&B&&B.focus&&B.focus()},ue=(A,M)=>{if(gr(A)){p++;const{unsubscribe:L}=y.state.subscribe({next:U=>"values"in U&&A(U.values||R(void 0,M),U)});let B=!1;return{unsubscribe:()=>{B||(B=!0,p--,L())}}}return R(A,M,!0)},ve=A=>{var M;const L=!!(!((M=A.formState)===null||M===void 0)&&M.values);L&&p++;const{unsubscribe:B}=y.state.subscribe({next:X=>{if(zP(A.name,X.name,A.exact)&&GP(X,A.formState||b,K,A.reRenderRoot)){const z={...a};A.callback({values:z,...r,...X,defaultValues:n})}}});if(!L)return B;let U=!1;return()=>{U||(U=!0,p--,B())}},Oe=A=>(s.mount=!0,g={...g,...A.formState},ve({...A,formState:{...h,...A.formState}})),et=(A,M={})=>{for(const L of A?Kl(A):l.mount)l.mount.delete(L),l.array.delete(L),M.keepValue||(gt(o,L),gt(a,L)),!M.keepError&&gt(r.errors,L),!M.keepDirty&&gt(r.dirtyFields,L),!M.keepTouched&&gt(r.touchedFields,L),!M.keepIsValidating&&gt(r.validatingFields,L),!t.shouldUnregister&&!M.keepDefaultValue&&gt(n,L);y.state.next({values:ht(a)}),y.state.next({...r,...M.keepDirty?{isDirty:W()}:{}}),!M.keepIsValid&&w()},at=({disabled:A,name:M})=>{if(jr(A)&&s.mount||A||l.disabled.has(M)){const U=l.disabled.has(M)!==!!A;A?l.disabled.add(M):l.disabled.delete(M),U&&s.mount&&!s.action&&w()}},it=(A,M={})=>{let L=pe(o,A);const B=jr(M.disabled)||jr(t.disabled),U=!l.registerName.has(A)&&L&&L._f&&!L._f.mount;return lt(o,A,{...L||{},_f:{...L&&L._f?L._f:{ref:{name:A}},name:A,mount:!0,...M}}),l.mount.add(A),L&&!U?at({disabled:jr(M.disabled)?M.disabled:t.disabled,name:A}):O(A,!0,M.value),{...B?{disabled:M.disabled||t.disabled}:{},...t.progressive?{required:!!M.required,min:_a(M.min),max:_a(M.max),minLength:_a(M.minLength),maxLength:_a(M.maxLength),pattern:_a(M.pattern)}:{},name:A,onChange:re,onBlur:re,ref:X=>{if(X){l.registerName.add(A),it(A,M),l.registerName.delete(A),L=pe(o,A);const z=dt(X.value)&&X.querySelectorAll&&X.querySelectorAll("input,select,textarea")[0]||X,ee=OP(z),ne=L._f.refs||[];if(ee?ne.find(Fe=>Fe===z):z===L._f.ref)return;const Ce={...L._f};ee?(Ce.refs=[...ne.filter(vu),z,...Array.isArray(pe(n,A))?[{}]:[]],Ce.ref={type:z.type,name:A}):(Ce.ref=z,delete Ce.refs),lt(o,A,{_f:Ce}),O(A,!1,void 0,z)}else L=pe(o,A,{}),L._f&&(L._f.mount=!1),(t.shouldUnregister||M.shouldUnregister)&&!(EP(l.array,A)&&s.action)&&l.unMount.add(A)}}},tt=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&Aa(o,me,l.mount),$e=A=>{jr(A)&&(y.state.next({disabled:A}),Aa(o,(M,L)=>{const B=pe(o,L);B&&(M.disabled=B._f.disabled||A,Array.isArray(B._f.refs)&&B._f.refs.forEach(U=>{U.disabled=B._f.disabled||A}))},0,!1))},yt=(A,M)=>async L=>{let B,U;L&&(L.preventDefault&&L.preventDefault(),L.persist&&L.persist());let X=ht(a);if(y.state.next({isSubmitting:!0}),t.resolver){const{errors:z,values:ee}=await G();N(),r.errors=z,X=ht(ee)}else await Y({fields:o,eventType:Tn.SUBMIT});if(l.disabled.size)for(const z of l.disabled)gt(X,z);if(gt(r.errors,yy),Gt(r.errors)){y.state.next({errors:{}});try{B=await A(X,L)}catch(z){U=z}}else M&&await M({...r.errors},L),tt(),setTimeout(tt);if(y.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Gt(r.errors)&&!U,submitCount:r.submitCount+1,errors:r.errors}),U)throw U;return B},Xt=(A,M={})=>{pe(o,A)&&(dt(M.defaultValue)?de(A,ht(pe(n,A))):(de(A,M.defaultValue),lt(n,A,ht(M.defaultValue))),M.keepTouched||gt(r.touchedFields,A),M.keepDirty||(gt(r.dirtyFields,A),r.isDirty=M.defaultValue?W(A,ht(pe(n,A))):W()),M.keepError||(gt(r.errors,A),b.isValid&&w()),y.state.next({...r}))},Wt=(A,M={})=>{const L=A?ht(A):n,B=ht(L),U=Gt(A),X=B,z=o;if(M.keepDefaultValues||(n=L),!M.keepValues){if(M.keepDirtyValues){const ee=new Set([...l.mount,...Ly(an(n,a,void 0,z),r.dirtyFields)]);for(const ne of Array.from(ee)){const Ce=pe(r.dirtyFields,ne),Fe=pe(a,ne),Ue=pe(X,ne);Ce&&!dt(Fe)?lt(X,ne,Fe):!Ce&&!dt(Ue)&&de(ne,Ue)}}else{if(Hl&&dt(A))for(const ee of l.mount){const ne=pe(o,ee);if(ne&&ne._f){const Ce=Array.isArray(ne._f.refs)?ne._f.refs[0]:ne._f.ref;if(Yl(Ce)){const Fe=Ce.closest("form");if(Fe){Fe.reset();break}}}}if(M.keepFieldsRef)for(const ee of l.mount)de(ee,pe(X,ee));else o={}}if(t.shouldUnregister){if(a=M.keepDefaultValues?ht(n):{},M.keepFieldsRef)for(const ee of l.mount)lt(a,ee,pe(X,ee))}else a=ht(X);y.array.next({values:{...X}}),y.state.next({name:void 0,type:void 0,values:{...X}})}l={mount:M.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},s.mount=!b.isValid||!!M.keepIsValid||!!M.keepDirtyValues||!t.shouldUnregister&&!Gt(X),s.watch=!!t.shouldUnregister,s.keepIsValid=!!M.keepIsValid,s.action=!1,M.keepErrors||(r.errors={}),y.state.next({submitCount:M.keepSubmitCount?r.submitCount:0,isDirty:U?!1:M.keepDirty?r.isDirty:M.keepValues?W():!!(M.keepDefaultValues&&!qr(A,n)),isSubmitted:M.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:U?{}:M.keepDirtyValues?M.keepDefaultValues&&a?an(n,a,void 0,z):r.dirtyFields:M.keepDefaultValues&&A?an(n,A,void 0,z):M.keepDirty?r.dirtyFields:{},touchedFields:M.keepTouched?r.touchedFields:{},errors:M.keepErrors?r.errors:{},isSubmitSuccessful:M.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:n})},I=(A,M)=>Wt(gr(A)?A(a):A,{...t.resetOptions,...M}),F=(A,M={})=>{const L=pe(o,A),B=L&&L._f;if(B){const U=B.refs?B.refs[0]:B.ref;U.focus&&setTimeout(()=>{U.focus(),M.shouldSelect&&gr(U.select)&&U.select()})}},K=A=>{const{name:M,type:L,values:B,...U}=A;r={...r,...U}},se={control:{register:it,unregister:et,getFieldState:xe,handleSubmit:yt,setError:ae,_subscribe:ve,_runSchema:G,_updateIsValidating:N,_focusError:tt,_getWatch:R,_getDirty:W,_setValid:w,_setFieldArray:_,_setDisabledField:at,_setErrors:D,_getFieldArray:we,_reset:Wt,_resetDefaultValues:()=>gr(t.defaultValues)&&t.defaultValues().then(A=>{I(A,t.resetOptions),y.state.next({isLoading:!1})}),_removeUnmounted:J,_disableForm:$e,_subjects:y,_proxyFormState:b,get _fields(){return o},get _formValues(){return a},get _state(){return s},set _state(A){s=A},get _defaultValues(){return n},get _names(){return l},set _names(A){l=A},get _formState(){return r},get _options(){return t},set _options(A){t={...t,...A},u=ql(t.mode),f=ql(t.reValidateMode)}},subscribe:Oe,trigger:ce,register:it,handleSubmit:yt,watch:ue,setValue:de,setValues:Se,getValues:Ie,reset:I,resetField:Xt,resetDefaultValues:(A,M={})=>{if(n=ht(A),!M.keepDirty){const L=an(n,a,void 0,o);r.dirtyFields=L,r.isDirty=!Gt(L)}M.keepIsValid||w(),y.state.next({...r,defaultValues:n})},clearErrors:be,unregister:et,setError:ae,setFocus:F,getFieldState:xe};return{...se,formControl:se}}function jy(e={}){const t=P.useRef(void 0),r=P.useRef(void 0),o=P.useRef(e.formControl),[n,a]=P.useState(()=>({...ht(Hy),isLoading:gr(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:gr(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&o.current!==e.formControl)if(o.current=e.formControl,e.formControl)t.current={...e.formControl,formState:n},e.defaultValues&&!gr(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...c}=jP(e);t.current={...c,formState:n}}const s=t.current.control;return s._options=e,TP(()=>{const l=s._subscribe({formState:s._proxyFormState,callback:()=>a({...s._formState,defaultValues:s._defaultValues}),reRenderRoot:!0});return a(c=>({...c,isReady:!0})),s._formState.isReady=!0,l},[s]),P.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),P.useEffect(()=>{e.mode&&(s._options.mode=e.mode),e.reValidateMode&&(s._options.reValidateMode=e.reValidateMode)},[s,e.mode,e.reValidateMode]),P.useEffect(()=>{e.errors&&(s._setErrors(e.errors),s._focusError())},[s,e.errors]),P.useEffect(()=>{e.shouldUnregister&&s._subjects.state.next({values:s._getWatch()})},[s,e.shouldUnregister]),P.useEffect(()=>{if(s._proxyFormState.isDirty){const l=s._getDirty();l!==n.isDirty&&s._subjects.state.next({isDirty:l})}},[s,n.isDirty]),P.useEffect(()=>{var l;e.values&&!qr(e.values,r.current)?(s._reset(e.values,{keepFieldsRef:!0,...s._options.resetOptions}),!((l=s._options.resetOptions)===null||l===void 0)&&l.keepIsValid||s._setValid(),r.current=e.values,a(c=>({...c}))):s._resetDefaultValues()},[s,e.values]),P.useEffect(()=>{s._state.mount||(s._setValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),t.current.formState=P.useMemo(()=>_P(n,s),[s,n]),t.current}function qy(e){return["divider","paragraph","heading","link","image"].includes(e.type)?"layout":["submit","button"].includes(e.type)?"action":["pages","group","repeatGroup"].includes(e.type)?"container":"field"}function Yy(e,t){var a,s;const r=[],o=new Map,n=new Map;for(const l of t){const c=((a=l.attributes)==null?void 0:a.name)||l.id;o.set(c,l),n.set(l.id,l)}for(const[l,c]of Object.entries(e)){const d=o.get(l);if(d){if(d.parentId){const u=n.get(d.parentId);if(u&&(u.type==="repeatGroup"||u.type==="repeatElement")&&e[((s=u.attributes)==null?void 0:s.name)||u.id]!==void 0)continue}const p=qy(d);if(p==="layout"||p==="action")continue;r.push({id:l,value:c,type:d.type,category:p})}else r.push({id:l,value:c,type:"unknown",category:"field"})}return r}function Su(e,t,r="keyValue"){return r==="array"?Yy(e,t):e}function qP(e,t){var a,s;const r={},o=new Map,n=new Map;for(const l of t){const c=((a=l.attributes)==null?void 0:a.name)||l.id;o.set(c,l),n.set(l.id,l)}for(const[l,c]of Object.entries(e)){const d=o.get(l);if(d){if(d.parentId){const u=n.get(d.parentId);if(u&&(u.type==="repeatGroup"||u.type==="repeatElement")&&e[((s=u.attributes)==null?void 0:s.name)||u.id]!==void 0)continue}const p=qy(d);(p==="field"||p==="container")&&(r[l]=c)}else r[l]=c}return r}const YP=({currentPage:e,totalPages:t,pages:r,showStepNumbers:o,onPageClick:n})=>{const a=(e+1)/t*100;return i.jsxs("div",{className:m("mb-8"),children:[i.jsx("div",{className:m("h-2 bg-gray-200 rounded-full overflow-hidden"),children:i.jsx("div",{className:m("h-full bg-blue-600 transition-all duration-300 ease-out"),style:{width:`${a}%`}})}),o&&i.jsx("div",{className:m("flex justify-between mt-4"),children:r.map((s,l)=>{const c=l<e,d=l===e;return i.jsxs("button",{type:"button",onClick:()=>n==null?void 0:n(l),disabled:l>e,className:m(`flex flex-col items-center ${n&&l<=e?"cursor-pointer":"cursor-default"}`),children:[i.jsx("div",{className:m(`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors ${c?"bg-blue-600 text-white":d?"bg-blue-600 text-white ring-4 ring-blue-100":"bg-gray-200 text-gray-500"}`),children:c?i.jsx("svg",{className:m("w-4 h-4"),fill:"currentColor",viewBox:"0 0 20 20",children:i.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):l+1}),i.jsx("span",{className:m(`mt-2 text-xs font-medium ${d?"text-blue-600":"text-gray-500"}`),children:s.title})]},s.id)})})]})},QP=({page:e,pageIndex:t,totalPages:r})=>i.jsxs("div",{className:m("mb-6"),children:[i.jsxs("div",{className:m("flex items-center justify-between mb-2"),children:[i.jsx("h2",{className:m("text-xl font-semibold text-gray-900"),children:e.title}),i.jsxs("span",{className:m("text-sm text-gray-500"),children:["Step ",t+1," of ",r]})]}),e.description&&i.jsx("p",{className:m("text-gray-600"),children:e.description})]}),KP=({currentPage:e,totalPages:t,allowSkip:r,isSubmitting:o,nextButtonLabel:n,onPrevious:a,onNext:s,onSkip:l})=>{const c=e===0,d=e===t-1;return i.jsxs("div",{className:m("flex items-center justify-between mt-8 pt-6 border-t border-gray-200"),children:[i.jsx("div",{children:!c&&i.jsx("button",{type:"button",onClick:a,className:m("px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"),children:"← Previous"})}),i.jsxs("div",{className:m("flex gap-3"),children:[r&&!d&&i.jsx("button",{type:"button",onClick:l,className:m("px-4 py-2 text-sm font-medium text-gray-500 hover:text-gray-700"),children:"Skip"}),d?i.jsx("button",{type:"submit",disabled:o,className:m("px-6 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"),children:o?"Submitting...":"Submit"}):i.jsxs("button",{type:"button",onClick:s,className:m("px-6 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500"),children:[n," →"]})]})]})},Qy=({element:e,elements:t})=>{const{setValue:r,watch:o,register:n,unregister:a}=yu(),s=o(),{visible:l,required:c,disabled:d}=P.useMemo(()=>Gg(e,s,t),[e,s,t]),p=e.attributes.name;if(P.useEffect(()=>{var N,k,_,E,D,T;if(p){if(!l){a(p,{keepValue:!0});return}return n(p,{required:c?((N=e.validation)==null?void 0:N.errorMessage)||"This field is required":void 0,minLength:(k=e.validation)==null?void 0:k.minLength,maxLength:(_=e.validation)==null?void 0:_.maxLength,min:(E=e.validation)==null?void 0:E.min,max:(D=e.validation)==null?void 0:D.max,pattern:XP((T=e.validation)==null?void 0:T.pattern),disabled:d||e.properties.disabled||void 0}),()=>a(p,{keepValue:!0})}},[p,l,c,d,e.validation,e.properties.disabled,n,a]),!l)return null;const u=o(p),f=d||e.properties.disabled||!1,h={small:"max-w-xs",medium:"max-w-md",large:"max-w-lg",full:"w-full",default:"max-w-md"},b=h[e.layout.size||"default"]||h.default,g=vt.get(e.type),y=(N,k)=>{const _=t.filter(E=>E.parentId===N).sort((E,D)=>E.order-D.order);return i.jsx("div",{className:m("space-y-4"),children:_.map(E=>i.jsx(Qy,{element:{...E,attributes:{...E.attributes,name:k?`${k}.${E.attributes.name}`:E.attributes.name}},elements:t},E.id))})},v={element:e,properties:e.properties,layout:e.layout,validation:{...e.validation,required:c},logic:e.logic,config:e.config,mode:"render",value:u,onChange:N=>r(p,N),errors:[],formValues:s,readOnly:!1,disabled:f,allElements:t,renderChildren:y},S=()=>g!=null&&g.render?g.render(v):i.jsxs("div",{className:m("p-3 bg-yellow-50 border border-yellow-200 rounded-md text-sm text-yellow-700"),children:[i.jsxs("p",{className:m("font-medium"),children:["Unknown element type: ",e.type]}),i.jsxs("p",{className:m("text-xs mt-1"),children:["This element is not registered in the element registry. Please register it using ",i.jsx("code",{children:"registerElement()"}),"."]})]});return(g==null?void 0:g.structure)==="page"&&["heading","layout","special"].includes(g.subCategory||"")||["paragraph","image","link","formHeading","sectionHeading","subheading","divider","spacer","captcha","submit"].includes(e.type)?i.jsx("div",{className:m(b,"mb-4"),children:S()}):i.jsx("div",{className:m(b,"mb-4"),children:S()})};function RP(e){var o,n,a;if(e.attributes.defaultValue!==void 0)return e.attributes.defaultValue;const t=vt.get(e.type);switch(t==null?void 0:t.dataType){case"array":return[];case"boolean":return!1;case"number":return((o=e.config)==null?void 0:o.min)??0;case"object":return e.type==="rangeSlider"?[((n=e.config)==null?void 0:n.min)??0,((a=e.config)==null?void 0:a.max)??100]:e.type==="dateRange"?{start:"",end:""}:{};default:return""}}function XP(e){if(e)try{return new RegExp(e)}catch{return}}function JP(e){const t={};return e.forEach(r=>{var o;(o=r.attributes)!=null&&o.name&&(t[r.attributes.name]=RP(r))}),t}function ZP(e,t){const r=[],o=n=>{var a;for(const s of n)(a=s.attributes)!=null&&a.name&&r.push(s.attributes.name),o(t.filter(l=>l.parentId===s.id))};return o(e),r}const Nu=({schema:e,onSubmit:t,initialValues:r,onPageChange:o,submissionFormat:n="keyValue",debug:a=!1})=>{const[s,l]=P.useState(0),[c,d]=P.useState(!1),[p,u]=P.useState(null),f=P.useMemo(()=>e.elements.find(O=>O.type==="pages"),[e.elements]),h=P.useMemo(()=>{var O,$,V,G,q,H;return{showProgressBar:((O=f==null?void 0:f.config)==null?void 0:O.showProgressBar)??!0,showStepNumbers:(($=f==null?void 0:f.config)==null?void 0:$.showStepNumbers)??!0,allowSkip:((V=f==null?void 0:f.config)==null?void 0:V.allowSkip)??!1,validateOnNext:((G=f==null?void 0:f.config)==null?void 0:G.validateOnNext)??!0,nextButtonLabel:((q=f==null?void 0:f.config)==null?void 0:q.nextButtonLabel)??"Next",steps:((H=f==null?void 0:f.config)==null?void 0:H.steps)||[{id:"step1",label:"Step 1"}]}},[f]),b=P.useMemo(()=>f?h.steps.map($=>{const V=e.elements.filter(G=>{var q;return G.parentId===`${f.id}:${$.id}`||G.parentId===f.id&&((q=G.config)==null?void 0:q.wizardStepId)===$.id});return{id:$.id,title:$.label,description:$.description,elements:V.sort((G,q)=>G.order-q.order)}}):[],[f,h.steps,e.elements]),g=P.useMemo(()=>e.elements.filter(O=>O.type!=="pages"),[e.elements]),y=P.useMemo(()=>r||JP(g),[r,g]),v=jy({defaultValues:y,mode:"onChange"}),{handleSubmit:S,trigger:x}=v,w=P.useCallback(O=>{O>=0&&O<b.length&&(l(O),o==null||o(O))},[b.length,o]),N=P.useCallback(()=>{w(s-1)},[s,w]),k=P.useCallback(async()=>{if(h.validateOnNext){const O=ZP(b[s].elements,e.elements);if(!await x(O))return}w(s+1)},[s,h.validateOnNext,b,e.elements,x,w]),_=P.useCallback(()=>{w(s+1)},[s,w]),E=P.useCallback(async O=>{d(!0);try{const $=Su(O,e.elements,n);console.log("Wizard form submitted:",$),a?u($):await(t==null?void 0:t($))}catch($){console.error("Form submission error:",$)}finally{d(!1)}},[t,e.elements,n,a]),D=P.useCallback(O=>{if(s<b.length-1){O.preventDefault(),k();return}S(E)(O)},[s,b.length,k,S,E]),T=b[s];return T?i.jsxs("div",{className:m("max-w-3xl mx-auto"),children:[i.jsx($y,{...v,children:i.jsxs("form",{onSubmit:D,className:m("space-y-1"),children:[h.showProgressBar&&i.jsx(YP,{currentPage:s,totalPages:b.length,pages:b,showStepNumbers:h.showStepNumbers,onPageClick:h.allowSkip?w:void 0}),i.jsx(QP,{page:T,pageIndex:s,totalPages:b.length}),i.jsx("div",{className:m("space-y-4"),children:T.elements.map(O=>i.jsx(Qy,{element:O,elements:e.elements},O.id))}),i.jsx(KP,{currentPage:s,totalPages:b.length,allowSkip:h.allowSkip,isSubmitting:c,nextButtonLabel:h.nextButtonLabel,onPrevious:N,onNext:k,onSkip:_})]})}),a&&p&&i.jsxs("div",{className:m("mt-8 p-4 bg-green-50 border border-green-200 rounded-lg"),children:[i.jsx("h3",{className:m("text-lg font-medium text-green-800 mb-2"),children:"Submitted Data:"}),i.jsx("pre",{className:m("text-sm text-green-700 overflow-x-auto"),children:JSON.stringify(p,null,2)})]})]}):i.jsxs("div",{className:m("p-8 text-center text-gray-500"),children:[i.jsx("p",{children:"No wizard steps configured."}),i.jsx("p",{className:m("text-sm mt-2"),children:"Add steps to the wizard element to create a multi-page form."})]})};function e2(e){var o,n,a;if(e.attributes.defaultValue!==void 0)return e.attributes.defaultValue;const t=vt.get(e.type);switch(t==null?void 0:t.dataType){case"array":return[];case"boolean":return!1;case"number":return((o=e.config)==null?void 0:o.min)??0;case"object":return e.type==="rangeSlider"?[((n=e.config)==null?void 0:n.min)??0,((a=e.config)==null?void 0:a.max)??100]:e.type==="dateRange"?{start:"",end:""}:{};default:return""}}function t2(e){const t={};return e.forEach(r=>{var o;(o=r.attributes)!=null&&o.name&&(t[r.attributes.name]=e2(r))}),t}const Ky=({element:e,elements:t})=>{const{watch:r}=yu(),o=r(),{visible:n,required:a,disabled:s}=P.useMemo(()=>Gg(e,o,t),[e,o,t]);return n?i.jsx(r2,{element:e,elements:t,dynamicRequired:a,dynamicDisabled:s}):null},r2=({element:e,elements:t,dynamicRequired:r,dynamicDisabled:o})=>{const{setValue:n,watch:a}=yu(),s=e.attributes.name,l=a(s),c=o||e.properties.disabled||!1,d=r,p={small:"max-w-xs",medium:"max-w-md",large:"max-w-lg",full:"w-full",default:"max-w-md"},u=p[e.layout.size||"default"]||p.default,f=vt.get(e.type),h=(S,x)=>{const w=t.filter(N=>N.parentId===S).sort((N,k)=>N.order-k.order);return i.jsx("div",{className:m("space-y-4"),children:w.map(N=>i.jsx(Ky,{element:{...N,attributes:{...N.attributes,name:x?`${x}.${N.attributes.name}`:N.attributes.name}},elements:t},N.id))})},b={element:e,properties:e.properties,layout:e.layout,validation:{...e.validation,required:d},logic:e.logic,config:e.config,mode:"render",value:l,onChange:S=>n(s,S),errors:[],formValues:a(),readOnly:!1,disabled:c,allElements:t,renderChildren:h},g=()=>f!=null&&f.render?f.render(b):i.jsxs("div",{className:m("p-3 bg-yellow-50 border border-yellow-200 rounded-md text-sm text-yellow-700"),children:[i.jsxs("p",{className:m("font-medium"),children:["Unknown element type: ",e.type]}),i.jsxs("p",{className:m("text-xs mt-1"),children:["This element is not registered in the element registry. Please register it using ",i.jsx("code",{children:"registerElement()"}),"."]})]});return(f==null?void 0:f.structure)==="page"&&["heading","layout","special"].includes(f.subCategory||"")||["paragraph","image","link","formHeading","sectionHeading","subheading","divider","spacer","captcha","submit"].includes(e.type)?i.jsx("div",{className:m(u,"mb-4"),children:g()}):i.jsx("div",{className:m(u,"mb-4"),children:g()})},Ry=({schema:e,onSubmit:t,initialValues:r,submissionFormat:o="keyValue",debug:n=!1})=>{const[a,s]=P.useState(null);if(P.useMemo(()=>e.elements.some(h=>h.type==="pages"),[e.elements]))return i.jsx(Nu,{schema:e,onSubmit:t,initialValues:r,submissionFormat:o,debug:n});const c=P.useMemo(()=>e.elements.filter(h=>!h.parentId),[e.elements]),d=P.useMemo(()=>r||t2(c),[r,c]),p=jy({defaultValues:d,mode:"onChange"}),u=P.useCallback(h=>{const b=Su(h,e.elements,o);console.log("Form submitted:",b),n?s(b):t==null||t(b)},[t,e.elements,o,n]),f=P.useMemo(()=>[...c].sort((h,b)=>h.order-b.order),[c]);return i.jsxs("div",{className:m("max-w-3xl mx-auto"),children:[i.jsx($y,{...p,children:i.jsxs("form",{onSubmit:p.handleSubmit(u),className:m("space-y-1"),children:[i.jsx("div",{className:m(""),children:e.description&&i.jsx("p",{className:m("mt-2 text-gray-600"),children:e.description})}),i.jsx("div",{className:m("space-y-4"),children:f.map(h=>i.jsx(Ky,{element:h,elements:e.elements},h.id))})]})}),n&&a&&i.jsxs("div",{className:m("mt-8 p-4 bg-green-50 border border-green-200 rounded-lg"),children:[i.jsx("h3",{className:m("text-lg font-medium text-green-800 mb-2"),children:"Submitted Data:"}),i.jsx("pre",{className:m("text-sm text-green-700 overflow-x-auto"),children:JSON.stringify(a,null,2)})]})]})},Xy=C.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:m("rounded-xl border bg-card text-card-foreground shadow",e),...t}));Xy.displayName="Card";const o2=C.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:m("flex flex-col space-y-1.5 p-6",e),...t}));o2.displayName="CardHeader";const n2=C.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:m("font-semibold leading-none tracking-tight",e),...t}));n2.displayName="CardTitle";const a2=C.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:m("text-sm text-muted-foreground",e),...t}));a2.displayName="CardDescription";const Jy=C.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:m("p-6 pt-0",e),...t}));Jy.displayName="CardContent";const s2=C.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:m("flex items-center p-6 pt-0",e),...t}));s2.displayName="CardFooter";const l2=Is("relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Zy=C.forwardRef(({className:e,variant:t,...r},o)=>i.jsx("div",{ref:o,role:"alert",className:m(l2({variant:t}),e),...r}));Zy.displayName="Alert";const ev=C.forwardRef(({className:e,...t},r)=>i.jsx("h5",{ref:r,className:m("mb-1 font-medium leading-none tracking-tight",e),...t}));ev.displayName="AlertTitle";const tv=C.forwardRef(({className:e,...t},r)=>i.jsx("div",{ref:r,className:m("text-sm [&_p]:leading-relaxed",e),...t}));tv.displayName="AlertDescription";const i2={id:"design",label:"Design Mode",icon:N1,order:0,keyboardShortcut:"d",description:"Edit your form layout and properties",renderContent:(e,t)=>i.jsxs(i.Fragment,{children:[t==null?void 0:t.ElementSidebar,t==null?void 0:t.Canvas,t==null?void 0:t.PropertyPanel]})},c2={id:"preview",label:"Preview Mode",icon:yh,order:10,keyboardShortcut:"p",description:"Preview your form as an end user",renderContent:(e,t)=>{const{schema:r,setMode:o,submissionFormat:n,onSubmit:a}=e,s=r.elements.some(c=>c.type==="pages"),l=c=>{console.log("Form submitted:",c),a==null||a(c)};return i.jsx("div",{className:m("flex-1 overflow-y-auto bg-muted/30"),children:i.jsxs("div",{className:m("py-8 px-4"),children:[i.jsx("div",{className:m("max-w-3xl mx-auto mb-6"),children:i.jsxs("div",{className:m("flex items-center justify-between"),children:[i.jsxs("div",{className:m("flex items-center gap-2 text-sm text-muted-foreground"),children:[i.jsx(yh,{className:m("h-4","w-4")}),i.jsx("span",{children:"Preview Mode"}),s&&i.jsx(vc,{variant:"secondary",children:"Wizard Form"})]}),i.jsxs(st,{variant:"ghost",size:"sm",onClick:()=>o("design"),children:[i.jsx(w1,{className:m("h-4","w-4","mr-1")}),"Back to Editor"]})]})}),i.jsx(Xy,{className:m("max-w-3xl mx-auto"),children:i.jsx(Jy,{className:m("p-8"),children:r.elements.length===0?i.jsxs("div",{className:m("text-center py-12 text-muted-foreground"),children:[i.jsx(S1,{className:m("h-12","w-12","mx-auto","mb-4","text-muted-foreground/50")}),i.jsx("p",{className:m("text-lg font-medium mb-2"),children:"No elements to preview"}),i.jsx("p",{className:m("text-sm"),children:"Switch to Design mode and add some elements to your form."})]}):s?i.jsx(Nu,{schema:r,onSubmit:l,submissionFormat:n}):i.jsx(Ry,{schema:r,onSubmit:l,submissionFormat:n})})}),r.elements.some(c=>c.logic)&&i.jsx("div",{className:m("max-w-3xl mx-auto mt-6"),children:i.jsxs(Zy,{children:[i.jsx(vh,{className:m("h-4","w-4")}),i.jsx(ev,{children:"Conditional Logic Active"}),i.jsx(tv,{children:"This form has conditional logic rules. Some fields may show/hide based on your input."})]})})]})})}};function rv(){tr.has("design")||tr.register(i2),tr.has("preview")||tr.register(c2)}rv();const ov=({initialSchema:e,onSchemaChange:t,toolbarActions:r,toolbarConfig:o,sidebarTabs:n,sidebarConfig:a,onPreviewSubmit:s,showElementSidebar:l=!0,showPropertyPanel:c=!0,submissionFormat:d="array",className:p})=>{const u=ie(w=>w.mode),f=ie(w=>w.setMode),h=ie(w=>w.schema),b=ie(w=>w.loadSchema);P.useEffect(()=>Pw(),[]),P.useEffect(()=>{e&&b(e)},[e,b]),P.useEffect(()=>{t&&t(h)},[h,t]);const g=r||o?{...o,actions:[...(o==null?void 0:o.actions)??[],...r??[]]}:void 0,y=n||a!=null&&a.tabs?[...(a==null?void 0:a.tabs)??[],...n??[]]:void 0,v=tr.get(u),S=P.useMemo(()=>({schema:h,currentMode:u,setMode:f,submissionFormat:d,onSubmit:s,showElementSidebar:l,showPropertyPanel:c,loadSchema:b}),[h,u,f,d,s,l,c,b]),x=P.useMemo(()=>({ElementSidebar:l?i.jsx(hk,{sidebarTabs:y}):void 0,Canvas:i.jsx(Ok,{toolbarConfig:g}),PropertyPanel:c?i.jsx(SP,{}):void 0}),[l,y,g,c]);return i.jsx("div",{className:m("ep-main-layout h-screen flex flex-col bg-muted/50",p),children:i.jsx("div",{className:m("flex-1 flex overflow-hidden"),children:v?v.renderContent(S,x):null})})};le.AffixInput=Si,le.CanvasElementRenderer=Ms,le.CanvasPreviewWrapper=$x,le.ElementDescription=rs,le.ElementLabel=ts,le.EmptyState=Px,le.EntryPulse=ov,le.ErrorMessages=Vn,le.FieldWrapper=Dx,le.FormElementRenderer=Nh,le.FormPreview=Ry,le.IconInput=Io,le.InputWrapper=ge,le.WizardForm=Nu,le.builtInElements=Sh,le.createSidebarTab=sm,le.createSidebarTabs=fk,le.createToolbarAction=um,le.createToolbarActions=Sk,le.default=ov,le.elementRegistry=vt,le.extractContextValues=oe,le.filterFieldData=qP,le.getButtonClassName=Mx,le.getCanvasInputClassName=Ot,le.getElementDefinition=Vw,le.getElementIcon=Eh,le.getElementLabel=yc,le.getInputClassName=qt,le.getModeDefinition=_k,le.hasElement=Gw,le.hasMode=Tk,le.isActionDisabled=fm,le.isActionHidden=Vc,le.isElementRegistered=iE,le.isSidebarTabDisabled=lm,le.isSidebarTabHidden=im,le.modeRegistry=tr,le.registerBuiltInElements=H1,le.registerBuiltinModes=rv,le.registerElement=Iw,le.registerElements=Lw,le.registerMode=Ek,le.registerModes=kk,le.renderElement=dE,le.renderElementOnCanvas=cE,le.transformSubmissionData=Su,le.transformToArrayFormat=Yy,le.unregisterElement=Fw,le.unregisterMode=Ak,le.useFormStore=ie,Object.defineProperties(le,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
204
209
  //# sourceMappingURL=entry-pulse.umd.cjs.map