@dipusevilla/componentes-iu 1.1.8 → 1.1.9

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.
package/dist/index.cjs.js CHANGED
@@ -53,7 +53,7 @@ React keys must be passed directly to JSX without using spread:
53
53
  text-[var(--color-ds-text-on-accent)] \r
54
54
  rounded-tr-[20px] \r
55
55
  pl-4 pr-10\r
56
- text-ds-lg`,children:e}),t&&s.jsx("div",{className:"flex items-center space-x-2",children:t})]}),s.jsx("main",{className:"flex-1 overflow-auto",children:r})]})}function Ir(e,t,r={}){if(!e)return{};const n={};for(const[o,l]of Object.entries(e))if(l.type==="static")n[o]=l.value;else if(l.type==="field"&&l.fieldRef)n[o]=t(l.fieldRef);else if(l.type==="system"&&l.systemVar)n[o]=r[l.systemVar]??null;else if(l.type==="session"&&l.storageKey)try{n[o]=typeof window<"u"?window.sessionStorage.getItem(l.storageKey):null}catch(i){console.warn("Error reading sessionStorage:",i),n[o]=null}else if(l.type==="local"&&l.storageKey)try{n[o]=typeof window<"u"?window.localStorage.getItem(l.storageKey):null}catch(i){console.warn("Error reading localStorage:",i),n[o]=null}return n}function ho(e,t){return t?t.key:e}const jc=(e,t,r)=>{if(e&&"reportValidity"in e){const n=be(r,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},r5=(e,t)=>{for(const r in t.fields){const n=t.fields[r];n&&n.ref&&"reportValidity"in n.ref?jc(n.ref,r,e):n&&n.refs&&n.refs.forEach(o=>jc(o,r,e))}},vM=(e,t)=>{t.shouldUseNativeValidation&&r5(e,t);const r={};for(const n in e){const o=be(t.fields,n),l=Object.assign(e[n]||{},{ref:o&&o.ref});if(bM(t.names||Object.keys(e),n)){const i=Object.assign({},be(r,n));Ue(i,"root",l),Ue(r,n,i)}else Ue(r,n,l)}return r},bM=(e,t)=>{const r=kc(t);return e.some(n=>kc(n).match(`^${r}\\.\\d+`))};function kc(e){return e.replace(/\]|\[/g,"")}function ii(e,t,r){return r===void 0&&(r={}),function(n,o,l){try{return Promise.resolve((function(i,c){try{var u=(t!=null&&t.context&&process.env.NODE_ENV==="development"&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(e[r.mode==="sync"?"validateSync":"validate"](n,Object.assign({abortEarly:!1},t,{context:o}))).then(function(d){return l.shouldUseNativeValidation&&r5({},l),{values:r.raw?Object.assign({},n):d,errors:{}}}))}catch(d){return c(d)}return u&&u.then?u.then(void 0,c):u})(0,function(i){if(!i.inner)throw i;return{values:{},errors:vM((c=i,u=!l.shouldUseNativeValidation&&l.criteriaMode==="all",(c.inner||[]).reduce(function(d,m){if(d[m.path]||(d[m.path]={message:m.message,type:m.type}),u){var f=d[m.path].types,h=f&&f[m.type];d[m.path]=Pd(m.path,u,d,m.type,h?[].concat(h,m.message):m.message)}return d},{})),l)};var c,u}))}catch(i){return Promise.reject(i)}}}var js,Ec;function xM(){if(Ec)return js;Ec=1;function e(x){this._maxSize=x,this.clear()}e.prototype.clear=function(){this._size=0,this._values=Object.create(null)},e.prototype.get=function(x){return this._values[x]},e.prototype.set=function(x,w){return this._size>=this._maxSize&&this.clear(),x in this._values||this._size++,this._values[x]=w};var t=/[^.^\]^[]+|(?=\[\]|\.\.)/g,r=/^\d+$/,n=/^\d/,o=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,l=/^\s*(['"]?)(.*?)(\1)\s*$/,i=512,c=new e(i),u=new e(i),d=new e(i);js={Cache:e,split:f,normalizePath:m,setter:function(x){var w=m(x);return u.get(x)||u.set(x,function(k,y){for(var C=0,N=w.length,M=k;C<N-1;){var $=w[C];if($==="__proto__"||$==="constructor"||$==="prototype")return k;M=M[w[C++]]}M[w[C]]=y})},getter:function(x,w){var j=m(x);return d.get(x)||d.set(x,function(y){for(var C=0,N=j.length;C<N;)if(y!=null||!w)y=y[j[C++]];else return;return y})},join:function(x){return x.reduce(function(w,j){return w+(p(j)||r.test(j)?"["+j+"]":(w?".":"")+j)},"")},forEach:function(x,w,j){h(Array.isArray(x)?x:f(x),w,j)}};function m(x){return c.get(x)||c.set(x,f(x).map(function(w){return w.replace(l,"$2")}))}function f(x){return x.match(t)||[""]}function h(x,w,j){var k=x.length,y,C,N,M;for(C=0;C<k;C++)y=x[C],y&&(g(y)&&(y='"'+y+'"'),M=p(y),N=!M&&/^\d+$/.test(y),w.call(j,y,M,N,C,x))}function p(x){return typeof x=="string"&&x&&["'",'"'].indexOf(x.charAt(0))!==-1}function v(x){return x.match(n)&&!x.match(r)}function b(x){return o.test(x)}function g(x){return!p(x)&&(v(x)||b(x))}return js}var Zr=xM(),ks,Rc;function wM(){if(Rc)return ks;Rc=1;const e=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,t=m=>m.match(e)||[],r=m=>m[0].toUpperCase()+m.slice(1),n=(m,f)=>t(m).join(f).toLowerCase(),o=m=>t(m).reduce((f,h)=>`${f}${f?h[0].toUpperCase()+h.slice(1).toLowerCase():h.toLowerCase()}`,"");return ks={words:t,upperFirst:r,camelCase:o,pascalCase:m=>r(o(m)),snakeCase:m=>n(m,"_"),kebabCase:m=>n(m,"-"),sentenceCase:m=>r(n(m," ")),titleCase:m=>t(m).map(r).join(" ")},ks}var Es=wM(),$a={exports:{}},Cc;function yM(){if(Cc)return $a.exports;Cc=1,$a.exports=function(o){return e(t(o),o)},$a.exports.array=e;function e(o,l){var i=o.length,c=new Array(i),u={},d=i,m=r(l),f=n(o);for(l.forEach(function(p){if(!f.has(p[0])||!f.has(p[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});d--;)u[d]||h(o[d],d,new Set);return c;function h(p,v,b){if(b.has(p)){var g;try{g=", node was:"+JSON.stringify(p)}catch{g=""}throw new Error("Cyclic dependency"+g)}if(!f.has(p))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(p));if(!u[v]){u[v]=!0;var x=m.get(p)||new Set;if(x=Array.from(x),v=x.length){b.add(p);do{var w=x[--v];h(w,f.get(w),b)}while(v);b.delete(p)}c[--i]=p}}}function t(o){for(var l=new Set,i=0,c=o.length;i<c;i++){var u=o[i];l.add(u[0]),l.add(u[1])}return Array.from(l)}function r(o){for(var l=new Map,i=0,c=o.length;i<c;i++){var u=o[i];l.has(u[0])||l.set(u[0],new Set),l.has(u[1])||l.set(u[1],new Set),l.get(u[0]).add(u[1])}return l}function n(o){for(var l=new Map,i=0,c=o.length;i<c;i++)l.set(o[i],i);return l}return $a.exports}var jM=yM();const kM=H0(jM),EM=Object.prototype.toString,RM=Error.prototype.toString,CM=RegExp.prototype.toString,SM=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",NM=/^Symbol\((.*)\)(.*)$/;function MM(e){return e!=+e?"NaN":e===0&&1/e<0?"-0":""+e}function Sc(e,t=!1){if(e==null||e===!0||e===!1)return""+e;const r=typeof e;if(r==="number")return MM(e);if(r==="string")return t?`"${e}"`:e;if(r==="function")return"[Function "+(e.name||"anonymous")+"]";if(r==="symbol")return SM.call(e).replace(NM,"Symbol($1)");const n=EM.call(e).slice(8,-1);return n==="Date"?isNaN(e.getTime())?""+e:e.toISOString(e):n==="Error"||e instanceof Error?"["+RM.call(e)+"]":n==="RegExp"?CM.call(e):null}function ur(e,t){let r=Sc(e,t);return r!==null?r:JSON.stringify(e,function(n,o){let l=Sc(this[n],t);return l!==null?l:o},2)}function n5(e){return e==null?[]:[].concat(e)}let a5,o5,s5,AM=/\$\{\s*(\w+)\s*\}/g;a5=Symbol.toStringTag;class Nc{constructor(t,r,n,o){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[a5]="Error",this.name="ValidationError",this.value=r,this.path=n,this.type=o,this.errors=[],this.inner=[],n5(t).forEach(l=>{if(gt.isError(l)){this.errors.push(...l.errors);const i=l.inner.length?l.inner:[l];this.inner.push(...i)}else this.errors.push(l)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}}o5=Symbol.hasInstance;s5=Symbol.toStringTag;class gt extends Error{static formatError(t,r){const n=r.label||r.path||"this";return r=Object.assign({},r,{path:n,originalPath:r.path}),typeof t=="string"?t.replace(AM,(o,l)=>ur(r[l])):typeof t=="function"?t(r):t}static isError(t){return t&&t.name==="ValidationError"}constructor(t,r,n,o,l){const i=new Nc(t,r,n,o);if(l)return i;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[s5]="Error",this.name=i.name,this.message=i.message,this.type=i.type,this.value=i.value,this.path=i.path,this.errors=i.errors,this.inner=i.inner,Error.captureStackTrace&&Error.captureStackTrace(this,gt)}static[o5](t){return Nc[Symbol.hasInstance](t)||super[Symbol.hasInstance](t)}}let Kt={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:e,type:t,value:r,originalValue:n})=>{const o=n!=null&&n!==r?` (cast from the value \`${ur(n,!0)}\`).`:".";return t!=="mixed"?`${e} must be a \`${t}\` type, but the final value was: \`${ur(r,!0)}\``+o:`${e} must match the configured type. The validated value was: \`${ur(r,!0)}\``+o}},wt={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},br={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},hl={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},pl={isValue:"${path} field must be ${value}"},Ja={noUnknown:"${path} field has unspecified keys: ${unknown}",exact:"${path} object contains unknown properties: ${properties}"},Ya={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},OM={notType:e=>{const{path:t,value:r,spec:n}=e,o=n.types.length;if(Array.isArray(r)){if(r.length<o)return`${t} tuple value has too few items, expected a length of ${o} but got ${r.length} for value: \`${ur(r,!0)}\``;if(r.length>o)return`${t} tuple value has too many items, expected a length of ${o} but got ${r.length} for value: \`${ur(r,!0)}\``}return gt.formatError(Kt.notType,e)}};Object.assign(Object.create(null),{mixed:Kt,string:wt,number:br,date:hl,object:Ja,array:Ya,boolean:pl,tuple:OM});const Wo=e=>e&&e.__isYupSchema__;class po{static fromOptions(t,r){if(!r.then&&!r.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:n,then:o,otherwise:l}=r,i=typeof n=="function"?n:(...c)=>c.every(u=>u===n);return new po(t,(c,u)=>{var d;let m=i(...c)?o:l;return(d=m==null?void 0:m(u))!=null?d:u})}constructor(t,r){this.fn=void 0,this.refs=t,this.refs=t,this.fn=r}resolve(t,r){let n=this.refs.map(l=>l.getValue(r==null?void 0:r.value,r==null?void 0:r.parent,r==null?void 0:r.context)),o=this.fn(n,t,r);if(o===void 0||o===t)return t;if(!Wo(o))throw new TypeError("conditions must return a schema object");return o.resolve(r)}}const Ia={context:"$",value:"."};class Ur{constructor(t,r={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof t!="string")throw new TypeError("ref must be a string, got: "+t);if(this.key=t.trim(),t==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===Ia.context,this.isValue=this.key[0]===Ia.value,this.isSibling=!this.isContext&&!this.isValue;let n=this.isContext?Ia.context:this.isValue?Ia.value:"";this.path=this.key.slice(n.length),this.getter=this.path&&Zr.getter(this.path,!0),this.map=r.map}getValue(t,r,n){let o=this.isContext?n:this.isValue?t:r;return this.getter&&(o=this.getter(o||{})),this.map&&(o=this.map(o)),o}cast(t,r){return this.getValue(t,r==null?void 0:r.parent,r==null?void 0:r.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(t){return t&&t.__isYupRef}}Ur.prototype.__isYupRef=!0;const Ht=e=>e==null;function Xr(e){function t({value:r,path:n="",options:o,originalValue:l,schema:i},c,u){const{name:d,test:m,params:f,message:h,skipAbsent:p}=e;let{parent:v,context:b,abortEarly:g=i.spec.abortEarly,disableStackTrace:x=i.spec.disableStackTrace}=o;const w={value:r,parent:v,context:b};function j(V={}){const I=l5(Object.assign({value:r,originalValue:l,label:i.spec.label,path:V.path||n,spec:i.spec,disableStackTrace:V.disableStackTrace||x},f,V.params),w),z=new gt(gt.formatError(V.message||h,I),r,I.path,V.type||d,I.disableStackTrace);return z.params=I,z}const k=g?c:u;let y={path:n,parent:v,type:d,from:o.from,createError:j,resolve(V){return i5(V,w)},options:o,originalValue:l,schema:i};const C=V=>{gt.isError(V)?k(V):V?u(null):k(j())},N=V=>{gt.isError(V)?k(V):c(V)};if(p&&Ht(r))return C(!0);let $;try{var T;if($=m.call(y,r,y),typeof((T=$)==null?void 0:T.then)=="function"){if(o.sync)throw new Error(`Validation test of type: "${y.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve($).then(C,N)}}catch(V){N(V);return}C($)}return t.OPTIONS=e,t}function l5(e,t){if(!e)return e;for(const r of Object.keys(e))e[r]=i5(e[r],t);return e}function i5(e,t){return Ur.isRef(e)?e.getValue(t.value,t.parent,t.context):e}function LM(e,t,r,n=r){let o,l,i;return t?(Zr.forEach(t,(c,u,d)=>{let m=u?c.slice(1,c.length-1):c;e=e.resolve({context:n,parent:o,value:r});let f=e.type==="tuple",h=d?parseInt(m,10):0;if(e.innerType||f){if(f&&!d)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${i}" must contain an index to the tuple element, e.g. "${i}[0]"`);if(r&&h>=r.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${c}, in the path: ${t}. because there is no value at that index. `);o=r,r=r&&r[h],e=f?e.spec.types[h]:e.innerType}if(!d){if(!e.fields||!e.fields[m])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${i} which is a type: "${e.type}")`);o=r,r=r&&r[m],e=e.fields[m]}l=m,i=u?"["+c+"]":"."+c}),{schema:e,parent:o,parentPath:l}):{parent:o,parentPath:t,schema:e}}class go extends Set{describe(){const t=[];for(const r of this.values())t.push(Ur.isRef(r)?r.describe():r);return t}resolveAll(t){let r=[];for(const n of this.values())r.push(t(n));return r}clone(){return new go(this.values())}merge(t,r){const n=this.clone();return t.forEach(o=>n.add(o)),r.forEach(o=>n.delete(o)),n}}function on(e,t=new Map){if(Wo(e)||!e||typeof e!="object")return e;if(t.has(e))return t.get(e);let r;if(e instanceof Date)r=new Date(e.getTime()),t.set(e,r);else if(e instanceof RegExp)r=new RegExp(e),t.set(e,r);else if(Array.isArray(e)){r=new Array(e.length),t.set(e,r);for(let n=0;n<e.length;n++)r[n]=on(e[n],t)}else if(e instanceof Map){r=new Map,t.set(e,r);for(const[n,o]of e.entries())r.set(n,on(o,t))}else if(e instanceof Set){r=new Set,t.set(e,r);for(const n of e)r.add(on(n,t))}else if(e instanceof Object){r={},t.set(e,r);for(const[n,o]of Object.entries(e))r[n]=on(o,t)}else throw Error(`Unable to clone ${e}`);return r}function $M(e){if(!(e!=null&&e.length))return;const t=[];let r="",n=!1,o=!1;for(let l=0;l<e.length;l++){const i=e[l];if(i==="["&&!o){r&&(t.push(...r.split(".").filter(Boolean)),r=""),n=!0;continue}if(i==="]"&&!o){r&&(/^\d+$/.test(r)?t.push(r):t.push(r.replace(/^"|"$/g,"")),r=""),n=!1;continue}if(i==='"'){o=!o;continue}if(i==="."&&!n&&!o){r&&(t.push(r),r="");continue}r+=i}return r&&t.push(...r.split(".").filter(Boolean)),t}function IM(e,t){const r=t?`${t}.${e.path}`:e.path;return e.errors.map(n=>({message:n,path:$M(r)}))}function c5(e,t){var r;if(!((r=e.inner)!=null&&r.length)&&e.errors.length)return IM(e,t);const n=t?`${t}.${e.path}`:e.path;return e.inner.flatMap(o=>c5(o,n))}class Rt{constructor(t){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new go,this._blacklist=new go,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(Kt.notType)}),this.type=t.type,this._typeCheck=t.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},t==null?void 0:t.spec),this.withMutation(r=>{r.nonNullable()})}get _type(){return this.type}clone(t){if(this._mutate)return t&&Object.assign(this.spec,t),this;const r=Object.create(Object.getPrototypeOf(this));return r.type=this.type,r._typeCheck=this._typeCheck,r._whitelist=this._whitelist.clone(),r._blacklist=this._blacklist.clone(),r.internalTests=Object.assign({},this.internalTests),r.exclusiveTests=Object.assign({},this.exclusiveTests),r.deps=[...this.deps],r.conditions=[...this.conditions],r.tests=[...this.tests],r.transforms=[...this.transforms],r.spec=on(Object.assign({},this.spec,t)),r}label(t){let r=this.clone();return r.spec.label=t,r}meta(...t){if(t.length===0)return this.spec.meta;let r=this.clone();return r.spec.meta=Object.assign(r.spec.meta||{},t[0]),r}withMutation(t){let r=this._mutate;this._mutate=!0;let n=t(this);return this._mutate=r,n}concat(t){if(!t||t===this)return this;if(t.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${t.type}`);let r=this,n=t.clone();const o=Object.assign({},r.spec,n.spec);return n.spec=o,n.internalTests=Object.assign({},r.internalTests,n.internalTests),n._whitelist=r._whitelist.merge(t._whitelist,t._blacklist),n._blacklist=r._blacklist.merge(t._blacklist,t._whitelist),n.tests=r.tests,n.exclusiveTests=r.exclusiveTests,n.withMutation(l=>{t.tests.forEach(i=>{l.test(i.OPTIONS)})}),n.transforms=[...r.transforms,...n.transforms],n}isType(t){return t==null?!!(this.spec.nullable&&t===null||this.spec.optional&&t===void 0):this._typeCheck(t)}resolve(t){let r=this;if(r.conditions.length){let n=r.conditions;r=r.clone(),r.conditions=[],r=n.reduce((o,l)=>l.resolve(o,t),r),r=r.resolve(t)}return r}resolveOptions(t){var r,n,o,l;return Object.assign({},t,{from:t.from||[],strict:(r=t.strict)!=null?r:this.spec.strict,abortEarly:(n=t.abortEarly)!=null?n:this.spec.abortEarly,recursive:(o=t.recursive)!=null?o:this.spec.recursive,disableStackTrace:(l=t.disableStackTrace)!=null?l:this.spec.disableStackTrace})}cast(t,r={}){let n=this.resolve(Object.assign({},r,{value:t})),o=r.assert==="ignore-optionality",l=n._cast(t,r);if(r.assert!==!1&&!n.isType(l)){if(o&&Ht(l))return l;let i=ur(t),c=ur(l);throw new TypeError(`The value of ${r.path||"field"} could not be cast to a value that satisfies the schema type: "${n.type}".
56
+ text-ds-lg`,children:e}),t&&s.jsx("div",{className:"flex items-center space-x-2",children:t})]}),s.jsx("main",{className:"flex-1 overflow-auto",children:r})]})}function Ir(e,t,r={}){if(!e)return{};const n={};for(const[o,l]of Object.entries(e)){const i=o.toLowerCase();if(l.type==="static")n[i]=l.value;else if(l.type==="field"&&l.fieldRef)n[i]=t(l.fieldRef);else if(l.type==="system"&&l.systemVar)n[i]=r[l.systemVar]??null;else if(l.type==="session"&&l.storageKey)try{n[i]=typeof window<"u"?window.sessionStorage.getItem(l.storageKey):null}catch(c){console.warn("Error reading sessionStorage:",c),n[i]=null}else if(l.type==="local"&&l.storageKey)try{n[i]=typeof window<"u"?window.localStorage.getItem(l.storageKey):null}catch(c){console.warn("Error reading localStorage:",c),n[i]=null}}return n}function ho(e,t){return t?t.key:e}const jc=(e,t,r)=>{if(e&&"reportValidity"in e){const n=be(r,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},r5=(e,t)=>{for(const r in t.fields){const n=t.fields[r];n&&n.ref&&"reportValidity"in n.ref?jc(n.ref,r,e):n&&n.refs&&n.refs.forEach(o=>jc(o,r,e))}},vM=(e,t)=>{t.shouldUseNativeValidation&&r5(e,t);const r={};for(const n in e){const o=be(t.fields,n),l=Object.assign(e[n]||{},{ref:o&&o.ref});if(bM(t.names||Object.keys(e),n)){const i=Object.assign({},be(r,n));Ue(i,"root",l),Ue(r,n,i)}else Ue(r,n,l)}return r},bM=(e,t)=>{const r=kc(t);return e.some(n=>kc(n).match(`^${r}\\.\\d+`))};function kc(e){return e.replace(/\]|\[/g,"")}function ii(e,t,r){return r===void 0&&(r={}),function(n,o,l){try{return Promise.resolve((function(i,c){try{var u=(t!=null&&t.context&&process.env.NODE_ENV==="development"&&console.warn("You should not used the yup options context. Please, use the 'useForm' context object instead"),Promise.resolve(e[r.mode==="sync"?"validateSync":"validate"](n,Object.assign({abortEarly:!1},t,{context:o}))).then(function(d){return l.shouldUseNativeValidation&&r5({},l),{values:r.raw?Object.assign({},n):d,errors:{}}}))}catch(d){return c(d)}return u&&u.then?u.then(void 0,c):u})(0,function(i){if(!i.inner)throw i;return{values:{},errors:vM((c=i,u=!l.shouldUseNativeValidation&&l.criteriaMode==="all",(c.inner||[]).reduce(function(d,m){if(d[m.path]||(d[m.path]={message:m.message,type:m.type}),u){var f=d[m.path].types,h=f&&f[m.type];d[m.path]=Pd(m.path,u,d,m.type,h?[].concat(h,m.message):m.message)}return d},{})),l)};var c,u}))}catch(i){return Promise.reject(i)}}}var js,Ec;function xM(){if(Ec)return js;Ec=1;function e(x){this._maxSize=x,this.clear()}e.prototype.clear=function(){this._size=0,this._values=Object.create(null)},e.prototype.get=function(x){return this._values[x]},e.prototype.set=function(x,w){return this._size>=this._maxSize&&this.clear(),x in this._values||this._size++,this._values[x]=w};var t=/[^.^\]^[]+|(?=\[\]|\.\.)/g,r=/^\d+$/,n=/^\d/,o=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,l=/^\s*(['"]?)(.*?)(\1)\s*$/,i=512,c=new e(i),u=new e(i),d=new e(i);js={Cache:e,split:f,normalizePath:m,setter:function(x){var w=m(x);return u.get(x)||u.set(x,function(k,y){for(var C=0,N=w.length,M=k;C<N-1;){var $=w[C];if($==="__proto__"||$==="constructor"||$==="prototype")return k;M=M[w[C++]]}M[w[C]]=y})},getter:function(x,w){var j=m(x);return d.get(x)||d.set(x,function(y){for(var C=0,N=j.length;C<N;)if(y!=null||!w)y=y[j[C++]];else return;return y})},join:function(x){return x.reduce(function(w,j){return w+(p(j)||r.test(j)?"["+j+"]":(w?".":"")+j)},"")},forEach:function(x,w,j){h(Array.isArray(x)?x:f(x),w,j)}};function m(x){return c.get(x)||c.set(x,f(x).map(function(w){return w.replace(l,"$2")}))}function f(x){return x.match(t)||[""]}function h(x,w,j){var k=x.length,y,C,N,M;for(C=0;C<k;C++)y=x[C],y&&(g(y)&&(y='"'+y+'"'),M=p(y),N=!M&&/^\d+$/.test(y),w.call(j,y,M,N,C,x))}function p(x){return typeof x=="string"&&x&&["'",'"'].indexOf(x.charAt(0))!==-1}function v(x){return x.match(n)&&!x.match(r)}function b(x){return o.test(x)}function g(x){return!p(x)&&(v(x)||b(x))}return js}var Zr=xM(),ks,Rc;function wM(){if(Rc)return ks;Rc=1;const e=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,t=m=>m.match(e)||[],r=m=>m[0].toUpperCase()+m.slice(1),n=(m,f)=>t(m).join(f).toLowerCase(),o=m=>t(m).reduce((f,h)=>`${f}${f?h[0].toUpperCase()+h.slice(1).toLowerCase():h.toLowerCase()}`,"");return ks={words:t,upperFirst:r,camelCase:o,pascalCase:m=>r(o(m)),snakeCase:m=>n(m,"_"),kebabCase:m=>n(m,"-"),sentenceCase:m=>r(n(m," ")),titleCase:m=>t(m).map(r).join(" ")},ks}var Es=wM(),$a={exports:{}},Cc;function yM(){if(Cc)return $a.exports;Cc=1,$a.exports=function(o){return e(t(o),o)},$a.exports.array=e;function e(o,l){var i=o.length,c=new Array(i),u={},d=i,m=r(l),f=n(o);for(l.forEach(function(p){if(!f.has(p[0])||!f.has(p[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});d--;)u[d]||h(o[d],d,new Set);return c;function h(p,v,b){if(b.has(p)){var g;try{g=", node was:"+JSON.stringify(p)}catch{g=""}throw new Error("Cyclic dependency"+g)}if(!f.has(p))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(p));if(!u[v]){u[v]=!0;var x=m.get(p)||new Set;if(x=Array.from(x),v=x.length){b.add(p);do{var w=x[--v];h(w,f.get(w),b)}while(v);b.delete(p)}c[--i]=p}}}function t(o){for(var l=new Set,i=0,c=o.length;i<c;i++){var u=o[i];l.add(u[0]),l.add(u[1])}return Array.from(l)}function r(o){for(var l=new Map,i=0,c=o.length;i<c;i++){var u=o[i];l.has(u[0])||l.set(u[0],new Set),l.has(u[1])||l.set(u[1],new Set),l.get(u[0]).add(u[1])}return l}function n(o){for(var l=new Map,i=0,c=o.length;i<c;i++)l.set(o[i],i);return l}return $a.exports}var jM=yM();const kM=H0(jM),EM=Object.prototype.toString,RM=Error.prototype.toString,CM=RegExp.prototype.toString,SM=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",NM=/^Symbol\((.*)\)(.*)$/;function MM(e){return e!=+e?"NaN":e===0&&1/e<0?"-0":""+e}function Sc(e,t=!1){if(e==null||e===!0||e===!1)return""+e;const r=typeof e;if(r==="number")return MM(e);if(r==="string")return t?`"${e}"`:e;if(r==="function")return"[Function "+(e.name||"anonymous")+"]";if(r==="symbol")return SM.call(e).replace(NM,"Symbol($1)");const n=EM.call(e).slice(8,-1);return n==="Date"?isNaN(e.getTime())?""+e:e.toISOString(e):n==="Error"||e instanceof Error?"["+RM.call(e)+"]":n==="RegExp"?CM.call(e):null}function ur(e,t){let r=Sc(e,t);return r!==null?r:JSON.stringify(e,function(n,o){let l=Sc(this[n],t);return l!==null?l:o},2)}function n5(e){return e==null?[]:[].concat(e)}let a5,o5,s5,AM=/\$\{\s*(\w+)\s*\}/g;a5=Symbol.toStringTag;class Nc{constructor(t,r,n,o){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[a5]="Error",this.name="ValidationError",this.value=r,this.path=n,this.type=o,this.errors=[],this.inner=[],n5(t).forEach(l=>{if(gt.isError(l)){this.errors.push(...l.errors);const i=l.inner.length?l.inner:[l];this.inner.push(...i)}else this.errors.push(l)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}}o5=Symbol.hasInstance;s5=Symbol.toStringTag;class gt extends Error{static formatError(t,r){const n=r.label||r.path||"this";return r=Object.assign({},r,{path:n,originalPath:r.path}),typeof t=="string"?t.replace(AM,(o,l)=>ur(r[l])):typeof t=="function"?t(r):t}static isError(t){return t&&t.name==="ValidationError"}constructor(t,r,n,o,l){const i=new Nc(t,r,n,o);if(l)return i;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[s5]="Error",this.name=i.name,this.message=i.message,this.type=i.type,this.value=i.value,this.path=i.path,this.errors=i.errors,this.inner=i.inner,Error.captureStackTrace&&Error.captureStackTrace(this,gt)}static[o5](t){return Nc[Symbol.hasInstance](t)||super[Symbol.hasInstance](t)}}let Kt={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:e,type:t,value:r,originalValue:n})=>{const o=n!=null&&n!==r?` (cast from the value \`${ur(n,!0)}\`).`:".";return t!=="mixed"?`${e} must be a \`${t}\` type, but the final value was: \`${ur(r,!0)}\``+o:`${e} must match the configured type. The validated value was: \`${ur(r,!0)}\``+o}},wt={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},br={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},hl={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},pl={isValue:"${path} field must be ${value}"},Ja={noUnknown:"${path} field has unspecified keys: ${unknown}",exact:"${path} object contains unknown properties: ${properties}"},Ya={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},OM={notType:e=>{const{path:t,value:r,spec:n}=e,o=n.types.length;if(Array.isArray(r)){if(r.length<o)return`${t} tuple value has too few items, expected a length of ${o} but got ${r.length} for value: \`${ur(r,!0)}\``;if(r.length>o)return`${t} tuple value has too many items, expected a length of ${o} but got ${r.length} for value: \`${ur(r,!0)}\``}return gt.formatError(Kt.notType,e)}};Object.assign(Object.create(null),{mixed:Kt,string:wt,number:br,date:hl,object:Ja,array:Ya,boolean:pl,tuple:OM});const Wo=e=>e&&e.__isYupSchema__;class po{static fromOptions(t,r){if(!r.then&&!r.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:n,then:o,otherwise:l}=r,i=typeof n=="function"?n:(...c)=>c.every(u=>u===n);return new po(t,(c,u)=>{var d;let m=i(...c)?o:l;return(d=m==null?void 0:m(u))!=null?d:u})}constructor(t,r){this.fn=void 0,this.refs=t,this.refs=t,this.fn=r}resolve(t,r){let n=this.refs.map(l=>l.getValue(r==null?void 0:r.value,r==null?void 0:r.parent,r==null?void 0:r.context)),o=this.fn(n,t,r);if(o===void 0||o===t)return t;if(!Wo(o))throw new TypeError("conditions must return a schema object");return o.resolve(r)}}const Ia={context:"$",value:"."};class Ur{constructor(t,r={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof t!="string")throw new TypeError("ref must be a string, got: "+t);if(this.key=t.trim(),t==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===Ia.context,this.isValue=this.key[0]===Ia.value,this.isSibling=!this.isContext&&!this.isValue;let n=this.isContext?Ia.context:this.isValue?Ia.value:"";this.path=this.key.slice(n.length),this.getter=this.path&&Zr.getter(this.path,!0),this.map=r.map}getValue(t,r,n){let o=this.isContext?n:this.isValue?t:r;return this.getter&&(o=this.getter(o||{})),this.map&&(o=this.map(o)),o}cast(t,r){return this.getValue(t,r==null?void 0:r.parent,r==null?void 0:r.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(t){return t&&t.__isYupRef}}Ur.prototype.__isYupRef=!0;const Ht=e=>e==null;function Xr(e){function t({value:r,path:n="",options:o,originalValue:l,schema:i},c,u){const{name:d,test:m,params:f,message:h,skipAbsent:p}=e;let{parent:v,context:b,abortEarly:g=i.spec.abortEarly,disableStackTrace:x=i.spec.disableStackTrace}=o;const w={value:r,parent:v,context:b};function j(V={}){const I=l5(Object.assign({value:r,originalValue:l,label:i.spec.label,path:V.path||n,spec:i.spec,disableStackTrace:V.disableStackTrace||x},f,V.params),w),z=new gt(gt.formatError(V.message||h,I),r,I.path,V.type||d,I.disableStackTrace);return z.params=I,z}const k=g?c:u;let y={path:n,parent:v,type:d,from:o.from,createError:j,resolve(V){return i5(V,w)},options:o,originalValue:l,schema:i};const C=V=>{gt.isError(V)?k(V):V?u(null):k(j())},N=V=>{gt.isError(V)?k(V):c(V)};if(p&&Ht(r))return C(!0);let $;try{var T;if($=m.call(y,r,y),typeof((T=$)==null?void 0:T.then)=="function"){if(o.sync)throw new Error(`Validation test of type: "${y.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve($).then(C,N)}}catch(V){N(V);return}C($)}return t.OPTIONS=e,t}function l5(e,t){if(!e)return e;for(const r of Object.keys(e))e[r]=i5(e[r],t);return e}function i5(e,t){return Ur.isRef(e)?e.getValue(t.value,t.parent,t.context):e}function LM(e,t,r,n=r){let o,l,i;return t?(Zr.forEach(t,(c,u,d)=>{let m=u?c.slice(1,c.length-1):c;e=e.resolve({context:n,parent:o,value:r});let f=e.type==="tuple",h=d?parseInt(m,10):0;if(e.innerType||f){if(f&&!d)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${i}" must contain an index to the tuple element, e.g. "${i}[0]"`);if(r&&h>=r.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${c}, in the path: ${t}. because there is no value at that index. `);o=r,r=r&&r[h],e=f?e.spec.types[h]:e.innerType}if(!d){if(!e.fields||!e.fields[m])throw new Error(`The schema does not contain the path: ${t}. (failed at: ${i} which is a type: "${e.type}")`);o=r,r=r&&r[m],e=e.fields[m]}l=m,i=u?"["+c+"]":"."+c}),{schema:e,parent:o,parentPath:l}):{parent:o,parentPath:t,schema:e}}class go extends Set{describe(){const t=[];for(const r of this.values())t.push(Ur.isRef(r)?r.describe():r);return t}resolveAll(t){let r=[];for(const n of this.values())r.push(t(n));return r}clone(){return new go(this.values())}merge(t,r){const n=this.clone();return t.forEach(o=>n.add(o)),r.forEach(o=>n.delete(o)),n}}function on(e,t=new Map){if(Wo(e)||!e||typeof e!="object")return e;if(t.has(e))return t.get(e);let r;if(e instanceof Date)r=new Date(e.getTime()),t.set(e,r);else if(e instanceof RegExp)r=new RegExp(e),t.set(e,r);else if(Array.isArray(e)){r=new Array(e.length),t.set(e,r);for(let n=0;n<e.length;n++)r[n]=on(e[n],t)}else if(e instanceof Map){r=new Map,t.set(e,r);for(const[n,o]of e.entries())r.set(n,on(o,t))}else if(e instanceof Set){r=new Set,t.set(e,r);for(const n of e)r.add(on(n,t))}else if(e instanceof Object){r={},t.set(e,r);for(const[n,o]of Object.entries(e))r[n]=on(o,t)}else throw Error(`Unable to clone ${e}`);return r}function $M(e){if(!(e!=null&&e.length))return;const t=[];let r="",n=!1,o=!1;for(let l=0;l<e.length;l++){const i=e[l];if(i==="["&&!o){r&&(t.push(...r.split(".").filter(Boolean)),r=""),n=!0;continue}if(i==="]"&&!o){r&&(/^\d+$/.test(r)?t.push(r):t.push(r.replace(/^"|"$/g,"")),r=""),n=!1;continue}if(i==='"'){o=!o;continue}if(i==="."&&!n&&!o){r&&(t.push(r),r="");continue}r+=i}return r&&t.push(...r.split(".").filter(Boolean)),t}function IM(e,t){const r=t?`${t}.${e.path}`:e.path;return e.errors.map(n=>({message:n,path:$M(r)}))}function c5(e,t){var r;if(!((r=e.inner)!=null&&r.length)&&e.errors.length)return IM(e,t);const n=t?`${t}.${e.path}`:e.path;return e.inner.flatMap(o=>c5(o,n))}class Rt{constructor(t){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new go,this._blacklist=new go,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(Kt.notType)}),this.type=t.type,this._typeCheck=t.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},t==null?void 0:t.spec),this.withMutation(r=>{r.nonNullable()})}get _type(){return this.type}clone(t){if(this._mutate)return t&&Object.assign(this.spec,t),this;const r=Object.create(Object.getPrototypeOf(this));return r.type=this.type,r._typeCheck=this._typeCheck,r._whitelist=this._whitelist.clone(),r._blacklist=this._blacklist.clone(),r.internalTests=Object.assign({},this.internalTests),r.exclusiveTests=Object.assign({},this.exclusiveTests),r.deps=[...this.deps],r.conditions=[...this.conditions],r.tests=[...this.tests],r.transforms=[...this.transforms],r.spec=on(Object.assign({},this.spec,t)),r}label(t){let r=this.clone();return r.spec.label=t,r}meta(...t){if(t.length===0)return this.spec.meta;let r=this.clone();return r.spec.meta=Object.assign(r.spec.meta||{},t[0]),r}withMutation(t){let r=this._mutate;this._mutate=!0;let n=t(this);return this._mutate=r,n}concat(t){if(!t||t===this)return this;if(t.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${t.type}`);let r=this,n=t.clone();const o=Object.assign({},r.spec,n.spec);return n.spec=o,n.internalTests=Object.assign({},r.internalTests,n.internalTests),n._whitelist=r._whitelist.merge(t._whitelist,t._blacklist),n._blacklist=r._blacklist.merge(t._blacklist,t._whitelist),n.tests=r.tests,n.exclusiveTests=r.exclusiveTests,n.withMutation(l=>{t.tests.forEach(i=>{l.test(i.OPTIONS)})}),n.transforms=[...r.transforms,...n.transforms],n}isType(t){return t==null?!!(this.spec.nullable&&t===null||this.spec.optional&&t===void 0):this._typeCheck(t)}resolve(t){let r=this;if(r.conditions.length){let n=r.conditions;r=r.clone(),r.conditions=[],r=n.reduce((o,l)=>l.resolve(o,t),r),r=r.resolve(t)}return r}resolveOptions(t){var r,n,o,l;return Object.assign({},t,{from:t.from||[],strict:(r=t.strict)!=null?r:this.spec.strict,abortEarly:(n=t.abortEarly)!=null?n:this.spec.abortEarly,recursive:(o=t.recursive)!=null?o:this.spec.recursive,disableStackTrace:(l=t.disableStackTrace)!=null?l:this.spec.disableStackTrace})}cast(t,r={}){let n=this.resolve(Object.assign({},r,{value:t})),o=r.assert==="ignore-optionality",l=n._cast(t,r);if(r.assert!==!1&&!n.isType(l)){if(o&&Ht(l))return l;let i=ur(t),c=ur(l);throw new TypeError(`The value of ${r.path||"field"} could not be cast to a value that satisfies the schema type: "${n.type}".
57
57
 
58
58
  attempted value: ${i}
59
59
  `+(c!==i?`result of cast: ${c}`:""))}return l}_cast(t,r){let n=t===void 0?t:this.transforms.reduce((o,l)=>l.call(this,o,t,this,r),t);return n===void 0&&(n=this.getDefault(r)),n}_validate(t,r={},n,o){let{path:l,originalValue:i=t,strict:c=this.spec.strict}=r,u=t;c||(u=this._cast(u,Object.assign({assert:!1},r)));let d=[];for(let m of Object.values(this.internalTests))m&&d.push(m);this.runTests({path:l,value:u,originalValue:i,options:r,tests:d},n,m=>{if(m.length)return o(m,u);this.runTests({path:l,value:u,originalValue:i,options:r,tests:this.tests},n,o)})}runTests(t,r,n){let o=!1,{tests:l,value:i,originalValue:c,path:u,options:d}=t,m=b=>{o||(o=!0,r(b,i))},f=b=>{o||(o=!0,n(b,i))},h=l.length,p=[];if(!h)return f([]);let v={value:i,originalValue:c,path:u,options:d,schema:this};for(let b=0;b<l.length;b++){const g=l[b];g(v,m,function(w){w&&(Array.isArray(w)?p.push(...w):p.push(w)),--h<=0&&f(p)})}}asNestedTest({key:t,index:r,parent:n,parentPath:o,originalParent:l,options:i}){const c=t??r;if(c==null)throw TypeError("Must include `key` or `index` for nested validations");const u=typeof c=="number";let d=n[c];const m=Object.assign({},i,{strict:!0,parent:n,value:d,originalValue:l[c],key:void 0,[u?"index":"key"]:c,path:u||c.includes(".")?`${o||""}[${u?c:`"${c}"`}]`:(o?`${o}.`:"")+t});return(f,h,p)=>this.resolve(m)._validate(d,m,h,p)}validate(t,r){var n;let o=this.resolve(Object.assign({},r,{value:t})),l=(n=r==null?void 0:r.disableStackTrace)!=null?n:o.spec.disableStackTrace;return new Promise((i,c)=>o._validate(t,r,(u,d)=>{gt.isError(u)&&(u.value=d),c(u)},(u,d)=>{u.length?c(new gt(u,d,void 0,void 0,l)):i(d)}))}validateSync(t,r){var n;let o=this.resolve(Object.assign({},r,{value:t})),l,i=(n=r==null?void 0:r.disableStackTrace)!=null?n:o.spec.disableStackTrace;return o._validate(t,Object.assign({},r,{sync:!0}),(c,u)=>{throw gt.isError(c)&&(c.value=u),c},(c,u)=>{if(c.length)throw new gt(c,t,void 0,void 0,i);l=u}),l}isValid(t,r){return this.validate(t,r).then(()=>!0,n=>{if(gt.isError(n))return!1;throw n})}isValidSync(t,r){try{return this.validateSync(t,r),!0}catch(n){if(gt.isError(n))return!1;throw n}}_getDefault(t){let r=this.spec.default;return r==null?r:typeof r=="function"?r.call(this,t):on(r)}getDefault(t){return this.resolve(t||{})._getDefault(t)}default(t){return arguments.length===0?this._getDefault():this.clone({default:t})}strict(t=!0){return this.clone({strict:t})}nullability(t,r){const n=this.clone({nullable:t});return n.internalTests.nullable=Xr({message:r,name:"nullable",test(o){return o===null?this.schema.spec.nullable:!0}}),n}optionality(t,r){const n=this.clone({optional:t});return n.internalTests.optionality=Xr({message:r,name:"optionality",test(o){return o===void 0?this.schema.spec.optional:!0}}),n}optional(){return this.optionality(!0)}defined(t=Kt.defined){return this.optionality(!1,t)}nullable(){return this.nullability(!0)}nonNullable(t=Kt.notNull){return this.nullability(!1,t)}required(t=Kt.required){return this.clone().withMutation(r=>r.nonNullable(t).defined(t))}notRequired(){return this.clone().withMutation(t=>t.nullable().optional())}transform(t){let r=this.clone();return r.transforms.push(t),r}test(...t){let r;if(t.length===1?typeof t[0]=="function"?r={test:t[0]}:r=t[0]:t.length===2?r={name:t[0],test:t[1]}:r={name:t[0],message:t[1],test:t[2]},r.message===void 0&&(r.message=Kt.default),typeof r.test!="function")throw new TypeError("`test` is a required parameters");let n=this.clone(),o=Xr(r),l=r.exclusive||r.name&&n.exclusiveTests[r.name]===!0;if(r.exclusive&&!r.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return r.name&&(n.exclusiveTests[r.name]=!!r.exclusive),n.tests=n.tests.filter(i=>!(i.OPTIONS.name===r.name&&(l||i.OPTIONS.test===o.OPTIONS.test))),n.tests.push(o),n}when(t,r){!Array.isArray(t)&&typeof t!="string"&&(r=t,t=".");let n=this.clone(),o=n5(t).map(l=>new Ur(l));return o.forEach(l=>{l.isSibling&&n.deps.push(l.key)}),n.conditions.push(typeof r=="function"?new po(o,r):po.fromOptions(o,r)),n}typeError(t){let r=this.clone();return r.internalTests.typeError=Xr({message:t,name:"typeError",skipAbsent:!0,test(n){return this.schema._typeCheck(n)?!0:this.createError({params:{type:this.schema.type}})}}),r}oneOf(t,r=Kt.oneOf){let n=this.clone();return t.forEach(o=>{n._whitelist.add(o),n._blacklist.delete(o)}),n.internalTests.whiteList=Xr({message:r,name:"oneOf",skipAbsent:!0,test(o){let l=this.schema._whitelist,i=l.resolveAll(this.resolve);return i.includes(o)?!0:this.createError({params:{values:Array.from(l).join(", "),resolved:i}})}}),n}notOneOf(t,r=Kt.notOneOf){let n=this.clone();return t.forEach(o=>{n._blacklist.add(o),n._whitelist.delete(o)}),n.internalTests.blacklist=Xr({message:r,name:"notOneOf",test(o){let l=this.schema._blacklist,i=l.resolveAll(this.resolve);return i.includes(o)?this.createError({params:{values:Array.from(l).join(", "),resolved:i}}):!0}}),n}strip(t=!0){let r=this.clone();return r.spec.strip=t,r}describe(t){const r=(t?this.resolve(t):this).clone(),{label:n,meta:o,optional:l,nullable:i}=r.spec;return{meta:o,label:n,optional:l,nullable:i,default:r.getDefault(t),type:r.type,oneOf:r._whitelist.describe(),notOneOf:r._blacklist.describe(),tests:r.tests.filter((u,d,m)=>m.findIndex(f=>f.OPTIONS.name===u.OPTIONS.name)===d).map(u=>{const d=u.OPTIONS.params&&t?l5(Object.assign({},u.OPTIONS.params),t):u.OPTIONS.params;return{name:u.OPTIONS.name,params:d}})}}get"~standard"(){const t=this;return{version:1,vendor:"yup",async validate(n){try{return{value:await t.validate(n,{abortEarly:!1})}}catch(o){if(o instanceof gt)return{issues:c5(o)};throw o}}}}}Rt.prototype.__isYupSchema__=!0;for(const e of["validate","validateSync"])Rt.prototype[`${e}At`]=function(t,r,n={}){const{parent:o,parentPath:l,schema:i}=LM(this,t,r,n.context);return i[e](o&&o[l],Object.assign({},n,{parent:o,path:t}))};for(const e of["equals","is"])Rt.prototype[e]=Rt.prototype.oneOf;for(const e of["not","nope"])Rt.prototype[e]=Rt.prototype.notOneOf;const FM=()=>!0;function Wn(e){return new d5(e)}class d5 extends Rt{constructor(t){super(typeof t=="function"?{type:"mixed",check:t}:Object.assign({type:"mixed",check:FM},t))}}Wn.prototype=d5.prototype;function u5(){return new f5}class f5 extends Rt{constructor(){super({type:"boolean",check(t){return t instanceof Boolean&&(t=t.valueOf()),typeof t=="boolean"}}),this.withMutation(()=>{this.transform((t,r)=>{if(this.spec.coerce&&!this.isType(t)){if(/^(true|1)$/i.test(String(t)))return!0;if(/^(false|0)$/i.test(String(t)))return!1}return t})})}isTrue(t=pl.isValue){return this.test({message:t,name:"is-value",exclusive:!0,params:{value:"true"},test(r){return Ht(r)||r===!0}})}isFalse(t=pl.isValue){return this.test({message:t,name:"is-value",exclusive:!0,params:{value:"false"},test(r){return Ht(r)||r===!1}})}default(t){return super.default(t)}defined(t){return super.defined(t)}optional(){return super.optional()}required(t){return super.required(t)}notRequired(){return super.notRequired()}nullable(){return super.nullable()}nonNullable(t){return super.nonNullable(t)}strip(t){return super.strip(t)}}u5.prototype=f5.prototype;const _M=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function TM(e){const t=gl(e);if(!t)return Date.parse?Date.parse(e):Number.NaN;if(t.z===void 0&&t.plusMinus===void 0)return new Date(t.year,t.month,t.day,t.hour,t.minute,t.second,t.millisecond).valueOf();let r=0;return t.z!=="Z"&&t.plusMinus!==void 0&&(r=t.hourOffset*60+t.minuteOffset,t.plusMinus==="+"&&(r=0-r)),Date.UTC(t.year,t.month,t.day,t.hour,t.minute+r,t.second,t.millisecond)}function gl(e){var t,r;const n=_M.exec(e);return n?{year:ar(n[1]),month:ar(n[2],1)-1,day:ar(n[3],1),hour:ar(n[4]),minute:ar(n[5]),second:ar(n[6]),millisecond:n[7]?ar(n[7].substring(0,3)):0,precision:(t=(r=n[7])==null?void 0:r.length)!=null?t:void 0,z:n[8]||void 0,plusMinus:n[9]||void 0,hourOffset:ar(n[10]),minuteOffset:ar(n[11])}:null}function ar(e,t=0){return Number(e)||t}let BM=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,ZM=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,VM=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,DM="^\\d{4}-\\d{2}-\\d{2}",PM="\\d{2}:\\d{2}:\\d{2}",zM="(([+-]\\d{2}(:?\\d{2})?)|Z)",HM=new RegExp(`${DM}T${PM}(\\.\\d+)?${zM}$`),WM=e=>Ht(e)||e===e.trim(),UM={}.toString();function nn(){return new m5}class m5 extends Rt{constructor(){super({type:"string",check(t){return t instanceof String&&(t=t.valueOf()),typeof t=="string"}}),this.withMutation(()=>{this.transform((t,r)=>{if(!this.spec.coerce||this.isType(t)||Array.isArray(t))return t;const n=t!=null&&t.toString?t.toString():t;return n===UM?t:n})})}required(t){return super.required(t).withMutation(r=>r.test({message:t||Kt.required,name:"required",skipAbsent:!0,test:n=>!!n.length}))}notRequired(){return super.notRequired().withMutation(t=>(t.tests=t.tests.filter(r=>r.OPTIONS.name!=="required"),t))}length(t,r=wt.length){return this.test({message:r,name:"length",exclusive:!0,params:{length:t},skipAbsent:!0,test(n){return n.length===this.resolve(t)}})}min(t,r=wt.min){return this.test({message:r,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(n){return n.length>=this.resolve(t)}})}max(t,r=wt.max){return this.test({name:"max",exclusive:!0,message:r,params:{max:t},skipAbsent:!0,test(n){return n.length<=this.resolve(t)}})}matches(t,r){let n=!1,o,l;return r&&(typeof r=="object"?{excludeEmptyString:n=!1,message:o,name:l}=r:o=r),this.test({name:l||"matches",message:o||wt.matches,params:{regex:t},skipAbsent:!0,test:i=>i===""&&n||i.search(t)!==-1})}email(t=wt.email){return this.matches(BM,{name:"email",message:t,excludeEmptyString:!0})}url(t=wt.url){return this.matches(ZM,{name:"url",message:t,excludeEmptyString:!0})}uuid(t=wt.uuid){return this.matches(VM,{name:"uuid",message:t,excludeEmptyString:!1})}datetime(t){let r="",n,o;return t&&(typeof t=="object"?{message:r="",allowOffset:n=!1,precision:o=void 0}=t:r=t),this.matches(HM,{name:"datetime",message:r||wt.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:r||wt.datetime_offset,params:{allowOffset:n},skipAbsent:!0,test:l=>{if(!l||n)return!0;const i=gl(l);return i?!!i.z:!1}}).test({name:"datetime_precision",message:r||wt.datetime_precision,params:{precision:o},skipAbsent:!0,test:l=>{if(!l||o==null)return!0;const i=gl(l);return i?i.precision===o:!1}})}ensure(){return this.default("").transform(t=>t===null?"":t)}trim(t=wt.trim){return this.transform(r=>r!=null?r.trim():r).test({message:t,name:"trim",test:WM})}lowercase(t=wt.lowercase){return this.transform(r=>Ht(r)?r:r.toLowerCase()).test({message:t,name:"string_case",exclusive:!0,skipAbsent:!0,test:r=>Ht(r)||r===r.toLowerCase()})}uppercase(t=wt.uppercase){return this.transform(r=>Ht(r)?r:r.toUpperCase()).test({message:t,name:"string_case",exclusive:!0,skipAbsent:!0,test:r=>Ht(r)||r===r.toUpperCase()})}}nn.prototype=m5.prototype;let qM=e=>e!=+e;function h5(){return new p5}class p5 extends Rt{constructor(){super({type:"number",check(t){return t instanceof Number&&(t=t.valueOf()),typeof t=="number"&&!qM(t)}}),this.withMutation(()=>{this.transform((t,r)=>{if(!this.spec.coerce)return t;let n=t;if(typeof n=="string"){if(n=n.replace(/\s/g,""),n==="")return NaN;n=+n}return this.isType(n)||n===null?n:parseFloat(n)})})}min(t,r=br.min){return this.test({message:r,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(n){return n>=this.resolve(t)}})}max(t,r=br.max){return this.test({message:r,name:"max",exclusive:!0,params:{max:t},skipAbsent:!0,test(n){return n<=this.resolve(t)}})}lessThan(t,r=br.lessThan){return this.test({message:r,name:"max",exclusive:!0,params:{less:t},skipAbsent:!0,test(n){return n<this.resolve(t)}})}moreThan(t,r=br.moreThan){return this.test({message:r,name:"min",exclusive:!0,params:{more:t},skipAbsent:!0,test(n){return n>this.resolve(t)}})}positive(t=br.positive){return this.moreThan(0,t)}negative(t=br.negative){return this.lessThan(0,t)}integer(t=br.integer){return this.test({name:"integer",message:t,skipAbsent:!0,test:r=>Number.isInteger(r)})}truncate(){return this.transform(t=>Ht(t)?t:t|0)}round(t){var r;let n=["ceil","floor","round","trunc"];if(t=((r=t)==null?void 0:r.toLowerCase())||"round",t==="trunc")return this.truncate();if(n.indexOf(t.toLowerCase())===-1)throw new TypeError("Only valid options for round() are: "+n.join(", "));return this.transform(o=>Ht(o)?o:Math[t](o))}}h5.prototype=p5.prototype;let g5=new Date(""),GM=e=>Object.prototype.toString.call(e)==="[object Date]";function ci(){return new ba}class ba extends Rt{constructor(){super({type:"date",check(t){return GM(t)&&!isNaN(t.getTime())}}),this.withMutation(()=>{this.transform((t,r)=>!this.spec.coerce||this.isType(t)||t===null?t:(t=TM(t),isNaN(t)?ba.INVALID_DATE:new Date(t)))})}prepareParam(t,r){let n;if(Ur.isRef(t))n=t;else{let o=this.cast(t);if(!this._typeCheck(o))throw new TypeError(`\`${r}\` must be a Date or a value that can be \`cast()\` to a Date`);n=o}return n}min(t,r=hl.min){let n=this.prepareParam(t,"min");return this.test({message:r,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(o){return o>=this.resolve(n)}})}max(t,r=hl.max){let n=this.prepareParam(t,"max");return this.test({message:r,name:"max",exclusive:!0,params:{max:t},skipAbsent:!0,test(o){return o<=this.resolve(n)}})}}ba.INVALID_DATE=g5;ci.prototype=ba.prototype;ci.INVALID_DATE=g5;function KM(e,t=[]){let r=[],n=new Set,o=new Set(t.map(([i,c])=>`${i}-${c}`));function l(i,c){let u=Zr.split(i)[0];n.add(u),o.has(`${c}-${u}`)||r.push([c,u])}for(const i of Object.keys(e)){let c=e[i];n.add(i),Ur.isRef(c)&&c.isSibling?l(c.path,i):Wo(c)&&"deps"in c&&c.deps.forEach(u=>l(u,i))}return kM.array(Array.from(n),r).reverse()}function Mc(e,t){let r=1/0;return e.some((n,o)=>{var l;if((l=t.path)!=null&&l.includes(n))return r=o,!0}),r}function v5(e){return(t,r)=>Mc(e,t)-Mc(e,r)}const b5=(e,t,r)=>{if(typeof e!="string")return e;let n=e;try{n=JSON.parse(e)}catch{}return r.isType(n)?n:e};function Xa(e){if("fields"in e){const t={};for(const[r,n]of Object.entries(e.fields))t[r]=Xa(n);return e.setFields(t)}if(e.type==="array"){const t=e.optional();return t.innerType&&(t.innerType=Xa(t.innerType)),t}return e.type==="tuple"?e.optional().clone({types:e.spec.types.map(Xa)}):"optional"in e?e.optional():e}const JM=(e,t)=>{const r=[...Zr.normalizePath(t)];if(r.length===1)return r[0]in e;let n=r.pop(),o=Zr.getter(Zr.join(r),!0)(e);return!!(o&&n in o)};let Ac=e=>Object.prototype.toString.call(e)==="[object Object]";function Oc(e,t){let r=Object.keys(e.fields);return Object.keys(t).filter(n=>r.indexOf(n)===-1)}const YM=v5([]);function di(e){return new x5(e)}class x5 extends Rt{constructor(t){super({type:"object",check(r){return Ac(r)||typeof r=="function"}}),this.fields=Object.create(null),this._sortErrors=YM,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{t&&this.shape(t)})}_cast(t,r={}){var n;let o=super._cast(t,r);if(o===void 0)return this.getDefault(r);if(!this._typeCheck(o))return o;let l=this.fields,i=(n=r.stripUnknown)!=null?n:this.spec.noUnknown,c=[].concat(this._nodes,Object.keys(o).filter(f=>!this._nodes.includes(f))),u={},d=Object.assign({},r,{parent:u,__validating:r.__validating||!1}),m=!1;for(const f of c){let h=l[f],p=f in o,v=o[f];if(h){let b;d.path=(r.path?`${r.path}.`:"")+f,h=h.resolve({value:v,context:r.context,parent:u});let g=h instanceof Rt?h.spec:void 0,x=g==null?void 0:g.strict;if(g!=null&&g.strip){m=m||f in o;continue}b=!r.__validating||!x?h.cast(v,d):v,b!==void 0&&(u[f]=b)}else p&&!i&&(u[f]=v);(p!==f in u||u[f]!==v)&&(m=!0)}return m?u:o}_validate(t,r={},n,o){let{from:l=[],originalValue:i=t,recursive:c=this.spec.recursive}=r;r.from=[{schema:this,value:i},...l],r.__validating=!0,r.originalValue=i,super._validate(t,r,n,(u,d)=>{if(!c||!Ac(d)){o(u,d);return}i=i||d;let m=[];for(let f of this._nodes){let h=this.fields[f];!h||Ur.isRef(h)||m.push(h.asNestedTest({options:r,key:f,parent:d,parentPath:r.path,originalParent:i}))}this.runTests({tests:m,value:d,originalValue:i,options:r},n,f=>{o(f.sort(this._sortErrors).concat(u),d)})})}clone(t){const r=super.clone(t);return r.fields=Object.assign({},this.fields),r._nodes=this._nodes,r._excludedEdges=this._excludedEdges,r._sortErrors=this._sortErrors,r}concat(t){let r=super.concat(t),n=r.fields;for(let[o,l]of Object.entries(this.fields)){const i=n[o];n[o]=i===void 0?l:i}return r.withMutation(o=>o.setFields(n,[...this._excludedEdges,...t._excludedEdges]))}_getDefault(t){if("default"in this.spec)return super._getDefault(t);if(!this._nodes.length)return;let r={};return this._nodes.forEach(n=>{var o;const l=this.fields[n];let i=t;(o=i)!=null&&o.value&&(i=Object.assign({},i,{parent:i.value,value:i.value[n]})),r[n]=l&&"getDefault"in l?l.getDefault(i):void 0}),r}setFields(t,r){let n=this.clone();return n.fields=t,n._nodes=KM(t,r),n._sortErrors=v5(Object.keys(t)),r&&(n._excludedEdges=r),n}shape(t,r=[]){return this.clone().withMutation(n=>{let o=n._excludedEdges;return r.length&&(Array.isArray(r[0])||(r=[r]),o=[...n._excludedEdges,...r]),n.setFields(Object.assign(n.fields,t),o)})}partial(){const t={};for(const[r,n]of Object.entries(this.fields))t[r]="optional"in n&&n.optional instanceof Function?n.optional():n;return this.setFields(t)}deepPartial(){return Xa(this)}pick(t){const r={};for(const n of t)this.fields[n]&&(r[n]=this.fields[n]);return this.setFields(r,this._excludedEdges.filter(([n,o])=>t.includes(n)&&t.includes(o)))}omit(t){const r=[];for(const n of Object.keys(this.fields))t.includes(n)||r.push(n);return this.pick(r)}from(t,r,n){let o=Zr.getter(t,!0);return this.transform(l=>{if(!l)return l;let i=l;return JM(l,t)&&(i=Object.assign({},l),n||delete i[t],i[r]=o(l)),i})}json(){return this.transform(b5)}exact(t){return this.test({name:"exact",exclusive:!0,message:t||Ja.exact,test(r){if(r==null)return!0;const n=Oc(this.schema,r);return n.length===0||this.createError({params:{properties:n.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(t=!0,r=Ja.noUnknown){typeof t!="boolean"&&(r=t,t=!0);let n=this.test({name:"noUnknown",exclusive:!0,message:r,test(o){if(o==null)return!0;const l=Oc(this.schema,o);return!t||l.length===0||this.createError({params:{unknown:l.join(", ")}})}});return n.spec.noUnknown=t,n}unknown(t=!0,r=Ja.noUnknown){return this.noUnknown(!t,r)}transformKeys(t){return this.transform(r=>{if(!r)return r;const n={};for(const o of Object.keys(r))n[t(o)]=r[o];return n})}camelCase(){return this.transformKeys(Es.camelCase)}snakeCase(){return this.transformKeys(Es.snakeCase)}constantCase(){return this.transformKeys(t=>Es.snakeCase(t).toUpperCase())}describe(t){const r=(t?this.resolve(t):this).clone(),n=super.describe(t);n.fields={};for(const[l,i]of Object.entries(r.fields)){var o;let c=t;(o=c)!=null&&o.value&&(c=Object.assign({},c,{parent:c.value,value:c.value[l]})),n.fields[l]=i.describe(c)}return n}}di.prototype=x5.prototype;function vl(e){return new w5(e)}class w5 extends Rt{constructor(t){super({type:"array",spec:{types:t},check(r){return Array.isArray(r)}}),this.innerType=void 0,this.innerType=t}_cast(t,r){const n=super._cast(t,r);if(!this._typeCheck(n)||!this.innerType)return n;let o=!1;const l=n.map((i,c)=>{const u=this.innerType.cast(i,Object.assign({},r,{path:`${r.path||""}[${c}]`,parent:n,originalValue:i,value:i,index:c}));return u!==i&&(o=!0),u});return o?l:n}_validate(t,r={},n,o){var l;let i=this.innerType,c=(l=r.recursive)!=null?l:this.spec.recursive;r.originalValue!=null&&r.originalValue,super._validate(t,r,n,(u,d)=>{var m;if(!c||!i||!this._typeCheck(d)){o(u,d);return}let f=new Array(d.length);for(let p=0;p<d.length;p++){var h;f[p]=i.asNestedTest({options:r,index:p,parent:d,parentPath:r.path,originalParent:(h=r.originalValue)!=null?h:t})}this.runTests({value:d,tests:f,originalValue:(m=r.originalValue)!=null?m:t,options:r},n,p=>o(p.concat(u),d))})}clone(t){const r=super.clone(t);return r.innerType=this.innerType,r}json(){return this.transform(b5)}concat(t){let r=super.concat(t);return r.innerType=this.innerType,t.innerType&&(r.innerType=r.innerType?r.innerType.concat(t.innerType):t.innerType),r}of(t){let r=this.clone();if(!Wo(t))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+ur(t));return r.innerType=t,r.spec=Object.assign({},r.spec,{types:t}),r}length(t,r=Ya.length){return this.test({message:r,name:"length",exclusive:!0,params:{length:t},skipAbsent:!0,test(n){return n.length===this.resolve(t)}})}min(t,r){return r=r||Ya.min,this.test({message:r,name:"min",exclusive:!0,params:{min:t},skipAbsent:!0,test(n){return n.length>=this.resolve(t)}})}max(t,r){return r=r||Ya.max,this.test({message:r,name:"max",exclusive:!0,params:{max:t},skipAbsent:!0,test(n){return n.length<=this.resolve(t)}})}ensure(){return this.default(()=>[]).transform((t,r)=>this._typeCheck(t)?t:r==null?[]:[].concat(r))}compact(t){let r=t?(n,o,l)=>!t(n,o,l):n=>!!n;return this.transform(n=>n!=null?n.filter(r):n)}describe(t){const r=(t?this.resolve(t):this).clone(),n=super.describe(t);if(r.innerType){var o;let l=t;(o=l)!=null&&o.value&&(l=Object.assign({},l,{parent:l.value,value:l.value[0]})),n.innerType=r.innerType.describe(l)}return n}}vl.prototype=w5.prototype;function y5(e,t,r){const n=typeof r=="number"?{timeoutMs:r,translations:{}}:{timeoutMs:300,translations:{},...r},{timeoutMs:o=300,translations:l={}}=n;return new Promise((i,c)=>{const u=`
@@ -95,7 +95,7 @@ attempted value: ${i}
95
95
  shadow-lg ${Y} max-h-48 overflow-auto z-10
96
96
  `,children:C.map(de=>s.jsx("li",{className:`px-2 ${U} flex items-center cursor-pointer
97
97
  text-[var(--color-ds-text-primary)]
98
- hover:bg-[var(--color-ds-background-surface)]`,onClick:()=>{const me=String(de.value).trim();k(e,me,{shouldDirty:!0,shouldValidate:!0}),z(de.label??me),Q.current=!1,te.current=!1,V(!1)},children:de.label},String(de.value)))})]})}})}const Dn=(e,t)=>e[t],Bc=e=>e instanceof Date?e.getTime():e;function DA(e,t,r){const n=Bc(e),o=Bc(t);return typeof n=="number"&&typeof o=="number"||typeof n=="string"&&typeof o=="string"?r==="gt"?n>o:r==="gte"?n>=o:r==="lt"?n<o:n<=o:!1}function vo(e,t){if(!e)return!1;switch(e.op){case"eq":return Dn(t,e.field)===e.value;case"neq":return Dn(t,e.field)!==e.value;case"in":return e.values.includes(Dn(t,e.field));case"notIn":return!e.values.includes(Dn(t,e.field));case"gt":case"gte":case"lt":case"lte":return DA(Dn(t,e.field),e.value,e.op);case"and":return e.rules.every(r=>vo(r,t));case"or":return e.rules.some(r=>vo(r,t));case"always":return!!e.value;default:return!1}}function hi(e){return!!e&&(typeof e=="function"||typeof e=="object")}function yn(e,t){const r=t==="outline"?bn:xn,n=r==null?void 0:r[e];return hi(n)?n:null}const PA=Object.entries(bn).filter(([e,t])=>e.endsWith("Icon")&&hi(t)).map(([e,t])=>({name:e,Icon:t,style:"outline"})),zA=Object.entries(xn).filter(([e,t])=>e.endsWith("Icon")&&hi(t)).map(([e,t])=>({name:e,Icon:t,style:"solid"})),HA=ql||Ul||(e=>s.jsx("svg",{...e})),Fr=({value:e,onChange:t,buttonLabel:r,disabled:n,className:o})=>{const[l,i]=E.useState(!1),[c,u]=E.useState(""),[d,m]=E.useState((e==null?void 0:e.style)??"outline"),f=e&&yn(e.name,e.style)||HA,h=E.useCallback((v,b)=>{const g=yn(v,b);t==null||t({name:v,style:b},g),i(!1)},[t]),p=E.useCallback(()=>{t==null||t(void 0,void 0),i(!1)},[t]);return s.jsxs(s.Fragment,{children:[s.jsx(fe,{size:"sm",variant:"outline",shape:"circle",className:`rounded-full p-0 w-8 h-8 inline-flex items-center justify-center ${o??""}`,disabled:n,onClick:()=>i(!0),ariaLabel:"Elegir icono",title:r||"Elegir icono",children:s.jsx(f,{className:"h-4 w-4"})}),s.jsx(Et,{isOpen:l,onClose:()=>i(!1),title:"Seleccionar icono",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(je,{labelHidden:!0,placeholder:"Buscar icono (p. ej. 'user', 'arrow', 'calendar'...)",value:c,onChange:v=>u(v.target.value)}),s.jsx(fr,{options:[{label:"Outline",value:"outline"},{label:"Solid",value:"solid"}],value:d,onChange:v=>m(v),children:{outline:s.jsx(Zc,{items:PA,query:c,onPick:v=>h(v,"outline"),onClear:p}),solid:s.jsx(Zc,{items:zA,query:c,onPick:v=>h(v,"solid"),onClear:p})}})]})})]})},Zc=({items:e,query:t,onPick:r,onClear:n})=>{const o=E.useMemo(()=>{if(!t.trim())return e;const i=t.trim().toLowerCase().replace(/\s+/g,"");return e.filter(c=>c.name.toLowerCase().includes(i))},[e,t]),l=nt;return s.jsx("div",{className:"custom-scroll max-h-[60vh] overflow-y-auto",children:s.jsxs("div",{className:"grid gap-2 grid-cols-3 sm:grid-cols-4 md:grid-cols-6",children:[s.jsxs("button",{type:"button",onClick:n,className:"group w-full aspect-square border border-[var(--color-ds-border-default-50)] rounded-lg p-1 bg-[var(--color-ds-background-page)] hover:bg-[var(--color-ds-background-accent)]/5 hover:border-[var(--color-ds-border-default)] transition focus:outline-none",title:"Ninguno","aria-label":"Quitar icono",children:[s.jsx("div",{className:"h-full w-full flex items-center justify-center",children:l?s.jsx(l,{className:"w-6 h-6"}):s.jsx("span",{className:"text-ds-lg",children:"×"})}),s.jsx("div",{className:"mt-1 text-center",children:s.jsx("span",{className:"block text-[11px] leading-tight text-[var(--color-ds-text-secondary)] truncate",children:"Ninguno"})})]}),(o.length===0?e:o).map(({name:i,Icon:c})=>s.jsxs("button",{type:"button",onClick:()=>r(i),className:"group w-full aspect-square border border-[var(--color-ds-border-default-50)] rounded-lg p-1 bg-[var(--color-ds-background-page)] hover:bg-[var(--color-ds-background-accent)]/5 hover:border-[var(--color-ds-border-default)] transition focus:outline-none",title:i,"aria-label":`Elegir ${i}`,children:[s.jsx("div",{className:"h-full w-full flex items-center justify-center",children:s.jsx(c,{className:"w-6 h-6 text-[var(--color-ds-text-primary)]"})}),s.jsx("div",{className:"mt-1 text-center",children:s.jsx("span",{className:"block text-[11px] leading-tight text-[var(--color-ds-text-secondary)] truncate",children:i.replace(/Icon$/,"")})})]},i))]})})};function ct(e,t,r=""){if(!t)return r;if(typeof t=="object"&&t!==null){if(t.type==="complex"){const o=[];return t.header&&o.push(`<strong>${t.header}</strong>`),t.template&&o.push(t.template),o.join("<br/>")||r}return r}return e(t,{defaultValue:t})}const WA=({schema:e,renderField:t})=>{var b,g,x;const{control:r}=Sr(),{fields:n,append:o,remove:l}=fx({control:r,name:e.name}),{label:i,addLabel:c="Añadir",items:u,disabled:d,validation:m,className:f}=e,{formState:{errors:h}}=Sr(),p=((g=(b=h[e.name])==null?void 0:b.root)==null?void 0:g.message)||((x=h[e.name])==null?void 0:x.message),v=typeof p=="string"?p:void 0;return s.jsxs("div",{className:he("space-y-3",f),children:[i&&s.jsx("div",{className:"flex items-center justify-between",children:s.jsx("label",{className:"block text-ds-sm font-medium text-[var(--color-ds-text-primary)]",children:i})}),s.jsx("div",{className:"space-y-4",children:n.map((w,j)=>{const k=`${e.name}.${j}`;return s.jsxs("div",{className:"relative rounded-lg border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)] p-4 group",children:[!d&&s.jsx("div",{className:"absolute top-2 right-2",children:s.jsx(fe,{size:"xs",variant:"ghost",className:"text-[var(--color-ds-text-error)] hover:bg-[var(--color-ds-background-error-hover)]",onClick:()=>l(j),title:"Eliminar fila",ariaLabel:"Eliminar fila",children:s.jsx(bt,{className:"w-4 h-4"})})}),s.jsx("div",{className:"grid grid-cols-1 gap-4",children:u.map((y,C)=>s.jsx(E.Fragment,{children:t(y,k)},C))})]},w.id)})}),n.length===0&&s.jsx("div",{className:"text-ds-sm text-[var(--color-ds-text-secondary)] italic p-2 border border-dashed border-[var(--color-ds-border-default-50)] rounded bg-[var(--color-ds-background-subtle)]",children:"No hay elementos."}),v&&s.jsx("p",{className:"text-xs text-[var(--color-ds-text-error)]",children:v}),!d&&s.jsxs(fe,{type:"button",variant:"outline",size:"sm",onClick:()=>{o({})},children:[s.jsx(er,{className:"w-4 h-4 mr-1"}),c]})]})};function Vc(e){if(e){if(typeof e=="string")try{return JSON.parse(e)}catch{return}if(typeof e=="object")return e}}function UA(e,t){var r;return Array.isArray(e)?e.length&&typeof e[0]=="object"&&"value"in e[0]?t?e.map(n=>n.value):((r=e[0])==null?void 0:r.value)??"":t?e:e[0]??"":e&&typeof e=="object"&&"value"in e?e.value:e??(t?[]:"")}const qA=e=>e.type!=="inputGroup"&&e.type!=="button";function GA(){try{return St()??void 0}catch{return}}function Nt(e){if(!e||typeof e!="object")return;const t=e.name,r=e.style;if(!(!t||!r))return yn(t,r)||void 0}function O5({schema:e,resolver:t,serviceRegistry:r,activeVariantId:n}){var J;const{layout:o,fields:l=[],onSubmit:i,successMessage:c,errorMessage:u,footerButtons:d,defaultValues:m,loadDefaultValues:f,validationSchema:h}=e,{show:p}=qr(),{t:v}=Ct(),b=GA(),g=r??((J=b==null?void 0:b.services)==null?void 0:J.registry)??void 0,x=E.useMemo(()=>{if(t)return t;try{const H=h??ui(e);return ii(H)}catch{return}},[t,e,h]),w=ai({resolver:x,mode:"onBlur",reValidateMode:"onChange",defaultValues:m??{}}),j=un(H=>H.setRuntimeState),k=un(H=>H.systemContext),y=un(H=>H.formValues);E.useEffect(()=>{j({isActive:!0});let H=!1;return(async()=>{const L=e.defaultSource,S=e.onloadEndpoint;let D={};if(e.variables&&Array.isArray(e.variables)&&(e.variables.forEach(Z=>{Z.type==="constant"&&(D[Z.key]=Z.value)}),e.variables.forEach(Z=>{if(Z.type==="computed"&&Z.value)try{const B=new Function("ctx",`return (${Z.value});`);D[Z.key]=B(D)}catch(B){console.warn(`[FormRenderer] Error evaluating computed variable "${Z.key}":`,B),D[Z.key]=null}})),L)try{const Z=g==null?void 0:g[L];if(Z){const B=typeof Z=="function"?await Z():Z;B&&typeof B=="object"&&(D={...D,...B})}}catch{}j({systemContext:{...D}});const _=[];if(S&&_.push(S),e.onloadEndpoints&&Array.isArray(e.onloadEndpoints)&&_.push(...e.onloadEndpoints),_.length>0){const Z=async q=>{if(!q)return{};try{const X=g==null?void 0:g[q.key];if(!X)return console.warn("[FormRenderer] Provider not found for key:",q.key),{};const G=Ir(q.parameters,(()=>({})),{...D,ACTIVE_VARIANT:e.activeVariantId}),K=await Promise.resolve(X("",{getValues:(()=>({})),watch:(()=>{}),params:G}));let re=K;if(typeof K=="string")try{re=JSON.parse(K)}catch(ie){console.warn("[FormRenderer] Failed to parse onload response string",ie)}return re&&typeof re=="object"?re:(console.warn("[FormRenderer] OnLoad response is not an object:",re),{})}catch(X){return console.error("Error in onloadEndpoint",X),{}}};(await Promise.all(_.map(Z))).forEach(q=>{q&&typeof q=="object"&&(D={...D,...q})}),H||j({systemContext:{...D}})}if(!H&&Object.keys(D).length>0){const Z={...e.defaultValues??{}};Object.assign(Z,D);const B=e.fields.map(q=>q.name);Object.keys(D).forEach(q=>{const X=q.toLowerCase(),G=B.find(K=>K.toLowerCase()===X);G&&(Z[G]===void 0||Z[G]==="")&&(Z[G]=D[q])}),w.reset(Z)}})(),()=>{H=!0,j({isActive:!1,systemContext:{},formValues:{}})}},[e,g,w.reset]);const{control:C,reset:N,handleSubmit:M,formState:{errors:$,isSubmitting:T}}=w,[V,I]=E.useState(!1);E.useEffect(()=>{f&&(I(!0),f().then(H=>N(H)).finally(()=>I(!1)))},[f,N]);const z=E.useMemo(()=>(l??[]).filter(qA),[l]),{loadingCount:O,optionsMap:P}=M5(z),[Q,te]=E.useState({});E.useEffect(()=>{let H=!0;return(async()=>{const S=await Promise.all(z.filter(_=>_.type==="select"&&(_.optionSource||_.endpointConfig)).map(async _=>{const Z=_.name,B=ho(_.optionSource,_.endpointConfig);if(!B)return[Z,[]];const q=_.endpointConfig?Ir(_.endpointConfig.parameters,w.getValues,k):{},X=Vc(_.adapterCtx??_.optionAdapterCtx),G=g==null?void 0:g[B];if(typeof G!="function")return[Z,[]];try{const K=await Promise.resolve(G("",{getValues:w.getValues,watch:w.watch,ctx:X,params:q})),re=Array.isArray(K)?K:[];return[Z,re]}catch{return[Z,[]]}}));if(!H)return;const D={};for(const[_,Z]of S)D[_]=Z;te(D)})(),()=>{H=!1}},[g,w.getValues,w.watch,JSON.stringify(z.map(H=>({n:H.name,os:H.optionSource??null,ec:H.endpointConfig??null,ctx:H.adapterCtx??H.optionAdapterCtx??null,staticLen:Array.isArray(H.options)?H.options.length:-1}))),k]),E.useEffect(()=>{let H=!0;return(async()=>{for(const S of z){if(S.type!=="select")continue;const D=S.name,_=S.defaultSource;if(!_)continue;const Z=w.getValues(D);if(!(Z==null||(Array.isArray(Z)?Z.length===0:Z==="")))continue;const q=g==null?void 0:g[_];if(typeof q=="function")try{const X=Vc(S.adapterCtx??S.optionAdapterCtx),G=await Promise.resolve(q("",{getValues:w.getValues,watch:w.watch,ctx:X}));if(!H)return;const K=UA(G,!!S.multiple);w.setValue(D,K,{shouldDirty:!0,shouldTouch:!0})}catch{}}})(),()=>{H=!1}},[g,w.getValues,w.setValue,JSON.stringify(z.map(H=>({n:H.name,ds:H.defaultSource??null,mult:!!H.multiple})))]);const ne=C5(l),ae=A5(l,C),W=E.useMemo(()=>{const H={};return o.forEach((L,S)=>{L.type==="tabs"&&(H[S]=L.tabs[0].key)}),H},[o]),[A,F]=E.useState(W),[Y,U]=E.useState({}),[ee,le]=E.useState({}),ue=E.useRef({}),ge=E.useCallback(async()=>{const H={},L=l.filter(D=>{var Z,B,q;const _=D;return((Z=_.visibleWhen)==null?void 0:Z.endpoint)||((B=_.disabledWhen)==null?void 0:B.endpoint)||((q=_.clearWhen)==null?void 0:q.endpoint)});if(L.length===0)return;(await Promise.all(L.map(async D=>{const _=D,Z=_.name,B={};for(const q of["visibleWhen","disabledWhen","clearWhen"]){const X=_[q];if(X!=null&&X.enabled&&X.endpoint){const G=X.endpoint.key,K=g==null?void 0:g[G];if(typeof K=="function")try{const re=Ir(X.endpoint.parameters,w.getValues,k),ie=await Promise.resolve(K("",{getValues:w.getValues,watch:w.watch,params:re}));B[q]=typeof ie=="object"&&ie!==null?!!ie.ok:!!ie}catch(re){console.error(`Error evaluando regla backend para ${Z}.${q}:`,re),B[q]=!1}}}return{fieldName:Z,res:B}}))).forEach(({fieldName:D,res:_})=>{Object.keys(_).length>0&&(H[D]=_)}),U(H)},[l,g,w,k]),ce=E.useCallback(async H=>{var B;const L=H,S=L.name,D=L.asyncValidation.endpoint,_=D.key,Z=g==null?void 0:g[_];if(typeof Z=="function"){le(q=>({...q,[S]:{...q[S],loading:!0}}));try{const q=Ir(D.parameters,w.getValues,k),X=await Promise.resolve(Z("",{getValues:w.getValues,watch:w.watch,params:q})),G=typeof X=="object"&&X!==null?!!X.ok:!!X,K=typeof X=="object"&&X!==null?X.message:void 0;le(re=>({...re,[S]:{ok:G,message:K,loading:!1}})),G?((B=w.formState.errors[S])==null?void 0:B.type)==="manual"&&w.clearErrors(S):w.setError(S,{type:"manual",message:K||"Validación externa fallida"})}catch{le(X=>({...X,[S]:{ok:!1,message:"Error de conexión",loading:!1}}))}}},[g,w,k]),se=E.useCallback(async(H,L,S)=>{const D=l.filter(_=>{var X,G;const Z=_,B=(X=Z.asyncValidation)==null?void 0:X.endpoint;if(!B)return!1;const q=B.trigger||Z.asyncValidation.trigger||"onBlur";if(S&&q!==S&&!(q==="auto"&&S==="onChange"))return!1;if(L&&S!=="onSubmit"){const K=Z.name===L,re=Object.values(B.parameters||{}).some(pe=>pe.fieldRef===L),ie=(G=B.triggerFields)==null?void 0:G.includes(L);if(!K&&!re&&!ie)return!1}return!0});for(const _ of D){const Z=_,B=Z.name,q=Z.asyncValidation.endpoint;if(S==="onChange"&&q.trigger==="debounced"){ue.current[B]&&clearTimeout(ue.current[B]),ue.current[B]=setTimeout(()=>ce(_),q.debounceMs||300);continue}await ce(_)}},[l,ce]);E.useEffect(()=>{ge();const H=w.watch((L,{name:S})=>{ge(),S&&se(L,S,"onChange")});return()=>{H.unsubscribe(),Object.values(ue.current).forEach(L=>L&&clearTimeout(L))}},[ge,se,w]);const we=E.useCallback((H,L,S,D)=>{var Z;if(!(H!=null&&H.enabled))return L;let _=!0;if(H.rule)try{const B={...w.getValues(),...k,ACTIVE_VARIANT:n};_=!!vo(H.rule,B)}catch{_=L}if(_&&S&&D&&H.endpoint){const B=(Z=Y[S])==null?void 0:Z[D];if(B===void 0)return!1;_=B}return _},[w,Y,n]),de=E.useMemo(()=>l.map(H=>H).filter(H=>{var L;return((L=H.clearWhen)==null?void 0:L.enabled)&&(H.clearWhen.rule||H.clearWhen.endpoint)}).map(H=>({name:H.name,container:H.clearWhen})),[l]);E.useEffect(()=>{if(!de.length)return;const H=S=>{de.forEach(({name:D,container:_})=>{try{if(we(_,!1,D,"clearWhen")){const B=_.clearTo??"";S[D]!==B&&w.setValue(D,B,{shouldDirty:!0,shouldValidate:!0})}}catch{}})};H(w.getValues());const L=w.watch(()=>H(w.getValues()));return()=>{var S;return(S=L==null?void 0:L.unsubscribe)==null?void 0:S.call(L)}},[w,de,we]);const me=E.useCallback(H=>{const L=ct(v,H);if(!L)return"";const S={...k,...y,sys:k,form:y};return bl(L,S)},[v,k,y]),R=E.useCallback((H,L)=>{var ke,Fe,Oe,Ce;let S;if(typeof H=="string"){if(S=ne[H],!S){const xe=(l??[]).find(Ne=>(Ne==null?void 0:Ne.name)===H);if(xe)S=xe;else return null}}else S=H;const D=S.name,_=D?L?`${L}.${D}`:D:void 0,Z=S.visibleWhen;if(!we(Z,!0,D,"visibleWhen"))return null;let q=!!S.disabled;const X=S.disabledWhen,G=we(X,!1,D,"disabledWhen");if(X!=null&&X.enabled&&(q=G),!(X!=null&&X.enabled)&&D&&ae[D]&&(q=!0),S.type==="search"){const xe=typeof S.searchFn=="function",Ne=ho(S.searchSource,S.endpointConfig),Le=async ze=>{if(xe)return S.searchFn(ze,{getValues:w.getValues,watch:w.watch});if(Ne){const De=S.endpointConfig?Ir(S.endpointConfig.parameters,w.getValues,k):{},He=g==null?void 0:g[Ne];if(typeof He=="function")return await He(ze,{getValues:w.getValues,watch:w.watch,params:De});if(Array.isArray(He))return He}return[]},Me={};S.searchMode&&(Me.searchMode=S.searchMode),S.minChars&&(Me.minChars=S.minChars),S.debounceMs&&(Me.debounceMs=S.debounceMs),S.resolveByValue&&(Me.resolveByValue=S.resolveByValue);const Te=Nt(S.labelIconLeft??S.labelPrefixIcon),Ie=Nt(S.labelIconRight??S.labelSuffixIcon),Ae=Nt(S.prefixIcon),qe=Nt(S.suffixIcon);return s.jsx(mi,{name:_,control:C,searchFn:Le,label:me(S.label),size:S.size,width:S.width,disabled:q||T,labelPrefixIcon:Te,labelSuffixIcon:Ie,prefixIcon:Ae,suffixIcon:qe,...Me},_)}if(S.type==="inputGroup"){const xe=S,Ne=(xe.inputs??[]).map(Le=>{var Je,Ve;const Me=typeof Le=="string"?ne[Le]??(l??[]).find(tt=>(tt==null?void 0:tt.name)===Le):Le;if(!Me)return null;const Te=Me.name,Ie=L?`${L}.${Te}`:Te,Ae=Me.disabledWhen;let qe=!!Me.disabled;const ze=we(Ae,!1,Te,"disabledWhen");Ae!=null&&Ae.enabled&&(qe=ze),!(Ae!=null&&Ae.enabled)&&ae[Te]&&(qe=!0);const De=Nt(Me.labelIconLeft??Me.labelPrefixIcon),He=Nt(Me.labelIconRight??Me.labelSuffixIcon),We=Nt(Me.prefixIcon),Tt=Nt(Me.suffixIcon),Be={name:Ie,control:C,label:me(Me.label),size:Me.size,width:Me.width,placeholder:me(Me.placeholder),hasError:!!($[Ie]||L&&((Je=$[L])!=null&&Je[Te])),errorMessage:ct(v,(Ve=$[Ie])==null?void 0:Ve.message),loading:V,disabled:qe||T,suffixButton:Me.suffixButton,reserveErrorSpace:!0,labelPrefixIcon:De,labelSuffixIcon:He,prefixIcon:We,suffixIcon:Tt};return Me.type==="select"?{...Be,options:Me.options??Q[Te]??P[Te]??[],loadOptions:Me.options||Me.optionSource?void 0:Me.loadOptions}:{...Be,type:Me.type}}).filter(Boolean);return s.jsx(fi,{groupLabel:ct(v,xe.groupLabel),inputs:Ne,separator:xe.separator,useSeparator:xe.useSeparator,className:xe.className,showVisibleLabel:xe.showVisibleLabel,size:xe.size},`inputGroup_${_??xe.groupLabel??"group"}`)}if(S.type==="button"){const xe=S,Ne=xe.icon,Le=Ne&&typeof Ne=="object"&&Ne.name&&Ne.style?Nt(Ne):void 0;return s.jsx("div",{className:"self-center",children:s.jsx(fe,{type:"button",variant:xe.variant,size:xe.size,width:xe.width,icon:Le,iconPosition:xe.iconPosition,ariaLabel:me(xe.ariaLabel),onClick:xe.onClick,disabled:q||T,children:me(xe.label)})},_??xe.label)}if(S.type==="array"){const xe=S;return s.jsx(WA,{schema:{...xe,name:_},renderField:R},_)}const K=S.suffixButton,re=typeof K=="string"?R(K):K,ie=Nt(S.labelIconLeft??S.labelPrefixIcon),pe=Nt(S.labelIconRight??S.labelSuffixIcon),ve=Nt(S.prefixIcon),ye=Nt(S.suffixIcon),Se={name:_,control:C,disabled:q||T,label:me(S.label),size:S.size,width:S.width,placeholder:me(S.placeholder),info:ct(v,S.info),suffixButton:re,labelPrefixIcon:ie,labelSuffixIcon:pe,prefixIcon:ve,suffixIcon:ye,onBlur:()=>{se(w.getValues(),D,"onBlur"),l.filter(Ne=>{const Le=Ne;return["visibleWhen","disabledWhen","clearWhen"].some(Me=>{var Ie;const Te=(Ie=Le[Me])==null?void 0:Ie.endpoint;return(Te==null?void 0:Te.trigger)==="onBlur"&&Object.values(Te.parameters||{}).some(Ae=>Ae.fieldRef===D)})}).length>0&&ge()}};switch(S.type){case"select":{const xe=S.options??Q[D]??P[D]??[],Ne=Array.isArray(xe)&&xe.length?`${xe.length}:${xe.map(Me=>String((Me==null?void 0:Me.value)??"")).join("|")}`:"0",Le=!S.options&&!S.optionSource&&S.loadOptions;return s.jsx(Ft,{name:_,control:C,render:({field:Me})=>{var Te;return s.jsx(Ke,{...Se,value:Me.value,onChange:Me.onChange,options:xe,loadOptions:Le||void 0,hasError:!!$[_],errorMessage:ct(v,(Te=$[_])==null?void 0:Te.message),suffixButton:re})}},`${_}:${Ne}`)}case"textarea":return s.jsx(Ft,{name:_,control:C,render:({field:xe,fieldState:Ne})=>{var Le;return s.jsx(Nr,{...Se,value:xe.value,onChange:xe.onChange,maxLength:S.maxLength,showCounter:!!S.showCounter,hasError:!!Ne.error,errorMessage:ct(v,(Le=Ne.error)==null?void 0:Le.message)})}},_);case"file":return s.jsx(li,{...Se,defaultValue:[],maxFiles:S.maxFiles,accept:S.accept,hideDropZone:S.hideDropZone,hasError:!!$[_],errorMessage:ct(v,(ke=$[_])==null?void 0:ke.message)},_);case"checkbox":return s.jsx(rt,{...Se,defaultValue:!1,hasError:!!$[_],errorMessage:ct(v,(Fe=$[_])==null?void 0:Fe.message),name:_},_);case"date":return s.jsx(wn,{...Se,defaultValue:"",showTime:!!S.showTime,hasError:!!$[_],errorMessage:ct(v,(Oe=$[_])==null?void 0:Oe.message)},_);case"optionGroup":return s.jsx(Uo,{...Se,options:S.options||[],multiple:S.multiple,vertical:S.vertical,groupLabel:S.groupLabel,defaultValue:S.defaultValue,className:S.width?void 0:"w-full",name:_},_);default:return s.jsx(Ho,{...Se,type:S.type,loadingDefaults:V,hasError:!!$[_],errorMessage:ct(v,(Ce=$[_])==null?void 0:Ce.message),suffixButton:re,name:_},_)}},[l,ne,C,$,T,V,P,Q,we,ae,w.getValues,w.watch,g,v]);return s.jsx(ei,{...w,children:s.jsxs("form",{noValidate:!0,onSubmit:M(async H=>{await se(H,void 0,"onSubmit"),!(Object.keys(w.formState.errors).length>0)&&(await i(H),p(c??v("ds.form.saveSuccess"),"success"))},H=>{bA(H),p(u??v("ds.form.saveError"),"error")}),className:"space-y-6",children:[o.map((H,L)=>H.type==="rows"?s.jsx(E.Fragment,{children:H.sections.map((S,D)=>s.jsx("div",{children:s.jsx(ot,{title:me(S.sectionTitle),defaultOpen:S.defaultOpen,children:S.rows.map((_,Z)=>s.jsxs("div",{children:[_.title&&s.jsx("h2",{className:"mb-2 text-lg text-[var(--color-ds-text-primary)]",children:me(_.title)}),s.jsx("div",{className:"flex flex-wrap -mx-2",children:_.columns.map((B,q)=>{var X;return s.jsx("div",{className:`${B.width} px-2 flex flex-col`,children:s.jsx("div",{className:"",children:B.fields?B.fields.map(G=>R(G)):(X=B.rows)==null?void 0:X.map((G,K)=>s.jsx("div",{className:"mb-1",children:s.jsx("div",{className:"flex flex-wrap -mx-2",children:G.columns.map((re,ie)=>{var pe;return s.jsx("div",{className:`${re.width} px-2`,children:(pe=re.fields)==null?void 0:pe.map(ve=>R(ve))},ie)})})},K))})},q)})})]},Z))})},D))},L):s.jsx(fr,{options:H.tabs.map(S=>{const D=S.icon?yn(S.icon.name,S.icon.style):null;return{label:me(S.label),value:S.key,disabled:S.disabled,icon:D?s.jsx(D,{className:"w-4 h-4"}):null}}),value:A[L],onChange:S=>F(D=>({...D,[L]:S})),children:Object.fromEntries(H.tabs.map(S=>[S.key,s.jsx("div",{className:"space-y-6",children:S.sections.map((D,_)=>s.jsx("div",{className:"mb-6",children:s.jsx(ot,{title:me(D.sectionTitle),defaultOpen:D.defaultOpen,children:D.rows.map((Z,B)=>s.jsx("div",{children:s.jsx("div",{className:"flex flex-wrap -mx-2",children:Z.columns.map((q,X)=>{var G;return s.jsx("div",{className:`${q.width??"flex-1"} px-2 flex flex-col`,children:s.jsx("div",{className:"space-y-4",children:(G=q.fields)==null?void 0:G.map((K,re)=>s.jsx(E.Fragment,{children:R(K)},re))})},X)})})},B))})},_))},S.key)]))},L)),s.jsx("footer",{className:"py-4 w-full flex justify-center space-x-4",children:d??s.jsx(fe,{type:"submit",variant:"primary",icon:Br,size:"sm",disabled:T||V||O>0,children:v(T?"ds.form.sending":"ds.form.submit")})})]})})}const KA={sm:"h-8 w-8",md:"h-10 w-10",lg:"h-12 w-12"};function It({icon:e,size:t="md",ariaLabel:r,disabled:n=!1,onClick:o,className:l,...i}){return s.jsx("button",{type:"button","aria-label":r,disabled:n,onClick:o,className:he("inline-flex items-center justify-center","rounded-full","bg-transparent","text-[var(--color-ds-text-primary)]","transition-transform","focus:outline-none",KA[t],n?"opacity-50 cursor-not-allowed":["hover:scale-110","hover:animate-pulse","hover:bg-[var(--color-ds-background-neutral-hover)]"],l),...i,children:s.jsx(e,{className:he(t==="sm"?"h-4 w-4":t==="md"?"h-5 w-5":"h-6 w-6")})})}function L5({dark:e,onToggle:t}){return s.jsx("button",{type:"button","aria-pressed":e,"aria-label":e?"Cambiar a modo claro":"Cambiar a modo oscuro",onClick:t,className:he("relative inline-flex items-center transition-colors focus:outline-none duration-200 ease-in-out","bg-[var(--color-ds-background-accent)]","h-6 w-12 rounded-full"),children:s.jsxs("div",{className:he("absolute bg-[var(--color-ds-background-page)] flex items-center justify-center rounded-full transition-transform duration-200 ease-in-out","h-5 w-5",e?"translate-x-6":"translate-x-1"),children:[s.jsx(vt,{component:Gl,size:"sm",className:he("absolute transition-opacity duration-200 ease-in-out",e?"opacity-0":"opacity-100 text-[var(--color-ds-background-accent)]")}),s.jsx(vt,{component:zl,size:"sm",className:he("absolute transition-opacity duration-200 ease-in-out",e?"opacity-100 text-[var(--color-ds-background-accent)]":"opacity-0")})]})})}const Dc="licytal:ui:theme",$5=E.createContext({theme:"light",dark:!1,toggle:()=>{}});function JA({children:e}){const[t,r]=E.useState(!1),[n,o]=E.useState("light");E.useEffect(()=>{if(typeof window>"u")return;const i=localStorage.getItem(Dc);i==="light"||i==="dark"?o(i):window.matchMedia("(prefers-color-scheme: dark)").matches&&o("dark"),r(!0)},[]),E.useEffect(()=>{t&&(document.documentElement.classList.toggle("dark",n==="dark"),localStorage.setItem(Dc,n))},[n,t]);const l=()=>o(i=>i==="light"?"dark":"light");return t?s.jsx($5.Provider,{value:{theme:n,dark:n==="dark",toggle:l},children:e}):null}const pi=()=>E.useContext($5),Pn={locale:"licytal:ui:locale",theme:"licytal:ui:theme"},I5=({pinnedPages:e,onRemovePinned:t,onBack:r,dark:n,locale:o,languageOptions:l,onChangeLocale:i,profile:c="",profileOptions:u=[],onChangeProfile:d})=>{const m=e.slice(0,3),{toggle:f}=pi(),h=v=>{try{localStorage.setItem(Pn.locale,v)}catch{}i==null||i(v)},p=()=>{const v=!n;try{localStorage.setItem(Pn.theme,v?"dark":"light")}catch{}f()};return E.useEffect(()=>{try{const v=localStorage.getItem(Pn.locale);v&&v!==o&&(i==null||i(v))}catch{}},[]),E.useEffect(()=>{if(o)try{localStorage.setItem(Pn.locale,o)}catch{}},[o]),E.useEffect(()=>{try{const v=localStorage.getItem(Pn.theme);if(!v)return;v==="dark"!==n&&f()}catch{}},[]),s.jsxs("header",{className:"flex items-center bg-[var(--color-ds-background-page)] py-2",children:[s.jsx("div",{className:"flex items-center space-x-2",children:m.map(v=>s.jsxs("div",{className:"flex items-center",children:[s.jsx("a",{href:v.href,className:he("inline-flex items-center rounded-lg","py-1 px-1 my-1 text-ds-sm","bg-transparent text-[var(--color-ds-text-primary)]","transition-colors duration-200 ease-in-out","hover:bg-[var(--color-ds-border-muted)] hover:animate-pulse"),children:v.label}),s.jsx(It,{icon:nt,size:"sm",ariaLabel:`Remove ${v.label}`,onClick:()=>t(v.id)})]},v.id))}),s.jsx("div",{className:"flex-grow"}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(Ke,{size:"sm",width:"auto",options:l,value:o,onChange:h,disableErrorPlaceholder:!0,label:"Idioma",labelHidden:!0}),!!u.length&&s.jsx(Ke,{size:"sm",width:"auto",options:u,value:c,onChange:v=>d==null?void 0:d(v),disableErrorPlaceholder:!0,label:"Perfil",labelHidden:!0}),s.jsx(L5,{dark:n,onToggle:p})]})]})},YA=({loading:e=!1,ariaLabel:t="Cargando..."})=>e?s.jsxs("div",{className:`\r
98
+ hover:bg-[var(--color-ds-background-surface)]`,onClick:()=>{const me=String(de.value).trim();k(e,me,{shouldDirty:!0,shouldValidate:!0}),z(de.label??me),Q.current=!1,te.current=!1,V(!1)},children:de.label},String(de.value)))})]})}})}const Dn=(e,t)=>e[t],Bc=e=>e instanceof Date?e.getTime():e;function DA(e,t,r){const n=Bc(e),o=Bc(t);return typeof n=="number"&&typeof o=="number"||typeof n=="string"&&typeof o=="string"?r==="gt"?n>o:r==="gte"?n>=o:r==="lt"?n<o:n<=o:!1}function vo(e,t){if(!e)return!1;switch(e.op){case"eq":return Dn(t,e.field)===e.value;case"neq":return Dn(t,e.field)!==e.value;case"in":return e.values.includes(Dn(t,e.field));case"notIn":return!e.values.includes(Dn(t,e.field));case"gt":case"gte":case"lt":case"lte":return DA(Dn(t,e.field),e.value,e.op);case"and":return e.rules.every(r=>vo(r,t));case"or":return e.rules.some(r=>vo(r,t));case"always":return!!e.value;default:return!1}}function hi(e){return!!e&&(typeof e=="function"||typeof e=="object")}function yn(e,t){const r=t==="outline"?bn:xn,n=r==null?void 0:r[e];return hi(n)?n:null}const PA=Object.entries(bn).filter(([e,t])=>e.endsWith("Icon")&&hi(t)).map(([e,t])=>({name:e,Icon:t,style:"outline"})),zA=Object.entries(xn).filter(([e,t])=>e.endsWith("Icon")&&hi(t)).map(([e,t])=>({name:e,Icon:t,style:"solid"})),HA=ql||Ul||(e=>s.jsx("svg",{...e})),Fr=({value:e,onChange:t,buttonLabel:r,disabled:n,className:o})=>{const[l,i]=E.useState(!1),[c,u]=E.useState(""),[d,m]=E.useState((e==null?void 0:e.style)??"outline"),f=e&&yn(e.name,e.style)||HA,h=E.useCallback((v,b)=>{const g=yn(v,b);t==null||t({name:v,style:b},g),i(!1)},[t]),p=E.useCallback(()=>{t==null||t(void 0,void 0),i(!1)},[t]);return s.jsxs(s.Fragment,{children:[s.jsx(fe,{size:"sm",variant:"outline",shape:"circle",className:`rounded-full p-0 w-8 h-8 inline-flex items-center justify-center ${o??""}`,disabled:n,onClick:()=>i(!0),ariaLabel:"Elegir icono",title:r||"Elegir icono",children:s.jsx(f,{className:"h-4 w-4"})}),s.jsx(Et,{isOpen:l,onClose:()=>i(!1),title:"Seleccionar icono",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(je,{labelHidden:!0,placeholder:"Buscar icono (p. ej. 'user', 'arrow', 'calendar'...)",value:c,onChange:v=>u(v.target.value)}),s.jsx(fr,{options:[{label:"Outline",value:"outline"},{label:"Solid",value:"solid"}],value:d,onChange:v=>m(v),children:{outline:s.jsx(Zc,{items:PA,query:c,onPick:v=>h(v,"outline"),onClear:p}),solid:s.jsx(Zc,{items:zA,query:c,onPick:v=>h(v,"solid"),onClear:p})}})]})})]})},Zc=({items:e,query:t,onPick:r,onClear:n})=>{const o=E.useMemo(()=>{if(!t.trim())return e;const i=t.trim().toLowerCase().replace(/\s+/g,"");return e.filter(c=>c.name.toLowerCase().includes(i))},[e,t]),l=nt;return s.jsx("div",{className:"custom-scroll max-h-[60vh] overflow-y-auto",children:s.jsxs("div",{className:"grid gap-2 grid-cols-3 sm:grid-cols-4 md:grid-cols-6",children:[s.jsxs("button",{type:"button",onClick:n,className:"group w-full aspect-square border border-[var(--color-ds-border-default-50)] rounded-lg p-1 bg-[var(--color-ds-background-page)] hover:bg-[var(--color-ds-background-accent)]/5 hover:border-[var(--color-ds-border-default)] transition focus:outline-none",title:"Ninguno","aria-label":"Quitar icono",children:[s.jsx("div",{className:"h-full w-full flex items-center justify-center",children:l?s.jsx(l,{className:"w-6 h-6"}):s.jsx("span",{className:"text-ds-lg",children:"×"})}),s.jsx("div",{className:"mt-1 text-center",children:s.jsx("span",{className:"block text-[11px] leading-tight text-[var(--color-ds-text-secondary)] truncate",children:"Ninguno"})})]}),(o.length===0?e:o).map(({name:i,Icon:c})=>s.jsxs("button",{type:"button",onClick:()=>r(i),className:"group w-full aspect-square border border-[var(--color-ds-border-default-50)] rounded-lg p-1 bg-[var(--color-ds-background-page)] hover:bg-[var(--color-ds-background-accent)]/5 hover:border-[var(--color-ds-border-default)] transition focus:outline-none",title:i,"aria-label":`Elegir ${i}`,children:[s.jsx("div",{className:"h-full w-full flex items-center justify-center",children:s.jsx(c,{className:"w-6 h-6 text-[var(--color-ds-text-primary)]"})}),s.jsx("div",{className:"mt-1 text-center",children:s.jsx("span",{className:"block text-[11px] leading-tight text-[var(--color-ds-text-secondary)] truncate",children:i.replace(/Icon$/,"")})})]},i))]})})};function ct(e,t,r=""){if(!t)return r;if(typeof t=="object"&&t!==null){if(t.type==="complex"){const o=[];return t.header&&o.push(`<strong>${t.header}</strong>`),t.template&&o.push(t.template),o.join("<br/>")||r}return r}return e(t,{defaultValue:t})}const WA=({schema:e,renderField:t})=>{var b,g,x;const{control:r}=Sr(),{fields:n,append:o,remove:l}=fx({control:r,name:e.name}),{label:i,addLabel:c="Añadir",items:u,disabled:d,validation:m,className:f}=e,{formState:{errors:h}}=Sr(),p=((g=(b=h[e.name])==null?void 0:b.root)==null?void 0:g.message)||((x=h[e.name])==null?void 0:x.message),v=typeof p=="string"?p:void 0;return s.jsxs("div",{className:he("space-y-3",f),children:[i&&s.jsx("div",{className:"flex items-center justify-between",children:s.jsx("label",{className:"block text-ds-sm font-medium text-[var(--color-ds-text-primary)]",children:i})}),s.jsx("div",{className:"space-y-4",children:n.map((w,j)=>{const k=`${e.name}.${j}`;return s.jsxs("div",{className:"relative rounded-lg border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)] p-4 group",children:[!d&&s.jsx("div",{className:"absolute top-2 right-2",children:s.jsx(fe,{size:"xs",variant:"ghost",className:"text-[var(--color-ds-text-error)] hover:bg-[var(--color-ds-background-error-hover)]",onClick:()=>l(j),title:"Eliminar fila",ariaLabel:"Eliminar fila",children:s.jsx(bt,{className:"w-4 h-4"})})}),s.jsx("div",{className:"grid grid-cols-1 gap-4",children:u.map((y,C)=>s.jsx(E.Fragment,{children:t(y,k)},C))})]},w.id)})}),n.length===0&&s.jsx("div",{className:"text-ds-sm text-[var(--color-ds-text-secondary)] italic p-2 border border-dashed border-[var(--color-ds-border-default-50)] rounded bg-[var(--color-ds-background-subtle)]",children:"No hay elementos."}),v&&s.jsx("p",{className:"text-xs text-[var(--color-ds-text-error)]",children:v}),!d&&s.jsxs(fe,{type:"button",variant:"outline",size:"sm",onClick:()=>{o({})},children:[s.jsx(er,{className:"w-4 h-4 mr-1"}),c]})]})};function Vc(e){if(e){if(typeof e=="string")try{return JSON.parse(e)}catch{return}if(typeof e=="object")return e}}function UA(e,t){var r;return Array.isArray(e)?e.length&&typeof e[0]=="object"&&"value"in e[0]?t?e.map(n=>n.value):((r=e[0])==null?void 0:r.value)??"":t?e:e[0]??"":e&&typeof e=="object"&&"value"in e?e.value:e??(t?[]:"")}const qA=e=>e.type!=="inputGroup"&&e.type!=="button";function GA(){try{return St()??void 0}catch{return}}function Nt(e){if(!e||typeof e!="object")return;const t=e.name,r=e.style;if(!(!t||!r))return yn(t,r)||void 0}function O5({schema:e,resolver:t,serviceRegistry:r,activeVariantId:n}){var J;const{layout:o,fields:l=[],onSubmit:i,successMessage:c,errorMessage:u,footerButtons:d,defaultValues:m,loadDefaultValues:f,validationSchema:h}=e,{show:p}=qr(),{t:v}=Ct(),b=GA(),g=r??((J=b==null?void 0:b.services)==null?void 0:J.registry)??void 0,x=E.useMemo(()=>{if(t)return t;try{const H=h??ui(e);return ii(H)}catch{return}},[t,e,h]),w=ai({resolver:x,mode:"onBlur",reValidateMode:"onChange",defaultValues:m??{}}),j=un(H=>H.setRuntimeState),k=un(H=>H.systemContext),y=un(H=>H.formValues);E.useEffect(()=>{j({isActive:!0});let H=!1;return(async()=>{const L=e.defaultSource,S=e.onloadEndpoint;let D={};if(e.variables&&Array.isArray(e.variables)&&(e.variables.forEach(Z=>{Z.type==="constant"&&(D[Z.key]=Z.value)}),e.variables.forEach(Z=>{if(Z.type==="computed"&&Z.value)try{const B=new Function("ctx",`return (${Z.value});`);D[Z.key]=B(D)}catch(B){console.warn(`[FormRenderer] Error evaluating computed variable "${Z.key}":`,B),D[Z.key]=null}})),L)try{const Z=g==null?void 0:g[L];if(Z){const B=typeof Z=="function"?await Z():Z;B&&typeof B=="object"&&(D={...D,...B})}}catch{}j({systemContext:{...D}});const _=[];if(S&&_.push(S),e.onloadEndpoints&&Array.isArray(e.onloadEndpoints)&&_.push(...e.onloadEndpoints),_.length>0){const Z=async q=>{if(!q)return{};try{const X=g==null?void 0:g[q.key];if(!X)return console.warn("[FormRenderer] Provider not found for key:",q.key),{};const G=Ir(q.parameters,(()=>({})),{...D,ACTIVE_VARIANT:e.activeVariantId});console.log(`[FormRenderer] Calling ${q.key} with params:`,G);const K=await Promise.resolve(X("",{getValues:(()=>({})),watch:(()=>{}),params:G}));let re=K;if(typeof K=="string")try{re=JSON.parse(K)}catch(ie){console.warn("[FormRenderer] Failed to parse onload response string",ie)}return re&&typeof re=="object"?re:(console.warn("[FormRenderer] OnLoad response is not an object:",re),{})}catch(X){return console.error("Error in onloadEndpoint",X),{}}};(await Promise.all(_.map(Z))).forEach(q=>{q&&typeof q=="object"&&(D={...D,...q})}),H||j({systemContext:{...D}})}if(!H&&Object.keys(D).length>0){const Z={...e.defaultValues??{}};Object.assign(Z,D);const B=e.fields.map(q=>q.name);Object.keys(D).forEach(q=>{const X=q.toLowerCase(),G=B.find(K=>K.toLowerCase()===X);G&&(Z[G]===void 0||Z[G]==="")&&(Z[G]=D[q])}),w.reset(Z)}})(),()=>{H=!0,j({isActive:!1,systemContext:{},formValues:{}})}},[e,g,w.reset]);const{control:C,reset:N,handleSubmit:M,formState:{errors:$,isSubmitting:T}}=w,[V,I]=E.useState(!1);E.useEffect(()=>{f&&(I(!0),f().then(H=>N(H)).finally(()=>I(!1)))},[f,N]);const z=E.useMemo(()=>(l??[]).filter(qA),[l]),{loadingCount:O,optionsMap:P}=M5(z),[Q,te]=E.useState({});E.useEffect(()=>{let H=!0;return(async()=>{const S=await Promise.all(z.filter(_=>_.type==="select"&&(_.optionSource||_.endpointConfig)).map(async _=>{const Z=_.name,B=ho(_.optionSource,_.endpointConfig);if(!B)return[Z,[]];const q=_.endpointConfig?Ir(_.endpointConfig.parameters,w.getValues,k):{},X=Vc(_.adapterCtx??_.optionAdapterCtx),G=g==null?void 0:g[B];if(typeof G!="function")return[Z,[]];try{const K=await Promise.resolve(G("",{getValues:w.getValues,watch:w.watch,ctx:X,params:q})),re=Array.isArray(K)?K:[];return[Z,re]}catch{return[Z,[]]}}));if(!H)return;const D={};for(const[_,Z]of S)D[_]=Z;te(D)})(),()=>{H=!1}},[g,w.getValues,w.watch,JSON.stringify(z.map(H=>({n:H.name,os:H.optionSource??null,ec:H.endpointConfig??null,ctx:H.adapterCtx??H.optionAdapterCtx??null,staticLen:Array.isArray(H.options)?H.options.length:-1}))),k]),E.useEffect(()=>{let H=!0;return(async()=>{for(const S of z){if(S.type!=="select")continue;const D=S.name,_=S.defaultSource;if(!_)continue;const Z=w.getValues(D);if(!(Z==null||(Array.isArray(Z)?Z.length===0:Z==="")))continue;const q=g==null?void 0:g[_];if(typeof q=="function")try{const X=Vc(S.adapterCtx??S.optionAdapterCtx),G=await Promise.resolve(q("",{getValues:w.getValues,watch:w.watch,ctx:X}));if(!H)return;const K=UA(G,!!S.multiple);w.setValue(D,K,{shouldDirty:!0,shouldTouch:!0})}catch{}}})(),()=>{H=!1}},[g,w.getValues,w.setValue,JSON.stringify(z.map(H=>({n:H.name,ds:H.defaultSource??null,mult:!!H.multiple})))]);const ne=C5(l),ae=A5(l,C),W=E.useMemo(()=>{const H={};return o.forEach((L,S)=>{L.type==="tabs"&&(H[S]=L.tabs[0].key)}),H},[o]),[A,F]=E.useState(W),[Y,U]=E.useState({}),[ee,le]=E.useState({}),ue=E.useRef({}),ge=E.useCallback(async()=>{const H={},L=l.filter(D=>{var Z,B,q;const _=D;return((Z=_.visibleWhen)==null?void 0:Z.endpoint)||((B=_.disabledWhen)==null?void 0:B.endpoint)||((q=_.clearWhen)==null?void 0:q.endpoint)});if(L.length===0)return;(await Promise.all(L.map(async D=>{const _=D,Z=_.name,B={};for(const q of["visibleWhen","disabledWhen","clearWhen"]){const X=_[q];if(X!=null&&X.enabled&&X.endpoint){const G=X.endpoint.key,K=g==null?void 0:g[G];if(typeof K=="function")try{const re=Ir(X.endpoint.parameters,w.getValues,k),ie=await Promise.resolve(K("",{getValues:w.getValues,watch:w.watch,params:re}));B[q]=typeof ie=="object"&&ie!==null?!!ie.ok:!!ie}catch(re){console.error(`Error evaluando regla backend para ${Z}.${q}:`,re),B[q]=!1}}}return{fieldName:Z,res:B}}))).forEach(({fieldName:D,res:_})=>{Object.keys(_).length>0&&(H[D]=_)}),U(H)},[l,g,w,k]),ce=E.useCallback(async H=>{var B;const L=H,S=L.name,D=L.asyncValidation.endpoint,_=D.key,Z=g==null?void 0:g[_];if(typeof Z=="function"){le(q=>({...q,[S]:{...q[S],loading:!0}}));try{const q=Ir(D.parameters,w.getValues,k),X=await Promise.resolve(Z("",{getValues:w.getValues,watch:w.watch,params:q})),G=typeof X=="object"&&X!==null?!!X.ok:!!X,K=typeof X=="object"&&X!==null?X.message:void 0;le(re=>({...re,[S]:{ok:G,message:K,loading:!1}})),G?((B=w.formState.errors[S])==null?void 0:B.type)==="manual"&&w.clearErrors(S):w.setError(S,{type:"manual",message:K||"Validación externa fallida"})}catch{le(X=>({...X,[S]:{ok:!1,message:"Error de conexión",loading:!1}}))}}},[g,w,k]),se=E.useCallback(async(H,L,S)=>{const D=l.filter(_=>{var X,G;const Z=_,B=(X=Z.asyncValidation)==null?void 0:X.endpoint;if(!B)return!1;const q=B.trigger||Z.asyncValidation.trigger||"onBlur";if(S&&q!==S&&!(q==="auto"&&S==="onChange"))return!1;if(L&&S!=="onSubmit"){const K=Z.name===L,re=Object.values(B.parameters||{}).some(pe=>pe.fieldRef===L),ie=(G=B.triggerFields)==null?void 0:G.includes(L);if(!K&&!re&&!ie)return!1}return!0});for(const _ of D){const Z=_,B=Z.name,q=Z.asyncValidation.endpoint;if(S==="onChange"&&q.trigger==="debounced"){ue.current[B]&&clearTimeout(ue.current[B]),ue.current[B]=setTimeout(()=>ce(_),q.debounceMs||300);continue}await ce(_)}},[l,ce]);E.useEffect(()=>{ge();const H=w.watch((L,{name:S})=>{ge(),S&&se(L,S,"onChange")});return()=>{H.unsubscribe(),Object.values(ue.current).forEach(L=>L&&clearTimeout(L))}},[ge,se,w]);const we=E.useCallback((H,L,S,D)=>{var Z;if(!(H!=null&&H.enabled))return L;let _=!0;if(H.rule)try{const B={...w.getValues(),...k,ACTIVE_VARIANT:n};_=!!vo(H.rule,B)}catch{_=L}if(_&&S&&D&&H.endpoint){const B=(Z=Y[S])==null?void 0:Z[D];if(B===void 0)return!1;_=B}return _},[w,Y,n]),de=E.useMemo(()=>l.map(H=>H).filter(H=>{var L;return((L=H.clearWhen)==null?void 0:L.enabled)&&(H.clearWhen.rule||H.clearWhen.endpoint)}).map(H=>({name:H.name,container:H.clearWhen})),[l]);E.useEffect(()=>{if(!de.length)return;const H=S=>{de.forEach(({name:D,container:_})=>{try{if(we(_,!1,D,"clearWhen")){const B=_.clearTo??"";S[D]!==B&&w.setValue(D,B,{shouldDirty:!0,shouldValidate:!0})}}catch{}})};H(w.getValues());const L=w.watch(()=>H(w.getValues()));return()=>{var S;return(S=L==null?void 0:L.unsubscribe)==null?void 0:S.call(L)}},[w,de,we]);const me=E.useCallback(H=>{const L=ct(v,H);if(!L)return"";const S={...k,...y,sys:k,form:y};return bl(L,S)},[v,k,y]),R=E.useCallback((H,L)=>{var ke,Fe,Oe,Ce;let S;if(typeof H=="string"){if(S=ne[H],!S){const xe=(l??[]).find(Ne=>(Ne==null?void 0:Ne.name)===H);if(xe)S=xe;else return null}}else S=H;const D=S.name,_=D?L?`${L}.${D}`:D:void 0,Z=S.visibleWhen;if(!we(Z,!0,D,"visibleWhen"))return null;let q=!!S.disabled;const X=S.disabledWhen,G=we(X,!1,D,"disabledWhen");if(X!=null&&X.enabled&&(q=G),!(X!=null&&X.enabled)&&D&&ae[D]&&(q=!0),S.type==="search"){const xe=typeof S.searchFn=="function",Ne=ho(S.searchSource,S.endpointConfig),Le=async ze=>{if(xe)return S.searchFn(ze,{getValues:w.getValues,watch:w.watch});if(Ne){const De=S.endpointConfig?Ir(S.endpointConfig.parameters,w.getValues,k):{},He=g==null?void 0:g[Ne];if(typeof He=="function")return await He(ze,{getValues:w.getValues,watch:w.watch,params:De});if(Array.isArray(He))return He}return[]},Me={};S.searchMode&&(Me.searchMode=S.searchMode),S.minChars&&(Me.minChars=S.minChars),S.debounceMs&&(Me.debounceMs=S.debounceMs),S.resolveByValue&&(Me.resolveByValue=S.resolveByValue);const Te=Nt(S.labelIconLeft??S.labelPrefixIcon),Ie=Nt(S.labelIconRight??S.labelSuffixIcon),Ae=Nt(S.prefixIcon),qe=Nt(S.suffixIcon);return s.jsx(mi,{name:_,control:C,searchFn:Le,label:me(S.label),size:S.size,width:S.width,disabled:q||T,labelPrefixIcon:Te,labelSuffixIcon:Ie,prefixIcon:Ae,suffixIcon:qe,...Me},_)}if(S.type==="inputGroup"){const xe=S,Ne=(xe.inputs??[]).map(Le=>{var Je,Ve;const Me=typeof Le=="string"?ne[Le]??(l??[]).find(tt=>(tt==null?void 0:tt.name)===Le):Le;if(!Me)return null;const Te=Me.name,Ie=L?`${L}.${Te}`:Te,Ae=Me.disabledWhen;let qe=!!Me.disabled;const ze=we(Ae,!1,Te,"disabledWhen");Ae!=null&&Ae.enabled&&(qe=ze),!(Ae!=null&&Ae.enabled)&&ae[Te]&&(qe=!0);const De=Nt(Me.labelIconLeft??Me.labelPrefixIcon),He=Nt(Me.labelIconRight??Me.labelSuffixIcon),We=Nt(Me.prefixIcon),Tt=Nt(Me.suffixIcon),Be={name:Ie,control:C,label:me(Me.label),size:Me.size,width:Me.width,placeholder:me(Me.placeholder),hasError:!!($[Ie]||L&&((Je=$[L])!=null&&Je[Te])),errorMessage:ct(v,(Ve=$[Ie])==null?void 0:Ve.message),loading:V,disabled:qe||T,suffixButton:Me.suffixButton,reserveErrorSpace:!0,labelPrefixIcon:De,labelSuffixIcon:He,prefixIcon:We,suffixIcon:Tt};return Me.type==="select"?{...Be,options:Me.options??Q[Te]??P[Te]??[],loadOptions:Me.options||Me.optionSource?void 0:Me.loadOptions}:{...Be,type:Me.type}}).filter(Boolean);return s.jsx(fi,{groupLabel:ct(v,xe.groupLabel),inputs:Ne,separator:xe.separator,useSeparator:xe.useSeparator,className:xe.className,showVisibleLabel:xe.showVisibleLabel,size:xe.size},`inputGroup_${_??xe.groupLabel??"group"}`)}if(S.type==="button"){const xe=S,Ne=xe.icon,Le=Ne&&typeof Ne=="object"&&Ne.name&&Ne.style?Nt(Ne):void 0;return s.jsx("div",{className:"self-center",children:s.jsx(fe,{type:"button",variant:xe.variant,size:xe.size,width:xe.width,icon:Le,iconPosition:xe.iconPosition,ariaLabel:me(xe.ariaLabel),onClick:xe.onClick,disabled:q||T,children:me(xe.label)})},_??xe.label)}if(S.type==="array"){const xe=S;return s.jsx(WA,{schema:{...xe,name:_},renderField:R},_)}const K=S.suffixButton,re=typeof K=="string"?R(K):K,ie=Nt(S.labelIconLeft??S.labelPrefixIcon),pe=Nt(S.labelIconRight??S.labelSuffixIcon),ve=Nt(S.prefixIcon),ye=Nt(S.suffixIcon),Se={name:_,control:C,disabled:q||T,label:me(S.label),size:S.size,width:S.width,placeholder:me(S.placeholder),info:ct(v,S.info),suffixButton:re,labelPrefixIcon:ie,labelSuffixIcon:pe,prefixIcon:ve,suffixIcon:ye,onBlur:()=>{se(w.getValues(),D,"onBlur"),l.filter(Ne=>{const Le=Ne;return["visibleWhen","disabledWhen","clearWhen"].some(Me=>{var Ie;const Te=(Ie=Le[Me])==null?void 0:Ie.endpoint;return(Te==null?void 0:Te.trigger)==="onBlur"&&Object.values(Te.parameters||{}).some(Ae=>Ae.fieldRef===D)})}).length>0&&ge()}};switch(S.type){case"select":{const xe=S.options??Q[D]??P[D]??[],Ne=Array.isArray(xe)&&xe.length?`${xe.length}:${xe.map(Me=>String((Me==null?void 0:Me.value)??"")).join("|")}`:"0",Le=!S.options&&!S.optionSource&&S.loadOptions;return s.jsx(Ft,{name:_,control:C,render:({field:Me})=>{var Te;return s.jsx(Ke,{...Se,value:Me.value,onChange:Me.onChange,options:xe,loadOptions:Le||void 0,hasError:!!$[_],errorMessage:ct(v,(Te=$[_])==null?void 0:Te.message),suffixButton:re})}},`${_}:${Ne}`)}case"textarea":return s.jsx(Ft,{name:_,control:C,render:({field:xe,fieldState:Ne})=>{var Le;return s.jsx(Nr,{...Se,value:xe.value,onChange:xe.onChange,maxLength:S.maxLength,showCounter:!!S.showCounter,hasError:!!Ne.error,errorMessage:ct(v,(Le=Ne.error)==null?void 0:Le.message)})}},_);case"file":return s.jsx(li,{...Se,defaultValue:[],maxFiles:S.maxFiles,accept:S.accept,hideDropZone:S.hideDropZone,hasError:!!$[_],errorMessage:ct(v,(ke=$[_])==null?void 0:ke.message)},_);case"checkbox":return s.jsx(rt,{...Se,defaultValue:!1,hasError:!!$[_],errorMessage:ct(v,(Fe=$[_])==null?void 0:Fe.message),name:_},_);case"date":return s.jsx(wn,{...Se,defaultValue:"",showTime:!!S.showTime,hasError:!!$[_],errorMessage:ct(v,(Oe=$[_])==null?void 0:Oe.message)},_);case"optionGroup":return s.jsx(Uo,{...Se,options:S.options||[],multiple:S.multiple,vertical:S.vertical,groupLabel:S.groupLabel,defaultValue:S.defaultValue,className:S.width?void 0:"w-full",name:_},_);default:return s.jsx(Ho,{...Se,type:S.type,loadingDefaults:V,hasError:!!$[_],errorMessage:ct(v,(Ce=$[_])==null?void 0:Ce.message),suffixButton:re,name:_},_)}},[l,ne,C,$,T,V,P,Q,we,ae,w.getValues,w.watch,g,v]);return s.jsx(ei,{...w,children:s.jsxs("form",{noValidate:!0,onSubmit:M(async H=>{await se(H,void 0,"onSubmit"),!(Object.keys(w.formState.errors).length>0)&&(await i(H),p(c??v("ds.form.saveSuccess"),"success"))},H=>{bA(H),p(u??v("ds.form.saveError"),"error")}),className:"space-y-6",children:[o.map((H,L)=>H.type==="rows"?s.jsx(E.Fragment,{children:H.sections.map((S,D)=>s.jsx("div",{children:s.jsx(ot,{title:me(S.sectionTitle),defaultOpen:S.defaultOpen,children:S.rows.map((_,Z)=>s.jsxs("div",{children:[_.title&&s.jsx("h2",{className:"mb-2 text-lg text-[var(--color-ds-text-primary)]",children:me(_.title)}),s.jsx("div",{className:"flex flex-wrap -mx-2",children:_.columns.map((B,q)=>{var X;return s.jsx("div",{className:`${B.width} px-2 flex flex-col`,children:s.jsx("div",{className:"",children:B.fields?B.fields.map(G=>R(G)):(X=B.rows)==null?void 0:X.map((G,K)=>s.jsx("div",{className:"mb-1",children:s.jsx("div",{className:"flex flex-wrap -mx-2",children:G.columns.map((re,ie)=>{var pe;return s.jsx("div",{className:`${re.width} px-2`,children:(pe=re.fields)==null?void 0:pe.map(ve=>R(ve))},ie)})})},K))})},q)})})]},Z))})},D))},L):s.jsx(fr,{options:H.tabs.map(S=>{const D=S.icon?yn(S.icon.name,S.icon.style):null;return{label:me(S.label),value:S.key,disabled:S.disabled,icon:D?s.jsx(D,{className:"w-4 h-4"}):null}}),value:A[L],onChange:S=>F(D=>({...D,[L]:S})),children:Object.fromEntries(H.tabs.map(S=>[S.key,s.jsx("div",{className:"space-y-6",children:S.sections.map((D,_)=>s.jsx("div",{className:"mb-6",children:s.jsx(ot,{title:me(D.sectionTitle),defaultOpen:D.defaultOpen,children:D.rows.map((Z,B)=>s.jsx("div",{children:s.jsx("div",{className:"flex flex-wrap -mx-2",children:Z.columns.map((q,X)=>{var G;return s.jsx("div",{className:`${q.width??"flex-1"} px-2 flex flex-col`,children:s.jsx("div",{className:"space-y-4",children:(G=q.fields)==null?void 0:G.map((K,re)=>s.jsx(E.Fragment,{children:R(K)},re))})},X)})})},B))})},_))},S.key)]))},L)),s.jsx("footer",{className:"py-4 w-full flex justify-center space-x-4",children:d??s.jsx(fe,{type:"submit",variant:"primary",icon:Br,size:"sm",disabled:T||V||O>0,children:v(T?"ds.form.sending":"ds.form.submit")})})]})})}const KA={sm:"h-8 w-8",md:"h-10 w-10",lg:"h-12 w-12"};function It({icon:e,size:t="md",ariaLabel:r,disabled:n=!1,onClick:o,className:l,...i}){return s.jsx("button",{type:"button","aria-label":r,disabled:n,onClick:o,className:he("inline-flex items-center justify-center","rounded-full","bg-transparent","text-[var(--color-ds-text-primary)]","transition-transform","focus:outline-none",KA[t],n?"opacity-50 cursor-not-allowed":["hover:scale-110","hover:animate-pulse","hover:bg-[var(--color-ds-background-neutral-hover)]"],l),...i,children:s.jsx(e,{className:he(t==="sm"?"h-4 w-4":t==="md"?"h-5 w-5":"h-6 w-6")})})}function L5({dark:e,onToggle:t}){return s.jsx("button",{type:"button","aria-pressed":e,"aria-label":e?"Cambiar a modo claro":"Cambiar a modo oscuro",onClick:t,className:he("relative inline-flex items-center transition-colors focus:outline-none duration-200 ease-in-out","bg-[var(--color-ds-background-accent)]","h-6 w-12 rounded-full"),children:s.jsxs("div",{className:he("absolute bg-[var(--color-ds-background-page)] flex items-center justify-center rounded-full transition-transform duration-200 ease-in-out","h-5 w-5",e?"translate-x-6":"translate-x-1"),children:[s.jsx(vt,{component:Gl,size:"sm",className:he("absolute transition-opacity duration-200 ease-in-out",e?"opacity-0":"opacity-100 text-[var(--color-ds-background-accent)]")}),s.jsx(vt,{component:zl,size:"sm",className:he("absolute transition-opacity duration-200 ease-in-out",e?"opacity-100 text-[var(--color-ds-background-accent)]":"opacity-0")})]})})}const Dc="licytal:ui:theme",$5=E.createContext({theme:"light",dark:!1,toggle:()=>{}});function JA({children:e}){const[t,r]=E.useState(!1),[n,o]=E.useState("light");E.useEffect(()=>{if(typeof window>"u")return;const i=localStorage.getItem(Dc);i==="light"||i==="dark"?o(i):window.matchMedia("(prefers-color-scheme: dark)").matches&&o("dark"),r(!0)},[]),E.useEffect(()=>{t&&(document.documentElement.classList.toggle("dark",n==="dark"),localStorage.setItem(Dc,n))},[n,t]);const l=()=>o(i=>i==="light"?"dark":"light");return t?s.jsx($5.Provider,{value:{theme:n,dark:n==="dark",toggle:l},children:e}):null}const pi=()=>E.useContext($5),Pn={locale:"licytal:ui:locale",theme:"licytal:ui:theme"},I5=({pinnedPages:e,onRemovePinned:t,onBack:r,dark:n,locale:o,languageOptions:l,onChangeLocale:i,profile:c="",profileOptions:u=[],onChangeProfile:d})=>{const m=e.slice(0,3),{toggle:f}=pi(),h=v=>{try{localStorage.setItem(Pn.locale,v)}catch{}i==null||i(v)},p=()=>{const v=!n;try{localStorage.setItem(Pn.theme,v?"dark":"light")}catch{}f()};return E.useEffect(()=>{try{const v=localStorage.getItem(Pn.locale);v&&v!==o&&(i==null||i(v))}catch{}},[]),E.useEffect(()=>{if(o)try{localStorage.setItem(Pn.locale,o)}catch{}},[o]),E.useEffect(()=>{try{const v=localStorage.getItem(Pn.theme);if(!v)return;v==="dark"!==n&&f()}catch{}},[]),s.jsxs("header",{className:"flex items-center bg-[var(--color-ds-background-page)] py-2",children:[s.jsx("div",{className:"flex items-center space-x-2",children:m.map(v=>s.jsxs("div",{className:"flex items-center",children:[s.jsx("a",{href:v.href,className:he("inline-flex items-center rounded-lg","py-1 px-1 my-1 text-ds-sm","bg-transparent text-[var(--color-ds-text-primary)]","transition-colors duration-200 ease-in-out","hover:bg-[var(--color-ds-border-muted)] hover:animate-pulse"),children:v.label}),s.jsx(It,{icon:nt,size:"sm",ariaLabel:`Remove ${v.label}`,onClick:()=>t(v.id)})]},v.id))}),s.jsx("div",{className:"flex-grow"}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(Ke,{size:"sm",width:"auto",options:l,value:o,onChange:h,disableErrorPlaceholder:!0,label:"Idioma",labelHidden:!0}),!!u.length&&s.jsx(Ke,{size:"sm",width:"auto",options:u,value:c,onChange:v=>d==null?void 0:d(v),disableErrorPlaceholder:!0,label:"Perfil",labelHidden:!0}),s.jsx(L5,{dark:n,onToggle:p})]})]})},YA=({loading:e=!1,ariaLabel:t="Cargando..."})=>e?s.jsxs("div",{className:`\r
99
99
  fixed inset-0\r
100
100
  flex items-center justify-center\r
101
101
  bg-[var(--color-ds-background-surface)]/90\r
@@ -179,11 +179,11 @@ return true;${R}`}},[n.type]),[g,x]=E.useState(null),[w,j]=E.useState({}),[k,y]=
179
179
  "nPlazoDuracion": 12,
180
180
  "cUnidadPlazo": "meses"
181
181
  }
182
- /* O pega un interface TS */`,maxLength:2e6}),s.jsxs("button",{className:"text-xs flex items-center gap-1 text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)] transition-colors",onClick:()=>M(!N),children:[N?s.jsx(Ut,{className:"w-4 h-4"}):s.jsx(Fo,{className:"w-4 h-4"}),s.jsx(Rn,{className:"w-4 h-4"}),"Opciones avanzadas"]}),N&&s.jsx("div",{className:"p-3 border border-[var(--color-ds-border-default-50)] rounded-md space-y-3 animation-fade-in-down",children:z?s.jsxs(s.Fragment,{children:[s.jsx(W,{}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Estrategia de Generación"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:ln.map(A=>s.jsxs("div",{className:JF("border rounded p-2 text-sm cursor-pointer transition-all hover:bg-[var(--color-ds-background-neutral-subtle)]",V===A.name?"ring-2 ring-[var(--color-ds-primary-500)] border-[var(--color-ds-primary-500)] bg-[var(--color-ds-primary-50)]":"border-[var(--color-ds-border-default-50)]"),onClick:()=>I(A.name),children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-semibold",children:A.name}),V===A.name&&s.jsx(Br,{className:"w-4 h-4 text-[var(--color-ds-primary-600)]"})]}),s.jsxs("div",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:[A.name==="Standard"&&"Campos planos organizados en columnas inteligentes.",A.name==="Tabs"&&"Divide objetos principales en pestañas independientes.",A.name==="MasterDetail"&&"Visualiza listas de objetos como tablas repetibles.",A.name==="Mixed"&&"Combina cabecera global + pestañas para objetos y tablas."]})]},A.name))})]})]}):s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:"Analice el contenido para ver sugerencias de estrategia."}),s.jsxs(fe,{size:"sm",variant:"outline",onClick:ne,disabled:!c.trim(),children:[s.jsx(Qs,{className:"w-4 h-4 mr-2"})," Analizar Estructura"]})]})})]}),s.jsxs("div",{className:"px-4 py-3 border-t border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] flex items-center justify-end gap-2 flex-shrink-0",children:[s.jsx(fe,{size:"sm",variant:"outline",onClick:t,children:n("ds.editor.importModal.actions.cancel")}),s.jsx(fe,{size:"sm",variant:"primary",onClick:ae,disabled:j,children:j?P||n("ds.editor.importModal.actions.generating"):n("ds.editor.importModal.actions.generate")})]})]})]}):null}function Oo(e){var c;if(!e.openapi&&!e.swagger)throw new Error("No es una especificación OpenAPI/Swagger válida");const t=e.openapi||e.swagger,r=QF(e),n=((c=e.components)==null?void 0:c.schemas)||e.definitions||{},o=[],l=new Map;for(const[u,d]of Object.entries(e.paths||{}))for(const[m,f]of Object.entries(d)){if(!["get","post","put","delete","patch"].includes(m.toLowerCase()))continue;const h=XF(u,m,f);if(h){o.push(h);const p=h.controller;l.has(p)||l.set(p,[]),l.get(p).push(h)}}return{controllers:Array.from(l.entries()).map(([u,d])=>({name:u,description:e_(e,u),endpoints:d})),endpoints:o,schemas:n,baseUrl:r,version:t}}function XF(e,t,r,n){var d;const o=r.operationId||t_(e,t),l=r.tags||["default"],i=l[0]||"default",c=[];if(r.parameters)for(const m of r.parameters)c.push({name:m.name,in:m.in,required:m.required||!1,schema:m.schema||{type:m.type},description:m.description,type:r_(m.schema||{type:m.type})});if(r.requestBody){const m=(d=r.requestBody.content)==null?void 0:d["application/json"];m!=null&&m.schema&&c.push({name:"body",in:"body",required:r.requestBody.required||!1,schema:m.schema,description:r.requestBody.description,type:"object"})}return{key:`${i}.${o}`,controller:i,operationId:o,path:e,method:t.toUpperCase(),summary:r.summary,description:r.description,parameters:c,requestBody:r.requestBody,responses:r.responses||{},tags:l}}function QF(e){var t;if(e.servers&&e.servers.length>0)return e.servers[0].url;if(e.host){const r=((t=e.schemes)==null?void 0:t[0])||"https",n=e.basePath||"";return`${r}://${e.host}${n}`}}function e_(e,t){if(e.tags){const r=e.tags.find(n=>n.name===t);return r==null?void 0:r.description}}function t_(e,t){const r=e.split("/").filter(Boolean).map(n=>{const o=n.replace(/[{}]/g,"");return o.charAt(0).toUpperCase()+o.slice(1)}).join("");return`${t.toLowerCase()}${r}`}function r_(e){return e?e.type?e.type:e.$ref?"object":e.items?"array":"any":"any"}function Li(e,t){const r={};for(const n of e.endpoints){if(n.method!=="GET"&&n.method!=="POST")continue;const o=n.key;r[o]=async(l,i)=>{try{let c=n_(e.baseUrl||"",n.path,n.parameters,i);const u=new URL(c,window.location.origin);if(l){const h=l_(n);h&&u.searchParams.set(h.name,l)}if(a_(u,n.parameters,i),t){const h=n.method.toLowerCase(),p={"Content-Type":"application/json"};let v;if(n.method==="POST"){const x={};n.parameters.filter(w=>w.in==="body").forEach(w=>{const j=Lo(w.name,i);j!==void 0&&(x[w.name]=j)}),v=x}const b={method:h,url:u.pathname+u.search,headers:p,data:v},g=await t.request(b);return Ol(g.data)}const d={method:n.method,headers:{"Content-Type":"application/json"}};if(n.method==="POST"){const h={};n.parameters.filter(p=>p.in==="body").forEach(p=>{const v=Lo(p.name,i);v!==void 0&&(h[p.name]=v)}),d.body=JSON.stringify(h)}const m=await fetch(u.toString(),d);if(!m.ok)return console.error(`Error fetching ${o}: ${m.status}`),[];const f=await m.json();return Ol(f)}catch(c){return console.error(`Error in adapter ${o}:`,c),[]}}}return r}function n_(e,t,r,n){let o=`${e}${t}`;const l=r.filter(i=>String(i.in).toLowerCase()==="path");for(const i of l){const c=i.name.trim(),u=Lo(c,n);if(u!=null){const d=new RegExp(`\\{\\s*${s_(c)}\\s*\\}`,"g");o=o.replace(d,encodeURIComponent(String(u)))}else console.warn(`[AdapterGenerator] Missing value for path parameter: ${c}`)}return o}function a_(e,t,r){const n=t.filter(o=>String(o.in).toLowerCase()==="query");for(const o of n){const l=o.name.trim(),i=Lo(l,r);i!=null&&i!==""&&e.searchParams.set(l,String(i))}}function Lo(e,t){const r=o_(e,t);if(r!==void 0)return r;const n=e.toLowerCase();if(t!=null&&t.params){const o=Object.keys(t.params).find(l=>l.toLowerCase()===n);if(o)return t.params[o]}}function o_(e,t){if(t!=null&&t.params&&e in t.params)return t.params[e];if(t!=null&&t.getValues){const r=typeof t.getValues=="function"?t.getValues():t.getValues;if(r&&e in r)return r[e]}if(t&&e in t)return t[e]}function s_(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function l_(e){const t=["q","query","search","filter","term"];for(const r of e.parameters)if(r.in==="query"&&t.includes(r.name.toLowerCase()))return r;return null}function Ol(e){if(Array.isArray(e))return e.length>0&&"label"in e[0]&&"value"in e[0]?e:e.map((t,r)=>{if(typeof t=="string")return{label:t,value:t};const n=t.name||t.label||t.title||t.description||String(t.id||r),o=t.id||t.value||t.code||String(r);return{label:n,value:String(o)}});if(e&&typeof e=="object"){const t=["data","items","results","content","records"];for(const r of t)if(Array.isArray(e[r]))return Ol(e[r])}return e}function $i(e){const t={};for(const r of e.endpoints){if(r.method!=="GET"&&r.method!=="POST")continue;const n=r.key,o=i_(r);t[n]={key:n,controller:r.controller,name:r.summary||r.operationId,description:r.description,type:o,parameters:r.parameters.filter(l=>l.in!=="header"&&l.in!=="cookie").map(l=>c_(l)),method:r.method}}return t}function i_(e){const t=(e.operationId||"").toLowerCase(),r=(e.summary||"").toLowerCase(),n=(e.path||"").toLowerCase();if(["validate","check","exists","valid","verificar","comprobar","validar"].some(u=>t.includes(u)||r.includes(u)||n.includes(u))||e.method==="POST")return"validation";const i=["q","query","search","filter","term"];return e.parameters.some(u=>u.in==="query"&&i.includes(u.name.toLowerCase()))?"search":"options"}function c_(e){return{name:e.name,type:d_(e.schema),required:e.required,description:e.description,source:u_(e)}}function d_(e){if(!e)return"string";const t=e.type||"string";return t==="integer"||t==="number"?"number":t==="boolean"?"boolean":"string"}function u_(e){return e.in==="path"?"both":e.in==="query"?["q","query","search","filter","term"].includes(e.name.toLowerCase())?"field":"both":e.in==="body"?"static":"both"}const $o="v1:editor:openapi_specs";function eu(e){var t,r;try{const n=localStorage.getItem($o);let o=n?JSON.parse(n):[];const l=(t=e.info)==null?void 0:t.title,i=(r=e.info)==null?void 0:r.version;l&&i&&(o=o.filter(c=>{var u,d;return!(((u=c.info)==null?void 0:u.title)===l&&((d=c.info)==null?void 0:d.version)===i)})),o.push(e),localStorage.setItem($o,JSON.stringify(o))}catch(n){console.error("Error saving OpenAPI spec",n)}}function tu(){try{const e=localStorage.getItem($o);return e?JSON.parse(e):[]}catch(e){return console.error("Error loading OpenAPI specs",e),[]}}function ru(){localStorage.removeItem($o)}const f_=({isOpen:e,onClose:t})=>{const{services:r,setServices:n}=St(),[o,l]=E.useState(""),[i,c]=E.useState(null),[u,d]=E.useState(null),[m,f]=E.useState(null),[h,p]=E.useState(!1),v=()=>{d(null),f(null),c(null);try{if(!o.trim())throw new Error("El contenido está vacío.");const x=JSON.parse(o);if(!x.openapi&&!x.swagger)throw new Error("No parece una definición OpenAPI/Swagger válida (falta 'openapi' o 'swagger').");const w=Oo(x);if(w.endpoints.length===0)throw new Error("No se encontraron endpoints en la definición.");c({controllers:w.controllers.map(j=>j.name),endpointsCount:w.endpoints.length,endpointKeys:w.endpoints.map(j=>j.key)})}catch(x){d(x.message)}},b=()=>{if(i){p(!0),d(null),f(null);try{const x=JSON.parse(o),w=Oo(x),j=Li(w),k=$i(w);n&&n({registry:{...r.registry,...j}}),Si(k),eu(x),f(`Se han generado ${Object.keys(j).length} endpoints de ${i.controllers.length} controllers.`),setTimeout(()=>{t(),f(null),l(""),c(null)},2e3)}catch(x){d(x.message)}finally{p(!1)}}},g=Object.keys((r==null?void 0:r.registry)||{});return s.jsx(Et,{isOpen:e,onClose:t,title:"Gestor de Servicios de Datos",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(fe,{variant:"outline",onClick:t,children:"Cerrar"}),!i&&s.jsx(fe,{variant:"primary",onClick:v,disabled:!o.trim(),children:"Analizar OpenAPI"}),i&&s.jsx(fe,{variant:"primary",onClick:b,disabled:h,children:h?"Generando...":"Generar Servicios"})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"bg-[var(--color-ds-background-surface)] p-3 rounded text-sm text-[var(--color-ds-text-secondary)]",children:s.jsxs("p",{children:["Pega aquí tu definición ",s.jsx("strong",{children:"OpenAPI (Swagger) 3.x"})," en formato JSON. El sistema generará automáticamente servicios y adaptadores para todos los endpoints GET."]})}),s.jsx(Nr,{label:"Definición JSON (OpenAPI)",placeholder:'{"openapi": "3.0.0", "paths": { ... } }',value:o,onChange:x=>{l(x.target.value),c(null)},rows:10,className:"font-mono text-xs",disabled:h}),u&&s.jsxs("div",{className:"flex items-start gap-2 text-ds-sm bg-red-50 dark:bg-red-900/10 p-3 rounded border border-red-200 dark:border-red-800",children:[s.jsx(Zl,{className:"w-5 h-5 text-red-600 flex-shrink-0 mt-0.5"}),s.jsx("span",{className:"text-red-600",children:u})]}),m&&s.jsxs("div",{className:"flex items-center gap-2 text-ds-sm text-green-600 bg-green-50 dark:bg-green-900/10 p-3 rounded border border-green-200 dark:border-green-800",children:[s.jsx(Rr,{className:"w-5 h-5"}),m]}),i&&!m&&s.jsxs("div",{className:"border border-[var(--color-ds-border-default-50)] rounded p-3 bg-[var(--color-ds-background-page)]",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Cn,{className:"w-5 h-5 text-[var(--color-ds-text-secondary)]"}),s.jsxs("h4",{className:"font-semibold text-sm",children:["Preview: ",i.endpointsCount," endpoints detectados"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"text-xs font-medium text-[var(--color-ds-text-secondary)] mb-1",children:["Controllers (",i.controllers.length,"):"]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:i.controllers.map(x=>s.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-[var(--color-ds-background-surface)] border border-[var(--color-ds-border-default-50)]",children:x},x))})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-medium text-[var(--color-ds-text-secondary)] mb-1",children:"Endpoints:"}),s.jsx("div",{className:"max-h-32 overflow-y-auto custom-scroll border border-[var(--color-ds-border-default-50)] rounded bg-[var(--color-ds-background-surface)] p-2",children:s.jsx("ul",{className:"space-y-0.5",children:i.endpointKeys.map(x=>s.jsx("li",{className:"text-xs font-mono text-[var(--color-ds-text-secondary)]",children:x},x))})})]})]})]}),s.jsxs("div",{className:"border-t border-[var(--color-ds-border-default-50)] pt-3",children:[s.jsxs("h4",{className:"text-xs font-semibold uppercase text-[var(--color-ds-text-secondary)] mb-2",children:["Servicios Activos (",g.length,")"]}),s.jsx("div",{className:"max-h-32 overflow-y-auto custom-scroll border border-[var(--color-ds-border-default-50)] rounded bg-[var(--color-ds-background-page)] p-2",children:g.length===0?s.jsx("span",{className:"text-xs opacity-50 italic",children:"No hay servicios registrados."}):s.jsx("ul",{className:"space-y-1",children:g.map(x=>s.jsx("li",{className:"text-xs font-mono truncate",title:x,children:x},x))})}),s.jsx("div",{className:"mt-2 flex justify-end",children:s.jsx(fe,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-600",onClick:()=>{confirm("¿Seguro que quieres borrar todos los servicios guardados?")&&(ru(),alert("Servicios guardados eliminados. Refresca la página para limpiar la memoria actual."))},children:"Borrar servicios guardados"})})]})]})})};function m_({isOpen:e,onClose:t}){const r=oe(b=>b.schema),n=oe(b=>b.setSchema),{services:o}=St(),l=E.useMemo(()=>{const b=[];return r.onloadEndpoint&&b.push(r.onloadEndpoint),r.onloadEndpoints&&b.push(...r.onloadEndpoints),b},[r]),[i,c]=E.useState(null),[u,d]=E.useState(!1),m=b=>{n(g=>{g.onloadEndpoint&&!g.onloadEndpoints&&(g.onloadEndpoints=[g.onloadEndpoint],delete g.onloadEndpoint),g.onloadEndpoints||(g.onloadEndpoints=[]),g.onloadEndpoints.push(b)}),d(!1)},f=b=>{i!==null&&(n(g=>{i===0&&g.onloadEndpoint&&!g.onloadEndpoints?(g.onloadEndpoints=[b],delete g.onloadEndpoint):g.onloadEndpoints&&(g.onloadEndpoints[i]=b)}),c(null))},h=b=>{n(g=>{if(b===0&&g.onloadEndpoint&&!g.onloadEndpoints){delete g.onloadEndpoint;return}g.onloadEndpoints&&g.onloadEndpoints.splice(b,1)})},p=(r.fields??[]).filter(b=>b.name&&b.type!=="button"),v=u||i!==null;return s.jsxs(s.Fragment,{children:[s.jsx(Et,{isOpen:e&&!v,onClose:t,title:"Configuración de Pre-carga",maxWidth:"lg",footer:s.jsx("div",{className:"flex justify-end",children:s.jsx(fe,{variant:"outline",onClick:t,children:"Cerrar"})}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:"Configura las llamadas al backend que se ejecutarán al cargar el formulario. Los resultados se fusionarán en el contexto del sistema."}),l.length===0?s.jsxs("div",{className:"text-center py-8 text-[var(--color-ds-text-tertiary)]",children:[s.jsx(_o,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No hay endpoints de pre-carga configurados."})]}):s.jsx("ul",{className:"divide-y divide-[var(--color-ds-border-default-50)] border border-[var(--color-ds-border-default-50)] rounded-lg overflow-hidden",children:l.map((b,g)=>s.jsxs("li",{className:"flex items-center justify-between px-4 py-3 bg-[var(--color-ds-background-elevated)] hover:bg-[var(--color-ds-background-neutral-hover)] transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(oo,{className:"w-5 h-5 text-[var(--color-ds-text-tertiary)]"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-sm text-[var(--color-ds-text-primary)]",children:b.key||`Endpoint ${g+1}`}),s.jsxs("div",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:[Object.keys(b.parameters||{}).length," parámetro(s)"]})]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(It,{icon:Bo,size:"sm",ariaLabel:"Editar",onClick:()=>c(g)}),s.jsx(It,{icon:bt,size:"sm",ariaLabel:"Eliminar",onClick:()=>h(g),className:"text-[var(--color-ds-danger-500)] hover:bg-[var(--color-ds-danger-50)]"})]})]},g))}),s.jsx(fe,{variant:"outline",icon:Sn,onClick:()=>d(!0),className:"w-full",children:"Añadir Endpoint"})]})}),u&&s.jsx(Mo,{isOpen:!0,onClose:()=>d(!1),endpointType:"onload",currentConfig:void 0,onConfirm:m,availableFields:p}),i!==null&&s.jsx(Mo,{isOpen:!0,onClose:()=>c(null),endpointType:"onload",currentConfig:l[i],onConfirm:f,availableFields:p})]})}const h_={Texto:["template","concat","uppercase","lowercase","trim","substring","replace","padStart","padEnd"],Números:["math","round","abs","length"],Lógica:["condition","default","includes","startsWith","endsWith"],"Fecha/Hora":["today","now"],Arrays:["split","join","first","last"],Avanzado:["custom"]},p_={concat:"🔗 Concatenar textos",template:"📝 Plantilla con variables",math:"➕ Operación matemática",uppercase:"🔠 Convertir a MAYÚSCULAS",lowercase:"🔡 Convertir a minúsculas",substring:"✂️ Extraer subcadena",replace:"🔄 Buscar y reemplazar",condition:"❓ Valor condicional",default:"📌 Valor por defecto",trim:"🧹 Quitar espacios",length:"📏 Longitud de texto",round:"🔢 Redondear número",abs:"➡️ Valor absoluto",today:"📅 Fecha actual",now:"🕐 Fecha y hora actual",padStart:"◀️ Rellenar al inicio",padEnd:"▶️ Rellenar al final",includes:"🔍 Contiene texto",startsWith:"▶️ Empieza con",endsWith:"◀️ Termina con",split:"📊 Dividir texto",join:"🔗 Unir elementos",first:"1️⃣ Primer elemento",last:"🔚 Último elemento",custom:"💻 Expresión avanzada (JS)"};function C0(e){const{operation:t,args:r}=e,n=(l,i='""')=>l?l.startsWith("$")?`ctx.${l.slice(1)}`:`"${l}"`:i,o=(l,i="0")=>l?l.startsWith("$")?`ctx.${l.slice(1)}`:l:i;switch(t){case"concat":return`(${(r.parts||[]).map(l=>l.startsWith("$")?`ctx.${l.slice(1)}`:`"${l}"`).join(" + ")})`;case"template":return`\`${(r.template||"").replace(/\{\{(\w+)\}\}/g,"${ctx.$1}")}\``;case"math":{const l=o(r.left),i=o(r.right);return`(${l} ${r.operator||"+"} ${i})`}case"uppercase":return`String(ctx.${r.source||""}).toUpperCase()`;case"lowercase":return`String(ctx.${r.source||""}).toLowerCase()`;case"substring":{const l=r.start||0,i=r.end?`, ${r.end}`:"";return`String(ctx.${r.source||""}).substring(${l}${i})`}case"replace":return`String(ctx.${r.source||""}).replace("${r.search||""}", "${r.replacement||""}")`;case"condition":{const l=n(r.condLeft),i=n(r.condRight),c=n(r.trueValue),u=n(r.falseValue);return`(${l} ${r.condOperator||"==="} ${i} ? ${c} : ${u})`}case"default":{const l=r.source?`ctx.${r.source}`:'""',i=n(r.defaultValue);return`(${l} || ${i})`}case"trim":return`String(ctx.${r.source||""}).trim()`;case"length":return`String(ctx.${r.source||""}).length`;case"round":{const l=o(r.source?`$${r.source}`:void 0),i=r.decimals||0;return i===0?`Math.round(${l})`:`(Math.round(${l} * ${Math.pow(10,i)}) / ${Math.pow(10,i)})`}case"abs":return`Math.abs(${o(r.source?`$${r.source}`:void 0)})`;case"today":return"new Date().toISOString().split('T')[0]";case"now":{const l=r.format||"iso";return l==="iso"?"new Date().toISOString()":l==="locale"?"new Date().toLocaleString()":l==="time"?"new Date().toLocaleTimeString()":"new Date().toLocaleDateString()"}case"padStart":{const l=r.length||2,i=r.char||"0";return`String(ctx.${r.source||""}).padStart(${l}, "${i}")`}case"padEnd":{const l=r.length||2,i=r.char||" ";return`String(ctx.${r.source||""}).padEnd(${l}, "${i}")`}case"includes":return`String(ctx.${r.source||""}).includes("${r.search||""}")`;case"startsWith":return`String(ctx.${r.source||""}).startsWith("${r.search||""}")`;case"endsWith":return`String(ctx.${r.source||""}).endsWith("${r.search||""}")`;case"split":{const l=r.separator||",";return`String(ctx.${r.source||""}).split("${l}")`}case"join":{const l=r.separator||", ";return`(Array.isArray(ctx.${r.source||""}) ? ctx.${r.source||""}.join("${l}") : "")`}case"first":return`(Array.isArray(ctx.${r.source||""}) ? ctx.${r.source||""}[0] : String(ctx.${r.source||""}).charAt(0))`;case"last":return`(Array.isArray(ctx.${r.source||""}) ? ctx.${r.source||""}[ctx.${r.source||""}.length - 1] : String(ctx.${r.source||""}).slice(-1))`;case"custom":default:return r.expression||""}}function g_(e){return{operation:"custom",args:{expression:e}}}function v_({value:e,onChange:t,availableVars:r,previewContext:n}){const[o,l]=E.useState(()=>e?g_(e):{operation:"template",args:{template:""}}),i=d=>{l(d),t(C0(d))},c=(d,m)=>{i({...o,args:{...o.args,[d]:m}})},u=E.useMemo(()=>{try{const d=n||{};n||r.forEach(h=>{d[h]=`[${h}]`});const f=new Function("ctx",`return (${C0(o)});`)(d);return f==null?"":typeof f=="object"?JSON.stringify(f):String(f)}catch{return"(error)"}},[o,r,n]);return s.jsxs("div",{className:"space-y-3 p-3 bg-[var(--color-ds-background-elevated)] rounded-lg border border-[var(--color-ds-border-default-50)]",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs font-medium text-[var(--color-ds-text-secondary)] w-20",children:"Operación:"}),s.jsx("select",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.operation,onChange:d=>i({operation:d.target.value,args:{}}),children:Object.entries(h_).map(([d,m])=>s.jsx("optgroup",{label:d,children:m.map(f=>s.jsx("option",{value:f,children:p_[f]},f))},d))})]}),s.jsxs("div",{className:"space-y-2",children:[o.operation==="template"&&s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:["Plantilla (usa ",s.jsx("code",{className:"bg-[var(--color-ds-background-neutral)] px-1 rounded",children:"{{VARIABLE}}"}),"):"]}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1.5 text-sm",value:o.args.template||"",placeholder:"Ej: Hola {{NOMBRE}}, tu ID es {{ID}}",onChange:d=>c("template",d.target.value)}),r.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[s.jsx("span",{className:"text-[10px] text-[var(--color-ds-text-tertiary)]",children:"Variables:"}),r.map(d=>s.jsx("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 bg-[var(--color-ds-background-accent)] text-[var(--color-ds-text-on-accent)] rounded hover:opacity-80",onClick:()=>c("template",(o.args.template||"")+`{{${d}}}`),children:d},d))]})]}),o.operation==="concat"&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Partes a concatenar (una por línea, prefija con $ para usar variable):"}),s.jsx("textarea",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm font-mono",rows:3,placeholder:`$NOMBRE
182
+ /* O pega un interface TS */`,maxLength:2e6}),s.jsxs("button",{className:"text-xs flex items-center gap-1 text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)] transition-colors",onClick:()=>M(!N),children:[N?s.jsx(Ut,{className:"w-4 h-4"}):s.jsx(Fo,{className:"w-4 h-4"}),s.jsx(Rn,{className:"w-4 h-4"}),"Opciones avanzadas"]}),N&&s.jsx("div",{className:"p-3 border border-[var(--color-ds-border-default-50)] rounded-md space-y-3 animation-fade-in-down",children:z?s.jsxs(s.Fragment,{children:[s.jsx(W,{}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Estrategia de Generación"}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:ln.map(A=>s.jsxs("div",{className:JF("border rounded p-2 text-sm cursor-pointer transition-all hover:bg-[var(--color-ds-background-neutral-subtle)]",V===A.name?"ring-2 ring-[var(--color-ds-primary-500)] border-[var(--color-ds-primary-500)] bg-[var(--color-ds-primary-50)]":"border-[var(--color-ds-border-default-50)]"),onClick:()=>I(A.name),children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-semibold",children:A.name}),V===A.name&&s.jsx(Br,{className:"w-4 h-4 text-[var(--color-ds-primary-600)]"})]}),s.jsxs("div",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:[A.name==="Standard"&&"Campos planos organizados en columnas inteligentes.",A.name==="Tabs"&&"Divide objetos principales en pestañas independientes.",A.name==="MasterDetail"&&"Visualiza listas de objetos como tablas repetibles.",A.name==="Mixed"&&"Combina cabecera global + pestañas para objetos y tablas."]})]},A.name))})]})]}):s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("span",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:"Analice el contenido para ver sugerencias de estrategia."}),s.jsxs(fe,{size:"sm",variant:"outline",onClick:ne,disabled:!c.trim(),children:[s.jsx(Qs,{className:"w-4 h-4 mr-2"})," Analizar Estructura"]})]})})]}),s.jsxs("div",{className:"px-4 py-3 border-t border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] flex items-center justify-end gap-2 flex-shrink-0",children:[s.jsx(fe,{size:"sm",variant:"outline",onClick:t,children:n("ds.editor.importModal.actions.cancel")}),s.jsx(fe,{size:"sm",variant:"primary",onClick:ae,disabled:j,children:j?P||n("ds.editor.importModal.actions.generating"):n("ds.editor.importModal.actions.generate")})]})]})]}):null}function Oo(e){var c;if(!e.openapi&&!e.swagger)throw new Error("No es una especificación OpenAPI/Swagger válida");const t=e.openapi||e.swagger,r=QF(e),n=((c=e.components)==null?void 0:c.schemas)||e.definitions||{},o=[],l=new Map;for(const[u,d]of Object.entries(e.paths||{}))for(const[m,f]of Object.entries(d)){if(!["get","post","put","delete","patch"].includes(m.toLowerCase()))continue;const h=XF(u,m,f);if(h){o.push(h);const p=h.controller;l.has(p)||l.set(p,[]),l.get(p).push(h)}}return{controllers:Array.from(l.entries()).map(([u,d])=>({name:u,description:e_(e,u),endpoints:d})),endpoints:o,schemas:n,baseUrl:r,version:t}}function XF(e,t,r,n){var d;const o=r.operationId||t_(e,t),l=r.tags||["default"],i=l[0]||"default",c=[];if(r.parameters)for(const m of r.parameters)c.push({name:m.name,in:m.in,required:m.required||!1,schema:m.schema||{type:m.type},description:m.description,type:r_(m.schema||{type:m.type})});if(r.requestBody){const m=(d=r.requestBody.content)==null?void 0:d["application/json"];m!=null&&m.schema&&c.push({name:"body",in:"body",required:r.requestBody.required||!1,schema:m.schema,description:r.requestBody.description,type:"object"})}return{key:`${i}.${o}`,controller:i,operationId:o,path:e,method:t.toUpperCase(),summary:r.summary,description:r.description,parameters:c,requestBody:r.requestBody,responses:r.responses||{},tags:l}}function QF(e){var t;if(e.servers&&e.servers.length>0)return e.servers[0].url;if(e.host){const r=((t=e.schemes)==null?void 0:t[0])||"https",n=e.basePath||"";return`${r}://${e.host}${n}`}}function e_(e,t){if(e.tags){const r=e.tags.find(n=>n.name===t);return r==null?void 0:r.description}}function t_(e,t){const r=e.split("/").filter(Boolean).map(n=>{const o=n.replace(/[{}]/g,"");return o.charAt(0).toUpperCase()+o.slice(1)}).join("");return`${t.toLowerCase()}${r}`}function r_(e){return e?e.type?e.type:e.$ref?"object":e.items?"array":"any":"any"}function Li(e,t){const r={};for(const n of e.endpoints){if(n.method!=="GET"&&n.method!=="POST")continue;const o=n.key;r[o]=async(l,i)=>{try{let c=n_(e.baseUrl||"",n.path,n.parameters,i);const u=new URL(c,window.location.origin);if(l){const h=s_(n);h&&u.searchParams.set(h.name,l)}if(a_(u,n.parameters,i),t){const h=n.method.toLowerCase(),p={"Content-Type":"application/json"};let v;if(n.method==="POST"){const x={};n.parameters.filter(w=>w.in==="body").forEach(w=>{const j=Lo(w.name,i);j!==void 0&&(x[w.name]=j)}),v=x}const b={method:h,url:u.pathname+u.search,headers:p,data:v},g=await t.request(b);return Ol(g.data)}const d={method:n.method,headers:{"Content-Type":"application/json"}};if(n.method==="POST"){const h={};n.parameters.filter(p=>p.in==="body").forEach(p=>{const v=Lo(p.name,i);v!==void 0&&(h[p.name]=v)}),d.body=JSON.stringify(h)}const m=await fetch(u.toString(),d);if(!m.ok)return console.error(`Error fetching ${o}: ${m.status}`),[];const f=await m.json();return Ol(f)}catch(c){return console.error(`Error in adapter ${o}:`,c),[]}}}return r}function n_(e,t,r,n){let o=`${e}${t}`;const l=r.filter(i=>String(i.in).toLowerCase()==="path");console.log(`[Adapter] Building URL. Template: ${t}, Params:`,l.map(i=>i.name));for(const i of l){const c=i.name.trim(),u=Lo(c,n);if(console.log(`[Adapter] Replacing {${c}} with value:`,u),u!=null){const d=new RegExp(`\\{\\s*${o_(c)}\\s*\\}`,"g");o=o.replace(d,encodeURIComponent(String(u)))}else console.warn(`[AdapterGenerator] Missing value for path parameter: ${c}`)}return console.log(`[Adapter] Final URL: ${o}`),o}function a_(e,t,r){const n=t.filter(o=>String(o.in).toLowerCase()==="query");for(const o of n){const l=o.name.trim(),i=Lo(l,r);i!=null&&i!==""&&e.searchParams.set(l,String(i))}}function Lo(e,t){const r=e.trim().toLowerCase();if(t!=null&&t.params){if(r in t.params)return t.params[r];const n=Object.keys(t.params).find(o=>o.toLowerCase()===r);if(n)return t.params[n];console.warn(`[Adapter] Param '${e}' (norm: '${r}') not found in ctx.params. Available keys:`,Object.keys(t.params))}if(t!=null&&t.getValues){const n=typeof t.getValues=="function"?t.getValues():t.getValues;if(n){if(e in n)return n[e];const o=Object.keys(n).find(l=>l.toLowerCase()===r);if(o)return n[o]}}if(t){if(e in t)return t[e];const n=Object.keys(t).find(o=>o.toLowerCase()===r);if(n)return t[n]}}function o_(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function s_(e){const t=["q","query","search","filter","term"];for(const r of e.parameters)if(r.in==="query"&&t.includes(r.name.toLowerCase()))return r;return null}function Ol(e){if(Array.isArray(e))return e.length>0&&"label"in e[0]&&"value"in e[0]?e:e.map((t,r)=>{if(typeof t=="string")return{label:t,value:t};const n=t.name||t.label||t.title||t.description||String(t.id||r),o=t.id||t.value||t.code||String(r);return{label:n,value:String(o)}});if(e&&typeof e=="object"){const t=["data","items","results","content","records"];for(const r of t)if(Array.isArray(e[r]))return Ol(e[r])}return e}function $i(e){const t={};for(const r of e.endpoints){if(r.method!=="GET"&&r.method!=="POST")continue;const n=r.key,o=l_(r);t[n]={key:n,controller:r.controller,name:r.summary||r.operationId,description:r.description,type:o,parameters:r.parameters.filter(l=>l.in!=="header"&&l.in!=="cookie").map(l=>i_(l)),method:r.method}}return t}function l_(e){const t=(e.operationId||"").toLowerCase(),r=(e.summary||"").toLowerCase(),n=(e.path||"").toLowerCase();if(["validate","check","exists","valid","verificar","comprobar","validar"].some(u=>t.includes(u)||r.includes(u)||n.includes(u))||e.method==="POST")return"validation";const i=["q","query","search","filter","term"];return e.parameters.some(u=>u.in==="query"&&i.includes(u.name.toLowerCase()))?"search":"options"}function i_(e){return{name:e.name,type:c_(e.schema),required:e.required,description:e.description,source:d_(e)}}function c_(e){if(!e)return"string";const t=e.type||"string";return t==="integer"||t==="number"?"number":t==="boolean"?"boolean":"string"}function d_(e){return e.in==="path"?"both":e.in==="query"?["q","query","search","filter","term"].includes(e.name.toLowerCase())?"field":"both":e.in==="body"?"static":"both"}const $o="v1:editor:openapi_specs";function eu(e){var t,r;try{const n=localStorage.getItem($o);let o=n?JSON.parse(n):[];const l=(t=e.info)==null?void 0:t.title,i=(r=e.info)==null?void 0:r.version;l&&i&&(o=o.filter(c=>{var u,d;return!(((u=c.info)==null?void 0:u.title)===l&&((d=c.info)==null?void 0:d.version)===i)})),o.push(e),localStorage.setItem($o,JSON.stringify(o))}catch(n){console.error("Error saving OpenAPI spec",n)}}function tu(){try{const e=localStorage.getItem($o);return e?JSON.parse(e):[]}catch(e){return console.error("Error loading OpenAPI specs",e),[]}}function ru(){localStorage.removeItem($o)}const u_=({isOpen:e,onClose:t})=>{const{services:r,setServices:n}=St(),[o,l]=E.useState(""),[i,c]=E.useState(null),[u,d]=E.useState(null),[m,f]=E.useState(null),[h,p]=E.useState(!1),v=()=>{d(null),f(null),c(null);try{if(!o.trim())throw new Error("El contenido está vacío.");const x=JSON.parse(o);if(!x.openapi&&!x.swagger)throw new Error("No parece una definición OpenAPI/Swagger válida (falta 'openapi' o 'swagger').");const w=Oo(x);if(w.endpoints.length===0)throw new Error("No se encontraron endpoints en la definición.");c({controllers:w.controllers.map(j=>j.name),endpointsCount:w.endpoints.length,endpointKeys:w.endpoints.map(j=>j.key)})}catch(x){d(x.message)}},b=()=>{if(i){p(!0),d(null),f(null);try{const x=JSON.parse(o),w=Oo(x),j=Li(w),k=$i(w);n&&n({registry:{...r.registry,...j}}),Si(k),eu(x),f(`Se han generado ${Object.keys(j).length} endpoints de ${i.controllers.length} controllers.`),setTimeout(()=>{t(),f(null),l(""),c(null)},2e3)}catch(x){d(x.message)}finally{p(!1)}}},g=Object.keys((r==null?void 0:r.registry)||{});return s.jsx(Et,{isOpen:e,onClose:t,title:"Gestor de Servicios de Datos",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(fe,{variant:"outline",onClick:t,children:"Cerrar"}),!i&&s.jsx(fe,{variant:"primary",onClick:v,disabled:!o.trim(),children:"Analizar OpenAPI"}),i&&s.jsx(fe,{variant:"primary",onClick:b,disabled:h,children:h?"Generando...":"Generar Servicios"})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"bg-[var(--color-ds-background-surface)] p-3 rounded text-sm text-[var(--color-ds-text-secondary)]",children:s.jsxs("p",{children:["Pega aquí tu definición ",s.jsx("strong",{children:"OpenAPI (Swagger) 3.x"})," en formato JSON. El sistema generará automáticamente servicios y adaptadores para todos los endpoints GET."]})}),s.jsx(Nr,{label:"Definición JSON (OpenAPI)",placeholder:'{"openapi": "3.0.0", "paths": { ... } }',value:o,onChange:x=>{l(x.target.value),c(null)},rows:10,className:"font-mono text-xs",disabled:h}),u&&s.jsxs("div",{className:"flex items-start gap-2 text-ds-sm bg-red-50 dark:bg-red-900/10 p-3 rounded border border-red-200 dark:border-red-800",children:[s.jsx(Zl,{className:"w-5 h-5 text-red-600 flex-shrink-0 mt-0.5"}),s.jsx("span",{className:"text-red-600",children:u})]}),m&&s.jsxs("div",{className:"flex items-center gap-2 text-ds-sm text-green-600 bg-green-50 dark:bg-green-900/10 p-3 rounded border border-green-200 dark:border-green-800",children:[s.jsx(Rr,{className:"w-5 h-5"}),m]}),i&&!m&&s.jsxs("div",{className:"border border-[var(--color-ds-border-default-50)] rounded p-3 bg-[var(--color-ds-background-page)]",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Cn,{className:"w-5 h-5 text-[var(--color-ds-text-secondary)]"}),s.jsxs("h4",{className:"font-semibold text-sm",children:["Preview: ",i.endpointsCount," endpoints detectados"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"text-xs font-medium text-[var(--color-ds-text-secondary)] mb-1",children:["Controllers (",i.controllers.length,"):"]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:i.controllers.map(x=>s.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-[var(--color-ds-background-surface)] border border-[var(--color-ds-border-default-50)]",children:x},x))})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-medium text-[var(--color-ds-text-secondary)] mb-1",children:"Endpoints:"}),s.jsx("div",{className:"max-h-32 overflow-y-auto custom-scroll border border-[var(--color-ds-border-default-50)] rounded bg-[var(--color-ds-background-surface)] p-2",children:s.jsx("ul",{className:"space-y-0.5",children:i.endpointKeys.map(x=>s.jsx("li",{className:"text-xs font-mono text-[var(--color-ds-text-secondary)]",children:x},x))})})]})]})]}),s.jsxs("div",{className:"border-t border-[var(--color-ds-border-default-50)] pt-3",children:[s.jsxs("h4",{className:"text-xs font-semibold uppercase text-[var(--color-ds-text-secondary)] mb-2",children:["Servicios Activos (",g.length,")"]}),s.jsx("div",{className:"max-h-32 overflow-y-auto custom-scroll border border-[var(--color-ds-border-default-50)] rounded bg-[var(--color-ds-background-page)] p-2",children:g.length===0?s.jsx("span",{className:"text-xs opacity-50 italic",children:"No hay servicios registrados."}):s.jsx("ul",{className:"space-y-1",children:g.map(x=>s.jsx("li",{className:"text-xs font-mono truncate",title:x,children:x},x))})}),s.jsx("div",{className:"mt-2 flex justify-end",children:s.jsx(fe,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-600",onClick:()=>{confirm("¿Seguro que quieres borrar todos los servicios guardados?")&&(ru(),alert("Servicios guardados eliminados. Refresca la página para limpiar la memoria actual."))},children:"Borrar servicios guardados"})})]})]})})};function f_({isOpen:e,onClose:t}){const r=oe(b=>b.schema),n=oe(b=>b.setSchema),{services:o}=St(),l=E.useMemo(()=>{const b=[];return r.onloadEndpoint&&b.push(r.onloadEndpoint),r.onloadEndpoints&&b.push(...r.onloadEndpoints),b},[r]),[i,c]=E.useState(null),[u,d]=E.useState(!1),m=b=>{n(g=>{g.onloadEndpoint&&!g.onloadEndpoints&&(g.onloadEndpoints=[g.onloadEndpoint],delete g.onloadEndpoint),g.onloadEndpoints||(g.onloadEndpoints=[]),g.onloadEndpoints.push(b)}),d(!1)},f=b=>{i!==null&&(n(g=>{i===0&&g.onloadEndpoint&&!g.onloadEndpoints?(g.onloadEndpoints=[b],delete g.onloadEndpoint):g.onloadEndpoints&&(g.onloadEndpoints[i]=b)}),c(null))},h=b=>{n(g=>{if(b===0&&g.onloadEndpoint&&!g.onloadEndpoints){delete g.onloadEndpoint;return}g.onloadEndpoints&&g.onloadEndpoints.splice(b,1)})},p=(r.fields??[]).filter(b=>b.name&&b.type!=="button"),v=u||i!==null;return s.jsxs(s.Fragment,{children:[s.jsx(Et,{isOpen:e&&!v,onClose:t,title:"Configuración de Pre-carga",maxWidth:"lg",footer:s.jsx("div",{className:"flex justify-end",children:s.jsx(fe,{variant:"outline",onClick:t,children:"Cerrar"})}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:"Configura las llamadas al backend que se ejecutarán al cargar el formulario. Los resultados se fusionarán en el contexto del sistema."}),l.length===0?s.jsxs("div",{className:"text-center py-8 text-[var(--color-ds-text-tertiary)]",children:[s.jsx(_o,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No hay endpoints de pre-carga configurados."})]}):s.jsx("ul",{className:"divide-y divide-[var(--color-ds-border-default-50)] border border-[var(--color-ds-border-default-50)] rounded-lg overflow-hidden",children:l.map((b,g)=>s.jsxs("li",{className:"flex items-center justify-between px-4 py-3 bg-[var(--color-ds-background-elevated)] hover:bg-[var(--color-ds-background-neutral-hover)] transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(oo,{className:"w-5 h-5 text-[var(--color-ds-text-tertiary)]"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-sm text-[var(--color-ds-text-primary)]",children:b.key||`Endpoint ${g+1}`}),s.jsxs("div",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:[Object.keys(b.parameters||{}).length," parámetro(s)"]})]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(It,{icon:Bo,size:"sm",ariaLabel:"Editar",onClick:()=>c(g)}),s.jsx(It,{icon:bt,size:"sm",ariaLabel:"Eliminar",onClick:()=>h(g),className:"text-[var(--color-ds-danger-500)] hover:bg-[var(--color-ds-danger-50)]"})]})]},g))}),s.jsx(fe,{variant:"outline",icon:Sn,onClick:()=>d(!0),className:"w-full",children:"Añadir Endpoint"})]})}),u&&s.jsx(Mo,{isOpen:!0,onClose:()=>d(!1),endpointType:"onload",currentConfig:void 0,onConfirm:m,availableFields:p}),i!==null&&s.jsx(Mo,{isOpen:!0,onClose:()=>c(null),endpointType:"onload",currentConfig:l[i],onConfirm:f,availableFields:p})]})}const m_={Texto:["template","concat","uppercase","lowercase","trim","substring","replace","padStart","padEnd"],Números:["math","round","abs","length"],Lógica:["condition","default","includes","startsWith","endsWith"],"Fecha/Hora":["today","now"],Arrays:["split","join","first","last"],Avanzado:["custom"]},h_={concat:"🔗 Concatenar textos",template:"📝 Plantilla con variables",math:"➕ Operación matemática",uppercase:"🔠 Convertir a MAYÚSCULAS",lowercase:"🔡 Convertir a minúsculas",substring:"✂️ Extraer subcadena",replace:"🔄 Buscar y reemplazar",condition:"❓ Valor condicional",default:"📌 Valor por defecto",trim:"🧹 Quitar espacios",length:"📏 Longitud de texto",round:"🔢 Redondear número",abs:"➡️ Valor absoluto",today:"📅 Fecha actual",now:"🕐 Fecha y hora actual",padStart:"◀️ Rellenar al inicio",padEnd:"▶️ Rellenar al final",includes:"🔍 Contiene texto",startsWith:"▶️ Empieza con",endsWith:"◀️ Termina con",split:"📊 Dividir texto",join:"🔗 Unir elementos",first:"1️⃣ Primer elemento",last:"🔚 Último elemento",custom:"💻 Expresión avanzada (JS)"};function C0(e){const{operation:t,args:r}=e,n=(l,i='""')=>l?l.startsWith("$")?`ctx.${l.slice(1)}`:`"${l}"`:i,o=(l,i="0")=>l?l.startsWith("$")?`ctx.${l.slice(1)}`:l:i;switch(t){case"concat":return`(${(r.parts||[]).map(l=>l.startsWith("$")?`ctx.${l.slice(1)}`:`"${l}"`).join(" + ")})`;case"template":return`\`${(r.template||"").replace(/\{\{(\w+)\}\}/g,"${ctx.$1}")}\``;case"math":{const l=o(r.left),i=o(r.right);return`(${l} ${r.operator||"+"} ${i})`}case"uppercase":return`String(ctx.${r.source||""}).toUpperCase()`;case"lowercase":return`String(ctx.${r.source||""}).toLowerCase()`;case"substring":{const l=r.start||0,i=r.end?`, ${r.end}`:"";return`String(ctx.${r.source||""}).substring(${l}${i})`}case"replace":return`String(ctx.${r.source||""}).replace("${r.search||""}", "${r.replacement||""}")`;case"condition":{const l=n(r.condLeft),i=n(r.condRight),c=n(r.trueValue),u=n(r.falseValue);return`(${l} ${r.condOperator||"==="} ${i} ? ${c} : ${u})`}case"default":{const l=r.source?`ctx.${r.source}`:'""',i=n(r.defaultValue);return`(${l} || ${i})`}case"trim":return`String(ctx.${r.source||""}).trim()`;case"length":return`String(ctx.${r.source||""}).length`;case"round":{const l=o(r.source?`$${r.source}`:void 0),i=r.decimals||0;return i===0?`Math.round(${l})`:`(Math.round(${l} * ${Math.pow(10,i)}) / ${Math.pow(10,i)})`}case"abs":return`Math.abs(${o(r.source?`$${r.source}`:void 0)})`;case"today":return"new Date().toISOString().split('T')[0]";case"now":{const l=r.format||"iso";return l==="iso"?"new Date().toISOString()":l==="locale"?"new Date().toLocaleString()":l==="time"?"new Date().toLocaleTimeString()":"new Date().toLocaleDateString()"}case"padStart":{const l=r.length||2,i=r.char||"0";return`String(ctx.${r.source||""}).padStart(${l}, "${i}")`}case"padEnd":{const l=r.length||2,i=r.char||" ";return`String(ctx.${r.source||""}).padEnd(${l}, "${i}")`}case"includes":return`String(ctx.${r.source||""}).includes("${r.search||""}")`;case"startsWith":return`String(ctx.${r.source||""}).startsWith("${r.search||""}")`;case"endsWith":return`String(ctx.${r.source||""}).endsWith("${r.search||""}")`;case"split":{const l=r.separator||",";return`String(ctx.${r.source||""}).split("${l}")`}case"join":{const l=r.separator||", ";return`(Array.isArray(ctx.${r.source||""}) ? ctx.${r.source||""}.join("${l}") : "")`}case"first":return`(Array.isArray(ctx.${r.source||""}) ? ctx.${r.source||""}[0] : String(ctx.${r.source||""}).charAt(0))`;case"last":return`(Array.isArray(ctx.${r.source||""}) ? ctx.${r.source||""}[ctx.${r.source||""}.length - 1] : String(ctx.${r.source||""}).slice(-1))`;case"custom":default:return r.expression||""}}function p_(e){return{operation:"custom",args:{expression:e}}}function g_({value:e,onChange:t,availableVars:r,previewContext:n}){const[o,l]=E.useState(()=>e?p_(e):{operation:"template",args:{template:""}}),i=d=>{l(d),t(C0(d))},c=(d,m)=>{i({...o,args:{...o.args,[d]:m}})},u=E.useMemo(()=>{try{const d=n||{};n||r.forEach(h=>{d[h]=`[${h}]`});const f=new Function("ctx",`return (${C0(o)});`)(d);return f==null?"":typeof f=="object"?JSON.stringify(f):String(f)}catch{return"(error)"}},[o,r,n]);return s.jsxs("div",{className:"space-y-3 p-3 bg-[var(--color-ds-background-elevated)] rounded-lg border border-[var(--color-ds-border-default-50)]",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs font-medium text-[var(--color-ds-text-secondary)] w-20",children:"Operación:"}),s.jsx("select",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.operation,onChange:d=>i({operation:d.target.value,args:{}}),children:Object.entries(m_).map(([d,m])=>s.jsx("optgroup",{label:d,children:m.map(f=>s.jsx("option",{value:f,children:h_[f]},f))},d))})]}),s.jsxs("div",{className:"space-y-2",children:[o.operation==="template"&&s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:["Plantilla (usa ",s.jsx("code",{className:"bg-[var(--color-ds-background-neutral)] px-1 rounded",children:"{{VARIABLE}}"}),"):"]}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1.5 text-sm",value:o.args.template||"",placeholder:"Ej: Hola {{NOMBRE}}, tu ID es {{ID}}",onChange:d=>c("template",d.target.value)}),r.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[s.jsx("span",{className:"text-[10px] text-[var(--color-ds-text-tertiary)]",children:"Variables:"}),r.map(d=>s.jsx("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 bg-[var(--color-ds-background-accent)] text-[var(--color-ds-text-on-accent)] rounded hover:opacity-80",onClick:()=>c("template",(o.args.template||"")+`{{${d}}}`),children:d},d))]})]}),o.operation==="concat"&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Partes a concatenar (una por línea, prefija con $ para usar variable):"}),s.jsx("textarea",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm font-mono",rows:3,placeholder:`$NOMBRE
183
183
  _
184
184
  $ID`,value:(o.args.parts||[]).join(`
185
185
  `),onChange:d=>c("parts",d.target.value.split(`
186
- `))})]}),o.operation==="math"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",placeholder:"Valor o $VAR",value:o.args.left||"",onChange:d=>c("left",d.target.value)}),s.jsxs("select",{className:"bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.operator||"+",onChange:d=>c("operator",d.target.value),children:[s.jsx("option",{value:"+",children:"+"}),s.jsx("option",{value:"-",children:"−"}),s.jsx("option",{value:"*",children:"×"}),s.jsx("option",{value:"/",children:"÷"})]}),s.jsx("input",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",placeholder:"Valor o $VAR",value:o.args.right||"",onChange:d=>c("right",d.target.value)})]}),(o.operation==="uppercase"||o.operation==="lowercase")&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable a transformar:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),o.operation==="substring"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Desde:"}),s.jsx("input",{type:"number",className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.start||0,onChange:d=>c("start",Number(d.target.value))})]}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Hasta (vacío = final):"}),s.jsx("input",{type:"number",className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.end||"",onChange:d=>c("end",d.target.value?Number(d.target.value):void 0)})]})]})]}),o.operation==="replace"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Buscar:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.search||"",onChange:d=>c("search",d.target.value)})]}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Reemplazar por:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.replacement||"",onChange:d=>c("replacement",d.target.value)})]})]})]}),o.operation==="condition"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Si"}),s.jsx("input",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",placeholder:"Valor o $VAR",value:o.args.condLeft||"",onChange:d=>c("condLeft",d.target.value)}),s.jsxs("select",{className:"bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.condOperator||"===",onChange:d=>c("condOperator",d.target.value),children:[s.jsx("option",{value:"===",children:"es igual a"}),s.jsx("option",{value:"!==",children:"es diferente de"}),s.jsx("option",{value:">",children:"es mayor que"}),s.jsx("option",{value:"<",children:"es menor que"})]}),s.jsx("input",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",placeholder:"Valor o $VAR",value:o.args.condRight||"",onChange:d=>c("condRight",d.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Entonces:"}),s.jsx("input",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",placeholder:"Valor o $VAR",value:o.args.trueValue||"",onChange:d=>c("trueValue",d.target.value)}),s.jsx("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Sino:"}),s.jsx("input",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",placeholder:"Valor o $VAR",value:o.args.falseValue||"",onChange:d=>c("falseValue",d.target.value)})]})]}),o.operation==="default"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Valor si está vacío:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.defaultValue||"",placeholder:"Valor por defecto o $OTRA_VAR",onChange:d=>c("defaultValue",d.target.value)})]})]}),o.operation==="trim"&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable a limpiar:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)] mt-1",children:"Elimina espacios al inicio y final del texto."})]}),o.operation==="length"&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)] mt-1",children:"Devuelve el número de caracteres del texto."})]}),o.operation==="round"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable numérica:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Decimales:"}),s.jsx("input",{type:"number",min:"0",max:"10",className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.decimals||0,onChange:d=>c("decimals",Number(d.target.value))})]})]}),o.operation==="abs"&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable numérica:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)] mt-1",children:"Convierte números negativos a positivos."})]}),o.operation==="today"&&s.jsxs("div",{className:"p-3 bg-[var(--color-ds-background-page)] rounded border border-[var(--color-ds-border-default-50)]",children:[s.jsxs("p",{className:"text-sm text-[var(--color-ds-text-primary)]",children:["📅 Devuelve la fecha actual en formato ",s.jsx("code",{className:"bg-[var(--color-ds-background-neutral)] px-1 rounded",children:"YYYY-MM-DD"})]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)] mt-1",children:"No requiere configuración adicional."})]}),o.operation==="now"&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Formato:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.format||"iso",onChange:d=>c("format",d.target.value),children:[s.jsx("option",{value:"iso",children:"ISO 8601 (2024-01-15T10:30:00.000Z)"}),s.jsx("option",{value:"locale",children:"Fecha y hora local (15/1/2024, 10:30:00)"}),s.jsx("option",{value:"date",children:"Solo fecha local (15/1/2024)"}),s.jsx("option",{value:"time",children:"Solo hora local (10:30:00)"})]})]}),o.operation==="padStart"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Longitud final:"}),s.jsx("input",{type:"number",min:"1",className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.length||2,onChange:d=>c("length",Number(d.target.value))})]}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Carácter de relleno:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.char||"0",maxLength:1,onChange:d=>c("char",d.target.value)})]})]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)]",children:'Ej: "5" con longitud 3 y relleno "0" → "005"'})]}),o.operation==="padEnd"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Longitud final:"}),s.jsx("input",{type:"number",min:"1",className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.length||10,onChange:d=>c("length",Number(d.target.value))})]}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Carácter de relleno:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.char||" ",maxLength:1,onChange:d=>c("char",d.target.value)})]})]})]}),(o.operation==="includes"||o.operation==="startsWith"||o.operation==="endsWith")&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:o.operation==="includes"?"Texto a buscar:":o.operation==="startsWith"?"Debe empezar con:":"Debe terminar con:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.search||"",onChange:d=>c("search",d.target.value)})]}),s.jsxs("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)]",children:["Devuelve ",s.jsx("code",{className:"bg-[var(--color-ds-background-neutral)] px-0.5 rounded",children:"true"})," o ",s.jsx("code",{className:"bg-[var(--color-ds-background-neutral)] px-0.5 rounded",children:"false"})]})]}),o.operation==="split"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Separador:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.separator||",",placeholder:",",onChange:d=>c("separator",d.target.value)})]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)]",children:'Divide el texto en una lista. Ej: "a,b,c" → ["a", "b", "c"]'})]}),o.operation==="join"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable (array):"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Separador:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.separator||", ",placeholder:", ",onChange:d=>c("separator",d.target.value)})]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)]",children:'Une los elementos de la lista. Ej: ["a", "b"] → "a, b"'})]}),(o.operation==="first"||o.operation==="last")&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable (texto o array):"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)] mt-1",children:o.operation==="first"?"Devuelve el primer elemento (o carácter si es texto).":"Devuelve el último elemento (o carácter si es texto)."})]}),o.operation==="custom"&&s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-[var(--color-ds-text-secondary)] mb-1 block",children:["Expresión JavaScript (usa ",s.jsx("code",{className:"bg-[var(--color-ds-background-neutral)] px-1 rounded",children:"ctx"})," para acceder a variables):"]}),s.jsx("div",{className:"h-40 border border-[var(--color-ds-border-default-50)] rounded overflow-hidden",children:s.jsx(Ai,{value:o.args.expression||"",onChange:d=>c("expression",d),language:"javascript",minimap:!1})}),s.jsxs("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)] mt-1",children:["Ejemplo: ",s.jsx("code",{children:"ctx.NOMBRE.toUpperCase() + '_' + ctx.ID"})]})]})]}),s.jsx("div",{className:"pt-2 border-t border-[var(--color-ds-border-default-50)]",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] font-medium text-[var(--color-ds-text-tertiary)] uppercase",children:"Preview:"}),s.jsx("code",{className:"text-xs bg-[var(--color-ds-background-neutral)] px-2 py-0.5 rounded text-[var(--color-ds-text-primary)]",children:u})]})})]})}const b_=({isOpen:e,onClose:t})=>{var k,y;const{isActive:r,formValues:n,systemContext:o}=un(),l=oe(C=>C.schema),i=oe(C=>C.activeVariantId),c=oe(C=>C.setSchema||C.updateSchema),[u,d]=E.useState("variables"),[m,f]=E.useState(null),h=l.variables||[],p=E.useMemo(()=>["ACTIVE_VARIANT",...h.filter(C=>C.type==="constant").map(C=>C.key)],[h]),v=E.useMemo(()=>{var M,$;const C=(($=(M=l.variants)==null?void 0:M.find(T=>T.key===i))==null?void 0:$.label)||i,N={...o,ACTIVE_VARIANT:C};return h.forEach(T=>{T.type==="constant"?N[T.key]=T.value:N[T.key]===void 0&&(N[T.key]=`[${T.key}]`)}),N},[o,h]),b=()=>{const C={key:"NUEVA_VAR",type:"constant",value:""},N={...l,variables:[...h,C]};c(N)},g=C=>{const N=[...h];N.splice(C,1),c({...l,variables:N}),m===C&&f(null)},x=C=>{const N=h[C],M={...N,key:`${N.key}_COPY`},$=[...h];$.splice(C+1,0,M),c({...l,variables:$}),f(C+1)},w=(C,N)=>{if(N==="up"&&C===0||N==="down"&&C===h.length-1)return;const M=[...h],$=N==="up"?C-1:C+1;[M[C],M[$]]=[M[$],M[C]],c({...l,variables:M}),m===C?f($):m===$&&f(C)},j=(C,N,M)=>{const $=[...h];$[C]={...$[C],[N]:M},c({...l,variables:$})};return e?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t,children:s.jsxs("div",{className:"bg-[var(--color-ds-background-page)] rounded-lg shadow-2xl w-full max-w-4xl mx-4 max-h-[85vh] flex flex-col",onClick:C=>C.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--color-ds-border-default-50)]",children:[s.jsxs("h2",{className:"text-lg font-medium text-[var(--color-ds-text-primary)] flex items-center gap-2",children:["Variables del Sistema",!r&&s.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-yellow-100 text-yellow-800 font-normal",children:"Modo diseño (inactivo)"})]}),s.jsx(fe,{size:"sm",variant:"ghost",shape:"circle",icon:nt,onClick:t,ariaLabel:"Cerrar"})]}),s.jsx("div",{className:"flex-1 overflow-hidden p-4",children:s.jsx(fr,{value:u,onChange:d,options:[{label:"Variables Definidas",value:"variables"},{label:"Contexto Total (Preview)",value:"context"},{label:"Formulario (Preview)",value:"values"}],children:{variables:s.jsxs("div",{className:"h-full flex flex-col pt-2",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:"Define constantes o expresiones calculadas disponibles en todo el formulario."}),s.jsx(fe,{size:"sm",variant:"primary",icon:Sn,onClick:b,children:"Añadir"})]}),s.jsxs("div",{className:"flex-1 overflow-auto space-y-2",children:[s.jsxs("div",{className:"bg-[var(--color-ds-background-subtle)] rounded-lg border border-[var(--color-ds-border-default-50)] overflow-hidden mb-4 opacity-80",children:[s.jsx("div",{className:"p-2 border-b border-[var(--color-ds-border-default-50)] text-[10px] font-bold uppercase text-[var(--color-ds-text-secondary)]",children:"Variables Globales (Solo Lectura)"}),s.jsxs("div",{className:"p-3 flex items-center gap-3",children:[s.jsx("div",{className:"flex-1 font-mono text-sm font-medium text-[var(--color-ds-text-primary)]",children:"ACTIVE_VARIANT"}),s.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-[var(--color-ds-background-accent)] text-[var(--color-ds-text-on-accent)]",children:"Sistema"}),s.jsx("input",{className:"flex-1 bg-transparent border-none text-right text-sm text-[var(--color-ds-text-secondary)]",readOnly:!0,value:((y=(k=l.variants)==null?void 0:k.find(C=>C.key===i))==null?void 0:y.label)||i||"(ninguna)"})]})]}),h.map((C,N)=>s.jsxs("div",{className:"bg-[var(--color-ds-background-page)] rounded-lg border border-[var(--color-ds-border-default-50)] overflow-hidden",children:[s.jsxs("div",{className:"flex items-center gap-3 p-3",children:[s.jsxs("div",{className:"flex flex-col gap-0.5 mr-1",children:[s.jsx("button",{onClick:()=>w(N,"up"),disabled:N===0,className:"p-0.5 text-[var(--color-ds-text-tertiary)] hover:text-[var(--color-ds-text-primary)] disabled:opacity-20 transition-colors",title:"Mover arriba",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),s.jsx("button",{onClick:()=>w(N,"down"),disabled:N===h.length-1,className:"p-0.5 text-[var(--color-ds-text-tertiary)] hover:text-[var(--color-ds-text-primary)] disabled:opacity-20 transition-colors",title:"Mover abajo",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),s.jsx("input",{className:"flex-1 max-w-[200px] bg-transparent border border-transparent hover:border-[var(--color-ds-border-default-50)] focus:border-[var(--color-ds-border-primary)] rounded px-2 py-1 font-mono text-sm font-medium",value:C.key,placeholder:"NOMBRE_VAR",onChange:M=>j(N,"key",M.target.value.replace(/\s/g,"_"))}),s.jsxs("select",{className:"bg-[var(--color-ds-background-elevated)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:C.type,onChange:M=>{j(N,"type",M.target.value),M.target.value==="computed"&&f(N)},children:[s.jsx("option",{value:"constant",children:"📌 Constante"}),s.jsx("option",{value:"computed",children:"⚡ Calculada"})]}),C.type==="constant"&&s.jsx("input",{className:"flex-1 bg-transparent border border-[var(--color-ds-border-default-50)] hover:border-[var(--color-ds-border-primary)] focus:border-[var(--color-ds-border-primary)] rounded px-2 py-1 text-sm",value:C.value,placeholder:"Valor estático...",onChange:M=>j(N,"value",M.target.value)}),C.type==="computed"&&s.jsxs("button",{className:"flex-1 text-left px-2 py-1 text-sm bg-[var(--color-ds-background-elevated)] border border-[var(--color-ds-border-default-50)] rounded hover:border-[var(--color-ds-border-primary)] transition-colors flex items-center justify-between",onClick:()=>f(m===N?null:N),children:[s.jsx("span",{className:"text-[var(--color-ds-text-secondary)] truncate",children:C.value?"Expresión configurada":"Click para configurar..."}),s.jsx(Ut,{className:`w-4 h-4 transition-transform ${m===N?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>x(N),className:"p-1 text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-primary-600)] transition-colors",title:"Duplicar",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7v8a2 2 0 002 2h6M8 7V5a2 2 0 012-2h4.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V15a2 2 0 01-2 2h-2M8 7H6a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2v-2"})})}),s.jsx("button",{onClick:()=>g(N),className:"p-1 text-[var(--color-ds-text-secondary)] hover:text-red-500 transition-colors",title:"Eliminar variable",children:s.jsx(bt,{className:"w-4 h-4"})})]}),C.type==="computed"&&m===N&&s.jsx("div",{className:"border-t border-[var(--color-ds-border-default-50)] p-3 bg-[var(--color-ds-background-page)]",children:s.jsx(v_,{value:C.value,onChange:M=>j(N,"value",M),availableVars:p.filter(M=>M!==C.key),previewContext:v})})]},N)),h.length===0&&s.jsxs("div",{className:"p-8 text-center text-[var(--color-ds-text-secondary)] italic bg-[var(--color-ds-background-page)] rounded-lg border border-dashed border-[var(--color-ds-border-default-50)]",children:[s.jsx(kd,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),'No hay variables definidas. Haz click en "Añadir" para crear una.']})]})]}),context:s.jsxs("div",{className:"h-full overflow-auto mt-2 p-2 rounded bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)]",children:[s.jsx("p",{className:"text-xs font-bold text-[var(--color-ds-text-secondary)] mb-2 uppercase",children:"Datos cargados desde el backend + Variables definidas"}),r?Object.keys(o).length>0?s.jsx("pre",{className:"text-xs font-mono text-[var(--color-ds-text-primary)]",children:JSON.stringify(o,null,2)}):s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)] italic",children:"No hay contexto cargado."}):s.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-[var(--color-ds-text-secondary)] opacity-70",children:[s.jsx(oo,{className:"w-6 h-6 mb-1"}),s.jsx("p",{className:"text-sm",children:"Inicia el modo Preview para ver el contexto en vivo."})]})]}),values:s.jsx("div",{className:"h-full overflow-auto mt-2 p-2 rounded bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)]",children:r?s.jsx("pre",{className:"text-xs font-mono text-[var(--color-ds-text-primary)]",children:JSON.stringify(n,null,2)}):s.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-[var(--color-ds-text-secondary)] opacity-70",children:[s.jsx(oo,{className:"w-6 h-6 mb-1"}),s.jsx("p",{className:"text-sm",children:"Inicia el modo Preview para ver los valores en vivo."})]})})}})}),s.jsx("div",{className:"p-4 border-t border-[var(--color-ds-border-default-50)] flex justify-end",children:s.jsx(fe,{variant:"primary",onClick:t,size:"sm",children:"Cerrar"})})]})}):null};function x_(){var j;const e=oe(k=>k.schema),t=oe(k=>k.activeVariantId),r=oe(k=>k.setActiveVariant),n=oe(k=>k.addVariant),o=oe(k=>k.removeVariant),l=oe(k=>k.renameVariant),[i,c]=E.useState(!1),[u,d]=E.useState(!1),[m,f]=E.useState(""),[h,p]=E.useState(null),v=e.variants||[],b=t?((j=v.find(k=>k.key===t))==null?void 0:j.label)||"Variante desconocida":"Esquema Base",g=()=>{if(!m.trim())return;const k=`variant_${Date.now().toString(36)}`;n(k,m.trim()),r(k),d(!1)},x=()=>{h&&h.label.trim()&&(l(h.key,h.label.trim()),p(null))},w=[{label:"Esquema Base",icon:t===null?Br:Ka,onSelect:()=>r(null)},...v.map(k=>({label:k.label,icon:t===k.key?Br:Ka,onSelect:()=>r(k.key)})),{label:"Nueva variante...",icon:Sn,onSelect:()=>{f(""),d(!0)}},{label:"Gestionar variantes...",icon:gn,onSelect:()=>c(!0)}];return s.jsxs(s.Fragment,{children:[s.jsx(sa,{trigger:s.jsxs("span",{className:"flex items-center gap-1 px-2 py-1.5 text-sm font-medium text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-background-neutral-hover)] rounded-md transition-colors cursor-pointer",title:"Seleccionar variante activa",children:[s.jsx(Ka,{className:"w-4 h-4 mr-1 text-[var(--color-ds-text-secondary)]"}),b,s.jsx(Ut,{className:"w-3 h-3 opacity-50"})]}),items:w}),s.jsx(Et,{isOpen:u,onClose:()=>d(!1),title:"Nueva Variante",maxWidth:"max-w-md",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(Wt,{id:"new-variant-name",text:"Nombre de la variante",size:"sm"}),s.jsx(je,{value:m,onChange:k=>f(k.target.value),placeholder:"Ej. Formulario de Edición",autoFocus:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(fe,{variant:"ghost",onClick:()=>d(!1),children:"Cancelar"}),s.jsx(fe,{onClick:g,disabled:!m.trim(),children:"Crear"})]})]})}),s.jsx(Et,{isOpen:i,onClose:()=>c(!1),title:"Gestionar Variantes",maxWidth:"max-w-lg",children:s.jsxs("div",{className:"space-y-4",children:[v.length===0&&s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:"No hay variantes definidas."}),s.jsx("div",{className:"flex flex-col gap-2",children:v.map(k=>s.jsxs("div",{className:"flex items-center justify-between p-2 border rounded border-[var(--color-ds-border-default-50)]",children:[(h==null?void 0:h.key)===k.key?s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx(je,{value:h.label,onChange:y=>p({...h,label:y.target.value}),className:"h-8 text-sm"}),s.jsx(It,{size:"sm",icon:Br,onClick:x,ariaLabel:"Guardar nombre"})]}):s.jsx("span",{className:"text-sm font-medium",children:k.label}),s.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[!h&&s.jsx(It,{size:"sm",icon:gn,onClick:()=>p({key:k.key,label:k.label}),title:"Renombrar",ariaLabel:"Renombrar variante"}),s.jsx(It,{size:"sm",icon:bt,onClick:()=>{window.confirm(`¿Eliminar variante "${k.label}"?`)&&o(k.key)},title:"Eliminar",ariaLabel:"Eliminar variante",className:"text-red-500 hover:text-red-700"})]})]},k.key))}),s.jsx("div",{className:"flex justify-end pt-4 border-t border-[var(--color-ds-border-default-50)]",children:s.jsx(fe,{onClick:()=>c(!1),children:"Cerrar"})})]})})]})}function w_(e){return typeof e.type=="string"}function y_(e){const t=e.validation;return t===void 0||typeof t=="object"}function j_(e){const t=e.options;return Array.isArray(t)}function k_(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function vr(e){return String(e).replace(/\\/g,"\\\\").replace(/`/g,"\\`")}function E_(e){var l,i,c,u,d;const t=w_(e)&&e.type?e.type:"string";let r="yup.string()";switch(t){case"number":r="yup.number()";break;case"checkbox":r="yup.boolean()";break;case"date":r="yup.date().nullable()";break;case"file":r="yup.array()";break;case"select":case"text":case"email":case"password":case"textarea":default:r="yup.string()";break}const n=y_(e)&&e.validation?e.validation:{},o=[r];if(n.required){const m=typeof n.required=="string"?n.required:n.requiredMessage||"Requerido";o.push(`.required(\`${vr(m)}\`)`)}if(((l=n.minLength)==null?void 0:l.value)!=null&&o.push(`.min(${Number(n.minLength.value)}, \`${vr(n.minLength.message??"Muy corto")}\`)`),((i=n.maxLength)==null?void 0:i.value)!=null&&o.push(`.max(${Number(n.maxLength.value)}, \`${vr(n.maxLength.message??"Muy largo")}\`)`),(c=n.pattern)!=null&&c.value&&k_(n.pattern.value)){const m=n.pattern.value.source,f=n.pattern.value.flags||"";o.push(`.matches(new RegExp(\`${vr(m)}\`, \`${vr(f)}\`), \`${vr(n.pattern.message??"Formato inválido")}\`)`)}if(t==="number"&&(((u=n.min)==null?void 0:u.value)!=null&&o.push(`.min(${Number(n.min.value)}, \`${vr(n.min.message??"Demasiado pequeño")}\`)`),((d=n.max)==null?void 0:d.value)!=null&&o.push(`.max(${Number(n.max.value)}, \`${vr(n.max.message??"Demasiado grande")}\`)`)),t==="select"&&j_(e)&&e.options&&e.options.length){const m=e.options.map(f=>JSON.stringify(String(f.value)));o.push(`.oneOf([${m.join(", ")}])`)}return o.join("")}function Ii(e,t="validationSchema"){const r=[],n=e.fields??[];for(const i of n){const c=i;!c.name||typeof c.name!="string"||r.push(` ${c.name}: ${E_(c)},`)}const o=r.join(`
186
+ `))})]}),o.operation==="math"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",placeholder:"Valor o $VAR",value:o.args.left||"",onChange:d=>c("left",d.target.value)}),s.jsxs("select",{className:"bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.operator||"+",onChange:d=>c("operator",d.target.value),children:[s.jsx("option",{value:"+",children:"+"}),s.jsx("option",{value:"-",children:"−"}),s.jsx("option",{value:"*",children:"×"}),s.jsx("option",{value:"/",children:"÷"})]}),s.jsx("input",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",placeholder:"Valor o $VAR",value:o.args.right||"",onChange:d=>c("right",d.target.value)})]}),(o.operation==="uppercase"||o.operation==="lowercase")&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable a transformar:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),o.operation==="substring"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Desde:"}),s.jsx("input",{type:"number",className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.start||0,onChange:d=>c("start",Number(d.target.value))})]}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Hasta (vacío = final):"}),s.jsx("input",{type:"number",className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.end||"",onChange:d=>c("end",d.target.value?Number(d.target.value):void 0)})]})]})]}),o.operation==="replace"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Buscar:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.search||"",onChange:d=>c("search",d.target.value)})]}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Reemplazar por:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.replacement||"",onChange:d=>c("replacement",d.target.value)})]})]})]}),o.operation==="condition"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Si"}),s.jsx("input",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",placeholder:"Valor o $VAR",value:o.args.condLeft||"",onChange:d=>c("condLeft",d.target.value)}),s.jsxs("select",{className:"bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.condOperator||"===",onChange:d=>c("condOperator",d.target.value),children:[s.jsx("option",{value:"===",children:"es igual a"}),s.jsx("option",{value:"!==",children:"es diferente de"}),s.jsx("option",{value:">",children:"es mayor que"}),s.jsx("option",{value:"<",children:"es menor que"})]}),s.jsx("input",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",placeholder:"Valor o $VAR",value:o.args.condRight||"",onChange:d=>c("condRight",d.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Entonces:"}),s.jsx("input",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",placeholder:"Valor o $VAR",value:o.args.trueValue||"",onChange:d=>c("trueValue",d.target.value)}),s.jsx("span",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Sino:"}),s.jsx("input",{className:"flex-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",placeholder:"Valor o $VAR",value:o.args.falseValue||"",onChange:d=>c("falseValue",d.target.value)})]})]}),o.operation==="default"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Valor si está vacío:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.defaultValue||"",placeholder:"Valor por defecto o $OTRA_VAR",onChange:d=>c("defaultValue",d.target.value)})]})]}),o.operation==="trim"&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable a limpiar:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)] mt-1",children:"Elimina espacios al inicio y final del texto."})]}),o.operation==="length"&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)] mt-1",children:"Devuelve el número de caracteres del texto."})]}),o.operation==="round"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable numérica:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Decimales:"}),s.jsx("input",{type:"number",min:"0",max:"10",className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.decimals||0,onChange:d=>c("decimals",Number(d.target.value))})]})]}),o.operation==="abs"&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable numérica:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)] mt-1",children:"Convierte números negativos a positivos."})]}),o.operation==="today"&&s.jsxs("div",{className:"p-3 bg-[var(--color-ds-background-page)] rounded border border-[var(--color-ds-border-default-50)]",children:[s.jsxs("p",{className:"text-sm text-[var(--color-ds-text-primary)]",children:["📅 Devuelve la fecha actual en formato ",s.jsx("code",{className:"bg-[var(--color-ds-background-neutral)] px-1 rounded",children:"YYYY-MM-DD"})]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)] mt-1",children:"No requiere configuración adicional."})]}),o.operation==="now"&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Formato:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.format||"iso",onChange:d=>c("format",d.target.value),children:[s.jsx("option",{value:"iso",children:"ISO 8601 (2024-01-15T10:30:00.000Z)"}),s.jsx("option",{value:"locale",children:"Fecha y hora local (15/1/2024, 10:30:00)"}),s.jsx("option",{value:"date",children:"Solo fecha local (15/1/2024)"}),s.jsx("option",{value:"time",children:"Solo hora local (10:30:00)"})]})]}),o.operation==="padStart"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Longitud final:"}),s.jsx("input",{type:"number",min:"1",className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.length||2,onChange:d=>c("length",Number(d.target.value))})]}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Carácter de relleno:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.char||"0",maxLength:1,onChange:d=>c("char",d.target.value)})]})]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)]",children:'Ej: "5" con longitud 3 y relleno "0" → "005"'})]}),o.operation==="padEnd"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Longitud final:"}),s.jsx("input",{type:"number",min:"1",className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.length||10,onChange:d=>c("length",Number(d.target.value))})]}),s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Carácter de relleno:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.char||" ",maxLength:1,onChange:d=>c("char",d.target.value)})]})]})]}),(o.operation==="includes"||o.operation==="startsWith"||o.operation==="endsWith")&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:o.operation==="includes"?"Texto a buscar:":o.operation==="startsWith"?"Debe empezar con:":"Debe terminar con:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.search||"",onChange:d=>c("search",d.target.value)})]}),s.jsxs("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)]",children:["Devuelve ",s.jsx("code",{className:"bg-[var(--color-ds-background-neutral)] px-0.5 rounded",children:"true"})," o ",s.jsx("code",{className:"bg-[var(--color-ds-background-neutral)] px-0.5 rounded",children:"false"})]})]}),o.operation==="split"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable:"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Separador:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.separator||",",placeholder:",",onChange:d=>c("separator",d.target.value)})]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)]",children:'Divide el texto en una lista. Ej: "a,b,c" → ["a", "b", "c"]'})]}),o.operation==="join"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable (array):"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Separador:"}),s.jsx("input",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.separator||", ",placeholder:", ",onChange:d=>c("separator",d.target.value)})]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)]",children:'Une los elementos de la lista. Ej: ["a", "b"] → "a, b"'})]}),(o.operation==="first"||o.operation==="last")&&s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Variable (texto o array):"}),s.jsxs("select",{className:"w-full mt-1 bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:o.args.source||"",onChange:d=>c("source",d.target.value),children:[s.jsx("option",{value:"",children:"Selecciona..."}),r.map(d=>s.jsx("option",{value:d,children:d},d))]}),s.jsx("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)] mt-1",children:o.operation==="first"?"Devuelve el primer elemento (o carácter si es texto).":"Devuelve el último elemento (o carácter si es texto)."})]}),o.operation==="custom"&&s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-[var(--color-ds-text-secondary)] mb-1 block",children:["Expresión JavaScript (usa ",s.jsx("code",{className:"bg-[var(--color-ds-background-neutral)] px-1 rounded",children:"ctx"})," para acceder a variables):"]}),s.jsx("div",{className:"h-40 border border-[var(--color-ds-border-default-50)] rounded overflow-hidden",children:s.jsx(Ai,{value:o.args.expression||"",onChange:d=>c("expression",d),language:"javascript",minimap:!1})}),s.jsxs("p",{className:"text-[10px] text-[var(--color-ds-text-tertiary)] mt-1",children:["Ejemplo: ",s.jsx("code",{children:"ctx.NOMBRE.toUpperCase() + '_' + ctx.ID"})]})]})]}),s.jsx("div",{className:"pt-2 border-t border-[var(--color-ds-border-default-50)]",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] font-medium text-[var(--color-ds-text-tertiary)] uppercase",children:"Preview:"}),s.jsx("code",{className:"text-xs bg-[var(--color-ds-background-neutral)] px-2 py-0.5 rounded text-[var(--color-ds-text-primary)]",children:u})]})})]})}const v_=({isOpen:e,onClose:t})=>{var k,y;const{isActive:r,formValues:n,systemContext:o}=un(),l=oe(C=>C.schema),i=oe(C=>C.activeVariantId),c=oe(C=>C.setSchema||C.updateSchema),[u,d]=E.useState("variables"),[m,f]=E.useState(null),h=l.variables||[],p=E.useMemo(()=>["ACTIVE_VARIANT",...h.filter(C=>C.type==="constant").map(C=>C.key)],[h]),v=E.useMemo(()=>{var M,$;const C=(($=(M=l.variants)==null?void 0:M.find(T=>T.key===i))==null?void 0:$.label)||i,N={...o,ACTIVE_VARIANT:C};return h.forEach(T=>{T.type==="constant"?N[T.key]=T.value:N[T.key]===void 0&&(N[T.key]=`[${T.key}]`)}),N},[o,h]),b=()=>{const C={key:"NUEVA_VAR",type:"constant",value:""},N={...l,variables:[...h,C]};c(N)},g=C=>{const N=[...h];N.splice(C,1),c({...l,variables:N}),m===C&&f(null)},x=C=>{const N=h[C],M={...N,key:`${N.key}_COPY`},$=[...h];$.splice(C+1,0,M),c({...l,variables:$}),f(C+1)},w=(C,N)=>{if(N==="up"&&C===0||N==="down"&&C===h.length-1)return;const M=[...h],$=N==="up"?C-1:C+1;[M[C],M[$]]=[M[$],M[C]],c({...l,variables:M}),m===C?f($):m===$&&f(C)},j=(C,N,M)=>{const $=[...h];$[C]={...$[C],[N]:M},c({...l,variables:$})};return e?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t,children:s.jsxs("div",{className:"bg-[var(--color-ds-background-page)] rounded-lg shadow-2xl w-full max-w-4xl mx-4 max-h-[85vh] flex flex-col",onClick:C=>C.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--color-ds-border-default-50)]",children:[s.jsxs("h2",{className:"text-lg font-medium text-[var(--color-ds-text-primary)] flex items-center gap-2",children:["Variables del Sistema",!r&&s.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-yellow-100 text-yellow-800 font-normal",children:"Modo diseño (inactivo)"})]}),s.jsx(fe,{size:"sm",variant:"ghost",shape:"circle",icon:nt,onClick:t,ariaLabel:"Cerrar"})]}),s.jsx("div",{className:"flex-1 overflow-hidden p-4",children:s.jsx(fr,{value:u,onChange:d,options:[{label:"Variables Definidas",value:"variables"},{label:"Contexto Total (Preview)",value:"context"},{label:"Formulario (Preview)",value:"values"}],children:{variables:s.jsxs("div",{className:"h-full flex flex-col pt-2",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:"Define constantes o expresiones calculadas disponibles en todo el formulario."}),s.jsx(fe,{size:"sm",variant:"primary",icon:Sn,onClick:b,children:"Añadir"})]}),s.jsxs("div",{className:"flex-1 overflow-auto space-y-2",children:[s.jsxs("div",{className:"bg-[var(--color-ds-background-subtle)] rounded-lg border border-[var(--color-ds-border-default-50)] overflow-hidden mb-4 opacity-80",children:[s.jsx("div",{className:"p-2 border-b border-[var(--color-ds-border-default-50)] text-[10px] font-bold uppercase text-[var(--color-ds-text-secondary)]",children:"Variables Globales (Solo Lectura)"}),s.jsxs("div",{className:"p-3 flex items-center gap-3",children:[s.jsx("div",{className:"flex-1 font-mono text-sm font-medium text-[var(--color-ds-text-primary)]",children:"ACTIVE_VARIANT"}),s.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-[var(--color-ds-background-accent)] text-[var(--color-ds-text-on-accent)]",children:"Sistema"}),s.jsx("input",{className:"flex-1 bg-transparent border-none text-right text-sm text-[var(--color-ds-text-secondary)]",readOnly:!0,value:((y=(k=l.variants)==null?void 0:k.find(C=>C.key===i))==null?void 0:y.label)||i||"(ninguna)"})]})]}),h.map((C,N)=>s.jsxs("div",{className:"bg-[var(--color-ds-background-page)] rounded-lg border border-[var(--color-ds-border-default-50)] overflow-hidden",children:[s.jsxs("div",{className:"flex items-center gap-3 p-3",children:[s.jsxs("div",{className:"flex flex-col gap-0.5 mr-1",children:[s.jsx("button",{onClick:()=>w(N,"up"),disabled:N===0,className:"p-0.5 text-[var(--color-ds-text-tertiary)] hover:text-[var(--color-ds-text-primary)] disabled:opacity-20 transition-colors",title:"Mover arriba",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})})}),s.jsx("button",{onClick:()=>w(N,"down"),disabled:N===h.length-1,className:"p-0.5 text-[var(--color-ds-text-tertiary)] hover:text-[var(--color-ds-text-primary)] disabled:opacity-20 transition-colors",title:"Mover abajo",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}),s.jsx("input",{className:"flex-1 max-w-[200px] bg-transparent border border-transparent hover:border-[var(--color-ds-border-default-50)] focus:border-[var(--color-ds-border-primary)] rounded px-2 py-1 font-mono text-sm font-medium",value:C.key,placeholder:"NOMBRE_VAR",onChange:M=>j(N,"key",M.target.value.replace(/\s/g,"_"))}),s.jsxs("select",{className:"bg-[var(--color-ds-background-elevated)] border border-[var(--color-ds-border-default-50)] rounded px-2 py-1 text-sm",value:C.type,onChange:M=>{j(N,"type",M.target.value),M.target.value==="computed"&&f(N)},children:[s.jsx("option",{value:"constant",children:"📌 Constante"}),s.jsx("option",{value:"computed",children:"⚡ Calculada"})]}),C.type==="constant"&&s.jsx("input",{className:"flex-1 bg-transparent border border-[var(--color-ds-border-default-50)] hover:border-[var(--color-ds-border-primary)] focus:border-[var(--color-ds-border-primary)] rounded px-2 py-1 text-sm",value:C.value,placeholder:"Valor estático...",onChange:M=>j(N,"value",M.target.value)}),C.type==="computed"&&s.jsxs("button",{className:"flex-1 text-left px-2 py-1 text-sm bg-[var(--color-ds-background-elevated)] border border-[var(--color-ds-border-default-50)] rounded hover:border-[var(--color-ds-border-primary)] transition-colors flex items-center justify-between",onClick:()=>f(m===N?null:N),children:[s.jsx("span",{className:"text-[var(--color-ds-text-secondary)] truncate",children:C.value?"Expresión configurada":"Click para configurar..."}),s.jsx(Ut,{className:`w-4 h-4 transition-transform ${m===N?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>x(N),className:"p-1 text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-primary-600)] transition-colors",title:"Duplicar",children:s.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7v8a2 2 0 002 2h6M8 7V5a2 2 0 012-2h4.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V15a2 2 0 01-2 2h-2M8 7H6a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2v-2"})})}),s.jsx("button",{onClick:()=>g(N),className:"p-1 text-[var(--color-ds-text-secondary)] hover:text-red-500 transition-colors",title:"Eliminar variable",children:s.jsx(bt,{className:"w-4 h-4"})})]}),C.type==="computed"&&m===N&&s.jsx("div",{className:"border-t border-[var(--color-ds-border-default-50)] p-3 bg-[var(--color-ds-background-page)]",children:s.jsx(g_,{value:C.value,onChange:M=>j(N,"value",M),availableVars:p.filter(M=>M!==C.key),previewContext:v})})]},N)),h.length===0&&s.jsxs("div",{className:"p-8 text-center text-[var(--color-ds-text-secondary)] italic bg-[var(--color-ds-background-page)] rounded-lg border border-dashed border-[var(--color-ds-border-default-50)]",children:[s.jsx(kd,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),'No hay variables definidas. Haz click en "Añadir" para crear una.']})]})]}),context:s.jsxs("div",{className:"h-full overflow-auto mt-2 p-2 rounded bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)]",children:[s.jsx("p",{className:"text-xs font-bold text-[var(--color-ds-text-secondary)] mb-2 uppercase",children:"Datos cargados desde el backend + Variables definidas"}),r?Object.keys(o).length>0?s.jsx("pre",{className:"text-xs font-mono text-[var(--color-ds-text-primary)]",children:JSON.stringify(o,null,2)}):s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)] italic",children:"No hay contexto cargado."}):s.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-[var(--color-ds-text-secondary)] opacity-70",children:[s.jsx(oo,{className:"w-6 h-6 mb-1"}),s.jsx("p",{className:"text-sm",children:"Inicia el modo Preview para ver el contexto en vivo."})]})]}),values:s.jsx("div",{className:"h-full overflow-auto mt-2 p-2 rounded bg-[var(--color-ds-background-page)] border border-[var(--color-ds-border-default-50)]",children:r?s.jsx("pre",{className:"text-xs font-mono text-[var(--color-ds-text-primary)]",children:JSON.stringify(n,null,2)}):s.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-[var(--color-ds-text-secondary)] opacity-70",children:[s.jsx(oo,{className:"w-6 h-6 mb-1"}),s.jsx("p",{className:"text-sm",children:"Inicia el modo Preview para ver los valores en vivo."})]})})}})}),s.jsx("div",{className:"p-4 border-t border-[var(--color-ds-border-default-50)] flex justify-end",children:s.jsx(fe,{variant:"primary",onClick:t,size:"sm",children:"Cerrar"})})]})}):null};function b_(){var j;const e=oe(k=>k.schema),t=oe(k=>k.activeVariantId),r=oe(k=>k.setActiveVariant),n=oe(k=>k.addVariant),o=oe(k=>k.removeVariant),l=oe(k=>k.renameVariant),[i,c]=E.useState(!1),[u,d]=E.useState(!1),[m,f]=E.useState(""),[h,p]=E.useState(null),v=e.variants||[],b=t?((j=v.find(k=>k.key===t))==null?void 0:j.label)||"Variante desconocida":"Esquema Base",g=()=>{if(!m.trim())return;const k=`variant_${Date.now().toString(36)}`;n(k,m.trim()),r(k),d(!1)},x=()=>{h&&h.label.trim()&&(l(h.key,h.label.trim()),p(null))},w=[{label:"Esquema Base",icon:t===null?Br:Ka,onSelect:()=>r(null)},...v.map(k=>({label:k.label,icon:t===k.key?Br:Ka,onSelect:()=>r(k.key)})),{label:"Nueva variante...",icon:Sn,onSelect:()=>{f(""),d(!0)}},{label:"Gestionar variantes...",icon:gn,onSelect:()=>c(!0)}];return s.jsxs(s.Fragment,{children:[s.jsx(sa,{trigger:s.jsxs("span",{className:"flex items-center gap-1 px-2 py-1.5 text-sm font-medium text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-background-neutral-hover)] rounded-md transition-colors cursor-pointer",title:"Seleccionar variante activa",children:[s.jsx(Ka,{className:"w-4 h-4 mr-1 text-[var(--color-ds-text-secondary)]"}),b,s.jsx(Ut,{className:"w-3 h-3 opacity-50"})]}),items:w}),s.jsx(Et,{isOpen:u,onClose:()=>d(!1),title:"Nueva Variante",maxWidth:"max-w-md",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(Wt,{id:"new-variant-name",text:"Nombre de la variante",size:"sm"}),s.jsx(je,{value:m,onChange:k=>f(k.target.value),placeholder:"Ej. Formulario de Edición",autoFocus:!0})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(fe,{variant:"ghost",onClick:()=>d(!1),children:"Cancelar"}),s.jsx(fe,{onClick:g,disabled:!m.trim(),children:"Crear"})]})]})}),s.jsx(Et,{isOpen:i,onClose:()=>c(!1),title:"Gestionar Variantes",maxWidth:"max-w-lg",children:s.jsxs("div",{className:"space-y-4",children:[v.length===0&&s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:"No hay variantes definidas."}),s.jsx("div",{className:"flex flex-col gap-2",children:v.map(k=>s.jsxs("div",{className:"flex items-center justify-between p-2 border rounded border-[var(--color-ds-border-default-50)]",children:[(h==null?void 0:h.key)===k.key?s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx(je,{value:h.label,onChange:y=>p({...h,label:y.target.value}),className:"h-8 text-sm"}),s.jsx(It,{size:"sm",icon:Br,onClick:x,ariaLabel:"Guardar nombre"})]}):s.jsx("span",{className:"text-sm font-medium",children:k.label}),s.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[!h&&s.jsx(It,{size:"sm",icon:gn,onClick:()=>p({key:k.key,label:k.label}),title:"Renombrar",ariaLabel:"Renombrar variante"}),s.jsx(It,{size:"sm",icon:bt,onClick:()=>{window.confirm(`¿Eliminar variante "${k.label}"?`)&&o(k.key)},title:"Eliminar",ariaLabel:"Eliminar variante",className:"text-red-500 hover:text-red-700"})]})]},k.key))}),s.jsx("div",{className:"flex justify-end pt-4 border-t border-[var(--color-ds-border-default-50)]",children:s.jsx(fe,{onClick:()=>c(!1),children:"Cerrar"})})]})})]})}function x_(e){return typeof e.type=="string"}function w_(e){const t=e.validation;return t===void 0||typeof t=="object"}function y_(e){const t=e.options;return Array.isArray(t)}function j_(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function vr(e){return String(e).replace(/\\/g,"\\\\").replace(/`/g,"\\`")}function k_(e){var l,i,c,u,d;const t=x_(e)&&e.type?e.type:"string";let r="yup.string()";switch(t){case"number":r="yup.number()";break;case"checkbox":r="yup.boolean()";break;case"date":r="yup.date().nullable()";break;case"file":r="yup.array()";break;case"select":case"text":case"email":case"password":case"textarea":default:r="yup.string()";break}const n=w_(e)&&e.validation?e.validation:{},o=[r];if(n.required){const m=typeof n.required=="string"?n.required:n.requiredMessage||"Requerido";o.push(`.required(\`${vr(m)}\`)`)}if(((l=n.minLength)==null?void 0:l.value)!=null&&o.push(`.min(${Number(n.minLength.value)}, \`${vr(n.minLength.message??"Muy corto")}\`)`),((i=n.maxLength)==null?void 0:i.value)!=null&&o.push(`.max(${Number(n.maxLength.value)}, \`${vr(n.maxLength.message??"Muy largo")}\`)`),(c=n.pattern)!=null&&c.value&&j_(n.pattern.value)){const m=n.pattern.value.source,f=n.pattern.value.flags||"";o.push(`.matches(new RegExp(\`${vr(m)}\`, \`${vr(f)}\`), \`${vr(n.pattern.message??"Formato inválido")}\`)`)}if(t==="number"&&(((u=n.min)==null?void 0:u.value)!=null&&o.push(`.min(${Number(n.min.value)}, \`${vr(n.min.message??"Demasiado pequeño")}\`)`),((d=n.max)==null?void 0:d.value)!=null&&o.push(`.max(${Number(n.max.value)}, \`${vr(n.max.message??"Demasiado grande")}\`)`)),t==="select"&&y_(e)&&e.options&&e.options.length){const m=e.options.map(f=>JSON.stringify(String(f.value)));o.push(`.oneOf([${m.join(", ")}])`)}return o.join("")}function Ii(e,t="validationSchema"){const r=[],n=e.fields??[];for(const i of n){const c=i;!c.name||typeof c.name!="string"||r.push(` ${c.name}: ${k_(c)},`)}const o=r.join(`
187
187
  `);return`/* eslint-disable */
188
188
  // Auto-generated with generateYupCode(schema)
189
189
  import * as yup from "yup";
@@ -192,7 +192,7 @@ $ID`,value:(o.args.parts||[]).join(`
192
192
  ${o}
193
193
  });
194
194
 
195
- export type FormValues = yup.InferType<typeof ${t}>;`}function R_(e){const t={},r=o=>{typeof o=="string"&&(o.startsWith("forms.")||o.startsWith("ds."))&&(t[o]="")};return e.fields.forEach(o=>{var l,i,c,u,d,m,f,h,p,v,b,g,x,w,j;if(r(o.label),r(o.placeholder),r(o.info),r(o.groupLabel),o.validation){if(typeof o.validation.required=="string"&&r(o.validation.required),(l=o.validation.minLength)!=null&&l.message&&r(o.validation.minLength.message),(i=o.validation.maxLength)!=null&&i.message&&r(o.validation.maxLength.message),(c=o.validation.pattern)!=null&&c.message&&r(o.validation.pattern.message),(u=o.validation.numberMin)!=null&&u.message&&r(o.validation.numberMin.message),(d=o.validation.numberMax)!=null&&d.message&&r(o.validation.numberMax.message),(m=o.validation.step)!=null&&m.message&&r(o.validation.step.message),(f=o.validation.integerOnly)!=null&&f.message&&r(o.validation.integerOnly.message),(h=o.validation.positiveOnly)!=null&&h.message&&r(o.validation.positiveOnly.message),(p=o.validation.selectMin)!=null&&p.message&&r(o.validation.selectMin.message),(v=o.validation.selectMax)!=null&&v.message&&r(o.validation.selectMax.message),(b=o.validation.dateMin)!=null&&b.message&&r(o.validation.dateMin.message),(g=o.validation.dateMax)!=null&&g.message&&r(o.validation.dateMax.message),(x=o.validation.disallowPast)!=null&&x.message&&r(o.validation.disallowPast.message),(w=o.validation.disallowFuture)!=null&&w.message&&r(o.validation.disallowFuture.message),(j=o.validation.fileMaxSizeMB)!=null&&j.message&&r(o.validation.fileMaxSizeMB.message),o.validation.customFn){const k=/t\s*\(\s*(['"])(.*?)\1\s*\)/g;let y;for(;(y=k.exec(o.validation.customFn))!==null;)r(y[2])}o.validation.customMessages&&Object.values(o.validation.customMessages).forEach(k=>{r(k)})}o.type==="inputGroup"&&Array.isArray(o.inputs)&&o.inputs.forEach(k=>{typeof k=="object"&&(r(k.label),r(k.placeholder))}),Array.isArray(o.options)&&o.options.forEach(k=>{r(k.label)})}),(o=>{o.forEach(l=>{l.type==="rows"?l.sections.forEach(i=>{r(i.sectionTitle),i.rows.forEach(c=>{r(c.title)})}):l.type==="tabs"&&l.tabs.forEach(i=>{r(i.label),i.sections.forEach(c=>{r(c.sectionTitle),c.rows.forEach(u=>{r(u.title)})})})})})(e.layout),r(e.successMessage),r(e.errorMessage),t}function Fi(e,t,r){const n=R_(e);if(t&&typeof t.exportTranslations=="function"){const i=t.exportTranslations(),c={},u=(d,m="")=>{Object.entries(d).forEach(([f,h])=>{const p=m?`${m}.${f}`:f;if(typeof h=="object"&&h!==null&&!Array.isArray(h))u(h,p);else if(p in n){const v=p.split(".");let b=c;for(let g=0;g<v.length-1;g++)b[v[g]]||(b[v[g]]={}),b=b[v[g]];b[v[v.length-1]]=h}})};return u(i),Object.keys(n).forEach(d=>{const m=d.split(".");let f=c,h=!0;for(let p=0;p<m.length;p++)if(p===m.length-1)f[m[p]]||(h=!1);else{if(!f[m[p]]){h=!1;break}f=f[m[p]]}if(!h){let p=d;r&&typeof r.t=="function"&&(p=r.t(d,{defaultValue:d})),f=c;for(let v=0;v<m.length-1;v++)f[m[v]]||(f[m[v]]={}),f=f[m[v]];f[m[m.length-1]]=p}}),c}const o={},l=i=>{if(t){const c=t.getTranslation(i);if(c&&c!==i)return c}if(r&&typeof r.t=="function"){const c=r.t(i,{defaultValue:i});if(c&&c!==i)return c}return`[${i}]`};return Object.keys(n).forEach(i=>{const c=l(i),u=i.split(".");let d=o;for(let m=0;m<u.length-1;m++)d[u[m]]||(d[u[m]]={}),d=d[u[m]];d[u[u.length-1]]=c}),o}function Ha(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Us={exports:{}};/*!
195
+ export type FormValues = yup.InferType<typeof ${t}>;`}function E_(e){const t={},r=o=>{typeof o=="string"&&(o.startsWith("forms.")||o.startsWith("ds."))&&(t[o]="")};return e.fields.forEach(o=>{var l,i,c,u,d,m,f,h,p,v,b,g,x,w,j;if(r(o.label),r(o.placeholder),r(o.info),r(o.groupLabel),o.validation){if(typeof o.validation.required=="string"&&r(o.validation.required),(l=o.validation.minLength)!=null&&l.message&&r(o.validation.minLength.message),(i=o.validation.maxLength)!=null&&i.message&&r(o.validation.maxLength.message),(c=o.validation.pattern)!=null&&c.message&&r(o.validation.pattern.message),(u=o.validation.numberMin)!=null&&u.message&&r(o.validation.numberMin.message),(d=o.validation.numberMax)!=null&&d.message&&r(o.validation.numberMax.message),(m=o.validation.step)!=null&&m.message&&r(o.validation.step.message),(f=o.validation.integerOnly)!=null&&f.message&&r(o.validation.integerOnly.message),(h=o.validation.positiveOnly)!=null&&h.message&&r(o.validation.positiveOnly.message),(p=o.validation.selectMin)!=null&&p.message&&r(o.validation.selectMin.message),(v=o.validation.selectMax)!=null&&v.message&&r(o.validation.selectMax.message),(b=o.validation.dateMin)!=null&&b.message&&r(o.validation.dateMin.message),(g=o.validation.dateMax)!=null&&g.message&&r(o.validation.dateMax.message),(x=o.validation.disallowPast)!=null&&x.message&&r(o.validation.disallowPast.message),(w=o.validation.disallowFuture)!=null&&w.message&&r(o.validation.disallowFuture.message),(j=o.validation.fileMaxSizeMB)!=null&&j.message&&r(o.validation.fileMaxSizeMB.message),o.validation.customFn){const k=/t\s*\(\s*(['"])(.*?)\1\s*\)/g;let y;for(;(y=k.exec(o.validation.customFn))!==null;)r(y[2])}o.validation.customMessages&&Object.values(o.validation.customMessages).forEach(k=>{r(k)})}o.type==="inputGroup"&&Array.isArray(o.inputs)&&o.inputs.forEach(k=>{typeof k=="object"&&(r(k.label),r(k.placeholder))}),Array.isArray(o.options)&&o.options.forEach(k=>{r(k.label)})}),(o=>{o.forEach(l=>{l.type==="rows"?l.sections.forEach(i=>{r(i.sectionTitle),i.rows.forEach(c=>{r(c.title)})}):l.type==="tabs"&&l.tabs.forEach(i=>{r(i.label),i.sections.forEach(c=>{r(c.sectionTitle),c.rows.forEach(u=>{r(u.title)})})})})})(e.layout),r(e.successMessage),r(e.errorMessage),t}function Fi(e,t,r){const n=E_(e);if(t&&typeof t.exportTranslations=="function"){const i=t.exportTranslations(),c={},u=(d,m="")=>{Object.entries(d).forEach(([f,h])=>{const p=m?`${m}.${f}`:f;if(typeof h=="object"&&h!==null&&!Array.isArray(h))u(h,p);else if(p in n){const v=p.split(".");let b=c;for(let g=0;g<v.length-1;g++)b[v[g]]||(b[v[g]]={}),b=b[v[g]];b[v[v.length-1]]=h}})};return u(i),Object.keys(n).forEach(d=>{const m=d.split(".");let f=c,h=!0;for(let p=0;p<m.length;p++)if(p===m.length-1)f[m[p]]||(h=!1);else{if(!f[m[p]]){h=!1;break}f=f[m[p]]}if(!h){let p=d;r&&typeof r.t=="function"&&(p=r.t(d,{defaultValue:d})),f=c;for(let v=0;v<m.length-1;v++)f[m[v]]||(f[m[v]]={}),f=f[m[v]];f[m[m.length-1]]=p}}),c}const o={},l=i=>{if(t){const c=t.getTranslation(i);if(c&&c!==i)return c}if(r&&typeof r.t=="function"){const c=r.t(i,{defaultValue:i});if(c&&c!==i)return c}return`[${i}]`};return Object.keys(n).forEach(i=>{const c=l(i),u=i.split(".");let d=o;for(let m=0;m<u.length-1;m++)d[u[m]]||(d[u[m]]={}),d=d[u[m]];d[u[u.length-1]]=c}),o}function Ha(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Us={exports:{}};/*!
196
196
 
197
197
  JSZip v3.10.1 - A JavaScript class for generating and reading zip files
198
198
  <http://stuartk.com/jszip>
@@ -202,8 +202,8 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js
202
202
 
203
203
  JSZip uses the library pako released under the MIT license :
204
204
  https://github.com/nodeca/pako/blob/main/LICENSE
205
- */var S0;function C_(){return S0||(S0=1,(function(e,t){(function(r){e.exports=r()})(function(){return(function r(n,o,l){function i(d,m){if(!o[d]){if(!n[d]){var f=typeof Ha=="function"&&Ha;if(!m&&f)return f(d,!0);if(c)return c(d,!0);var h=new Error("Cannot find module '"+d+"'");throw h.code="MODULE_NOT_FOUND",h}var p=o[d]={exports:{}};n[d][0].call(p.exports,function(v){var b=n[d][1][v];return i(b||v)},p,p.exports,r,n,o,l)}return o[d].exports}for(var c=typeof Ha=="function"&&Ha,u=0;u<l.length;u++)i(l[u]);return i})({1:[function(r,n,o){var l=r("./utils"),i=r("./support"),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(u){for(var d,m,f,h,p,v,b,g=[],x=0,w=u.length,j=w,k=l.getTypeOf(u)!=="string";x<u.length;)j=w-x,f=k?(d=u[x++],m=x<w?u[x++]:0,x<w?u[x++]:0):(d=u.charCodeAt(x++),m=x<w?u.charCodeAt(x++):0,x<w?u.charCodeAt(x++):0),h=d>>2,p=(3&d)<<4|m>>4,v=1<j?(15&m)<<2|f>>6:64,b=2<j?63&f:64,g.push(c.charAt(h)+c.charAt(p)+c.charAt(v)+c.charAt(b));return g.join("")},o.decode=function(u){var d,m,f,h,p,v,b=0,g=0,x="data:";if(u.substr(0,x.length)===x)throw new Error("Invalid base64 input, it looks like a data url.");var w,j=3*(u=u.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(u.charAt(u.length-1)===c.charAt(64)&&j--,u.charAt(u.length-2)===c.charAt(64)&&j--,j%1!=0)throw new Error("Invalid base64 input, bad content length.");for(w=i.uint8array?new Uint8Array(0|j):new Array(0|j);b<u.length;)d=c.indexOf(u.charAt(b++))<<2|(h=c.indexOf(u.charAt(b++)))>>4,m=(15&h)<<4|(p=c.indexOf(u.charAt(b++)))>>2,f=(3&p)<<6|(v=c.indexOf(u.charAt(b++))),w[g++]=d,p!==64&&(w[g++]=m),v!==64&&(w[g++]=f);return w}},{"./support":30,"./utils":32}],2:[function(r,n,o){var l=r("./external"),i=r("./stream/DataWorker"),c=r("./stream/Crc32Probe"),u=r("./stream/DataLengthProbe");function d(m,f,h,p,v){this.compressedSize=m,this.uncompressedSize=f,this.crc32=h,this.compression=p,this.compressedContent=v}d.prototype={getContentWorker:function(){var m=new i(l.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new u("data_length")),f=this;return m.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),m},getCompressedWorker:function(){return new i(l.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},d.createWorkerFrom=function(m,f,h){return m.pipe(new c).pipe(new u("uncompressedSize")).pipe(f.compressWorker(h)).pipe(new u("compressedSize")).withStreamInfo("compression",f)},n.exports=d},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,n,o){var l=r("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new l("STORE compression")},uncompressWorker:function(){return new l("STORE decompression")}},o.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,n,o){var l=r("./utils"),i=(function(){for(var c,u=[],d=0;d<256;d++){c=d;for(var m=0;m<8;m++)c=1&c?3988292384^c>>>1:c>>>1;u[d]=c}return u})();n.exports=function(c,u){return c!==void 0&&c.length?l.getTypeOf(c)!=="string"?(function(d,m,f,h){var p=i,v=h+f;d^=-1;for(var b=h;b<v;b++)d=d>>>8^p[255&(d^m[b])];return-1^d})(0|u,c,c.length,0):(function(d,m,f,h){var p=i,v=h+f;d^=-1;for(var b=h;b<v;b++)d=d>>>8^p[255&(d^m.charCodeAt(b))];return-1^d})(0|u,c,c.length,0):0}},{"./utils":32}],5:[function(r,n,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(r,n,o){var l=null;l=typeof Promise<"u"?Promise:r("lie"),n.exports={Promise:l}},{lie:37}],7:[function(r,n,o){var l=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=r("pako"),c=r("./utils"),u=r("./stream/GenericWorker"),d=l?"uint8array":"array";function m(f,h){u.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=h,this.meta={}}o.magic="\b\0",c.inherits(m,u),m.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(c.transformTo(d,f.data),!1)},m.prototype.flush=function(){u.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},m.prototype.cleanUp=function(){u.prototype.cleanUp.call(this),this._pako=null},m.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(h){f.push({data:h,meta:f.meta})}},o.compressWorker=function(f){return new m("Deflate",f)},o.uncompressWorker=function(){return new m("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,o){function l(p,v){var b,g="";for(b=0;b<v;b++)g+=String.fromCharCode(255&p),p>>>=8;return g}function i(p,v,b,g,x,w){var j,k,y=p.file,C=p.compression,N=w!==d.utf8encode,M=c.transformTo("string",w(y.name)),$=c.transformTo("string",d.utf8encode(y.name)),T=y.comment,V=c.transformTo("string",w(T)),I=c.transformTo("string",d.utf8encode(T)),z=$.length!==y.name.length,O=I.length!==T.length,P="",Q="",te="",ne=y.dir,ae=y.date,W={crc32:0,compressedSize:0,uncompressedSize:0};v&&!b||(W.crc32=p.crc32,W.compressedSize=p.compressedSize,W.uncompressedSize=p.uncompressedSize);var A=0;v&&(A|=8),N||!z&&!O||(A|=2048);var F=0,Y=0;ne&&(F|=16),x==="UNIX"?(Y=798,F|=(function(ee,le){var ue=ee;return ee||(ue=le?16893:33204),(65535&ue)<<16})(y.unixPermissions,ne)):(Y=20,F|=(function(ee){return 63&(ee||0)})(y.dosPermissions)),j=ae.getUTCHours(),j<<=6,j|=ae.getUTCMinutes(),j<<=5,j|=ae.getUTCSeconds()/2,k=ae.getUTCFullYear()-1980,k<<=4,k|=ae.getUTCMonth()+1,k<<=5,k|=ae.getUTCDate(),z&&(Q=l(1,1)+l(m(M),4)+$,P+="up"+l(Q.length,2)+Q),O&&(te=l(1,1)+l(m(V),4)+I,P+="uc"+l(te.length,2)+te);var U="";return U+=`
206
- \0`,U+=l(A,2),U+=C.magic,U+=l(j,2),U+=l(k,2),U+=l(W.crc32,4),U+=l(W.compressedSize,4),U+=l(W.uncompressedSize,4),U+=l(M.length,2),U+=l(P.length,2),{fileRecord:f.LOCAL_FILE_HEADER+U+M+P,dirRecord:f.CENTRAL_FILE_HEADER+l(Y,2)+U+l(V.length,2)+"\0\0\0\0"+l(F,4)+l(g,4)+M+P+V}}var c=r("../utils"),u=r("../stream/GenericWorker"),d=r("../utf8"),m=r("../crc32"),f=r("../signature");function h(p,v,b,g){u.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=b,this.encodeFileName=g,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}c.inherits(h,u),h.prototype.push=function(p){var v=p.meta.percent||0,b=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,u.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:b?(v+100*(b-g-1))/b:100}}))},h.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var v=this.streamFiles&&!p.file.dir;if(v){var b=i(p,v,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:b.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(p){this.accumulate=!1;var v=this.streamFiles&&!p.file.dir,b=i(p,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(b.dirRecord),v)this.push({data:(function(g){return f.DATA_DESCRIPTOR+l(g.crc32,4)+l(g.compressedSize,4)+l(g.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:b.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var p=this.bytesWritten,v=0;v<this.dirRecords.length;v++)this.push({data:this.dirRecords[v],meta:{percent:100}});var b=this.bytesWritten-p,g=(function(x,w,j,k,y){var C=c.transformTo("string",y(k));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+l(x,2)+l(x,2)+l(w,4)+l(j,4)+l(C.length,2)+C})(this.dirRecords.length,b,p,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(p){this._sources.push(p);var v=this;return p.on("data",function(b){v.processChunk(b)}),p.on("end",function(){v.closedSource(v.previous.streamInfo),v._sources.length?v.prepareNextSource():v.end()}),p.on("error",function(b){v.error(b)}),this},h.prototype.resume=function(){return!!u.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},h.prototype.error=function(p){var v=this._sources;if(!u.prototype.error.call(this,p))return!1;for(var b=0;b<v.length;b++)try{v[b].error(p)}catch{}return!0},h.prototype.lock=function(){u.prototype.lock.call(this);for(var p=this._sources,v=0;v<p.length;v++)p[v].lock()},n.exports=h},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(r,n,o){var l=r("../compressions"),i=r("./ZipFileWorker");o.generateWorker=function(c,u,d){var m=new i(u.streamFiles,d,u.platform,u.encodeFileName),f=0;try{c.forEach(function(h,p){f++;var v=(function(w,j){var k=w||j,y=l[k];if(!y)throw new Error(k+" is not a valid compression method !");return y})(p.options.compression,u.compression),b=p.options.compressionOptions||u.compressionOptions||{},g=p.dir,x=p.date;p._compressWorker(v,b).withStreamInfo("file",{name:h,dir:g,date:x,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(m)}),m.entriesCount=f}catch(h){m.error(h)}return m}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(r,n,o){function l(){if(!(this instanceof l))return new l;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var i=new l;for(var c in this)typeof this[c]!="function"&&(i[c]=this[c]);return i}}(l.prototype=r("./object")).loadAsync=r("./load"),l.support=r("./support"),l.defaults=r("./defaults"),l.version="3.10.1",l.loadAsync=function(i,c){return new l().loadAsync(i,c)},l.external=r("./external"),n.exports=l},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(r,n,o){var l=r("./utils"),i=r("./external"),c=r("./utf8"),u=r("./zipEntries"),d=r("./stream/Crc32Probe"),m=r("./nodejsUtils");function f(h){return new i.Promise(function(p,v){var b=h.decompressed.getContentWorker().pipe(new d);b.on("error",function(g){v(g)}).on("end",function(){b.streamInfo.crc32!==h.decompressed.crc32?v(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}n.exports=function(h,p){var v=this;return p=l.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:c.utf8decode}),m.isNode&&m.isStream(h)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):l.prepareContent("the loaded zip file",h,!0,p.optimizedBinaryString,p.base64).then(function(b){var g=new u(p);return g.load(b),g}).then(function(b){var g=[i.Promise.resolve(b)],x=b.files;if(p.checkCRC32)for(var w=0;w<x.length;w++)g.push(f(x[w]));return i.Promise.all(g)}).then(function(b){for(var g=b.shift(),x=g.files,w=0;w<x.length;w++){var j=x[w],k=j.fileNameStr,y=l.resolve(j.fileNameStr);v.file(y,j.decompressed,{binary:!0,optimizedBinaryString:!0,date:j.date,dir:j.dir,comment:j.fileCommentStr.length?j.fileCommentStr:null,unixPermissions:j.unixPermissions,dosPermissions:j.dosPermissions,createFolders:p.createFolders}),j.dir||(v.file(y).unsafeOriginalName=k)}return g.zipComment.length&&(v.comment=g.zipComment),v})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(r,n,o){var l=r("../utils"),i=r("../stream/GenericWorker");function c(u,d){i.call(this,"Nodejs stream input adapter for "+u),this._upstreamEnded=!1,this._bindStream(d)}l.inherits(c,i),c.prototype._bindStream=function(u){var d=this;(this._stream=u).pause(),u.on("data",function(m){d.push({data:m,meta:{percent:0}})}).on("error",function(m){d.isPaused?this.generatedError=m:d.error(m)}).on("end",function(){d.isPaused?d._upstreamEnded=!0:d.end()})},c.prototype.pause=function(){return!!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},c.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},n.exports=c},{"../stream/GenericWorker":28,"../utils":32}],13:[function(r,n,o){var l=r("readable-stream").Readable;function i(c,u,d){l.call(this,u),this._helper=c;var m=this;c.on("data",function(f,h){m.push(f)||m._helper.pause(),d&&d(h)}).on("error",function(f){m.emit("error",f)}).on("end",function(){m.push(null)})}r("../utils").inherits(i,l),i.prototype._read=function(){this._helper.resume()},n.exports=i},{"../utils":32,"readable-stream":16}],14:[function(r,n,o){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(l,i){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(l,i);if(typeof l=="number")throw new Error('The "data" argument must not be a number');return new Buffer(l,i)},allocBuffer:function(l){if(Buffer.alloc)return Buffer.alloc(l);var i=new Buffer(l);return i.fill(0),i},isBuffer:function(l){return Buffer.isBuffer(l)},isStream:function(l){return l&&typeof l.on=="function"&&typeof l.pause=="function"&&typeof l.resume=="function"}}},{}],15:[function(r,n,o){function l(y,C,N){var M,$=c.getTypeOf(C),T=c.extend(N||{},m);T.date=T.date||new Date,T.compression!==null&&(T.compression=T.compression.toUpperCase()),typeof T.unixPermissions=="string"&&(T.unixPermissions=parseInt(T.unixPermissions,8)),T.unixPermissions&&16384&T.unixPermissions&&(T.dir=!0),T.dosPermissions&&16&T.dosPermissions&&(T.dir=!0),T.dir&&(y=x(y)),T.createFolders&&(M=g(y))&&w.call(this,M,!0);var V=$==="string"&&T.binary===!1&&T.base64===!1;N&&N.binary!==void 0||(T.binary=!V),(C instanceof f&&C.uncompressedSize===0||T.dir||!C||C.length===0)&&(T.base64=!1,T.binary=!0,C="",T.compression="STORE",$="string");var I=null;I=C instanceof f||C instanceof u?C:v.isNode&&v.isStream(C)?new b(y,C):c.prepareContent(y,C,T.binary,T.optimizedBinaryString,T.base64);var z=new h(y,I,T);this.files[y]=z}var i=r("./utf8"),c=r("./utils"),u=r("./stream/GenericWorker"),d=r("./stream/StreamHelper"),m=r("./defaults"),f=r("./compressedObject"),h=r("./zipObject"),p=r("./generate"),v=r("./nodejsUtils"),b=r("./nodejs/NodejsStreamInputAdapter"),g=function(y){y.slice(-1)==="/"&&(y=y.substring(0,y.length-1));var C=y.lastIndexOf("/");return 0<C?y.substring(0,C):""},x=function(y){return y.slice(-1)!=="/"&&(y+="/"),y},w=function(y,C){return C=C!==void 0?C:m.createFolders,y=x(y),this.files[y]||l.call(this,y,null,{dir:!0,createFolders:C}),this.files[y]};function j(y){return Object.prototype.toString.call(y)==="[object RegExp]"}var k={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(y){var C,N,M;for(C in this.files)M=this.files[C],(N=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&y(N,M)},filter:function(y){var C=[];return this.forEach(function(N,M){y(N,M)&&C.push(M)}),C},file:function(y,C,N){if(arguments.length!==1)return y=this.root+y,l.call(this,y,C,N),this;if(j(y)){var M=y;return this.filter(function(T,V){return!V.dir&&M.test(T)})}var $=this.files[this.root+y];return $&&!$.dir?$:null},folder:function(y){if(!y)return this;if(j(y))return this.filter(function($,T){return T.dir&&y.test($)});var C=this.root+y,N=w.call(this,C),M=this.clone();return M.root=N.name,M},remove:function(y){y=this.root+y;var C=this.files[y];if(C||(y.slice(-1)!=="/"&&(y+="/"),C=this.files[y]),C&&!C.dir)delete this.files[y];else for(var N=this.filter(function($,T){return T.name.slice(0,y.length)===y}),M=0;M<N.length;M++)delete this.files[N[M].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(y){var C,N={};try{if((N=c.extend(y||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.utf8encode})).type=N.type.toLowerCase(),N.compression=N.compression.toUpperCase(),N.type==="binarystring"&&(N.type="string"),!N.type)throw new Error("No output type specified.");c.checkSupport(N.type),N.platform!=="darwin"&&N.platform!=="freebsd"&&N.platform!=="linux"&&N.platform!=="sunos"||(N.platform="UNIX"),N.platform==="win32"&&(N.platform="DOS");var M=N.comment||this.comment||"";C=p.generateWorker(this,N,M)}catch($){(C=new u("error")).error($)}return new d(C,N.type||"string",N.mimeType)},generateAsync:function(y,C){return this.generateInternalStream(y).accumulate(C)},generateNodeStream:function(y,C){return(y=y||{}).type||(y.type="nodebuffer"),this.generateInternalStream(y).toNodejsStream(C)}};n.exports=k},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(r,n,o){n.exports=r("stream")},{stream:void 0}],17:[function(r,n,o){var l=r("./DataReader");function i(c){l.call(this,c);for(var u=0;u<this.data.length;u++)c[u]=255&c[u]}r("../utils").inherits(i,l),i.prototype.byteAt=function(c){return this.data[this.zero+c]},i.prototype.lastIndexOfSignature=function(c){for(var u=c.charCodeAt(0),d=c.charCodeAt(1),m=c.charCodeAt(2),f=c.charCodeAt(3),h=this.length-4;0<=h;--h)if(this.data[h]===u&&this.data[h+1]===d&&this.data[h+2]===m&&this.data[h+3]===f)return h-this.zero;return-1},i.prototype.readAndCheckSignature=function(c){var u=c.charCodeAt(0),d=c.charCodeAt(1),m=c.charCodeAt(2),f=c.charCodeAt(3),h=this.readData(4);return u===h[0]&&d===h[1]&&m===h[2]&&f===h[3]},i.prototype.readData=function(c){if(this.checkOffset(c),c===0)return[];var u=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,u},n.exports=i},{"../utils":32,"./DataReader":18}],18:[function(r,n,o){var l=r("../utils");function i(c){this.data=c,this.length=c.length,this.index=0,this.zero=0}i.prototype={checkOffset:function(c){this.checkIndex(this.index+c)},checkIndex:function(c){if(this.length<this.zero+c||c<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+c+"). Corrupted zip ?")},setIndex:function(c){this.checkIndex(c),this.index=c},skip:function(c){this.setIndex(this.index+c)},byteAt:function(){},readInt:function(c){var u,d=0;for(this.checkOffset(c),u=this.index+c-1;u>=this.index;u--)d=(d<<8)+this.byteAt(u);return this.index+=c,d},readString:function(c){return l.transformTo("string",this.readData(c))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var c=this.readInt(4);return new Date(Date.UTC(1980+(c>>25&127),(c>>21&15)-1,c>>16&31,c>>11&31,c>>5&63,(31&c)<<1))}},n.exports=i},{"../utils":32}],19:[function(r,n,o){var l=r("./Uint8ArrayReader");function i(c){l.call(this,c)}r("../utils").inherits(i,l),i.prototype.readData=function(c){this.checkOffset(c);var u=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,u},n.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,n,o){var l=r("./DataReader");function i(c){l.call(this,c)}r("../utils").inherits(i,l),i.prototype.byteAt=function(c){return this.data.charCodeAt(this.zero+c)},i.prototype.lastIndexOfSignature=function(c){return this.data.lastIndexOf(c)-this.zero},i.prototype.readAndCheckSignature=function(c){return c===this.readData(4)},i.prototype.readData=function(c){this.checkOffset(c);var u=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,u},n.exports=i},{"../utils":32,"./DataReader":18}],21:[function(r,n,o){var l=r("./ArrayReader");function i(c){l.call(this,c)}r("../utils").inherits(i,l),i.prototype.readData=function(c){if(this.checkOffset(c),c===0)return new Uint8Array(0);var u=this.data.subarray(this.zero+this.index,this.zero+this.index+c);return this.index+=c,u},n.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,o){var l=r("../utils"),i=r("../support"),c=r("./ArrayReader"),u=r("./StringReader"),d=r("./NodeBufferReader"),m=r("./Uint8ArrayReader");n.exports=function(f){var h=l.getTypeOf(f);return l.checkSupport(h),h!=="string"||i.uint8array?h==="nodebuffer"?new d(f):i.uint8array?new m(l.transformTo("uint8array",f)):new c(l.transformTo("array",f)):new u(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,n,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,n,o){var l=r("./GenericWorker"),i=r("../utils");function c(u){l.call(this,"ConvertWorker to "+u),this.destType=u}i.inherits(c,l),c.prototype.processChunk=function(u){this.push({data:i.transformTo(this.destType,u.data),meta:u.meta})},n.exports=c},{"../utils":32,"./GenericWorker":28}],25:[function(r,n,o){var l=r("./GenericWorker"),i=r("../crc32");function c(){l.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(c,l),c.prototype.processChunk=function(u){this.streamInfo.crc32=i(u.data,this.streamInfo.crc32||0),this.push(u)},n.exports=c},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,o){var l=r("../utils"),i=r("./GenericWorker");function c(u){i.call(this,"DataLengthProbe for "+u),this.propName=u,this.withStreamInfo(u,0)}l.inherits(c,i),c.prototype.processChunk=function(u){if(u){var d=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=d+u.data.length}i.prototype.processChunk.call(this,u)},n.exports=c},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,o){var l=r("../utils"),i=r("./GenericWorker");function c(u){i.call(this,"DataWorker");var d=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,u.then(function(m){d.dataIsReady=!0,d.data=m,d.max=m&&m.length||0,d.type=l.getTypeOf(m),d.isPaused||d._tickAndRepeat()},function(m){d.error(m)})}l.inherits(c,i),c.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},c.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,l.delay(this._tickAndRepeat,[],this)),!0)},c.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(l.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},c.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var u=null,d=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":u=this.data.substring(this.index,d);break;case"uint8array":u=this.data.subarray(this.index,d);break;case"array":case"nodebuffer":u=this.data.slice(this.index,d)}return this.index=d,this.push({data:u,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=c},{"../utils":32,"./GenericWorker":28}],28:[function(r,n,o){function l(i){this.name=i||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}l.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,c){return this._listeners[i].push(c),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,c){if(this._listeners[i])for(var u=0;u<this._listeners[i].length;u++)this._listeners[i][u].call(this,c)},pipe:function(i){return i.registerPrevious(this)},registerPrevious:function(i){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=i.streamInfo,this.mergeStreamInfo(),this.previous=i;var c=this;return i.on("data",function(u){c.processChunk(u)}),i.on("end",function(){c.end()}),i.on("error",function(u){c.error(u)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var i=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),i=!0),this.previous&&this.previous.resume(),!i},flush:function(){},processChunk:function(i){this.push(i)},withStreamInfo:function(i,c){return this.extraStreamInfo[i]=c,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var i in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,i)&&(this.streamInfo[i]=this.extraStreamInfo[i])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var i="Worker "+this.name;return this.previous?this.previous+" -> "+i:i}},n.exports=l},{}],29:[function(r,n,o){var l=r("../utils"),i=r("./ConvertWorker"),c=r("./GenericWorker"),u=r("../base64"),d=r("../support"),m=r("../external"),f=null;if(d.nodestream)try{f=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function h(v,b){return new m.Promise(function(g,x){var w=[],j=v._internalType,k=v._outputType,y=v._mimeType;v.on("data",function(C,N){w.push(C),b&&b(N)}).on("error",function(C){w=[],x(C)}).on("end",function(){try{var C=(function(N,M,$){switch(N){case"blob":return l.newBlob(l.transformTo("arraybuffer",M),$);case"base64":return u.encode(M);default:return l.transformTo(N,M)}})(k,(function(N,M){var $,T=0,V=null,I=0;for($=0;$<M.length;$++)I+=M[$].length;switch(N){case"string":return M.join("");case"array":return Array.prototype.concat.apply([],M);case"uint8array":for(V=new Uint8Array(I),$=0;$<M.length;$++)V.set(M[$],T),T+=M[$].length;return V;case"nodebuffer":return Buffer.concat(M);default:throw new Error("concat : unsupported type '"+N+"'")}})(j,w),y);g(C)}catch(N){x(N)}w=[]}).resume()})}function p(v,b,g){var x=b;switch(b){case"blob":case"arraybuffer":x="uint8array";break;case"base64":x="string"}try{this._internalType=x,this._outputType=b,this._mimeType=g,l.checkSupport(x),this._worker=v.pipe(new i(x)),v.lock()}catch(w){this._worker=new c("error"),this._worker.error(w)}}p.prototype={accumulate:function(v){return h(this,v)},on:function(v,b){var g=this;return v==="data"?this._worker.on(v,function(x){b.call(g,x.data,x.meta)}):this._worker.on(v,function(){l.delay(b,arguments,g)}),this},resume:function(){return l.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(v){if(l.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},v)}},n.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(r,n,o){if(o.base64=!0,o.array=!0,o.string=!0,o.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",o.nodebuffer=typeof Buffer<"u",o.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")o.blob=!1;else{var l=new ArrayBuffer(0);try{o.blob=new Blob([l],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(l),o.blob=i.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!r("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(r,n,o){for(var l=r("./utils"),i=r("./support"),c=r("./nodejsUtils"),u=r("./stream/GenericWorker"),d=new Array(256),m=0;m<256;m++)d[m]=252<=m?6:248<=m?5:240<=m?4:224<=m?3:192<=m?2:1;d[254]=d[254]=1;function f(){u.call(this,"utf-8 decode"),this.leftOver=null}function h(){u.call(this,"utf-8 encode")}o.utf8encode=function(p){return i.nodebuffer?c.newBufferFrom(p,"utf-8"):(function(v){var b,g,x,w,j,k=v.length,y=0;for(w=0;w<k;w++)(64512&(g=v.charCodeAt(w)))==55296&&w+1<k&&(64512&(x=v.charCodeAt(w+1)))==56320&&(g=65536+(g-55296<<10)+(x-56320),w++),y+=g<128?1:g<2048?2:g<65536?3:4;for(b=i.uint8array?new Uint8Array(y):new Array(y),w=j=0;j<y;w++)(64512&(g=v.charCodeAt(w)))==55296&&w+1<k&&(64512&(x=v.charCodeAt(w+1)))==56320&&(g=65536+(g-55296<<10)+(x-56320),w++),g<128?b[j++]=g:(g<2048?b[j++]=192|g>>>6:(g<65536?b[j++]=224|g>>>12:(b[j++]=240|g>>>18,b[j++]=128|g>>>12&63),b[j++]=128|g>>>6&63),b[j++]=128|63&g);return b})(p)},o.utf8decode=function(p){return i.nodebuffer?l.transformTo("nodebuffer",p).toString("utf-8"):(function(v){var b,g,x,w,j=v.length,k=new Array(2*j);for(b=g=0;b<j;)if((x=v[b++])<128)k[g++]=x;else if(4<(w=d[x]))k[g++]=65533,b+=w-1;else{for(x&=w===2?31:w===3?15:7;1<w&&b<j;)x=x<<6|63&v[b++],w--;1<w?k[g++]=65533:x<65536?k[g++]=x:(x-=65536,k[g++]=55296|x>>10&1023,k[g++]=56320|1023&x)}return k.length!==g&&(k.subarray?k=k.subarray(0,g):k.length=g),l.applyFromCharCode(k)})(p=l.transformTo(i.uint8array?"uint8array":"array",p))},l.inherits(f,u),f.prototype.processChunk=function(p){var v=l.transformTo(i.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var b=v;(v=new Uint8Array(b.length+this.leftOver.length)).set(this.leftOver,0),v.set(b,this.leftOver.length)}else v=this.leftOver.concat(v);this.leftOver=null}var g=(function(w,j){var k;for((j=j||w.length)>w.length&&(j=w.length),k=j-1;0<=k&&(192&w[k])==128;)k--;return k<0||k===0?j:k+d[w[k]]>j?k:j})(v),x=v;g!==v.length&&(i.uint8array?(x=v.subarray(0,g),this.leftOver=v.subarray(g,v.length)):(x=v.slice(0,g),this.leftOver=v.slice(g,v.length))),this.push({data:o.utf8decode(x),meta:p.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=f,l.inherits(h,u),h.prototype.processChunk=function(p){this.push({data:o.utf8encode(p.data),meta:p.meta})},o.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,n,o){var l=r("./support"),i=r("./base64"),c=r("./nodejsUtils"),u=r("./external");function d(b){return b}function m(b,g){for(var x=0;x<b.length;++x)g[x]=255&b.charCodeAt(x);return g}r("setimmediate"),o.newBlob=function(b,g){o.checkSupport("blob");try{return new Blob([b],{type:g})}catch{try{var x=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return x.append(b),x.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(b,g,x){var w=[],j=0,k=b.length;if(k<=x)return String.fromCharCode.apply(null,b);for(;j<k;)g==="array"||g==="nodebuffer"?w.push(String.fromCharCode.apply(null,b.slice(j,Math.min(j+x,k)))):w.push(String.fromCharCode.apply(null,b.subarray(j,Math.min(j+x,k)))),j+=x;return w.join("")},stringifyByChar:function(b){for(var g="",x=0;x<b.length;x++)g+=String.fromCharCode(b[x]);return g},applyCanBeUsed:{uint8array:(function(){try{return l.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return l.nodebuffer&&String.fromCharCode.apply(null,c.allocBuffer(1)).length===1}catch{return!1}})()}};function h(b){var g=65536,x=o.getTypeOf(b),w=!0;if(x==="uint8array"?w=f.applyCanBeUsed.uint8array:x==="nodebuffer"&&(w=f.applyCanBeUsed.nodebuffer),w)for(;1<g;)try{return f.stringifyByChunk(b,x,g)}catch{g=Math.floor(g/2)}return f.stringifyByChar(b)}function p(b,g){for(var x=0;x<b.length;x++)g[x]=b[x];return g}o.applyFromCharCode=h;var v={};v.string={string:d,array:function(b){return m(b,new Array(b.length))},arraybuffer:function(b){return v.string.uint8array(b).buffer},uint8array:function(b){return m(b,new Uint8Array(b.length))},nodebuffer:function(b){return m(b,c.allocBuffer(b.length))}},v.array={string:h,array:d,arraybuffer:function(b){return new Uint8Array(b).buffer},uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return c.newBufferFrom(b)}},v.arraybuffer={string:function(b){return h(new Uint8Array(b))},array:function(b){return p(new Uint8Array(b),new Array(b.byteLength))},arraybuffer:d,uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return c.newBufferFrom(new Uint8Array(b))}},v.uint8array={string:h,array:function(b){return p(b,new Array(b.length))},arraybuffer:function(b){return b.buffer},uint8array:d,nodebuffer:function(b){return c.newBufferFrom(b)}},v.nodebuffer={string:h,array:function(b){return p(b,new Array(b.length))},arraybuffer:function(b){return v.nodebuffer.uint8array(b).buffer},uint8array:function(b){return p(b,new Uint8Array(b.length))},nodebuffer:d},o.transformTo=function(b,g){if(g=g||"",!b)return g;o.checkSupport(b);var x=o.getTypeOf(g);return v[x][b](g)},o.resolve=function(b){for(var g=b.split("/"),x=[],w=0;w<g.length;w++){var j=g[w];j==="."||j===""&&w!==0&&w!==g.length-1||(j===".."?x.pop():x.push(j))}return x.join("/")},o.getTypeOf=function(b){return typeof b=="string"?"string":Object.prototype.toString.call(b)==="[object Array]"?"array":l.nodebuffer&&c.isBuffer(b)?"nodebuffer":l.uint8array&&b instanceof Uint8Array?"uint8array":l.arraybuffer&&b instanceof ArrayBuffer?"arraybuffer":void 0},o.checkSupport=function(b){if(!l[b.toLowerCase()])throw new Error(b+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(b){var g,x,w="";for(x=0;x<(b||"").length;x++)w+="\\x"+((g=b.charCodeAt(x))<16?"0":"")+g.toString(16).toUpperCase();return w},o.delay=function(b,g,x){setImmediate(function(){b.apply(x||null,g||[])})},o.inherits=function(b,g){function x(){}x.prototype=g.prototype,b.prototype=new x},o.extend=function(){var b,g,x={};for(b=0;b<arguments.length;b++)for(g in arguments[b])Object.prototype.hasOwnProperty.call(arguments[b],g)&&x[g]===void 0&&(x[g]=arguments[b][g]);return x},o.prepareContent=function(b,g,x,w,j){return u.Promise.resolve(g).then(function(k){return l.blob&&(k instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(k))!==-1)&&typeof FileReader<"u"?new u.Promise(function(y,C){var N=new FileReader;N.onload=function(M){y(M.target.result)},N.onerror=function(M){C(M.target.error)},N.readAsArrayBuffer(k)}):k}).then(function(k){var y=o.getTypeOf(k);return y?(y==="arraybuffer"?k=o.transformTo("uint8array",k):y==="string"&&(j?k=i.decode(k):x&&w!==!0&&(k=(function(C){return m(C,l.uint8array?new Uint8Array(C.length):new Array(C.length))})(k))),k):u.Promise.reject(new Error("Can't read the data of '"+b+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(r,n,o){var l=r("./reader/readerFor"),i=r("./utils"),c=r("./signature"),u=r("./zipEntry"),d=r("./support");function m(f){this.files=[],this.loadOptions=f}m.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(h)+", expected "+i.pretty(f)+")")}},isSignature:function(f,h){var p=this.reader.index;this.reader.setIndex(f);var v=this.reader.readString(4)===h;return this.reader.setIndex(p),v},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),h=d.uint8array?"uint8array":"array",p=i.transformTo(h,f);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,h,p,v=this.zip64EndOfCentralSize-44;0<v;)f=this.reader.readInt(2),h=this.reader.readInt(4),p=this.reader.readData(h),this.zip64ExtensibleData[f]={id:f,length:h,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,h;for(f=0;f<this.files.length;f++)h=this.files[f],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(c.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(c.CENTRAL_FILE_HEADER);)(f=new u({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(c.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,c.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var h=f;if(this.checkSignature(c.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,c.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(c.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(c.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var v=h-p;if(0<v)this.isSignature(h,c.CENTRAL_FILE_HEADER)||(this.reader.zero=v);else if(v<0)throw new Error("Corrupted zip: missing "+Math.abs(v)+" bytes.")},prepareReader:function(f){this.reader=l(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=m},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(r,n,o){var l=r("./reader/readerFor"),i=r("./utils"),c=r("./compressedObject"),u=r("./crc32"),d=r("./utf8"),m=r("./compressions"),f=r("./support");function h(p,v){this.options=p,this.loadOptions=v}h.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var v,b;if(p.skip(22),this.fileNameLength=p.readInt(2),b=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(b),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((v=(function(g){for(var x in m)if(Object.prototype.hasOwnProperty.call(m,x)&&m[x].magic===g)return m[x];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+i.pretty(this.compressionMethod)+" unknown (inner file : "+i.transformTo("string",this.fileName)+")");this.decompressed=new c(this.compressedSize,this.uncompressedSize,this.crc32,v,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var v=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(v),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=l(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var v,b,g,x=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<x;)v=p.readInt(2),b=p.readInt(2),g=p.readData(b),this.extraFields[v]={id:v,length:b,value:g};p.setIndex(x)},handleUTF8:function(){var p=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=d.utf8decode(this.fileName),this.fileCommentStr=d.utf8decode(this.fileComment);else{var v=this.findExtraFieldUnicodePath();if(v!==null)this.fileNameStr=v;else{var b=i.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(b)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var x=i.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(x)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var v=l(p.value);return v.readInt(1)!==1||u(this.fileName)!==v.readInt(4)?null:d.utf8decode(v.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var v=l(p.value);return v.readInt(1)!==1||u(this.fileComment)!==v.readInt(4)?null:d.utf8decode(v.readData(p.length-5))}return null}},n.exports=h},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(r,n,o){function l(v,b,g){this.name=v,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=b,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var i=r("./stream/StreamHelper"),c=r("./stream/DataWorker"),u=r("./utf8"),d=r("./compressedObject"),m=r("./stream/GenericWorker");l.prototype={internalStream:function(v){var b=null,g="string";try{if(!v)throw new Error("No output type specified.");var x=(g=v.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),b=this._decompressWorker();var w=!this._dataBinary;w&&!x&&(b=b.pipe(new u.Utf8EncodeWorker)),!w&&x&&(b=b.pipe(new u.Utf8DecodeWorker))}catch(j){(b=new m("error")).error(j)}return new i(b,g,"")},async:function(v,b){return this.internalStream(v).accumulate(b)},nodeStream:function(v,b){return this.internalStream(v||"nodebuffer").toNodejsStream(b)},_compressWorker:function(v,b){if(this._data instanceof d&&this._data.compression.magic===v.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new u.Utf8EncodeWorker)),d.createWorkerFrom(g,v,b)},_decompressWorker:function(){return this._data instanceof d?this._data.getContentWorker():this._data instanceof m?this._data:new c(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<f.length;p++)l.prototype[f[p]]=h;n.exports=l},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(r,n,o){(function(l){var i,c,u=l.MutationObserver||l.WebKitMutationObserver;if(u){var d=0,m=new u(v),f=l.document.createTextNode("");m.observe(f,{characterData:!0}),i=function(){f.data=d=++d%2}}else if(l.setImmediate||l.MessageChannel===void 0)i="document"in l&&"onreadystatechange"in l.document.createElement("script")?function(){var b=l.document.createElement("script");b.onreadystatechange=function(){v(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},l.document.documentElement.appendChild(b)}:function(){setTimeout(v,0)};else{var h=new l.MessageChannel;h.port1.onmessage=v,i=function(){h.port2.postMessage(0)}}var p=[];function v(){var b,g;c=!0;for(var x=p.length;x;){for(g=p,p=[],b=-1;++b<x;)g[b]();x=p.length}c=!1}n.exports=function(b){p.push(b)!==1||c||i()}}).call(this,typeof jr<"u"?jr:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(r,n,o){var l=r("immediate");function i(){}var c={},u=["REJECTED"],d=["FULFILLED"],m=["PENDING"];function f(x){if(typeof x!="function")throw new TypeError("resolver must be a function");this.state=m,this.queue=[],this.outcome=void 0,x!==i&&b(this,x)}function h(x,w,j){this.promise=x,typeof w=="function"&&(this.onFulfilled=w,this.callFulfilled=this.otherCallFulfilled),typeof j=="function"&&(this.onRejected=j,this.callRejected=this.otherCallRejected)}function p(x,w,j){l(function(){var k;try{k=w(j)}catch(y){return c.reject(x,y)}k===x?c.reject(x,new TypeError("Cannot resolve promise with itself")):c.resolve(x,k)})}function v(x){var w=x&&x.then;if(x&&(typeof x=="object"||typeof x=="function")&&typeof w=="function")return function(){w.apply(x,arguments)}}function b(x,w){var j=!1;function k(N){j||(j=!0,c.reject(x,N))}function y(N){j||(j=!0,c.resolve(x,N))}var C=g(function(){w(y,k)});C.status==="error"&&k(C.value)}function g(x,w){var j={};try{j.value=x(w),j.status="success"}catch(k){j.status="error",j.value=k}return j}(n.exports=f).prototype.finally=function(x){if(typeof x!="function")return this;var w=this.constructor;return this.then(function(j){return w.resolve(x()).then(function(){return j})},function(j){return w.resolve(x()).then(function(){throw j})})},f.prototype.catch=function(x){return this.then(null,x)},f.prototype.then=function(x,w){if(typeof x!="function"&&this.state===d||typeof w!="function"&&this.state===u)return this;var j=new this.constructor(i);return this.state!==m?p(j,this.state===d?x:w,this.outcome):this.queue.push(new h(j,x,w)),j},h.prototype.callFulfilled=function(x){c.resolve(this.promise,x)},h.prototype.otherCallFulfilled=function(x){p(this.promise,this.onFulfilled,x)},h.prototype.callRejected=function(x){c.reject(this.promise,x)},h.prototype.otherCallRejected=function(x){p(this.promise,this.onRejected,x)},c.resolve=function(x,w){var j=g(v,w);if(j.status==="error")return c.reject(x,j.value);var k=j.value;if(k)b(x,k);else{x.state=d,x.outcome=w;for(var y=-1,C=x.queue.length;++y<C;)x.queue[y].callFulfilled(w)}return x},c.reject=function(x,w){x.state=u,x.outcome=w;for(var j=-1,k=x.queue.length;++j<k;)x.queue[j].callRejected(w);return x},f.resolve=function(x){return x instanceof this?x:c.resolve(new this(i),x)},f.reject=function(x){var w=new this(i);return c.reject(w,x)},f.all=function(x){var w=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var j=x.length,k=!1;if(!j)return this.resolve([]);for(var y=new Array(j),C=0,N=-1,M=new this(i);++N<j;)$(x[N],N);return M;function $(T,V){w.resolve(T).then(function(I){y[V]=I,++C!==j||k||(k=!0,c.resolve(M,y))},function(I){k||(k=!0,c.reject(M,I))})}},f.race=function(x){var w=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var j=x.length,k=!1;if(!j)return this.resolve([]);for(var y=-1,C=new this(i);++y<j;)N=x[y],w.resolve(N).then(function(M){k||(k=!0,c.resolve(C,M))},function(M){k||(k=!0,c.reject(C,M))});var N;return C}},{immediate:36}],38:[function(r,n,o){var l={};(0,r("./lib/utils/common").assign)(l,r("./lib/deflate"),r("./lib/inflate"),r("./lib/zlib/constants")),n.exports=l},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(r,n,o){var l=r("./zlib/deflate"),i=r("./utils/common"),c=r("./utils/strings"),u=r("./zlib/messages"),d=r("./zlib/zstream"),m=Object.prototype.toString,f=0,h=-1,p=0,v=8;function b(x){if(!(this instanceof b))return new b(x);this.options=i.assign({level:h,method:v,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},x||{});var w=this.options;w.raw&&0<w.windowBits?w.windowBits=-w.windowBits:w.gzip&&0<w.windowBits&&w.windowBits<16&&(w.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var j=l.deflateInit2(this.strm,w.level,w.method,w.windowBits,w.memLevel,w.strategy);if(j!==f)throw new Error(u[j]);if(w.header&&l.deflateSetHeader(this.strm,w.header),w.dictionary){var k;if(k=typeof w.dictionary=="string"?c.string2buf(w.dictionary):m.call(w.dictionary)==="[object ArrayBuffer]"?new Uint8Array(w.dictionary):w.dictionary,(j=l.deflateSetDictionary(this.strm,k))!==f)throw new Error(u[j]);this._dict_set=!0}}function g(x,w){var j=new b(w);if(j.push(x,!0),j.err)throw j.msg||u[j.err];return j.result}b.prototype.push=function(x,w){var j,k,y=this.strm,C=this.options.chunkSize;if(this.ended)return!1;k=w===~~w?w:w===!0?4:0,typeof x=="string"?y.input=c.string2buf(x):m.call(x)==="[object ArrayBuffer]"?y.input=new Uint8Array(x):y.input=x,y.next_in=0,y.avail_in=y.input.length;do{if(y.avail_out===0&&(y.output=new i.Buf8(C),y.next_out=0,y.avail_out=C),(j=l.deflate(y,k))!==1&&j!==f)return this.onEnd(j),!(this.ended=!0);y.avail_out!==0&&(y.avail_in!==0||k!==4&&k!==2)||(this.options.to==="string"?this.onData(c.buf2binstring(i.shrinkBuf(y.output,y.next_out))):this.onData(i.shrinkBuf(y.output,y.next_out)))}while((0<y.avail_in||y.avail_out===0)&&j!==1);return k===4?(j=l.deflateEnd(this.strm),this.onEnd(j),this.ended=!0,j===f):k!==2||(this.onEnd(f),!(y.avail_out=0))},b.prototype.onData=function(x){this.chunks.push(x)},b.prototype.onEnd=function(x){x===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},o.Deflate=b,o.deflate=g,o.deflateRaw=function(x,w){return(w=w||{}).raw=!0,g(x,w)},o.gzip=function(x,w){return(w=w||{}).gzip=!0,g(x,w)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(r,n,o){var l=r("./zlib/inflate"),i=r("./utils/common"),c=r("./utils/strings"),u=r("./zlib/constants"),d=r("./zlib/messages"),m=r("./zlib/zstream"),f=r("./zlib/gzheader"),h=Object.prototype.toString;function p(b){if(!(this instanceof p))return new p(b);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},b||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||b&&b.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new m,this.strm.avail_out=0;var x=l.inflateInit2(this.strm,g.windowBits);if(x!==u.Z_OK)throw new Error(d[x]);this.header=new f,l.inflateGetHeader(this.strm,this.header)}function v(b,g){var x=new p(g);if(x.push(b,!0),x.err)throw x.msg||d[x.err];return x.result}p.prototype.push=function(b,g){var x,w,j,k,y,C,N=this.strm,M=this.options.chunkSize,$=this.options.dictionary,T=!1;if(this.ended)return!1;w=g===~~g?g:g===!0?u.Z_FINISH:u.Z_NO_FLUSH,typeof b=="string"?N.input=c.binstring2buf(b):h.call(b)==="[object ArrayBuffer]"?N.input=new Uint8Array(b):N.input=b,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new i.Buf8(M),N.next_out=0,N.avail_out=M),(x=l.inflate(N,u.Z_NO_FLUSH))===u.Z_NEED_DICT&&$&&(C=typeof $=="string"?c.string2buf($):h.call($)==="[object ArrayBuffer]"?new Uint8Array($):$,x=l.inflateSetDictionary(this.strm,C)),x===u.Z_BUF_ERROR&&T===!0&&(x=u.Z_OK,T=!1),x!==u.Z_STREAM_END&&x!==u.Z_OK)return this.onEnd(x),!(this.ended=!0);N.next_out&&(N.avail_out!==0&&x!==u.Z_STREAM_END&&(N.avail_in!==0||w!==u.Z_FINISH&&w!==u.Z_SYNC_FLUSH)||(this.options.to==="string"?(j=c.utf8border(N.output,N.next_out),k=N.next_out-j,y=c.buf2string(N.output,j),N.next_out=k,N.avail_out=M-k,k&&i.arraySet(N.output,N.output,j,k,0),this.onData(y)):this.onData(i.shrinkBuf(N.output,N.next_out)))),N.avail_in===0&&N.avail_out===0&&(T=!0)}while((0<N.avail_in||N.avail_out===0)&&x!==u.Z_STREAM_END);return x===u.Z_STREAM_END&&(w=u.Z_FINISH),w===u.Z_FINISH?(x=l.inflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===u.Z_OK):w!==u.Z_SYNC_FLUSH||(this.onEnd(u.Z_OK),!(N.avail_out=0))},p.prototype.onData=function(b){this.chunks.push(b)},p.prototype.onEnd=function(b){b===u.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},o.Inflate=p,o.inflate=v,o.inflateRaw=function(b,g){return(g=g||{}).raw=!0,v(b,g)},o.ungzip=v},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(r,n,o){var l=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";o.assign=function(u){for(var d=Array.prototype.slice.call(arguments,1);d.length;){var m=d.shift();if(m){if(typeof m!="object")throw new TypeError(m+"must be non-object");for(var f in m)m.hasOwnProperty(f)&&(u[f]=m[f])}}return u},o.shrinkBuf=function(u,d){return u.length===d?u:u.subarray?u.subarray(0,d):(u.length=d,u)};var i={arraySet:function(u,d,m,f,h){if(d.subarray&&u.subarray)u.set(d.subarray(m,m+f),h);else for(var p=0;p<f;p++)u[h+p]=d[m+p]},flattenChunks:function(u){var d,m,f,h,p,v;for(d=f=0,m=u.length;d<m;d++)f+=u[d].length;for(v=new Uint8Array(f),d=h=0,m=u.length;d<m;d++)p=u[d],v.set(p,h),h+=p.length;return v}},c={arraySet:function(u,d,m,f,h){for(var p=0;p<f;p++)u[h+p]=d[m+p]},flattenChunks:function(u){return[].concat.apply([],u)}};o.setTyped=function(u){u?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,i)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,c))},o.setTyped(l)},{}],42:[function(r,n,o){var l=r("./common"),i=!0,c=!0;try{String.fromCharCode.apply(null,[0])}catch{i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{c=!1}for(var u=new l.Buf8(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;function m(f,h){if(h<65537&&(f.subarray&&c||!f.subarray&&i))return String.fromCharCode.apply(null,l.shrinkBuf(f,h));for(var p="",v=0;v<h;v++)p+=String.fromCharCode(f[v]);return p}u[254]=u[254]=1,o.string2buf=function(f){var h,p,v,b,g,x=f.length,w=0;for(b=0;b<x;b++)(64512&(p=f.charCodeAt(b)))==55296&&b+1<x&&(64512&(v=f.charCodeAt(b+1)))==56320&&(p=65536+(p-55296<<10)+(v-56320),b++),w+=p<128?1:p<2048?2:p<65536?3:4;for(h=new l.Buf8(w),b=g=0;g<w;b++)(64512&(p=f.charCodeAt(b)))==55296&&b+1<x&&(64512&(v=f.charCodeAt(b+1)))==56320&&(p=65536+(p-55296<<10)+(v-56320),b++),p<128?h[g++]=p:(p<2048?h[g++]=192|p>>>6:(p<65536?h[g++]=224|p>>>12:(h[g++]=240|p>>>18,h[g++]=128|p>>>12&63),h[g++]=128|p>>>6&63),h[g++]=128|63&p);return h},o.buf2binstring=function(f){return m(f,f.length)},o.binstring2buf=function(f){for(var h=new l.Buf8(f.length),p=0,v=h.length;p<v;p++)h[p]=f.charCodeAt(p);return h},o.buf2string=function(f,h){var p,v,b,g,x=h||f.length,w=new Array(2*x);for(p=v=0;p<x;)if((b=f[p++])<128)w[v++]=b;else if(4<(g=u[b]))w[v++]=65533,p+=g-1;else{for(b&=g===2?31:g===3?15:7;1<g&&p<x;)b=b<<6|63&f[p++],g--;1<g?w[v++]=65533:b<65536?w[v++]=b:(b-=65536,w[v++]=55296|b>>10&1023,w[v++]=56320|1023&b)}return m(w,v)},o.utf8border=function(f,h){var p;for((h=h||f.length)>f.length&&(h=f.length),p=h-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?h:p+u[f[p]]>h?p:h}},{"./common":41}],43:[function(r,n,o){n.exports=function(l,i,c,u){for(var d=65535&l|0,m=l>>>16&65535|0,f=0;c!==0;){for(c-=f=2e3<c?2e3:c;m=m+(d=d+i[u++]|0)|0,--f;);d%=65521,m%=65521}return d|m<<16|0}},{}],44:[function(r,n,o){n.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(r,n,o){var l=(function(){for(var i,c=[],u=0;u<256;u++){i=u;for(var d=0;d<8;d++)i=1&i?3988292384^i>>>1:i>>>1;c[u]=i}return c})();n.exports=function(i,c,u,d){var m=l,f=d+u;i^=-1;for(var h=d;h<f;h++)i=i>>>8^m[255&(i^c[h])];return-1^i}},{}],46:[function(r,n,o){var l,i=r("../utils/common"),c=r("./trees"),u=r("./adler32"),d=r("./crc32"),m=r("./messages"),f=0,h=4,p=0,v=-2,b=-1,g=4,x=2,w=8,j=9,k=286,y=30,C=19,N=2*k+1,M=15,$=3,T=258,V=T+$+1,I=42,z=113,O=1,P=2,Q=3,te=4;function ne(R,J){return R.msg=m[J],J}function ae(R){return(R<<1)-(4<R?9:0)}function W(R){for(var J=R.length;0<=--J;)R[J]=0}function A(R){var J=R.state,H=J.pending;H>R.avail_out&&(H=R.avail_out),H!==0&&(i.arraySet(R.output,J.pending_buf,J.pending_out,H,R.next_out),R.next_out+=H,J.pending_out+=H,R.total_out+=H,R.avail_out-=H,J.pending-=H,J.pending===0&&(J.pending_out=0))}function F(R,J){c._tr_flush_block(R,0<=R.block_start?R.block_start:-1,R.strstart-R.block_start,J),R.block_start=R.strstart,A(R.strm)}function Y(R,J){R.pending_buf[R.pending++]=J}function U(R,J){R.pending_buf[R.pending++]=J>>>8&255,R.pending_buf[R.pending++]=255&J}function ee(R,J){var H,L,S=R.max_chain_length,D=R.strstart,_=R.prev_length,Z=R.nice_match,B=R.strstart>R.w_size-V?R.strstart-(R.w_size-V):0,q=R.window,X=R.w_mask,G=R.prev,K=R.strstart+T,re=q[D+_-1],ie=q[D+_];R.prev_length>=R.good_match&&(S>>=2),Z>R.lookahead&&(Z=R.lookahead);do if(q[(H=J)+_]===ie&&q[H+_-1]===re&&q[H]===q[D]&&q[++H]===q[D+1]){D+=2,H++;do;while(q[++D]===q[++H]&&q[++D]===q[++H]&&q[++D]===q[++H]&&q[++D]===q[++H]&&q[++D]===q[++H]&&q[++D]===q[++H]&&q[++D]===q[++H]&&q[++D]===q[++H]&&D<K);if(L=T-(K-D),D=K-T,_<L){if(R.match_start=J,Z<=(_=L))break;re=q[D+_-1],ie=q[D+_]}}while((J=G[J&X])>B&&--S!=0);return _<=R.lookahead?_:R.lookahead}function le(R){var J,H,L,S,D,_,Z,B,q,X,G=R.w_size;do{if(S=R.window_size-R.lookahead-R.strstart,R.strstart>=G+(G-V)){for(i.arraySet(R.window,R.window,G,G,0),R.match_start-=G,R.strstart-=G,R.block_start-=G,J=H=R.hash_size;L=R.head[--J],R.head[J]=G<=L?L-G:0,--H;);for(J=H=G;L=R.prev[--J],R.prev[J]=G<=L?L-G:0,--H;);S+=G}if(R.strm.avail_in===0)break;if(_=R.strm,Z=R.window,B=R.strstart+R.lookahead,q=S,X=void 0,X=_.avail_in,q<X&&(X=q),H=X===0?0:(_.avail_in-=X,i.arraySet(Z,_.input,_.next_in,X,B),_.state.wrap===1?_.adler=u(_.adler,Z,X,B):_.state.wrap===2&&(_.adler=d(_.adler,Z,X,B)),_.next_in+=X,_.total_in+=X,X),R.lookahead+=H,R.lookahead+R.insert>=$)for(D=R.strstart-R.insert,R.ins_h=R.window[D],R.ins_h=(R.ins_h<<R.hash_shift^R.window[D+1])&R.hash_mask;R.insert&&(R.ins_h=(R.ins_h<<R.hash_shift^R.window[D+$-1])&R.hash_mask,R.prev[D&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=D,D++,R.insert--,!(R.lookahead+R.insert<$)););}while(R.lookahead<V&&R.strm.avail_in!==0)}function ue(R,J){for(var H,L;;){if(R.lookahead<V){if(le(R),R.lookahead<V&&J===f)return O;if(R.lookahead===0)break}if(H=0,R.lookahead>=$&&(R.ins_h=(R.ins_h<<R.hash_shift^R.window[R.strstart+$-1])&R.hash_mask,H=R.prev[R.strstart&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=R.strstart),H!==0&&R.strstart-H<=R.w_size-V&&(R.match_length=ee(R,H)),R.match_length>=$)if(L=c._tr_tally(R,R.strstart-R.match_start,R.match_length-$),R.lookahead-=R.match_length,R.match_length<=R.max_lazy_match&&R.lookahead>=$){for(R.match_length--;R.strstart++,R.ins_h=(R.ins_h<<R.hash_shift^R.window[R.strstart+$-1])&R.hash_mask,H=R.prev[R.strstart&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=R.strstart,--R.match_length!=0;);R.strstart++}else R.strstart+=R.match_length,R.match_length=0,R.ins_h=R.window[R.strstart],R.ins_h=(R.ins_h<<R.hash_shift^R.window[R.strstart+1])&R.hash_mask;else L=c._tr_tally(R,0,R.window[R.strstart]),R.lookahead--,R.strstart++;if(L&&(F(R,!1),R.strm.avail_out===0))return O}return R.insert=R.strstart<$-1?R.strstart:$-1,J===h?(F(R,!0),R.strm.avail_out===0?Q:te):R.last_lit&&(F(R,!1),R.strm.avail_out===0)?O:P}function ge(R,J){for(var H,L,S;;){if(R.lookahead<V){if(le(R),R.lookahead<V&&J===f)return O;if(R.lookahead===0)break}if(H=0,R.lookahead>=$&&(R.ins_h=(R.ins_h<<R.hash_shift^R.window[R.strstart+$-1])&R.hash_mask,H=R.prev[R.strstart&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=R.strstart),R.prev_length=R.match_length,R.prev_match=R.match_start,R.match_length=$-1,H!==0&&R.prev_length<R.max_lazy_match&&R.strstart-H<=R.w_size-V&&(R.match_length=ee(R,H),R.match_length<=5&&(R.strategy===1||R.match_length===$&&4096<R.strstart-R.match_start)&&(R.match_length=$-1)),R.prev_length>=$&&R.match_length<=R.prev_length){for(S=R.strstart+R.lookahead-$,L=c._tr_tally(R,R.strstart-1-R.prev_match,R.prev_length-$),R.lookahead-=R.prev_length-1,R.prev_length-=2;++R.strstart<=S&&(R.ins_h=(R.ins_h<<R.hash_shift^R.window[R.strstart+$-1])&R.hash_mask,H=R.prev[R.strstart&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=R.strstart),--R.prev_length!=0;);if(R.match_available=0,R.match_length=$-1,R.strstart++,L&&(F(R,!1),R.strm.avail_out===0))return O}else if(R.match_available){if((L=c._tr_tally(R,0,R.window[R.strstart-1]))&&F(R,!1),R.strstart++,R.lookahead--,R.strm.avail_out===0)return O}else R.match_available=1,R.strstart++,R.lookahead--}return R.match_available&&(L=c._tr_tally(R,0,R.window[R.strstart-1]),R.match_available=0),R.insert=R.strstart<$-1?R.strstart:$-1,J===h?(F(R,!0),R.strm.avail_out===0?Q:te):R.last_lit&&(F(R,!1),R.strm.avail_out===0)?O:P}function ce(R,J,H,L,S){this.good_length=R,this.max_lazy=J,this.nice_length=H,this.max_chain=L,this.func=S}function se(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=w,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(2*N),this.dyn_dtree=new i.Buf16(2*(2*y+1)),this.bl_tree=new i.Buf16(2*(2*C+1)),W(this.dyn_ltree),W(this.dyn_dtree),W(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(M+1),this.heap=new i.Buf16(2*k+1),W(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(2*k+1),W(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function we(R){var J;return R&&R.state?(R.total_in=R.total_out=0,R.data_type=x,(J=R.state).pending=0,J.pending_out=0,J.wrap<0&&(J.wrap=-J.wrap),J.status=J.wrap?I:z,R.adler=J.wrap===2?0:1,J.last_flush=f,c._tr_init(J),p):ne(R,v)}function de(R){var J=we(R);return J===p&&(function(H){H.window_size=2*H.w_size,W(H.head),H.max_lazy_match=l[H.level].max_lazy,H.good_match=l[H.level].good_length,H.nice_match=l[H.level].nice_length,H.max_chain_length=l[H.level].max_chain,H.strstart=0,H.block_start=0,H.lookahead=0,H.insert=0,H.match_length=H.prev_length=$-1,H.match_available=0,H.ins_h=0})(R.state),J}function me(R,J,H,L,S,D){if(!R)return v;var _=1;if(J===b&&(J=6),L<0?(_=0,L=-L):15<L&&(_=2,L-=16),S<1||j<S||H!==w||L<8||15<L||J<0||9<J||D<0||g<D)return ne(R,v);L===8&&(L=9);var Z=new se;return(R.state=Z).strm=R,Z.wrap=_,Z.gzhead=null,Z.w_bits=L,Z.w_size=1<<Z.w_bits,Z.w_mask=Z.w_size-1,Z.hash_bits=S+7,Z.hash_size=1<<Z.hash_bits,Z.hash_mask=Z.hash_size-1,Z.hash_shift=~~((Z.hash_bits+$-1)/$),Z.window=new i.Buf8(2*Z.w_size),Z.head=new i.Buf16(Z.hash_size),Z.prev=new i.Buf16(Z.w_size),Z.lit_bufsize=1<<S+6,Z.pending_buf_size=4*Z.lit_bufsize,Z.pending_buf=new i.Buf8(Z.pending_buf_size),Z.d_buf=1*Z.lit_bufsize,Z.l_buf=3*Z.lit_bufsize,Z.level=J,Z.strategy=D,Z.method=H,de(R)}l=[new ce(0,0,0,0,function(R,J){var H=65535;for(H>R.pending_buf_size-5&&(H=R.pending_buf_size-5);;){if(R.lookahead<=1){if(le(R),R.lookahead===0&&J===f)return O;if(R.lookahead===0)break}R.strstart+=R.lookahead,R.lookahead=0;var L=R.block_start+H;if((R.strstart===0||R.strstart>=L)&&(R.lookahead=R.strstart-L,R.strstart=L,F(R,!1),R.strm.avail_out===0)||R.strstart-R.block_start>=R.w_size-V&&(F(R,!1),R.strm.avail_out===0))return O}return R.insert=0,J===h?(F(R,!0),R.strm.avail_out===0?Q:te):(R.strstart>R.block_start&&(F(R,!1),R.strm.avail_out),O)}),new ce(4,4,8,4,ue),new ce(4,5,16,8,ue),new ce(4,6,32,32,ue),new ce(4,4,16,16,ge),new ce(8,16,32,32,ge),new ce(8,16,128,128,ge),new ce(8,32,128,256,ge),new ce(32,128,258,1024,ge),new ce(32,258,258,4096,ge)],o.deflateInit=function(R,J){return me(R,J,w,15,8,0)},o.deflateInit2=me,o.deflateReset=de,o.deflateResetKeep=we,o.deflateSetHeader=function(R,J){return R&&R.state?R.state.wrap!==2?v:(R.state.gzhead=J,p):v},o.deflate=function(R,J){var H,L,S,D;if(!R||!R.state||5<J||J<0)return R?ne(R,v):v;if(L=R.state,!R.output||!R.input&&R.avail_in!==0||L.status===666&&J!==h)return ne(R,R.avail_out===0?-5:v);if(L.strm=R,H=L.last_flush,L.last_flush=J,L.status===I)if(L.wrap===2)R.adler=0,Y(L,31),Y(L,139),Y(L,8),L.gzhead?(Y(L,(L.gzhead.text?1:0)+(L.gzhead.hcrc?2:0)+(L.gzhead.extra?4:0)+(L.gzhead.name?8:0)+(L.gzhead.comment?16:0)),Y(L,255&L.gzhead.time),Y(L,L.gzhead.time>>8&255),Y(L,L.gzhead.time>>16&255),Y(L,L.gzhead.time>>24&255),Y(L,L.level===9?2:2<=L.strategy||L.level<2?4:0),Y(L,255&L.gzhead.os),L.gzhead.extra&&L.gzhead.extra.length&&(Y(L,255&L.gzhead.extra.length),Y(L,L.gzhead.extra.length>>8&255)),L.gzhead.hcrc&&(R.adler=d(R.adler,L.pending_buf,L.pending,0)),L.gzindex=0,L.status=69):(Y(L,0),Y(L,0),Y(L,0),Y(L,0),Y(L,0),Y(L,L.level===9?2:2<=L.strategy||L.level<2?4:0),Y(L,3),L.status=z);else{var _=w+(L.w_bits-8<<4)<<8;_|=(2<=L.strategy||L.level<2?0:L.level<6?1:L.level===6?2:3)<<6,L.strstart!==0&&(_|=32),_+=31-_%31,L.status=z,U(L,_),L.strstart!==0&&(U(L,R.adler>>>16),U(L,65535&R.adler)),R.adler=1}if(L.status===69)if(L.gzhead.extra){for(S=L.pending;L.gzindex<(65535&L.gzhead.extra.length)&&(L.pending!==L.pending_buf_size||(L.gzhead.hcrc&&L.pending>S&&(R.adler=d(R.adler,L.pending_buf,L.pending-S,S)),A(R),S=L.pending,L.pending!==L.pending_buf_size));)Y(L,255&L.gzhead.extra[L.gzindex]),L.gzindex++;L.gzhead.hcrc&&L.pending>S&&(R.adler=d(R.adler,L.pending_buf,L.pending-S,S)),L.gzindex===L.gzhead.extra.length&&(L.gzindex=0,L.status=73)}else L.status=73;if(L.status===73)if(L.gzhead.name){S=L.pending;do{if(L.pending===L.pending_buf_size&&(L.gzhead.hcrc&&L.pending>S&&(R.adler=d(R.adler,L.pending_buf,L.pending-S,S)),A(R),S=L.pending,L.pending===L.pending_buf_size)){D=1;break}D=L.gzindex<L.gzhead.name.length?255&L.gzhead.name.charCodeAt(L.gzindex++):0,Y(L,D)}while(D!==0);L.gzhead.hcrc&&L.pending>S&&(R.adler=d(R.adler,L.pending_buf,L.pending-S,S)),D===0&&(L.gzindex=0,L.status=91)}else L.status=91;if(L.status===91)if(L.gzhead.comment){S=L.pending;do{if(L.pending===L.pending_buf_size&&(L.gzhead.hcrc&&L.pending>S&&(R.adler=d(R.adler,L.pending_buf,L.pending-S,S)),A(R),S=L.pending,L.pending===L.pending_buf_size)){D=1;break}D=L.gzindex<L.gzhead.comment.length?255&L.gzhead.comment.charCodeAt(L.gzindex++):0,Y(L,D)}while(D!==0);L.gzhead.hcrc&&L.pending>S&&(R.adler=d(R.adler,L.pending_buf,L.pending-S,S)),D===0&&(L.status=103)}else L.status=103;if(L.status===103&&(L.gzhead.hcrc?(L.pending+2>L.pending_buf_size&&A(R),L.pending+2<=L.pending_buf_size&&(Y(L,255&R.adler),Y(L,R.adler>>8&255),R.adler=0,L.status=z)):L.status=z),L.pending!==0){if(A(R),R.avail_out===0)return L.last_flush=-1,p}else if(R.avail_in===0&&ae(J)<=ae(H)&&J!==h)return ne(R,-5);if(L.status===666&&R.avail_in!==0)return ne(R,-5);if(R.avail_in!==0||L.lookahead!==0||J!==f&&L.status!==666){var Z=L.strategy===2?(function(B,q){for(var X;;){if(B.lookahead===0&&(le(B),B.lookahead===0)){if(q===f)return O;break}if(B.match_length=0,X=c._tr_tally(B,0,B.window[B.strstart]),B.lookahead--,B.strstart++,X&&(F(B,!1),B.strm.avail_out===0))return O}return B.insert=0,q===h?(F(B,!0),B.strm.avail_out===0?Q:te):B.last_lit&&(F(B,!1),B.strm.avail_out===0)?O:P})(L,J):L.strategy===3?(function(B,q){for(var X,G,K,re,ie=B.window;;){if(B.lookahead<=T){if(le(B),B.lookahead<=T&&q===f)return O;if(B.lookahead===0)break}if(B.match_length=0,B.lookahead>=$&&0<B.strstart&&(G=ie[K=B.strstart-1])===ie[++K]&&G===ie[++K]&&G===ie[++K]){re=B.strstart+T;do;while(G===ie[++K]&&G===ie[++K]&&G===ie[++K]&&G===ie[++K]&&G===ie[++K]&&G===ie[++K]&&G===ie[++K]&&G===ie[++K]&&K<re);B.match_length=T-(re-K),B.match_length>B.lookahead&&(B.match_length=B.lookahead)}if(B.match_length>=$?(X=c._tr_tally(B,1,B.match_length-$),B.lookahead-=B.match_length,B.strstart+=B.match_length,B.match_length=0):(X=c._tr_tally(B,0,B.window[B.strstart]),B.lookahead--,B.strstart++),X&&(F(B,!1),B.strm.avail_out===0))return O}return B.insert=0,q===h?(F(B,!0),B.strm.avail_out===0?Q:te):B.last_lit&&(F(B,!1),B.strm.avail_out===0)?O:P})(L,J):l[L.level].func(L,J);if(Z!==Q&&Z!==te||(L.status=666),Z===O||Z===Q)return R.avail_out===0&&(L.last_flush=-1),p;if(Z===P&&(J===1?c._tr_align(L):J!==5&&(c._tr_stored_block(L,0,0,!1),J===3&&(W(L.head),L.lookahead===0&&(L.strstart=0,L.block_start=0,L.insert=0))),A(R),R.avail_out===0))return L.last_flush=-1,p}return J!==h?p:L.wrap<=0?1:(L.wrap===2?(Y(L,255&R.adler),Y(L,R.adler>>8&255),Y(L,R.adler>>16&255),Y(L,R.adler>>24&255),Y(L,255&R.total_in),Y(L,R.total_in>>8&255),Y(L,R.total_in>>16&255),Y(L,R.total_in>>24&255)):(U(L,R.adler>>>16),U(L,65535&R.adler)),A(R),0<L.wrap&&(L.wrap=-L.wrap),L.pending!==0?p:1)},o.deflateEnd=function(R){var J;return R&&R.state?(J=R.state.status)!==I&&J!==69&&J!==73&&J!==91&&J!==103&&J!==z&&J!==666?ne(R,v):(R.state=null,J===z?ne(R,-3):p):v},o.deflateSetDictionary=function(R,J){var H,L,S,D,_,Z,B,q,X=J.length;if(!R||!R.state||(D=(H=R.state).wrap)===2||D===1&&H.status!==I||H.lookahead)return v;for(D===1&&(R.adler=u(R.adler,J,X,0)),H.wrap=0,X>=H.w_size&&(D===0&&(W(H.head),H.strstart=0,H.block_start=0,H.insert=0),q=new i.Buf8(H.w_size),i.arraySet(q,J,X-H.w_size,H.w_size,0),J=q,X=H.w_size),_=R.avail_in,Z=R.next_in,B=R.input,R.avail_in=X,R.next_in=0,R.input=J,le(H);H.lookahead>=$;){for(L=H.strstart,S=H.lookahead-($-1);H.ins_h=(H.ins_h<<H.hash_shift^H.window[L+$-1])&H.hash_mask,H.prev[L&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=L,L++,--S;);H.strstart=L,H.lookahead=$-1,le(H)}return H.strstart+=H.lookahead,H.block_start=H.strstart,H.insert=H.lookahead,H.lookahead=0,H.match_length=H.prev_length=$-1,H.match_available=0,R.next_in=Z,R.input=B,R.avail_in=_,H.wrap=D,p},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(r,n,o){n.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(r,n,o){n.exports=function(l,i){var c,u,d,m,f,h,p,v,b,g,x,w,j,k,y,C,N,M,$,T,V,I,z,O,P;c=l.state,u=l.next_in,O=l.input,d=u+(l.avail_in-5),m=l.next_out,P=l.output,f=m-(i-l.avail_out),h=m+(l.avail_out-257),p=c.dmax,v=c.wsize,b=c.whave,g=c.wnext,x=c.window,w=c.hold,j=c.bits,k=c.lencode,y=c.distcode,C=(1<<c.lenbits)-1,N=(1<<c.distbits)-1;e:do{j<15&&(w+=O[u++]<<j,j+=8,w+=O[u++]<<j,j+=8),M=k[w&C];t:for(;;){if(w>>>=$=M>>>24,j-=$,($=M>>>16&255)===0)P[m++]=65535&M;else{if(!(16&$)){if((64&$)==0){M=k[(65535&M)+(w&(1<<$)-1)];continue t}if(32&$){c.mode=12;break e}l.msg="invalid literal/length code",c.mode=30;break e}T=65535&M,($&=15)&&(j<$&&(w+=O[u++]<<j,j+=8),T+=w&(1<<$)-1,w>>>=$,j-=$),j<15&&(w+=O[u++]<<j,j+=8,w+=O[u++]<<j,j+=8),M=y[w&N];r:for(;;){if(w>>>=$=M>>>24,j-=$,!(16&($=M>>>16&255))){if((64&$)==0){M=y[(65535&M)+(w&(1<<$)-1)];continue r}l.msg="invalid distance code",c.mode=30;break e}if(V=65535&M,j<($&=15)&&(w+=O[u++]<<j,(j+=8)<$&&(w+=O[u++]<<j,j+=8)),p<(V+=w&(1<<$)-1)){l.msg="invalid distance too far back",c.mode=30;break e}if(w>>>=$,j-=$,($=m-f)<V){if(b<($=V-$)&&c.sane){l.msg="invalid distance too far back",c.mode=30;break e}if(z=x,(I=0)===g){if(I+=v-$,$<T){for(T-=$;P[m++]=x[I++],--$;);I=m-V,z=P}}else if(g<$){if(I+=v+g-$,($-=g)<T){for(T-=$;P[m++]=x[I++],--$;);if(I=0,g<T){for(T-=$=g;P[m++]=x[I++],--$;);I=m-V,z=P}}}else if(I+=g-$,$<T){for(T-=$;P[m++]=x[I++],--$;);I=m-V,z=P}for(;2<T;)P[m++]=z[I++],P[m++]=z[I++],P[m++]=z[I++],T-=3;T&&(P[m++]=z[I++],1<T&&(P[m++]=z[I++]))}else{for(I=m-V;P[m++]=P[I++],P[m++]=P[I++],P[m++]=P[I++],2<(T-=3););T&&(P[m++]=P[I++],1<T&&(P[m++]=P[I++]))}break}}break}}while(u<d&&m<h);u-=T=j>>3,w&=(1<<(j-=T<<3))-1,l.next_in=u,l.next_out=m,l.avail_in=u<d?d-u+5:5-(u-d),l.avail_out=m<h?h-m+257:257-(m-h),c.hold=w,c.bits=j}},{}],49:[function(r,n,o){var l=r("../utils/common"),i=r("./adler32"),c=r("./crc32"),u=r("./inffast"),d=r("./inftrees"),m=1,f=2,h=0,p=-2,v=1,b=852,g=592;function x(I){return(I>>>24&255)+(I>>>8&65280)+((65280&I)<<8)+((255&I)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new l.Buf16(320),this.work=new l.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function j(I){var z;return I&&I.state?(z=I.state,I.total_in=I.total_out=z.total=0,I.msg="",z.wrap&&(I.adler=1&z.wrap),z.mode=v,z.last=0,z.havedict=0,z.dmax=32768,z.head=null,z.hold=0,z.bits=0,z.lencode=z.lendyn=new l.Buf32(b),z.distcode=z.distdyn=new l.Buf32(g),z.sane=1,z.back=-1,h):p}function k(I){var z;return I&&I.state?((z=I.state).wsize=0,z.whave=0,z.wnext=0,j(I)):p}function y(I,z){var O,P;return I&&I.state?(P=I.state,z<0?(O=0,z=-z):(O=1+(z>>4),z<48&&(z&=15)),z&&(z<8||15<z)?p:(P.window!==null&&P.wbits!==z&&(P.window=null),P.wrap=O,P.wbits=z,k(I))):p}function C(I,z){var O,P;return I?(P=new w,(I.state=P).window=null,(O=y(I,z))!==h&&(I.state=null),O):p}var N,M,$=!0;function T(I){if($){var z;for(N=new l.Buf32(512),M=new l.Buf32(32),z=0;z<144;)I.lens[z++]=8;for(;z<256;)I.lens[z++]=9;for(;z<280;)I.lens[z++]=7;for(;z<288;)I.lens[z++]=8;for(d(m,I.lens,0,288,N,0,I.work,{bits:9}),z=0;z<32;)I.lens[z++]=5;d(f,I.lens,0,32,M,0,I.work,{bits:5}),$=!1}I.lencode=N,I.lenbits=9,I.distcode=M,I.distbits=5}function V(I,z,O,P){var Q,te=I.state;return te.window===null&&(te.wsize=1<<te.wbits,te.wnext=0,te.whave=0,te.window=new l.Buf8(te.wsize)),P>=te.wsize?(l.arraySet(te.window,z,O-te.wsize,te.wsize,0),te.wnext=0,te.whave=te.wsize):(P<(Q=te.wsize-te.wnext)&&(Q=P),l.arraySet(te.window,z,O-P,Q,te.wnext),(P-=Q)?(l.arraySet(te.window,z,O-P,P,0),te.wnext=P,te.whave=te.wsize):(te.wnext+=Q,te.wnext===te.wsize&&(te.wnext=0),te.whave<te.wsize&&(te.whave+=Q))),0}o.inflateReset=k,o.inflateReset2=y,o.inflateResetKeep=j,o.inflateInit=function(I){return C(I,15)},o.inflateInit2=C,o.inflate=function(I,z){var O,P,Q,te,ne,ae,W,A,F,Y,U,ee,le,ue,ge,ce,se,we,de,me,R,J,H,L,S=0,D=new l.Buf8(4),_=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!I||!I.state||!I.output||!I.input&&I.avail_in!==0)return p;(O=I.state).mode===12&&(O.mode=13),ne=I.next_out,Q=I.output,W=I.avail_out,te=I.next_in,P=I.input,ae=I.avail_in,A=O.hold,F=O.bits,Y=ae,U=W,J=h;e:for(;;)switch(O.mode){case v:if(O.wrap===0){O.mode=13;break}for(;F<16;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(2&O.wrap&&A===35615){D[O.check=0]=255&A,D[1]=A>>>8&255,O.check=c(O.check,D,2,0),F=A=0,O.mode=2;break}if(O.flags=0,O.head&&(O.head.done=!1),!(1&O.wrap)||(((255&A)<<8)+(A>>8))%31){I.msg="incorrect header check",O.mode=30;break}if((15&A)!=8){I.msg="unknown compression method",O.mode=30;break}if(F-=4,R=8+(15&(A>>>=4)),O.wbits===0)O.wbits=R;else if(R>O.wbits){I.msg="invalid window size",O.mode=30;break}O.dmax=1<<R,I.adler=O.check=1,O.mode=512&A?10:12,F=A=0;break;case 2:for(;F<16;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(O.flags=A,(255&O.flags)!=8){I.msg="unknown compression method",O.mode=30;break}if(57344&O.flags){I.msg="unknown header flags set",O.mode=30;break}O.head&&(O.head.text=A>>8&1),512&O.flags&&(D[0]=255&A,D[1]=A>>>8&255,O.check=c(O.check,D,2,0)),F=A=0,O.mode=3;case 3:for(;F<32;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}O.head&&(O.head.time=A),512&O.flags&&(D[0]=255&A,D[1]=A>>>8&255,D[2]=A>>>16&255,D[3]=A>>>24&255,O.check=c(O.check,D,4,0)),F=A=0,O.mode=4;case 4:for(;F<16;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}O.head&&(O.head.xflags=255&A,O.head.os=A>>8),512&O.flags&&(D[0]=255&A,D[1]=A>>>8&255,O.check=c(O.check,D,2,0)),F=A=0,O.mode=5;case 5:if(1024&O.flags){for(;F<16;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}O.length=A,O.head&&(O.head.extra_len=A),512&O.flags&&(D[0]=255&A,D[1]=A>>>8&255,O.check=c(O.check,D,2,0)),F=A=0}else O.head&&(O.head.extra=null);O.mode=6;case 6:if(1024&O.flags&&(ae<(ee=O.length)&&(ee=ae),ee&&(O.head&&(R=O.head.extra_len-O.length,O.head.extra||(O.head.extra=new Array(O.head.extra_len)),l.arraySet(O.head.extra,P,te,ee,R)),512&O.flags&&(O.check=c(O.check,P,ee,te)),ae-=ee,te+=ee,O.length-=ee),O.length))break e;O.length=0,O.mode=7;case 7:if(2048&O.flags){if(ae===0)break e;for(ee=0;R=P[te+ee++],O.head&&R&&O.length<65536&&(O.head.name+=String.fromCharCode(R)),R&&ee<ae;);if(512&O.flags&&(O.check=c(O.check,P,ee,te)),ae-=ee,te+=ee,R)break e}else O.head&&(O.head.name=null);O.length=0,O.mode=8;case 8:if(4096&O.flags){if(ae===0)break e;for(ee=0;R=P[te+ee++],O.head&&R&&O.length<65536&&(O.head.comment+=String.fromCharCode(R)),R&&ee<ae;);if(512&O.flags&&(O.check=c(O.check,P,ee,te)),ae-=ee,te+=ee,R)break e}else O.head&&(O.head.comment=null);O.mode=9;case 9:if(512&O.flags){for(;F<16;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(A!==(65535&O.check)){I.msg="header crc mismatch",O.mode=30;break}F=A=0}O.head&&(O.head.hcrc=O.flags>>9&1,O.head.done=!0),I.adler=O.check=0,O.mode=12;break;case 10:for(;F<32;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}I.adler=O.check=x(A),F=A=0,O.mode=11;case 11:if(O.havedict===0)return I.next_out=ne,I.avail_out=W,I.next_in=te,I.avail_in=ae,O.hold=A,O.bits=F,2;I.adler=O.check=1,O.mode=12;case 12:if(z===5||z===6)break e;case 13:if(O.last){A>>>=7&F,F-=7&F,O.mode=27;break}for(;F<3;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}switch(O.last=1&A,F-=1,3&(A>>>=1)){case 0:O.mode=14;break;case 1:if(T(O),O.mode=20,z!==6)break;A>>>=2,F-=2;break e;case 2:O.mode=17;break;case 3:I.msg="invalid block type",O.mode=30}A>>>=2,F-=2;break;case 14:for(A>>>=7&F,F-=7&F;F<32;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if((65535&A)!=(A>>>16^65535)){I.msg="invalid stored block lengths",O.mode=30;break}if(O.length=65535&A,F=A=0,O.mode=15,z===6)break e;case 15:O.mode=16;case 16:if(ee=O.length){if(ae<ee&&(ee=ae),W<ee&&(ee=W),ee===0)break e;l.arraySet(Q,P,te,ee,ne),ae-=ee,te+=ee,W-=ee,ne+=ee,O.length-=ee;break}O.mode=12;break;case 17:for(;F<14;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(O.nlen=257+(31&A),A>>>=5,F-=5,O.ndist=1+(31&A),A>>>=5,F-=5,O.ncode=4+(15&A),A>>>=4,F-=4,286<O.nlen||30<O.ndist){I.msg="too many length or distance symbols",O.mode=30;break}O.have=0,O.mode=18;case 18:for(;O.have<O.ncode;){for(;F<3;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}O.lens[_[O.have++]]=7&A,A>>>=3,F-=3}for(;O.have<19;)O.lens[_[O.have++]]=0;if(O.lencode=O.lendyn,O.lenbits=7,H={bits:O.lenbits},J=d(0,O.lens,0,19,O.lencode,0,O.work,H),O.lenbits=H.bits,J){I.msg="invalid code lengths set",O.mode=30;break}O.have=0,O.mode=19;case 19:for(;O.have<O.nlen+O.ndist;){for(;ce=(S=O.lencode[A&(1<<O.lenbits)-1])>>>16&255,se=65535&S,!((ge=S>>>24)<=F);){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(se<16)A>>>=ge,F-=ge,O.lens[O.have++]=se;else{if(se===16){for(L=ge+2;F<L;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(A>>>=ge,F-=ge,O.have===0){I.msg="invalid bit length repeat",O.mode=30;break}R=O.lens[O.have-1],ee=3+(3&A),A>>>=2,F-=2}else if(se===17){for(L=ge+3;F<L;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}F-=ge,R=0,ee=3+(7&(A>>>=ge)),A>>>=3,F-=3}else{for(L=ge+7;F<L;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}F-=ge,R=0,ee=11+(127&(A>>>=ge)),A>>>=7,F-=7}if(O.have+ee>O.nlen+O.ndist){I.msg="invalid bit length repeat",O.mode=30;break}for(;ee--;)O.lens[O.have++]=R}}if(O.mode===30)break;if(O.lens[256]===0){I.msg="invalid code -- missing end-of-block",O.mode=30;break}if(O.lenbits=9,H={bits:O.lenbits},J=d(m,O.lens,0,O.nlen,O.lencode,0,O.work,H),O.lenbits=H.bits,J){I.msg="invalid literal/lengths set",O.mode=30;break}if(O.distbits=6,O.distcode=O.distdyn,H={bits:O.distbits},J=d(f,O.lens,O.nlen,O.ndist,O.distcode,0,O.work,H),O.distbits=H.bits,J){I.msg="invalid distances set",O.mode=30;break}if(O.mode=20,z===6)break e;case 20:O.mode=21;case 21:if(6<=ae&&258<=W){I.next_out=ne,I.avail_out=W,I.next_in=te,I.avail_in=ae,O.hold=A,O.bits=F,u(I,U),ne=I.next_out,Q=I.output,W=I.avail_out,te=I.next_in,P=I.input,ae=I.avail_in,A=O.hold,F=O.bits,O.mode===12&&(O.back=-1);break}for(O.back=0;ce=(S=O.lencode[A&(1<<O.lenbits)-1])>>>16&255,se=65535&S,!((ge=S>>>24)<=F);){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(ce&&(240&ce)==0){for(we=ge,de=ce,me=se;ce=(S=O.lencode[me+((A&(1<<we+de)-1)>>we)])>>>16&255,se=65535&S,!(we+(ge=S>>>24)<=F);){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}A>>>=we,F-=we,O.back+=we}if(A>>>=ge,F-=ge,O.back+=ge,O.length=se,ce===0){O.mode=26;break}if(32&ce){O.back=-1,O.mode=12;break}if(64&ce){I.msg="invalid literal/length code",O.mode=30;break}O.extra=15&ce,O.mode=22;case 22:if(O.extra){for(L=O.extra;F<L;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}O.length+=A&(1<<O.extra)-1,A>>>=O.extra,F-=O.extra,O.back+=O.extra}O.was=O.length,O.mode=23;case 23:for(;ce=(S=O.distcode[A&(1<<O.distbits)-1])>>>16&255,se=65535&S,!((ge=S>>>24)<=F);){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if((240&ce)==0){for(we=ge,de=ce,me=se;ce=(S=O.distcode[me+((A&(1<<we+de)-1)>>we)])>>>16&255,se=65535&S,!(we+(ge=S>>>24)<=F);){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}A>>>=we,F-=we,O.back+=we}if(A>>>=ge,F-=ge,O.back+=ge,64&ce){I.msg="invalid distance code",O.mode=30;break}O.offset=se,O.extra=15&ce,O.mode=24;case 24:if(O.extra){for(L=O.extra;F<L;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}O.offset+=A&(1<<O.extra)-1,A>>>=O.extra,F-=O.extra,O.back+=O.extra}if(O.offset>O.dmax){I.msg="invalid distance too far back",O.mode=30;break}O.mode=25;case 25:if(W===0)break e;if(ee=U-W,O.offset>ee){if((ee=O.offset-ee)>O.whave&&O.sane){I.msg="invalid distance too far back",O.mode=30;break}le=ee>O.wnext?(ee-=O.wnext,O.wsize-ee):O.wnext-ee,ee>O.length&&(ee=O.length),ue=O.window}else ue=Q,le=ne-O.offset,ee=O.length;for(W<ee&&(ee=W),W-=ee,O.length-=ee;Q[ne++]=ue[le++],--ee;);O.length===0&&(O.mode=21);break;case 26:if(W===0)break e;Q[ne++]=O.length,W--,O.mode=21;break;case 27:if(O.wrap){for(;F<32;){if(ae===0)break e;ae--,A|=P[te++]<<F,F+=8}if(U-=W,I.total_out+=U,O.total+=U,U&&(I.adler=O.check=O.flags?c(O.check,Q,U,ne-U):i(O.check,Q,U,ne-U)),U=W,(O.flags?A:x(A))!==O.check){I.msg="incorrect data check",O.mode=30;break}F=A=0}O.mode=28;case 28:if(O.wrap&&O.flags){for(;F<32;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(A!==(4294967295&O.total)){I.msg="incorrect length check",O.mode=30;break}F=A=0}O.mode=29;case 29:J=1;break e;case 30:J=-3;break e;case 31:return-4;case 32:default:return p}return I.next_out=ne,I.avail_out=W,I.next_in=te,I.avail_in=ae,O.hold=A,O.bits=F,(O.wsize||U!==I.avail_out&&O.mode<30&&(O.mode<27||z!==4))&&V(I,I.output,I.next_out,U-I.avail_out)?(O.mode=31,-4):(Y-=I.avail_in,U-=I.avail_out,I.total_in+=Y,I.total_out+=U,O.total+=U,O.wrap&&U&&(I.adler=O.check=O.flags?c(O.check,Q,U,I.next_out-U):i(O.check,Q,U,I.next_out-U)),I.data_type=O.bits+(O.last?64:0)+(O.mode===12?128:0)+(O.mode===20||O.mode===15?256:0),(Y==0&&U===0||z===4)&&J===h&&(J=-5),J)},o.inflateEnd=function(I){if(!I||!I.state)return p;var z=I.state;return z.window&&(z.window=null),I.state=null,h},o.inflateGetHeader=function(I,z){var O;return I&&I.state?(2&(O=I.state).wrap)==0?p:((O.head=z).done=!1,h):p},o.inflateSetDictionary=function(I,z){var O,P=z.length;return I&&I.state?(O=I.state).wrap!==0&&O.mode!==11?p:O.mode===11&&i(1,z,P,0)!==O.check?-3:V(I,z,P,P)?(O.mode=31,-4):(O.havedict=1,h):p},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(r,n,o){var l=r("../utils/common"),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],c=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],u=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],d=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];n.exports=function(m,f,h,p,v,b,g,x){var w,j,k,y,C,N,M,$,T,V=x.bits,I=0,z=0,O=0,P=0,Q=0,te=0,ne=0,ae=0,W=0,A=0,F=null,Y=0,U=new l.Buf16(16),ee=new l.Buf16(16),le=null,ue=0;for(I=0;I<=15;I++)U[I]=0;for(z=0;z<p;z++)U[f[h+z]]++;for(Q=V,P=15;1<=P&&U[P]===0;P--);if(P<Q&&(Q=P),P===0)return v[b++]=20971520,v[b++]=20971520,x.bits=1,0;for(O=1;O<P&&U[O]===0;O++);for(Q<O&&(Q=O),I=ae=1;I<=15;I++)if(ae<<=1,(ae-=U[I])<0)return-1;if(0<ae&&(m===0||P!==1))return-1;for(ee[1]=0,I=1;I<15;I++)ee[I+1]=ee[I]+U[I];for(z=0;z<p;z++)f[h+z]!==0&&(g[ee[f[h+z]]++]=z);if(N=m===0?(F=le=g,19):m===1?(F=i,Y-=257,le=c,ue-=257,256):(F=u,le=d,-1),I=O,C=b,ne=z=A=0,k=-1,y=(W=1<<(te=Q))-1,m===1&&852<W||m===2&&592<W)return 1;for(;;){for(M=I-ne,T=g[z]<N?($=0,g[z]):g[z]>N?($=le[ue+g[z]],F[Y+g[z]]):($=96,0),w=1<<I-ne,O=j=1<<te;v[C+(A>>ne)+(j-=w)]=M<<24|$<<16|T|0,j!==0;);for(w=1<<I-1;A&w;)w>>=1;if(w!==0?(A&=w-1,A+=w):A=0,z++,--U[I]==0){if(I===P)break;I=f[h+g[z]]}if(Q<I&&(A&y)!==k){for(ne===0&&(ne=Q),C+=O,ae=1<<(te=I-ne);te+ne<P&&!((ae-=U[te+ne])<=0);)te++,ae<<=1;if(W+=1<<te,m===1&&852<W||m===2&&592<W)return 1;v[k=A&y]=Q<<24|te<<16|C-b|0}}return A!==0&&(v[C+A]=I-ne<<24|64<<16|0),x.bits=Q,0}},{"../utils/common":41}],51:[function(r,n,o){n.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(r,n,o){var l=r("../utils/common"),i=0,c=1;function u(S){for(var D=S.length;0<=--D;)S[D]=0}var d=0,m=29,f=256,h=f+1+m,p=30,v=19,b=2*h+1,g=15,x=16,w=7,j=256,k=16,y=17,C=18,N=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],M=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],$=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],V=new Array(2*(h+2));u(V);var I=new Array(2*p);u(I);var z=new Array(512);u(z);var O=new Array(256);u(O);var P=new Array(m);u(P);var Q,te,ne,ae=new Array(p);function W(S,D,_,Z,B){this.static_tree=S,this.extra_bits=D,this.extra_base=_,this.elems=Z,this.max_length=B,this.has_stree=S&&S.length}function A(S,D){this.dyn_tree=S,this.max_code=0,this.stat_desc=D}function F(S){return S<256?z[S]:z[256+(S>>>7)]}function Y(S,D){S.pending_buf[S.pending++]=255&D,S.pending_buf[S.pending++]=D>>>8&255}function U(S,D,_){S.bi_valid>x-_?(S.bi_buf|=D<<S.bi_valid&65535,Y(S,S.bi_buf),S.bi_buf=D>>x-S.bi_valid,S.bi_valid+=_-x):(S.bi_buf|=D<<S.bi_valid&65535,S.bi_valid+=_)}function ee(S,D,_){U(S,_[2*D],_[2*D+1])}function le(S,D){for(var _=0;_|=1&S,S>>>=1,_<<=1,0<--D;);return _>>>1}function ue(S,D,_){var Z,B,q=new Array(g+1),X=0;for(Z=1;Z<=g;Z++)q[Z]=X=X+_[Z-1]<<1;for(B=0;B<=D;B++){var G=S[2*B+1];G!==0&&(S[2*B]=le(q[G]++,G))}}function ge(S){var D;for(D=0;D<h;D++)S.dyn_ltree[2*D]=0;for(D=0;D<p;D++)S.dyn_dtree[2*D]=0;for(D=0;D<v;D++)S.bl_tree[2*D]=0;S.dyn_ltree[2*j]=1,S.opt_len=S.static_len=0,S.last_lit=S.matches=0}function ce(S){8<S.bi_valid?Y(S,S.bi_buf):0<S.bi_valid&&(S.pending_buf[S.pending++]=S.bi_buf),S.bi_buf=0,S.bi_valid=0}function se(S,D,_,Z){var B=2*D,q=2*_;return S[B]<S[q]||S[B]===S[q]&&Z[D]<=Z[_]}function we(S,D,_){for(var Z=S.heap[_],B=_<<1;B<=S.heap_len&&(B<S.heap_len&&se(D,S.heap[B+1],S.heap[B],S.depth)&&B++,!se(D,Z,S.heap[B],S.depth));)S.heap[_]=S.heap[B],_=B,B<<=1;S.heap[_]=Z}function de(S,D,_){var Z,B,q,X,G=0;if(S.last_lit!==0)for(;Z=S.pending_buf[S.d_buf+2*G]<<8|S.pending_buf[S.d_buf+2*G+1],B=S.pending_buf[S.l_buf+G],G++,Z===0?ee(S,B,D):(ee(S,(q=O[B])+f+1,D),(X=N[q])!==0&&U(S,B-=P[q],X),ee(S,q=F(--Z),_),(X=M[q])!==0&&U(S,Z-=ae[q],X)),G<S.last_lit;);ee(S,j,D)}function me(S,D){var _,Z,B,q=D.dyn_tree,X=D.stat_desc.static_tree,G=D.stat_desc.has_stree,K=D.stat_desc.elems,re=-1;for(S.heap_len=0,S.heap_max=b,_=0;_<K;_++)q[2*_]!==0?(S.heap[++S.heap_len]=re=_,S.depth[_]=0):q[2*_+1]=0;for(;S.heap_len<2;)q[2*(B=S.heap[++S.heap_len]=re<2?++re:0)]=1,S.depth[B]=0,S.opt_len--,G&&(S.static_len-=X[2*B+1]);for(D.max_code=re,_=S.heap_len>>1;1<=_;_--)we(S,q,_);for(B=K;_=S.heap[1],S.heap[1]=S.heap[S.heap_len--],we(S,q,1),Z=S.heap[1],S.heap[--S.heap_max]=_,S.heap[--S.heap_max]=Z,q[2*B]=q[2*_]+q[2*Z],S.depth[B]=(S.depth[_]>=S.depth[Z]?S.depth[_]:S.depth[Z])+1,q[2*_+1]=q[2*Z+1]=B,S.heap[1]=B++,we(S,q,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],(function(ie,pe){var ve,ye,Se,ke,Fe,Oe,Ce=pe.dyn_tree,xe=pe.max_code,Ne=pe.stat_desc.static_tree,Le=pe.stat_desc.has_stree,Me=pe.stat_desc.extra_bits,Te=pe.stat_desc.extra_base,Ie=pe.stat_desc.max_length,Ae=0;for(ke=0;ke<=g;ke++)ie.bl_count[ke]=0;for(Ce[2*ie.heap[ie.heap_max]+1]=0,ve=ie.heap_max+1;ve<b;ve++)Ie<(ke=Ce[2*Ce[2*(ye=ie.heap[ve])+1]+1]+1)&&(ke=Ie,Ae++),Ce[2*ye+1]=ke,xe<ye||(ie.bl_count[ke]++,Fe=0,Te<=ye&&(Fe=Me[ye-Te]),Oe=Ce[2*ye],ie.opt_len+=Oe*(ke+Fe),Le&&(ie.static_len+=Oe*(Ne[2*ye+1]+Fe)));if(Ae!==0){do{for(ke=Ie-1;ie.bl_count[ke]===0;)ke--;ie.bl_count[ke]--,ie.bl_count[ke+1]+=2,ie.bl_count[Ie]--,Ae-=2}while(0<Ae);for(ke=Ie;ke!==0;ke--)for(ye=ie.bl_count[ke];ye!==0;)xe<(Se=ie.heap[--ve])||(Ce[2*Se+1]!==ke&&(ie.opt_len+=(ke-Ce[2*Se+1])*Ce[2*Se],Ce[2*Se+1]=ke),ye--)}})(S,D),ue(q,re,S.bl_count)}function R(S,D,_){var Z,B,q=-1,X=D[1],G=0,K=7,re=4;for(X===0&&(K=138,re=3),D[2*(_+1)+1]=65535,Z=0;Z<=_;Z++)B=X,X=D[2*(Z+1)+1],++G<K&&B===X||(G<re?S.bl_tree[2*B]+=G:B!==0?(B!==q&&S.bl_tree[2*B]++,S.bl_tree[2*k]++):G<=10?S.bl_tree[2*y]++:S.bl_tree[2*C]++,q=B,re=(G=0)===X?(K=138,3):B===X?(K=6,3):(K=7,4))}function J(S,D,_){var Z,B,q=-1,X=D[1],G=0,K=7,re=4;for(X===0&&(K=138,re=3),Z=0;Z<=_;Z++)if(B=X,X=D[2*(Z+1)+1],!(++G<K&&B===X)){if(G<re)for(;ee(S,B,S.bl_tree),--G!=0;);else B!==0?(B!==q&&(ee(S,B,S.bl_tree),G--),ee(S,k,S.bl_tree),U(S,G-3,2)):G<=10?(ee(S,y,S.bl_tree),U(S,G-3,3)):(ee(S,C,S.bl_tree),U(S,G-11,7));q=B,re=(G=0)===X?(K=138,3):B===X?(K=6,3):(K=7,4)}}u(ae);var H=!1;function L(S,D,_,Z){U(S,(d<<1)+(Z?1:0),3),(function(B,q,X,G){ce(B),Y(B,X),Y(B,~X),l.arraySet(B.pending_buf,B.window,q,X,B.pending),B.pending+=X})(S,D,_)}o._tr_init=function(S){H||((function(){var D,_,Z,B,q,X=new Array(g+1);for(B=Z=0;B<m-1;B++)for(P[B]=Z,D=0;D<1<<N[B];D++)O[Z++]=B;for(O[Z-1]=B,B=q=0;B<16;B++)for(ae[B]=q,D=0;D<1<<M[B];D++)z[q++]=B;for(q>>=7;B<p;B++)for(ae[B]=q<<7,D=0;D<1<<M[B]-7;D++)z[256+q++]=B;for(_=0;_<=g;_++)X[_]=0;for(D=0;D<=143;)V[2*D+1]=8,D++,X[8]++;for(;D<=255;)V[2*D+1]=9,D++,X[9]++;for(;D<=279;)V[2*D+1]=7,D++,X[7]++;for(;D<=287;)V[2*D+1]=8,D++,X[8]++;for(ue(V,h+1,X),D=0;D<p;D++)I[2*D+1]=5,I[2*D]=le(D,5);Q=new W(V,N,f+1,h,g),te=new W(I,M,0,p,g),ne=new W(new Array(0),$,0,v,w)})(),H=!0),S.l_desc=new A(S.dyn_ltree,Q),S.d_desc=new A(S.dyn_dtree,te),S.bl_desc=new A(S.bl_tree,ne),S.bi_buf=0,S.bi_valid=0,ge(S)},o._tr_stored_block=L,o._tr_flush_block=function(S,D,_,Z){var B,q,X=0;0<S.level?(S.strm.data_type===2&&(S.strm.data_type=(function(G){var K,re=4093624447;for(K=0;K<=31;K++,re>>>=1)if(1&re&&G.dyn_ltree[2*K]!==0)return i;if(G.dyn_ltree[18]!==0||G.dyn_ltree[20]!==0||G.dyn_ltree[26]!==0)return c;for(K=32;K<f;K++)if(G.dyn_ltree[2*K]!==0)return c;return i})(S)),me(S,S.l_desc),me(S,S.d_desc),X=(function(G){var K;for(R(G,G.dyn_ltree,G.l_desc.max_code),R(G,G.dyn_dtree,G.d_desc.max_code),me(G,G.bl_desc),K=v-1;3<=K&&G.bl_tree[2*T[K]+1]===0;K--);return G.opt_len+=3*(K+1)+5+5+4,K})(S),B=S.opt_len+3+7>>>3,(q=S.static_len+3+7>>>3)<=B&&(B=q)):B=q=_+5,_+4<=B&&D!==-1?L(S,D,_,Z):S.strategy===4||q===B?(U(S,2+(Z?1:0),3),de(S,V,I)):(U(S,4+(Z?1:0),3),(function(G,K,re,ie){var pe;for(U(G,K-257,5),U(G,re-1,5),U(G,ie-4,4),pe=0;pe<ie;pe++)U(G,G.bl_tree[2*T[pe]+1],3);J(G,G.dyn_ltree,K-1),J(G,G.dyn_dtree,re-1)})(S,S.l_desc.max_code+1,S.d_desc.max_code+1,X+1),de(S,S.dyn_ltree,S.dyn_dtree)),ge(S),Z&&ce(S)},o._tr_tally=function(S,D,_){return S.pending_buf[S.d_buf+2*S.last_lit]=D>>>8&255,S.pending_buf[S.d_buf+2*S.last_lit+1]=255&D,S.pending_buf[S.l_buf+S.last_lit]=255&_,S.last_lit++,D===0?S.dyn_ltree[2*_]++:(S.matches++,D--,S.dyn_ltree[2*(O[_]+f+1)]++,S.dyn_dtree[2*F(D)]++),S.last_lit===S.lit_bufsize-1},o._tr_align=function(S){U(S,2,3),ee(S,j,V),(function(D){D.bi_valid===16?(Y(D,D.bi_buf),D.bi_buf=0,D.bi_valid=0):8<=D.bi_valid&&(D.pending_buf[D.pending++]=255&D.bi_buf,D.bi_buf>>=8,D.bi_valid-=8)})(S)}},{"../utils/common":41}],53:[function(r,n,o){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,n,o){(function(l){(function(i,c){if(!i.setImmediate){var u,d,m,f,h=1,p={},v=!1,b=i.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(i);g=g&&g.setTimeout?g:i,u={}.toString.call(i.process)==="[object process]"?function(k){process.nextTick(function(){w(k)})}:(function(){if(i.postMessage&&!i.importScripts){var k=!0,y=i.onmessage;return i.onmessage=function(){k=!1},i.postMessage("","*"),i.onmessage=y,k}})()?(f="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",j,!1):i.attachEvent("onmessage",j),function(k){i.postMessage(f+k,"*")}):i.MessageChannel?((m=new MessageChannel).port1.onmessage=function(k){w(k.data)},function(k){m.port2.postMessage(k)}):b&&"onreadystatechange"in b.createElement("script")?(d=b.documentElement,function(k){var y=b.createElement("script");y.onreadystatechange=function(){w(k),y.onreadystatechange=null,d.removeChild(y),y=null},d.appendChild(y)}):function(k){setTimeout(w,0,k)},g.setImmediate=function(k){typeof k!="function"&&(k=new Function(""+k));for(var y=new Array(arguments.length-1),C=0;C<y.length;C++)y[C]=arguments[C+1];var N={callback:k,args:y};return p[h]=N,u(h),h++},g.clearImmediate=x}function x(k){delete p[k]}function w(k){if(v)setTimeout(w,0,k);else{var y=p[k];if(y){v=!0;try{(function(C){var N=C.callback,M=C.args;switch(M.length){case 0:N();break;case 1:N(M[0]);break;case 2:N(M[0],M[1]);break;case 3:N(M[0],M[1],M[2]);break;default:N.apply(c,M)}})(y)}finally{x(k),v=!1}}}}function j(k){k.source===i&&typeof k.data=="string"&&k.data.indexOf(f)===0&&w(+k.data.slice(f.length))}})(typeof self>"u"?l===void 0?this:l:self)}).call(this,typeof jr<"u"?jr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Us)),Us.exports}var S_=C_();const nu=H0(S_);async function N_({file:e,setSchema:t,setServices:r,translationAdapter:n}){const l=await new nu().loadAsync(e),i=l.file("schema.json");if(i){const d=await i.async("string");try{console.log("Reading schema.json from ZIP:",d.substring(0,100)+"...");const m=JSON.parse(d);console.log("Parsed schema:",m),t(m),console.log("setSchema called")}catch(m){throw console.error("Failed to parse schema.json",m),new Error("El archivo schema.json no es válido.")}}else throw new Error("El archivo ZIP no contiene schema.json");const c=l.file("openapi_specs.json");if(c)try{console.log("Found openapi_specs.json in ZIP");const d=await c.async("string"),m=JSON.parse(d);if(Array.isArray(m)){ru();let f={};for(const h of m){eu(h);const p=Oo(h),v=Li(p),b=$i(p);f={...f,...v},Si(b)}r&&(r({registry:f}),console.log(`Restored ${Object.keys(f).length} services from OpenAPI specs.`))}}catch(d){console.error("Failed to restore OpenAPI specs",d)}else{console.log("openapi_specs.json NOT found in ZIP.");const d=l.file("services.json");if(d){if(console.log("Found services.json in ZIP (Fallback)"),r)try{const m=await d.async("string"),f=JSON.parse(m);Object.keys(f).length>0?(r({registry:f}),console.log("setServices called with fallback registry")):console.warn("services.json is empty, jumping fallback.")}catch(m){console.error("Failed to parse services.json",m)}}else console.log("No services configuration found in ZIP.")}const u=l.folder("i18n");if(u){const d=[];u.forEach((m,f)=>{!f.dir&&m.endsWith(".json")&&d.push({path:m,file:f})});for(const{path:m,file:f}of d)try{const h=await f.async("string"),p=JSON.parse(h),v=m.replace(".json","");n&&typeof n.importTranslations=="function"&&n.importTranslations(p,v)}catch(h){console.error(`Failed to import translation ${m}`,h)}}}var ro={exports:{}},M_=ro.exports,N0;function A_(){return N0||(N0=1,(function(e,t){(function(r,n){n()})(M_,function(){function r(d,m){return typeof m>"u"?m={autoBom:!1}:typeof m!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),m={autoBom:!m}),m.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(d.type)?new Blob(["\uFEFF",d],{type:d.type}):d}function n(d,m,f){var h=new XMLHttpRequest;h.open("GET",d),h.responseType="blob",h.onload=function(){u(h.response,m,f)},h.onerror=function(){console.error("could not download file")},h.send()}function o(d){var m=new XMLHttpRequest;m.open("HEAD",d,!1);try{m.send()}catch{}return 200<=m.status&&299>=m.status}function l(d){try{d.dispatchEvent(new MouseEvent("click"))}catch{var m=document.createEvent("MouseEvents");m.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),d.dispatchEvent(m)}}var i=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof jr=="object"&&jr.global===jr?jr:void 0,c=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),u=i.saveAs||(typeof window!="object"||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!c?function(d,m,f){var h=i.URL||i.webkitURL,p=document.createElement("a");m=m||d.name||"download",p.download=m,p.rel="noopener",typeof d=="string"?(p.href=d,p.origin===location.origin?l(p):o(p.href)?n(d,m,f):l(p,p.target="_blank")):(p.href=h.createObjectURL(d),setTimeout(function(){h.revokeObjectURL(p.href)},4e4),setTimeout(function(){l(p)},0))}:"msSaveOrOpenBlob"in navigator?function(d,m,f){if(m=m||d.name||"download",typeof d!="string")navigator.msSaveOrOpenBlob(r(d,f),m);else if(o(d))n(d,m,f);else{var h=document.createElement("a");h.href=d,h.target="_blank",setTimeout(function(){l(h)})}}:function(d,m,f,h){if(h=h||open("","_blank"),h&&(h.document.title=h.document.body.innerText="downloading..."),typeof d=="string")return n(d,m,f);var p=d.type==="application/octet-stream",v=/constructor/i.test(i.HTMLElement)||i.safari,b=/CriOS\/[\d]+/.test(navigator.userAgent);if((b||p&&v||c)&&typeof FileReader<"u"){var g=new FileReader;g.onloadend=function(){var j=g.result;j=b?j:j.replace(/^data:[^;]*;/,"data:attachment/file;"),h?h.location.href=j:location=j,h=null},g.readAsDataURL(d)}else{var x=i.URL||i.webkitURL,w=x.createObjectURL(d);h?h.location=w:location.href=w,h=null,setTimeout(function(){x.revokeObjectURL(w)},4e4)}});i.saveAs=u.saveAs=u,e.exports=u})})(ro)),ro.exports}var O_=A_();function au(e,t){const n=e.replace(/[^a-zA-Z0-9]/g," ").split(" ").filter(Boolean).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join("")+"Service";let o=`// ${n}.ts
205
+ */var S0;function R_(){return S0||(S0=1,(function(e,t){(function(r){e.exports=r()})(function(){return(function r(n,o,l){function i(d,m){if(!o[d]){if(!n[d]){var f=typeof Ha=="function"&&Ha;if(!m&&f)return f(d,!0);if(c)return c(d,!0);var h=new Error("Cannot find module '"+d+"'");throw h.code="MODULE_NOT_FOUND",h}var p=o[d]={exports:{}};n[d][0].call(p.exports,function(v){var b=n[d][1][v];return i(b||v)},p,p.exports,r,n,o,l)}return o[d].exports}for(var c=typeof Ha=="function"&&Ha,u=0;u<l.length;u++)i(l[u]);return i})({1:[function(r,n,o){var l=r("./utils"),i=r("./support"),c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(u){for(var d,m,f,h,p,v,b,g=[],x=0,w=u.length,j=w,k=l.getTypeOf(u)!=="string";x<u.length;)j=w-x,f=k?(d=u[x++],m=x<w?u[x++]:0,x<w?u[x++]:0):(d=u.charCodeAt(x++),m=x<w?u.charCodeAt(x++):0,x<w?u.charCodeAt(x++):0),h=d>>2,p=(3&d)<<4|m>>4,v=1<j?(15&m)<<2|f>>6:64,b=2<j?63&f:64,g.push(c.charAt(h)+c.charAt(p)+c.charAt(v)+c.charAt(b));return g.join("")},o.decode=function(u){var d,m,f,h,p,v,b=0,g=0,x="data:";if(u.substr(0,x.length)===x)throw new Error("Invalid base64 input, it looks like a data url.");var w,j=3*(u=u.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(u.charAt(u.length-1)===c.charAt(64)&&j--,u.charAt(u.length-2)===c.charAt(64)&&j--,j%1!=0)throw new Error("Invalid base64 input, bad content length.");for(w=i.uint8array?new Uint8Array(0|j):new Array(0|j);b<u.length;)d=c.indexOf(u.charAt(b++))<<2|(h=c.indexOf(u.charAt(b++)))>>4,m=(15&h)<<4|(p=c.indexOf(u.charAt(b++)))>>2,f=(3&p)<<6|(v=c.indexOf(u.charAt(b++))),w[g++]=d,p!==64&&(w[g++]=m),v!==64&&(w[g++]=f);return w}},{"./support":30,"./utils":32}],2:[function(r,n,o){var l=r("./external"),i=r("./stream/DataWorker"),c=r("./stream/Crc32Probe"),u=r("./stream/DataLengthProbe");function d(m,f,h,p,v){this.compressedSize=m,this.uncompressedSize=f,this.crc32=h,this.compression=p,this.compressedContent=v}d.prototype={getContentWorker:function(){var m=new i(l.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new u("data_length")),f=this;return m.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),m},getCompressedWorker:function(){return new i(l.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},d.createWorkerFrom=function(m,f,h){return m.pipe(new c).pipe(new u("uncompressedSize")).pipe(f.compressWorker(h)).pipe(new u("compressedSize")).withStreamInfo("compression",f)},n.exports=d},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,n,o){var l=r("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new l("STORE compression")},uncompressWorker:function(){return new l("STORE decompression")}},o.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,n,o){var l=r("./utils"),i=(function(){for(var c,u=[],d=0;d<256;d++){c=d;for(var m=0;m<8;m++)c=1&c?3988292384^c>>>1:c>>>1;u[d]=c}return u})();n.exports=function(c,u){return c!==void 0&&c.length?l.getTypeOf(c)!=="string"?(function(d,m,f,h){var p=i,v=h+f;d^=-1;for(var b=h;b<v;b++)d=d>>>8^p[255&(d^m[b])];return-1^d})(0|u,c,c.length,0):(function(d,m,f,h){var p=i,v=h+f;d^=-1;for(var b=h;b<v;b++)d=d>>>8^p[255&(d^m.charCodeAt(b))];return-1^d})(0|u,c,c.length,0):0}},{"./utils":32}],5:[function(r,n,o){o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(r,n,o){var l=null;l=typeof Promise<"u"?Promise:r("lie"),n.exports={Promise:l}},{lie:37}],7:[function(r,n,o){var l=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",i=r("pako"),c=r("./utils"),u=r("./stream/GenericWorker"),d=l?"uint8array":"array";function m(f,h){u.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=h,this.meta={}}o.magic="\b\0",c.inherits(m,u),m.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(c.transformTo(d,f.data),!1)},m.prototype.flush=function(){u.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},m.prototype.cleanUp=function(){u.prototype.cleanUp.call(this),this._pako=null},m.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(h){f.push({data:h,meta:f.meta})}},o.compressWorker=function(f){return new m("Deflate",f)},o.uncompressWorker=function(){return new m("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,o){function l(p,v){var b,g="";for(b=0;b<v;b++)g+=String.fromCharCode(255&p),p>>>=8;return g}function i(p,v,b,g,x,w){var j,k,y=p.file,C=p.compression,N=w!==d.utf8encode,M=c.transformTo("string",w(y.name)),$=c.transformTo("string",d.utf8encode(y.name)),T=y.comment,V=c.transformTo("string",w(T)),I=c.transformTo("string",d.utf8encode(T)),z=$.length!==y.name.length,O=I.length!==T.length,P="",Q="",te="",ne=y.dir,ae=y.date,W={crc32:0,compressedSize:0,uncompressedSize:0};v&&!b||(W.crc32=p.crc32,W.compressedSize=p.compressedSize,W.uncompressedSize=p.uncompressedSize);var A=0;v&&(A|=8),N||!z&&!O||(A|=2048);var F=0,Y=0;ne&&(F|=16),x==="UNIX"?(Y=798,F|=(function(ee,le){var ue=ee;return ee||(ue=le?16893:33204),(65535&ue)<<16})(y.unixPermissions,ne)):(Y=20,F|=(function(ee){return 63&(ee||0)})(y.dosPermissions)),j=ae.getUTCHours(),j<<=6,j|=ae.getUTCMinutes(),j<<=5,j|=ae.getUTCSeconds()/2,k=ae.getUTCFullYear()-1980,k<<=4,k|=ae.getUTCMonth()+1,k<<=5,k|=ae.getUTCDate(),z&&(Q=l(1,1)+l(m(M),4)+$,P+="up"+l(Q.length,2)+Q),O&&(te=l(1,1)+l(m(V),4)+I,P+="uc"+l(te.length,2)+te);var U="";return U+=`
206
+ \0`,U+=l(A,2),U+=C.magic,U+=l(j,2),U+=l(k,2),U+=l(W.crc32,4),U+=l(W.compressedSize,4),U+=l(W.uncompressedSize,4),U+=l(M.length,2),U+=l(P.length,2),{fileRecord:f.LOCAL_FILE_HEADER+U+M+P,dirRecord:f.CENTRAL_FILE_HEADER+l(Y,2)+U+l(V.length,2)+"\0\0\0\0"+l(F,4)+l(g,4)+M+P+V}}var c=r("../utils"),u=r("../stream/GenericWorker"),d=r("../utf8"),m=r("../crc32"),f=r("../signature");function h(p,v,b,g){u.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=v,this.zipPlatform=b,this.encodeFileName=g,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}c.inherits(h,u),h.prototype.push=function(p){var v=p.meta.percent||0,b=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,u.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:b?(v+100*(b-g-1))/b:100}}))},h.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var v=this.streamFiles&&!p.file.dir;if(v){var b=i(p,v,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:b.fileRecord,meta:{percent:0}})}else this.accumulate=!0},h.prototype.closedSource=function(p){this.accumulate=!1;var v=this.streamFiles&&!p.file.dir,b=i(p,v,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(b.dirRecord),v)this.push({data:(function(g){return f.DATA_DESCRIPTOR+l(g.crc32,4)+l(g.compressedSize,4)+l(g.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:b.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},h.prototype.flush=function(){for(var p=this.bytesWritten,v=0;v<this.dirRecords.length;v++)this.push({data:this.dirRecords[v],meta:{percent:100}});var b=this.bytesWritten-p,g=(function(x,w,j,k,y){var C=c.transformTo("string",y(k));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+l(x,2)+l(x,2)+l(w,4)+l(j,4)+l(C.length,2)+C})(this.dirRecords.length,b,p,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},h.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},h.prototype.registerPrevious=function(p){this._sources.push(p);var v=this;return p.on("data",function(b){v.processChunk(b)}),p.on("end",function(){v.closedSource(v.previous.streamInfo),v._sources.length?v.prepareNextSource():v.end()}),p.on("error",function(b){v.error(b)}),this},h.prototype.resume=function(){return!!u.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},h.prototype.error=function(p){var v=this._sources;if(!u.prototype.error.call(this,p))return!1;for(var b=0;b<v.length;b++)try{v[b].error(p)}catch{}return!0},h.prototype.lock=function(){u.prototype.lock.call(this);for(var p=this._sources,v=0;v<p.length;v++)p[v].lock()},n.exports=h},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(r,n,o){var l=r("../compressions"),i=r("./ZipFileWorker");o.generateWorker=function(c,u,d){var m=new i(u.streamFiles,d,u.platform,u.encodeFileName),f=0;try{c.forEach(function(h,p){f++;var v=(function(w,j){var k=w||j,y=l[k];if(!y)throw new Error(k+" is not a valid compression method !");return y})(p.options.compression,u.compression),b=p.options.compressionOptions||u.compressionOptions||{},g=p.dir,x=p.date;p._compressWorker(v,b).withStreamInfo("file",{name:h,dir:g,date:x,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(m)}),m.entriesCount=f}catch(h){m.error(h)}return m}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(r,n,o){function l(){if(!(this instanceof l))return new l;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var i=new l;for(var c in this)typeof this[c]!="function"&&(i[c]=this[c]);return i}}(l.prototype=r("./object")).loadAsync=r("./load"),l.support=r("./support"),l.defaults=r("./defaults"),l.version="3.10.1",l.loadAsync=function(i,c){return new l().loadAsync(i,c)},l.external=r("./external"),n.exports=l},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(r,n,o){var l=r("./utils"),i=r("./external"),c=r("./utf8"),u=r("./zipEntries"),d=r("./stream/Crc32Probe"),m=r("./nodejsUtils");function f(h){return new i.Promise(function(p,v){var b=h.decompressed.getContentWorker().pipe(new d);b.on("error",function(g){v(g)}).on("end",function(){b.streamInfo.crc32!==h.decompressed.crc32?v(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}n.exports=function(h,p){var v=this;return p=l.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:c.utf8decode}),m.isNode&&m.isStream(h)?i.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):l.prepareContent("the loaded zip file",h,!0,p.optimizedBinaryString,p.base64).then(function(b){var g=new u(p);return g.load(b),g}).then(function(b){var g=[i.Promise.resolve(b)],x=b.files;if(p.checkCRC32)for(var w=0;w<x.length;w++)g.push(f(x[w]));return i.Promise.all(g)}).then(function(b){for(var g=b.shift(),x=g.files,w=0;w<x.length;w++){var j=x[w],k=j.fileNameStr,y=l.resolve(j.fileNameStr);v.file(y,j.decompressed,{binary:!0,optimizedBinaryString:!0,date:j.date,dir:j.dir,comment:j.fileCommentStr.length?j.fileCommentStr:null,unixPermissions:j.unixPermissions,dosPermissions:j.dosPermissions,createFolders:p.createFolders}),j.dir||(v.file(y).unsafeOriginalName=k)}return g.zipComment.length&&(v.comment=g.zipComment),v})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(r,n,o){var l=r("../utils"),i=r("../stream/GenericWorker");function c(u,d){i.call(this,"Nodejs stream input adapter for "+u),this._upstreamEnded=!1,this._bindStream(d)}l.inherits(c,i),c.prototype._bindStream=function(u){var d=this;(this._stream=u).pause(),u.on("data",function(m){d.push({data:m,meta:{percent:0}})}).on("error",function(m){d.isPaused?this.generatedError=m:d.error(m)}).on("end",function(){d.isPaused?d._upstreamEnded=!0:d.end()})},c.prototype.pause=function(){return!!i.prototype.pause.call(this)&&(this._stream.pause(),!0)},c.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},n.exports=c},{"../stream/GenericWorker":28,"../utils":32}],13:[function(r,n,o){var l=r("readable-stream").Readable;function i(c,u,d){l.call(this,u),this._helper=c;var m=this;c.on("data",function(f,h){m.push(f)||m._helper.pause(),d&&d(h)}).on("error",function(f){m.emit("error",f)}).on("end",function(){m.push(null)})}r("../utils").inherits(i,l),i.prototype._read=function(){this._helper.resume()},n.exports=i},{"../utils":32,"readable-stream":16}],14:[function(r,n,o){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(l,i){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(l,i);if(typeof l=="number")throw new Error('The "data" argument must not be a number');return new Buffer(l,i)},allocBuffer:function(l){if(Buffer.alloc)return Buffer.alloc(l);var i=new Buffer(l);return i.fill(0),i},isBuffer:function(l){return Buffer.isBuffer(l)},isStream:function(l){return l&&typeof l.on=="function"&&typeof l.pause=="function"&&typeof l.resume=="function"}}},{}],15:[function(r,n,o){function l(y,C,N){var M,$=c.getTypeOf(C),T=c.extend(N||{},m);T.date=T.date||new Date,T.compression!==null&&(T.compression=T.compression.toUpperCase()),typeof T.unixPermissions=="string"&&(T.unixPermissions=parseInt(T.unixPermissions,8)),T.unixPermissions&&16384&T.unixPermissions&&(T.dir=!0),T.dosPermissions&&16&T.dosPermissions&&(T.dir=!0),T.dir&&(y=x(y)),T.createFolders&&(M=g(y))&&w.call(this,M,!0);var V=$==="string"&&T.binary===!1&&T.base64===!1;N&&N.binary!==void 0||(T.binary=!V),(C instanceof f&&C.uncompressedSize===0||T.dir||!C||C.length===0)&&(T.base64=!1,T.binary=!0,C="",T.compression="STORE",$="string");var I=null;I=C instanceof f||C instanceof u?C:v.isNode&&v.isStream(C)?new b(y,C):c.prepareContent(y,C,T.binary,T.optimizedBinaryString,T.base64);var z=new h(y,I,T);this.files[y]=z}var i=r("./utf8"),c=r("./utils"),u=r("./stream/GenericWorker"),d=r("./stream/StreamHelper"),m=r("./defaults"),f=r("./compressedObject"),h=r("./zipObject"),p=r("./generate"),v=r("./nodejsUtils"),b=r("./nodejs/NodejsStreamInputAdapter"),g=function(y){y.slice(-1)==="/"&&(y=y.substring(0,y.length-1));var C=y.lastIndexOf("/");return 0<C?y.substring(0,C):""},x=function(y){return y.slice(-1)!=="/"&&(y+="/"),y},w=function(y,C){return C=C!==void 0?C:m.createFolders,y=x(y),this.files[y]||l.call(this,y,null,{dir:!0,createFolders:C}),this.files[y]};function j(y){return Object.prototype.toString.call(y)==="[object RegExp]"}var k={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(y){var C,N,M;for(C in this.files)M=this.files[C],(N=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&y(N,M)},filter:function(y){var C=[];return this.forEach(function(N,M){y(N,M)&&C.push(M)}),C},file:function(y,C,N){if(arguments.length!==1)return y=this.root+y,l.call(this,y,C,N),this;if(j(y)){var M=y;return this.filter(function(T,V){return!V.dir&&M.test(T)})}var $=this.files[this.root+y];return $&&!$.dir?$:null},folder:function(y){if(!y)return this;if(j(y))return this.filter(function($,T){return T.dir&&y.test($)});var C=this.root+y,N=w.call(this,C),M=this.clone();return M.root=N.name,M},remove:function(y){y=this.root+y;var C=this.files[y];if(C||(y.slice(-1)!=="/"&&(y+="/"),C=this.files[y]),C&&!C.dir)delete this.files[y];else for(var N=this.filter(function($,T){return T.name.slice(0,y.length)===y}),M=0;M<N.length;M++)delete this.files[N[M].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(y){var C,N={};try{if((N=c.extend(y||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:i.utf8encode})).type=N.type.toLowerCase(),N.compression=N.compression.toUpperCase(),N.type==="binarystring"&&(N.type="string"),!N.type)throw new Error("No output type specified.");c.checkSupport(N.type),N.platform!=="darwin"&&N.platform!=="freebsd"&&N.platform!=="linux"&&N.platform!=="sunos"||(N.platform="UNIX"),N.platform==="win32"&&(N.platform="DOS");var M=N.comment||this.comment||"";C=p.generateWorker(this,N,M)}catch($){(C=new u("error")).error($)}return new d(C,N.type||"string",N.mimeType)},generateAsync:function(y,C){return this.generateInternalStream(y).accumulate(C)},generateNodeStream:function(y,C){return(y=y||{}).type||(y.type="nodebuffer"),this.generateInternalStream(y).toNodejsStream(C)}};n.exports=k},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(r,n,o){n.exports=r("stream")},{stream:void 0}],17:[function(r,n,o){var l=r("./DataReader");function i(c){l.call(this,c);for(var u=0;u<this.data.length;u++)c[u]=255&c[u]}r("../utils").inherits(i,l),i.prototype.byteAt=function(c){return this.data[this.zero+c]},i.prototype.lastIndexOfSignature=function(c){for(var u=c.charCodeAt(0),d=c.charCodeAt(1),m=c.charCodeAt(2),f=c.charCodeAt(3),h=this.length-4;0<=h;--h)if(this.data[h]===u&&this.data[h+1]===d&&this.data[h+2]===m&&this.data[h+3]===f)return h-this.zero;return-1},i.prototype.readAndCheckSignature=function(c){var u=c.charCodeAt(0),d=c.charCodeAt(1),m=c.charCodeAt(2),f=c.charCodeAt(3),h=this.readData(4);return u===h[0]&&d===h[1]&&m===h[2]&&f===h[3]},i.prototype.readData=function(c){if(this.checkOffset(c),c===0)return[];var u=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,u},n.exports=i},{"../utils":32,"./DataReader":18}],18:[function(r,n,o){var l=r("../utils");function i(c){this.data=c,this.length=c.length,this.index=0,this.zero=0}i.prototype={checkOffset:function(c){this.checkIndex(this.index+c)},checkIndex:function(c){if(this.length<this.zero+c||c<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+c+"). Corrupted zip ?")},setIndex:function(c){this.checkIndex(c),this.index=c},skip:function(c){this.setIndex(this.index+c)},byteAt:function(){},readInt:function(c){var u,d=0;for(this.checkOffset(c),u=this.index+c-1;u>=this.index;u--)d=(d<<8)+this.byteAt(u);return this.index+=c,d},readString:function(c){return l.transformTo("string",this.readData(c))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var c=this.readInt(4);return new Date(Date.UTC(1980+(c>>25&127),(c>>21&15)-1,c>>16&31,c>>11&31,c>>5&63,(31&c)<<1))}},n.exports=i},{"../utils":32}],19:[function(r,n,o){var l=r("./Uint8ArrayReader");function i(c){l.call(this,c)}r("../utils").inherits(i,l),i.prototype.readData=function(c){this.checkOffset(c);var u=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,u},n.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,n,o){var l=r("./DataReader");function i(c){l.call(this,c)}r("../utils").inherits(i,l),i.prototype.byteAt=function(c){return this.data.charCodeAt(this.zero+c)},i.prototype.lastIndexOfSignature=function(c){return this.data.lastIndexOf(c)-this.zero},i.prototype.readAndCheckSignature=function(c){return c===this.readData(4)},i.prototype.readData=function(c){this.checkOffset(c);var u=this.data.slice(this.zero+this.index,this.zero+this.index+c);return this.index+=c,u},n.exports=i},{"../utils":32,"./DataReader":18}],21:[function(r,n,o){var l=r("./ArrayReader");function i(c){l.call(this,c)}r("../utils").inherits(i,l),i.prototype.readData=function(c){if(this.checkOffset(c),c===0)return new Uint8Array(0);var u=this.data.subarray(this.zero+this.index,this.zero+this.index+c);return this.index+=c,u},n.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,o){var l=r("../utils"),i=r("../support"),c=r("./ArrayReader"),u=r("./StringReader"),d=r("./NodeBufferReader"),m=r("./Uint8ArrayReader");n.exports=function(f){var h=l.getTypeOf(f);return l.checkSupport(h),h!=="string"||i.uint8array?h==="nodebuffer"?new d(f):i.uint8array?new m(l.transformTo("uint8array",f)):new c(l.transformTo("array",f)):new u(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,n,o){o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,n,o){var l=r("./GenericWorker"),i=r("../utils");function c(u){l.call(this,"ConvertWorker to "+u),this.destType=u}i.inherits(c,l),c.prototype.processChunk=function(u){this.push({data:i.transformTo(this.destType,u.data),meta:u.meta})},n.exports=c},{"../utils":32,"./GenericWorker":28}],25:[function(r,n,o){var l=r("./GenericWorker"),i=r("../crc32");function c(){l.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(c,l),c.prototype.processChunk=function(u){this.streamInfo.crc32=i(u.data,this.streamInfo.crc32||0),this.push(u)},n.exports=c},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,o){var l=r("../utils"),i=r("./GenericWorker");function c(u){i.call(this,"DataLengthProbe for "+u),this.propName=u,this.withStreamInfo(u,0)}l.inherits(c,i),c.prototype.processChunk=function(u){if(u){var d=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=d+u.data.length}i.prototype.processChunk.call(this,u)},n.exports=c},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,o){var l=r("../utils"),i=r("./GenericWorker");function c(u){i.call(this,"DataWorker");var d=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,u.then(function(m){d.dataIsReady=!0,d.data=m,d.max=m&&m.length||0,d.type=l.getTypeOf(m),d.isPaused||d._tickAndRepeat()},function(m){d.error(m)})}l.inherits(c,i),c.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},c.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,l.delay(this._tickAndRepeat,[],this)),!0)},c.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(l.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},c.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var u=null,d=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":u=this.data.substring(this.index,d);break;case"uint8array":u=this.data.subarray(this.index,d);break;case"array":case"nodebuffer":u=this.data.slice(this.index,d)}return this.index=d,this.push({data:u,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=c},{"../utils":32,"./GenericWorker":28}],28:[function(r,n,o){function l(i){this.name=i||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}l.prototype={push:function(i){this.emit("data",i)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(i){this.emit("error",i)}return!0},error:function(i){return!this.isFinished&&(this.isPaused?this.generatedError=i:(this.isFinished=!0,this.emit("error",i),this.previous&&this.previous.error(i),this.cleanUp()),!0)},on:function(i,c){return this._listeners[i].push(c),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(i,c){if(this._listeners[i])for(var u=0;u<this._listeners[i].length;u++)this._listeners[i][u].call(this,c)},pipe:function(i){return i.registerPrevious(this)},registerPrevious:function(i){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=i.streamInfo,this.mergeStreamInfo(),this.previous=i;var c=this;return i.on("data",function(u){c.processChunk(u)}),i.on("end",function(){c.end()}),i.on("error",function(u){c.error(u)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var i=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),i=!0),this.previous&&this.previous.resume(),!i},flush:function(){},processChunk:function(i){this.push(i)},withStreamInfo:function(i,c){return this.extraStreamInfo[i]=c,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var i in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,i)&&(this.streamInfo[i]=this.extraStreamInfo[i])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var i="Worker "+this.name;return this.previous?this.previous+" -> "+i:i}},n.exports=l},{}],29:[function(r,n,o){var l=r("../utils"),i=r("./ConvertWorker"),c=r("./GenericWorker"),u=r("../base64"),d=r("../support"),m=r("../external"),f=null;if(d.nodestream)try{f=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function h(v,b){return new m.Promise(function(g,x){var w=[],j=v._internalType,k=v._outputType,y=v._mimeType;v.on("data",function(C,N){w.push(C),b&&b(N)}).on("error",function(C){w=[],x(C)}).on("end",function(){try{var C=(function(N,M,$){switch(N){case"blob":return l.newBlob(l.transformTo("arraybuffer",M),$);case"base64":return u.encode(M);default:return l.transformTo(N,M)}})(k,(function(N,M){var $,T=0,V=null,I=0;for($=0;$<M.length;$++)I+=M[$].length;switch(N){case"string":return M.join("");case"array":return Array.prototype.concat.apply([],M);case"uint8array":for(V=new Uint8Array(I),$=0;$<M.length;$++)V.set(M[$],T),T+=M[$].length;return V;case"nodebuffer":return Buffer.concat(M);default:throw new Error("concat : unsupported type '"+N+"'")}})(j,w),y);g(C)}catch(N){x(N)}w=[]}).resume()})}function p(v,b,g){var x=b;switch(b){case"blob":case"arraybuffer":x="uint8array";break;case"base64":x="string"}try{this._internalType=x,this._outputType=b,this._mimeType=g,l.checkSupport(x),this._worker=v.pipe(new i(x)),v.lock()}catch(w){this._worker=new c("error"),this._worker.error(w)}}p.prototype={accumulate:function(v){return h(this,v)},on:function(v,b){var g=this;return v==="data"?this._worker.on(v,function(x){b.call(g,x.data,x.meta)}):this._worker.on(v,function(){l.delay(b,arguments,g)}),this},resume:function(){return l.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(v){if(l.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},v)}},n.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(r,n,o){if(o.base64=!0,o.array=!0,o.string=!0,o.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",o.nodebuffer=typeof Buffer<"u",o.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")o.blob=!1;else{var l=new ArrayBuffer(0);try{o.blob=new Blob([l],{type:"application/zip"}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(l),o.blob=i.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!r("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(r,n,o){for(var l=r("./utils"),i=r("./support"),c=r("./nodejsUtils"),u=r("./stream/GenericWorker"),d=new Array(256),m=0;m<256;m++)d[m]=252<=m?6:248<=m?5:240<=m?4:224<=m?3:192<=m?2:1;d[254]=d[254]=1;function f(){u.call(this,"utf-8 decode"),this.leftOver=null}function h(){u.call(this,"utf-8 encode")}o.utf8encode=function(p){return i.nodebuffer?c.newBufferFrom(p,"utf-8"):(function(v){var b,g,x,w,j,k=v.length,y=0;for(w=0;w<k;w++)(64512&(g=v.charCodeAt(w)))==55296&&w+1<k&&(64512&(x=v.charCodeAt(w+1)))==56320&&(g=65536+(g-55296<<10)+(x-56320),w++),y+=g<128?1:g<2048?2:g<65536?3:4;for(b=i.uint8array?new Uint8Array(y):new Array(y),w=j=0;j<y;w++)(64512&(g=v.charCodeAt(w)))==55296&&w+1<k&&(64512&(x=v.charCodeAt(w+1)))==56320&&(g=65536+(g-55296<<10)+(x-56320),w++),g<128?b[j++]=g:(g<2048?b[j++]=192|g>>>6:(g<65536?b[j++]=224|g>>>12:(b[j++]=240|g>>>18,b[j++]=128|g>>>12&63),b[j++]=128|g>>>6&63),b[j++]=128|63&g);return b})(p)},o.utf8decode=function(p){return i.nodebuffer?l.transformTo("nodebuffer",p).toString("utf-8"):(function(v){var b,g,x,w,j=v.length,k=new Array(2*j);for(b=g=0;b<j;)if((x=v[b++])<128)k[g++]=x;else if(4<(w=d[x]))k[g++]=65533,b+=w-1;else{for(x&=w===2?31:w===3?15:7;1<w&&b<j;)x=x<<6|63&v[b++],w--;1<w?k[g++]=65533:x<65536?k[g++]=x:(x-=65536,k[g++]=55296|x>>10&1023,k[g++]=56320|1023&x)}return k.length!==g&&(k.subarray?k=k.subarray(0,g):k.length=g),l.applyFromCharCode(k)})(p=l.transformTo(i.uint8array?"uint8array":"array",p))},l.inherits(f,u),f.prototype.processChunk=function(p){var v=l.transformTo(i.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var b=v;(v=new Uint8Array(b.length+this.leftOver.length)).set(this.leftOver,0),v.set(b,this.leftOver.length)}else v=this.leftOver.concat(v);this.leftOver=null}var g=(function(w,j){var k;for((j=j||w.length)>w.length&&(j=w.length),k=j-1;0<=k&&(192&w[k])==128;)k--;return k<0||k===0?j:k+d[w[k]]>j?k:j})(v),x=v;g!==v.length&&(i.uint8array?(x=v.subarray(0,g),this.leftOver=v.subarray(g,v.length)):(x=v.slice(0,g),this.leftOver=v.slice(g,v.length))),this.push({data:o.utf8decode(x),meta:p.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=f,l.inherits(h,u),h.prototype.processChunk=function(p){this.push({data:o.utf8encode(p.data),meta:p.meta})},o.Utf8EncodeWorker=h},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,n,o){var l=r("./support"),i=r("./base64"),c=r("./nodejsUtils"),u=r("./external");function d(b){return b}function m(b,g){for(var x=0;x<b.length;++x)g[x]=255&b.charCodeAt(x);return g}r("setimmediate"),o.newBlob=function(b,g){o.checkSupport("blob");try{return new Blob([b],{type:g})}catch{try{var x=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return x.append(b),x.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(b,g,x){var w=[],j=0,k=b.length;if(k<=x)return String.fromCharCode.apply(null,b);for(;j<k;)g==="array"||g==="nodebuffer"?w.push(String.fromCharCode.apply(null,b.slice(j,Math.min(j+x,k)))):w.push(String.fromCharCode.apply(null,b.subarray(j,Math.min(j+x,k)))),j+=x;return w.join("")},stringifyByChar:function(b){for(var g="",x=0;x<b.length;x++)g+=String.fromCharCode(b[x]);return g},applyCanBeUsed:{uint8array:(function(){try{return l.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return l.nodebuffer&&String.fromCharCode.apply(null,c.allocBuffer(1)).length===1}catch{return!1}})()}};function h(b){var g=65536,x=o.getTypeOf(b),w=!0;if(x==="uint8array"?w=f.applyCanBeUsed.uint8array:x==="nodebuffer"&&(w=f.applyCanBeUsed.nodebuffer),w)for(;1<g;)try{return f.stringifyByChunk(b,x,g)}catch{g=Math.floor(g/2)}return f.stringifyByChar(b)}function p(b,g){for(var x=0;x<b.length;x++)g[x]=b[x];return g}o.applyFromCharCode=h;var v={};v.string={string:d,array:function(b){return m(b,new Array(b.length))},arraybuffer:function(b){return v.string.uint8array(b).buffer},uint8array:function(b){return m(b,new Uint8Array(b.length))},nodebuffer:function(b){return m(b,c.allocBuffer(b.length))}},v.array={string:h,array:d,arraybuffer:function(b){return new Uint8Array(b).buffer},uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return c.newBufferFrom(b)}},v.arraybuffer={string:function(b){return h(new Uint8Array(b))},array:function(b){return p(new Uint8Array(b),new Array(b.byteLength))},arraybuffer:d,uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return c.newBufferFrom(new Uint8Array(b))}},v.uint8array={string:h,array:function(b){return p(b,new Array(b.length))},arraybuffer:function(b){return b.buffer},uint8array:d,nodebuffer:function(b){return c.newBufferFrom(b)}},v.nodebuffer={string:h,array:function(b){return p(b,new Array(b.length))},arraybuffer:function(b){return v.nodebuffer.uint8array(b).buffer},uint8array:function(b){return p(b,new Uint8Array(b.length))},nodebuffer:d},o.transformTo=function(b,g){if(g=g||"",!b)return g;o.checkSupport(b);var x=o.getTypeOf(g);return v[x][b](g)},o.resolve=function(b){for(var g=b.split("/"),x=[],w=0;w<g.length;w++){var j=g[w];j==="."||j===""&&w!==0&&w!==g.length-1||(j===".."?x.pop():x.push(j))}return x.join("/")},o.getTypeOf=function(b){return typeof b=="string"?"string":Object.prototype.toString.call(b)==="[object Array]"?"array":l.nodebuffer&&c.isBuffer(b)?"nodebuffer":l.uint8array&&b instanceof Uint8Array?"uint8array":l.arraybuffer&&b instanceof ArrayBuffer?"arraybuffer":void 0},o.checkSupport=function(b){if(!l[b.toLowerCase()])throw new Error(b+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(b){var g,x,w="";for(x=0;x<(b||"").length;x++)w+="\\x"+((g=b.charCodeAt(x))<16?"0":"")+g.toString(16).toUpperCase();return w},o.delay=function(b,g,x){setImmediate(function(){b.apply(x||null,g||[])})},o.inherits=function(b,g){function x(){}x.prototype=g.prototype,b.prototype=new x},o.extend=function(){var b,g,x={};for(b=0;b<arguments.length;b++)for(g in arguments[b])Object.prototype.hasOwnProperty.call(arguments[b],g)&&x[g]===void 0&&(x[g]=arguments[b][g]);return x},o.prepareContent=function(b,g,x,w,j){return u.Promise.resolve(g).then(function(k){return l.blob&&(k instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(k))!==-1)&&typeof FileReader<"u"?new u.Promise(function(y,C){var N=new FileReader;N.onload=function(M){y(M.target.result)},N.onerror=function(M){C(M.target.error)},N.readAsArrayBuffer(k)}):k}).then(function(k){var y=o.getTypeOf(k);return y?(y==="arraybuffer"?k=o.transformTo("uint8array",k):y==="string"&&(j?k=i.decode(k):x&&w!==!0&&(k=(function(C){return m(C,l.uint8array?new Uint8Array(C.length):new Array(C.length))})(k))),k):u.Promise.reject(new Error("Can't read the data of '"+b+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(r,n,o){var l=r("./reader/readerFor"),i=r("./utils"),c=r("./signature"),u=r("./zipEntry"),d=r("./support");function m(f){this.files=[],this.loadOptions=f}m.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var h=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+i.pretty(h)+", expected "+i.pretty(f)+")")}},isSignature:function(f,h){var p=this.reader.index;this.reader.setIndex(f);var v=this.reader.readString(4)===h;return this.reader.setIndex(p),v},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),h=d.uint8array?"uint8array":"array",p=i.transformTo(h,f);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,h,p,v=this.zip64EndOfCentralSize-44;0<v;)f=this.reader.readInt(2),h=this.reader.readInt(4),p=this.reader.readData(h),this.zip64ExtensibleData[f]={id:f,length:h,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,h;for(f=0;f<this.files.length;f++)h=this.files[f],this.reader.setIndex(h.localHeaderOffset),this.checkSignature(c.LOCAL_FILE_HEADER),h.readLocalPart(this.reader),h.handleUTF8(),h.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(c.CENTRAL_FILE_HEADER);)(f=new u({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(c.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,c.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var h=f;if(this.checkSignature(c.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===i.MAX_VALUE_16BITS||this.diskWithCentralDirStart===i.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===i.MAX_VALUE_16BITS||this.centralDirRecords===i.MAX_VALUE_16BITS||this.centralDirSize===i.MAX_VALUE_32BITS||this.centralDirOffset===i.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(c.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,c.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(c.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(c.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var v=h-p;if(0<v)this.isSignature(h,c.CENTRAL_FILE_HEADER)||(this.reader.zero=v);else if(v<0)throw new Error("Corrupted zip: missing "+Math.abs(v)+" bytes.")},prepareReader:function(f){this.reader=l(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=m},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(r,n,o){var l=r("./reader/readerFor"),i=r("./utils"),c=r("./compressedObject"),u=r("./crc32"),d=r("./utf8"),m=r("./compressions"),f=r("./support");function h(p,v){this.options=p,this.loadOptions=v}h.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var v,b;if(p.skip(22),this.fileNameLength=p.readInt(2),b=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(b),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((v=(function(g){for(var x in m)if(Object.prototype.hasOwnProperty.call(m,x)&&m[x].magic===g)return m[x];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+i.pretty(this.compressionMethod)+" unknown (inner file : "+i.transformTo("string",this.fileName)+")");this.decompressed=new c(this.compressedSize,this.uncompressedSize,this.crc32,v,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var v=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(v),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=l(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var v,b,g,x=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<x;)v=p.readInt(2),b=p.readInt(2),g=p.readData(b),this.extraFields[v]={id:v,length:b,value:g};p.setIndex(x)},handleUTF8:function(){var p=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=d.utf8decode(this.fileName),this.fileCommentStr=d.utf8decode(this.fileComment);else{var v=this.findExtraFieldUnicodePath();if(v!==null)this.fileNameStr=v;else{var b=i.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(b)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var x=i.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(x)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var v=l(p.value);return v.readInt(1)!==1||u(this.fileName)!==v.readInt(4)?null:d.utf8decode(v.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var v=l(p.value);return v.readInt(1)!==1||u(this.fileComment)!==v.readInt(4)?null:d.utf8decode(v.readData(p.length-5))}return null}},n.exports=h},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(r,n,o){function l(v,b,g){this.name=v,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=b,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var i=r("./stream/StreamHelper"),c=r("./stream/DataWorker"),u=r("./utf8"),d=r("./compressedObject"),m=r("./stream/GenericWorker");l.prototype={internalStream:function(v){var b=null,g="string";try{if(!v)throw new Error("No output type specified.");var x=(g=v.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),b=this._decompressWorker();var w=!this._dataBinary;w&&!x&&(b=b.pipe(new u.Utf8EncodeWorker)),!w&&x&&(b=b.pipe(new u.Utf8DecodeWorker))}catch(j){(b=new m("error")).error(j)}return new i(b,g,"")},async:function(v,b){return this.internalStream(v).accumulate(b)},nodeStream:function(v,b){return this.internalStream(v||"nodebuffer").toNodejsStream(b)},_compressWorker:function(v,b){if(this._data instanceof d&&this._data.compression.magic===v.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new u.Utf8EncodeWorker)),d.createWorkerFrom(g,v,b)},_decompressWorker:function(){return this._data instanceof d?this._data.getContentWorker():this._data instanceof m?this._data:new c(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],h=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<f.length;p++)l.prototype[f[p]]=h;n.exports=l},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(r,n,o){(function(l){var i,c,u=l.MutationObserver||l.WebKitMutationObserver;if(u){var d=0,m=new u(v),f=l.document.createTextNode("");m.observe(f,{characterData:!0}),i=function(){f.data=d=++d%2}}else if(l.setImmediate||l.MessageChannel===void 0)i="document"in l&&"onreadystatechange"in l.document.createElement("script")?function(){var b=l.document.createElement("script");b.onreadystatechange=function(){v(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},l.document.documentElement.appendChild(b)}:function(){setTimeout(v,0)};else{var h=new l.MessageChannel;h.port1.onmessage=v,i=function(){h.port2.postMessage(0)}}var p=[];function v(){var b,g;c=!0;for(var x=p.length;x;){for(g=p,p=[],b=-1;++b<x;)g[b]();x=p.length}c=!1}n.exports=function(b){p.push(b)!==1||c||i()}}).call(this,typeof jr<"u"?jr:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(r,n,o){var l=r("immediate");function i(){}var c={},u=["REJECTED"],d=["FULFILLED"],m=["PENDING"];function f(x){if(typeof x!="function")throw new TypeError("resolver must be a function");this.state=m,this.queue=[],this.outcome=void 0,x!==i&&b(this,x)}function h(x,w,j){this.promise=x,typeof w=="function"&&(this.onFulfilled=w,this.callFulfilled=this.otherCallFulfilled),typeof j=="function"&&(this.onRejected=j,this.callRejected=this.otherCallRejected)}function p(x,w,j){l(function(){var k;try{k=w(j)}catch(y){return c.reject(x,y)}k===x?c.reject(x,new TypeError("Cannot resolve promise with itself")):c.resolve(x,k)})}function v(x){var w=x&&x.then;if(x&&(typeof x=="object"||typeof x=="function")&&typeof w=="function")return function(){w.apply(x,arguments)}}function b(x,w){var j=!1;function k(N){j||(j=!0,c.reject(x,N))}function y(N){j||(j=!0,c.resolve(x,N))}var C=g(function(){w(y,k)});C.status==="error"&&k(C.value)}function g(x,w){var j={};try{j.value=x(w),j.status="success"}catch(k){j.status="error",j.value=k}return j}(n.exports=f).prototype.finally=function(x){if(typeof x!="function")return this;var w=this.constructor;return this.then(function(j){return w.resolve(x()).then(function(){return j})},function(j){return w.resolve(x()).then(function(){throw j})})},f.prototype.catch=function(x){return this.then(null,x)},f.prototype.then=function(x,w){if(typeof x!="function"&&this.state===d||typeof w!="function"&&this.state===u)return this;var j=new this.constructor(i);return this.state!==m?p(j,this.state===d?x:w,this.outcome):this.queue.push(new h(j,x,w)),j},h.prototype.callFulfilled=function(x){c.resolve(this.promise,x)},h.prototype.otherCallFulfilled=function(x){p(this.promise,this.onFulfilled,x)},h.prototype.callRejected=function(x){c.reject(this.promise,x)},h.prototype.otherCallRejected=function(x){p(this.promise,this.onRejected,x)},c.resolve=function(x,w){var j=g(v,w);if(j.status==="error")return c.reject(x,j.value);var k=j.value;if(k)b(x,k);else{x.state=d,x.outcome=w;for(var y=-1,C=x.queue.length;++y<C;)x.queue[y].callFulfilled(w)}return x},c.reject=function(x,w){x.state=u,x.outcome=w;for(var j=-1,k=x.queue.length;++j<k;)x.queue[j].callRejected(w);return x},f.resolve=function(x){return x instanceof this?x:c.resolve(new this(i),x)},f.reject=function(x){var w=new this(i);return c.reject(w,x)},f.all=function(x){var w=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var j=x.length,k=!1;if(!j)return this.resolve([]);for(var y=new Array(j),C=0,N=-1,M=new this(i);++N<j;)$(x[N],N);return M;function $(T,V){w.resolve(T).then(function(I){y[V]=I,++C!==j||k||(k=!0,c.resolve(M,y))},function(I){k||(k=!0,c.reject(M,I))})}},f.race=function(x){var w=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var j=x.length,k=!1;if(!j)return this.resolve([]);for(var y=-1,C=new this(i);++y<j;)N=x[y],w.resolve(N).then(function(M){k||(k=!0,c.resolve(C,M))},function(M){k||(k=!0,c.reject(C,M))});var N;return C}},{immediate:36}],38:[function(r,n,o){var l={};(0,r("./lib/utils/common").assign)(l,r("./lib/deflate"),r("./lib/inflate"),r("./lib/zlib/constants")),n.exports=l},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(r,n,o){var l=r("./zlib/deflate"),i=r("./utils/common"),c=r("./utils/strings"),u=r("./zlib/messages"),d=r("./zlib/zstream"),m=Object.prototype.toString,f=0,h=-1,p=0,v=8;function b(x){if(!(this instanceof b))return new b(x);this.options=i.assign({level:h,method:v,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},x||{});var w=this.options;w.raw&&0<w.windowBits?w.windowBits=-w.windowBits:w.gzip&&0<w.windowBits&&w.windowBits<16&&(w.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var j=l.deflateInit2(this.strm,w.level,w.method,w.windowBits,w.memLevel,w.strategy);if(j!==f)throw new Error(u[j]);if(w.header&&l.deflateSetHeader(this.strm,w.header),w.dictionary){var k;if(k=typeof w.dictionary=="string"?c.string2buf(w.dictionary):m.call(w.dictionary)==="[object ArrayBuffer]"?new Uint8Array(w.dictionary):w.dictionary,(j=l.deflateSetDictionary(this.strm,k))!==f)throw new Error(u[j]);this._dict_set=!0}}function g(x,w){var j=new b(w);if(j.push(x,!0),j.err)throw j.msg||u[j.err];return j.result}b.prototype.push=function(x,w){var j,k,y=this.strm,C=this.options.chunkSize;if(this.ended)return!1;k=w===~~w?w:w===!0?4:0,typeof x=="string"?y.input=c.string2buf(x):m.call(x)==="[object ArrayBuffer]"?y.input=new Uint8Array(x):y.input=x,y.next_in=0,y.avail_in=y.input.length;do{if(y.avail_out===0&&(y.output=new i.Buf8(C),y.next_out=0,y.avail_out=C),(j=l.deflate(y,k))!==1&&j!==f)return this.onEnd(j),!(this.ended=!0);y.avail_out!==0&&(y.avail_in!==0||k!==4&&k!==2)||(this.options.to==="string"?this.onData(c.buf2binstring(i.shrinkBuf(y.output,y.next_out))):this.onData(i.shrinkBuf(y.output,y.next_out)))}while((0<y.avail_in||y.avail_out===0)&&j!==1);return k===4?(j=l.deflateEnd(this.strm),this.onEnd(j),this.ended=!0,j===f):k!==2||(this.onEnd(f),!(y.avail_out=0))},b.prototype.onData=function(x){this.chunks.push(x)},b.prototype.onEnd=function(x){x===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},o.Deflate=b,o.deflate=g,o.deflateRaw=function(x,w){return(w=w||{}).raw=!0,g(x,w)},o.gzip=function(x,w){return(w=w||{}).gzip=!0,g(x,w)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(r,n,o){var l=r("./zlib/inflate"),i=r("./utils/common"),c=r("./utils/strings"),u=r("./zlib/constants"),d=r("./zlib/messages"),m=r("./zlib/zstream"),f=r("./zlib/gzheader"),h=Object.prototype.toString;function p(b){if(!(this instanceof p))return new p(b);this.options=i.assign({chunkSize:16384,windowBits:0,to:""},b||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||b&&b.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new m,this.strm.avail_out=0;var x=l.inflateInit2(this.strm,g.windowBits);if(x!==u.Z_OK)throw new Error(d[x]);this.header=new f,l.inflateGetHeader(this.strm,this.header)}function v(b,g){var x=new p(g);if(x.push(b,!0),x.err)throw x.msg||d[x.err];return x.result}p.prototype.push=function(b,g){var x,w,j,k,y,C,N=this.strm,M=this.options.chunkSize,$=this.options.dictionary,T=!1;if(this.ended)return!1;w=g===~~g?g:g===!0?u.Z_FINISH:u.Z_NO_FLUSH,typeof b=="string"?N.input=c.binstring2buf(b):h.call(b)==="[object ArrayBuffer]"?N.input=new Uint8Array(b):N.input=b,N.next_in=0,N.avail_in=N.input.length;do{if(N.avail_out===0&&(N.output=new i.Buf8(M),N.next_out=0,N.avail_out=M),(x=l.inflate(N,u.Z_NO_FLUSH))===u.Z_NEED_DICT&&$&&(C=typeof $=="string"?c.string2buf($):h.call($)==="[object ArrayBuffer]"?new Uint8Array($):$,x=l.inflateSetDictionary(this.strm,C)),x===u.Z_BUF_ERROR&&T===!0&&(x=u.Z_OK,T=!1),x!==u.Z_STREAM_END&&x!==u.Z_OK)return this.onEnd(x),!(this.ended=!0);N.next_out&&(N.avail_out!==0&&x!==u.Z_STREAM_END&&(N.avail_in!==0||w!==u.Z_FINISH&&w!==u.Z_SYNC_FLUSH)||(this.options.to==="string"?(j=c.utf8border(N.output,N.next_out),k=N.next_out-j,y=c.buf2string(N.output,j),N.next_out=k,N.avail_out=M-k,k&&i.arraySet(N.output,N.output,j,k,0),this.onData(y)):this.onData(i.shrinkBuf(N.output,N.next_out)))),N.avail_in===0&&N.avail_out===0&&(T=!0)}while((0<N.avail_in||N.avail_out===0)&&x!==u.Z_STREAM_END);return x===u.Z_STREAM_END&&(w=u.Z_FINISH),w===u.Z_FINISH?(x=l.inflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===u.Z_OK):w!==u.Z_SYNC_FLUSH||(this.onEnd(u.Z_OK),!(N.avail_out=0))},p.prototype.onData=function(b){this.chunks.push(b)},p.prototype.onEnd=function(b){b===u.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},o.Inflate=p,o.inflate=v,o.inflateRaw=function(b,g){return(g=g||{}).raw=!0,v(b,g)},o.ungzip=v},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(r,n,o){var l=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";o.assign=function(u){for(var d=Array.prototype.slice.call(arguments,1);d.length;){var m=d.shift();if(m){if(typeof m!="object")throw new TypeError(m+"must be non-object");for(var f in m)m.hasOwnProperty(f)&&(u[f]=m[f])}}return u},o.shrinkBuf=function(u,d){return u.length===d?u:u.subarray?u.subarray(0,d):(u.length=d,u)};var i={arraySet:function(u,d,m,f,h){if(d.subarray&&u.subarray)u.set(d.subarray(m,m+f),h);else for(var p=0;p<f;p++)u[h+p]=d[m+p]},flattenChunks:function(u){var d,m,f,h,p,v;for(d=f=0,m=u.length;d<m;d++)f+=u[d].length;for(v=new Uint8Array(f),d=h=0,m=u.length;d<m;d++)p=u[d],v.set(p,h),h+=p.length;return v}},c={arraySet:function(u,d,m,f,h){for(var p=0;p<f;p++)u[h+p]=d[m+p]},flattenChunks:function(u){return[].concat.apply([],u)}};o.setTyped=function(u){u?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,i)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,c))},o.setTyped(l)},{}],42:[function(r,n,o){var l=r("./common"),i=!0,c=!0;try{String.fromCharCode.apply(null,[0])}catch{i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{c=!1}for(var u=new l.Buf8(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;function m(f,h){if(h<65537&&(f.subarray&&c||!f.subarray&&i))return String.fromCharCode.apply(null,l.shrinkBuf(f,h));for(var p="",v=0;v<h;v++)p+=String.fromCharCode(f[v]);return p}u[254]=u[254]=1,o.string2buf=function(f){var h,p,v,b,g,x=f.length,w=0;for(b=0;b<x;b++)(64512&(p=f.charCodeAt(b)))==55296&&b+1<x&&(64512&(v=f.charCodeAt(b+1)))==56320&&(p=65536+(p-55296<<10)+(v-56320),b++),w+=p<128?1:p<2048?2:p<65536?3:4;for(h=new l.Buf8(w),b=g=0;g<w;b++)(64512&(p=f.charCodeAt(b)))==55296&&b+1<x&&(64512&(v=f.charCodeAt(b+1)))==56320&&(p=65536+(p-55296<<10)+(v-56320),b++),p<128?h[g++]=p:(p<2048?h[g++]=192|p>>>6:(p<65536?h[g++]=224|p>>>12:(h[g++]=240|p>>>18,h[g++]=128|p>>>12&63),h[g++]=128|p>>>6&63),h[g++]=128|63&p);return h},o.buf2binstring=function(f){return m(f,f.length)},o.binstring2buf=function(f){for(var h=new l.Buf8(f.length),p=0,v=h.length;p<v;p++)h[p]=f.charCodeAt(p);return h},o.buf2string=function(f,h){var p,v,b,g,x=h||f.length,w=new Array(2*x);for(p=v=0;p<x;)if((b=f[p++])<128)w[v++]=b;else if(4<(g=u[b]))w[v++]=65533,p+=g-1;else{for(b&=g===2?31:g===3?15:7;1<g&&p<x;)b=b<<6|63&f[p++],g--;1<g?w[v++]=65533:b<65536?w[v++]=b:(b-=65536,w[v++]=55296|b>>10&1023,w[v++]=56320|1023&b)}return m(w,v)},o.utf8border=function(f,h){var p;for((h=h||f.length)>f.length&&(h=f.length),p=h-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?h:p+u[f[p]]>h?p:h}},{"./common":41}],43:[function(r,n,o){n.exports=function(l,i,c,u){for(var d=65535&l|0,m=l>>>16&65535|0,f=0;c!==0;){for(c-=f=2e3<c?2e3:c;m=m+(d=d+i[u++]|0)|0,--f;);d%=65521,m%=65521}return d|m<<16|0}},{}],44:[function(r,n,o){n.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(r,n,o){var l=(function(){for(var i,c=[],u=0;u<256;u++){i=u;for(var d=0;d<8;d++)i=1&i?3988292384^i>>>1:i>>>1;c[u]=i}return c})();n.exports=function(i,c,u,d){var m=l,f=d+u;i^=-1;for(var h=d;h<f;h++)i=i>>>8^m[255&(i^c[h])];return-1^i}},{}],46:[function(r,n,o){var l,i=r("../utils/common"),c=r("./trees"),u=r("./adler32"),d=r("./crc32"),m=r("./messages"),f=0,h=4,p=0,v=-2,b=-1,g=4,x=2,w=8,j=9,k=286,y=30,C=19,N=2*k+1,M=15,$=3,T=258,V=T+$+1,I=42,z=113,O=1,P=2,Q=3,te=4;function ne(R,J){return R.msg=m[J],J}function ae(R){return(R<<1)-(4<R?9:0)}function W(R){for(var J=R.length;0<=--J;)R[J]=0}function A(R){var J=R.state,H=J.pending;H>R.avail_out&&(H=R.avail_out),H!==0&&(i.arraySet(R.output,J.pending_buf,J.pending_out,H,R.next_out),R.next_out+=H,J.pending_out+=H,R.total_out+=H,R.avail_out-=H,J.pending-=H,J.pending===0&&(J.pending_out=0))}function F(R,J){c._tr_flush_block(R,0<=R.block_start?R.block_start:-1,R.strstart-R.block_start,J),R.block_start=R.strstart,A(R.strm)}function Y(R,J){R.pending_buf[R.pending++]=J}function U(R,J){R.pending_buf[R.pending++]=J>>>8&255,R.pending_buf[R.pending++]=255&J}function ee(R,J){var H,L,S=R.max_chain_length,D=R.strstart,_=R.prev_length,Z=R.nice_match,B=R.strstart>R.w_size-V?R.strstart-(R.w_size-V):0,q=R.window,X=R.w_mask,G=R.prev,K=R.strstart+T,re=q[D+_-1],ie=q[D+_];R.prev_length>=R.good_match&&(S>>=2),Z>R.lookahead&&(Z=R.lookahead);do if(q[(H=J)+_]===ie&&q[H+_-1]===re&&q[H]===q[D]&&q[++H]===q[D+1]){D+=2,H++;do;while(q[++D]===q[++H]&&q[++D]===q[++H]&&q[++D]===q[++H]&&q[++D]===q[++H]&&q[++D]===q[++H]&&q[++D]===q[++H]&&q[++D]===q[++H]&&q[++D]===q[++H]&&D<K);if(L=T-(K-D),D=K-T,_<L){if(R.match_start=J,Z<=(_=L))break;re=q[D+_-1],ie=q[D+_]}}while((J=G[J&X])>B&&--S!=0);return _<=R.lookahead?_:R.lookahead}function le(R){var J,H,L,S,D,_,Z,B,q,X,G=R.w_size;do{if(S=R.window_size-R.lookahead-R.strstart,R.strstart>=G+(G-V)){for(i.arraySet(R.window,R.window,G,G,0),R.match_start-=G,R.strstart-=G,R.block_start-=G,J=H=R.hash_size;L=R.head[--J],R.head[J]=G<=L?L-G:0,--H;);for(J=H=G;L=R.prev[--J],R.prev[J]=G<=L?L-G:0,--H;);S+=G}if(R.strm.avail_in===0)break;if(_=R.strm,Z=R.window,B=R.strstart+R.lookahead,q=S,X=void 0,X=_.avail_in,q<X&&(X=q),H=X===0?0:(_.avail_in-=X,i.arraySet(Z,_.input,_.next_in,X,B),_.state.wrap===1?_.adler=u(_.adler,Z,X,B):_.state.wrap===2&&(_.adler=d(_.adler,Z,X,B)),_.next_in+=X,_.total_in+=X,X),R.lookahead+=H,R.lookahead+R.insert>=$)for(D=R.strstart-R.insert,R.ins_h=R.window[D],R.ins_h=(R.ins_h<<R.hash_shift^R.window[D+1])&R.hash_mask;R.insert&&(R.ins_h=(R.ins_h<<R.hash_shift^R.window[D+$-1])&R.hash_mask,R.prev[D&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=D,D++,R.insert--,!(R.lookahead+R.insert<$)););}while(R.lookahead<V&&R.strm.avail_in!==0)}function ue(R,J){for(var H,L;;){if(R.lookahead<V){if(le(R),R.lookahead<V&&J===f)return O;if(R.lookahead===0)break}if(H=0,R.lookahead>=$&&(R.ins_h=(R.ins_h<<R.hash_shift^R.window[R.strstart+$-1])&R.hash_mask,H=R.prev[R.strstart&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=R.strstart),H!==0&&R.strstart-H<=R.w_size-V&&(R.match_length=ee(R,H)),R.match_length>=$)if(L=c._tr_tally(R,R.strstart-R.match_start,R.match_length-$),R.lookahead-=R.match_length,R.match_length<=R.max_lazy_match&&R.lookahead>=$){for(R.match_length--;R.strstart++,R.ins_h=(R.ins_h<<R.hash_shift^R.window[R.strstart+$-1])&R.hash_mask,H=R.prev[R.strstart&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=R.strstart,--R.match_length!=0;);R.strstart++}else R.strstart+=R.match_length,R.match_length=0,R.ins_h=R.window[R.strstart],R.ins_h=(R.ins_h<<R.hash_shift^R.window[R.strstart+1])&R.hash_mask;else L=c._tr_tally(R,0,R.window[R.strstart]),R.lookahead--,R.strstart++;if(L&&(F(R,!1),R.strm.avail_out===0))return O}return R.insert=R.strstart<$-1?R.strstart:$-1,J===h?(F(R,!0),R.strm.avail_out===0?Q:te):R.last_lit&&(F(R,!1),R.strm.avail_out===0)?O:P}function ge(R,J){for(var H,L,S;;){if(R.lookahead<V){if(le(R),R.lookahead<V&&J===f)return O;if(R.lookahead===0)break}if(H=0,R.lookahead>=$&&(R.ins_h=(R.ins_h<<R.hash_shift^R.window[R.strstart+$-1])&R.hash_mask,H=R.prev[R.strstart&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=R.strstart),R.prev_length=R.match_length,R.prev_match=R.match_start,R.match_length=$-1,H!==0&&R.prev_length<R.max_lazy_match&&R.strstart-H<=R.w_size-V&&(R.match_length=ee(R,H),R.match_length<=5&&(R.strategy===1||R.match_length===$&&4096<R.strstart-R.match_start)&&(R.match_length=$-1)),R.prev_length>=$&&R.match_length<=R.prev_length){for(S=R.strstart+R.lookahead-$,L=c._tr_tally(R,R.strstart-1-R.prev_match,R.prev_length-$),R.lookahead-=R.prev_length-1,R.prev_length-=2;++R.strstart<=S&&(R.ins_h=(R.ins_h<<R.hash_shift^R.window[R.strstart+$-1])&R.hash_mask,H=R.prev[R.strstart&R.w_mask]=R.head[R.ins_h],R.head[R.ins_h]=R.strstart),--R.prev_length!=0;);if(R.match_available=0,R.match_length=$-1,R.strstart++,L&&(F(R,!1),R.strm.avail_out===0))return O}else if(R.match_available){if((L=c._tr_tally(R,0,R.window[R.strstart-1]))&&F(R,!1),R.strstart++,R.lookahead--,R.strm.avail_out===0)return O}else R.match_available=1,R.strstart++,R.lookahead--}return R.match_available&&(L=c._tr_tally(R,0,R.window[R.strstart-1]),R.match_available=0),R.insert=R.strstart<$-1?R.strstart:$-1,J===h?(F(R,!0),R.strm.avail_out===0?Q:te):R.last_lit&&(F(R,!1),R.strm.avail_out===0)?O:P}function ce(R,J,H,L,S){this.good_length=R,this.max_lazy=J,this.nice_length=H,this.max_chain=L,this.func=S}function se(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=w,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(2*N),this.dyn_dtree=new i.Buf16(2*(2*y+1)),this.bl_tree=new i.Buf16(2*(2*C+1)),W(this.dyn_ltree),W(this.dyn_dtree),W(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(M+1),this.heap=new i.Buf16(2*k+1),W(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(2*k+1),W(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function we(R){var J;return R&&R.state?(R.total_in=R.total_out=0,R.data_type=x,(J=R.state).pending=0,J.pending_out=0,J.wrap<0&&(J.wrap=-J.wrap),J.status=J.wrap?I:z,R.adler=J.wrap===2?0:1,J.last_flush=f,c._tr_init(J),p):ne(R,v)}function de(R){var J=we(R);return J===p&&(function(H){H.window_size=2*H.w_size,W(H.head),H.max_lazy_match=l[H.level].max_lazy,H.good_match=l[H.level].good_length,H.nice_match=l[H.level].nice_length,H.max_chain_length=l[H.level].max_chain,H.strstart=0,H.block_start=0,H.lookahead=0,H.insert=0,H.match_length=H.prev_length=$-1,H.match_available=0,H.ins_h=0})(R.state),J}function me(R,J,H,L,S,D){if(!R)return v;var _=1;if(J===b&&(J=6),L<0?(_=0,L=-L):15<L&&(_=2,L-=16),S<1||j<S||H!==w||L<8||15<L||J<0||9<J||D<0||g<D)return ne(R,v);L===8&&(L=9);var Z=new se;return(R.state=Z).strm=R,Z.wrap=_,Z.gzhead=null,Z.w_bits=L,Z.w_size=1<<Z.w_bits,Z.w_mask=Z.w_size-1,Z.hash_bits=S+7,Z.hash_size=1<<Z.hash_bits,Z.hash_mask=Z.hash_size-1,Z.hash_shift=~~((Z.hash_bits+$-1)/$),Z.window=new i.Buf8(2*Z.w_size),Z.head=new i.Buf16(Z.hash_size),Z.prev=new i.Buf16(Z.w_size),Z.lit_bufsize=1<<S+6,Z.pending_buf_size=4*Z.lit_bufsize,Z.pending_buf=new i.Buf8(Z.pending_buf_size),Z.d_buf=1*Z.lit_bufsize,Z.l_buf=3*Z.lit_bufsize,Z.level=J,Z.strategy=D,Z.method=H,de(R)}l=[new ce(0,0,0,0,function(R,J){var H=65535;for(H>R.pending_buf_size-5&&(H=R.pending_buf_size-5);;){if(R.lookahead<=1){if(le(R),R.lookahead===0&&J===f)return O;if(R.lookahead===0)break}R.strstart+=R.lookahead,R.lookahead=0;var L=R.block_start+H;if((R.strstart===0||R.strstart>=L)&&(R.lookahead=R.strstart-L,R.strstart=L,F(R,!1),R.strm.avail_out===0)||R.strstart-R.block_start>=R.w_size-V&&(F(R,!1),R.strm.avail_out===0))return O}return R.insert=0,J===h?(F(R,!0),R.strm.avail_out===0?Q:te):(R.strstart>R.block_start&&(F(R,!1),R.strm.avail_out),O)}),new ce(4,4,8,4,ue),new ce(4,5,16,8,ue),new ce(4,6,32,32,ue),new ce(4,4,16,16,ge),new ce(8,16,32,32,ge),new ce(8,16,128,128,ge),new ce(8,32,128,256,ge),new ce(32,128,258,1024,ge),new ce(32,258,258,4096,ge)],o.deflateInit=function(R,J){return me(R,J,w,15,8,0)},o.deflateInit2=me,o.deflateReset=de,o.deflateResetKeep=we,o.deflateSetHeader=function(R,J){return R&&R.state?R.state.wrap!==2?v:(R.state.gzhead=J,p):v},o.deflate=function(R,J){var H,L,S,D;if(!R||!R.state||5<J||J<0)return R?ne(R,v):v;if(L=R.state,!R.output||!R.input&&R.avail_in!==0||L.status===666&&J!==h)return ne(R,R.avail_out===0?-5:v);if(L.strm=R,H=L.last_flush,L.last_flush=J,L.status===I)if(L.wrap===2)R.adler=0,Y(L,31),Y(L,139),Y(L,8),L.gzhead?(Y(L,(L.gzhead.text?1:0)+(L.gzhead.hcrc?2:0)+(L.gzhead.extra?4:0)+(L.gzhead.name?8:0)+(L.gzhead.comment?16:0)),Y(L,255&L.gzhead.time),Y(L,L.gzhead.time>>8&255),Y(L,L.gzhead.time>>16&255),Y(L,L.gzhead.time>>24&255),Y(L,L.level===9?2:2<=L.strategy||L.level<2?4:0),Y(L,255&L.gzhead.os),L.gzhead.extra&&L.gzhead.extra.length&&(Y(L,255&L.gzhead.extra.length),Y(L,L.gzhead.extra.length>>8&255)),L.gzhead.hcrc&&(R.adler=d(R.adler,L.pending_buf,L.pending,0)),L.gzindex=0,L.status=69):(Y(L,0),Y(L,0),Y(L,0),Y(L,0),Y(L,0),Y(L,L.level===9?2:2<=L.strategy||L.level<2?4:0),Y(L,3),L.status=z);else{var _=w+(L.w_bits-8<<4)<<8;_|=(2<=L.strategy||L.level<2?0:L.level<6?1:L.level===6?2:3)<<6,L.strstart!==0&&(_|=32),_+=31-_%31,L.status=z,U(L,_),L.strstart!==0&&(U(L,R.adler>>>16),U(L,65535&R.adler)),R.adler=1}if(L.status===69)if(L.gzhead.extra){for(S=L.pending;L.gzindex<(65535&L.gzhead.extra.length)&&(L.pending!==L.pending_buf_size||(L.gzhead.hcrc&&L.pending>S&&(R.adler=d(R.adler,L.pending_buf,L.pending-S,S)),A(R),S=L.pending,L.pending!==L.pending_buf_size));)Y(L,255&L.gzhead.extra[L.gzindex]),L.gzindex++;L.gzhead.hcrc&&L.pending>S&&(R.adler=d(R.adler,L.pending_buf,L.pending-S,S)),L.gzindex===L.gzhead.extra.length&&(L.gzindex=0,L.status=73)}else L.status=73;if(L.status===73)if(L.gzhead.name){S=L.pending;do{if(L.pending===L.pending_buf_size&&(L.gzhead.hcrc&&L.pending>S&&(R.adler=d(R.adler,L.pending_buf,L.pending-S,S)),A(R),S=L.pending,L.pending===L.pending_buf_size)){D=1;break}D=L.gzindex<L.gzhead.name.length?255&L.gzhead.name.charCodeAt(L.gzindex++):0,Y(L,D)}while(D!==0);L.gzhead.hcrc&&L.pending>S&&(R.adler=d(R.adler,L.pending_buf,L.pending-S,S)),D===0&&(L.gzindex=0,L.status=91)}else L.status=91;if(L.status===91)if(L.gzhead.comment){S=L.pending;do{if(L.pending===L.pending_buf_size&&(L.gzhead.hcrc&&L.pending>S&&(R.adler=d(R.adler,L.pending_buf,L.pending-S,S)),A(R),S=L.pending,L.pending===L.pending_buf_size)){D=1;break}D=L.gzindex<L.gzhead.comment.length?255&L.gzhead.comment.charCodeAt(L.gzindex++):0,Y(L,D)}while(D!==0);L.gzhead.hcrc&&L.pending>S&&(R.adler=d(R.adler,L.pending_buf,L.pending-S,S)),D===0&&(L.status=103)}else L.status=103;if(L.status===103&&(L.gzhead.hcrc?(L.pending+2>L.pending_buf_size&&A(R),L.pending+2<=L.pending_buf_size&&(Y(L,255&R.adler),Y(L,R.adler>>8&255),R.adler=0,L.status=z)):L.status=z),L.pending!==0){if(A(R),R.avail_out===0)return L.last_flush=-1,p}else if(R.avail_in===0&&ae(J)<=ae(H)&&J!==h)return ne(R,-5);if(L.status===666&&R.avail_in!==0)return ne(R,-5);if(R.avail_in!==0||L.lookahead!==0||J!==f&&L.status!==666){var Z=L.strategy===2?(function(B,q){for(var X;;){if(B.lookahead===0&&(le(B),B.lookahead===0)){if(q===f)return O;break}if(B.match_length=0,X=c._tr_tally(B,0,B.window[B.strstart]),B.lookahead--,B.strstart++,X&&(F(B,!1),B.strm.avail_out===0))return O}return B.insert=0,q===h?(F(B,!0),B.strm.avail_out===0?Q:te):B.last_lit&&(F(B,!1),B.strm.avail_out===0)?O:P})(L,J):L.strategy===3?(function(B,q){for(var X,G,K,re,ie=B.window;;){if(B.lookahead<=T){if(le(B),B.lookahead<=T&&q===f)return O;if(B.lookahead===0)break}if(B.match_length=0,B.lookahead>=$&&0<B.strstart&&(G=ie[K=B.strstart-1])===ie[++K]&&G===ie[++K]&&G===ie[++K]){re=B.strstart+T;do;while(G===ie[++K]&&G===ie[++K]&&G===ie[++K]&&G===ie[++K]&&G===ie[++K]&&G===ie[++K]&&G===ie[++K]&&G===ie[++K]&&K<re);B.match_length=T-(re-K),B.match_length>B.lookahead&&(B.match_length=B.lookahead)}if(B.match_length>=$?(X=c._tr_tally(B,1,B.match_length-$),B.lookahead-=B.match_length,B.strstart+=B.match_length,B.match_length=0):(X=c._tr_tally(B,0,B.window[B.strstart]),B.lookahead--,B.strstart++),X&&(F(B,!1),B.strm.avail_out===0))return O}return B.insert=0,q===h?(F(B,!0),B.strm.avail_out===0?Q:te):B.last_lit&&(F(B,!1),B.strm.avail_out===0)?O:P})(L,J):l[L.level].func(L,J);if(Z!==Q&&Z!==te||(L.status=666),Z===O||Z===Q)return R.avail_out===0&&(L.last_flush=-1),p;if(Z===P&&(J===1?c._tr_align(L):J!==5&&(c._tr_stored_block(L,0,0,!1),J===3&&(W(L.head),L.lookahead===0&&(L.strstart=0,L.block_start=0,L.insert=0))),A(R),R.avail_out===0))return L.last_flush=-1,p}return J!==h?p:L.wrap<=0?1:(L.wrap===2?(Y(L,255&R.adler),Y(L,R.adler>>8&255),Y(L,R.adler>>16&255),Y(L,R.adler>>24&255),Y(L,255&R.total_in),Y(L,R.total_in>>8&255),Y(L,R.total_in>>16&255),Y(L,R.total_in>>24&255)):(U(L,R.adler>>>16),U(L,65535&R.adler)),A(R),0<L.wrap&&(L.wrap=-L.wrap),L.pending!==0?p:1)},o.deflateEnd=function(R){var J;return R&&R.state?(J=R.state.status)!==I&&J!==69&&J!==73&&J!==91&&J!==103&&J!==z&&J!==666?ne(R,v):(R.state=null,J===z?ne(R,-3):p):v},o.deflateSetDictionary=function(R,J){var H,L,S,D,_,Z,B,q,X=J.length;if(!R||!R.state||(D=(H=R.state).wrap)===2||D===1&&H.status!==I||H.lookahead)return v;for(D===1&&(R.adler=u(R.adler,J,X,0)),H.wrap=0,X>=H.w_size&&(D===0&&(W(H.head),H.strstart=0,H.block_start=0,H.insert=0),q=new i.Buf8(H.w_size),i.arraySet(q,J,X-H.w_size,H.w_size,0),J=q,X=H.w_size),_=R.avail_in,Z=R.next_in,B=R.input,R.avail_in=X,R.next_in=0,R.input=J,le(H);H.lookahead>=$;){for(L=H.strstart,S=H.lookahead-($-1);H.ins_h=(H.ins_h<<H.hash_shift^H.window[L+$-1])&H.hash_mask,H.prev[L&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=L,L++,--S;);H.strstart=L,H.lookahead=$-1,le(H)}return H.strstart+=H.lookahead,H.block_start=H.strstart,H.insert=H.lookahead,H.lookahead=0,H.match_length=H.prev_length=$-1,H.match_available=0,R.next_in=Z,R.input=B,R.avail_in=_,H.wrap=D,p},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(r,n,o){n.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(r,n,o){n.exports=function(l,i){var c,u,d,m,f,h,p,v,b,g,x,w,j,k,y,C,N,M,$,T,V,I,z,O,P;c=l.state,u=l.next_in,O=l.input,d=u+(l.avail_in-5),m=l.next_out,P=l.output,f=m-(i-l.avail_out),h=m+(l.avail_out-257),p=c.dmax,v=c.wsize,b=c.whave,g=c.wnext,x=c.window,w=c.hold,j=c.bits,k=c.lencode,y=c.distcode,C=(1<<c.lenbits)-1,N=(1<<c.distbits)-1;e:do{j<15&&(w+=O[u++]<<j,j+=8,w+=O[u++]<<j,j+=8),M=k[w&C];t:for(;;){if(w>>>=$=M>>>24,j-=$,($=M>>>16&255)===0)P[m++]=65535&M;else{if(!(16&$)){if((64&$)==0){M=k[(65535&M)+(w&(1<<$)-1)];continue t}if(32&$){c.mode=12;break e}l.msg="invalid literal/length code",c.mode=30;break e}T=65535&M,($&=15)&&(j<$&&(w+=O[u++]<<j,j+=8),T+=w&(1<<$)-1,w>>>=$,j-=$),j<15&&(w+=O[u++]<<j,j+=8,w+=O[u++]<<j,j+=8),M=y[w&N];r:for(;;){if(w>>>=$=M>>>24,j-=$,!(16&($=M>>>16&255))){if((64&$)==0){M=y[(65535&M)+(w&(1<<$)-1)];continue r}l.msg="invalid distance code",c.mode=30;break e}if(V=65535&M,j<($&=15)&&(w+=O[u++]<<j,(j+=8)<$&&(w+=O[u++]<<j,j+=8)),p<(V+=w&(1<<$)-1)){l.msg="invalid distance too far back",c.mode=30;break e}if(w>>>=$,j-=$,($=m-f)<V){if(b<($=V-$)&&c.sane){l.msg="invalid distance too far back",c.mode=30;break e}if(z=x,(I=0)===g){if(I+=v-$,$<T){for(T-=$;P[m++]=x[I++],--$;);I=m-V,z=P}}else if(g<$){if(I+=v+g-$,($-=g)<T){for(T-=$;P[m++]=x[I++],--$;);if(I=0,g<T){for(T-=$=g;P[m++]=x[I++],--$;);I=m-V,z=P}}}else if(I+=g-$,$<T){for(T-=$;P[m++]=x[I++],--$;);I=m-V,z=P}for(;2<T;)P[m++]=z[I++],P[m++]=z[I++],P[m++]=z[I++],T-=3;T&&(P[m++]=z[I++],1<T&&(P[m++]=z[I++]))}else{for(I=m-V;P[m++]=P[I++],P[m++]=P[I++],P[m++]=P[I++],2<(T-=3););T&&(P[m++]=P[I++],1<T&&(P[m++]=P[I++]))}break}}break}}while(u<d&&m<h);u-=T=j>>3,w&=(1<<(j-=T<<3))-1,l.next_in=u,l.next_out=m,l.avail_in=u<d?d-u+5:5-(u-d),l.avail_out=m<h?h-m+257:257-(m-h),c.hold=w,c.bits=j}},{}],49:[function(r,n,o){var l=r("../utils/common"),i=r("./adler32"),c=r("./crc32"),u=r("./inffast"),d=r("./inftrees"),m=1,f=2,h=0,p=-2,v=1,b=852,g=592;function x(I){return(I>>>24&255)+(I>>>8&65280)+((65280&I)<<8)+((255&I)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new l.Buf16(320),this.work=new l.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function j(I){var z;return I&&I.state?(z=I.state,I.total_in=I.total_out=z.total=0,I.msg="",z.wrap&&(I.adler=1&z.wrap),z.mode=v,z.last=0,z.havedict=0,z.dmax=32768,z.head=null,z.hold=0,z.bits=0,z.lencode=z.lendyn=new l.Buf32(b),z.distcode=z.distdyn=new l.Buf32(g),z.sane=1,z.back=-1,h):p}function k(I){var z;return I&&I.state?((z=I.state).wsize=0,z.whave=0,z.wnext=0,j(I)):p}function y(I,z){var O,P;return I&&I.state?(P=I.state,z<0?(O=0,z=-z):(O=1+(z>>4),z<48&&(z&=15)),z&&(z<8||15<z)?p:(P.window!==null&&P.wbits!==z&&(P.window=null),P.wrap=O,P.wbits=z,k(I))):p}function C(I,z){var O,P;return I?(P=new w,(I.state=P).window=null,(O=y(I,z))!==h&&(I.state=null),O):p}var N,M,$=!0;function T(I){if($){var z;for(N=new l.Buf32(512),M=new l.Buf32(32),z=0;z<144;)I.lens[z++]=8;for(;z<256;)I.lens[z++]=9;for(;z<280;)I.lens[z++]=7;for(;z<288;)I.lens[z++]=8;for(d(m,I.lens,0,288,N,0,I.work,{bits:9}),z=0;z<32;)I.lens[z++]=5;d(f,I.lens,0,32,M,0,I.work,{bits:5}),$=!1}I.lencode=N,I.lenbits=9,I.distcode=M,I.distbits=5}function V(I,z,O,P){var Q,te=I.state;return te.window===null&&(te.wsize=1<<te.wbits,te.wnext=0,te.whave=0,te.window=new l.Buf8(te.wsize)),P>=te.wsize?(l.arraySet(te.window,z,O-te.wsize,te.wsize,0),te.wnext=0,te.whave=te.wsize):(P<(Q=te.wsize-te.wnext)&&(Q=P),l.arraySet(te.window,z,O-P,Q,te.wnext),(P-=Q)?(l.arraySet(te.window,z,O-P,P,0),te.wnext=P,te.whave=te.wsize):(te.wnext+=Q,te.wnext===te.wsize&&(te.wnext=0),te.whave<te.wsize&&(te.whave+=Q))),0}o.inflateReset=k,o.inflateReset2=y,o.inflateResetKeep=j,o.inflateInit=function(I){return C(I,15)},o.inflateInit2=C,o.inflate=function(I,z){var O,P,Q,te,ne,ae,W,A,F,Y,U,ee,le,ue,ge,ce,se,we,de,me,R,J,H,L,S=0,D=new l.Buf8(4),_=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!I||!I.state||!I.output||!I.input&&I.avail_in!==0)return p;(O=I.state).mode===12&&(O.mode=13),ne=I.next_out,Q=I.output,W=I.avail_out,te=I.next_in,P=I.input,ae=I.avail_in,A=O.hold,F=O.bits,Y=ae,U=W,J=h;e:for(;;)switch(O.mode){case v:if(O.wrap===0){O.mode=13;break}for(;F<16;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(2&O.wrap&&A===35615){D[O.check=0]=255&A,D[1]=A>>>8&255,O.check=c(O.check,D,2,0),F=A=0,O.mode=2;break}if(O.flags=0,O.head&&(O.head.done=!1),!(1&O.wrap)||(((255&A)<<8)+(A>>8))%31){I.msg="incorrect header check",O.mode=30;break}if((15&A)!=8){I.msg="unknown compression method",O.mode=30;break}if(F-=4,R=8+(15&(A>>>=4)),O.wbits===0)O.wbits=R;else if(R>O.wbits){I.msg="invalid window size",O.mode=30;break}O.dmax=1<<R,I.adler=O.check=1,O.mode=512&A?10:12,F=A=0;break;case 2:for(;F<16;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(O.flags=A,(255&O.flags)!=8){I.msg="unknown compression method",O.mode=30;break}if(57344&O.flags){I.msg="unknown header flags set",O.mode=30;break}O.head&&(O.head.text=A>>8&1),512&O.flags&&(D[0]=255&A,D[1]=A>>>8&255,O.check=c(O.check,D,2,0)),F=A=0,O.mode=3;case 3:for(;F<32;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}O.head&&(O.head.time=A),512&O.flags&&(D[0]=255&A,D[1]=A>>>8&255,D[2]=A>>>16&255,D[3]=A>>>24&255,O.check=c(O.check,D,4,0)),F=A=0,O.mode=4;case 4:for(;F<16;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}O.head&&(O.head.xflags=255&A,O.head.os=A>>8),512&O.flags&&(D[0]=255&A,D[1]=A>>>8&255,O.check=c(O.check,D,2,0)),F=A=0,O.mode=5;case 5:if(1024&O.flags){for(;F<16;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}O.length=A,O.head&&(O.head.extra_len=A),512&O.flags&&(D[0]=255&A,D[1]=A>>>8&255,O.check=c(O.check,D,2,0)),F=A=0}else O.head&&(O.head.extra=null);O.mode=6;case 6:if(1024&O.flags&&(ae<(ee=O.length)&&(ee=ae),ee&&(O.head&&(R=O.head.extra_len-O.length,O.head.extra||(O.head.extra=new Array(O.head.extra_len)),l.arraySet(O.head.extra,P,te,ee,R)),512&O.flags&&(O.check=c(O.check,P,ee,te)),ae-=ee,te+=ee,O.length-=ee),O.length))break e;O.length=0,O.mode=7;case 7:if(2048&O.flags){if(ae===0)break e;for(ee=0;R=P[te+ee++],O.head&&R&&O.length<65536&&(O.head.name+=String.fromCharCode(R)),R&&ee<ae;);if(512&O.flags&&(O.check=c(O.check,P,ee,te)),ae-=ee,te+=ee,R)break e}else O.head&&(O.head.name=null);O.length=0,O.mode=8;case 8:if(4096&O.flags){if(ae===0)break e;for(ee=0;R=P[te+ee++],O.head&&R&&O.length<65536&&(O.head.comment+=String.fromCharCode(R)),R&&ee<ae;);if(512&O.flags&&(O.check=c(O.check,P,ee,te)),ae-=ee,te+=ee,R)break e}else O.head&&(O.head.comment=null);O.mode=9;case 9:if(512&O.flags){for(;F<16;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(A!==(65535&O.check)){I.msg="header crc mismatch",O.mode=30;break}F=A=0}O.head&&(O.head.hcrc=O.flags>>9&1,O.head.done=!0),I.adler=O.check=0,O.mode=12;break;case 10:for(;F<32;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}I.adler=O.check=x(A),F=A=0,O.mode=11;case 11:if(O.havedict===0)return I.next_out=ne,I.avail_out=W,I.next_in=te,I.avail_in=ae,O.hold=A,O.bits=F,2;I.adler=O.check=1,O.mode=12;case 12:if(z===5||z===6)break e;case 13:if(O.last){A>>>=7&F,F-=7&F,O.mode=27;break}for(;F<3;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}switch(O.last=1&A,F-=1,3&(A>>>=1)){case 0:O.mode=14;break;case 1:if(T(O),O.mode=20,z!==6)break;A>>>=2,F-=2;break e;case 2:O.mode=17;break;case 3:I.msg="invalid block type",O.mode=30}A>>>=2,F-=2;break;case 14:for(A>>>=7&F,F-=7&F;F<32;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if((65535&A)!=(A>>>16^65535)){I.msg="invalid stored block lengths",O.mode=30;break}if(O.length=65535&A,F=A=0,O.mode=15,z===6)break e;case 15:O.mode=16;case 16:if(ee=O.length){if(ae<ee&&(ee=ae),W<ee&&(ee=W),ee===0)break e;l.arraySet(Q,P,te,ee,ne),ae-=ee,te+=ee,W-=ee,ne+=ee,O.length-=ee;break}O.mode=12;break;case 17:for(;F<14;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(O.nlen=257+(31&A),A>>>=5,F-=5,O.ndist=1+(31&A),A>>>=5,F-=5,O.ncode=4+(15&A),A>>>=4,F-=4,286<O.nlen||30<O.ndist){I.msg="too many length or distance symbols",O.mode=30;break}O.have=0,O.mode=18;case 18:for(;O.have<O.ncode;){for(;F<3;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}O.lens[_[O.have++]]=7&A,A>>>=3,F-=3}for(;O.have<19;)O.lens[_[O.have++]]=0;if(O.lencode=O.lendyn,O.lenbits=7,H={bits:O.lenbits},J=d(0,O.lens,0,19,O.lencode,0,O.work,H),O.lenbits=H.bits,J){I.msg="invalid code lengths set",O.mode=30;break}O.have=0,O.mode=19;case 19:for(;O.have<O.nlen+O.ndist;){for(;ce=(S=O.lencode[A&(1<<O.lenbits)-1])>>>16&255,se=65535&S,!((ge=S>>>24)<=F);){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(se<16)A>>>=ge,F-=ge,O.lens[O.have++]=se;else{if(se===16){for(L=ge+2;F<L;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(A>>>=ge,F-=ge,O.have===0){I.msg="invalid bit length repeat",O.mode=30;break}R=O.lens[O.have-1],ee=3+(3&A),A>>>=2,F-=2}else if(se===17){for(L=ge+3;F<L;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}F-=ge,R=0,ee=3+(7&(A>>>=ge)),A>>>=3,F-=3}else{for(L=ge+7;F<L;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}F-=ge,R=0,ee=11+(127&(A>>>=ge)),A>>>=7,F-=7}if(O.have+ee>O.nlen+O.ndist){I.msg="invalid bit length repeat",O.mode=30;break}for(;ee--;)O.lens[O.have++]=R}}if(O.mode===30)break;if(O.lens[256]===0){I.msg="invalid code -- missing end-of-block",O.mode=30;break}if(O.lenbits=9,H={bits:O.lenbits},J=d(m,O.lens,0,O.nlen,O.lencode,0,O.work,H),O.lenbits=H.bits,J){I.msg="invalid literal/lengths set",O.mode=30;break}if(O.distbits=6,O.distcode=O.distdyn,H={bits:O.distbits},J=d(f,O.lens,O.nlen,O.ndist,O.distcode,0,O.work,H),O.distbits=H.bits,J){I.msg="invalid distances set",O.mode=30;break}if(O.mode=20,z===6)break e;case 20:O.mode=21;case 21:if(6<=ae&&258<=W){I.next_out=ne,I.avail_out=W,I.next_in=te,I.avail_in=ae,O.hold=A,O.bits=F,u(I,U),ne=I.next_out,Q=I.output,W=I.avail_out,te=I.next_in,P=I.input,ae=I.avail_in,A=O.hold,F=O.bits,O.mode===12&&(O.back=-1);break}for(O.back=0;ce=(S=O.lencode[A&(1<<O.lenbits)-1])>>>16&255,se=65535&S,!((ge=S>>>24)<=F);){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(ce&&(240&ce)==0){for(we=ge,de=ce,me=se;ce=(S=O.lencode[me+((A&(1<<we+de)-1)>>we)])>>>16&255,se=65535&S,!(we+(ge=S>>>24)<=F);){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}A>>>=we,F-=we,O.back+=we}if(A>>>=ge,F-=ge,O.back+=ge,O.length=se,ce===0){O.mode=26;break}if(32&ce){O.back=-1,O.mode=12;break}if(64&ce){I.msg="invalid literal/length code",O.mode=30;break}O.extra=15&ce,O.mode=22;case 22:if(O.extra){for(L=O.extra;F<L;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}O.length+=A&(1<<O.extra)-1,A>>>=O.extra,F-=O.extra,O.back+=O.extra}O.was=O.length,O.mode=23;case 23:for(;ce=(S=O.distcode[A&(1<<O.distbits)-1])>>>16&255,se=65535&S,!((ge=S>>>24)<=F);){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if((240&ce)==0){for(we=ge,de=ce,me=se;ce=(S=O.distcode[me+((A&(1<<we+de)-1)>>we)])>>>16&255,se=65535&S,!(we+(ge=S>>>24)<=F);){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}A>>>=we,F-=we,O.back+=we}if(A>>>=ge,F-=ge,O.back+=ge,64&ce){I.msg="invalid distance code",O.mode=30;break}O.offset=se,O.extra=15&ce,O.mode=24;case 24:if(O.extra){for(L=O.extra;F<L;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}O.offset+=A&(1<<O.extra)-1,A>>>=O.extra,F-=O.extra,O.back+=O.extra}if(O.offset>O.dmax){I.msg="invalid distance too far back",O.mode=30;break}O.mode=25;case 25:if(W===0)break e;if(ee=U-W,O.offset>ee){if((ee=O.offset-ee)>O.whave&&O.sane){I.msg="invalid distance too far back",O.mode=30;break}le=ee>O.wnext?(ee-=O.wnext,O.wsize-ee):O.wnext-ee,ee>O.length&&(ee=O.length),ue=O.window}else ue=Q,le=ne-O.offset,ee=O.length;for(W<ee&&(ee=W),W-=ee,O.length-=ee;Q[ne++]=ue[le++],--ee;);O.length===0&&(O.mode=21);break;case 26:if(W===0)break e;Q[ne++]=O.length,W--,O.mode=21;break;case 27:if(O.wrap){for(;F<32;){if(ae===0)break e;ae--,A|=P[te++]<<F,F+=8}if(U-=W,I.total_out+=U,O.total+=U,U&&(I.adler=O.check=O.flags?c(O.check,Q,U,ne-U):i(O.check,Q,U,ne-U)),U=W,(O.flags?A:x(A))!==O.check){I.msg="incorrect data check",O.mode=30;break}F=A=0}O.mode=28;case 28:if(O.wrap&&O.flags){for(;F<32;){if(ae===0)break e;ae--,A+=P[te++]<<F,F+=8}if(A!==(4294967295&O.total)){I.msg="incorrect length check",O.mode=30;break}F=A=0}O.mode=29;case 29:J=1;break e;case 30:J=-3;break e;case 31:return-4;case 32:default:return p}return I.next_out=ne,I.avail_out=W,I.next_in=te,I.avail_in=ae,O.hold=A,O.bits=F,(O.wsize||U!==I.avail_out&&O.mode<30&&(O.mode<27||z!==4))&&V(I,I.output,I.next_out,U-I.avail_out)?(O.mode=31,-4):(Y-=I.avail_in,U-=I.avail_out,I.total_in+=Y,I.total_out+=U,O.total+=U,O.wrap&&U&&(I.adler=O.check=O.flags?c(O.check,Q,U,I.next_out-U):i(O.check,Q,U,I.next_out-U)),I.data_type=O.bits+(O.last?64:0)+(O.mode===12?128:0)+(O.mode===20||O.mode===15?256:0),(Y==0&&U===0||z===4)&&J===h&&(J=-5),J)},o.inflateEnd=function(I){if(!I||!I.state)return p;var z=I.state;return z.window&&(z.window=null),I.state=null,h},o.inflateGetHeader=function(I,z){var O;return I&&I.state?(2&(O=I.state).wrap)==0?p:((O.head=z).done=!1,h):p},o.inflateSetDictionary=function(I,z){var O,P=z.length;return I&&I.state?(O=I.state).wrap!==0&&O.mode!==11?p:O.mode===11&&i(1,z,P,0)!==O.check?-3:V(I,z,P,P)?(O.mode=31,-4):(O.havedict=1,h):p},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(r,n,o){var l=r("../utils/common"),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],c=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],u=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],d=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];n.exports=function(m,f,h,p,v,b,g,x){var w,j,k,y,C,N,M,$,T,V=x.bits,I=0,z=0,O=0,P=0,Q=0,te=0,ne=0,ae=0,W=0,A=0,F=null,Y=0,U=new l.Buf16(16),ee=new l.Buf16(16),le=null,ue=0;for(I=0;I<=15;I++)U[I]=0;for(z=0;z<p;z++)U[f[h+z]]++;for(Q=V,P=15;1<=P&&U[P]===0;P--);if(P<Q&&(Q=P),P===0)return v[b++]=20971520,v[b++]=20971520,x.bits=1,0;for(O=1;O<P&&U[O]===0;O++);for(Q<O&&(Q=O),I=ae=1;I<=15;I++)if(ae<<=1,(ae-=U[I])<0)return-1;if(0<ae&&(m===0||P!==1))return-1;for(ee[1]=0,I=1;I<15;I++)ee[I+1]=ee[I]+U[I];for(z=0;z<p;z++)f[h+z]!==0&&(g[ee[f[h+z]]++]=z);if(N=m===0?(F=le=g,19):m===1?(F=i,Y-=257,le=c,ue-=257,256):(F=u,le=d,-1),I=O,C=b,ne=z=A=0,k=-1,y=(W=1<<(te=Q))-1,m===1&&852<W||m===2&&592<W)return 1;for(;;){for(M=I-ne,T=g[z]<N?($=0,g[z]):g[z]>N?($=le[ue+g[z]],F[Y+g[z]]):($=96,0),w=1<<I-ne,O=j=1<<te;v[C+(A>>ne)+(j-=w)]=M<<24|$<<16|T|0,j!==0;);for(w=1<<I-1;A&w;)w>>=1;if(w!==0?(A&=w-1,A+=w):A=0,z++,--U[I]==0){if(I===P)break;I=f[h+g[z]]}if(Q<I&&(A&y)!==k){for(ne===0&&(ne=Q),C+=O,ae=1<<(te=I-ne);te+ne<P&&!((ae-=U[te+ne])<=0);)te++,ae<<=1;if(W+=1<<te,m===1&&852<W||m===2&&592<W)return 1;v[k=A&y]=Q<<24|te<<16|C-b|0}}return A!==0&&(v[C+A]=I-ne<<24|64<<16|0),x.bits=Q,0}},{"../utils/common":41}],51:[function(r,n,o){n.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(r,n,o){var l=r("../utils/common"),i=0,c=1;function u(S){for(var D=S.length;0<=--D;)S[D]=0}var d=0,m=29,f=256,h=f+1+m,p=30,v=19,b=2*h+1,g=15,x=16,w=7,j=256,k=16,y=17,C=18,N=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],M=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],$=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],T=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],V=new Array(2*(h+2));u(V);var I=new Array(2*p);u(I);var z=new Array(512);u(z);var O=new Array(256);u(O);var P=new Array(m);u(P);var Q,te,ne,ae=new Array(p);function W(S,D,_,Z,B){this.static_tree=S,this.extra_bits=D,this.extra_base=_,this.elems=Z,this.max_length=B,this.has_stree=S&&S.length}function A(S,D){this.dyn_tree=S,this.max_code=0,this.stat_desc=D}function F(S){return S<256?z[S]:z[256+(S>>>7)]}function Y(S,D){S.pending_buf[S.pending++]=255&D,S.pending_buf[S.pending++]=D>>>8&255}function U(S,D,_){S.bi_valid>x-_?(S.bi_buf|=D<<S.bi_valid&65535,Y(S,S.bi_buf),S.bi_buf=D>>x-S.bi_valid,S.bi_valid+=_-x):(S.bi_buf|=D<<S.bi_valid&65535,S.bi_valid+=_)}function ee(S,D,_){U(S,_[2*D],_[2*D+1])}function le(S,D){for(var _=0;_|=1&S,S>>>=1,_<<=1,0<--D;);return _>>>1}function ue(S,D,_){var Z,B,q=new Array(g+1),X=0;for(Z=1;Z<=g;Z++)q[Z]=X=X+_[Z-1]<<1;for(B=0;B<=D;B++){var G=S[2*B+1];G!==0&&(S[2*B]=le(q[G]++,G))}}function ge(S){var D;for(D=0;D<h;D++)S.dyn_ltree[2*D]=0;for(D=0;D<p;D++)S.dyn_dtree[2*D]=0;for(D=0;D<v;D++)S.bl_tree[2*D]=0;S.dyn_ltree[2*j]=1,S.opt_len=S.static_len=0,S.last_lit=S.matches=0}function ce(S){8<S.bi_valid?Y(S,S.bi_buf):0<S.bi_valid&&(S.pending_buf[S.pending++]=S.bi_buf),S.bi_buf=0,S.bi_valid=0}function se(S,D,_,Z){var B=2*D,q=2*_;return S[B]<S[q]||S[B]===S[q]&&Z[D]<=Z[_]}function we(S,D,_){for(var Z=S.heap[_],B=_<<1;B<=S.heap_len&&(B<S.heap_len&&se(D,S.heap[B+1],S.heap[B],S.depth)&&B++,!se(D,Z,S.heap[B],S.depth));)S.heap[_]=S.heap[B],_=B,B<<=1;S.heap[_]=Z}function de(S,D,_){var Z,B,q,X,G=0;if(S.last_lit!==0)for(;Z=S.pending_buf[S.d_buf+2*G]<<8|S.pending_buf[S.d_buf+2*G+1],B=S.pending_buf[S.l_buf+G],G++,Z===0?ee(S,B,D):(ee(S,(q=O[B])+f+1,D),(X=N[q])!==0&&U(S,B-=P[q],X),ee(S,q=F(--Z),_),(X=M[q])!==0&&U(S,Z-=ae[q],X)),G<S.last_lit;);ee(S,j,D)}function me(S,D){var _,Z,B,q=D.dyn_tree,X=D.stat_desc.static_tree,G=D.stat_desc.has_stree,K=D.stat_desc.elems,re=-1;for(S.heap_len=0,S.heap_max=b,_=0;_<K;_++)q[2*_]!==0?(S.heap[++S.heap_len]=re=_,S.depth[_]=0):q[2*_+1]=0;for(;S.heap_len<2;)q[2*(B=S.heap[++S.heap_len]=re<2?++re:0)]=1,S.depth[B]=0,S.opt_len--,G&&(S.static_len-=X[2*B+1]);for(D.max_code=re,_=S.heap_len>>1;1<=_;_--)we(S,q,_);for(B=K;_=S.heap[1],S.heap[1]=S.heap[S.heap_len--],we(S,q,1),Z=S.heap[1],S.heap[--S.heap_max]=_,S.heap[--S.heap_max]=Z,q[2*B]=q[2*_]+q[2*Z],S.depth[B]=(S.depth[_]>=S.depth[Z]?S.depth[_]:S.depth[Z])+1,q[2*_+1]=q[2*Z+1]=B,S.heap[1]=B++,we(S,q,1),2<=S.heap_len;);S.heap[--S.heap_max]=S.heap[1],(function(ie,pe){var ve,ye,Se,ke,Fe,Oe,Ce=pe.dyn_tree,xe=pe.max_code,Ne=pe.stat_desc.static_tree,Le=pe.stat_desc.has_stree,Me=pe.stat_desc.extra_bits,Te=pe.stat_desc.extra_base,Ie=pe.stat_desc.max_length,Ae=0;for(ke=0;ke<=g;ke++)ie.bl_count[ke]=0;for(Ce[2*ie.heap[ie.heap_max]+1]=0,ve=ie.heap_max+1;ve<b;ve++)Ie<(ke=Ce[2*Ce[2*(ye=ie.heap[ve])+1]+1]+1)&&(ke=Ie,Ae++),Ce[2*ye+1]=ke,xe<ye||(ie.bl_count[ke]++,Fe=0,Te<=ye&&(Fe=Me[ye-Te]),Oe=Ce[2*ye],ie.opt_len+=Oe*(ke+Fe),Le&&(ie.static_len+=Oe*(Ne[2*ye+1]+Fe)));if(Ae!==0){do{for(ke=Ie-1;ie.bl_count[ke]===0;)ke--;ie.bl_count[ke]--,ie.bl_count[ke+1]+=2,ie.bl_count[Ie]--,Ae-=2}while(0<Ae);for(ke=Ie;ke!==0;ke--)for(ye=ie.bl_count[ke];ye!==0;)xe<(Se=ie.heap[--ve])||(Ce[2*Se+1]!==ke&&(ie.opt_len+=(ke-Ce[2*Se+1])*Ce[2*Se],Ce[2*Se+1]=ke),ye--)}})(S,D),ue(q,re,S.bl_count)}function R(S,D,_){var Z,B,q=-1,X=D[1],G=0,K=7,re=4;for(X===0&&(K=138,re=3),D[2*(_+1)+1]=65535,Z=0;Z<=_;Z++)B=X,X=D[2*(Z+1)+1],++G<K&&B===X||(G<re?S.bl_tree[2*B]+=G:B!==0?(B!==q&&S.bl_tree[2*B]++,S.bl_tree[2*k]++):G<=10?S.bl_tree[2*y]++:S.bl_tree[2*C]++,q=B,re=(G=0)===X?(K=138,3):B===X?(K=6,3):(K=7,4))}function J(S,D,_){var Z,B,q=-1,X=D[1],G=0,K=7,re=4;for(X===0&&(K=138,re=3),Z=0;Z<=_;Z++)if(B=X,X=D[2*(Z+1)+1],!(++G<K&&B===X)){if(G<re)for(;ee(S,B,S.bl_tree),--G!=0;);else B!==0?(B!==q&&(ee(S,B,S.bl_tree),G--),ee(S,k,S.bl_tree),U(S,G-3,2)):G<=10?(ee(S,y,S.bl_tree),U(S,G-3,3)):(ee(S,C,S.bl_tree),U(S,G-11,7));q=B,re=(G=0)===X?(K=138,3):B===X?(K=6,3):(K=7,4)}}u(ae);var H=!1;function L(S,D,_,Z){U(S,(d<<1)+(Z?1:0),3),(function(B,q,X,G){ce(B),Y(B,X),Y(B,~X),l.arraySet(B.pending_buf,B.window,q,X,B.pending),B.pending+=X})(S,D,_)}o._tr_init=function(S){H||((function(){var D,_,Z,B,q,X=new Array(g+1);for(B=Z=0;B<m-1;B++)for(P[B]=Z,D=0;D<1<<N[B];D++)O[Z++]=B;for(O[Z-1]=B,B=q=0;B<16;B++)for(ae[B]=q,D=0;D<1<<M[B];D++)z[q++]=B;for(q>>=7;B<p;B++)for(ae[B]=q<<7,D=0;D<1<<M[B]-7;D++)z[256+q++]=B;for(_=0;_<=g;_++)X[_]=0;for(D=0;D<=143;)V[2*D+1]=8,D++,X[8]++;for(;D<=255;)V[2*D+1]=9,D++,X[9]++;for(;D<=279;)V[2*D+1]=7,D++,X[7]++;for(;D<=287;)V[2*D+1]=8,D++,X[8]++;for(ue(V,h+1,X),D=0;D<p;D++)I[2*D+1]=5,I[2*D]=le(D,5);Q=new W(V,N,f+1,h,g),te=new W(I,M,0,p,g),ne=new W(new Array(0),$,0,v,w)})(),H=!0),S.l_desc=new A(S.dyn_ltree,Q),S.d_desc=new A(S.dyn_dtree,te),S.bl_desc=new A(S.bl_tree,ne),S.bi_buf=0,S.bi_valid=0,ge(S)},o._tr_stored_block=L,o._tr_flush_block=function(S,D,_,Z){var B,q,X=0;0<S.level?(S.strm.data_type===2&&(S.strm.data_type=(function(G){var K,re=4093624447;for(K=0;K<=31;K++,re>>>=1)if(1&re&&G.dyn_ltree[2*K]!==0)return i;if(G.dyn_ltree[18]!==0||G.dyn_ltree[20]!==0||G.dyn_ltree[26]!==0)return c;for(K=32;K<f;K++)if(G.dyn_ltree[2*K]!==0)return c;return i})(S)),me(S,S.l_desc),me(S,S.d_desc),X=(function(G){var K;for(R(G,G.dyn_ltree,G.l_desc.max_code),R(G,G.dyn_dtree,G.d_desc.max_code),me(G,G.bl_desc),K=v-1;3<=K&&G.bl_tree[2*T[K]+1]===0;K--);return G.opt_len+=3*(K+1)+5+5+4,K})(S),B=S.opt_len+3+7>>>3,(q=S.static_len+3+7>>>3)<=B&&(B=q)):B=q=_+5,_+4<=B&&D!==-1?L(S,D,_,Z):S.strategy===4||q===B?(U(S,2+(Z?1:0),3),de(S,V,I)):(U(S,4+(Z?1:0),3),(function(G,K,re,ie){var pe;for(U(G,K-257,5),U(G,re-1,5),U(G,ie-4,4),pe=0;pe<ie;pe++)U(G,G.bl_tree[2*T[pe]+1],3);J(G,G.dyn_ltree,K-1),J(G,G.dyn_dtree,re-1)})(S,S.l_desc.max_code+1,S.d_desc.max_code+1,X+1),de(S,S.dyn_ltree,S.dyn_dtree)),ge(S),Z&&ce(S)},o._tr_tally=function(S,D,_){return S.pending_buf[S.d_buf+2*S.last_lit]=D>>>8&255,S.pending_buf[S.d_buf+2*S.last_lit+1]=255&D,S.pending_buf[S.l_buf+S.last_lit]=255&_,S.last_lit++,D===0?S.dyn_ltree[2*_]++:(S.matches++,D--,S.dyn_ltree[2*(O[_]+f+1)]++,S.dyn_dtree[2*F(D)]++),S.last_lit===S.lit_bufsize-1},o._tr_align=function(S){U(S,2,3),ee(S,j,V),(function(D){D.bi_valid===16?(Y(D,D.bi_buf),D.bi_buf=0,D.bi_valid=0):8<=D.bi_valid&&(D.pending_buf[D.pending++]=255&D.bi_buf,D.bi_buf>>=8,D.bi_valid-=8)})(S)}},{"../utils/common":41}],53:[function(r,n,o){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,n,o){(function(l){(function(i,c){if(!i.setImmediate){var u,d,m,f,h=1,p={},v=!1,b=i.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(i);g=g&&g.setTimeout?g:i,u={}.toString.call(i.process)==="[object process]"?function(k){process.nextTick(function(){w(k)})}:(function(){if(i.postMessage&&!i.importScripts){var k=!0,y=i.onmessage;return i.onmessage=function(){k=!1},i.postMessage("","*"),i.onmessage=y,k}})()?(f="setImmediate$"+Math.random()+"$",i.addEventListener?i.addEventListener("message",j,!1):i.attachEvent("onmessage",j),function(k){i.postMessage(f+k,"*")}):i.MessageChannel?((m=new MessageChannel).port1.onmessage=function(k){w(k.data)},function(k){m.port2.postMessage(k)}):b&&"onreadystatechange"in b.createElement("script")?(d=b.documentElement,function(k){var y=b.createElement("script");y.onreadystatechange=function(){w(k),y.onreadystatechange=null,d.removeChild(y),y=null},d.appendChild(y)}):function(k){setTimeout(w,0,k)},g.setImmediate=function(k){typeof k!="function"&&(k=new Function(""+k));for(var y=new Array(arguments.length-1),C=0;C<y.length;C++)y[C]=arguments[C+1];var N={callback:k,args:y};return p[h]=N,u(h),h++},g.clearImmediate=x}function x(k){delete p[k]}function w(k){if(v)setTimeout(w,0,k);else{var y=p[k];if(y){v=!0;try{(function(C){var N=C.callback,M=C.args;switch(M.length){case 0:N();break;case 1:N(M[0]);break;case 2:N(M[0],M[1]);break;case 3:N(M[0],M[1],M[2]);break;default:N.apply(c,M)}})(y)}finally{x(k),v=!1}}}}function j(k){k.source===i&&typeof k.data=="string"&&k.data.indexOf(f)===0&&w(+k.data.slice(f.length))}})(typeof self>"u"?l===void 0?this:l:self)}).call(this,typeof jr<"u"?jr:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Us)),Us.exports}var C_=R_();const nu=H0(C_);async function S_({file:e,setSchema:t,setServices:r,translationAdapter:n}){const l=await new nu().loadAsync(e),i=l.file("schema.json");if(i){const d=await i.async("string");try{console.log("Reading schema.json from ZIP:",d.substring(0,100)+"...");const m=JSON.parse(d);console.log("Parsed schema:",m),t(m),console.log("setSchema called")}catch(m){throw console.error("Failed to parse schema.json",m),new Error("El archivo schema.json no es válido.")}}else throw new Error("El archivo ZIP no contiene schema.json");const c=l.file("openapi_specs.json");if(c)try{console.log("Found openapi_specs.json in ZIP");const d=await c.async("string"),m=JSON.parse(d);if(Array.isArray(m)){ru();let f={};for(const h of m){eu(h);const p=Oo(h),v=Li(p),b=$i(p);f={...f,...v},Si(b)}r&&(r({registry:f}),console.log(`Restored ${Object.keys(f).length} services from OpenAPI specs.`))}}catch(d){console.error("Failed to restore OpenAPI specs",d)}else{console.log("openapi_specs.json NOT found in ZIP.");const d=l.file("services.json");if(d){if(console.log("Found services.json in ZIP (Fallback)"),r)try{const m=await d.async("string"),f=JSON.parse(m);Object.keys(f).length>0?(r({registry:f}),console.log("setServices called with fallback registry")):console.warn("services.json is empty, jumping fallback.")}catch(m){console.error("Failed to parse services.json",m)}}else console.log("No services configuration found in ZIP.")}const u=l.folder("i18n");if(u){const d=[];u.forEach((m,f)=>{!f.dir&&m.endsWith(".json")&&d.push({path:m,file:f})});for(const{path:m,file:f}of d)try{const h=await f.async("string"),p=JSON.parse(h),v=m.replace(".json","");n&&typeof n.importTranslations=="function"&&n.importTranslations(p,v)}catch(h){console.error(`Failed to import translation ${m}`,h)}}}var ro={exports:{}},N_=ro.exports,N0;function M_(){return N0||(N0=1,(function(e,t){(function(r,n){n()})(N_,function(){function r(d,m){return typeof m>"u"?m={autoBom:!1}:typeof m!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),m={autoBom:!m}),m.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(d.type)?new Blob(["\uFEFF",d],{type:d.type}):d}function n(d,m,f){var h=new XMLHttpRequest;h.open("GET",d),h.responseType="blob",h.onload=function(){u(h.response,m,f)},h.onerror=function(){console.error("could not download file")},h.send()}function o(d){var m=new XMLHttpRequest;m.open("HEAD",d,!1);try{m.send()}catch{}return 200<=m.status&&299>=m.status}function l(d){try{d.dispatchEvent(new MouseEvent("click"))}catch{var m=document.createEvent("MouseEvents");m.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),d.dispatchEvent(m)}}var i=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof jr=="object"&&jr.global===jr?jr:void 0,c=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),u=i.saveAs||(typeof window!="object"||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!c?function(d,m,f){var h=i.URL||i.webkitURL,p=document.createElement("a");m=m||d.name||"download",p.download=m,p.rel="noopener",typeof d=="string"?(p.href=d,p.origin===location.origin?l(p):o(p.href)?n(d,m,f):l(p,p.target="_blank")):(p.href=h.createObjectURL(d),setTimeout(function(){h.revokeObjectURL(p.href)},4e4),setTimeout(function(){l(p)},0))}:"msSaveOrOpenBlob"in navigator?function(d,m,f){if(m=m||d.name||"download",typeof d!="string")navigator.msSaveOrOpenBlob(r(d,f),m);else if(o(d))n(d,m,f);else{var h=document.createElement("a");h.href=d,h.target="_blank",setTimeout(function(){l(h)})}}:function(d,m,f,h){if(h=h||open("","_blank"),h&&(h.document.title=h.document.body.innerText="downloading..."),typeof d=="string")return n(d,m,f);var p=d.type==="application/octet-stream",v=/constructor/i.test(i.HTMLElement)||i.safari,b=/CriOS\/[\d]+/.test(navigator.userAgent);if((b||p&&v||c)&&typeof FileReader<"u"){var g=new FileReader;g.onloadend=function(){var j=g.result;j=b?j:j.replace(/^data:[^;]*;/,"data:attachment/file;"),h?h.location.href=j:location=j,h=null},g.readAsDataURL(d)}else{var x=i.URL||i.webkitURL,w=x.createObjectURL(d);h?h.location=w:location.href=w,h=null,setTimeout(function(){x.revokeObjectURL(w)},4e4)}});i.saveAs=u.saveAs=u,e.exports=u})})(ro)),ro.exports}var A_=M_();function au(e,t){const n=e.replace(/[^a-zA-Z0-9]/g," ").split(" ").filter(Boolean).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join("")+"Service";let o=`// ${n}.ts
207
207
  // Generated from OpenAPI
208
208
  // Total endpoints: ${t.length}
209
209
 
@@ -269,7 +269,7 @@ export {
269
269
  `,r+=t.map(n=>` ${n.charAt(0).toUpperCase()+n.slice(1)+"Service"}`).join(`,
270
270
  `),r+=`
271
271
  };
272
- `,r}async function L_({schema:e,translationsAdapter:t,i18n:r,servicesRegistry:n,baseName:o="my-form-project"}){var f;const l=new nu;l.file("schema.json",JSON.stringify(e,null,2));try{const h=Ii(e,"validationSchema");l.file("validation.ts",h)}catch(h){console.error("Error generating validation code",h),l.file("validation.ts","// Error generating validation code")}try{const h=Fi(e,t,r);(f=l.folder("i18n"))==null||f.file("es.json",JSON.stringify(h,null,2))}catch(h){console.error("Error generating translations",h),l.file("i18n/error.txt","Error generating translations")}const i=l.folder("services"),c=n||{},u=Object.entries(c);if(u.length>0){const h={};u.forEach(([v])=>{const g=v.split(".")[0]||"default";h[g]||(h[g]=[]),h[g].push(v)}),Object.entries(h).forEach(([v,b])=>{const g=au(v,b),x=v.charAt(0).toUpperCase()+v.slice(1)+"Service";i==null||i.file(`${x}.ts`,g)});const p=ou(h);i==null||i.file("index.ts",p),l.file("services.json",JSON.stringify(c,null,2))}else i==null||i.file("placeholder.ts",`// No services defined in the editor
272
+ `,r}async function O_({schema:e,translationsAdapter:t,i18n:r,servicesRegistry:n,baseName:o="my-form-project"}){var f;const l=new nu;l.file("schema.json",JSON.stringify(e,null,2));try{const h=Ii(e,"validationSchema");l.file("validation.ts",h)}catch(h){console.error("Error generating validation code",h),l.file("validation.ts","// Error generating validation code")}try{const h=Fi(e,t,r);(f=l.folder("i18n"))==null||f.file("es.json",JSON.stringify(h,null,2))}catch(h){console.error("Error generating translations",h),l.file("i18n/error.txt","Error generating translations")}const i=l.folder("services"),c=n||{},u=Object.entries(c);if(u.length>0){const h={};u.forEach(([v])=>{const g=v.split(".")[0]||"default";h[g]||(h[g]=[]),h[g].push(v)}),Object.entries(h).forEach(([v,b])=>{const g=au(v,b),x=v.charAt(0).toUpperCase()+v.slice(1)+"Service";i==null||i.file(`${x}.ts`,g)});const p=ou(h);i==null||i.file("index.ts",p),l.file("services.json",JSON.stringify(c,null,2))}else i==null||i.file("placeholder.ts",`// No services defined in the editor
273
273
  export const services = {};`),l.file("services.json","{}");try{const h=tu();console.log("Exporting OpenAPI Specs. Found:",(h==null?void 0:h.length)||0),h&&h.length>0?(l.file("openapi_specs.json",JSON.stringify(h,null,2)),console.log("Added openapi_specs.json to ZIP")):console.warn("No OpenAPI specs found in localStorage. The exported services might not be fully restorable.")}catch(h){console.error("Error saving OpenAPI specs to ZIP",h)}const d=`# ${o}
274
274
 
275
275
  Exported Form Project
@@ -287,12 +287,12 @@ Exported Form Project
287
287
  2. Import \`schema.json\` into your form renderer.
288
288
  3. Use \`validationSchema\` from \`validation.ts\` with React Hook Form.
289
289
  4. Load translations into i18next or your preferred i18n lib.
290
- `;l.file("README.md",d);const m=await l.generateAsync({type:"blob"});O_.saveAs(m,`${o}-export.zip`)}const no={undo:{key:"z",ctrl:!0,description:"Deshacer",action:"undo",enabled:!0},redo:{key:"y",ctrl:!0,description:"Rehacer",action:"redo",enabled:!0},save:{key:"s",ctrl:!0,description:"Guardar",action:"save",enabled:!0},saveAs:{key:"s",ctrl:!0,shift:!0,description:"Guardar como...",action:"saveAs",enabled:!0},toggleRelations:{key:"r",ctrl:!0,description:"Mostrar/Ocultar relaciones",action:"toggleRelations",enabled:!0},togglePreview:{key:"p",ctrl:!0,description:"Alternar vista previa",action:"togglePreview",enabled:!0},deleteField:{key:"Delete",description:"Eliminar campo seleccionado",action:"deleteField",enabled:!0},duplicateField:{key:"d",ctrl:!0,description:"Duplicar campo seleccionado",action:"duplicateField",enabled:!0},copy:{key:"c",ctrl:!0,shift:!0,description:"Copiar JSON al portapapeles",action:"copy",enabled:!0},paste:{key:"v",ctrl:!0,description:"Pegar",action:"paste",enabled:!1},selectAll:{key:"a",ctrl:!0,description:"Seleccionar todo",action:"selectAll",enabled:!1},newSchema:{key:"n",ctrl:!0,description:"Nuevo esquema",action:"newSchema",enabled:!0},importSchema:{key:"o",ctrl:!0,description:"Importar esquema",action:"importSchema",enabled:!0},exportSchema:{key:"e",ctrl:!0,description:"Exportar esquema",action:"exportSchema",enabled:!0}},su="form-editor-shortcuts";function $_(){try{const e=localStorage.getItem(su);if(!e)return{...no};const t=JSON.parse(e);return{...no,...t}}catch(e){return console.error("Error loading shortcuts config:",e),{...no}}}function lu(e){try{localStorage.setItem(su,JSON.stringify(e))}catch(t){console.error("Error saving shortcuts config:",t)}}function I_(){const e={...no};return lu(e),e}function F_(e,t){if(!t.enabled)return!1;const r=e.key.toLowerCase()===t.key.toLowerCase(),n=!!t.ctrl===(e.ctrlKey||e.metaKey),o=!!t.shift===e.shiftKey,l=!!t.alt===e.altKey;return r&&n&&o&&l}function qn(e){const t=[];(e.ctrl||e.meta)&&t.push(navigator.platform.includes("Mac")?"⌘":"Ctrl"),e.shift&&t.push("Shift"),e.alt&&t.push("Alt");let r=e.key;return r===" "?r="Space":r.length===1&&(r=r.toUpperCase()),t.push(r),t.join("+")}function __(e){const t=[],r=Object.keys(e);for(let n=0;n<r.length;n++)for(let o=n+1;o<r.length;o++){const l=e[r[n]],i=e[r[o]];!l.enabled||!i.enabled||l.key.toLowerCase()===i.key.toLowerCase()&&!!l.ctrl==!!i.ctrl&&!!l.shift==!!i.shift&&!!l.alt==!!i.alt&&t.push({action1:r[n],action2:r[o]})}return{valid:t.length===0,conflicts:t}}function T_(e){const[t,r]=E.useState(()=>$_()),n=E.useCallback(o=>{r(o),lu(o)},[]);return E.useEffect(()=>{const o=l=>{const i=l.target,c=i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.isContentEditable,u=["save","saveAs","undo","redo","copy"];for(const[d,m]of Object.entries(t))if(F_(l,m)){const f=e[d];if(f){if(c&&!u.includes(d))continue;f(l)!==!1&&(l.preventDefault(),l.stopPropagation());break}}};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t,e]),{config:t,updateConfig:n}}const B_=({isOpen:e,onClose:t,config:r,onSaveShortcuts:n})=>{const{t:o}=Ct(),[l,i]=E.useState("general"),[c,u]=E.useState(r),[d,m]=E.useState(null),[f,h]=E.useState(!1),{show:p}=qr(),v=oe(C=>C.editorSettings),b=oe(C=>C.updateSettings),g=()=>{const C=__(c);if(!C.valid){const N=C.conflicts.map(({action1:M,action2:$})=>`${c[M].description} y ${c[$].description}`);p(`Conflictos detectados:
290
+ `;l.file("README.md",d);const m=await l.generateAsync({type:"blob"});A_.saveAs(m,`${o}-export.zip`)}const no={undo:{key:"z",ctrl:!0,description:"Deshacer",action:"undo",enabled:!0},redo:{key:"y",ctrl:!0,description:"Rehacer",action:"redo",enabled:!0},save:{key:"s",ctrl:!0,description:"Guardar",action:"save",enabled:!0},saveAs:{key:"s",ctrl:!0,shift:!0,description:"Guardar como...",action:"saveAs",enabled:!0},toggleRelations:{key:"r",ctrl:!0,description:"Mostrar/Ocultar relaciones",action:"toggleRelations",enabled:!0},togglePreview:{key:"p",ctrl:!0,description:"Alternar vista previa",action:"togglePreview",enabled:!0},deleteField:{key:"Delete",description:"Eliminar campo seleccionado",action:"deleteField",enabled:!0},duplicateField:{key:"d",ctrl:!0,description:"Duplicar campo seleccionado",action:"duplicateField",enabled:!0},copy:{key:"c",ctrl:!0,shift:!0,description:"Copiar JSON al portapapeles",action:"copy",enabled:!0},paste:{key:"v",ctrl:!0,description:"Pegar",action:"paste",enabled:!1},selectAll:{key:"a",ctrl:!0,description:"Seleccionar todo",action:"selectAll",enabled:!1},newSchema:{key:"n",ctrl:!0,description:"Nuevo esquema",action:"newSchema",enabled:!0},importSchema:{key:"o",ctrl:!0,description:"Importar esquema",action:"importSchema",enabled:!0},exportSchema:{key:"e",ctrl:!0,description:"Exportar esquema",action:"exportSchema",enabled:!0}},su="form-editor-shortcuts";function L_(){try{const e=localStorage.getItem(su);if(!e)return{...no};const t=JSON.parse(e);return{...no,...t}}catch(e){return console.error("Error loading shortcuts config:",e),{...no}}}function lu(e){try{localStorage.setItem(su,JSON.stringify(e))}catch(t){console.error("Error saving shortcuts config:",t)}}function $_(){const e={...no};return lu(e),e}function I_(e,t){if(!t.enabled)return!1;const r=e.key.toLowerCase()===t.key.toLowerCase(),n=!!t.ctrl===(e.ctrlKey||e.metaKey),o=!!t.shift===e.shiftKey,l=!!t.alt===e.altKey;return r&&n&&o&&l}function qn(e){const t=[];(e.ctrl||e.meta)&&t.push(navigator.platform.includes("Mac")?"⌘":"Ctrl"),e.shift&&t.push("Shift"),e.alt&&t.push("Alt");let r=e.key;return r===" "?r="Space":r.length===1&&(r=r.toUpperCase()),t.push(r),t.join("+")}function F_(e){const t=[],r=Object.keys(e);for(let n=0;n<r.length;n++)for(let o=n+1;o<r.length;o++){const l=e[r[n]],i=e[r[o]];!l.enabled||!i.enabled||l.key.toLowerCase()===i.key.toLowerCase()&&!!l.ctrl==!!i.ctrl&&!!l.shift==!!i.shift&&!!l.alt==!!i.alt&&t.push({action1:r[n],action2:r[o]})}return{valid:t.length===0,conflicts:t}}function __(e){const[t,r]=E.useState(()=>L_()),n=E.useCallback(o=>{r(o),lu(o)},[]);return E.useEffect(()=>{const o=l=>{const i=l.target,c=i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.isContentEditable,u=["save","saveAs","undo","redo","copy"];for(const[d,m]of Object.entries(t))if(I_(l,m)){const f=e[d];if(f){if(c&&!u.includes(d))continue;f(l)!==!1&&(l.preventDefault(),l.stopPropagation());break}}};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t,e]),{config:t,updateConfig:n}}const T_=({isOpen:e,onClose:t,config:r,onSaveShortcuts:n})=>{const{t:o}=Ct(),[l,i]=E.useState("general"),[c,u]=E.useState(r),[d,m]=E.useState(null),[f,h]=E.useState(!1),{show:p}=qr(),v=oe(C=>C.editorSettings),b=oe(C=>C.updateSettings),g=()=>{const C=F_(c);if(!C.valid){const N=C.conflicts.map(({action1:M,action2:$})=>`${c[M].description} y ${c[$].description}`);p(`Conflictos detectados:
291
291
  ${N.join(`
292
- `)}`,"error");return}n(c),p("Configuración de shortcuts guardada","success")},x=()=>{if(window.confirm("¿Restaurar shortcuts a valores por defecto?")){const C=I_();u(C),p("Shortcuts restaurados a valores por defecto","info")}},w=C=>{u(N=>({...N,[C]:{...N[C],enabled:!N[C].enabled}}))},j=C=>{m(C),h(!0)},k=C=>{if(!f||!d||(C.preventDefault(),C.stopPropagation(),["Control","Shift","Alt","Meta"].includes(C.key)))return;const N={...c[d],key:C.key,ctrl:C.ctrlKey||C.metaKey,shift:C.shiftKey,alt:C.altKey};u(M=>({...M,[d]:N})),h(!1),m(null)};if(E.useEffect(()=>{u(r)},[r]),E.useEffect(()=>{if(f)return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[f,d,c]),E.useEffect(()=>{e||(h(!1),m(null),u(r),i("general"))},[e,r]),!e)return null;const y=[{id:"general",label:o("ds.editor.settings.general","General"),icon:Rn},{id:"appearance",label:o("ds.editor.settings.appearance","Apariencia"),icon:yd},{id:"shortcuts",label:o("ds.editor.settings.shortcuts","Atajos"),icon:cn}];return s.jsxs(Et,{isOpen:e,onClose:t,title:o("ds.editor.settings.title","Configuración del Editor"),maxWidth:"max-w-4xl",children:[s.jsxs("div",{className:"flex h-[60vh] gap-6",children:[s.jsx("div",{className:"w-48 flex-shrink-0 flex flex-col gap-1 border-r border-[var(--color-ds-border-default-50)] pr-4",children:y.map(C=>s.jsxs("button",{onClick:()=>i(C.id),className:he("flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg transition-colors text-left",l===C.id?"bg-[var(--color-ds-button-primary-bg)] text-[var(--color-ds-button-primary-text)]":"text-[var(--color-ds-text-secondary)] hover:bg-[var(--color-ds-background-neutral-hover)] hover:text-[var(--color-ds-text-primary)]"),children:[s.jsx(C.icon,{className:"w-4 h-4"}),C.label]},C.id))}),s.jsxs("div",{className:"flex-1 overflow-y-auto pr-2",children:[l==="general"&&s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("h4",{className:"text-sm font-semibold text-[var(--color-ds-text-primary)] border-b border-[var(--color-ds-border-default-50)] pb-2",children:"Comportamiento"}),s.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)]",children:[s.jsx(rt,{checked:v.confirmDelete,onChange:C=>b({confirmDelete:C}),size:"md",disableErrorPlaceholder:!0}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-[var(--color-ds-text-primary)]",children:"Confirmar eliminación"}),s.jsx("div",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Solicitar confirmación antes de eliminar campos o secciones."})]})]}),s.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)]",children:[s.jsx(rt,{checked:v.showGrid,onChange:C=>b({showGrid:C}),size:"md",disableErrorPlaceholder:!0}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-[var(--color-ds-text-primary)]",children:"Mostrar rejilla de diseño"}),s.jsx("div",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Visualizar guías de columnas y filas en el editor."})]})]})]})}),l==="appearance"&&s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("h4",{className:"text-sm font-semibold text-[var(--color-ds-text-primary)] border-b border-[var(--color-ds-border-default-50)] pb-2",children:"Tema del Editor"}),s.jsxs("div",{className:"p-4 rounded-lg border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)] flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-[var(--color-ds-text-primary)] mb-1",children:"Preferencia de color"}),s.jsx("div",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Elige entre modo claro, oscuro o sincronizar con el sistema."})]}),s.jsx(xa,{value:v.theme,onChange:C=>b({theme:C}),size:"lg",variant:"rounded",items:[{id:"light",label:"Claro",icon:Gl},{id:"system",label:"Sistema",icon:Tl},{id:"dark",label:"Oscuro",icon:zl}]})]})]})}),l==="shortcuts"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex justify-between items-center mb-2",children:[s.jsx("div",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:"Personaliza los atajos de teclado para mejorar tu productividad."}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(fe,{variant:"ghost",size:"xs",onClick:x,children:"Restaurar"}),s.jsx(fe,{variant:"primary",size:"xs",onClick:g,children:"Guardar Atajos"})]})]}),s.jsx("div",{className:"space-y-2",children:Object.entries(c).map(([C,N])=>s.jsxs("div",{className:he("flex items-center justify-between p-3 rounded-xl transition-colors border","border-[var(--color-ds-border-muted)] hover:border-[var(--color-ds-border-default)]","bg-[var(--color-ds-background-surface)] hover:bg-[var(--color-ds-background-surface-hover)]"),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[s.jsx(rt,{checked:N.enabled,onChange:()=>w(C),size:"sm",disableErrorPlaceholder:!0}),s.jsx("div",{className:"cursor-pointer",onClick:()=>w(C),children:s.jsx("div",{className:he("font-medium text-sm",!N.enabled&&"opacity-50 line-through"),children:N.description})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:he("px-2 py-1 rounded border font-mono text-[10px] min-w-[60px] text-center",f&&d===C?"bg-blue-100 text-blue-700 border-blue-300 animate-pulse":"bg-[var(--color-ds-background-page)] border-[var(--color-ds-border-muted)]",!N.enabled&&"opacity-40"),children:f&&d===C?"...":qn(N)}),s.jsx(fe,{size:"xs",variant:"ghost",onClick:M=>{M.stopPropagation(),j(C)},disabled:!N.enabled||f,children:s.jsx(Bo,{className:"w-3 h-3"})})]})]},C))})]})]})]}),s.jsx("div",{className:"flex justify-end pt-4 border-t border-[var(--color-ds-border-default)] mt-2",children:s.jsx(fe,{variant:"outline",onClick:t,children:"Cerrar"})})]})},Z_=B_;function qs(e,t){const r=new Blob([t],{type:"text/plain;charset=utf-8"}),n=URL.createObjectURL(r),o=document.createElement("a");o.href=n,o.download=e,o.click(),URL.revokeObjectURL(n)}const Gs=e=>e.toLowerCase().endsWith(".json")?e:`${e}.json`,M0=(e,t)=>`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`,A0=()=>s.jsx("div",{className:"w-px h-6 bg-[var(--color-ds-border-default-50)] mx-2"});function V_(){var L;const{t:e,i18n:t}=Ct(),r=oe(S=>S.schema),n=oe(S=>S.undo),o=oe(S=>S.redo),l=oe(S=>S.setSchema),i=oe(S=>S.resetHistory),c=oe(S=>S.past.length),u=oe(S=>S.future.length),d=oe(S=>S.selection),m=oe(S=>S.removeField),f=oe(S=>S.duplicateField),h=oe(S=>S.editorSettings),p=oe(S=>S.showRelations??!1),v=oe(S=>S.toggleRelations),b=oe(S=>S.setShowRelations),g=oe(S=>S.mode),x=oe(S=>S.setMode),[w,j]=E.useState(!1),[k,y]=E.useState(!1),[C,N]=E.useState(!1),[M,$]=E.useState(!1),[T,V]=E.useState(!1),I=()=>{typeof v=="function"?v():typeof b=="function"&&b(!p)},z=E.useRef(null),O=E.useRef(null),{show:P}=qr(),{fs:Q,baseDir:te,translations:ne,services:ae,setServices:W}=St(),A=((L=r.title)==null?void 0:L.toString().trim().replace(/\s+/g,"-").toLowerCase())||"form-schema",F=()=>{qs(`${A}.json`,JSON.stringify(r,null,2)),P("Esquema exportado como JSON.","success")},Y=()=>{try{const S=Ii(r,"validationSchema");qs(`${A}.validation.ts`,S),P("Yup exportado como TypeScript.","success")}catch(S){console.error(S),P("No se pudo generar el Yup.","error")}},U=()=>{try{const S=Fi(r,ne,t),D=`${A}.translations.json`;qs(D,JSON.stringify(S,null,2)),P("Traducciones exportadas como JSON.","success")}catch(S){console.error(S),P("No se pudo generar el JSON de traducciones.","error")}},ee=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(r,null,2)),P("JSON copiado al portapapeles.","success")}catch{P("No se pudo copiar al portapapeles.","error")}},le=()=>{var S;return(S=z.current)==null?void 0:S.click()},ue=()=>{var S;return(S=O.current)==null?void 0:S.click()},ge=S=>{var B;const D=(B=S.target.files)==null?void 0:B[0];if(!D)return;if(!window.confirm("Vas a reemplazar el esquema actual. ¿Continuar?")){S.currentTarget.value="";return}const Z=new FileReader;Z.onload=()=>{try{const q=JSON.parse(String(Z.result));if(!Array.isArray(q.layout)||!Array.isArray(q.fields)){P("JSON inválido: faltan layout/fields.","error");return}l(q),i(),P("Esquema importado correctamente.","success")}catch{P("No se pudo parsear el JSON.","error")}},Z.readAsText(D),S.currentTarget.value=""},ce=async S=>{var B;const D=S.target,_=(B=D.files)==null?void 0:B[0];if(!_)return;if(!window.confirm("Al importar un proyecto ZIP se reemplazará el esquema actual, los servicios y las traducciones. ¿Continuar?")){D.value="";return}try{await N_({file:_,setSchema:q=>{l(q),i()},setServices:W,translationAdapter:ne}),P("Proyecto importado correctamente.","success")}catch(q){console.error(q),P(q.message||"Error al importar ZIP","error")}D.value=""},se=()=>{window.confirm("Crear un esquema nuevo vacío (perderás cambios no guardados). ¿Continuar?")&&(l(D=>{D.layout=[{type:"rows",sections:[{sectionTitle:"Sección 1",defaultOpen:!0,rows:[{title:"",columns:[{width:"w-full",fields:[]}]}]}]}],D.fields=[],D.successMessage="Guardado",D.errorMessage="Error",D.onSubmit=async()=>{}}),i(),P("Esquema nuevo creado.","info"))},we=async()=>{try{const S=M0(te,Gs(`${A}.json`));await Q.write(S,JSON.stringify(r,null,2)),P(`Guardado rápido en ${S}`,"success")}catch(S){console.error(S),P("Guardado rápido fallido.","error")}},de=async()=>{try{const S=Gs(`${A}.json`),D=window.prompt("Guardar como (archivo en baseDir):",S);if(!D)return;const _=M0(te,Gs(D));await Q.write(_,JSON.stringify(r,null,2)),P(`Guardado en ${_}`,"success")}catch(S){console.error(S),P("No se pudo guardar el archivo.","error")}},{config:me,updateConfig:R}=T_({undo:()=>{c>0&&n()},redo:()=>{u>0&&o()},save:()=>{we()},saveAs:()=>{de()},toggleRelations:()=>{I()},togglePreview:()=>{x(g==="design"?"preview":g==="preview"?"code":"design")},deleteField:()=>{d.kind==="field"&&(!h.confirmDelete||window.confirm(`¿Eliminar el campo "${d.name}"?`))&&(m(d.name),P("Campo eliminado","success"))},duplicateField:()=>{d.kind==="field"&&(f(d.name),P("Campo duplicado","success"))},copy:()=>{ee()},newSchema:()=>{se()},importSchema:()=>{le()},exportSchema:()=>{F()}}),J=[{label:"Nuevo esquema",icon:pd,onSelect:se},{label:"Importar JSON...",icon:vd,onSelect:le},{label:"Importar Proyecto (ZIP)...",icon:U0,onSelect:ue},{label:"Generar desde DTO...",icon:cn,onSelect:()=>y(!0)},{label:"Gestionar Servicios...",icon:cn,onSelect:()=>N(!0)},{label:"Guardar",icon:Xs,onSelect:we},{label:"Guardar como...",icon:Xs,onSelect:de}],H=[{label:"Exportar JSON",icon:Cn,onSelect:F},{label:"Exportar Yup (.ts)",icon:Xt,onSelect:Y},{label:"Exportar Traducciones",icon:To,onSelect:U},{label:"Copiar JSON",icon:Fl,onSelect:ee},{label:"Exportar Proyecto (ZIP)",icon:el,onSelect:()=>{const S=(ae==null?void 0:ae.registry)||{};console.log("Services Registry for Export:",S),L_({schema:r,translationsAdapter:ne,i18n:t,servicesRegistry:S,baseName:A}),P("Proyecto exportado correctamente","success")}}];return s.jsxs("div",{className:"pb-1 bg-[var(--color-ds-background-page)]",children:[s.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-sm px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(It,{icon:ed,size:"sm",onClick:n,disabled:c===0,ariaLabel:`Deshacer (${qn(me.undo)})`,title:`Deshacer (${qn(me.undo)})`}),s.jsx(It,{icon:td,size:"sm",onClick:o,disabled:u===0,ariaLabel:`Rehacer (${qn(me.redo)})`,title:`Rehacer (${qn(me.redo)})`}),s.jsx(A0,{}),s.jsx(x_,{}),s.jsx(A0,{}),s.jsx(sa,{trigger:s.jsxs("span",{className:"flex items-center gap-1 px-2 py-1.5 text-sm font-medium text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-background-neutral-hover)] rounded-md transition-colors",children:["Archivo",s.jsx(Ut,{className:"w-3 h-3 opacity-50"})]}),items:J}),s.jsx(sa,{trigger:s.jsxs("span",{className:"flex items-center gap-1 px-2 py-1.5 text-sm font-medium text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-background-neutral-hover)] rounded-md transition-colors",children:[e("ds.editor.toolbar.export"),s.jsx(Ut,{className:"w-3 h-3 opacity-50"})]}),items:H}),s.jsx(fe,{variant:"subtle",size:"sm",onClick:()=>N(!0),icon:el,ariaLabel:"Importar/Gestionar Servicios OpenAPI",className:"ml-1 text-[var(--color-ds-primary-700)] bg-[var(--color-ds-primary-50)] hover:bg-[var(--color-ds-primary-100)] ring-[var(--color-ds-primary-200)]",children:"Servicios"}),s.jsx(fe,{variant:"subtle",size:"sm",onClick:()=>$(!0),icon:_o,ariaLabel:"Configurar carga inicial de datos",className:"ml-1 text-[var(--color-ds-primary-700)] bg-[var(--color-ds-primary-50)] hover:bg-[var(--color-ds-primary-100)] ring-[var(--color-ds-primary-200)]",children:"Pre-carga"}),s.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>V(!0),icon:cn,ariaLabel:"Ver variables de sistema",title:"Variables de sistema",className:"ml-1 text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)]"}),s.jsx("input",{ref:z,type:"file",accept:"application/json",className:"hidden",onChange:ge,"aria-label":e("ds.editor.toolbar.import")}),s.jsx("input",{ref:O,type:"file",accept:".zip,application/zip,application/x-zip-compressed",className:"hidden",onChange:ce,"aria-label":"Importar Proyecto ZIP"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(It,{icon:p?Vl:Vr,size:"sm",onClick:I,ariaLabel:e(p?"ds.editor.toolbar.hideRelations":"ds.editor.toolbar.showRelations"),title:e(p?"ds.editor.toolbar.hideRelations":"ds.editor.toolbar.showRelations"),className:"text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)]"}),s.jsx(It,{icon:Rn,size:"sm",onClick:()=>j(!0),ariaLabel:e("ds.editor.toolbar.shortcuts"),title:e("ds.editor.toolbar.shortcuts")}),s.jsx("div",{className:"w-px h-6 bg-[var(--color-ds-border-default-50)] mx-1"}),s.jsx(xa,{value:g,onChange:S=>x(S),size:"sm",variant:"square",items:[{id:"design",label:e("ds.editor.modes.design"),icon:gn},{id:"preview",label:e("ds.editor.modes.preview"),icon:Vr},{id:"code",label:e("ds.editor.modes.code"),icon:Xt}]})]})]}),s.jsx(Z_,{isOpen:w,onClose:()=>j(!1),config:me,onSaveShortcuts:R}),s.jsx(YF,{open:k,onClose:()=>y(!1)}),s.jsx(f_,{isOpen:C,onClose:()=>N(!1)}),M&&s.jsx(m_,{isOpen:!0,onClose:()=>$(!1)}),s.jsx(b_,{isOpen:T,onClose:()=>V(!1)})]})}const Wa="application/x-ds-field-template",O0="application/x-ds-layout-kind";function Ks(e){return e.layout.find(t=>(t==null?void 0:t.type)==="rows")}function D_({className:e,children:t}){var w;const r=oe(j=>j.schema),n=oe(j=>j.addFieldAndPlace),o=oe(j=>j.addRowsBlockAt),l=oe(j=>j.addSection),i=oe(j=>j.addRowToSection),c=oe(j=>j.setRowColumns),u=oe(j=>j.moveField),[d,m]=E.useState(!1),f=E.useMemo(()=>{var y;const j=Ks(r);if(!j)return[];const k=[];return(y=j.sections)==null||y.forEach((C,N)=>{var M;(M=C.rows)==null||M.forEach(($,T)=>{($.columns??[]).forEach((V,I)=>{var P;const z=((P=V.fields)==null?void 0:P.length)??0,O=Math.max(1,z+1);for(let Q=0;Q<O;Q++)k.push({kind:"field-slot",sectionIdx:N,rowIdx:T,colIdx:I,insertIdx:Q,key:`s${N}-r${T}-c${I}-i${Q}`})})})}),k},[r]),h=E.useCallback(()=>{var C,N;const j=r.layout.findIndex(M=>(M==null?void 0:M.type)==="rows"),k=r.layout[j];return k?(C=k.sections)!=null&&C.length?(N=k.sections[0].rows)!=null&&N.length?((k.sections[0].rows[0].columns??[]).length||c==null||c(j,0,0,1),{s:0,r:0,c:0}):(i==null||i(j,0),{s:0,r:0,c:0}):(l==null||l("Sección 1"),{s:0,r:0,c:0}):(o==null||o(r.layout.length??0,"Sección 1"),{s:0,r:0,c:0})},[r,o,l,i,c]),p=E.useCallback(j=>{var y;const k=((y=j.dataTransfer)==null?void 0:y.types)||[];(k.includes(Wa)||k.includes(O0))&&(j.preventDefault(),j.dataTransfer.dropEffect="copy",m(k.includes(Wa)?"field":"layout"))},[]),v=E.useCallback(()=>m(!1),[]),b=E.useCallback(j=>{var N;const k=j.dataTransfer.getData(O0);if(!k)return!1;const{kind:y}=JSON.parse(k),C=((N=r==null?void 0:r.layout)==null?void 0:N.length)??0;return y==="section-layout"&&(o==null||o(C,"Nueva sección")),!0},[(w=r==null?void 0:r.layout)==null?void 0:w.length,o]),g=E.useCallback((j,k)=>{const y=k.dataTransfer.getData(Wa);if(!y)return!1;const{fieldTemplate:C}=JSON.parse(y);return n(C,j.sectionIdx,j.rowIdx,j.colIdx),queueMicrotask(()=>{var V;const N=oe.getState().schema,T=(((V=Ks(N).sections[j.sectionIdx].rows[j.rowIdx].columns[j.colIdx].fields)==null?void 0:V.length)??1)-1;j.insertIdx>=0&&j.insertIdx<T&&u({s:j.sectionIdx,r:j.rowIdx,c:j.colIdx,idx:T},{s:j.sectionIdx,r:j.rowIdx,c:j.colIdx,idx:j.insertIdx})}),!0},[n,u]),x=E.useCallback(j=>{if(j.preventDefault(),j.stopPropagation(),b(j)){m(!1);return}const k=j.dataTransfer.getData(Wa);if(k){const{fieldTemplate:y}=JSON.parse(k),C=h();n(y,C.s,C.r,C.c)}m(!1)},[b,h,n]);return s.jsxs("div",{className:["relative",e].filter(Boolean).join(" "),onDragOver:p,onDragLeave:v,onDrop:x,children:[t,d&&s.jsxs("div",{className:"absolute inset-0 z-40",children:[s.jsx("div",{className:"absolute inset-0 bg-black/5 pointer-events-none"}),s.jsx("div",{className:"absolute inset-0 px-4 py-4 overflow-auto space-y-4",children:(()=>{var y;const j=Ks(r);if(!j||!((y=j.sections)!=null&&y.length)){const C=h(),N={kind:"field-slot",sectionIdx:C.s,rowIdx:C.r,colIdx:C.c,insertIdx:0,key:"init"};return s.jsx("div",{className:"min-h-[220px] border-2 border-dashed rounded-2xl bg-white/70 flex items-center justify-center text-ds-sm",onDragOver:M=>M.preventDefault(),onDrop:M=>{M.preventDefault(),M.stopPropagation(),g(N,M),m(!1)},children:"Suelta aquí para empezar"})}const k=[];return j.sections.forEach((C,N)=>{var M;(M=C.rows)==null||M.forEach(($,T)=>{const V=[];($.columns??[]).forEach((I,z)=>{const O=f.filter(P=>P.sectionIdx===N&&P.rowIdx===T&&P.colIdx===z);V.push(O)}),k.push({key:`s${N}-r${T}`,cols:V})})}),k.map(C=>s.jsx("div",{className:"grid gap-3 pointer-events-none",style:{gridTemplateColumns:`repeat(${C.cols.length||1}, minmax(0,1fr))`},children:C.cols.map((N,M)=>{const $=N.length===1;return s.jsx("div",{className:"pointer-events-auto",children:s.jsx("div",{className:["rounded-xl border-2 border-dashed bg-white/60",$?"min-h-[160px]":"py-2"].join(" "),children:s.jsx("div",{className:"flex flex-col gap-2",children:N.map(T=>s.jsx("div",{className:"h-7 rounded-md border border-transparent hover:border-[var(--color-ds-border-default)] hover:bg-white/80 flex items-center justify-center text-ds-sm text-[var(--color-ds-text-secondary)]",onDragOver:V=>V.preventDefault(),onDrop:V=>{V.preventDefault(),V.stopPropagation(),g(T,V),m(!1)},title:`Insertar en Col ${T.colIdx+1}, posición ${T.insertIdx+1}`,children:$?"Soltar aquí":T.insertIdx===N.length-1?"Añadir al final":"Insertar aquí"},T.key))})})},`${C.key}-c${M}`)})},C.key))})()})]})]})}function P_({nodeIdx:e,insertAt:t}){const r={scope:"rows-section",nodeIdx:e,insertAt:t},{setNodeRef:n,isOver:o}=tr({id:`rows-section:drop:${e}:${t}`,data:r});return s.jsx("div",{ref:n,className:["h-2 my-1 w-full rounded-sm transition relative mx-1 px-1",o?"bg-[var(--color-ds-border-default)]/30 ring-1 ring-[var(--color-ds-border-default)]":"bg-transparent"].join(" "),"aria-label":`Insertar sección en posición ${t+1}`})}function z_({nodeIdx:e,sIdx:t}){const r=`rows-section:drag:${e}:${t}`,n={kind:"rows-section",nodeIdx:e,sIdx:t},{attributes:o,listeners:l,setNodeRef:i,isDragging:c}=Gr({id:r,data:n});return s.jsx("div",{ref:i,...o,...l,role:"button",title:"Arrastrar sección","aria-grabbed":c,className:"shrink-0 w-6 h-6 grid place-items-center cursor-grab active:cursor-grabbing rounded text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-background-muted)]",children:"⇅"})}function L0(e){const r={...e.scope==="rows-column"?{scope:"rows-column",s:e.s,r:e.r,c:e.c,rowsNodeIdx:e.rowsNodeIdx}:{scope:"tabs-column",tabKey:e.tabKey,s:e.s,r:e.r,c:e.c},insertAt:Number.MAX_SAFE_INTEGER},{setNodeRef:n,isOver:o}=tr({id:JSON.stringify(r),data:r});return s.jsx("div",{ref:n,className:o?"ring-5 ring-[var(--color-ds-border-default)] rounded-md":"","aria-dropeffect":o?"copy":void 0,"data-drop-scope":e.scope,children:e.children})}function H_(e,t=44){if(!e)return t;const r=e.previousElementSibling,n=e.nextElementSibling,o=c=>{var u;return((u=c==null?void 0:c.querySelector)==null?void 0:u.call(c,"[data-sortable-item]"))||c},l=o(r)??o(n)??null,i=(l==null?void 0:l.getBoundingClientRect().height)??0;return Math.max(32,Math.min(96,Math.round(i||t)))}function W_(e){var f,h,p,v,b,g,x,w;if(!e)return null;const t=e.kind??e.scope??e.type,r=e.s??((f=e.path)==null?void 0:f.s),n=e.r??((h=e.path)==null?void 0:h.r),o=e.c??((p=e.path)==null?void 0:p.c),l=e.idx??((v=e.path)==null?void 0:v.idx),i=e.index,c=e.rowsNodeIdx??e.nodeIdx??((b=e.path)==null?void 0:b.rowsNodeIdx),u=e.tabKey??((g=e.path)==null?void 0:g.tabKey),d=e.groupName??((x=e.path)==null?void 0:x.groupName),m=e.arrayName??((w=e.path)==null?void 0:w.arrayName);return{kind:t,s:r,r:n,c:o,idx:l,index:i,rowsNodeIdx:c,tabKey:u,groupName:d,arrayName:m}}function U_(e,t){if(!t)return!1;const r=n=>typeof n=="number"&&(e.insertAt===n||e.insertAt===n+1);if(e.scope==="rows-column"){if((t.kind==="field-in-rows"||t.kind==="rows-column")&&t.rowsNodeIdx===e.rowsNodeIdx&&t.s===e.s&&t.r===e.r&&t.c===e.c&&r(t.idx))return!0}else if(e.scope==="tabs-column"){if((t.kind==="field-in-tabs"||t.kind==="tabs-column")&&t.tabKey===e.tabKey&&t.s===e.s&&t.r===e.r&&t.c===e.c&&r(t.idx))return!0}else if(e.scope==="input-group"){if((t.kind==="field-in-inputgroup"||t.kind==="input-group")&&t.groupName===e.groupName&&r(t.idx))return!0}else if(e.scope==="array-items"&&(t.kind==="field-in-array"||t.kind==="array-items")&&t.arrayName===e.arrayName&&r(t.index))return!0;return!1}function Yt(e){let t;e.scope==="rows-column"?t={scope:"rows-column",rowsNodeIdx:e.rowsNodeIdx,s:e.s,r:e.r,c:e.c,insertAt:e.insertAt}:e.scope==="tabs-column"?t={scope:"tabs-column",tabKey:e.tabKey,s:e.s,r:e.r,c:e.c,insertAt:e.insertAt}:e.scope==="input-group"?t={scope:"input-group",groupName:e.groupName,insertAt:e.insertAt}:t={scope:"array-items",arrayName:e.arrayName,insertAt:e.insertAt};const r=E.useRef(null),{setNodeRef:n,isOver:o}=tr({id:JSON.stringify(t),data:t}),[l,i]=E.useState(44),c=e.scope==="input-group"?6:8,[u,d]=E.useState(null);Ea({onDragStart:b=>{var g,x;return d(((x=(g=b.active)==null?void 0:g.data)==null?void 0:x.current)??null)},onDragCancel:()=>d(null),onDragEnd:()=>d(null)});const m=U_(e,W_(u)),f=!!e.suppressAll||m;if(E.useEffect(()=>{if(!o||f)return;const b=H_(r.current,e.scope==="input-group"?36:44);i(b)},[o,e.scope,f]),f)return s.jsx("div",{ref:b=>{r.current=b,n(b)},style:{position:"absolute",inset:0,pointerEvents:"none"},role:"button","aria-dropeffect":o?"copy":void 0,"aria-label":`Soltar aquí (posición ${e.insertAt+1})`,"data-drop-scope":e.scope,"data-insert-at":e.insertAt});const h=e.insertAt===0,p={height:o?l:0,margin:o?`${c}px 0`:"0px",transition:"height 120ms ease, margin 120ms ease, opacity 80ms ease",opacity:o?1:0},v=e.scope==="input-group"?"w-full inline-flex":"w-full block";return s.jsx("div",{ref:b=>{r.current=b,n(b)},role:"button","aria-dropeffect":o?"copy":void 0,"aria-label":`Soltar aquí (posición ${e.insertAt+1})`,"data-drop-scope":e.scope,"data-insert-at":e.insertAt,className:v,style:p,children:o&&s.jsx("div",{"aria-hidden":!0,className:["w-full","rounded-md","border","border-dashed","border-[var(--color-ds-border-default-50)]",e.scope==="input-group"?"bg-[var(--color-ds-background-surface)]/70":"bg-[var(--color-ds-background)]/60","relative"].join(" "),style:{height:l,boxShadow:"inset 0 0 0 1px color-mix(in srgb, var(--color-ds-border-default-50) 30%, transparent)"},children:!e.suppressHint&&s.jsxs("div",{className:"absolute -top-2 left-3 px-1.5 py-0.5 rounded text-[11px] leading-none",style:{background:"var(--color-ds-background-elevated)",color:"var(--color-ds-text-secondary)",border:"1px solid var(--color-ds-border-default-50)"},children:["Soltar aquí",""]})})})}function xr(e){const t=e.kind==="field-in-tabs"?`${e.kind}:${e.tabKey}:${e.name}:${e.path.s}-${e.path.r}-${e.path.c}-${e.path.idx}`:e.kind==="field-in-rows"?`${e.kind}:${e.rowsNodeIdx}:${e.name}:${e.path.s}-${e.path.r}-${e.path.c}-${e.path.idx}`:e.kind==="field-in-inputgroup"?`${e.kind}:${e.groupName}:${e.name}:${e.path.idx}`:`${e.kind}:${e.arrayName}:${e.name}:${e.index}`,r=e.kind==="field-in-rows"?{kind:e.kind,name:e.name,path:e.path,rowsNodeIdx:e.rowsNodeIdx}:e.kind==="field-in-tabs"?{kind:e.kind,name:e.name,path:e.path,tabKey:e.tabKey}:e.kind==="field-in-inputgroup"?{kind:e.kind,name:e.name,path:e.path,groupName:e.groupName}:{kind:e.kind,name:e.name,arrayName:e.arrayName,index:e.index},{attributes:n,listeners:o,setNodeRef:l,isDragging:i}=Gr({id:t,data:r}),c=e.disableSelect?s.jsxs("span",{className:"text-[var(--color-ds-text-primary)] text-ds-sm text-left truncate inline-flex items-center gap-1",children:[e.icon?s.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-[var(--color-ds-text-secondary)]",children:e.icon}):null,s.jsx("span",{className:"truncate",children:e.name})]}):s.jsxs("button",{type:"button",className:"text-[var(--color-ds-text-primary)] text-ds-sm hover:underline text-left truncate inline-flex items-center gap-1",onClick:u=>{u.stopPropagation(),e.onSelect()},children:[e.icon?s.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-[var(--color-ds-text-secondary)]",children:e.icon}):null,s.jsx("span",{className:"truncate",children:e.name})]});return s.jsxs("div",{ref:l,className:["text-[var(--color-ds-text-primary)] group flex items-center justify-between rounded-md py-1 w-full","overflow-visible",i?"opacity-50":"opacity-100"].join(" "),"data-field-name":e.name,children:[c,s.jsx("div",{...o,...n,role:"button","aria-grabbed":i,"aria-label":`Arrastrar campo ${e.name}`,className:["text-[var(--color-ds-text-primary)] text-[11px] select-none cursor-grab active:cursor-grabbing","px-1 py-0.5 rounded-sm","hover:bg-[var(--color-ds-background-muted)]","focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"].join(" "),title:"Arrastra para reordenar",children:"⇅"})]})}function iu(e){return oe(E.useCallback(t=>{if(e)return t.schema.fields.find(r=>r.name===e)},[e]))}const q_=E.memo(({fieldOrName:e,groupName:t,index:r,onRemove:n,setSelection:o,confirmDelete:l})=>{const i=typeof e=="string"?e:e.name,u=iu(i)||(typeof e=="object"?e:void 0),d=u==null?void 0:u.name,m=(u==null?void 0:u.type)??"text";let f;u&&("label"in u?f=u.label:"groupLabel"in u&&(f=u.groupLabel));const h=dr(m),p=Dt(m);return s.jsxs("div",{className:"flex items-center justify-between w-full gap-2 rounded-md border bg-[var(--color-ds-background-page)] px-2 py-1",style:{borderColor:"var(--color-ds-border-default-50)",borderLeft:`4px solid ${h}`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, ${h} 18%, transparent)`},children:[d?s.jsx(xr,{kind:"field-in-inputgroup",groupName:t,name:d,path:{idx:r},onSelect:()=>o({kind:"field",name:d}),icon:p}):s.jsx("div",{className:"text-ds-sm opacity-80",children:f??"(inline sin nombre)"}),d?s.jsx(fe,{size:"xs",variant:"danger",onClick:()=>l("Eliminar campo","¿Estás seguro de que quieres eliminar este campo del grupo?",n),title:"Quitar del grupo",shape:"circle",icon:nt}):null]})}),G_=E.memo(function({field:t,index:r,nodeIdx:n,sIdx:o,rIdx:l,cIdx:i,parentType:c,tabKey:u,onDelete:d,confirmDelete:m}){const f=typeof t=="string"?t:t==null?void 0:t.name,p=iu(f)||(typeof t=="object"?t:void 0),v=oe(P=>P.setSelection),b=oe(P=>P.removeFieldFromInputGroup),g=oe(P=>P.removeFieldFromArray),x=(p==null?void 0:p.name)??f,w=(p==null?void 0:p.type)??"text",j=Dt(w),k=dr(w),y=()=>c==="rows"?s.jsx(xr,{kind:"field-in-rows",rowsNodeIdx:n,name:x,path:{s:o,r:l,c:i,idx:r},onSelect:()=>v({kind:"field",name:x}),icon:j}):s.jsx(xr,{kind:"field-in-tabs",tabKey:u,name:x,path:{s:o,r:l,c:i,idx:r},onSelect:()=>v({kind:"field",name:x}),icon:j}),C=(P,Q)=>c==="rows"?s.jsx(Yt,{scope:"rows-column",rowsNodeIdx:n,s:o,r:l,c:i,insertAt:P,suppressAll:Q}):s.jsx(Yt,{scope:"tabs-column",tabKey:u,s:o,r:l,c:i,insertAt:P,suppressAll:Q}),N=oe(P=>P.activeVariantId),M=oe(P=>P.schema.variants),$=E.useMemo(()=>M==null?void 0:M.find(P=>P.key===N),[M,N]),T=E.useMemo(()=>{var P;return(P=$==null?void 0:$.overrides)==null?void 0:P[x]},[$,x]),V=T==null?void 0:T.hidden,I=T==null?void 0:T.disabled,z=V?{opacity:.4,filter:"grayscale(100%)"}:{},O=()=>V||I?s.jsxs("div",{className:"flex gap-1 absolute top-0 right-8 -mt-2",children:[V&&s.jsx("span",{className:"bg-gray-500 text-white text-[9px] px-1 rounded shadow-sm",children:"Hidden"}),I&&s.jsx("span",{className:"bg-amber-500 text-white text-[9px] px-1 rounded shadow-sm",children:"Disabled"})]}):null;if(w==="inputGroup"){const P=p,Q=(P==null?void 0:P.type)==="inputGroup"&&Array.isArray(P==null?void 0:P.inputs)?P.inputs:[],te=(P==null?void 0:P.type)!=="inputGroup"&&Array.isArray(P==null?void 0:P.inputs)?P.inputs:[],ne=Q.length>0,ae=!ne&&te.length>0;return s.jsxs(E.Fragment,{children:[s.jsxs("div",{"data-field-name":x,className:"rounded-md border bg-[var(--color-ds-background-page)] relative",style:{borderColor:"var(--color-ds-border-default-50)",boxShadow:`inset 0 0 0 1px color-mix(in srgb, ${dr("inputGroup")} 18%, transparent)`,...z},children:[s.jsx(O,{}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 py-1 bg-[var(--color-ds-background-surface)] border-b border-[var(--color-ds-border-default-50)]",children:[c==="rows"?s.jsx(xr,{kind:"field-in-rows",rowsNodeIdx:n,name:x,path:{s:o,r:l,c:i,idx:r},onSelect:()=>v({kind:"field",name:x}),icon:Dt("inputGroup"),disableSelect:!0}):s.jsx(xr,{kind:"field-in-tabs",tabKey:u,name:x,path:{s:o,r:l,c:i,idx:r},onSelect:()=>v({kind:"field",name:x}),icon:Dt("inputGroup"),disableSelect:!0}),s.jsx(fe,{size:"xs",variant:"danger",onClick:d,title:"Quitar grupo del layout",shape:"circle",icon:nt})]}),s.jsx("div",{className:"p-2",children:s.jsxs("div",{className:"flex flex-row gap-2 flex-wrap relative",children:[s.jsx(Yt,{scope:"input-group",groupName:x,insertAt:0,suppressAll:!ne}),ne&&Q.map((W,A)=>{const F=typeof W=="string"?W:W.name??A;return s.jsxs(E.Fragment,{children:[s.jsx(q_,{fieldOrName:W,groupName:x,index:A,onRemove:()=>b(x,A),setSelection:v,confirmDelete:m}),s.jsx(Yt,{scope:"input-group",groupName:x,insertAt:A+1,suppressAll:!ne})]},`${x}-child-${F}`)}),!ne&&ae&&te.map((W,A)=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-dashed bg-[var(--color-ds-background-surface)] px-2 py-1 opacity-80",title:"Definido en FieldSchema.inputs (vista previa).",children:[s.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded-full border",children:(W==null?void 0:W.label)??(W==null?void 0:W.name)??"Input"}),s.jsx("span",{className:"text-[var(--color-ds-text-secondary)] text-ds-sm",children:"(solo vista)"})]},`${x}-ui-${(W==null?void 0:W.name)??A}`)),!ne&&!ae&&s.jsx("div",{className:"text-center text-[12px] text-[var(--color-ds-text-secondary)] border border-dashed border-[var(--color-ds-border-default-50)] rounded-md py-3 w-full",children:"Suelta inputs dentro del grupo"})]})})]}),C(r+1,!1)]})}if(w==="array"){const P=p,Q=Array.isArray(P==null?void 0:P.items)?P.items:[];return s.jsxs(E.Fragment,{children:[s.jsxs("div",{"data-field-name":x,className:"rounded-md border bg-[var(--color-ds-background-page)] relative",style:{borderColor:"var(--color-ds-border-default-50)",boxShadow:`inset 0 0 0 1px color-mix(in srgb, ${dr("array")} 18%, transparent)`,...z},children:[s.jsx(O,{}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 py-1 bg-[var(--color-ds-background-surface)] border-b border-[var(--color-ds-border-default-50)]",children:[c==="rows"?s.jsx(xr,{kind:"field-in-rows",rowsNodeIdx:n,name:x,path:{s:o,r:l,c:i,idx:r},onSelect:()=>v({kind:"field",name:x}),icon:Dt("array"),disableSelect:!0}):s.jsx(xr,{kind:"field-in-tabs",tabKey:u,name:x,path:{s:o,r:l,c:i,idx:r},onSelect:()=>v({kind:"field",name:x}),icon:Dt("array"),disableSelect:!0}),s.jsx(fe,{size:"xs",variant:"danger",onClick:d,title:"Quitar repeater",shape:"circle",icon:nt})]}),s.jsxs("div",{className:"p-3 bg-[var(--color-ds-background-subtle)] rounded-b-md",children:[s.jsx("div",{className:"text-[10px] uppercase font-bold tracking-wider text-[var(--color-ds-text-tertiary)] mb-2 pl-1 select-none",children:"Plantilla de Item"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Yt,{scope:"array-items",arrayName:x,insertAt:0,suppressAll:Q.length===0}),Q.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 text-center text-[12px] text-[var(--color-ds-text-secondary)] border-2 border-dashed border-[var(--color-ds-border-default-50)] rounded-lg py-6 bg-[var(--color-ds-background-page)] transition-colors hover:border-[var(--color-ds-border-default)] hover:bg-[var(--color-ds-background-surface)]",children:[s.jsx("div",{className:"p-2 rounded-full bg-[var(--color-ds-background-subtle)]",children:s.jsx(er,{className:"w-5 h-5 opacity-50"})}),s.jsx("span",{className:"font-medium",children:"Arrastra campos aquí"}),s.jsx("span",{className:"text-[11px] opacity-70 max-w-[180px]",children:"Define qué campos tendrá cada elemento de la lista"})]}),Q.map((te,ne)=>{const ae=te.name,W=te.type,A=Dt(W),F=dr(W);return s.jsxs(E.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded border bg-[var(--color-ds-background-page)] px-2 py-1",style:{borderLeft:`3px solid ${F}`},children:[s.jsx(xr,{kind:"field-in-array",arrayName:x,name:ae,index:ne,path:{idx:ne},onSelect:()=>v({kind:"field",name:ae}),icon:A}),s.jsx(fe,{size:"xs",variant:"danger",onClick:()=>g(x,ne),title:"Eliminar campo del template",shape:"circle",icon:nt})]}),s.jsx(Yt,{scope:"array-items",arrayName:x,insertAt:ne+1,suppressAll:Q.length===0})]},`${x}-item-${ne}`)})]})]})]}),C(r+1,!1)]})}return s.jsxs(E.Fragment,{children:[s.jsxs("div",{"data-field-name":x,className:"flex items-center justify-between gap-2 w-full rounded-md border bg-[var(--color-ds-background-page)] px-2 py-1 relative",style:{borderColor:"var(--color-ds-border-default-50)",borderLeft:`4px solid ${k}`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, ${k} 18%, transparent)`,...z},children:[s.jsx(O,{}),y(),s.jsx(fe,{size:"xs",variant:"danger",onClick:d,title:"Quitar del layout",shape:"circle",icon:nt})]}),C(r+1,!1)]})}),K_=E.memo(function({col:t,widthClass:r,nodeIdx:n,sIdx:o,rIdx:l,cIdx:i,parentType:c,tabKey:u,confirmDelete:d}){const m=oe(y=>y.removeColumn),f=oe(y=>y.removeTabColumn),h=oe(y=>y.placeFieldInColumn),p=oe(y=>y.placeFieldInTabColumn),v=oe(y=>y.removeFieldFromLayout),b=oe(y=>y.removeFieldFromTabLayout),g=t.fields??[],x=oe(E.useCallback(y=>{const C=y.schema.fields;for(let N=C.length-1;N>=0;N--){const M=C[N];if(M.type!=="inputGroup"&&M.type!=="button")return M.name}},[])),w=()=>{d("Eliminar columna","¿Estás seguro de que quieres eliminar esta columna? Se perderán los campos que contiene.",()=>{c==="rows"?m(n,o,l,i):f(u,o,l,i)})},j=()=>{x&&(c==="rows"?h(x,n,o,l,i):p(x,u,o,l,i))},k=()=>s.jsxs("div",{className:"bg-[var(--color-ds-background-page)] overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-[var(--color-ds-background-surface)]",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"inline-flex items-center justify-center text-[11px] leading-none px-1.5 py-0.5 rounded-full border text-[var(--color-ds-text-primary)] border-[var(--color-ds-border-default-50)]",children:["Col ",i+1]}),s.jsx("span",{className:"text-[11px] leading-none text-[var(--color-ds-text-secondary)]",children:t.width||r||"flex-1"})]}),s.jsx("div",{className:"flex items-center gap-1",children:s.jsx(fe,{size:"xs",variant:"danger",onClick:w,title:"Eliminar columna",shape:"circle",icon:nt})})]}),s.jsxs("div",{className:"p-2 relative",children:[s.jsxs("div",{className:"space-y-2",children:[c==="rows"?s.jsx(Yt,{scope:"rows-column",rowsNodeIdx:n,s:o,r:l,c:i,insertAt:0,suppressAll:g.length===0}):s.jsx(Yt,{scope:"tabs-column",tabKey:u,s:o,r:l,c:i,insertAt:0,suppressAll:g.length===0}),g.length===0&&s.jsx("div",{className:"text-center text-[12px] text-[var(--color-ds-text-secondary)] border border-dashed border-[var(--color-ds-border-default-50)] rounded-md py-4",children:"Suelta campos aquí"}),g.map((y,C)=>s.jsx(G_,{field:y,index:C,nodeIdx:n,sIdx:o,rIdx:l,cIdx:i,parentType:c,tabKey:u,onDelete:()=>{d("Eliminar campo","¿Estás seguro de que quieres eliminar este campo?",()=>{c==="rows"?v({nodeIdx:n,s:o,r:l,c:i,idx:C}):b({tabKey:u,s:o,r:l,c:i,idx:C})})},confirmDelete:d},`${typeof y=="string"?y:y.name}-${C}`))]}),s.jsx("div",{className:"mt-2 text-center",children:s.jsx(fe,{size:"xs",variant:"outline",onClick:j,title:"Colocar el último campo creado en esta columna",children:"Colocar último campo"})})]})]});return c==="rows"?s.jsx(L0,{scope:"rows-column",rowsNodeIdx:n,s:o,r:l,c:i,children:k()}):s.jsx(L0,{scope:"tabs-column",tabKey:u,s:o,r:l,c:i,children:k()})}),_i=({value:e,onChange:t,placeholder:r="Click to edit",className:n,inputClassName:o,autoFocus:l=!1})=>{const[i,c]=E.useState(l),[u,d]=E.useState(e),m=E.useRef(null);E.useEffect(()=>{d(e)},[e]),E.useEffect(()=>{i&&m.current&&(m.current.focus(),m.current.select())},[i]);const f=()=>{c(!1),u.trim()!==e&&t(u)},h=p=>{p.key==="Enter"?(p.preventDefault(),f()):p.key==="Escape"&&(d(e),c(!1))};return i?s.jsx("input",{ref:m,value:u,onChange:p=>d(p.target.value),onBlur:f,onKeyDown:h,placeholder:r,className:he("bg-transparent border border-transparent focus:border-gray-400 dark:focus:border-gray-500 rounded px-0.5 -ml-0.5 outline-none w-full min-w-[20px] leading-inherit font-inherit text-inherit","focus:ring-2 focus:ring-gray-200 dark:focus:ring-gray-700",o,n),onClick:p=>p.stopPropagation(),onPointerDown:p=>p.stopPropagation(),onMouseDown:p=>p.stopPropagation()}):s.jsxs("span",{onDoubleClick:p=>{p.preventDefault(),p.stopPropagation(),c(!0)},onClick:p=>{p.preventDefault()},className:he("group cursor-text hover:bg-gray-100 dark:hover:bg-white/5 rounded px-0.5 -mx-0.5 border border-transparent hover:border-dashed hover:border-gray-400 truncate min-w-[20px] inline-flex items-center gap-1",!e&&"text-gray-400 italic",n),title:"Double click to edit",children:[s.jsx("span",{className:"truncate",children:e||r}),s.jsx("span",{role:"button",onClick:p=>{p.stopPropagation(),p.preventDefault(),c(!0)},className:"opacity-0 group-hover:opacity-100 transition-opacity text-gray-400 hover:text-blue-500 cursor-pointer",title:"Edit",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"w-3 h-3",children:[s.jsx("path",{d:"M5.433 13.917l1.262-3.155A4 4 0 017.58 9.42l6.92-6.918a2.121 2.121 0 013 3l-6.92 6.918c-.383.383-.84.685-1.343.886l-3.154 1.262a.5.5 0 01-.65-.65z"}),s.jsx("path",{d:"M3.5 5.75c0-.69.56-1.25 1.25-1.25H10A.75.75 0 0010 3H4.75A2.75 2.75 0 002 5.75v9.5A2.75 2.75 0 004.75 18h9.5A2.75 2.75 0 0017 15.25V10a.75.75 0 00-1.5 0v5.25c0 .69-.56 1.25-1.25 1.25h-9.5c-.69 0-1.25-.56-1.25-1.25v-9.5z"})]})})]})},J_=e=>e<=1?["w-full"]:e===2?["w-1/2","w-1/2"]:e===3?["w-1/3","w-1/3","w-1/3"]:Array.from({length:e},()=>"flex-1"),Y_=[1,2,3,4],X_=E.memo(function({row:t,nodeIdx:r,sIdx:n,rIdx:o,parentType:l,tabKey:i,confirmDelete:c}){const u=oe($=>$.setRowColumns),d=oe($=>$.removeRowFromSection),m=oe($=>$.addRowToSectionAt),f=oe($=>$.setRowTitle),h=oe($=>$.setTabRowColumns),p=oe($=>$.removeTabRow),v=oe($=>$.addRowToTabSectionAt),b=oe($=>$.setTabRowTitle),[g,x]=E.useState(!!t.title),w=t.columns??[],j=w.length===0,k=J_(w.length),y=$=>{l==="rows"?u(r,n,o,$):h(i,n,o,$)},C=()=>{c("Eliminar fila","¿Estás seguro de que quieres eliminar esta fila? Se perderán todos los campos que contiene.",()=>{l==="rows"?d(r,n,o):p(i,n,o)})},N=$=>{l==="rows"?f(r,n,o,$):b(i,n,o,$),$.trim()||x(!1)},M=()=>{x(!0)};return s.jsxs("div",{className:"space-y-0",children:[(g||t.title)&&s.jsx("div",{className:"px-3 py-2 bg-[var(--color-ds-background-elevated)] border-b border-[var(--color-ds-border-default-50)]",children:s.jsx(_i,{value:t.title||"",onChange:N,placeholder:"Título de la fila (opcional)",className:"text-sm font-medium text-[var(--color-ds-text-primary)]"})}),s.jsxs("div",{className:"px-3 py-2 flex items-center gap-1 bg-[var(--color-ds-background)] border-b border-[var(--color-ds-border-default-50)]",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap flex-1 min-w-0",children:[s.jsxs("span",{className:"text-[11px] leading-none uppercase tracking-wide text-[var(--color-ds-text-secondary)]",children:["Fila ",o+1]}),!g&&!t.title&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"h-3 w-px bg-[var(--color-ds-border-default-50)]"}),s.jsx(fe,{size:"xs",variant:"ghost",onClick:M,title:"Añadir título a la fila",icon:Bo,className:"text-[10px] text-[var(--color-ds-text-secondary)]",children:"Título"})]}),s.jsx("div",{className:"h-3 w-px bg-[var(--color-ds-border-default-50)]"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:Y_.map($=>s.jsx(fe,{size:"xs",variant:"outline",className:"rounded-full px-2 py-0.5",onClick:()=>y($),title:`${$} columna(s)`,children:$},$))})]}),s.jsx(fe,{size:"xs",variant:"danger",onClick:C,title:"Eliminar fila",shape:"circle",icon:nt})]}),j?s.jsx("div",{className:"rounded-md border border-dashed p-6 text-center border-[var(--color-ds-border-default-50)] text-[var(--color-ds-text-secondary)]",children:'No hay columnas. Usa "+ columna".'}):s.jsx("div",{children:w.map(($,T)=>s.jsx(K_,{col:$,widthClass:k[T],nodeIdx:r,sIdx:n,rIdx:o,cIdx:T,parentType:l,tabKey:i,confirmDelete:c},`${l==="rows"?"col":"tcol"}-${r}-${n}-${o}-${T}`))}),s.jsx("div",{className:"flex justify-center p-1 bg-[var(--color-ds-background-surface)] border-t border-[var(--color-ds-border-default-50)]",children:s.jsx(fe,{size:"xs",variant:"ghost",className:"w-full justify-center text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)]",onClick:()=>{l==="rows"?m(r,n,o+1):v(i,n,o+1)},title:"Añadir fila debajo",children:"+ Añadir fila debajo"})})]})});function Q_({nodeIdx:e,tabKey:t,insertAt:r}){const n={scope:"tab-section",nodeIdx:e,tabKey:t,insertAt:r},{setNodeRef:o,isOver:l}=tr({id:`tab-section:${e}:${t}:${r}`,data:n});return s.jsx("div",{ref:o,className:["h-2 my-1 w-full rounded-sm transition relative -mx-1 px-1",l?"bg-[var(--color-ds-border-default)]/30 ring-1 ring-[var(--color-ds-border-default)]":"bg-transparent"].join(" "),"aria-label":`Insertar sección de pestaña en posición ${r+1}`})}function eT({nodeIdx:e,tabKey:t,sIdx:r}){const n=`tab-section:${e}:${t}:${r}`,o={kind:"tab-section",nodeIdx:e,tabKey:t,sIdx:r},{attributes:l,listeners:i,setNodeRef:c,isDragging:u}=Gr({id:n,data:o});return s.jsx("div",{ref:c,...l,...i,title:"Arrastrar sección de pestaña","aria-grabbed":u,className:"shrink-0 w-6 h-6 grid place-items-center cursor-grab active:cursor-grabbing rounded text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-background-muted)]",children:"⇅"})}function cu({expanded:e,onClick:t,labelExpanded:r,labelCollapsed:n,titleExpanded:o,titleCollapsed:l,className:i=""}){return s.jsx(fe,{size:"xs",variant:"ghost","aria-expanded":e,"aria-label":e?r:n,onClick:t,title:e?o??"Colapsar":l??"Expandir",className:`shrink-0 w-8 h-8 p-0 grid place-items-center ${i}`,children:s.jsx(Ut,{className:`w-4 h-4 text-[var(--color-ds-text-primary)] transition-transform duration-150 ${e?"rotate-180":""}`})})}function tT({section:e,onChange:t,formId:r,parentType:n,sectionIndex:o,tabKey:l}){const{translations:i}=St(),{t:c}=Ct(),[u,d]=E.useState("");E.useEffect(()=>{const h=e.sectionTitle,p=h&&(h.startsWith("forms.")||h.startsWith("ds."));if(i&&p){const v=i.getTranslation(h);d(v!==h?v:h)}else d(ct(c,h))},[e.sectionTitle,i,c]);const m=async()=>{const h=e.sectionTitle||"";if(u===(i&&h.startsWith("forms.")?i.getTranslation(h):ct(c,h)))return;if(!i){t(u);return}if((h.startsWith("forms.")||h.startsWith("ds."))&&!h.startsWith("ds."))await i.updateTranslation(h,u);else{const v=r||"defaultForm",b=Date.now().toString(36);let g="";n==="tabs"&&l?g=`forms.${v}.tabs.${l}.sections.s_${b}.title`:g=`forms.${v}.sections.s_${b}.title`,console.log("Generating section key",g,u),await i.updateTranslation(g,u),t(g)}},f=h=>{h.key==="Enter"&&h.currentTarget.blur()};return s.jsx("input",{type:"text",value:u,onChange:h=>d(h.target.value),onBlur:m,onKeyDown:f,className:"bg-transparent font-medium text-[var(--color-ds-text-primary)] placeholder-[var(--color-ds-text-tertiary)] outline-none border-b border-transparent focus:border-[var(--color-ds-border-accent)] transition-colors w-full",placeholder:"Sección sin título"})}const du=E.memo(function({section:t,nodeIdx:r,sIdx:n,parentType:o,tabKey:l,confirmDelete:i}){const{t:c}=Ct(),[u,d]=E.useState(!1),m=oe(x=>{var w,j;return((w=x.schema)==null?void 0:w.formId)||((j=x.schema)==null?void 0:j.id)}),f=oe(x=>x.renameSectionAt),h=oe(x=>x.removeSectionAt),p=oe(x=>x.removeTabSection),v=oe(x=>x.renameTabSection),b=x=>{o==="rows"?f(r,n,x):v(l,n,x)},g=()=>{i("Eliminar sección","¿Estás seguro de que quieres eliminar esta sección? Se perderán todos los campos que contiene.",()=>{o==="tabs"&&l?p(l,n):h(r,n)})};return s.jsxs("div",{className:"rounded-lg border border-[var(--color-ds-border-default-50)] overflow-hidden",children:[s.jsx("div",{className:"pr-3 bg-[var(--color-ds-background-surface)] border-b border-[var(--color-ds-border-default-50)]",children:s.jsxs("div",{className:"flex items-center gap-2 min-h-9 py-1",children:[s.jsx(cu,{expanded:!u,onClick:()=>d(!u),labelExpanded:"Colapsar sección",labelCollapsed:"Expandir sección",className:o==="tabs"?"ml-2":""}),s.jsx("div",{className:"flex-1 min-w-0 px-2 font-medium text-[var(--color-ds-text-primary)]",children:s.jsx(tT,{section:t,onChange:b,formId:m,parentType:o,sectionIndex:n,tabKey:l})}),o==="rows"?s.jsx(z_,{nodeIdx:r,sIdx:n}):s.jsx(eT,{nodeIdx:r,tabKey:l,sIdx:n}),s.jsx("div",{className:"flex flex-wrap gap-1 ml-auto",children:s.jsx(fe,{size:"xs",variant:"danger",onClick:g,title:"Eliminar sección",shape:"circle",icon:nt})})]})}),!u&&s.jsx("div",{className:"bg-[var(--color-ds-background-page)]",children:t.rows.map((x,w)=>s.jsx(X_,{row:x,nodeIdx:r,sIdx:n,rIdx:w,parentType:o,tabKey:l,confirmDelete:i},`${o==="rows"?"row":"trow"}-${o==="tabs"?l:r}-${w}`))})]})});function $0({nodeIdx:e,insertAt:t}){const r={scope:"tabs-tab",nodeIdx:e,insertAt:t},{setNodeRef:n,isOver:o}=tr({id:`tabs-tab:${e}:${t}`,data:r});return s.jsx("div",{ref:n,className:["w-1 h-5 rounded-md transition",o?"bg-[var(--color-ds-border-default)]/30 ring-1 ring-[var(--color-ds-border-default)]":"bg-transparent"].join(" "),title:`Insertar pestaña en posición ${t+1}`})}function rT({className:e=""}){return s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",className:e,fill:"currentColor",children:[1,5].map(t=>[1,4,7].map((r,n)=>s.jsx("circle",{cx:t,cy:r,r:"1"},`${t}-${r}-${n}`)))})}function nT({nodeIdx:e,index:t,tabKey:r,label:n,onRename:o}){const l=`tabs-tab:${e}:${t}:${r}`,i={kind:"tabs-tab",nodeIdx:e,index:t,tabKey:r},{attributes:c,listeners:u,setNodeRef:d,isDragging:m}=Gr({id:l,data:i});return s.jsxs("div",{ref:d,...c,...u,tabIndex:0,"aria-grabbed":m,"aria-label":`Arrastrar pestaña "${n}"`,title:`Arrastrar pestaña "${n}"`,className:["inline-flex items-center gap-1 select-none","h-6 px-1.5 rounded-full","text-[11px] leading-none","border border-[var(--color-ds-border-default-50)]","bg-[var(--color-ds-background-surface)]","text-[var(--color-ds-text-primary)]","cursor-grab active:cursor-grabbing","hover:bg-[color-mix(in_srgb,var(--color-ds-background-surface)_85%,black_15%)]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-ds-border-default)]",m?"opacity-60":"opacity-100","transition-colors"].join(" "),children:[s.jsx(rT,{className:"text-[var(--color-ds-text-primary)]"}),o?s.jsx(_i,{value:n,onChange:o,className:"max-w-[10rem]",inputClassName:"w-20 text-[11px]"}):s.jsx("span",{className:"truncate max-w-[10rem]",children:n})]})}function aT({tab:e,onChange:t,formId:r}){const{translations:n}=St(),{t:o}=Ct(),[l,i]=E.useState("");E.useEffect(()=>{const d=e.label,m=d&&(d.startsWith("forms.")||d.startsWith("ds."));if(n&&m){const f=n.getTranslation(d);i(f!==d?f:d)}else i(ct(o,d))},[e.label,n,o]);const c=async()=>{const d=e.label||"";if(l===(n&&d.startsWith("forms.")?n.getTranslation(d):ct(o,d)))return;if(!n){t(l);return}if((d.startsWith("forms.")||d.startsWith("ds."))&&!d.startsWith("ds."))await n.updateTranslation(d,l);else{const h=`forms.${r||"defaultForm"}.tabs.${e.key}.label`;await n.updateTranslation(h,l),t(h)}},u=d=>{d.key==="Enter"&&d.currentTarget.blur()};return s.jsx("input",{type:"text",value:l,onChange:d=>i(d.target.value),onBlur:c,onKeyDown:u,className:"bg-transparent text-lg font-bold text-[var(--color-ds-text-primary)] placeholder-[var(--color-ds-text-tertiary)] outline-none border-b border-transparent focus:border-[var(--color-ds-border-accent)] transition-colors flex-1 w-auto min-w-[60px]",placeholder:"Pestaña sin título"})}const oT=E.memo(function({node:t,nodeIdx:r,draggedTabSection:n,confirmDelete:o}){var w;const{t:l}=Ct(),[i,c]=E.useState(!1),[u,d]=E.useState(((w=t.tabs[0])==null?void 0:w.key)??""),m=oe(j=>j.removeLayoutNode),f=oe(j=>j.renameTab),h=oe(j=>j.updateTab),p=oe(j=>j.addTabAfter),v=oe(j=>j.removeTab),b=oe(j=>j.addSectionToTab);oe(j=>j.renameTabSection);const g=oe(j=>{var k,y;return((k=j.schema)==null?void 0:k.formId)||((y=j.schema)==null?void 0:y.id)}),x=t.tabs.map(j=>{const k=j.icon?yn(j.icon.name,j.icon.style):null;return{label:ct(l,j.label),value:j.key,disabled:!1,icon:k?s.jsx(k,{className:"w-4 h-4"}):null}});return E.useEffect(()=>{u===""&&t.tabs.length>0&&d(t.tabs[0].key)},[t.tabs,u]),s.jsx("div",{className:"space-y-2",children:s.jsxs("div",{className:"rounded-lg border border-[var(--color-ds-border-default-50)] overflow-hidden",children:[s.jsx("div",{className:"bg-[var(--color-ds-background-surface)] border-b border-[var(--color-ds-border-default-50)]",children:s.jsxs("div",{className:"flex items-center gap-2 min-h-9 py-1 pr-2",children:[s.jsx(cu,{expanded:!i,onClick:()=>c(!i),labelExpanded:"Colapsar pestañas",labelCollapsed:"Expandir pestañas"}),s.jsx("span",{className:"text-[11px] leading-none uppercase tracking-wide text-[var(--color-ds-text-secondary)]",children:"Pestañas"}),s.jsx("div",{className:"ml-auto",children:s.jsx(fe,{size:"xs",variant:"danger",onClick:()=>o("Eliminar bloque de pestañas","¿Estás seguro de que quieres eliminar este bloque de pestañas? Se perderá todo su contenido.",()=>m(r)),title:"Eliminar bloque",shape:"circle",icon:nt})})]})}),!i&&s.jsxs("div",{className:"bg-[var(--color-ds-background)]",children:[s.jsx("div",{className:"px-3 py-2 border-b border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface-soft)]",children:s.jsxs("span",{className:"text-[10px] uppercase tracking-wider font-medium text-[var(--color-ds-text-tertiary)] flex items-center gap-2",children:["Reordenar pestañas ",s.jsx("span",{className:"text-[var(--color-ds-text-tertiary)]/50 text-[9px] font-normal normal-case",children:"(Arrastrar para ordenar)"})]})}),s.jsx("div",{className:"custom-scroll scrollbar-hidden overflow-x-auto overflow-y-hidden bg-[var(--color-ds-background-surface-soft)]/30 border-b border-[var(--color-ds-border-default-50)]",children:s.jsxs("div",{className:"px-2 py-2 inline-flex items-center gap-1 whitespace-nowrap min-h-[2rem]",role:"list","aria-label":"Reordenar pestañas",children:[s.jsx($0,{nodeIdx:r,insertAt:0}),t.tabs.map((j,k)=>s.jsxs(E.Fragment,{children:[s.jsx(nT,{nodeIdx:r,index:k,tabKey:j.key,label:j.label,onRename:y=>f==null?void 0:f(j.key,y)}),s.jsx($0,{nodeIdx:r,insertAt:k+1})]},`tabchip-${r}-${j.key}`))]})}),s.jsx("div",{children:s.jsx(fr,{options:x,value:u,onChange:j=>d(j),children:t.tabs.reduce((j,k)=>(j[k.key]=s.jsxs("div",{className:"space-y-3",children:[u===k.key&&s.jsxs("div",{className:"flex flex-wrap items-center justify-between px-3 pt-3 pb-1 mb-1 gap-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-[150px]",children:[s.jsx("div",{className:"flex-shrink-0",children:s.jsx(Fr,{value:k.icon,onChange:y=>h==null?void 0:h(k.key,{icon:y})})}),s.jsx(aT,{tab:k,onChange:y=>h==null?void 0:h(k.key,{label:y}),formId:g})]}),s.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0 ml-auto",children:[s.jsxs("button",{onClick:()=>h==null?void 0:h(k.key,{disabled:!k.disabled}),className:`
292
+ `)}`,"error");return}n(c),p("Configuración de shortcuts guardada","success")},x=()=>{if(window.confirm("¿Restaurar shortcuts a valores por defecto?")){const C=$_();u(C),p("Shortcuts restaurados a valores por defecto","info")}},w=C=>{u(N=>({...N,[C]:{...N[C],enabled:!N[C].enabled}}))},j=C=>{m(C),h(!0)},k=C=>{if(!f||!d||(C.preventDefault(),C.stopPropagation(),["Control","Shift","Alt","Meta"].includes(C.key)))return;const N={...c[d],key:C.key,ctrl:C.ctrlKey||C.metaKey,shift:C.shiftKey,alt:C.altKey};u(M=>({...M,[d]:N})),h(!1),m(null)};if(E.useEffect(()=>{u(r)},[r]),E.useEffect(()=>{if(f)return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[f,d,c]),E.useEffect(()=>{e||(h(!1),m(null),u(r),i("general"))},[e,r]),!e)return null;const y=[{id:"general",label:o("ds.editor.settings.general","General"),icon:Rn},{id:"appearance",label:o("ds.editor.settings.appearance","Apariencia"),icon:yd},{id:"shortcuts",label:o("ds.editor.settings.shortcuts","Atajos"),icon:cn}];return s.jsxs(Et,{isOpen:e,onClose:t,title:o("ds.editor.settings.title","Configuración del Editor"),maxWidth:"max-w-4xl",children:[s.jsxs("div",{className:"flex h-[60vh] gap-6",children:[s.jsx("div",{className:"w-48 flex-shrink-0 flex flex-col gap-1 border-r border-[var(--color-ds-border-default-50)] pr-4",children:y.map(C=>s.jsxs("button",{onClick:()=>i(C.id),className:he("flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg transition-colors text-left",l===C.id?"bg-[var(--color-ds-button-primary-bg)] text-[var(--color-ds-button-primary-text)]":"text-[var(--color-ds-text-secondary)] hover:bg-[var(--color-ds-background-neutral-hover)] hover:text-[var(--color-ds-text-primary)]"),children:[s.jsx(C.icon,{className:"w-4 h-4"}),C.label]},C.id))}),s.jsxs("div",{className:"flex-1 overflow-y-auto pr-2",children:[l==="general"&&s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("h4",{className:"text-sm font-semibold text-[var(--color-ds-text-primary)] border-b border-[var(--color-ds-border-default-50)] pb-2",children:"Comportamiento"}),s.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)]",children:[s.jsx(rt,{checked:v.confirmDelete,onChange:C=>b({confirmDelete:C}),size:"md",disableErrorPlaceholder:!0}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-[var(--color-ds-text-primary)]",children:"Confirmar eliminación"}),s.jsx("div",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Solicitar confirmación antes de eliminar campos o secciones."})]})]}),s.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)]",children:[s.jsx(rt,{checked:v.showGrid,onChange:C=>b({showGrid:C}),size:"md",disableErrorPlaceholder:!0}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-[var(--color-ds-text-primary)]",children:"Mostrar rejilla de diseño"}),s.jsx("div",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Visualizar guías de columnas y filas en el editor."})]})]})]})}),l==="appearance"&&s.jsx("div",{className:"space-y-6",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("h4",{className:"text-sm font-semibold text-[var(--color-ds-text-primary)] border-b border-[var(--color-ds-border-default-50)] pb-2",children:"Tema del Editor"}),s.jsxs("div",{className:"p-4 rounded-lg border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)] flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-[var(--color-ds-text-primary)] mb-1",children:"Preferencia de color"}),s.jsx("div",{className:"text-xs text-[var(--color-ds-text-secondary)]",children:"Elige entre modo claro, oscuro o sincronizar con el sistema."})]}),s.jsx(xa,{value:v.theme,onChange:C=>b({theme:C}),size:"lg",variant:"rounded",items:[{id:"light",label:"Claro",icon:Gl},{id:"system",label:"Sistema",icon:Tl},{id:"dark",label:"Oscuro",icon:zl}]})]})]})}),l==="shortcuts"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex justify-between items-center mb-2",children:[s.jsx("div",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:"Personaliza los atajos de teclado para mejorar tu productividad."}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(fe,{variant:"ghost",size:"xs",onClick:x,children:"Restaurar"}),s.jsx(fe,{variant:"primary",size:"xs",onClick:g,children:"Guardar Atajos"})]})]}),s.jsx("div",{className:"space-y-2",children:Object.entries(c).map(([C,N])=>s.jsxs("div",{className:he("flex items-center justify-between p-3 rounded-xl transition-colors border","border-[var(--color-ds-border-muted)] hover:border-[var(--color-ds-border-default)]","bg-[var(--color-ds-background-surface)] hover:bg-[var(--color-ds-background-surface-hover)]"),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[s.jsx(rt,{checked:N.enabled,onChange:()=>w(C),size:"sm",disableErrorPlaceholder:!0}),s.jsx("div",{className:"cursor-pointer",onClick:()=>w(C),children:s.jsx("div",{className:he("font-medium text-sm",!N.enabled&&"opacity-50 line-through"),children:N.description})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:he("px-2 py-1 rounded border font-mono text-[10px] min-w-[60px] text-center",f&&d===C?"bg-blue-100 text-blue-700 border-blue-300 animate-pulse":"bg-[var(--color-ds-background-page)] border-[var(--color-ds-border-muted)]",!N.enabled&&"opacity-40"),children:f&&d===C?"...":qn(N)}),s.jsx(fe,{size:"xs",variant:"ghost",onClick:M=>{M.stopPropagation(),j(C)},disabled:!N.enabled||f,children:s.jsx(Bo,{className:"w-3 h-3"})})]})]},C))})]})]})]}),s.jsx("div",{className:"flex justify-end pt-4 border-t border-[var(--color-ds-border-default)] mt-2",children:s.jsx(fe,{variant:"outline",onClick:t,children:"Cerrar"})})]})},B_=T_;function qs(e,t){const r=new Blob([t],{type:"text/plain;charset=utf-8"}),n=URL.createObjectURL(r),o=document.createElement("a");o.href=n,o.download=e,o.click(),URL.revokeObjectURL(n)}const Gs=e=>e.toLowerCase().endsWith(".json")?e:`${e}.json`,M0=(e,t)=>`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`,A0=()=>s.jsx("div",{className:"w-px h-6 bg-[var(--color-ds-border-default-50)] mx-2"});function Z_(){var L;const{t:e,i18n:t}=Ct(),r=oe(S=>S.schema),n=oe(S=>S.undo),o=oe(S=>S.redo),l=oe(S=>S.setSchema),i=oe(S=>S.resetHistory),c=oe(S=>S.past.length),u=oe(S=>S.future.length),d=oe(S=>S.selection),m=oe(S=>S.removeField),f=oe(S=>S.duplicateField),h=oe(S=>S.editorSettings),p=oe(S=>S.showRelations??!1),v=oe(S=>S.toggleRelations),b=oe(S=>S.setShowRelations),g=oe(S=>S.mode),x=oe(S=>S.setMode),[w,j]=E.useState(!1),[k,y]=E.useState(!1),[C,N]=E.useState(!1),[M,$]=E.useState(!1),[T,V]=E.useState(!1),I=()=>{typeof v=="function"?v():typeof b=="function"&&b(!p)},z=E.useRef(null),O=E.useRef(null),{show:P}=qr(),{fs:Q,baseDir:te,translations:ne,services:ae,setServices:W}=St(),A=((L=r.title)==null?void 0:L.toString().trim().replace(/\s+/g,"-").toLowerCase())||"form-schema",F=()=>{qs(`${A}.json`,JSON.stringify(r,null,2)),P("Esquema exportado como JSON.","success")},Y=()=>{try{const S=Ii(r,"validationSchema");qs(`${A}.validation.ts`,S),P("Yup exportado como TypeScript.","success")}catch(S){console.error(S),P("No se pudo generar el Yup.","error")}},U=()=>{try{const S=Fi(r,ne,t),D=`${A}.translations.json`;qs(D,JSON.stringify(S,null,2)),P("Traducciones exportadas como JSON.","success")}catch(S){console.error(S),P("No se pudo generar el JSON de traducciones.","error")}},ee=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(r,null,2)),P("JSON copiado al portapapeles.","success")}catch{P("No se pudo copiar al portapapeles.","error")}},le=()=>{var S;return(S=z.current)==null?void 0:S.click()},ue=()=>{var S;return(S=O.current)==null?void 0:S.click()},ge=S=>{var B;const D=(B=S.target.files)==null?void 0:B[0];if(!D)return;if(!window.confirm("Vas a reemplazar el esquema actual. ¿Continuar?")){S.currentTarget.value="";return}const Z=new FileReader;Z.onload=()=>{try{const q=JSON.parse(String(Z.result));if(!Array.isArray(q.layout)||!Array.isArray(q.fields)){P("JSON inválido: faltan layout/fields.","error");return}l(q),i(),P("Esquema importado correctamente.","success")}catch{P("No se pudo parsear el JSON.","error")}},Z.readAsText(D),S.currentTarget.value=""},ce=async S=>{var B;const D=S.target,_=(B=D.files)==null?void 0:B[0];if(!_)return;if(!window.confirm("Al importar un proyecto ZIP se reemplazará el esquema actual, los servicios y las traducciones. ¿Continuar?")){D.value="";return}try{await S_({file:_,setSchema:q=>{l(q),i()},setServices:W,translationAdapter:ne}),P("Proyecto importado correctamente.","success")}catch(q){console.error(q),P(q.message||"Error al importar ZIP","error")}D.value=""},se=()=>{window.confirm("Crear un esquema nuevo vacío (perderás cambios no guardados). ¿Continuar?")&&(l(D=>{D.layout=[{type:"rows",sections:[{sectionTitle:"Sección 1",defaultOpen:!0,rows:[{title:"",columns:[{width:"w-full",fields:[]}]}]}]}],D.fields=[],D.successMessage="Guardado",D.errorMessage="Error",D.onSubmit=async()=>{}}),i(),P("Esquema nuevo creado.","info"))},we=async()=>{try{const S=M0(te,Gs(`${A}.json`));await Q.write(S,JSON.stringify(r,null,2)),P(`Guardado rápido en ${S}`,"success")}catch(S){console.error(S),P("Guardado rápido fallido.","error")}},de=async()=>{try{const S=Gs(`${A}.json`),D=window.prompt("Guardar como (archivo en baseDir):",S);if(!D)return;const _=M0(te,Gs(D));await Q.write(_,JSON.stringify(r,null,2)),P(`Guardado en ${_}`,"success")}catch(S){console.error(S),P("No se pudo guardar el archivo.","error")}},{config:me,updateConfig:R}=__({undo:()=>{c>0&&n()},redo:()=>{u>0&&o()},save:()=>{we()},saveAs:()=>{de()},toggleRelations:()=>{I()},togglePreview:()=>{x(g==="design"?"preview":g==="preview"?"code":"design")},deleteField:()=>{d.kind==="field"&&(!h.confirmDelete||window.confirm(`¿Eliminar el campo "${d.name}"?`))&&(m(d.name),P("Campo eliminado","success"))},duplicateField:()=>{d.kind==="field"&&(f(d.name),P("Campo duplicado","success"))},copy:()=>{ee()},newSchema:()=>{se()},importSchema:()=>{le()},exportSchema:()=>{F()}}),J=[{label:"Nuevo esquema",icon:pd,onSelect:se},{label:"Importar JSON...",icon:vd,onSelect:le},{label:"Importar Proyecto (ZIP)...",icon:U0,onSelect:ue},{label:"Generar desde DTO...",icon:cn,onSelect:()=>y(!0)},{label:"Gestionar Servicios...",icon:cn,onSelect:()=>N(!0)},{label:"Guardar",icon:Xs,onSelect:we},{label:"Guardar como...",icon:Xs,onSelect:de}],H=[{label:"Exportar JSON",icon:Cn,onSelect:F},{label:"Exportar Yup (.ts)",icon:Xt,onSelect:Y},{label:"Exportar Traducciones",icon:To,onSelect:U},{label:"Copiar JSON",icon:Fl,onSelect:ee},{label:"Exportar Proyecto (ZIP)",icon:el,onSelect:()=>{const S=(ae==null?void 0:ae.registry)||{};console.log("Services Registry for Export:",S),O_({schema:r,translationsAdapter:ne,i18n:t,servicesRegistry:S,baseName:A}),P("Proyecto exportado correctamente","success")}}];return s.jsxs("div",{className:"pb-1 bg-[var(--color-ds-background-page)]",children:[s.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-sm px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(It,{icon:ed,size:"sm",onClick:n,disabled:c===0,ariaLabel:`Deshacer (${qn(me.undo)})`,title:`Deshacer (${qn(me.undo)})`}),s.jsx(It,{icon:td,size:"sm",onClick:o,disabled:u===0,ariaLabel:`Rehacer (${qn(me.redo)})`,title:`Rehacer (${qn(me.redo)})`}),s.jsx(A0,{}),s.jsx(b_,{}),s.jsx(A0,{}),s.jsx(sa,{trigger:s.jsxs("span",{className:"flex items-center gap-1 px-2 py-1.5 text-sm font-medium text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-background-neutral-hover)] rounded-md transition-colors",children:["Archivo",s.jsx(Ut,{className:"w-3 h-3 opacity-50"})]}),items:J}),s.jsx(sa,{trigger:s.jsxs("span",{className:"flex items-center gap-1 px-2 py-1.5 text-sm font-medium text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-background-neutral-hover)] rounded-md transition-colors",children:[e("ds.editor.toolbar.export"),s.jsx(Ut,{className:"w-3 h-3 opacity-50"})]}),items:H}),s.jsx(fe,{variant:"subtle",size:"sm",onClick:()=>N(!0),icon:el,ariaLabel:"Importar/Gestionar Servicios OpenAPI",className:"ml-1 text-[var(--color-ds-primary-700)] bg-[var(--color-ds-primary-50)] hover:bg-[var(--color-ds-primary-100)] ring-[var(--color-ds-primary-200)]",children:"Servicios"}),s.jsx(fe,{variant:"subtle",size:"sm",onClick:()=>$(!0),icon:_o,ariaLabel:"Configurar carga inicial de datos",className:"ml-1 text-[var(--color-ds-primary-700)] bg-[var(--color-ds-primary-50)] hover:bg-[var(--color-ds-primary-100)] ring-[var(--color-ds-primary-200)]",children:"Pre-carga"}),s.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>V(!0),icon:cn,ariaLabel:"Ver variables de sistema",title:"Variables de sistema",className:"ml-1 text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)]"}),s.jsx("input",{ref:z,type:"file",accept:"application/json",className:"hidden",onChange:ge,"aria-label":e("ds.editor.toolbar.import")}),s.jsx("input",{ref:O,type:"file",accept:".zip,application/zip,application/x-zip-compressed",className:"hidden",onChange:ce,"aria-label":"Importar Proyecto ZIP"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(It,{icon:p?Vl:Vr,size:"sm",onClick:I,ariaLabel:e(p?"ds.editor.toolbar.hideRelations":"ds.editor.toolbar.showRelations"),title:e(p?"ds.editor.toolbar.hideRelations":"ds.editor.toolbar.showRelations"),className:"text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)]"}),s.jsx(It,{icon:Rn,size:"sm",onClick:()=>j(!0),ariaLabel:e("ds.editor.toolbar.shortcuts"),title:e("ds.editor.toolbar.shortcuts")}),s.jsx("div",{className:"w-px h-6 bg-[var(--color-ds-border-default-50)] mx-1"}),s.jsx(xa,{value:g,onChange:S=>x(S),size:"sm",variant:"square",items:[{id:"design",label:e("ds.editor.modes.design"),icon:gn},{id:"preview",label:e("ds.editor.modes.preview"),icon:Vr},{id:"code",label:e("ds.editor.modes.code"),icon:Xt}]})]})]}),s.jsx(B_,{isOpen:w,onClose:()=>j(!1),config:me,onSaveShortcuts:R}),s.jsx(YF,{open:k,onClose:()=>y(!1)}),s.jsx(u_,{isOpen:C,onClose:()=>N(!1)}),M&&s.jsx(f_,{isOpen:!0,onClose:()=>$(!1)}),s.jsx(v_,{isOpen:T,onClose:()=>V(!1)})]})}const Wa="application/x-ds-field-template",O0="application/x-ds-layout-kind";function Ks(e){return e.layout.find(t=>(t==null?void 0:t.type)==="rows")}function V_({className:e,children:t}){var w;const r=oe(j=>j.schema),n=oe(j=>j.addFieldAndPlace),o=oe(j=>j.addRowsBlockAt),l=oe(j=>j.addSection),i=oe(j=>j.addRowToSection),c=oe(j=>j.setRowColumns),u=oe(j=>j.moveField),[d,m]=E.useState(!1),f=E.useMemo(()=>{var y;const j=Ks(r);if(!j)return[];const k=[];return(y=j.sections)==null||y.forEach((C,N)=>{var M;(M=C.rows)==null||M.forEach(($,T)=>{($.columns??[]).forEach((V,I)=>{var P;const z=((P=V.fields)==null?void 0:P.length)??0,O=Math.max(1,z+1);for(let Q=0;Q<O;Q++)k.push({kind:"field-slot",sectionIdx:N,rowIdx:T,colIdx:I,insertIdx:Q,key:`s${N}-r${T}-c${I}-i${Q}`})})})}),k},[r]),h=E.useCallback(()=>{var C,N;const j=r.layout.findIndex(M=>(M==null?void 0:M.type)==="rows"),k=r.layout[j];return k?(C=k.sections)!=null&&C.length?(N=k.sections[0].rows)!=null&&N.length?((k.sections[0].rows[0].columns??[]).length||c==null||c(j,0,0,1),{s:0,r:0,c:0}):(i==null||i(j,0),{s:0,r:0,c:0}):(l==null||l("Sección 1"),{s:0,r:0,c:0}):(o==null||o(r.layout.length??0,"Sección 1"),{s:0,r:0,c:0})},[r,o,l,i,c]),p=E.useCallback(j=>{var y;const k=((y=j.dataTransfer)==null?void 0:y.types)||[];(k.includes(Wa)||k.includes(O0))&&(j.preventDefault(),j.dataTransfer.dropEffect="copy",m(k.includes(Wa)?"field":"layout"))},[]),v=E.useCallback(()=>m(!1),[]),b=E.useCallback(j=>{var N;const k=j.dataTransfer.getData(O0);if(!k)return!1;const{kind:y}=JSON.parse(k),C=((N=r==null?void 0:r.layout)==null?void 0:N.length)??0;return y==="section-layout"&&(o==null||o(C,"Nueva sección")),!0},[(w=r==null?void 0:r.layout)==null?void 0:w.length,o]),g=E.useCallback((j,k)=>{const y=k.dataTransfer.getData(Wa);if(!y)return!1;const{fieldTemplate:C}=JSON.parse(y);return n(C,j.sectionIdx,j.rowIdx,j.colIdx),queueMicrotask(()=>{var V;const N=oe.getState().schema,T=(((V=Ks(N).sections[j.sectionIdx].rows[j.rowIdx].columns[j.colIdx].fields)==null?void 0:V.length)??1)-1;j.insertIdx>=0&&j.insertIdx<T&&u({s:j.sectionIdx,r:j.rowIdx,c:j.colIdx,idx:T},{s:j.sectionIdx,r:j.rowIdx,c:j.colIdx,idx:j.insertIdx})}),!0},[n,u]),x=E.useCallback(j=>{if(j.preventDefault(),j.stopPropagation(),b(j)){m(!1);return}const k=j.dataTransfer.getData(Wa);if(k){const{fieldTemplate:y}=JSON.parse(k),C=h();n(y,C.s,C.r,C.c)}m(!1)},[b,h,n]);return s.jsxs("div",{className:["relative",e].filter(Boolean).join(" "),onDragOver:p,onDragLeave:v,onDrop:x,children:[t,d&&s.jsxs("div",{className:"absolute inset-0 z-40",children:[s.jsx("div",{className:"absolute inset-0 bg-black/5 pointer-events-none"}),s.jsx("div",{className:"absolute inset-0 px-4 py-4 overflow-auto space-y-4",children:(()=>{var y;const j=Ks(r);if(!j||!((y=j.sections)!=null&&y.length)){const C=h(),N={kind:"field-slot",sectionIdx:C.s,rowIdx:C.r,colIdx:C.c,insertIdx:0,key:"init"};return s.jsx("div",{className:"min-h-[220px] border-2 border-dashed rounded-2xl bg-white/70 flex items-center justify-center text-ds-sm",onDragOver:M=>M.preventDefault(),onDrop:M=>{M.preventDefault(),M.stopPropagation(),g(N,M),m(!1)},children:"Suelta aquí para empezar"})}const k=[];return j.sections.forEach((C,N)=>{var M;(M=C.rows)==null||M.forEach(($,T)=>{const V=[];($.columns??[]).forEach((I,z)=>{const O=f.filter(P=>P.sectionIdx===N&&P.rowIdx===T&&P.colIdx===z);V.push(O)}),k.push({key:`s${N}-r${T}`,cols:V})})}),k.map(C=>s.jsx("div",{className:"grid gap-3 pointer-events-none",style:{gridTemplateColumns:`repeat(${C.cols.length||1}, minmax(0,1fr))`},children:C.cols.map((N,M)=>{const $=N.length===1;return s.jsx("div",{className:"pointer-events-auto",children:s.jsx("div",{className:["rounded-xl border-2 border-dashed bg-white/60",$?"min-h-[160px]":"py-2"].join(" "),children:s.jsx("div",{className:"flex flex-col gap-2",children:N.map(T=>s.jsx("div",{className:"h-7 rounded-md border border-transparent hover:border-[var(--color-ds-border-default)] hover:bg-white/80 flex items-center justify-center text-ds-sm text-[var(--color-ds-text-secondary)]",onDragOver:V=>V.preventDefault(),onDrop:V=>{V.preventDefault(),V.stopPropagation(),g(T,V),m(!1)},title:`Insertar en Col ${T.colIdx+1}, posición ${T.insertIdx+1}`,children:$?"Soltar aquí":T.insertIdx===N.length-1?"Añadir al final":"Insertar aquí"},T.key))})})},`${C.key}-c${M}`)})},C.key))})()})]})]})}function D_({nodeIdx:e,insertAt:t}){const r={scope:"rows-section",nodeIdx:e,insertAt:t},{setNodeRef:n,isOver:o}=tr({id:`rows-section:drop:${e}:${t}`,data:r});return s.jsx("div",{ref:n,className:["h-2 my-1 w-full rounded-sm transition relative mx-1 px-1",o?"bg-[var(--color-ds-border-default)]/30 ring-1 ring-[var(--color-ds-border-default)]":"bg-transparent"].join(" "),"aria-label":`Insertar sección en posición ${t+1}`})}function P_({nodeIdx:e,sIdx:t}){const r=`rows-section:drag:${e}:${t}`,n={kind:"rows-section",nodeIdx:e,sIdx:t},{attributes:o,listeners:l,setNodeRef:i,isDragging:c}=Gr({id:r,data:n});return s.jsx("div",{ref:i,...o,...l,role:"button",title:"Arrastrar sección","aria-grabbed":c,className:"shrink-0 w-6 h-6 grid place-items-center cursor-grab active:cursor-grabbing rounded text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-background-muted)]",children:"⇅"})}function L0(e){const r={...e.scope==="rows-column"?{scope:"rows-column",s:e.s,r:e.r,c:e.c,rowsNodeIdx:e.rowsNodeIdx}:{scope:"tabs-column",tabKey:e.tabKey,s:e.s,r:e.r,c:e.c},insertAt:Number.MAX_SAFE_INTEGER},{setNodeRef:n,isOver:o}=tr({id:JSON.stringify(r),data:r});return s.jsx("div",{ref:n,className:o?"ring-5 ring-[var(--color-ds-border-default)] rounded-md":"","aria-dropeffect":o?"copy":void 0,"data-drop-scope":e.scope,children:e.children})}function z_(e,t=44){if(!e)return t;const r=e.previousElementSibling,n=e.nextElementSibling,o=c=>{var u;return((u=c==null?void 0:c.querySelector)==null?void 0:u.call(c,"[data-sortable-item]"))||c},l=o(r)??o(n)??null,i=(l==null?void 0:l.getBoundingClientRect().height)??0;return Math.max(32,Math.min(96,Math.round(i||t)))}function H_(e){var f,h,p,v,b,g,x,w;if(!e)return null;const t=e.kind??e.scope??e.type,r=e.s??((f=e.path)==null?void 0:f.s),n=e.r??((h=e.path)==null?void 0:h.r),o=e.c??((p=e.path)==null?void 0:p.c),l=e.idx??((v=e.path)==null?void 0:v.idx),i=e.index,c=e.rowsNodeIdx??e.nodeIdx??((b=e.path)==null?void 0:b.rowsNodeIdx),u=e.tabKey??((g=e.path)==null?void 0:g.tabKey),d=e.groupName??((x=e.path)==null?void 0:x.groupName),m=e.arrayName??((w=e.path)==null?void 0:w.arrayName);return{kind:t,s:r,r:n,c:o,idx:l,index:i,rowsNodeIdx:c,tabKey:u,groupName:d,arrayName:m}}function W_(e,t){if(!t)return!1;const r=n=>typeof n=="number"&&(e.insertAt===n||e.insertAt===n+1);if(e.scope==="rows-column"){if((t.kind==="field-in-rows"||t.kind==="rows-column")&&t.rowsNodeIdx===e.rowsNodeIdx&&t.s===e.s&&t.r===e.r&&t.c===e.c&&r(t.idx))return!0}else if(e.scope==="tabs-column"){if((t.kind==="field-in-tabs"||t.kind==="tabs-column")&&t.tabKey===e.tabKey&&t.s===e.s&&t.r===e.r&&t.c===e.c&&r(t.idx))return!0}else if(e.scope==="input-group"){if((t.kind==="field-in-inputgroup"||t.kind==="input-group")&&t.groupName===e.groupName&&r(t.idx))return!0}else if(e.scope==="array-items"&&(t.kind==="field-in-array"||t.kind==="array-items")&&t.arrayName===e.arrayName&&r(t.index))return!0;return!1}function Yt(e){let t;e.scope==="rows-column"?t={scope:"rows-column",rowsNodeIdx:e.rowsNodeIdx,s:e.s,r:e.r,c:e.c,insertAt:e.insertAt}:e.scope==="tabs-column"?t={scope:"tabs-column",tabKey:e.tabKey,s:e.s,r:e.r,c:e.c,insertAt:e.insertAt}:e.scope==="input-group"?t={scope:"input-group",groupName:e.groupName,insertAt:e.insertAt}:t={scope:"array-items",arrayName:e.arrayName,insertAt:e.insertAt};const r=E.useRef(null),{setNodeRef:n,isOver:o}=tr({id:JSON.stringify(t),data:t}),[l,i]=E.useState(44),c=e.scope==="input-group"?6:8,[u,d]=E.useState(null);Ea({onDragStart:b=>{var g,x;return d(((x=(g=b.active)==null?void 0:g.data)==null?void 0:x.current)??null)},onDragCancel:()=>d(null),onDragEnd:()=>d(null)});const m=W_(e,H_(u)),f=!!e.suppressAll||m;if(E.useEffect(()=>{if(!o||f)return;const b=z_(r.current,e.scope==="input-group"?36:44);i(b)},[o,e.scope,f]),f)return s.jsx("div",{ref:b=>{r.current=b,n(b)},style:{position:"absolute",inset:0,pointerEvents:"none"},role:"button","aria-dropeffect":o?"copy":void 0,"aria-label":`Soltar aquí (posición ${e.insertAt+1})`,"data-drop-scope":e.scope,"data-insert-at":e.insertAt});const h=e.insertAt===0,p={height:o?l:0,margin:o?`${c}px 0`:"0px",transition:"height 120ms ease, margin 120ms ease, opacity 80ms ease",opacity:o?1:0},v=e.scope==="input-group"?"w-full inline-flex":"w-full block";return s.jsx("div",{ref:b=>{r.current=b,n(b)},role:"button","aria-dropeffect":o?"copy":void 0,"aria-label":`Soltar aquí (posición ${e.insertAt+1})`,"data-drop-scope":e.scope,"data-insert-at":e.insertAt,className:v,style:p,children:o&&s.jsx("div",{"aria-hidden":!0,className:["w-full","rounded-md","border","border-dashed","border-[var(--color-ds-border-default-50)]",e.scope==="input-group"?"bg-[var(--color-ds-background-surface)]/70":"bg-[var(--color-ds-background)]/60","relative"].join(" "),style:{height:l,boxShadow:"inset 0 0 0 1px color-mix(in srgb, var(--color-ds-border-default-50) 30%, transparent)"},children:!e.suppressHint&&s.jsxs("div",{className:"absolute -top-2 left-3 px-1.5 py-0.5 rounded text-[11px] leading-none",style:{background:"var(--color-ds-background-elevated)",color:"var(--color-ds-text-secondary)",border:"1px solid var(--color-ds-border-default-50)"},children:["Soltar aquí",""]})})})}function xr(e){const t=e.kind==="field-in-tabs"?`${e.kind}:${e.tabKey}:${e.name}:${e.path.s}-${e.path.r}-${e.path.c}-${e.path.idx}`:e.kind==="field-in-rows"?`${e.kind}:${e.rowsNodeIdx}:${e.name}:${e.path.s}-${e.path.r}-${e.path.c}-${e.path.idx}`:e.kind==="field-in-inputgroup"?`${e.kind}:${e.groupName}:${e.name}:${e.path.idx}`:`${e.kind}:${e.arrayName}:${e.name}:${e.index}`,r=e.kind==="field-in-rows"?{kind:e.kind,name:e.name,path:e.path,rowsNodeIdx:e.rowsNodeIdx}:e.kind==="field-in-tabs"?{kind:e.kind,name:e.name,path:e.path,tabKey:e.tabKey}:e.kind==="field-in-inputgroup"?{kind:e.kind,name:e.name,path:e.path,groupName:e.groupName}:{kind:e.kind,name:e.name,arrayName:e.arrayName,index:e.index},{attributes:n,listeners:o,setNodeRef:l,isDragging:i}=Gr({id:t,data:r}),c=e.disableSelect?s.jsxs("span",{className:"text-[var(--color-ds-text-primary)] text-ds-sm text-left truncate inline-flex items-center gap-1",children:[e.icon?s.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-[var(--color-ds-text-secondary)]",children:e.icon}):null,s.jsx("span",{className:"truncate",children:e.name})]}):s.jsxs("button",{type:"button",className:"text-[var(--color-ds-text-primary)] text-ds-sm hover:underline text-left truncate inline-flex items-center gap-1",onClick:u=>{u.stopPropagation(),e.onSelect()},children:[e.icon?s.jsx("span",{"aria-hidden":!0,className:"shrink-0 text-[var(--color-ds-text-secondary)]",children:e.icon}):null,s.jsx("span",{className:"truncate",children:e.name})]});return s.jsxs("div",{ref:l,className:["text-[var(--color-ds-text-primary)] group flex items-center justify-between rounded-md py-1 w-full","overflow-visible",i?"opacity-50":"opacity-100"].join(" "),"data-field-name":e.name,children:[c,s.jsx("div",{...o,...n,role:"button","aria-grabbed":i,"aria-label":`Arrastrar campo ${e.name}`,className:["text-[var(--color-ds-text-primary)] text-[11px] select-none cursor-grab active:cursor-grabbing","px-1 py-0.5 rounded-sm","hover:bg-[var(--color-ds-background-muted)]","focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"].join(" "),title:"Arrastra para reordenar",children:"⇅"})]})}function iu(e){return oe(E.useCallback(t=>{if(e)return t.schema.fields.find(r=>r.name===e)},[e]))}const U_=E.memo(({fieldOrName:e,groupName:t,index:r,onRemove:n,setSelection:o,confirmDelete:l})=>{const i=typeof e=="string"?e:e.name,u=iu(i)||(typeof e=="object"?e:void 0),d=u==null?void 0:u.name,m=(u==null?void 0:u.type)??"text";let f;u&&("label"in u?f=u.label:"groupLabel"in u&&(f=u.groupLabel));const h=dr(m),p=Dt(m);return s.jsxs("div",{className:"flex items-center justify-between w-full gap-2 rounded-md border bg-[var(--color-ds-background-page)] px-2 py-1",style:{borderColor:"var(--color-ds-border-default-50)",borderLeft:`4px solid ${h}`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, ${h} 18%, transparent)`},children:[d?s.jsx(xr,{kind:"field-in-inputgroup",groupName:t,name:d,path:{idx:r},onSelect:()=>o({kind:"field",name:d}),icon:p}):s.jsx("div",{className:"text-ds-sm opacity-80",children:f??"(inline sin nombre)"}),d?s.jsx(fe,{size:"xs",variant:"danger",onClick:()=>l("Eliminar campo","¿Estás seguro de que quieres eliminar este campo del grupo?",n),title:"Quitar del grupo",shape:"circle",icon:nt}):null]})}),q_=E.memo(function({field:t,index:r,nodeIdx:n,sIdx:o,rIdx:l,cIdx:i,parentType:c,tabKey:u,onDelete:d,confirmDelete:m}){const f=typeof t=="string"?t:t==null?void 0:t.name,p=iu(f)||(typeof t=="object"?t:void 0),v=oe(P=>P.setSelection),b=oe(P=>P.removeFieldFromInputGroup),g=oe(P=>P.removeFieldFromArray),x=(p==null?void 0:p.name)??f,w=(p==null?void 0:p.type)??"text",j=Dt(w),k=dr(w),y=()=>c==="rows"?s.jsx(xr,{kind:"field-in-rows",rowsNodeIdx:n,name:x,path:{s:o,r:l,c:i,idx:r},onSelect:()=>v({kind:"field",name:x}),icon:j}):s.jsx(xr,{kind:"field-in-tabs",tabKey:u,name:x,path:{s:o,r:l,c:i,idx:r},onSelect:()=>v({kind:"field",name:x}),icon:j}),C=(P,Q)=>c==="rows"?s.jsx(Yt,{scope:"rows-column",rowsNodeIdx:n,s:o,r:l,c:i,insertAt:P,suppressAll:Q}):s.jsx(Yt,{scope:"tabs-column",tabKey:u,s:o,r:l,c:i,insertAt:P,suppressAll:Q}),N=oe(P=>P.activeVariantId),M=oe(P=>P.schema.variants),$=E.useMemo(()=>M==null?void 0:M.find(P=>P.key===N),[M,N]),T=E.useMemo(()=>{var P;return(P=$==null?void 0:$.overrides)==null?void 0:P[x]},[$,x]),V=T==null?void 0:T.hidden,I=T==null?void 0:T.disabled,z=V?{opacity:.4,filter:"grayscale(100%)"}:{},O=()=>V||I?s.jsxs("div",{className:"flex gap-1 absolute top-0 right-8 -mt-2",children:[V&&s.jsx("span",{className:"bg-gray-500 text-white text-[9px] px-1 rounded shadow-sm",children:"Hidden"}),I&&s.jsx("span",{className:"bg-amber-500 text-white text-[9px] px-1 rounded shadow-sm",children:"Disabled"})]}):null;if(w==="inputGroup"){const P=p,Q=(P==null?void 0:P.type)==="inputGroup"&&Array.isArray(P==null?void 0:P.inputs)?P.inputs:[],te=(P==null?void 0:P.type)!=="inputGroup"&&Array.isArray(P==null?void 0:P.inputs)?P.inputs:[],ne=Q.length>0,ae=!ne&&te.length>0;return s.jsxs(E.Fragment,{children:[s.jsxs("div",{"data-field-name":x,className:"rounded-md border bg-[var(--color-ds-background-page)] relative",style:{borderColor:"var(--color-ds-border-default-50)",boxShadow:`inset 0 0 0 1px color-mix(in srgb, ${dr("inputGroup")} 18%, transparent)`,...z},children:[s.jsx(O,{}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 py-1 bg-[var(--color-ds-background-surface)] border-b border-[var(--color-ds-border-default-50)]",children:[c==="rows"?s.jsx(xr,{kind:"field-in-rows",rowsNodeIdx:n,name:x,path:{s:o,r:l,c:i,idx:r},onSelect:()=>v({kind:"field",name:x}),icon:Dt("inputGroup"),disableSelect:!0}):s.jsx(xr,{kind:"field-in-tabs",tabKey:u,name:x,path:{s:o,r:l,c:i,idx:r},onSelect:()=>v({kind:"field",name:x}),icon:Dt("inputGroup"),disableSelect:!0}),s.jsx(fe,{size:"xs",variant:"danger",onClick:d,title:"Quitar grupo del layout",shape:"circle",icon:nt})]}),s.jsx("div",{className:"p-2",children:s.jsxs("div",{className:"flex flex-row gap-2 flex-wrap relative",children:[s.jsx(Yt,{scope:"input-group",groupName:x,insertAt:0,suppressAll:!ne}),ne&&Q.map((W,A)=>{const F=typeof W=="string"?W:W.name??A;return s.jsxs(E.Fragment,{children:[s.jsx(U_,{fieldOrName:W,groupName:x,index:A,onRemove:()=>b(x,A),setSelection:v,confirmDelete:m}),s.jsx(Yt,{scope:"input-group",groupName:x,insertAt:A+1,suppressAll:!ne})]},`${x}-child-${F}`)}),!ne&&ae&&te.map((W,A)=>s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-dashed bg-[var(--color-ds-background-surface)] px-2 py-1 opacity-80",title:"Definido en FieldSchema.inputs (vista previa).",children:[s.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded-full border",children:(W==null?void 0:W.label)??(W==null?void 0:W.name)??"Input"}),s.jsx("span",{className:"text-[var(--color-ds-text-secondary)] text-ds-sm",children:"(solo vista)"})]},`${x}-ui-${(W==null?void 0:W.name)??A}`)),!ne&&!ae&&s.jsx("div",{className:"text-center text-[12px] text-[var(--color-ds-text-secondary)] border border-dashed border-[var(--color-ds-border-default-50)] rounded-md py-3 w-full",children:"Suelta inputs dentro del grupo"})]})})]}),C(r+1,!1)]})}if(w==="array"){const P=p,Q=Array.isArray(P==null?void 0:P.items)?P.items:[];return s.jsxs(E.Fragment,{children:[s.jsxs("div",{"data-field-name":x,className:"rounded-md border bg-[var(--color-ds-background-page)] relative",style:{borderColor:"var(--color-ds-border-default-50)",boxShadow:`inset 0 0 0 1px color-mix(in srgb, ${dr("array")} 18%, transparent)`,...z},children:[s.jsx(O,{}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-2 py-1 bg-[var(--color-ds-background-surface)] border-b border-[var(--color-ds-border-default-50)]",children:[c==="rows"?s.jsx(xr,{kind:"field-in-rows",rowsNodeIdx:n,name:x,path:{s:o,r:l,c:i,idx:r},onSelect:()=>v({kind:"field",name:x}),icon:Dt("array"),disableSelect:!0}):s.jsx(xr,{kind:"field-in-tabs",tabKey:u,name:x,path:{s:o,r:l,c:i,idx:r},onSelect:()=>v({kind:"field",name:x}),icon:Dt("array"),disableSelect:!0}),s.jsx(fe,{size:"xs",variant:"danger",onClick:d,title:"Quitar repeater",shape:"circle",icon:nt})]}),s.jsxs("div",{className:"p-3 bg-[var(--color-ds-background-subtle)] rounded-b-md",children:[s.jsx("div",{className:"text-[10px] uppercase font-bold tracking-wider text-[var(--color-ds-text-tertiary)] mb-2 pl-1 select-none",children:"Plantilla de Item"}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Yt,{scope:"array-items",arrayName:x,insertAt:0,suppressAll:Q.length===0}),Q.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 text-center text-[12px] text-[var(--color-ds-text-secondary)] border-2 border-dashed border-[var(--color-ds-border-default-50)] rounded-lg py-6 bg-[var(--color-ds-background-page)] transition-colors hover:border-[var(--color-ds-border-default)] hover:bg-[var(--color-ds-background-surface)]",children:[s.jsx("div",{className:"p-2 rounded-full bg-[var(--color-ds-background-subtle)]",children:s.jsx(er,{className:"w-5 h-5 opacity-50"})}),s.jsx("span",{className:"font-medium",children:"Arrastra campos aquí"}),s.jsx("span",{className:"text-[11px] opacity-70 max-w-[180px]",children:"Define qué campos tendrá cada elemento de la lista"})]}),Q.map((te,ne)=>{const ae=te.name,W=te.type,A=Dt(W),F=dr(W);return s.jsxs(E.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded border bg-[var(--color-ds-background-page)] px-2 py-1",style:{borderLeft:`3px solid ${F}`},children:[s.jsx(xr,{kind:"field-in-array",arrayName:x,name:ae,index:ne,path:{idx:ne},onSelect:()=>v({kind:"field",name:ae}),icon:A}),s.jsx(fe,{size:"xs",variant:"danger",onClick:()=>g(x,ne),title:"Eliminar campo del template",shape:"circle",icon:nt})]}),s.jsx(Yt,{scope:"array-items",arrayName:x,insertAt:ne+1,suppressAll:Q.length===0})]},`${x}-item-${ne}`)})]})]})]}),C(r+1,!1)]})}return s.jsxs(E.Fragment,{children:[s.jsxs("div",{"data-field-name":x,className:"flex items-center justify-between gap-2 w-full rounded-md border bg-[var(--color-ds-background-page)] px-2 py-1 relative",style:{borderColor:"var(--color-ds-border-default-50)",borderLeft:`4px solid ${k}`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, ${k} 18%, transparent)`,...z},children:[s.jsx(O,{}),y(),s.jsx(fe,{size:"xs",variant:"danger",onClick:d,title:"Quitar del layout",shape:"circle",icon:nt})]}),C(r+1,!1)]})}),G_=E.memo(function({col:t,widthClass:r,nodeIdx:n,sIdx:o,rIdx:l,cIdx:i,parentType:c,tabKey:u,confirmDelete:d}){const m=oe(y=>y.removeColumn),f=oe(y=>y.removeTabColumn),h=oe(y=>y.placeFieldInColumn),p=oe(y=>y.placeFieldInTabColumn),v=oe(y=>y.removeFieldFromLayout),b=oe(y=>y.removeFieldFromTabLayout),g=t.fields??[],x=oe(E.useCallback(y=>{const C=y.schema.fields;for(let N=C.length-1;N>=0;N--){const M=C[N];if(M.type!=="inputGroup"&&M.type!=="button")return M.name}},[])),w=()=>{d("Eliminar columna","¿Estás seguro de que quieres eliminar esta columna? Se perderán los campos que contiene.",()=>{c==="rows"?m(n,o,l,i):f(u,o,l,i)})},j=()=>{x&&(c==="rows"?h(x,n,o,l,i):p(x,u,o,l,i))},k=()=>s.jsxs("div",{className:"bg-[var(--color-ds-background-page)] overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-[var(--color-ds-background-surface)]",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"inline-flex items-center justify-center text-[11px] leading-none px-1.5 py-0.5 rounded-full border text-[var(--color-ds-text-primary)] border-[var(--color-ds-border-default-50)]",children:["Col ",i+1]}),s.jsx("span",{className:"text-[11px] leading-none text-[var(--color-ds-text-secondary)]",children:t.width||r||"flex-1"})]}),s.jsx("div",{className:"flex items-center gap-1",children:s.jsx(fe,{size:"xs",variant:"danger",onClick:w,title:"Eliminar columna",shape:"circle",icon:nt})})]}),s.jsxs("div",{className:"p-2 relative",children:[s.jsxs("div",{className:"space-y-2",children:[c==="rows"?s.jsx(Yt,{scope:"rows-column",rowsNodeIdx:n,s:o,r:l,c:i,insertAt:0,suppressAll:g.length===0}):s.jsx(Yt,{scope:"tabs-column",tabKey:u,s:o,r:l,c:i,insertAt:0,suppressAll:g.length===0}),g.length===0&&s.jsx("div",{className:"text-center text-[12px] text-[var(--color-ds-text-secondary)] border border-dashed border-[var(--color-ds-border-default-50)] rounded-md py-4",children:"Suelta campos aquí"}),g.map((y,C)=>s.jsx(q_,{field:y,index:C,nodeIdx:n,sIdx:o,rIdx:l,cIdx:i,parentType:c,tabKey:u,onDelete:()=>{d("Eliminar campo","¿Estás seguro de que quieres eliminar este campo?",()=>{c==="rows"?v({nodeIdx:n,s:o,r:l,c:i,idx:C}):b({tabKey:u,s:o,r:l,c:i,idx:C})})},confirmDelete:d},`${typeof y=="string"?y:y.name}-${C}`))]}),s.jsx("div",{className:"mt-2 text-center",children:s.jsx(fe,{size:"xs",variant:"outline",onClick:j,title:"Colocar el último campo creado en esta columna",children:"Colocar último campo"})})]})]});return c==="rows"?s.jsx(L0,{scope:"rows-column",rowsNodeIdx:n,s:o,r:l,c:i,children:k()}):s.jsx(L0,{scope:"tabs-column",tabKey:u,s:o,r:l,c:i,children:k()})}),_i=({value:e,onChange:t,placeholder:r="Click to edit",className:n,inputClassName:o,autoFocus:l=!1})=>{const[i,c]=E.useState(l),[u,d]=E.useState(e),m=E.useRef(null);E.useEffect(()=>{d(e)},[e]),E.useEffect(()=>{i&&m.current&&(m.current.focus(),m.current.select())},[i]);const f=()=>{c(!1),u.trim()!==e&&t(u)},h=p=>{p.key==="Enter"?(p.preventDefault(),f()):p.key==="Escape"&&(d(e),c(!1))};return i?s.jsx("input",{ref:m,value:u,onChange:p=>d(p.target.value),onBlur:f,onKeyDown:h,placeholder:r,className:he("bg-transparent border border-transparent focus:border-gray-400 dark:focus:border-gray-500 rounded px-0.5 -ml-0.5 outline-none w-full min-w-[20px] leading-inherit font-inherit text-inherit","focus:ring-2 focus:ring-gray-200 dark:focus:ring-gray-700",o,n),onClick:p=>p.stopPropagation(),onPointerDown:p=>p.stopPropagation(),onMouseDown:p=>p.stopPropagation()}):s.jsxs("span",{onDoubleClick:p=>{p.preventDefault(),p.stopPropagation(),c(!0)},onClick:p=>{p.preventDefault()},className:he("group cursor-text hover:bg-gray-100 dark:hover:bg-white/5 rounded px-0.5 -mx-0.5 border border-transparent hover:border-dashed hover:border-gray-400 truncate min-w-[20px] inline-flex items-center gap-1",!e&&"text-gray-400 italic",n),title:"Double click to edit",children:[s.jsx("span",{className:"truncate",children:e||r}),s.jsx("span",{role:"button",onClick:p=>{p.stopPropagation(),p.preventDefault(),c(!0)},className:"opacity-0 group-hover:opacity-100 transition-opacity text-gray-400 hover:text-blue-500 cursor-pointer",title:"Edit",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"w-3 h-3",children:[s.jsx("path",{d:"M5.433 13.917l1.262-3.155A4 4 0 017.58 9.42l6.92-6.918a2.121 2.121 0 013 3l-6.92 6.918c-.383.383-.84.685-1.343.886l-3.154 1.262a.5.5 0 01-.65-.65z"}),s.jsx("path",{d:"M3.5 5.75c0-.69.56-1.25 1.25-1.25H10A.75.75 0 0010 3H4.75A2.75 2.75 0 002 5.75v9.5A2.75 2.75 0 004.75 18h9.5A2.75 2.75 0 0017 15.25V10a.75.75 0 00-1.5 0v5.25c0 .69-.56 1.25-1.25 1.25h-9.5c-.69 0-1.25-.56-1.25-1.25v-9.5z"})]})})]})},K_=e=>e<=1?["w-full"]:e===2?["w-1/2","w-1/2"]:e===3?["w-1/3","w-1/3","w-1/3"]:Array.from({length:e},()=>"flex-1"),J_=[1,2,3,4],Y_=E.memo(function({row:t,nodeIdx:r,sIdx:n,rIdx:o,parentType:l,tabKey:i,confirmDelete:c}){const u=oe($=>$.setRowColumns),d=oe($=>$.removeRowFromSection),m=oe($=>$.addRowToSectionAt),f=oe($=>$.setRowTitle),h=oe($=>$.setTabRowColumns),p=oe($=>$.removeTabRow),v=oe($=>$.addRowToTabSectionAt),b=oe($=>$.setTabRowTitle),[g,x]=E.useState(!!t.title),w=t.columns??[],j=w.length===0,k=K_(w.length),y=$=>{l==="rows"?u(r,n,o,$):h(i,n,o,$)},C=()=>{c("Eliminar fila","¿Estás seguro de que quieres eliminar esta fila? Se perderán todos los campos que contiene.",()=>{l==="rows"?d(r,n,o):p(i,n,o)})},N=$=>{l==="rows"?f(r,n,o,$):b(i,n,o,$),$.trim()||x(!1)},M=()=>{x(!0)};return s.jsxs("div",{className:"space-y-0",children:[(g||t.title)&&s.jsx("div",{className:"px-3 py-2 bg-[var(--color-ds-background-elevated)] border-b border-[var(--color-ds-border-default-50)]",children:s.jsx(_i,{value:t.title||"",onChange:N,placeholder:"Título de la fila (opcional)",className:"text-sm font-medium text-[var(--color-ds-text-primary)]"})}),s.jsxs("div",{className:"px-3 py-2 flex items-center gap-1 bg-[var(--color-ds-background)] border-b border-[var(--color-ds-border-default-50)]",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap flex-1 min-w-0",children:[s.jsxs("span",{className:"text-[11px] leading-none uppercase tracking-wide text-[var(--color-ds-text-secondary)]",children:["Fila ",o+1]}),!g&&!t.title&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"h-3 w-px bg-[var(--color-ds-border-default-50)]"}),s.jsx(fe,{size:"xs",variant:"ghost",onClick:M,title:"Añadir título a la fila",icon:Bo,className:"text-[10px] text-[var(--color-ds-text-secondary)]",children:"Título"})]}),s.jsx("div",{className:"h-3 w-px bg-[var(--color-ds-border-default-50)]"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:J_.map($=>s.jsx(fe,{size:"xs",variant:"outline",className:"rounded-full px-2 py-0.5",onClick:()=>y($),title:`${$} columna(s)`,children:$},$))})]}),s.jsx(fe,{size:"xs",variant:"danger",onClick:C,title:"Eliminar fila",shape:"circle",icon:nt})]}),j?s.jsx("div",{className:"rounded-md border border-dashed p-6 text-center border-[var(--color-ds-border-default-50)] text-[var(--color-ds-text-secondary)]",children:'No hay columnas. Usa "+ columna".'}):s.jsx("div",{children:w.map(($,T)=>s.jsx(G_,{col:$,widthClass:k[T],nodeIdx:r,sIdx:n,rIdx:o,cIdx:T,parentType:l,tabKey:i,confirmDelete:c},`${l==="rows"?"col":"tcol"}-${r}-${n}-${o}-${T}`))}),s.jsx("div",{className:"flex justify-center p-1 bg-[var(--color-ds-background-surface)] border-t border-[var(--color-ds-border-default-50)]",children:s.jsx(fe,{size:"xs",variant:"ghost",className:"w-full justify-center text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)]",onClick:()=>{l==="rows"?m(r,n,o+1):v(i,n,o+1)},title:"Añadir fila debajo",children:"+ Añadir fila debajo"})})]})});function X_({nodeIdx:e,tabKey:t,insertAt:r}){const n={scope:"tab-section",nodeIdx:e,tabKey:t,insertAt:r},{setNodeRef:o,isOver:l}=tr({id:`tab-section:${e}:${t}:${r}`,data:n});return s.jsx("div",{ref:o,className:["h-2 my-1 w-full rounded-sm transition relative -mx-1 px-1",l?"bg-[var(--color-ds-border-default)]/30 ring-1 ring-[var(--color-ds-border-default)]":"bg-transparent"].join(" "),"aria-label":`Insertar sección de pestaña en posición ${r+1}`})}function Q_({nodeIdx:e,tabKey:t,sIdx:r}){const n=`tab-section:${e}:${t}:${r}`,o={kind:"tab-section",nodeIdx:e,tabKey:t,sIdx:r},{attributes:l,listeners:i,setNodeRef:c,isDragging:u}=Gr({id:n,data:o});return s.jsx("div",{ref:c,...l,...i,title:"Arrastrar sección de pestaña","aria-grabbed":u,className:"shrink-0 w-6 h-6 grid place-items-center cursor-grab active:cursor-grabbing rounded text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-background-muted)]",children:"⇅"})}function cu({expanded:e,onClick:t,labelExpanded:r,labelCollapsed:n,titleExpanded:o,titleCollapsed:l,className:i=""}){return s.jsx(fe,{size:"xs",variant:"ghost","aria-expanded":e,"aria-label":e?r:n,onClick:t,title:e?o??"Colapsar":l??"Expandir",className:`shrink-0 w-8 h-8 p-0 grid place-items-center ${i}`,children:s.jsx(Ut,{className:`w-4 h-4 text-[var(--color-ds-text-primary)] transition-transform duration-150 ${e?"rotate-180":""}`})})}function eT({section:e,onChange:t,formId:r,parentType:n,sectionIndex:o,tabKey:l}){const{translations:i}=St(),{t:c}=Ct(),[u,d]=E.useState("");E.useEffect(()=>{const h=e.sectionTitle,p=h&&(h.startsWith("forms.")||h.startsWith("ds."));if(i&&p){const v=i.getTranslation(h);d(v!==h?v:h)}else d(ct(c,h))},[e.sectionTitle,i,c]);const m=async()=>{const h=e.sectionTitle||"";if(u===(i&&h.startsWith("forms.")?i.getTranslation(h):ct(c,h)))return;if(!i){t(u);return}if((h.startsWith("forms.")||h.startsWith("ds."))&&!h.startsWith("ds."))await i.updateTranslation(h,u);else{const v=r||"defaultForm",b=Date.now().toString(36);let g="";n==="tabs"&&l?g=`forms.${v}.tabs.${l}.sections.s_${b}.title`:g=`forms.${v}.sections.s_${b}.title`,console.log("Generating section key",g,u),await i.updateTranslation(g,u),t(g)}},f=h=>{h.key==="Enter"&&h.currentTarget.blur()};return s.jsx("input",{type:"text",value:u,onChange:h=>d(h.target.value),onBlur:m,onKeyDown:f,className:"bg-transparent font-medium text-[var(--color-ds-text-primary)] placeholder-[var(--color-ds-text-tertiary)] outline-none border-b border-transparent focus:border-[var(--color-ds-border-accent)] transition-colors w-full",placeholder:"Sección sin título"})}const du=E.memo(function({section:t,nodeIdx:r,sIdx:n,parentType:o,tabKey:l,confirmDelete:i}){const{t:c}=Ct(),[u,d]=E.useState(!1),m=oe(x=>{var w,j;return((w=x.schema)==null?void 0:w.formId)||((j=x.schema)==null?void 0:j.id)}),f=oe(x=>x.renameSectionAt),h=oe(x=>x.removeSectionAt),p=oe(x=>x.removeTabSection),v=oe(x=>x.renameTabSection),b=x=>{o==="rows"?f(r,n,x):v(l,n,x)},g=()=>{i("Eliminar sección","¿Estás seguro de que quieres eliminar esta sección? Se perderán todos los campos que contiene.",()=>{o==="tabs"&&l?p(l,n):h(r,n)})};return s.jsxs("div",{className:"rounded-lg border border-[var(--color-ds-border-default-50)] overflow-hidden",children:[s.jsx("div",{className:"pr-3 bg-[var(--color-ds-background-surface)] border-b border-[var(--color-ds-border-default-50)]",children:s.jsxs("div",{className:"flex items-center gap-2 min-h-9 py-1",children:[s.jsx(cu,{expanded:!u,onClick:()=>d(!u),labelExpanded:"Colapsar sección",labelCollapsed:"Expandir sección",className:o==="tabs"?"ml-2":""}),s.jsx("div",{className:"flex-1 min-w-0 px-2 font-medium text-[var(--color-ds-text-primary)]",children:s.jsx(eT,{section:t,onChange:b,formId:m,parentType:o,sectionIndex:n,tabKey:l})}),o==="rows"?s.jsx(P_,{nodeIdx:r,sIdx:n}):s.jsx(Q_,{nodeIdx:r,tabKey:l,sIdx:n}),s.jsx("div",{className:"flex flex-wrap gap-1 ml-auto",children:s.jsx(fe,{size:"xs",variant:"danger",onClick:g,title:"Eliminar sección",shape:"circle",icon:nt})})]})}),!u&&s.jsx("div",{className:"bg-[var(--color-ds-background-page)]",children:t.rows.map((x,w)=>s.jsx(Y_,{row:x,nodeIdx:r,sIdx:n,rIdx:w,parentType:o,tabKey:l,confirmDelete:i},`${o==="rows"?"row":"trow"}-${o==="tabs"?l:r}-${w}`))})]})});function $0({nodeIdx:e,insertAt:t}){const r={scope:"tabs-tab",nodeIdx:e,insertAt:t},{setNodeRef:n,isOver:o}=tr({id:`tabs-tab:${e}:${t}`,data:r});return s.jsx("div",{ref:n,className:["w-1 h-5 rounded-md transition",o?"bg-[var(--color-ds-border-default)]/30 ring-1 ring-[var(--color-ds-border-default)]":"bg-transparent"].join(" "),title:`Insertar pestaña en posición ${t+1}`})}function tT({className:e=""}){return s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",className:e,fill:"currentColor",children:[1,5].map(t=>[1,4,7].map((r,n)=>s.jsx("circle",{cx:t,cy:r,r:"1"},`${t}-${r}-${n}`)))})}function rT({nodeIdx:e,index:t,tabKey:r,label:n,onRename:o}){const l=`tabs-tab:${e}:${t}:${r}`,i={kind:"tabs-tab",nodeIdx:e,index:t,tabKey:r},{attributes:c,listeners:u,setNodeRef:d,isDragging:m}=Gr({id:l,data:i});return s.jsxs("div",{ref:d,...c,...u,tabIndex:0,"aria-grabbed":m,"aria-label":`Arrastrar pestaña "${n}"`,title:`Arrastrar pestaña "${n}"`,className:["inline-flex items-center gap-1 select-none","h-6 px-1.5 rounded-full","text-[11px] leading-none","border border-[var(--color-ds-border-default-50)]","bg-[var(--color-ds-background-surface)]","text-[var(--color-ds-text-primary)]","cursor-grab active:cursor-grabbing","hover:bg-[color-mix(in_srgb,var(--color-ds-background-surface)_85%,black_15%)]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-ds-border-default)]",m?"opacity-60":"opacity-100","transition-colors"].join(" "),children:[s.jsx(tT,{className:"text-[var(--color-ds-text-primary)]"}),o?s.jsx(_i,{value:n,onChange:o,className:"max-w-[10rem]",inputClassName:"w-20 text-[11px]"}):s.jsx("span",{className:"truncate max-w-[10rem]",children:n})]})}function nT({tab:e,onChange:t,formId:r}){const{translations:n}=St(),{t:o}=Ct(),[l,i]=E.useState("");E.useEffect(()=>{const d=e.label,m=d&&(d.startsWith("forms.")||d.startsWith("ds."));if(n&&m){const f=n.getTranslation(d);i(f!==d?f:d)}else i(ct(o,d))},[e.label,n,o]);const c=async()=>{const d=e.label||"";if(l===(n&&d.startsWith("forms.")?n.getTranslation(d):ct(o,d)))return;if(!n){t(l);return}if((d.startsWith("forms.")||d.startsWith("ds."))&&!d.startsWith("ds."))await n.updateTranslation(d,l);else{const h=`forms.${r||"defaultForm"}.tabs.${e.key}.label`;await n.updateTranslation(h,l),t(h)}},u=d=>{d.key==="Enter"&&d.currentTarget.blur()};return s.jsx("input",{type:"text",value:l,onChange:d=>i(d.target.value),onBlur:c,onKeyDown:u,className:"bg-transparent text-lg font-bold text-[var(--color-ds-text-primary)] placeholder-[var(--color-ds-text-tertiary)] outline-none border-b border-transparent focus:border-[var(--color-ds-border-accent)] transition-colors flex-1 w-auto min-w-[60px]",placeholder:"Pestaña sin título"})}const aT=E.memo(function({node:t,nodeIdx:r,draggedTabSection:n,confirmDelete:o}){var w;const{t:l}=Ct(),[i,c]=E.useState(!1),[u,d]=E.useState(((w=t.tabs[0])==null?void 0:w.key)??""),m=oe(j=>j.removeLayoutNode),f=oe(j=>j.renameTab),h=oe(j=>j.updateTab),p=oe(j=>j.addTabAfter),v=oe(j=>j.removeTab),b=oe(j=>j.addSectionToTab);oe(j=>j.renameTabSection);const g=oe(j=>{var k,y;return((k=j.schema)==null?void 0:k.formId)||((y=j.schema)==null?void 0:y.id)}),x=t.tabs.map(j=>{const k=j.icon?yn(j.icon.name,j.icon.style):null;return{label:ct(l,j.label),value:j.key,disabled:!1,icon:k?s.jsx(k,{className:"w-4 h-4"}):null}});return E.useEffect(()=>{u===""&&t.tabs.length>0&&d(t.tabs[0].key)},[t.tabs,u]),s.jsx("div",{className:"space-y-2",children:s.jsxs("div",{className:"rounded-lg border border-[var(--color-ds-border-default-50)] overflow-hidden",children:[s.jsx("div",{className:"bg-[var(--color-ds-background-surface)] border-b border-[var(--color-ds-border-default-50)]",children:s.jsxs("div",{className:"flex items-center gap-2 min-h-9 py-1 pr-2",children:[s.jsx(cu,{expanded:!i,onClick:()=>c(!i),labelExpanded:"Colapsar pestañas",labelCollapsed:"Expandir pestañas"}),s.jsx("span",{className:"text-[11px] leading-none uppercase tracking-wide text-[var(--color-ds-text-secondary)]",children:"Pestañas"}),s.jsx("div",{className:"ml-auto",children:s.jsx(fe,{size:"xs",variant:"danger",onClick:()=>o("Eliminar bloque de pestañas","¿Estás seguro de que quieres eliminar este bloque de pestañas? Se perderá todo su contenido.",()=>m(r)),title:"Eliminar bloque",shape:"circle",icon:nt})})]})}),!i&&s.jsxs("div",{className:"bg-[var(--color-ds-background)]",children:[s.jsx("div",{className:"px-3 py-2 border-b border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface-soft)]",children:s.jsxs("span",{className:"text-[10px] uppercase tracking-wider font-medium text-[var(--color-ds-text-tertiary)] flex items-center gap-2",children:["Reordenar pestañas ",s.jsx("span",{className:"text-[var(--color-ds-text-tertiary)]/50 text-[9px] font-normal normal-case",children:"(Arrastrar para ordenar)"})]})}),s.jsx("div",{className:"custom-scroll scrollbar-hidden overflow-x-auto overflow-y-hidden bg-[var(--color-ds-background-surface-soft)]/30 border-b border-[var(--color-ds-border-default-50)]",children:s.jsxs("div",{className:"px-2 py-2 inline-flex items-center gap-1 whitespace-nowrap min-h-[2rem]",role:"list","aria-label":"Reordenar pestañas",children:[s.jsx($0,{nodeIdx:r,insertAt:0}),t.tabs.map((j,k)=>s.jsxs(E.Fragment,{children:[s.jsx(rT,{nodeIdx:r,index:k,tabKey:j.key,label:j.label,onRename:y=>f==null?void 0:f(j.key,y)}),s.jsx($0,{nodeIdx:r,insertAt:k+1})]},`tabchip-${r}-${j.key}`))]})}),s.jsx("div",{children:s.jsx(fr,{options:x,value:u,onChange:j=>d(j),children:t.tabs.reduce((j,k)=>(j[k.key]=s.jsxs("div",{className:"space-y-3",children:[u===k.key&&s.jsxs("div",{className:"flex flex-wrap items-center justify-between px-3 pt-3 pb-1 mb-1 gap-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-[150px]",children:[s.jsx("div",{className:"flex-shrink-0",children:s.jsx(Fr,{value:k.icon,onChange:y=>h==null?void 0:h(k.key,{icon:y})})}),s.jsx(nT,{tab:k,onChange:y=>h==null?void 0:h(k.key,{label:y}),formId:g})]}),s.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0 ml-auto",children:[s.jsxs("button",{onClick:()=>h==null?void 0:h(k.key,{disabled:!k.disabled}),className:`
293
293
  flex items-center gap-1.5 px-2 py-1 rounded-full text-[10px] font-medium transition-colors border
294
294
  ${k.disabled?"bg-red-50 text-red-700 border-red-200 hover:bg-red-100":"bg-[var(--color-ds-background-surface)] text-[var(--color-ds-text-tertiary)] border-[var(--color-ds-border-default-50)] hover:text-[var(--color-ds-text-primary)] hover:border-[var(--color-ds-border-default)]"}
295
- `,title:k.disabled?"Click para habilitar":"Click para deshabilitar",children:[k.disabled?s.jsx(ga,{className:"w-3 h-3"}):s.jsx(wd,{className:"w-3 h-3"}),s.jsx("span",{className:k.disabled?"inline":"hidden sm:inline",children:k.disabled?"Deshabilitada":"Habilitada"})]}),s.jsx("div",{className:"h-4 w-px bg-[var(--color-ds-border-default-50)]"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(fe,{icon:Sn,size:"sm",variant:"primary",shape:"circle",onClick:()=>b==null?void 0:b(k.key,"Nueva sección"),title:"Añadir nueva sección",className:"shadow-sm"}),s.jsx(sa,{align:"right",trigger:s.jsx("div",{className:"p-1.5 rounded-md hover:bg-[var(--color-ds-background-surface-soft)] text-[var(--color-ds-text-secondary)] transition-colors cursor-pointer",children:s.jsx(gd,{className:"w-5 h-5"})}),items:[{label:"Añadir Pestaña",icon:Ul,onSelect:()=>p==null?void 0:p(k.key)},{separator:!0},{label:"Eliminar Pestaña",icon:bt,variant:"danger",disabled:t.tabs.length<=1,onSelect:()=>o("Eliminar pestaña","¿Estás seguro de que quieres eliminar esta pestaña? Se perderá todo su contenido.",()=>v==null?void 0:v(k.key))}]})]})]})]}),Array.from({length:k.sections.length+1}).map((y,C)=>{const N=C,M=k.sections[N],$=(n==null?void 0:n.nodeIdx)===r&&(n==null?void 0:n.tabKey)===k.key&&C===n.sIdx+1;return s.jsxs(E.Fragment,{children:[s.jsx("div",{className:"px-2",children:!$&&s.jsx(Q_,{nodeIdx:r,tabKey:k.key,insertAt:C})}),N<k.sections.length&&s.jsx(du,{section:M,nodeIdx:r,sIdx:N,parentType:"tabs",tabKey:k.key,confirmDelete:o})]},`tsec-${k.key}-${C}`)})]}),j),{})})})]})]})})});function sT(){const e=oe(f=>f.schema.layout),t=oe(f=>f.editorSettings),[r,n]=E.useState(null),[o,l]=E.useState(null),[i,c]=E.useState({isOpen:!1,title:"",message:null,onConfirm:()=>{}});Ea({onDragStart:f=>{const{active:h}=f,p=h.data.current;p&&p.kind==="rows-section"&&n(p.sIdx),p&&p.kind==="tab-section"&&l({nodeIdx:p.nodeIdx,tabKey:p.tabKey,sIdx:p.sIdx})},onDragEnd:()=>{n(null),l(null)},onDragCancel:()=>{n(null),l(null)}});const u=E.useCallback((f,h,p)=>{if(!t.confirmDelete){p();return}c({isOpen:!0,title:f,message:h,onConfirm:p})},[t.confirmDelete]),d=()=>{i.onConfirm(),c(f=>({...f,isOpen:!1}))},m=()=>{c(f=>({...f,isOpen:!1}))};return s.jsxs("div",{id:"designer-canvas-root",className:"space-y-3 relative",children:[e.map((f,h)=>{if(f.type==="rows"){const p=f.sections;return s.jsx("div",{className:"space-y-3",children:Array.from({length:p.length+1}).map((v,b)=>{const g=b,x=p[g];return s.jsxs(E.Fragment,{children:[!(r!==null&&b===r+1)&&s.jsx(P_,{nodeIdx:h,insertAt:b}),g<p.length&&s.jsx(du,{section:x,nodeIdx:h,sIdx:g,parentType:"rows",confirmDelete:u})]},`rows-slot-sec-${h}-${b}`)})},`rows-${h}`)}return f.type==="tabs"?s.jsx(oT,{node:f,nodeIdx:h,draggedTabSection:o,confirmDelete:u},`tabs-${h}`):null}),s.jsx(Et,{isOpen:i.isOpen,onClose:m,title:i.title,footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(fe,{variant:"outline",onClick:m,children:"Cancelar"}),s.jsx(fe,{variant:"danger",onClick:d,children:"Eliminar"})]}),children:s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:i.message})})]})}function uu(e,t,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(t,1)[0]),n}function lT(e,t){return e.reduce((r,n,o)=>{const l=t.get(n);return l&&(r[o]=l),r},Array(e.length))}function Ua(e){return e!==null&&e>=0}function iT(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function cT(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const fu=e=>{let{rects:t,activeIndex:r,overIndex:n,index:o}=e;const l=uu(t,n,r),i=t[o],c=l[o];return!c||!i?null:{x:c.left-i.left,y:c.top-i.top,scaleX:c.width/i.width,scaleY:c.height/i.height}},qa={scaleX:1,scaleY:1},dT=e=>{var t;let{activeIndex:r,activeNodeRect:n,index:o,rects:l,overIndex:i}=e;const c=(t=l[r])!=null?t:n;if(!c)return null;if(o===r){const d=l[i];return d?{x:0,y:r<i?d.top+d.height-(c.top+c.height):d.top-c.top,...qa}:null}const u=uT(l,o,r);return o>r&&o<=i?{x:0,y:-c.height-u,...qa}:o<r&&o>=i?{x:0,y:c.height+u,...qa}:{x:0,y:0,...qa}};function uT(e,t,r){const n=e[t],o=e[t-1],l=e[t+1];return n?r<t?o?n.top-(o.top+o.height):l?l.top-(n.top+n.height):0:l?l.top-(n.top+n.height):o?n.top-(o.top+o.height):0:0}const mu="Sortable",hu=E.createContext({activeIndex:-1,containerId:mu,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:fu,disabled:{draggable:!1,droppable:!1}});function fT(e){let{children:t,id:r,items:n,strategy:o=fu,disabled:l=!1}=e;const{active:i,dragOverlay:c,droppableRects:u,over:d,measureDroppableContainers:m}=p1(),f=ka(mu,r),h=c.rect!==null,p=E.useMemo(()=>n.map(C=>typeof C=="object"&&"id"in C?C.id:C),[n]),v=i!=null,b=i?p.indexOf(i.id):-1,g=d?p.indexOf(d.id):-1,x=E.useRef(p),w=!iT(p,x.current),j=g!==-1&&b===-1||w,k=cT(l);qt(()=>{w&&v&&m(p)},[w,p,v,m]),E.useEffect(()=>{x.current=p},[p]);const y=E.useMemo(()=>({activeIndex:b,containerId:f,disabled:k,disableTransforms:j,items:p,overIndex:g,useDragOverlay:h,sortedRects:lT(p,u),strategy:o}),[b,f,k.draggable,k.droppable,j,p,g,u,h,o]);return E.createElement(hu.Provider,{value:y},t)}const mT=e=>{let{id:t,items:r,activeIndex:n,overIndex:o}=e;return uu(r,n,o).indexOf(t)},hT=e=>{let{containerId:t,isSorting:r,wasDragging:n,index:o,items:l,newIndex:i,previousItems:c,previousContainerId:u,transition:d}=e;return!d||!n||c!==l&&o===i?!1:r?!0:i!==o&&t===u},pT={duration:200,easing:"ease"},pu="transform",gT=Mr.Transition.toString({property:pu,duration:0,easing:"linear"}),vT={roleDescription:"sortable"};function bT(e){let{disabled:t,index:r,node:n,rect:o}=e;const[l,i]=E.useState(null),c=E.useRef(r);return qt(()=>{if(!t&&r!==c.current&&n.current){const u=o.current;if(u){const d=Ln(n.current,{ignoreTransform:!0}),m={x:u.left-d.left,y:u.top-d.top,scaleX:u.width/d.width,scaleY:u.height/d.height};(m.x||m.y)&&i(m)}}r!==c.current&&(c.current=r)},[t,r,n,o]),E.useEffect(()=>{l&&i(null)},[l]),l}function xT(e){let{animateLayoutChanges:t=hT,attributes:r,disabled:n,data:o,getNewIndex:l=mT,id:i,strategy:c,resizeObserverConfig:u,transition:d=pT}=e;const{items:m,containerId:f,activeIndex:h,disabled:p,disableTransforms:v,sortedRects:b,overIndex:g,useDragOverlay:x,strategy:w}=E.useContext(hu),j=wT(n,p),k=m.indexOf(i),y=E.useMemo(()=>({sortable:{containerId:f,index:k,items:m},...o}),[f,o,k,m]),C=E.useMemo(()=>m.slice(m.indexOf(i)),[m,i]),{rect:N,node:M,isOver:$,setNodeRef:T}=tr({id:i,data:y,disabled:j.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...u}}),{active:V,activatorEvent:I,activeNodeRect:z,attributes:O,setNodeRef:P,listeners:Q,isDragging:te,over:ne,setActivatorNodeRef:ae,transform:W}=Gr({id:i,data:y,attributes:{...vT,...r},disabled:j.draggable}),A=RO(T,P),F=!!V,Y=F&&!v&&Ua(h)&&Ua(g),U=!x&&te,ee=U&&Y?W:null,ue=Y?ee??(c??w)({rects:b,activeNodeRect:z,activeIndex:h,overIndex:g,index:k}):null,ge=Ua(h)&&Ua(g)?l({id:i,items:m,activeIndex:h,overIndex:g}):k,ce=V==null?void 0:V.id,se=E.useRef({activeId:ce,items:m,newIndex:ge,containerId:f}),we=m!==se.current.items,de=t({active:V,containerId:f,isDragging:te,isSorting:F,id:i,index:k,items:m,newIndex:se.current.newIndex,previousItems:se.current.items,previousContainerId:se.current.containerId,transition:d,wasDragging:se.current.activeId!=null}),me=bT({disabled:!de,index:k,node:M,rect:N});return E.useEffect(()=>{F&&se.current.newIndex!==ge&&(se.current.newIndex=ge),f!==se.current.containerId&&(se.current.containerId=f),m!==se.current.items&&(se.current.items=m)},[F,ge,f,m]),E.useEffect(()=>{if(ce===se.current.activeId)return;if(ce!=null&&se.current.activeId==null){se.current.activeId=ce;return}const J=setTimeout(()=>{se.current.activeId=ce},50);return()=>clearTimeout(J)},[ce]),{active:V,activeIndex:h,attributes:O,data:y,rect:N,index:k,newIndex:ge,items:m,isOver:$,isSorting:F,isDragging:te,listeners:Q,node:M,overIndex:g,over:ne,setNodeRef:A,setActivatorNodeRef:ae,setDroppableNodeRef:T,setDraggableNodeRef:P,transform:me??ue,transition:R()};function R(){if(me||we&&se.current.newIndex===k)return gT;if(!(U&&!Xo(I)||!d)&&(F||de))return Mr.Transition.toString({...d,property:pu})}}function wT(e,t){var r,n;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e==null?void 0:e.draggable)!=null?r:t.draggable,droppable:(n=e==null?void 0:e.droppable)!=null?n:t.droppable}}function Io(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const yT=[Ze.Down,Ze.Right,Ze.Up,Ze.Left],jT=(e,t)=>{let{context:{active:r,collisionRect:n,droppableRects:o,droppableContainers:l,over:i,scrollableAncestors:c}}=t;if(yT.includes(e.code)){if(e.preventDefault(),!r||!n)return;const u=[];l.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const h=o.get(f.id);if(h)switch(e.code){case Ze.Down:n.top<h.top&&u.push(f);break;case Ze.Up:n.top>h.top&&u.push(f);break;case Ze.Left:n.left>h.left&&u.push(f);break;case Ze.Right:n.left<h.left&&u.push(f);break}});const d=VO({collisionRect:n,droppableRects:o,droppableContainers:u});let m=J5(d,"id");if(m===(i==null?void 0:i.id)&&d.length>1&&(m=d[1].id),m!=null){const f=l.get(r.id),h=l.get(m),p=h?o.get(h.id):null,v=h==null?void 0:h.node.current;if(v&&p&&f&&h){const g=Qo(v).some((C,N)=>c[N]!==C),x=gu(f,h),w=kT(f,h),j=g||!x?{x:0,y:0}:{x:w?n.width-p.width:0,y:w?n.height-p.height:0},k={x:p.left,y:p.top};return j.x&&j.y?k:fa(k,j)}}}};function gu(e,t){return!Io(e)||!Io(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function kT(e,t){return!Io(e)||!Io(t)||!gu(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}const vu=(e,t,r)=>Math.max(t,Math.min(r,e));function I0(e){const t=[`li:${e.li}`];return e.tabIdx!=null&&t.push(`t:${e.tabIdx}`),t.push(`s:${e.sectionIdx}`,`r:${e.rowIdx}`,`c:${e.colIdx}`,`f:${e.fieldIdx}`),t.join("|")}function Gn(e){const t=Object.fromEntries(e.split("|").map(r=>r.split(":")));return{li:Number(t.li),tabIdx:t.t!=null?Number(t.t):void 0,sectionIdx:Number(t.s),rowIdx:Number(t.r),colIdx:Number(t.c),fieldIdx:Number(t.f)}}function F0(e,t){var n,o,l,i,c,u,d;const r=e[t.li];if(!r)return null;if(r.type==="rows"){const m=(n=r.sections)==null?void 0:n[t.sectionIdx],f=(o=m==null?void 0:m.rows)==null?void 0:o[t.rowIdx];return((l=f==null?void 0:f.columns)==null?void 0:l[t.colIdx])??null}if(r.type==="tabs"){const m=(i=r.tabs)==null?void 0:i[t.tabIdx??0],f=(c=m==null?void 0:m.sections)==null?void 0:c[t.sectionIdx],h=(u=f==null?void 0:f.rows)==null?void 0:u[t.rowIdx];return((d=h==null?void 0:h.columns)==null?void 0:d[t.colIdx])??null}return null}function ET(e,t,r){if(t.li===r.li&&(t.tabIdx??-1)===(r.tabIdx??-1)&&t.sectionIdx===r.sectionIdx&&t.rowIdx===r.rowIdx&&t.colIdx===r.colIdx&&t.fieldIdx===r.fieldIdx)return e;const n=JSON.parse(JSON.stringify(e.layout)),o=F0(n,{li:t.li,tabIdx:t.tabIdx,sectionIdx:t.sectionIdx,rowIdx:t.rowIdx,colIdx:t.colIdx}),l=F0(n,{li:r.li,tabIdx:r.tabIdx,sectionIdx:r.sectionIdx,rowIdx:r.rowIdx,colIdx:r.colIdx});if(!o||!Array.isArray(o.fields)||!l||!Array.isArray(l.fields))return e;const i=[...o.fields];if(t.fieldIdx<0||t.fieldIdx>=i.length)return e;const[c]=i.splice(t.fieldIdx,1);o.fields=i;const u=[...l.fields],d=vu(r.fieldIdx??u.length,0,u.length);return u.splice(d,0,c),l.fields=u,{...e,layout:n}}function RT(e,t){const r=JSON.parse(JSON.stringify(e.layout)),o=(u=>{var m,f,h,p,v,b,g,x,w,j,k,y;const d=r[u.li];return d?d.type==="rows"?((v=(p=(h=(f=(m=d.sections)==null?void 0:m[u.sectionIdx])==null?void 0:f.rows)==null?void 0:h[u.rowIdx])==null?void 0:p.columns)==null?void 0:v[u.colIdx])??null:d.type==="tabs"?((y=(k=(j=(w=(x=(g=(b=d.tabs)==null?void 0:b[u.tabIdx??0])==null?void 0:g.sections)==null?void 0:x[u.sectionIdx])==null?void 0:w.rows)==null?void 0:j[u.rowIdx])==null?void 0:k.columns)==null?void 0:y[u.colIdx])??null:null:null})({li:t.li,tabIdx:t.tabIdx,sectionIdx:t.sectionIdx,rowIdx:t.rowIdx,colIdx:t.colIdx});if(!o||!Array.isArray(o.fields))return e;const l=[...o.fields];if(t.fieldIdx<0||t.fieldIdx>=l.length)return e;const[i]=l.splice(t.fieldIdx,1);o.fields=l;const c=[...e.fields||[]];if(i){let u=0;const d=m=>{Array.isArray(m)&&m.includes(i)&&u++};if(r.forEach(m=>{var f,h;m.type==="rows"?(f=m.sections)==null||f.forEach(p=>{var v;return(v=p.rows)==null?void 0:v.forEach(b=>{var g;return(g=b.columns)==null?void 0:g.forEach(x=>d(x.fields))})}):m.type==="tabs"&&((h=m.tabs)==null||h.forEach(p=>{var v;return(v=p.sections)==null?void 0:v.forEach(b=>{var g;return(g=b.rows)==null?void 0:g.forEach(x=>{var w;return(w=x.columns)==null?void 0:w.forEach(j=>d(j.fields))})})}))}),u===0){const m=c.findIndex(f=>f.name===i);m!==-1&&c.splice(m,1)}}return{...e,layout:r,fields:c}}function CT(e,t){const r=new Set(e.map(l=>l.name));let n=1,o=`${t}_${n}`;for(;r.has(o);)n++,o=`${t}_${n}`;return o}function ST(e,t,r){const n=CT(e.fields||[],t.type||"field"),o={...t,name:n},l=[...e.fields||[],o],i=JSON.parse(JSON.stringify(e.layout)),u=(m=>{var h,p,v,b,g,x,w,j,k,y,C,N;const f=i[m.li];return f?f.type==="rows"?((g=(b=(v=(p=(h=f.sections)==null?void 0:h[m.sectionIdx])==null?void 0:p.rows)==null?void 0:v[m.rowIdx])==null?void 0:b.columns)==null?void 0:g[m.colIdx])??null:f.type==="tabs"?((N=(C=(y=(k=(j=(w=(x=f.tabs)==null?void 0:x[m.tabIdx??0])==null?void 0:w.sections)==null?void 0:j[m.sectionIdx])==null?void 0:k.rows)==null?void 0:y[m.rowIdx])==null?void 0:C.columns)==null?void 0:N[m.colIdx])??null:null:null})({li:r.li,tabIdx:r.tabIdx,sectionIdx:r.sectionIdx,rowIdx:r.rowIdx,colIdx:r.colIdx});if(!u)return{...e,fields:l};Array.isArray(u.fields)||(u.fields=[]);const d=vu(r.fieldIdx??u.fields.length,0,u.fields.length);return u.fields.splice(d,0,n),{...e,fields:l,layout:i}}const bu=E.createContext(null),xu=()=>{const e=E.useContext(bu);if(!e)throw new Error("useRelations must be used inside <RelationsProvider>");return e},NT=e=>{const{registerFieldEl:t}=xu();return E.useCallback(r=>{e&&t(e,r)},[e,t])},MT=({children:e})=>{const[t,r]=E.useState(!1),[n,o]=E.useState(null),[l,i]=E.useState({}),c=E.useRef({}),u=p=>r(v=>typeof p=="boolean"?p:!v),d=E.useCallback((p,v)=>{c.current[p]=v},[]);E.useEffect(()=>{let p=!0,v;const g=(async()=>{try{const{useEditorStore:x}=await Promise.resolve().then(()=>EO),j=x.getState().showRelations??!1;return v=j,p&&r(j),x.subscribe(y=>{const C=y.showRelations??!1;p&&C!==v&&(v=C,r(C))})}catch(x){return console.error("Failed to sync with store:",x),()=>{}}})();return()=>{p=!1,g.then(x=>x())}},[]);const m=E.useRef(null),f=E.useRef({});E.useEffect(()=>{if(!t)return;const p=()=>{const w=m.current;if(!w)return;const j=w.getBoundingClientRect(),k={};for(const[M,$]of Object.entries(c.current)){if(!$)continue;const T=$.getBoundingClientRect();k[M]={x:Math.round(T.left-j.left+T.width/2),y:Math.round(T.top-j.top+T.height/2),w:Math.round(T.width),h:Math.round(T.height)}}const y=f.current;let C=!1;const N=new Set([...Object.keys(k),...Object.keys(y)]);for(const M of N){const $=k[M],T=y[M];if(!$||!T||$.x!==T.x||$.y!==T.y||$.w!==T.w||$.h!==T.h){C=!0;break}}C&&(f.current=k,i(k))},v=()=>requestAnimationFrame(p),b=new ResizeObserver(v);m.current&&b.observe(m.current);const g=new MutationObserver(v);m.current&&g.observe(m.current,{childList:!0,subtree:!0}),window.addEventListener("resize",v,{passive:!0}),document.addEventListener("scroll",v,{passive:!0,capture:!0});const x=new ResizeObserver(v);return Object.values(c.current).forEach(w=>w&&x.observe(w)),v(),()=>{b.disconnect(),g.disconnect(),x.disconnect(),window.removeEventListener("resize",v),document.removeEventListener("scroll",v,{capture:!0})}},[t]);const h=E.useMemo(()=>({enabled:t,toggle:u,registerFieldEl:d,anchors:l,schema:n,setSchema:o}),[t,d,l,n]);return s.jsx(bu.Provider,{value:h,children:s.jsx("div",{ref:m,className:"relative",children:e})})};function ao(e){return e?e.op==="and"||e.op==="or"?(e.rules??[]).flatMap(ao):e.op==="always"?[]:[e.field]:[]}function Js(e){return e!=null&&e.parameters?Object.values(e.parameters).filter(t=>t.type==="field"&&t.fieldRef).map(t=>t.fieldRef):[]}function AT(e){var o,l,i,c,u,d;const t=[];for(const m of e.fields){const f=m.name;if(!f)continue;const h=(o=m.visibleWhen)==null?void 0:o.rule,p=(l=m.disabledWhen)==null?void 0:l.rule,v=(i=m.clearWhen)==null?void 0:i.rule;for(const w of ao(h))t.push({from:w,to:f,kind:"visibleWhen"});for(const w of ao(p))t.push({from:w,to:f,kind:"disabledWhen"});for(const w of ao(v))t.push({from:w,to:f,kind:"clearWhen"});const b=(c=m.visibleWhen)==null?void 0:c.endpoint,g=(u=m.disabledWhen)==null?void 0:u.endpoint,x=(d=m.clearWhen)==null?void 0:d.endpoint;for(const w of Js(b))t.push({from:w,to:f,kind:"visibleWhen"});for(const w of Js(g))t.push({from:w,to:f,kind:"disabledWhen"});for(const w of Js(x))t.push({from:w,to:f,kind:"clearWhen"})}const r=m=>`${m.from}->${m.to}:${m.kind}`,n=new Set;return t.filter(m=>n.has(r(m))?!1:(n.add(r(m)),!0))}const Ys={visibleWhen:"var(--color-success-500, #22c55e)",disabledWhen:"var(--color-warning-500, #f59e0b)",clearWhen:"var(--color-info-500, #0ea5e9)"};function _0(e){return{left:e.x-e.w/2,right:e.x+e.w/2,top:e.y-e.h/2,bottom:e.y+e.h/2,cx:e.x,cy:e.y,w:e.w,h:e.h}}function T0(e,t,r=20,n=0){const o=_0(e),l=_0(t),i=1,c=1,u=l.cx-o.cx,d=l.cy-o.cy,f=Math.min(o.bottom,l.bottom)-Math.max(o.top,l.top)>0||Math.abs(u)>Math.abs(d);let h,p,v=[];if(f)if(u>0?(h={x:o.right+i,y:o.cy},p={x:l.left-c,y:l.cy}):(h={x:o.left-i,y:o.cy},p={x:l.right+c,y:l.cy}),Math.abs(h.y-p.y)<5)v=[h,p];else{const x=(h.x+p.x)/2;if(u>0&&h.x>p.x||u<0&&h.x<p.x){const w=Math.max(o.bottom,l.bottom)+r;v=[h,{x:h.x+(u>0?10:-10),y:h.y},{x:h.x+(u>0?10:-10),y:w},{x:p.x-(u>0?10:-10),y:w},{x:p.x-(u>0?10:-10),y:p.y},p]}else v=[h,{x,y:h.y},{x,y:p.y},p]}else if(d>0?(h={x:o.cx,y:o.bottom+i},p={x:l.cx,y:l.top-c}):(h={x:o.right+i,y:o.cy},p={x:l.right+c,y:l.cy}),d>0&&Math.abs(h.x-p.x)<5)v=[h,p];else if(d>0){const x=(h.y+p.y)/2;v=[h,{x:h.x,y:x},{x:p.x,y:x},p]}else{const x=Math.max(o.right,l.right)+r;v=[h,{x,y:h.y},{x,y:p.y},p]}n!==0&&(v=v.map(x=>f?{x:x.x,y:x.y+n}:{x:x.x+n,y:x.y}));let b=`M ${v[0].x},${v[0].y}`;for(let x=1;x<v.length;x++)b+=` L ${v[x].x},${v[x].y}`;let g={x:0,y:0};if(v.length===2)g={x:(v[0].x+v[1].x)/2,y:(v[0].y+v[1].y)/2};else{const x=Math.floor((v.length-1)/2),w=v[x],j=v[x+1];g={x:(w.x+j.x)/2,y:(w.y+j.y)/2}}return{d:b,label:g}}const OT=({enabled:e=!0,anchors:t,schema:r})=>{const n=E.useMemo(()=>r?AT(r):[],[r]),[o,l]=E.useState(null),i=oe(m=>m.setSelection),c=oe(m=>m.selection),u=(c==null?void 0:c.kind)==="field"?c.name:null,d=E.useMemo(()=>{const m=new Map;return n.forEach(f=>{const h=`${f.from}->${f.to}`;m.has(h)||m.set(h,[]),m.get(h).push(f)}),Array.from(m.entries())},[n]);return!e||!r||n.length===0?null:s.jsxs("svg",{className:"pointer-events-none absolute inset-0 z-50",width:"100%",height:"100%",children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"arrow-head-visibleWhen",viewBox:"0 0 10 10",refX:8,refY:5,markerWidth:4,markerHeight:4,orient:"auto",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--color-success-500, #22c55e)"})}),s.jsx("marker",{id:"arrow-head-disabledWhen",viewBox:"0 0 10 10",refX:8,refY:5,markerWidth:4,markerHeight:4,orient:"auto",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--color-warning-500, #f59e0b)"})}),s.jsx("marker",{id:"arrow-head-clearWhen",viewBox:"0 0 10 10",refX:8,refY:5,markerWidth:4,markerHeight:4,orient:"auto",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--color-info-500, #0ea5e9)"})}),s.jsx("marker",{id:"circle-start-visibleWhen",viewBox:"0 0 10 10",refX:5,refY:5,markerWidth:3,markerHeight:3,children:s.jsx("circle",{cx:5,cy:5,r:3,fill:"var(--color-success-500, #22c55e)"})}),s.jsx("marker",{id:"circle-start-disabledWhen",viewBox:"0 0 10 10",refX:5,refY:5,markerWidth:3,markerHeight:3,children:s.jsx("circle",{cx:5,cy:5,r:3,fill:"var(--color-warning-500, #f59e0b)"})}),s.jsx("marker",{id:"circle-start-clearWhen",viewBox:"0 0 10 10",refX:5,refY:5,markerWidth:3,markerHeight:3,children:s.jsx("circle",{cx:5,cy:5,r:3,fill:"var(--color-info-500, #0ea5e9)"})})]}),d.map(([m,f])=>{const h=f[0],p=t[h.from],v=t[h.to];if(!p||!v)return null;const b=`${m}`,g=o===b,x=!!u&&f.some(z=>z.from===u||z.to===u),w=f[0].kind,j=Ys[w];let k=1;g?k=1:o?k=x?.4:.15:u&&(k=x?1:.2);const y=T0(p,v),{label:C}=y,N=f.length>1?f.map(z=>{const O=z.kind.replace("When","");return O.charAt(0).toUpperCase()+O.slice(1)}).join(" + "):h.kind,M=Math.max(80,N.length*6+20),$=()=>{i({kind:"field",name:h.to})},T=f.length,V=3,I=f.map((z,O)=>(O-(T-1)/2)*V);return s.jsxs("g",{style:{opacity:k,transition:"opacity 0.2s"},onMouseEnter:()=>l(b),onMouseLeave:()=>l(null),onClick:$,className:"pointer-events-auto cursor-pointer",children:[f.map((z,O)=>{const P=Ys[z.kind],{d:Q}=T0(p,v,20,I[O]),te=!!u&&(z.from===u||z.to===u),ne=g||te?1.75:1,ae=`url(#arrow-head-${z.kind})`,W=`url(#circle-start-${z.kind})`;return s.jsxs("g",{children:[s.jsx("path",{d:Q,stroke:"transparent",strokeWidth:18,fill:"none"}),s.jsx("path",{d:Q,stroke:P,strokeWidth:ne,fill:"none",markerEnd:ae,markerStart:W,strokeLinejoin:"round",strokeDasharray:z.kind==="disabledWhen"?"5 5":void 0})]},`${b}-${z.kind}-${O}`)}),s.jsxs("g",{transform:`translate(${C.x}, ${C.y})`,children:[s.jsx("rect",{x:-M/2,y:-10,width:M,height:20,rx:4,ry:4,fill:"var(--color-ds-background-page, #f8fafc)",stroke:j,strokeWidth:1,className:"shadow-sm"}),s.jsx("text",{x:0,y:4,textAnchor:"middle",fontSize:10,fontWeight:600,fill:"var(--color-ds-text-primary, #0f172a)",style:{pointerEvents:"none"},children:N}),f.length>1&&s.jsx("g",{transform:"translate(0, 15)",children:f.map((z,O)=>{const P=Ys[z.kind],Q=(O-(f.length-1)/2)*20;return s.jsx("circle",{cx:Q,cy:0,r:3,fill:P,stroke:"white",strokeWidth:1},O)})})]})]},b)})]})};function B0(e,t){if(!e||!t)return;const r=t==="outline"?bn:xn;let n=r==null?void 0:r[e];return!n&&(r!=null&&r.default)&&(n=r.default[e]),n||console.warn(`[IconResolver] Icon "${e}" (${t}) no encontrado en @heroicons/react/24/${t}. Revisa tu versión o el nombre. Exports disponibles (outline):`,Object.keys(t==="outline"?bn:xn)),console.log(n),n||void 0}function sr(e){if(!(!e||typeof e!="object"))return console.log(B0(e.name,e.style)),B0(e.name,e.style)}function LT(e){const{fields:t,fieldsByName:r,control:n,errors:o,isSubmitting:l,loadingDefaults:i,asyncOptionsMap:c,adapterOptionsMap:u,evalContainer:d,disabledMap:m,registry:f,methods:h,translateFn:p,onUpdateField:v,isDesignMode:b}=e,g=()=>oe.getState().fieldPick,x=j=>oe.getState().completeFieldPick(j),w=(j,k)=>{if(!k)return j;const y=g(),C=y.armed,N=C&&y.forField===k,M=C&&!N,$=I=>{C&&(I.preventDefault(),I.stopPropagation(),!N&&x(k))},T=I=>{C&&M&&(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),I.stopPropagation(),x(k))},V=C?N?"opacity-40 cursor-not-allowed":"cursor-pointer transition-all rounded border border-[color-mix(in_srgb,var(--color-ds-border-default)_40%,transparent)] hover:border-[color-mix(in_srgb,var(--color-ds-border-default)_70%,transparent)] hover:bg-[color-mix(in_srgb,var(--color-ds-background-accent)_5%,transparent)]":"";return s.jsx("div",{onClick:$,onKeyDown:T,tabIndex:M?0:-1,className:V,role:M?"button":void 0,"aria-label":M?`Seleccionar campo ${k}`:void 0,children:j})};return function j(k){var P,Q,te,ne,ae;let y;if(typeof k=="string"){if(y=r[k],y||(y=(t??[]).find(W=>(W==null?void 0:W.name)===k)),!y)return null}else y=k;y.visibleWhen;let C=!!y.disabled;const N=y.disabledWhen,M=d(N,!1);N!=null&&N.enabled&&(C=M),!(N!=null&&N.enabled)&&"name"in y&&y.name&&m[y.name]&&(C=!0);const $=y==null?void 0:y.name;if(y.type==="search"){const W=typeof y.searchFn=="function",A=ho(y.searchSource,y.endpointConfig),F=async ee=>{if(W)return y.searchFn(ee,{getValues:h.getValues,watch:h.watch});if(A){const le=y.endpointConfig?Ir(y.endpointConfig.parameters,h.getValues):{},ue=f==null?void 0:f[A];if(typeof ue=="function")return await ue(ee,{getValues:h.getValues,watch:h.watch,params:le});if(Array.isArray(ue))return ue}return[]},Y={};y.searchMode&&(Y.searchMode=y.searchMode),y.minChars&&(Y.minChars=y.minChars),y.debounceMs&&(Y.debounceMs=y.debounceMs),y.resolveByValue&&(Y.resolveByValue=y.resolveByValue);const U=s.jsx(mi,{name:y.name,control:n,searchFn:F,label:p(y.label),size:y.size,width:y.width,disabled:C||l,...Y},y.name);return w(U,$)}if(y.type==="inputGroup"){const W=y,A=(W.inputs??[]).map(Y=>{var ce;const U=typeof Y=="string"?r[Y]??(t??[]).find(se=>(se==null?void 0:se.name)===Y):Y;if(!U)return null;const ee=U.disabledWhen;let le=!!U.disabled;const ue=d(ee,!1);ee!=null&&ee.enabled&&(le=ue),!(ee!=null&&ee.enabled)&&m[U.name]&&(le=!0);const ge={name:U.name,control:n,label:p(U.label),size:U.size,width:U.width,placeholder:p(U.placeholder),hasError:!!o[U.name],errorMessage:p((ce=o[U.name])==null?void 0:ce.message),loading:!1,disabled:le||l,suffixButton:U.suffixButton,reserveErrorSpace:!0,labelPrefixIcon:sr(U.labelPrefixIcon),labelSuffixIcon:sr(U.labelSuffixIcon),prefixIcon:sr(U.prefixIcon),suffixIcon:sr(U.suffixIcon)};return U.type==="select"?{...ge,options:U.options??u[U.name]??c[U.name]??[],loadOptions:U.options||U.optionSource||U.endpointConfig?void 0:U.loadOptions}:{...ge,type:U.type}}).filter(Boolean),F=s.jsx(fi,{groupLabel:p(W.groupLabel),inputs:A,separator:W.separator,useSeparator:W.useSeparator,className:W.className,showVisibleLabel:W.showVisibleLabel,size:W.size},`inputGroup_${W.name??W.groupLabel??"group"}`);return w(F,W.name)}if(y.type==="button"){const W=y,A=W.icon,F=A&&typeof A=="object"&&A.name&&A.style?sr(A):void 0,Y=s.jsx("div",{className:"self-center",children:s.jsx(fe,{type:"button",variant:W.variant,size:W.size,width:W.width,icon:F,iconPosition:W.iconPosition,ariaLabel:p(W.ariaLabel),onClick:W.onClick,disabled:C||l,children:p(W.label)})},W.name);return w(Y,$)}const T=y.suffixButton,V=typeof T=="string"?j(T):T,I=p(y.label),z=b&&v&&y.name?s.jsx(_i,{value:I,onChange:W=>{const A=oe.getState().schema.formId||"defaultForm",F=y.name,Y=`forms.${A}.fields.${F}.label`;Xn.updateTranslation(Y,W),v(F,{label:Y})},placeholder:"Sin etiqueta",className:"font-medium"}):I,O={name:y.name,control:n,disabled:C||l,label:z,size:y.size,width:y.width,placeholder:p(y.placeholder),info:(()=>{const W=y.info;return W&&typeof W=="object"&&(W.type==="complex"||"header"in W||"template"in W)?W.template?p(W.template):"":p(W)})(),infoHeader:(()=>{const W=y.info;if(W&&typeof W=="object"&&(W.type==="complex"||"header"in W||"template"in W))return W.header||void 0})(),suffixButton:V,labelPrefixIcon:sr(y.labelPrefixIcon),labelSuffixIcon:sr(y.labelSuffixIcon),prefixIcon:sr(y.prefixIcon),suffixIcon:sr(y.suffixIcon)};switch(y.type){case"select":{const W=y.name,A=y.options??u[W]??c[W]??[],F=!y.options&&!y.optionSource&&!y.endpointConfig&&y.loadOptions,Y=s.jsx(Ft,{name:W,control:n,render:({field:U})=>{var ee;return s.jsx(Ke,{...O,value:U.value,onChange:U.onChange,options:A,loadOptions:F||void 0,hasError:!!o[W],errorMessage:p((ee=o[W])==null?void 0:ee.message),suffixButton:V})}},`${W}`);return w(Y,$)}case"textarea":{const W=s.jsx(Ft,{name:y.name,control:n,render:({field:A,fieldState:F})=>{var Y;return s.jsx(Nr,{...O,value:A.value,onChange:A.onChange,maxLength:y.maxLength,showCounter:!!y.showCounter,hasError:!!F.error,errorMessage:p((Y=F.error)==null?void 0:Y.message)})}},y.name);return w(W,$)}case"file":{const W=s.jsx(li,{...O,defaultValue:[],maxFiles:y.maxFiles,accept:y.accept,hideDropZone:y.hideDropZone,hasError:!!o[y.name],errorMessage:p((P=o[y.name])==null?void 0:P.message)},y.name);return w(W,$)}case"checkbox":{const W=s.jsx(rt,{...O,defaultValue:!1,hasError:!!o[y.name],errorMessage:p((Q=o[y.name])==null?void 0:Q.message),name:y.name},y.name);return w(W,$)}case"date":{const W=s.jsx(wn,{...O,defaultValue:"",showTime:!!y.showTime,hasError:!!o[y.name],errorMessage:p((te=o[y.name])==null?void 0:te.message)},y.name);return w(W,$)}case"optionGroup":{const W=s.jsx(Uo,{...O,options:y.options||[],multiple:y.multiple,vertical:y.vertical,groupLabel:y.groupLabel,defaultValue:y.defaultValue,className:y.width?void 0:"w-full",name:y.name},y.name);return w(W,$)}case"toggle":{const W=s.jsx(vi,{...O,checked:y.defaultValue??!1,errorMessage:p((ne=o[y.name])==null?void 0:ne.message),name:y.name},y.name);return w(W,$)}default:{const W=s.jsx(Ho,{...O,type:y.type,loadingDefaults:i,hasError:!!o[y.name],errorMessage:p((ae=o[y.name])==null?void 0:ae.message),suffixButton:V,name:y.name},y.name);return w(W,$)}}}}function $T(e){var r;return e?!!((r=e.closest)!=null&&r.call(e,'button,[role="button"],a[href],input,select,textarea,[contenteditable="true"],[data-interactive="true"]')):!1}function IT(e){var r;return e?!!((r=e.closest)!=null&&r.call(e,'[data-input-group-root],[data-input-group],[data-role="input-group"],.input-group,.InputGroup')):!1}function Hn(e){var t;e.preventDefault(),e.stopPropagation(),(t=e.nativeEvent)!=null&&t.stopImmediatePropagation&&e.nativeEvent.stopImmediatePropagation()}function FT({id:e,children:t,onDelete:r,fieldName:n,chromeDisabled:o=!1}){const{attributes:l,listeners:i,setNodeRef:c,transform:u,transition:d,isDragging:m}=xT({id:e,disabled:o}),f=oe(g=>g.setSelection),h={transform:Mr.Transform.toString(u),transition:d},p="opacity-0 scale-95 group-hover:opacity-100 group-hover:scale-100 group-focus-within:opacity-100 group-focus-within:scale-100",v=g=>{const x=g.target;$T(x)||IT(x)||n&&(g.stopPropagation(),f({kind:"field",name:n}))},b=g=>{Hn(g)};return s.jsxs("div",{ref:c,style:h,className:["relative",o?"":"group",m?"z-30":"z-0"].filter(Boolean).join(" "),onClickCapture:v,onDoubleClick:b,onDoubleClickCapture:b,children:[!o&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:["pointer-events-none absolute -inset-0.5 rounded-lg","bg-[var(--color-ds-background-surface)]/80","border border-dashed border-[var(--color-ds-border-default-50)]","transition-all duration-150 ease-out",p,m?"opacity-100 scale-100":""].join(" ")}),s.jsxs("div",{className:["pointer-events-none absolute -top-3 right-2 flex gap-1 z-40","transition-all duration-150 ease-out",p,m?"opacity-100 scale-100":""].join(" "),children:[r&&s.jsx("button",{type:"button","aria-label":"Eliminar campo",className:["pointer-events-auto inline-flex items-center justify-center","w-7 h-7 rounded-full","bg-[var(--color-ds-background-surface)]","border border-[var(--color-ds-border-default-50)]","text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-danger)]","focus:outline-none focus:ring-2 focus:ring-[var(--color-ds-border-default-50)]","transition-colors"].join(" "),onClick:g=>{g.preventDefault(),g.stopPropagation(),r==null||r(e)},onDoubleClick:Hn,onDoubleClickCapture:Hn,children:s.jsx(bt,{className:"w-4 h-4"})}),s.jsx("button",{type:"button","aria-label":"Mover campo","data-drag-handle":!0,className:["pointer-events-auto inline-flex items-center justify-center","w-8 h-8 rounded-full cursor-grab active:cursor-grabbing touch-none","bg-[var(--color-ds-background-surface)]","border border-[var(--color-ds-border-default-50)]","text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)]","focus:outline-none focus:ring-2 focus:ring-[var(--color-ds-border-default-50)]","transition-colors"].join(" "),...l,...i,onDoubleClick:Hn,onDoubleClickCapture:Hn,children:s.jsx(rd,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"relative z-10",children:t})]})}function _T(e,t){if(!t||t.kind!=="row-in-section"&&t.kind!=="row-in-tab-section")return!1;const r=n=>e.insertAt===n||e.insertAt===n+1;if(e.scope==="row-slot"){if(t.kind==="row-in-section"&&t.li===e.li&&t.sIdx===e.sIdx&&r(t.rIdx))return!0}else if(e.scope==="tab-row-slot"&&t.kind==="row-in-tab-section"&&t.li===e.li&&t.tabKey===e.tabKey&&t.sIdx===e.sIdx&&r(t.rIdx))return!0;return!1}function Ga(e){const t=e.scope==="row-slot"?{scope:"row-slot",li:e.li,sIdx:e.sIdx,insertAt:e.insertAt}:{scope:"tab-row-slot",li:e.li,tabKey:e.tabKey,sIdx:e.sIdx,insertAt:e.insertAt},r=e.scope==="row-slot"?`row-slot|li:${e.li}|s:${e.sIdx}|i:${e.insertAt}`:`tab-row-slot|li:${e.li}|t:${e.tabKey}|s:${e.sIdx}|i:${e.insertAt}`,{setNodeRef:n,isOver:o}=tr({id:r,data:t}),[l,i]=E.useState(void 0);return Ea({onDragStart:d=>{i(d.active.data.current)},onDragEnd:()=>i(void 0),onDragCancel:()=>i(void 0)}),_T(e,l)?s.jsx("div",{ref:n,style:{display:"none"}}):s.jsx("div",{className:"w-full relative transition-all duration-200 ease-in-out",style:{height:o?60:0,pointerEvents:"none",zIndex:o?10:0},children:s.jsx("div",{ref:n,className:"absolute left-0 right-0",style:{top:o?0:-12,height:o?"100%":24,zIndex:o?10:2,pointerEvents:"auto"},children:o&&s.jsx("div",{className:"w-full h-full rounded-md border border-dashed border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background)]/60 relative",style:{boxShadow:"inset 0 0 0 1px color-mix(in srgb, var(--color-ds-border-default-50) 30%, transparent)"},children:s.jsx("div",{className:"absolute -top-2 left-3 px-1.5 py-0.5 rounded text-[11px] leading-none",style:{background:"var(--color-ds-background-elevated)",color:"var(--color-ds-text-secondary)",border:"1px solid var(--color-ds-border-default-50)"},children:"Soltar fila aquí"})})})})}function Z0(e){const t=e.kind==="row-in-section"?{kind:"row-in-section",li:e.li,sIdx:e.sIdx,rIdx:e.rIdx}:{kind:"row-in-tab-section",li:e.li,tabKey:e.tabKey,sIdx:e.sIdx,rIdx:e.rIdx},r=e.kind==="row-in-section"?`row|li:${e.li}|s:${e.sIdx}|r:${e.rIdx}`:`tab-row|li:${e.li}|t:${e.tabKey}|s:${e.sIdx}|r:${e.rIdx}`,{attributes:n,listeners:o,setNodeRef:l,isDragging:i}=Gr({id:r,data:t});return s.jsx("div",{ref:l,"aria-label":"Handle de arrastre de fila",style:{position:"absolute",left:"50%",top:-14,transform:"translateX(-50%)",zIndex:2147483647,pointerEvents:e.visible?"auto":"none",opacity:e.visible?1:0,transition:"opacity .12s ease"},...o,...n,children:s.jsx("div",{className:"flex items-center justify-center bg-[var(--color-ds-background-elevated)]/85 backdrop-blur-sm px-1 py-0.5 rounded-lg border border-[var(--color-ds-border-default-50)] shadow-sm",children:s.jsx("div",{title:"Mover fila (arrastrar)",className:"flex items-center justify-center rounded hover:bg-[var(--color-ds-background-muted)] transition-colors",style:{cursor:i?"grabbing":"grab",touchAction:"none",padding:"2px 6px"},children:s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 text-[var(--color-ds-text-secondary)]",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9h16.5m-16.5 6.75h16.5"})})})})})}function TT(e){const r={text:()=>({label:"ds.fields.defaults.text.label",type:"text",width:"w-full",placeholder:"ds.fields.defaults.text.placeholder",size:"sm"}),number:()=>({label:"ds.fields.defaults.number.label",type:"number",width:"w-full",placeholder:"ds.fields.defaults.number.placeholder",size:"sm",validation:{required:!1}}),email:()=>({label:"ds.fields.defaults.email.label",type:"email",width:"w-full",placeholder:"ds.fields.defaults.email.placeholder",size:"sm"}),password:()=>({label:"ds.fields.defaults.password.label",type:"password",width:"w-full",placeholder:"ds.fields.defaults.password.placeholder",size:"sm",validation:{minLength:8}}),tel:()=>({label:"ds.fields.defaults.tel.label",type:"tel",width:"w-full",placeholder:"ds.fields.defaults.tel.placeholder",size:"sm"}),url:()=>({label:"ds.fields.defaults.url.label",type:"url",width:"w-full",placeholder:"ds.fields.defaults.url.placeholder",size:"sm"}),select:()=>({label:"ds.fields.defaults.select.label",type:"select",width:"w-full",size:"sm",options:[{label:"Opción A",value:"A"},{label:"Opción B",value:"B"}]}),checkbox:()=>({label:"ds.fields.defaults.checkbox.label",type:"checkbox",width:"w-full",size:"sm",defaultValue:!1}),textarea:()=>({label:"ds.fields.defaults.textarea.label",type:"textarea",width:"w-full",size:"sm",maxLength:300,showCounter:!0,placeholder:"ds.fields.defaults.textarea.placeholder"}),date:()=>({label:"ds.fields.defaults.date.label",type:"date",width:"w-full",size:"sm",showTime:!1}),file:()=>({label:"ds.fields.defaults.file.label",type:"file",width:"w-full",maxFiles:1,accept:".pdf,.doc,.docx"}),inputGroup:()=>({label:"Grupo",type:"inputGroup",width:"w-full",fields:[]}),search:()=>({label:"ds.fields.defaults.search.label",type:"search",width:"w-full",placeholder:"ds.fields.defaults.search.placeholder",size:"sm",searchMode:"button"}),optionGroup:()=>({label:"Selecciona opciones",type:"optionGroup",width:"w-full",size:"sm",multiple:!0,vertical:!0,options:[{label:"Opción 1",value:"opt1"},{label:"Opción 2",value:"opt2"},{label:"Opción 3",value:"opt3"}]}),array:()=>({label:"Lista repetible",type:"array",width:"w-full",items:[]}),button:()=>({label:"Botón",type:"button",width:"w-auto",variant:"primary",size:"sm"})}[e];return r?r():{type:e}}function BT(e){return typeof e=="function"}function Kn(e,t){if(!e||!t)return null;const r=t==="outline"?bn:xn,n=r==null?void 0:r[e];return BT(n)?n:null}function Ll(e){var c,u,d,m,f,h,p,v;if(!e||typeof e!="object")return e;if(e.type==="inputGroup"){const b=e,g={...b};return Array.isArray(b.inputs)&&(g.inputs=b.inputs.map(x=>typeof x=="string"?x:Ll(x))),g}const t=e,r={...t},n=Kn((c=t.labelPrefixIcon)==null?void 0:c.name,(u=t.labelPrefixIcon)==null?void 0:u.style),o=Kn((d=t.labelSuffixIcon)==null?void 0:d.name,(m=t.labelSuffixIcon)==null?void 0:m.style),l=Kn((f=t.prefixIcon)==null?void 0:f.name,(h=t.prefixIcon)==null?void 0:h.style),i=Kn((p=t.suffixIcon)==null?void 0:p.name,(v=t.suffixIcon)==null?void 0:v.style);return n&&(r.labelPrefixIcon=n),o&&(r.labelSuffixIcon=o),l&&(r.prefixIcon=l),i&&(r.suffixIcon=i),r}function ZT({name:e,children:t}){const r=NT(e);return s.jsx("div",{ref:r,"data-field":e,style:{position:"relative"},children:t})}function V0(e){return e.startsWith("row|")?Object.fromEntries(e.slice(4).split(";").map(r=>r.split(":"))):{}}function VT(e,t){const r=V0(e),n=V0(t);return r.ctx===n.ctx&&r.li===n.li&&r.s===n.s&&(r.t??"")===(n.t??"")}function D0(e,t){if(!e.startsWith("col|"))return Gn(e);const r=Object.fromEntries(e.slice(4).split(";").map(i=>i.split(":"))),n=r.ctx==="rows"?`rows|li:${r.li}|s:${r.s}|r:${r.r}|c:${r.c}`:`tabs|li:${r.li}|t:${r.t}|s:${r.s}|r:${r.r}|c:${r.c}`,o=(t[n]??[]).length,l=Object.prototype.hasOwnProperty.call(r,"insertAt");return{li:Number(r.li),tabIdx:r.t?Number(r.t):void 0,sectionIdx:Number(r.s),rowIdx:Number(r.r),colIdx:Number(r.c),fieldIdx:l?Number(r.insertAt):o}}function DT(e,t){const r=Array.from(e.querySelectorAll("[data-sortable-item]"));if(!r.length)return{insertAt:0,yAbs:e.getBoundingClientRect().top+8};let n=r.length,o=r[r.length-1].getBoundingClientRect().bottom;for(let l=0;l<r.length;l++){const i=r[l].getBoundingClientRect(),c=(i.top+i.bottom)/2;if(t<c){n=l,o=i.top;break}}return{insertAt:n,yAbs:o}}function PT(e){E.useEffect(()=>{if(!e)return;let t=0;const r=()=>{const n=document.getElementById("form-renderer-root");if(!n){t=requestAnimationFrame(r);return}const o=n.getBoundingClientRect(),l=window.__lastPointerY,i=80,c=14;typeof l=="number"&&(l<o.top+i?window.scrollBy({top:-c}):l>o.bottom-i&&window.scrollBy({top:c})),t=requestAnimationFrame(r)};return t=requestAnimationFrame(r),()=>cancelAnimationFrame(t)},[e])}function zT(e){const t=e.replaceAll("|",";");return t.startsWith("rows;")?`col|ctx:rows;${t.slice(5)}`:t.startsWith("tabs;")?`col|ctx:tabs;${t.slice(5)}`:`col|${t}`}function HT({droppableId:e,children:t,className:r,scope:n,li:o,tabIdx:l,sectionIdx:i,rowIdx:c,colIdx:u}){const d=n?{scope:n,...n==="rows-column"?{rowsNodeIdx:o}:{tabKey:`tab-${l}`},s:i,r:c,c:u,insertAt:0}:void 0,{isOver:m,setNodeRef:f}=tr({id:e,data:d});return s.jsx("div",{ref:f,className:["relative min-h-[28px] h-full overflow-visible transition-[box-shadow,border-color] duration-100",m?"ring-1 ring-[var(--color-ds-border-default-50)] rounded":"",r??""].join(" "),style:{isolation:"isolate"},"data-droppable-col":!0,children:t})}function WT(e,t){var n,o,l,i,c,u,d,m,f;const r=e.layout[t.li];if(r)return r.type==="rows"?(i=(l=(o=(n=r.sections[t.sectionIdx])==null?void 0:n.rows[t.rowIdx])==null?void 0:o.columns[t.colIdx])==null?void 0:l.fields)==null?void 0:i[t.fieldIdx]:(f=(m=(d=(u=(c=r.tabs[t.tabIdx])==null?void 0:c.sections[t.sectionIdx])==null?void 0:u.rows[t.rowIdx])==null?void 0:d.columns[t.colIdx])==null?void 0:m.fields)==null?void 0:f[t.fieldIdx]}function P0({ctx:e,visible:t}){const{t:r}=Ct(),n=oe(y=>y.addColumnToRow),o=oe(y=>y.setRowColumns),l=oe(y=>y.removeLastColumn),i=oe(y=>y.addRowToSectionAt),c=oe(y=>y.addColumnToTabRow),u=oe(y=>y.setTabRowColumns),d=oe(y=>y.removeLastTabColumn),m=oe(y=>y.addRowToTabSectionAt),f=()=>e.kind==="rows"?n==null?void 0:n(e.sectionIdx,e.rowIdx):c==null?void 0:c(e.tabKey,e.sectionIdx,e.rowIdx),h=()=>e.kind==="rows"?l==null?void 0:l(e.sectionIdx,e.rowIdx):d==null?void 0:d(e.tabKey,e.sectionIdx,e.rowIdx),p=y=>e.kind==="rows"?o==null?void 0:o(e.sectionIdx,e.rowIdx,y):u==null?void 0:u(e.tabKey,e.sectionIdx,e.rowIdx,y),v=()=>e.kind==="rows"?i==null?void 0:i(e.sectionIdx,e.rowIdx):m==null?void 0:m(e.tabKey,e.sectionIdx,e.rowIdx),b=()=>e.kind==="rows"?i==null?void 0:i(e.sectionIdx,e.rowIdx+1):m==null?void 0:m(e.tabKey,e.sectionIdx,e.rowIdx+1),[g,x]=E.useState({isOpen:!1,title:"",message:null,onConfirm:()=>{}}),w=(y,C,N)=>{x({isOpen:!0,title:y,message:C,onConfirm:N})},j=()=>{g.onConfirm(),x(y=>({...y,isOpen:!1}))},k=()=>{x(y=>({...y,isOpen:!1}))};return s.jsxs("div",{"aria-label":"Acciones de fila",style:{position:"absolute",insetInlineEnd:6,insetBlockStart:-25,zIndex:2147483646,pointerEvents:t?"auto":"none",opacity:t?1:0,transition:"opacity .12s ease"},className:"flex items-center gap-1",children:[s.jsxs("div",{className:"flex items-center gap-1 bg-[var(--color-ds-background-elevated)]/85 backdrop-blur-sm px-1.5 py-1 rounded-lg border border-[var(--color-ds-border-default-50)] shadow-sm",children:[s.jsx(fe,{size:"xs",variant:"ghost",title:r("ds.editor.actions.addRow"),onClick:v,children:"↑"}),s.jsx(fe,{size:"xs",variant:"ghost",title:r("ds.editor.actions.addRow"),onClick:b,children:"↓"}),s.jsx("span",{className:"w-px h-4 bg-[var(--color-ds-border-default-50)] mx-1","aria-hidden":!0}),s.jsx(fe,{size:"xs",variant:"ghost",title:r("ds.editor.actions.addColumn"),onClick:f,children:"+"}),s.jsx(fe,{size:"xs",variant:"ghost",title:r("ds.editor.actions.deleteColumn"),onClick:()=>w(r("ds.editor.confirmations.deleteColumn.title"),r("ds.editor.confirmations.deleteColumn.message"),h),children:"−"}),s.jsx("span",{className:"w-px h-4 bg-[var(--color-ds-border-default-50)] mx-1","aria-hidden":!0}),[1,2,3,4].map(y=>s.jsx(fe,{size:"xs",variant:"ghost",title:`Distribuir en ${y} columna(s)`,onClick:()=>p(y),children:y},y))]}),s.jsx(Et,{isOpen:g.isOpen,onClose:k,title:g.title,footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(fe,{variant:"outline",onClick:k,children:r("ds.editor.actions.cancel")}),s.jsx(fe,{variant:"danger",onClick:j,children:r("ds.editor.actions.delete")})]}),children:s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:g.message})})]})}function UT({schema:e,onSchemaChange:t,deps:r,layoutEditMode:n=!1}){const{t:o}=Ct(),l=oe(K=>K.updateField),i=oe(K=>K.mode),c=un(K=>K.setRuntimeState),u=un(K=>K.systemContext);E.useEffect(()=>{if(!e.variables)return;const K={};e.variables.forEach(re=>{re.type==="constant"&&(K[re.key]=re.value)}),e.variables.forEach(re=>{if(re.type==="computed"&&re.value)try{const ie=new Function("ctx",`return (${re.value});`);K[re.key]=ie(K)}catch(ie){console.warn(`[FormRendererDnd] Error evaluating computed variable "${re.key}":`,ie),K[re.key]=null}}),Object.keys(K).length>0&&c({systemContext:K})},[e.variables,c]);const d=E.useMemo(()=>({...r,translateFn:(K,re)=>{const ie=ct(o,K,re);return ie?bl(ie,u):""},onUpdateField:(K,re)=>{l(K,ie=>{Object.assign(ie,re)})},isDesignMode:i==="design"}),[r,o,l,i,u]),m=E.useCallback((K,re)=>{const ie=ct(o,K,re);return ie?bl(ie,u):""},[o,u]),f=E.useMemo(()=>LT(d),[d]),h=oe(K=>K.selection),p=(h==null?void 0:h.kind)==="field"?h.name:void 0,b=oe(K=>K.fieldPick).armed,{enabled:g,anchors:x,setSchema:w}=xu();E.useEffect(()=>{w(e)},[e,w]);const[j,k]=E.useState(null),[y,C]=E.useState(null),N=E.useRef({}),M=E.useCallback(K=>re=>{N.current[K]=re},[]),$=E.useRef(null),T=E.useRef(null),V=E.useRef(null),I=K=>{T.current==null&&(T.current=requestAnimationFrame(()=>{T.current=null;const re=V.current;JSON.stringify(re)!==JSON.stringify(K)&&(V.current=K,C(K))}))},z=E.useMemo(()=>{const K={};return e.layout.forEach((re,ie)=>{re.type==="tabs"&&(K[ie]=re.tabs[0].key)}),K},[e.layout]),[O,P]=E.useState(z),[Q,te]=E.useState({isOpen:!1,title:"",message:null,onConfirm:()=>{}}),ne=(K,re,ie)=>{te({isOpen:!0,title:K,message:re,onConfirm:ie})},ae=()=>{Q.onConfirm(),te(K=>({...K,isOpen:!1}))},W=()=>{te(K=>({...K,isOpen:!1}))},A=E.useMemo(()=>{const K={};return e.layout.forEach((re,ie)=>{re.type==="rows"?re.sections.forEach((pe,ve)=>{pe.rows.forEach((ye,Se)=>{ye.columns.forEach((ke,Fe)=>{const Oe=`rows|li:${ie}|s:${ve}|r:${Se}|c:${Fe}`;K[Oe]=(ke.fields??[]).map((Ce,xe)=>I0({li:ie,sectionIdx:ve,rowIdx:Se,colIdx:Fe,fieldIdx:xe}))})})}):re.type==="tabs"&&re.tabs.forEach((pe,ve)=>{pe.sections.forEach((ye,Se)=>{ye.rows.forEach((ke,Fe)=>{ke.columns.forEach((Oe,Ce)=>{const xe=`tabs|li:${ie}|t:${ve}|s:${Se}|r:${Fe}|c:${Ce}`;K[xe]=(Oe.fields??[]).map((Ne,Le)=>I0({li:ie,tabIdx:ve,sectionIdx:Se,rowIdx:Fe,colIdx:Ce,fieldIdx:Le}))})})})})}),K},[e]),F=E.useMemo(()=>{const K={};return Object.entries(A).forEach(([re,ie])=>ie.forEach(pe=>K[pe]=re)),K},[A]),Y=K5(Co(ts,{activationConstraint:{distance:6}}),Co(es,{coordinateGetter:jT})),U="__phantom__",[ee,le]=E.useState(!1),[ue,ge]=E.useState(null),[ce,se]=E.useState(null),[we,de]=E.useState(40),[me,R]=E.useState(null),[J,H]=E.useState(null),L=E.useCallback(K=>{if(!K)return!1;if(typeof K=="string"){const re=r.fieldsByName[K];return!!re&&re.type==="inputGroup"}return(K==null?void 0:K.type)==="inputGroup"},[r.fieldsByName]),S=K=>{var Se;const re=String(((Se=K.active)==null?void 0:Se.id)??""),ie=Y5(K),pe=ie[0],ve=pe?String(pe.id):null;if(ve&&F[ve]&&F[re]&&F[ve]===F[re])return ie;const ye=zO(K);if(re.startsWith("row|")||re.startsWith("tab-row|")){const ke=ye.filter(Fe=>String(Fe.id).startsWith("row-slot|")||String(Fe.id).startsWith("tab-row-slot|"));if(ke.length)return ke}else{const ke=ye.filter(Fe=>String(Fe.id).startsWith("col|"));if(ke.length)return ke}return ie};Ea({onDragStart:K=>{var pe,ve,ye,Se,ke,Fe;le(!0);const re=String(K.active.id??"");ge(re),se(F[re]??null),$.current=re.startsWith("row|")?"row":"field";const ie=((ve=(pe=K.active.rect.current)==null?void 0:pe.translated)==null?void 0:ve.height)??((Se=(ye=K.active.rect.current)==null?void 0:ye.initial)==null?void 0:Se.height)??40;if(de(Math.max(24,Math.floor(ie))),$.current==="field"&&!re.startsWith("col|")&&!re.startsWith("palette:"))try{const Oe=Gn(re),Ce=(ke=e.layout)==null?void 0:ke[Oe.li],Ne=(Fe=((Ce==null?void 0:Ce.type)==="rows"?Ce.sections[Oe.sectionIdx].rows[Oe.rowIdx].columns[Oe.colIdx]:Ce.tabs[Oe.tabIdx].sections[Oe.sectionIdx].rows[Oe.rowIdx].columns[Oe.colIdx]).fields)==null?void 0:Fe[Oe.fieldIdx??0],Le=Ne&&Ll(Ne);R(Le?f(Le):null)}catch{R(null)}else R(null)},onDragOver:K=>{var Fe,Oe;const re=String(((Fe=K.over)==null?void 0:Fe.id)??""),ie=String(((Oe=K.active)==null?void 0:Oe.id)??""),pe=K.activatorEvent;if(pe&&typeof pe.clientY=="number"&&(window.__lastPointerY=pe.clientY),$.current==="row"){if(re.startsWith("row|")&&ie.startsWith("row|"))if(VT(ie,re)&&ie!==re){const Ce=N.current[re],xe=(pe==null?void 0:pe.clientY)??0;if(Ce&&xe){const Ne=Ce.getBoundingClientRect(),Le=xe<Ne.top+Ne.height/2?"before":"after";I({rid:re,pos:Le})}else I(null)}else I(null);else I(null);H(null);return}if(!re.startsWith("col|")){H(null);return}const ve=Object.fromEntries(re.slice(4).split(";").map(Ce=>Ce.split(":"))),ye=ve.ctx==="rows"?`rows|li:${ve.li}|s:${ve.s}|r:${ve.r}|c:${ve.c}`:`tabs|li:${ve.li}|t:${ve.t}|s:${ve.s}|r:${ve.r}|c:${ve.c}`,Se=document.querySelector(`[data-col-key="${ye}"]`),ke=(pe==null?void 0:pe.clientY)??0;if(Se&&ke){const{insertAt:Ce,yAbs:xe}=DT(Se,ke),Ne=Se.getBoundingClientRect().top;H({overId:re,keyId:ye,insertAt:Ce,yRel:xe-Ne})}else H(null)},onDragCancel:K=>{le(!1),ge(null),se(null),de(40),R(null),H(null),C(null),$.current=null,T.current&&(cancelAnimationFrame(T.current),T.current=null),V.current=null},onDragEnd:()=>{le(!1),ge(null),se(null),de(40),R(null),C(null),$.current=null,T.current&&(cancelAnimationFrame(T.current),T.current=null),V.current=null}}),PT(ee);const D=E.useCallback(K=>{const{active:re,over:ie}=K;if(!(re!=null&&re.id)||!(ie!=null&&ie.id)){H(null),C(null);return}const pe=re.data.current,ve=ie.data.current;if(((pe==null?void 0:pe.kind)==="row-in-section"||(pe==null?void 0:pe.kind)==="row-in-tab-section")&&((ve==null?void 0:ve.scope)==="row-slot"||(ve==null?void 0:ve.scope)==="tab-row-slot")){const Ce=pe.li,xe=pe.sIdx,Ne=pe.rIdx,Le=ve.li,Me=ve.sIdx,Te=ve.insertAt,Ie={...e,layout:[...e.layout]},Ae={...Ie.layout[Ce]};Ie.layout[Ce]=Ae;let qe=null,ze=null,De=null;if(pe.kind==="row-in-section"&&Ae.type==="rows")Ae.sections=[...Ae.sections],ze={...Ae.sections[xe]},Ae.sections[xe]=ze,ze.rows=[...ze.rows],qe=ze.rows;else if(pe.kind==="row-in-tab-section"&&Ae.type==="tabs"){Ae.tabs=[...Ae.tabs];const Je=Ae.tabs.findIndex(Ve=>Ve.key===pe.tabKey);Je>=0&&(De={...Ae.tabs[Je]},Ae.tabs[Je]=De,De.sections=[...De.sections],ze={...De.sections[xe]},De.sections[xe]=ze,ze.rows=[...ze.rows],qe=ze.rows)}if(!qe)return;let He=null,We=null;if(Ce===Le?We=Ae:(We={...Ie.layout[Le]},Ie.layout[Le]=We),ve.scope==="row-slot"&&We.type==="rows")if(We.sections===Ae.sections||(We.sections=[...We.sections]),Ce===Le&&xe===Me&&pe.kind==="row-in-section")He=qe;else{const Je={...We.sections[Me]};We.sections[Me]=Je,Je.rows=[...Je.rows],He=Je.rows}else if(ve.scope==="tab-row-slot"&&We.type==="tabs"){We.tabs===Ae.tabs||(We.tabs=[...We.tabs]);const Je=We.tabs.findIndex(Ve=>Ve.key===ve.tabKey);if(Je>=0){let Ve=We.tabs[Je];if(Ce===Le&&pe.kind==="row-in-tab-section"&&pe.tabKey===ve.tabKey?Ve=De:(Ve={...Ve},We.tabs[Je]=Ve),Ve.sections===(De==null?void 0:De.sections)||(Ve.sections=[...Ve.sections]),Ce===Le&&xe===Me&&pe.kind==="row-in-tab-section"&&pe.tabKey===ve.tabKey)He=qe;else{const tt={...Ve.sections[Me]};Ve.sections[Me]=tt,tt.rows=[...tt.rows],He=tt.rows}}}if(!He)return;const[Tt]=qe.splice(Ne,1);let Be=Te;qe===He&&Ne<Te&&(Be-=1),He.splice(Be,0,Tt),t(Ie),H(null),C(null);return}if((pe==null?void 0:pe.kind)==="palette-field"){const Ce=String(ie.id);if(!Ce.startsWith("col|")){H(null),C(null);return}const xe=Object.fromEntries(Ce.slice(4).split(";").map(Ae=>Ae.split(":"))),Ne=J&&J.overId===Ce?J.insertAt:xe.insertAt?Number(xe.insertAt):0,Le={li:Number(xe.li),tabIdx:xe.t!=null?Number(xe.t):void 0,sectionIdx:Number(xe.s),rowIdx:Number(xe.r),colIdx:Number(xe.c),fieldIdx:Ne},Me=pe.factoryKind,Te=TT(Me),Ie=ST(e,Te,Le);H(null),C(null),t(Ie);return}const ye=String(re.id),Se=String(ie.id);if(ye.startsWith("row|")&&Se.startsWith("row|"),ye.startsWith("palette:")){H(null),C(null);return}const ke=Gn(ye);let Fe;if(Se.startsWith("col|")&&J&&J.overId===Se){const Ce=Object.fromEntries(Se.slice(4).split(";").map(Ne=>Ne.split(":"))),xe=`col|${Object.entries(Ce).filter(([Ne])=>Ne!=="insertAt").map(([Ne,Le])=>`${Ne}:${Le}`).join(";")};insertAt:${J.insertAt}`;Fe=D0(xe,A)}else Fe=D0(Se,A);const Oe=ET(e,ke,Fe);H(null),C(null),t(Oe)},[e,t,A,J]);function _(K,re){let ie=K;if(ue&&ce&&ce!==re&&(ie=ie.filter(pe=>pe!==ue)),ee&&J&&J.keyId===re){const pe=Math.max(0,Math.min(J.insertAt,ie.length)),ve=ie.slice();return ve.splice(pe,0,U),ve}return ie}const Z=({keyId:K,ids:re,className:ie,tabKey:pe})=>{const ve=zT(K),ye=_(re,K),Se=Object.fromEntries(K.split("|").map(Te=>Te.split(":"))),ke=K.startsWith("rows|"),Fe=ke?"rows-column":"tabs-column",Oe=Number(Se.li),Ce=Se.t!=null?Number(Se.t):void 0,xe=Number(Se.s),Ne=Number(Se.r),Le=Number(Se.c),Me=re.length;return s.jsx(HT,{droppableId:ve,className:ie,scope:Fe,li:Oe,tabIdx:Ce,sectionIdx:xe,rowIdx:Ne,colIdx:Le,children:s.jsxs("div",{"data-col-key":K,className:"relative",children:[ke?s.jsx(Yt,{scope:"rows-column",rowsNodeIdx:Oe,s:xe,r:Ne,c:Le,insertAt:0,suppressAll:Me===0}):pe?s.jsx(Yt,{scope:"tabs-column",tabKey:pe,s:xe,r:Ne,c:Le,insertAt:0,suppressAll:Me===0}):null,ee&&J&&J.overId===ve?s.jsx("div",{"aria-hidden":!0,style:{position:"absolute",left:0,right:0,top:Math.max(0,J.yRel-1),height:2,background:"var(--color-ds-border-default)",borderRadius:2}}):null,s.jsx(fT,{items:ye,strategy:dT,children:s.jsx("div",{children:ye.map((Te,Ie)=>{if(Te===U)return s.jsx("div",{"data-sortable-item":!0,"aria-hidden":!0,style:{height:we,border:"1px dashed var(--color-ds-border-default-50)",borderRadius:8,background:"color-mix(in srgb, var(--color-ds-border-default-50) 8%, transparent)"}},`${K}-ph-${Ie}`);const Ae=Gn(String(Te)),qe=WT(e,Ae);if(!qe)return s.jsx("div",{"data-sortable-item":!0,"aria-hidden":!0},`${K}-miss-${Ie}`);const ze=Ll(qe),De=typeof ze=="string"?ze:(ze==null?void 0:ze.name)??"",He=!!p&&!!De&&p===De,We=f(ze),Tt=L(ze),Be=Ve=>{var tt;Ve.preventDefault(),Ve.stopPropagation(),(tt=Ve.nativeEvent)!=null&&tt.stopImmediatePropagation&&Ve.nativeEvent.stopImmediatePropagation()},Je=Tt?{onDoubleClick:Be,onDoubleClickCapture:Be,onClick:Be,onClickCapture:Be,onMouseDown:Be,onMouseDownCapture:Be,onMouseUp:Be,onMouseUpCapture:Be,onPointerDown:Be,onPointerDownCapture:Be,onPointerUp:Be,onPointerUpCapture:Be,onContextMenu:Be}:{};return s.jsx("div",{"data-sortable-item":!0,children:s.jsx(FT,{id:String(Te),fieldName:De,onDelete:Ve=>{const tt=Gn(Ve);ne("Eliminar campo","¿Estás seguro de que quieres eliminar este campo?",()=>{const Or=RT(e,tt);t(Or)})},chromeDisabled:b,children:s.jsx(ZT,{name:De,children:s.jsx("div",{className:He?"selected-field":void 0,"data-field-name":De,"aria-selected":He||void 0,...Je,children:We})})})},String(Te))})})})]})})},B=ee&&$.current==="row",q=(K,re)=>s.jsx(s.Fragment,{children:K.sections.map((ie,pe)=>s.jsx("div",{className:"mb-6",children:s.jsx(ot,{title:m(ie.sectionTitle),defaultOpen:ie.defaultOpen,forceOpen:B,children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx(Ga,{scope:"row-slot",li:re,sIdx:pe,insertAt:0}),ie.rows.map((ve,ye)=>{const Se=`row|li:${re}|s:${pe}|r:${ye}`,ke=n&&j===Se,Fe=ue===Se;return s.jsxs(E.Fragment,{children:[s.jsxs("div",{ref:M(Se),className:`relative transition-all duration-200 ${Fe?"opacity-40 ring-1 ring-dashed ring-[var(--color-ds-border-default)] bg-[var(--color-ds-background-muted)]":n&&ke?"ring-1 ring-[var(--color-ds-border-default-50)]":""}`,onMouseEnter:()=>k(Se),onMouseLeave:()=>k(Oe=>Oe===Se?null:Oe),style:{borderRadius:8},children:[n&&s.jsxs(s.Fragment,{children:[s.jsx(P0,{ctx:{kind:"rows",li:re,sectionIdx:pe,rowIdx:ye},visible:!!ke&&!b}),s.jsx(Z0,{kind:"row-in-section",li:re,sIdx:pe,rIdx:ye,visible:!!ke&&!b})]}),ve.title&&s.jsx("h2",{className:"mb-2 text-lg text-[var(--color-ds-text-primary)]",children:m(ve.title)}),s.jsx("div",{className:"flex flex-wrap -mx-2 items-stretch",children:ve.columns.map((Oe,Ce)=>{const xe=`rows|li:${re}|s:${pe}|r:${ye}|c:${Ce}`,Ne=A[xe]??[];return s.jsx("div",{className:`${Oe.width} px-2 flex flex-col`,children:s.jsx(Z,{keyId:xe,ids:Ne})},`col-${re}-${pe}-${ye}-${Ce}`)})})]}),s.jsx(Ga,{scope:"row-slot",li:re,sIdx:pe,insertAt:ye+1})]},`rowwrap-${Se}`)})]})})},`sec-${re}-${pe}`))}),X=(K,re)=>{var pe;const ie=O[re]??((pe=K.tabs[0])==null?void 0:pe.key);return s.jsx(fr,{options:K.tabs.map(ve=>{const ye=ve.icon?Kn(ve.icon.name,ve.icon.style):null;return{label:m(ve.label),value:ve.key,disabled:ve.disabled,icon:ye?s.jsx(ye,{className:"w-4 h-4"}):null}}),value:ie,onChange:ve=>P(ye=>({...ye,[re]:ve})),children:Object.fromEntries(K.tabs.map((ve,ye)=>[ve.key,s.jsx("div",{className:"space-y-6",children:ve.sections.map((Se,ke)=>s.jsx("div",{className:"mb-6",children:s.jsx(ot,{title:m(Se.sectionTitle),defaultOpen:Se.defaultOpen,forceOpen:B,children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx(Ga,{scope:"tab-row-slot",li:re,tabKey:ve.key,sIdx:ke,insertAt:0}),Se.rows.map((Fe,Oe)=>{const Ce=`tab-row|li:${re}|t:${ve.key}|s:${ke}|r:${Oe}`,xe=n&&j===Ce,Ne=ue===Ce;return s.jsxs(E.Fragment,{children:[s.jsxs("div",{ref:M(Ce),className:`relative transition-all duration-200 ${Ne?"opacity-40 ring-1 ring-dashed ring-[var(--color-ds-border-default)] bg-[var(--color-ds-background-muted)]":n&&xe?"ring-1 ring-[var(--color-ds-border-default-50)]":""}`,onMouseEnter:()=>k(Ce),onMouseLeave:()=>k(Le=>Le===Ce?null:Le),style:{borderRadius:8},children:[n&&s.jsxs(s.Fragment,{children:[s.jsx(P0,{ctx:{kind:"tabs",li:re,tabKey:ve.key,tabIdx:ye,sectionIdx:ke,rowIdx:Oe},visible:!!xe&&!b}),s.jsx(Z0,{kind:"row-in-tab-section",li:re,tabKey:ve.key,sIdx:ke,rIdx:Oe,visible:!!xe&&!b})]}),Fe.title&&s.jsx("h2",{className:"mb-2 text-lg text-[var(--color-ds-text-primary)]",children:m(Fe.title)}),s.jsx("div",{className:"flex flex-wrap -mx-2 items-stretch",children:Fe.columns.map((Le,Me)=>{const Te=`tabs|li:${re}|t:${ye}|s:${ke}|r:${Oe}|c:${Me}`,Ie=A[Te]??[];return s.jsx("div",{className:`${Le.width??"flex-1"} px-2 flex flex-col`,children:s.jsx(Z,{keyId:Te,ids:Ie,tabKey:ve.key})},`col-${re}-${ye}-${ke}-${Oe}-${Me}`)})})]}),s.jsx(Ga,{scope:"tab-row-slot",li:re,tabKey:ve.key,sIdx:ke,insertAt:Oe+1})]},`rowwrap-${Ce}`)})]})})},`sec-${re}-${ye}-${ke}`))},`tabpanel-${re}-${ye}`)]))},`tabs-${re}`)},G=oe(K=>K.setSelection);return s.jsxs(ei,{...r.methods,children:[s.jsxs(h1,{sensors:Y,collisionDetection:S,onDragEnd:D,children:[s.jsxs("div",{id:"form-renderer-root",className:"relative overflow-visible",onDoubleClick:K=>{G({kind:"none"})},children:[s.jsx("div",{className:"space-y-6 ",children:e.layout.map((K,re)=>K.type==="rows"?s.jsx(E.Fragment,{children:q(K,re)},`rows-${re}`):s.jsx(E.Fragment,{children:X(K,re)},`tabs-${re}`))}),s.jsx(OT,{schema:e,anchors:x,enabled:g})]}),s.jsx(g1,{dropAnimation:null,children:me?s.jsx("div",{style:{pointerEvents:"none",opacity:.9},children:me}):null})]}),s.jsx(Et,{isOpen:Q.isOpen,onClose:W,title:Q.title,footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(fe,{variant:"outline",onClick:W,children:"Cancelar"}),s.jsx(fe,{variant:"danger",onClick:ae,children:"Eliminar"})]}),children:s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:Q.message})})]})}function qT(e,t,r,n){var w;const{fields:o=[],layout:l,validationSchema:i}=e,c=GT(),u=((w=c==null?void 0:c.services)==null?void 0:w.registry)??void 0,d=E.useMemo(()=>{if(t)return t;try{const j=i??ui(e);return ii(j)}catch{return}},[t,e,i]),m=ai({resolver:d,mode:"onBlur",reValidateMode:"onChange",defaultValues:e.defaultValues??{}}),f=E.useMemo(()=>(o??[]).filter(j=>j.type!=="inputGroup"&&j.type!=="button"),[o]),{optionsMap:h}=M5(f),p=C5(o),v=A5(o,m.control),[b,g]=E.useState({});E.useEffect(()=>{let j=!0;return(async()=>{const y=await Promise.all(f.filter(N=>N.type==="select"&&(N.optionSource||N.endpointConfig)).map(async N=>{const M=N.name,$=ho(N.optionSource,N.endpointConfig);if(!$)return[M,[]];const T=N.endpointConfig?Ir(N.endpointConfig.parameters,m.getValues,{ACTIVE_VARIANT:n}):{},V=u==null?void 0:u[$];if(typeof V!="function")return[M,[]];try{const I=await Promise.resolve(V("",{getValues:m.getValues,watch:m.watch,params:T})),z=Array.isArray(I)?I:[];return[M,z]}catch{return[M,[]]}}));if(!j)return;const C={};for(const[N,M]of y)C[N]=M;g(C)})(),()=>{j=!1}},[u,m.getValues,m.watch,JSON.stringify(f.map(j=>({n:j.name,os:j.optionSource??null,ec:j.endpointConfig??null}))),n]);const x=E.useCallback((j,k)=>{if(!(j!=null&&j.enabled)||!j.rule)return k;try{const y={...m.getValues(),ACTIVE_VARIANT:n};return!!vo(j.rule,y)}catch{return k}},[m,n]);return{methods:m,control:m.control,formState:m.formState,fields:o,fieldsByName:p,asyncOptionsMap:h,adapterOptionsMap:b,disabledMap:v,evalContainer:x,registry:u,layout:l}}function GT(){try{return St()??void 0}catch{return}}function KT(e,t,r){const n={...e};return t.top+e.y<=r.top?n.y=r.top-t.top:t.bottom+e.y>=r.top+r.height&&(n.y=r.top+r.height-t.bottom),t.left+e.x<=r.left?n.x=r.left-t.left:t.right+e.x>=r.left+r.width&&(n.x=r.left+r.width-t.right),n}const JT=e=>{let{transform:t,draggingNodeRect:r,windowRect:n}=e;return!r||!n?t:KT(t,r,n)};function tn(e){const r={text:()=>({label:"ds.fields.defaults.text.label",type:"text",width:"w-full",placeholder:"ds.fields.defaults.text.placeholder",size:"sm"}),number:()=>({label:"ds.fields.defaults.number.label",type:"number",width:"w-full",placeholder:"ds.fields.defaults.number.placeholder",size:"sm",validation:{required:!1}}),email:()=>({label:"ds.fields.defaults.email.label",type:"email",width:"w-full",placeholder:"ds.fields.defaults.email.placeholder",size:"sm"}),password:()=>({label:"ds.fields.defaults.password.label",type:"password",width:"w-full",placeholder:"ds.fields.defaults.password.placeholder",size:"sm",validation:{minLength:8}}),tel:()=>({label:"ds.fields.defaults.tel.label",type:"tel",width:"w-full",placeholder:"ds.fields.defaults.tel.placeholder",size:"sm"}),url:()=>({label:"ds.fields.defaults.url.label",type:"url",width:"w-full",placeholder:"ds.fields.defaults.url.placeholder",size:"sm"}),select:()=>({label:"ds.fields.defaults.select.label",type:"select",width:"w-full",size:"sm",options:[{label:"Opción A",value:"A"},{label:"Opción B",value:"B"}]}),checkbox:()=>({label:"ds.fields.defaults.checkbox.label",type:"checkbox",width:"w-full",size:"sm",defaultValue:!1}),textarea:()=>({label:"ds.fields.defaults.textarea.label",type:"textarea",width:"w-full",size:"sm",maxLength:300,showCounter:!0,placeholder:"ds.fields.defaults.textarea.placeholder"}),date:()=>({label:"ds.fields.defaults.date.label",type:"date",width:"w-full",size:"sm",showTime:!1}),file:()=>({label:"ds.fields.defaults.file.label",type:"file",width:"w-full",maxFiles:1,accept:".pdf,.doc,.docx"}),inputGroup:()=>({label:"Grupo",type:"inputGroup",width:"w-full",fields:[]}),search:()=>({label:"ds.fields.defaults.search.label",type:"search",width:"w-full",placeholder:"ds.fields.defaults.search.placeholder",size:"sm",searchMode:"button"}),optionGroup:()=>({label:"Selecciona opciones",type:"optionGroup",width:"w-full",size:"sm",multiple:!0,vertical:!0,options:[{label:"Opción 1",value:"opt1"},{label:"Opción 2",value:"opt2"},{label:"Opción 3",value:"opt3"}]}),array:()=>({label:"Lista repetible",type:"array",width:"w-full",items:[]})}[e];return r?r():{type:e}}function YT(e){if(!e)return null;const t=e.data;if(t.kind==="palette-field"){const r=t.factoryKind,n=g$[r];if(n)return s.jsx("div",{className:"pointer-events-none opacity-95",children:s.jsx("div",{className:`\r
295
+ `,title:k.disabled?"Click para habilitar":"Click para deshabilitar",children:[k.disabled?s.jsx(ga,{className:"w-3 h-3"}):s.jsx(wd,{className:"w-3 h-3"}),s.jsx("span",{className:k.disabled?"inline":"hidden sm:inline",children:k.disabled?"Deshabilitada":"Habilitada"})]}),s.jsx("div",{className:"h-4 w-px bg-[var(--color-ds-border-default-50)]"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(fe,{icon:Sn,size:"sm",variant:"primary",shape:"circle",onClick:()=>b==null?void 0:b(k.key,"Nueva sección"),title:"Añadir nueva sección",className:"shadow-sm"}),s.jsx(sa,{align:"right",trigger:s.jsx("div",{className:"p-1.5 rounded-md hover:bg-[var(--color-ds-background-surface-soft)] text-[var(--color-ds-text-secondary)] transition-colors cursor-pointer",children:s.jsx(gd,{className:"w-5 h-5"})}),items:[{label:"Añadir Pestaña",icon:Ul,onSelect:()=>p==null?void 0:p(k.key)},{separator:!0},{label:"Eliminar Pestaña",icon:bt,variant:"danger",disabled:t.tabs.length<=1,onSelect:()=>o("Eliminar pestaña","¿Estás seguro de que quieres eliminar esta pestaña? Se perderá todo su contenido.",()=>v==null?void 0:v(k.key))}]})]})]})]}),Array.from({length:k.sections.length+1}).map((y,C)=>{const N=C,M=k.sections[N],$=(n==null?void 0:n.nodeIdx)===r&&(n==null?void 0:n.tabKey)===k.key&&C===n.sIdx+1;return s.jsxs(E.Fragment,{children:[s.jsx("div",{className:"px-2",children:!$&&s.jsx(X_,{nodeIdx:r,tabKey:k.key,insertAt:C})}),N<k.sections.length&&s.jsx(du,{section:M,nodeIdx:r,sIdx:N,parentType:"tabs",tabKey:k.key,confirmDelete:o})]},`tsec-${k.key}-${C}`)})]}),j),{})})})]})]})})});function oT(){const e=oe(f=>f.schema.layout),t=oe(f=>f.editorSettings),[r,n]=E.useState(null),[o,l]=E.useState(null),[i,c]=E.useState({isOpen:!1,title:"",message:null,onConfirm:()=>{}});Ea({onDragStart:f=>{const{active:h}=f,p=h.data.current;p&&p.kind==="rows-section"&&n(p.sIdx),p&&p.kind==="tab-section"&&l({nodeIdx:p.nodeIdx,tabKey:p.tabKey,sIdx:p.sIdx})},onDragEnd:()=>{n(null),l(null)},onDragCancel:()=>{n(null),l(null)}});const u=E.useCallback((f,h,p)=>{if(!t.confirmDelete){p();return}c({isOpen:!0,title:f,message:h,onConfirm:p})},[t.confirmDelete]),d=()=>{i.onConfirm(),c(f=>({...f,isOpen:!1}))},m=()=>{c(f=>({...f,isOpen:!1}))};return s.jsxs("div",{id:"designer-canvas-root",className:"space-y-3 relative",children:[e.map((f,h)=>{if(f.type==="rows"){const p=f.sections;return s.jsx("div",{className:"space-y-3",children:Array.from({length:p.length+1}).map((v,b)=>{const g=b,x=p[g];return s.jsxs(E.Fragment,{children:[!(r!==null&&b===r+1)&&s.jsx(D_,{nodeIdx:h,insertAt:b}),g<p.length&&s.jsx(du,{section:x,nodeIdx:h,sIdx:g,parentType:"rows",confirmDelete:u})]},`rows-slot-sec-${h}-${b}`)})},`rows-${h}`)}return f.type==="tabs"?s.jsx(aT,{node:f,nodeIdx:h,draggedTabSection:o,confirmDelete:u},`tabs-${h}`):null}),s.jsx(Et,{isOpen:i.isOpen,onClose:m,title:i.title,footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(fe,{variant:"outline",onClick:m,children:"Cancelar"}),s.jsx(fe,{variant:"danger",onClick:d,children:"Eliminar"})]}),children:s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:i.message})})]})}function uu(e,t,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(t,1)[0]),n}function sT(e,t){return e.reduce((r,n,o)=>{const l=t.get(n);return l&&(r[o]=l),r},Array(e.length))}function Ua(e){return e!==null&&e>=0}function lT(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function iT(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const fu=e=>{let{rects:t,activeIndex:r,overIndex:n,index:o}=e;const l=uu(t,n,r),i=t[o],c=l[o];return!c||!i?null:{x:c.left-i.left,y:c.top-i.top,scaleX:c.width/i.width,scaleY:c.height/i.height}},qa={scaleX:1,scaleY:1},cT=e=>{var t;let{activeIndex:r,activeNodeRect:n,index:o,rects:l,overIndex:i}=e;const c=(t=l[r])!=null?t:n;if(!c)return null;if(o===r){const d=l[i];return d?{x:0,y:r<i?d.top+d.height-(c.top+c.height):d.top-c.top,...qa}:null}const u=dT(l,o,r);return o>r&&o<=i?{x:0,y:-c.height-u,...qa}:o<r&&o>=i?{x:0,y:c.height+u,...qa}:{x:0,y:0,...qa}};function dT(e,t,r){const n=e[t],o=e[t-1],l=e[t+1];return n?r<t?o?n.top-(o.top+o.height):l?l.top-(n.top+n.height):0:l?l.top-(n.top+n.height):o?n.top-(o.top+o.height):0:0}const mu="Sortable",hu=E.createContext({activeIndex:-1,containerId:mu,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:fu,disabled:{draggable:!1,droppable:!1}});function uT(e){let{children:t,id:r,items:n,strategy:o=fu,disabled:l=!1}=e;const{active:i,dragOverlay:c,droppableRects:u,over:d,measureDroppableContainers:m}=p1(),f=ka(mu,r),h=c.rect!==null,p=E.useMemo(()=>n.map(C=>typeof C=="object"&&"id"in C?C.id:C),[n]),v=i!=null,b=i?p.indexOf(i.id):-1,g=d?p.indexOf(d.id):-1,x=E.useRef(p),w=!lT(p,x.current),j=g!==-1&&b===-1||w,k=iT(l);qt(()=>{w&&v&&m(p)},[w,p,v,m]),E.useEffect(()=>{x.current=p},[p]);const y=E.useMemo(()=>({activeIndex:b,containerId:f,disabled:k,disableTransforms:j,items:p,overIndex:g,useDragOverlay:h,sortedRects:sT(p,u),strategy:o}),[b,f,k.draggable,k.droppable,j,p,g,u,h,o]);return E.createElement(hu.Provider,{value:y},t)}const fT=e=>{let{id:t,items:r,activeIndex:n,overIndex:o}=e;return uu(r,n,o).indexOf(t)},mT=e=>{let{containerId:t,isSorting:r,wasDragging:n,index:o,items:l,newIndex:i,previousItems:c,previousContainerId:u,transition:d}=e;return!d||!n||c!==l&&o===i?!1:r?!0:i!==o&&t===u},hT={duration:200,easing:"ease"},pu="transform",pT=Mr.Transition.toString({property:pu,duration:0,easing:"linear"}),gT={roleDescription:"sortable"};function vT(e){let{disabled:t,index:r,node:n,rect:o}=e;const[l,i]=E.useState(null),c=E.useRef(r);return qt(()=>{if(!t&&r!==c.current&&n.current){const u=o.current;if(u){const d=Ln(n.current,{ignoreTransform:!0}),m={x:u.left-d.left,y:u.top-d.top,scaleX:u.width/d.width,scaleY:u.height/d.height};(m.x||m.y)&&i(m)}}r!==c.current&&(c.current=r)},[t,r,n,o]),E.useEffect(()=>{l&&i(null)},[l]),l}function bT(e){let{animateLayoutChanges:t=mT,attributes:r,disabled:n,data:o,getNewIndex:l=fT,id:i,strategy:c,resizeObserverConfig:u,transition:d=hT}=e;const{items:m,containerId:f,activeIndex:h,disabled:p,disableTransforms:v,sortedRects:b,overIndex:g,useDragOverlay:x,strategy:w}=E.useContext(hu),j=xT(n,p),k=m.indexOf(i),y=E.useMemo(()=>({sortable:{containerId:f,index:k,items:m},...o}),[f,o,k,m]),C=E.useMemo(()=>m.slice(m.indexOf(i)),[m,i]),{rect:N,node:M,isOver:$,setNodeRef:T}=tr({id:i,data:y,disabled:j.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...u}}),{active:V,activatorEvent:I,activeNodeRect:z,attributes:O,setNodeRef:P,listeners:Q,isDragging:te,over:ne,setActivatorNodeRef:ae,transform:W}=Gr({id:i,data:y,attributes:{...gT,...r},disabled:j.draggable}),A=RO(T,P),F=!!V,Y=F&&!v&&Ua(h)&&Ua(g),U=!x&&te,ee=U&&Y?W:null,ue=Y?ee??(c??w)({rects:b,activeNodeRect:z,activeIndex:h,overIndex:g,index:k}):null,ge=Ua(h)&&Ua(g)?l({id:i,items:m,activeIndex:h,overIndex:g}):k,ce=V==null?void 0:V.id,se=E.useRef({activeId:ce,items:m,newIndex:ge,containerId:f}),we=m!==se.current.items,de=t({active:V,containerId:f,isDragging:te,isSorting:F,id:i,index:k,items:m,newIndex:se.current.newIndex,previousItems:se.current.items,previousContainerId:se.current.containerId,transition:d,wasDragging:se.current.activeId!=null}),me=vT({disabled:!de,index:k,node:M,rect:N});return E.useEffect(()=>{F&&se.current.newIndex!==ge&&(se.current.newIndex=ge),f!==se.current.containerId&&(se.current.containerId=f),m!==se.current.items&&(se.current.items=m)},[F,ge,f,m]),E.useEffect(()=>{if(ce===se.current.activeId)return;if(ce!=null&&se.current.activeId==null){se.current.activeId=ce;return}const J=setTimeout(()=>{se.current.activeId=ce},50);return()=>clearTimeout(J)},[ce]),{active:V,activeIndex:h,attributes:O,data:y,rect:N,index:k,newIndex:ge,items:m,isOver:$,isSorting:F,isDragging:te,listeners:Q,node:M,overIndex:g,over:ne,setNodeRef:A,setActivatorNodeRef:ae,setDroppableNodeRef:T,setDraggableNodeRef:P,transform:me??ue,transition:R()};function R(){if(me||we&&se.current.newIndex===k)return pT;if(!(U&&!Xo(I)||!d)&&(F||de))return Mr.Transition.toString({...d,property:pu})}}function xT(e,t){var r,n;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e==null?void 0:e.draggable)!=null?r:t.draggable,droppable:(n=e==null?void 0:e.droppable)!=null?n:t.droppable}}function Io(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const wT=[Ze.Down,Ze.Right,Ze.Up,Ze.Left],yT=(e,t)=>{let{context:{active:r,collisionRect:n,droppableRects:o,droppableContainers:l,over:i,scrollableAncestors:c}}=t;if(wT.includes(e.code)){if(e.preventDefault(),!r||!n)return;const u=[];l.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const h=o.get(f.id);if(h)switch(e.code){case Ze.Down:n.top<h.top&&u.push(f);break;case Ze.Up:n.top>h.top&&u.push(f);break;case Ze.Left:n.left>h.left&&u.push(f);break;case Ze.Right:n.left<h.left&&u.push(f);break}});const d=VO({collisionRect:n,droppableRects:o,droppableContainers:u});let m=J5(d,"id");if(m===(i==null?void 0:i.id)&&d.length>1&&(m=d[1].id),m!=null){const f=l.get(r.id),h=l.get(m),p=h?o.get(h.id):null,v=h==null?void 0:h.node.current;if(v&&p&&f&&h){const g=Qo(v).some((C,N)=>c[N]!==C),x=gu(f,h),w=jT(f,h),j=g||!x?{x:0,y:0}:{x:w?n.width-p.width:0,y:w?n.height-p.height:0},k={x:p.left,y:p.top};return j.x&&j.y?k:fa(k,j)}}}};function gu(e,t){return!Io(e)||!Io(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function jT(e,t){return!Io(e)||!Io(t)||!gu(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}const vu=(e,t,r)=>Math.max(t,Math.min(r,e));function I0(e){const t=[`li:${e.li}`];return e.tabIdx!=null&&t.push(`t:${e.tabIdx}`),t.push(`s:${e.sectionIdx}`,`r:${e.rowIdx}`,`c:${e.colIdx}`,`f:${e.fieldIdx}`),t.join("|")}function Gn(e){const t=Object.fromEntries(e.split("|").map(r=>r.split(":")));return{li:Number(t.li),tabIdx:t.t!=null?Number(t.t):void 0,sectionIdx:Number(t.s),rowIdx:Number(t.r),colIdx:Number(t.c),fieldIdx:Number(t.f)}}function F0(e,t){var n,o,l,i,c,u,d;const r=e[t.li];if(!r)return null;if(r.type==="rows"){const m=(n=r.sections)==null?void 0:n[t.sectionIdx],f=(o=m==null?void 0:m.rows)==null?void 0:o[t.rowIdx];return((l=f==null?void 0:f.columns)==null?void 0:l[t.colIdx])??null}if(r.type==="tabs"){const m=(i=r.tabs)==null?void 0:i[t.tabIdx??0],f=(c=m==null?void 0:m.sections)==null?void 0:c[t.sectionIdx],h=(u=f==null?void 0:f.rows)==null?void 0:u[t.rowIdx];return((d=h==null?void 0:h.columns)==null?void 0:d[t.colIdx])??null}return null}function kT(e,t,r){if(t.li===r.li&&(t.tabIdx??-1)===(r.tabIdx??-1)&&t.sectionIdx===r.sectionIdx&&t.rowIdx===r.rowIdx&&t.colIdx===r.colIdx&&t.fieldIdx===r.fieldIdx)return e;const n=JSON.parse(JSON.stringify(e.layout)),o=F0(n,{li:t.li,tabIdx:t.tabIdx,sectionIdx:t.sectionIdx,rowIdx:t.rowIdx,colIdx:t.colIdx}),l=F0(n,{li:r.li,tabIdx:r.tabIdx,sectionIdx:r.sectionIdx,rowIdx:r.rowIdx,colIdx:r.colIdx});if(!o||!Array.isArray(o.fields)||!l||!Array.isArray(l.fields))return e;const i=[...o.fields];if(t.fieldIdx<0||t.fieldIdx>=i.length)return e;const[c]=i.splice(t.fieldIdx,1);o.fields=i;const u=[...l.fields],d=vu(r.fieldIdx??u.length,0,u.length);return u.splice(d,0,c),l.fields=u,{...e,layout:n}}function ET(e,t){const r=JSON.parse(JSON.stringify(e.layout)),o=(u=>{var m,f,h,p,v,b,g,x,w,j,k,y;const d=r[u.li];return d?d.type==="rows"?((v=(p=(h=(f=(m=d.sections)==null?void 0:m[u.sectionIdx])==null?void 0:f.rows)==null?void 0:h[u.rowIdx])==null?void 0:p.columns)==null?void 0:v[u.colIdx])??null:d.type==="tabs"?((y=(k=(j=(w=(x=(g=(b=d.tabs)==null?void 0:b[u.tabIdx??0])==null?void 0:g.sections)==null?void 0:x[u.sectionIdx])==null?void 0:w.rows)==null?void 0:j[u.rowIdx])==null?void 0:k.columns)==null?void 0:y[u.colIdx])??null:null:null})({li:t.li,tabIdx:t.tabIdx,sectionIdx:t.sectionIdx,rowIdx:t.rowIdx,colIdx:t.colIdx});if(!o||!Array.isArray(o.fields))return e;const l=[...o.fields];if(t.fieldIdx<0||t.fieldIdx>=l.length)return e;const[i]=l.splice(t.fieldIdx,1);o.fields=l;const c=[...e.fields||[]];if(i){let u=0;const d=m=>{Array.isArray(m)&&m.includes(i)&&u++};if(r.forEach(m=>{var f,h;m.type==="rows"?(f=m.sections)==null||f.forEach(p=>{var v;return(v=p.rows)==null?void 0:v.forEach(b=>{var g;return(g=b.columns)==null?void 0:g.forEach(x=>d(x.fields))})}):m.type==="tabs"&&((h=m.tabs)==null||h.forEach(p=>{var v;return(v=p.sections)==null?void 0:v.forEach(b=>{var g;return(g=b.rows)==null?void 0:g.forEach(x=>{var w;return(w=x.columns)==null?void 0:w.forEach(j=>d(j.fields))})})}))}),u===0){const m=c.findIndex(f=>f.name===i);m!==-1&&c.splice(m,1)}}return{...e,layout:r,fields:c}}function RT(e,t){const r=new Set(e.map(l=>l.name));let n=1,o=`${t}_${n}`;for(;r.has(o);)n++,o=`${t}_${n}`;return o}function CT(e,t,r){const n=RT(e.fields||[],t.type||"field"),o={...t,name:n},l=[...e.fields||[],o],i=JSON.parse(JSON.stringify(e.layout)),u=(m=>{var h,p,v,b,g,x,w,j,k,y,C,N;const f=i[m.li];return f?f.type==="rows"?((g=(b=(v=(p=(h=f.sections)==null?void 0:h[m.sectionIdx])==null?void 0:p.rows)==null?void 0:v[m.rowIdx])==null?void 0:b.columns)==null?void 0:g[m.colIdx])??null:f.type==="tabs"?((N=(C=(y=(k=(j=(w=(x=f.tabs)==null?void 0:x[m.tabIdx??0])==null?void 0:w.sections)==null?void 0:j[m.sectionIdx])==null?void 0:k.rows)==null?void 0:y[m.rowIdx])==null?void 0:C.columns)==null?void 0:N[m.colIdx])??null:null:null})({li:r.li,tabIdx:r.tabIdx,sectionIdx:r.sectionIdx,rowIdx:r.rowIdx,colIdx:r.colIdx});if(!u)return{...e,fields:l};Array.isArray(u.fields)||(u.fields=[]);const d=vu(r.fieldIdx??u.fields.length,0,u.fields.length);return u.fields.splice(d,0,n),{...e,fields:l,layout:i}}const bu=E.createContext(null),xu=()=>{const e=E.useContext(bu);if(!e)throw new Error("useRelations must be used inside <RelationsProvider>");return e},ST=e=>{const{registerFieldEl:t}=xu();return E.useCallback(r=>{e&&t(e,r)},[e,t])},NT=({children:e})=>{const[t,r]=E.useState(!1),[n,o]=E.useState(null),[l,i]=E.useState({}),c=E.useRef({}),u=p=>r(v=>typeof p=="boolean"?p:!v),d=E.useCallback((p,v)=>{c.current[p]=v},[]);E.useEffect(()=>{let p=!0,v;const g=(async()=>{try{const{useEditorStore:x}=await Promise.resolve().then(()=>EO),j=x.getState().showRelations??!1;return v=j,p&&r(j),x.subscribe(y=>{const C=y.showRelations??!1;p&&C!==v&&(v=C,r(C))})}catch(x){return console.error("Failed to sync with store:",x),()=>{}}})();return()=>{p=!1,g.then(x=>x())}},[]);const m=E.useRef(null),f=E.useRef({});E.useEffect(()=>{if(!t)return;const p=()=>{const w=m.current;if(!w)return;const j=w.getBoundingClientRect(),k={};for(const[M,$]of Object.entries(c.current)){if(!$)continue;const T=$.getBoundingClientRect();k[M]={x:Math.round(T.left-j.left+T.width/2),y:Math.round(T.top-j.top+T.height/2),w:Math.round(T.width),h:Math.round(T.height)}}const y=f.current;let C=!1;const N=new Set([...Object.keys(k),...Object.keys(y)]);for(const M of N){const $=k[M],T=y[M];if(!$||!T||$.x!==T.x||$.y!==T.y||$.w!==T.w||$.h!==T.h){C=!0;break}}C&&(f.current=k,i(k))},v=()=>requestAnimationFrame(p),b=new ResizeObserver(v);m.current&&b.observe(m.current);const g=new MutationObserver(v);m.current&&g.observe(m.current,{childList:!0,subtree:!0}),window.addEventListener("resize",v,{passive:!0}),document.addEventListener("scroll",v,{passive:!0,capture:!0});const x=new ResizeObserver(v);return Object.values(c.current).forEach(w=>w&&x.observe(w)),v(),()=>{b.disconnect(),g.disconnect(),x.disconnect(),window.removeEventListener("resize",v),document.removeEventListener("scroll",v,{capture:!0})}},[t]);const h=E.useMemo(()=>({enabled:t,toggle:u,registerFieldEl:d,anchors:l,schema:n,setSchema:o}),[t,d,l,n]);return s.jsx(bu.Provider,{value:h,children:s.jsx("div",{ref:m,className:"relative",children:e})})};function ao(e){return e?e.op==="and"||e.op==="or"?(e.rules??[]).flatMap(ao):e.op==="always"?[]:[e.field]:[]}function Js(e){return e!=null&&e.parameters?Object.values(e.parameters).filter(t=>t.type==="field"&&t.fieldRef).map(t=>t.fieldRef):[]}function MT(e){var o,l,i,c,u,d;const t=[];for(const m of e.fields){const f=m.name;if(!f)continue;const h=(o=m.visibleWhen)==null?void 0:o.rule,p=(l=m.disabledWhen)==null?void 0:l.rule,v=(i=m.clearWhen)==null?void 0:i.rule;for(const w of ao(h))t.push({from:w,to:f,kind:"visibleWhen"});for(const w of ao(p))t.push({from:w,to:f,kind:"disabledWhen"});for(const w of ao(v))t.push({from:w,to:f,kind:"clearWhen"});const b=(c=m.visibleWhen)==null?void 0:c.endpoint,g=(u=m.disabledWhen)==null?void 0:u.endpoint,x=(d=m.clearWhen)==null?void 0:d.endpoint;for(const w of Js(b))t.push({from:w,to:f,kind:"visibleWhen"});for(const w of Js(g))t.push({from:w,to:f,kind:"disabledWhen"});for(const w of Js(x))t.push({from:w,to:f,kind:"clearWhen"})}const r=m=>`${m.from}->${m.to}:${m.kind}`,n=new Set;return t.filter(m=>n.has(r(m))?!1:(n.add(r(m)),!0))}const Ys={visibleWhen:"var(--color-success-500, #22c55e)",disabledWhen:"var(--color-warning-500, #f59e0b)",clearWhen:"var(--color-info-500, #0ea5e9)"};function _0(e){return{left:e.x-e.w/2,right:e.x+e.w/2,top:e.y-e.h/2,bottom:e.y+e.h/2,cx:e.x,cy:e.y,w:e.w,h:e.h}}function T0(e,t,r=20,n=0){const o=_0(e),l=_0(t),i=1,c=1,u=l.cx-o.cx,d=l.cy-o.cy,f=Math.min(o.bottom,l.bottom)-Math.max(o.top,l.top)>0||Math.abs(u)>Math.abs(d);let h,p,v=[];if(f)if(u>0?(h={x:o.right+i,y:o.cy},p={x:l.left-c,y:l.cy}):(h={x:o.left-i,y:o.cy},p={x:l.right+c,y:l.cy}),Math.abs(h.y-p.y)<5)v=[h,p];else{const x=(h.x+p.x)/2;if(u>0&&h.x>p.x||u<0&&h.x<p.x){const w=Math.max(o.bottom,l.bottom)+r;v=[h,{x:h.x+(u>0?10:-10),y:h.y},{x:h.x+(u>0?10:-10),y:w},{x:p.x-(u>0?10:-10),y:w},{x:p.x-(u>0?10:-10),y:p.y},p]}else v=[h,{x,y:h.y},{x,y:p.y},p]}else if(d>0?(h={x:o.cx,y:o.bottom+i},p={x:l.cx,y:l.top-c}):(h={x:o.right+i,y:o.cy},p={x:l.right+c,y:l.cy}),d>0&&Math.abs(h.x-p.x)<5)v=[h,p];else if(d>0){const x=(h.y+p.y)/2;v=[h,{x:h.x,y:x},{x:p.x,y:x},p]}else{const x=Math.max(o.right,l.right)+r;v=[h,{x,y:h.y},{x,y:p.y},p]}n!==0&&(v=v.map(x=>f?{x:x.x,y:x.y+n}:{x:x.x+n,y:x.y}));let b=`M ${v[0].x},${v[0].y}`;for(let x=1;x<v.length;x++)b+=` L ${v[x].x},${v[x].y}`;let g={x:0,y:0};if(v.length===2)g={x:(v[0].x+v[1].x)/2,y:(v[0].y+v[1].y)/2};else{const x=Math.floor((v.length-1)/2),w=v[x],j=v[x+1];g={x:(w.x+j.x)/2,y:(w.y+j.y)/2}}return{d:b,label:g}}const AT=({enabled:e=!0,anchors:t,schema:r})=>{const n=E.useMemo(()=>r?MT(r):[],[r]),[o,l]=E.useState(null),i=oe(m=>m.setSelection),c=oe(m=>m.selection),u=(c==null?void 0:c.kind)==="field"?c.name:null,d=E.useMemo(()=>{const m=new Map;return n.forEach(f=>{const h=`${f.from}->${f.to}`;m.has(h)||m.set(h,[]),m.get(h).push(f)}),Array.from(m.entries())},[n]);return!e||!r||n.length===0?null:s.jsxs("svg",{className:"pointer-events-none absolute inset-0 z-50",width:"100%",height:"100%",children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"arrow-head-visibleWhen",viewBox:"0 0 10 10",refX:8,refY:5,markerWidth:4,markerHeight:4,orient:"auto",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--color-success-500, #22c55e)"})}),s.jsx("marker",{id:"arrow-head-disabledWhen",viewBox:"0 0 10 10",refX:8,refY:5,markerWidth:4,markerHeight:4,orient:"auto",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--color-warning-500, #f59e0b)"})}),s.jsx("marker",{id:"arrow-head-clearWhen",viewBox:"0 0 10 10",refX:8,refY:5,markerWidth:4,markerHeight:4,orient:"auto",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--color-info-500, #0ea5e9)"})}),s.jsx("marker",{id:"circle-start-visibleWhen",viewBox:"0 0 10 10",refX:5,refY:5,markerWidth:3,markerHeight:3,children:s.jsx("circle",{cx:5,cy:5,r:3,fill:"var(--color-success-500, #22c55e)"})}),s.jsx("marker",{id:"circle-start-disabledWhen",viewBox:"0 0 10 10",refX:5,refY:5,markerWidth:3,markerHeight:3,children:s.jsx("circle",{cx:5,cy:5,r:3,fill:"var(--color-warning-500, #f59e0b)"})}),s.jsx("marker",{id:"circle-start-clearWhen",viewBox:"0 0 10 10",refX:5,refY:5,markerWidth:3,markerHeight:3,children:s.jsx("circle",{cx:5,cy:5,r:3,fill:"var(--color-info-500, #0ea5e9)"})})]}),d.map(([m,f])=>{const h=f[0],p=t[h.from],v=t[h.to];if(!p||!v)return null;const b=`${m}`,g=o===b,x=!!u&&f.some(z=>z.from===u||z.to===u),w=f[0].kind,j=Ys[w];let k=1;g?k=1:o?k=x?.4:.15:u&&(k=x?1:.2);const y=T0(p,v),{label:C}=y,N=f.length>1?f.map(z=>{const O=z.kind.replace("When","");return O.charAt(0).toUpperCase()+O.slice(1)}).join(" + "):h.kind,M=Math.max(80,N.length*6+20),$=()=>{i({kind:"field",name:h.to})},T=f.length,V=3,I=f.map((z,O)=>(O-(T-1)/2)*V);return s.jsxs("g",{style:{opacity:k,transition:"opacity 0.2s"},onMouseEnter:()=>l(b),onMouseLeave:()=>l(null),onClick:$,className:"pointer-events-auto cursor-pointer",children:[f.map((z,O)=>{const P=Ys[z.kind],{d:Q}=T0(p,v,20,I[O]),te=!!u&&(z.from===u||z.to===u),ne=g||te?1.75:1,ae=`url(#arrow-head-${z.kind})`,W=`url(#circle-start-${z.kind})`;return s.jsxs("g",{children:[s.jsx("path",{d:Q,stroke:"transparent",strokeWidth:18,fill:"none"}),s.jsx("path",{d:Q,stroke:P,strokeWidth:ne,fill:"none",markerEnd:ae,markerStart:W,strokeLinejoin:"round",strokeDasharray:z.kind==="disabledWhen"?"5 5":void 0})]},`${b}-${z.kind}-${O}`)}),s.jsxs("g",{transform:`translate(${C.x}, ${C.y})`,children:[s.jsx("rect",{x:-M/2,y:-10,width:M,height:20,rx:4,ry:4,fill:"var(--color-ds-background-page, #f8fafc)",stroke:j,strokeWidth:1,className:"shadow-sm"}),s.jsx("text",{x:0,y:4,textAnchor:"middle",fontSize:10,fontWeight:600,fill:"var(--color-ds-text-primary, #0f172a)",style:{pointerEvents:"none"},children:N}),f.length>1&&s.jsx("g",{transform:"translate(0, 15)",children:f.map((z,O)=>{const P=Ys[z.kind],Q=(O-(f.length-1)/2)*20;return s.jsx("circle",{cx:Q,cy:0,r:3,fill:P,stroke:"white",strokeWidth:1},O)})})]})]},b)})]})};function B0(e,t){if(!e||!t)return;const r=t==="outline"?bn:xn;let n=r==null?void 0:r[e];return!n&&(r!=null&&r.default)&&(n=r.default[e]),n||console.warn(`[IconResolver] Icon "${e}" (${t}) no encontrado en @heroicons/react/24/${t}. Revisa tu versión o el nombre. Exports disponibles (outline):`,Object.keys(t==="outline"?bn:xn)),console.log(n),n||void 0}function sr(e){if(!(!e||typeof e!="object"))return console.log(B0(e.name,e.style)),B0(e.name,e.style)}function OT(e){const{fields:t,fieldsByName:r,control:n,errors:o,isSubmitting:l,loadingDefaults:i,asyncOptionsMap:c,adapterOptionsMap:u,evalContainer:d,disabledMap:m,registry:f,methods:h,translateFn:p,onUpdateField:v,isDesignMode:b}=e,g=()=>oe.getState().fieldPick,x=j=>oe.getState().completeFieldPick(j),w=(j,k)=>{if(!k)return j;const y=g(),C=y.armed,N=C&&y.forField===k,M=C&&!N,$=I=>{C&&(I.preventDefault(),I.stopPropagation(),!N&&x(k))},T=I=>{C&&M&&(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),I.stopPropagation(),x(k))},V=C?N?"opacity-40 cursor-not-allowed":"cursor-pointer transition-all rounded border border-[color-mix(in_srgb,var(--color-ds-border-default)_40%,transparent)] hover:border-[color-mix(in_srgb,var(--color-ds-border-default)_70%,transparent)] hover:bg-[color-mix(in_srgb,var(--color-ds-background-accent)_5%,transparent)]":"";return s.jsx("div",{onClick:$,onKeyDown:T,tabIndex:M?0:-1,className:V,role:M?"button":void 0,"aria-label":M?`Seleccionar campo ${k}`:void 0,children:j})};return function j(k){var P,Q,te,ne,ae;let y;if(typeof k=="string"){if(y=r[k],y||(y=(t??[]).find(W=>(W==null?void 0:W.name)===k)),!y)return null}else y=k;y.visibleWhen;let C=!!y.disabled;const N=y.disabledWhen,M=d(N,!1);N!=null&&N.enabled&&(C=M),!(N!=null&&N.enabled)&&"name"in y&&y.name&&m[y.name]&&(C=!0);const $=y==null?void 0:y.name;if(y.type==="search"){const W=typeof y.searchFn=="function",A=ho(y.searchSource,y.endpointConfig),F=async ee=>{if(W)return y.searchFn(ee,{getValues:h.getValues,watch:h.watch});if(A){const le=y.endpointConfig?Ir(y.endpointConfig.parameters,h.getValues):{},ue=f==null?void 0:f[A];if(typeof ue=="function")return await ue(ee,{getValues:h.getValues,watch:h.watch,params:le});if(Array.isArray(ue))return ue}return[]},Y={};y.searchMode&&(Y.searchMode=y.searchMode),y.minChars&&(Y.minChars=y.minChars),y.debounceMs&&(Y.debounceMs=y.debounceMs),y.resolveByValue&&(Y.resolveByValue=y.resolveByValue);const U=s.jsx(mi,{name:y.name,control:n,searchFn:F,label:p(y.label),size:y.size,width:y.width,disabled:C||l,...Y},y.name);return w(U,$)}if(y.type==="inputGroup"){const W=y,A=(W.inputs??[]).map(Y=>{var ce;const U=typeof Y=="string"?r[Y]??(t??[]).find(se=>(se==null?void 0:se.name)===Y):Y;if(!U)return null;const ee=U.disabledWhen;let le=!!U.disabled;const ue=d(ee,!1);ee!=null&&ee.enabled&&(le=ue),!(ee!=null&&ee.enabled)&&m[U.name]&&(le=!0);const ge={name:U.name,control:n,label:p(U.label),size:U.size,width:U.width,placeholder:p(U.placeholder),hasError:!!o[U.name],errorMessage:p((ce=o[U.name])==null?void 0:ce.message),loading:!1,disabled:le||l,suffixButton:U.suffixButton,reserveErrorSpace:!0,labelPrefixIcon:sr(U.labelPrefixIcon),labelSuffixIcon:sr(U.labelSuffixIcon),prefixIcon:sr(U.prefixIcon),suffixIcon:sr(U.suffixIcon)};return U.type==="select"?{...ge,options:U.options??u[U.name]??c[U.name]??[],loadOptions:U.options||U.optionSource||U.endpointConfig?void 0:U.loadOptions}:{...ge,type:U.type}}).filter(Boolean),F=s.jsx(fi,{groupLabel:p(W.groupLabel),inputs:A,separator:W.separator,useSeparator:W.useSeparator,className:W.className,showVisibleLabel:W.showVisibleLabel,size:W.size},`inputGroup_${W.name??W.groupLabel??"group"}`);return w(F,W.name)}if(y.type==="button"){const W=y,A=W.icon,F=A&&typeof A=="object"&&A.name&&A.style?sr(A):void 0,Y=s.jsx("div",{className:"self-center",children:s.jsx(fe,{type:"button",variant:W.variant,size:W.size,width:W.width,icon:F,iconPosition:W.iconPosition,ariaLabel:p(W.ariaLabel),onClick:W.onClick,disabled:C||l,children:p(W.label)})},W.name);return w(Y,$)}const T=y.suffixButton,V=typeof T=="string"?j(T):T,I=p(y.label),z=b&&v&&y.name?s.jsx(_i,{value:I,onChange:W=>{const A=oe.getState().schema.formId||"defaultForm",F=y.name,Y=`forms.${A}.fields.${F}.label`;Xn.updateTranslation(Y,W),v(F,{label:Y})},placeholder:"Sin etiqueta",className:"font-medium"}):I,O={name:y.name,control:n,disabled:C||l,label:z,size:y.size,width:y.width,placeholder:p(y.placeholder),info:(()=>{const W=y.info;return W&&typeof W=="object"&&(W.type==="complex"||"header"in W||"template"in W)?W.template?p(W.template):"":p(W)})(),infoHeader:(()=>{const W=y.info;if(W&&typeof W=="object"&&(W.type==="complex"||"header"in W||"template"in W))return W.header||void 0})(),suffixButton:V,labelPrefixIcon:sr(y.labelPrefixIcon),labelSuffixIcon:sr(y.labelSuffixIcon),prefixIcon:sr(y.prefixIcon),suffixIcon:sr(y.suffixIcon)};switch(y.type){case"select":{const W=y.name,A=y.options??u[W]??c[W]??[],F=!y.options&&!y.optionSource&&!y.endpointConfig&&y.loadOptions,Y=s.jsx(Ft,{name:W,control:n,render:({field:U})=>{var ee;return s.jsx(Ke,{...O,value:U.value,onChange:U.onChange,options:A,loadOptions:F||void 0,hasError:!!o[W],errorMessage:p((ee=o[W])==null?void 0:ee.message),suffixButton:V})}},`${W}`);return w(Y,$)}case"textarea":{const W=s.jsx(Ft,{name:y.name,control:n,render:({field:A,fieldState:F})=>{var Y;return s.jsx(Nr,{...O,value:A.value,onChange:A.onChange,maxLength:y.maxLength,showCounter:!!y.showCounter,hasError:!!F.error,errorMessage:p((Y=F.error)==null?void 0:Y.message)})}},y.name);return w(W,$)}case"file":{const W=s.jsx(li,{...O,defaultValue:[],maxFiles:y.maxFiles,accept:y.accept,hideDropZone:y.hideDropZone,hasError:!!o[y.name],errorMessage:p((P=o[y.name])==null?void 0:P.message)},y.name);return w(W,$)}case"checkbox":{const W=s.jsx(rt,{...O,defaultValue:!1,hasError:!!o[y.name],errorMessage:p((Q=o[y.name])==null?void 0:Q.message),name:y.name},y.name);return w(W,$)}case"date":{const W=s.jsx(wn,{...O,defaultValue:"",showTime:!!y.showTime,hasError:!!o[y.name],errorMessage:p((te=o[y.name])==null?void 0:te.message)},y.name);return w(W,$)}case"optionGroup":{const W=s.jsx(Uo,{...O,options:y.options||[],multiple:y.multiple,vertical:y.vertical,groupLabel:y.groupLabel,defaultValue:y.defaultValue,className:y.width?void 0:"w-full",name:y.name},y.name);return w(W,$)}case"toggle":{const W=s.jsx(vi,{...O,checked:y.defaultValue??!1,errorMessage:p((ne=o[y.name])==null?void 0:ne.message),name:y.name},y.name);return w(W,$)}default:{const W=s.jsx(Ho,{...O,type:y.type,loadingDefaults:i,hasError:!!o[y.name],errorMessage:p((ae=o[y.name])==null?void 0:ae.message),suffixButton:V,name:y.name},y.name);return w(W,$)}}}}function LT(e){var r;return e?!!((r=e.closest)!=null&&r.call(e,'button,[role="button"],a[href],input,select,textarea,[contenteditable="true"],[data-interactive="true"]')):!1}function $T(e){var r;return e?!!((r=e.closest)!=null&&r.call(e,'[data-input-group-root],[data-input-group],[data-role="input-group"],.input-group,.InputGroup')):!1}function Hn(e){var t;e.preventDefault(),e.stopPropagation(),(t=e.nativeEvent)!=null&&t.stopImmediatePropagation&&e.nativeEvent.stopImmediatePropagation()}function IT({id:e,children:t,onDelete:r,fieldName:n,chromeDisabled:o=!1}){const{attributes:l,listeners:i,setNodeRef:c,transform:u,transition:d,isDragging:m}=bT({id:e,disabled:o}),f=oe(g=>g.setSelection),h={transform:Mr.Transform.toString(u),transition:d},p="opacity-0 scale-95 group-hover:opacity-100 group-hover:scale-100 group-focus-within:opacity-100 group-focus-within:scale-100",v=g=>{const x=g.target;LT(x)||$T(x)||n&&(g.stopPropagation(),f({kind:"field",name:n}))},b=g=>{Hn(g)};return s.jsxs("div",{ref:c,style:h,className:["relative",o?"":"group",m?"z-30":"z-0"].filter(Boolean).join(" "),onClickCapture:v,onDoubleClick:b,onDoubleClickCapture:b,children:[!o&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:["pointer-events-none absolute -inset-0.5 rounded-lg","bg-[var(--color-ds-background-surface)]/80","border border-dashed border-[var(--color-ds-border-default-50)]","transition-all duration-150 ease-out",p,m?"opacity-100 scale-100":""].join(" ")}),s.jsxs("div",{className:["pointer-events-none absolute -top-3 right-2 flex gap-1 z-40","transition-all duration-150 ease-out",p,m?"opacity-100 scale-100":""].join(" "),children:[r&&s.jsx("button",{type:"button","aria-label":"Eliminar campo",className:["pointer-events-auto inline-flex items-center justify-center","w-7 h-7 rounded-full","bg-[var(--color-ds-background-surface)]","border border-[var(--color-ds-border-default-50)]","text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-danger)]","focus:outline-none focus:ring-2 focus:ring-[var(--color-ds-border-default-50)]","transition-colors"].join(" "),onClick:g=>{g.preventDefault(),g.stopPropagation(),r==null||r(e)},onDoubleClick:Hn,onDoubleClickCapture:Hn,children:s.jsx(bt,{className:"w-4 h-4"})}),s.jsx("button",{type:"button","aria-label":"Mover campo","data-drag-handle":!0,className:["pointer-events-auto inline-flex items-center justify-center","w-8 h-8 rounded-full cursor-grab active:cursor-grabbing touch-none","bg-[var(--color-ds-background-surface)]","border border-[var(--color-ds-border-default-50)]","text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)]","focus:outline-none focus:ring-2 focus:ring-[var(--color-ds-border-default-50)]","transition-colors"].join(" "),...l,...i,onDoubleClick:Hn,onDoubleClickCapture:Hn,children:s.jsx(rd,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"relative z-10",children:t})]})}function FT(e,t){if(!t||t.kind!=="row-in-section"&&t.kind!=="row-in-tab-section")return!1;const r=n=>e.insertAt===n||e.insertAt===n+1;if(e.scope==="row-slot"){if(t.kind==="row-in-section"&&t.li===e.li&&t.sIdx===e.sIdx&&r(t.rIdx))return!0}else if(e.scope==="tab-row-slot"&&t.kind==="row-in-tab-section"&&t.li===e.li&&t.tabKey===e.tabKey&&t.sIdx===e.sIdx&&r(t.rIdx))return!0;return!1}function Ga(e){const t=e.scope==="row-slot"?{scope:"row-slot",li:e.li,sIdx:e.sIdx,insertAt:e.insertAt}:{scope:"tab-row-slot",li:e.li,tabKey:e.tabKey,sIdx:e.sIdx,insertAt:e.insertAt},r=e.scope==="row-slot"?`row-slot|li:${e.li}|s:${e.sIdx}|i:${e.insertAt}`:`tab-row-slot|li:${e.li}|t:${e.tabKey}|s:${e.sIdx}|i:${e.insertAt}`,{setNodeRef:n,isOver:o}=tr({id:r,data:t}),[l,i]=E.useState(void 0);return Ea({onDragStart:d=>{i(d.active.data.current)},onDragEnd:()=>i(void 0),onDragCancel:()=>i(void 0)}),FT(e,l)?s.jsx("div",{ref:n,style:{display:"none"}}):s.jsx("div",{className:"w-full relative transition-all duration-200 ease-in-out",style:{height:o?60:0,pointerEvents:"none",zIndex:o?10:0},children:s.jsx("div",{ref:n,className:"absolute left-0 right-0",style:{top:o?0:-12,height:o?"100%":24,zIndex:o?10:2,pointerEvents:"auto"},children:o&&s.jsx("div",{className:"w-full h-full rounded-md border border-dashed border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background)]/60 relative",style:{boxShadow:"inset 0 0 0 1px color-mix(in srgb, var(--color-ds-border-default-50) 30%, transparent)"},children:s.jsx("div",{className:"absolute -top-2 left-3 px-1.5 py-0.5 rounded text-[11px] leading-none",style:{background:"var(--color-ds-background-elevated)",color:"var(--color-ds-text-secondary)",border:"1px solid var(--color-ds-border-default-50)"},children:"Soltar fila aquí"})})})})}function Z0(e){const t=e.kind==="row-in-section"?{kind:"row-in-section",li:e.li,sIdx:e.sIdx,rIdx:e.rIdx}:{kind:"row-in-tab-section",li:e.li,tabKey:e.tabKey,sIdx:e.sIdx,rIdx:e.rIdx},r=e.kind==="row-in-section"?`row|li:${e.li}|s:${e.sIdx}|r:${e.rIdx}`:`tab-row|li:${e.li}|t:${e.tabKey}|s:${e.sIdx}|r:${e.rIdx}`,{attributes:n,listeners:o,setNodeRef:l,isDragging:i}=Gr({id:r,data:t});return s.jsx("div",{ref:l,"aria-label":"Handle de arrastre de fila",style:{position:"absolute",left:"50%",top:-14,transform:"translateX(-50%)",zIndex:2147483647,pointerEvents:e.visible?"auto":"none",opacity:e.visible?1:0,transition:"opacity .12s ease"},...o,...n,children:s.jsx("div",{className:"flex items-center justify-center bg-[var(--color-ds-background-elevated)]/85 backdrop-blur-sm px-1 py-0.5 rounded-lg border border-[var(--color-ds-border-default-50)] shadow-sm",children:s.jsx("div",{title:"Mover fila (arrastrar)",className:"flex items-center justify-center rounded hover:bg-[var(--color-ds-background-muted)] transition-colors",style:{cursor:i?"grabbing":"grab",touchAction:"none",padding:"2px 6px"},children:s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 text-[var(--color-ds-text-secondary)]",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9h16.5m-16.5 6.75h16.5"})})})})})}function _T(e){const r={text:()=>({label:"ds.fields.defaults.text.label",type:"text",width:"w-full",placeholder:"ds.fields.defaults.text.placeholder",size:"sm"}),number:()=>({label:"ds.fields.defaults.number.label",type:"number",width:"w-full",placeholder:"ds.fields.defaults.number.placeholder",size:"sm",validation:{required:!1}}),email:()=>({label:"ds.fields.defaults.email.label",type:"email",width:"w-full",placeholder:"ds.fields.defaults.email.placeholder",size:"sm"}),password:()=>({label:"ds.fields.defaults.password.label",type:"password",width:"w-full",placeholder:"ds.fields.defaults.password.placeholder",size:"sm",validation:{minLength:8}}),tel:()=>({label:"ds.fields.defaults.tel.label",type:"tel",width:"w-full",placeholder:"ds.fields.defaults.tel.placeholder",size:"sm"}),url:()=>({label:"ds.fields.defaults.url.label",type:"url",width:"w-full",placeholder:"ds.fields.defaults.url.placeholder",size:"sm"}),select:()=>({label:"ds.fields.defaults.select.label",type:"select",width:"w-full",size:"sm",options:[{label:"Opción A",value:"A"},{label:"Opción B",value:"B"}]}),checkbox:()=>({label:"ds.fields.defaults.checkbox.label",type:"checkbox",width:"w-full",size:"sm",defaultValue:!1}),textarea:()=>({label:"ds.fields.defaults.textarea.label",type:"textarea",width:"w-full",size:"sm",maxLength:300,showCounter:!0,placeholder:"ds.fields.defaults.textarea.placeholder"}),date:()=>({label:"ds.fields.defaults.date.label",type:"date",width:"w-full",size:"sm",showTime:!1}),file:()=>({label:"ds.fields.defaults.file.label",type:"file",width:"w-full",maxFiles:1,accept:".pdf,.doc,.docx"}),inputGroup:()=>({label:"Grupo",type:"inputGroup",width:"w-full",fields:[]}),search:()=>({label:"ds.fields.defaults.search.label",type:"search",width:"w-full",placeholder:"ds.fields.defaults.search.placeholder",size:"sm",searchMode:"button"}),optionGroup:()=>({label:"Selecciona opciones",type:"optionGroup",width:"w-full",size:"sm",multiple:!0,vertical:!0,options:[{label:"Opción 1",value:"opt1"},{label:"Opción 2",value:"opt2"},{label:"Opción 3",value:"opt3"}]}),array:()=>({label:"Lista repetible",type:"array",width:"w-full",items:[]}),button:()=>({label:"Botón",type:"button",width:"w-auto",variant:"primary",size:"sm"})}[e];return r?r():{type:e}}function TT(e){return typeof e=="function"}function Kn(e,t){if(!e||!t)return null;const r=t==="outline"?bn:xn,n=r==null?void 0:r[e];return TT(n)?n:null}function Ll(e){var c,u,d,m,f,h,p,v;if(!e||typeof e!="object")return e;if(e.type==="inputGroup"){const b=e,g={...b};return Array.isArray(b.inputs)&&(g.inputs=b.inputs.map(x=>typeof x=="string"?x:Ll(x))),g}const t=e,r={...t},n=Kn((c=t.labelPrefixIcon)==null?void 0:c.name,(u=t.labelPrefixIcon)==null?void 0:u.style),o=Kn((d=t.labelSuffixIcon)==null?void 0:d.name,(m=t.labelSuffixIcon)==null?void 0:m.style),l=Kn((f=t.prefixIcon)==null?void 0:f.name,(h=t.prefixIcon)==null?void 0:h.style),i=Kn((p=t.suffixIcon)==null?void 0:p.name,(v=t.suffixIcon)==null?void 0:v.style);return n&&(r.labelPrefixIcon=n),o&&(r.labelSuffixIcon=o),l&&(r.prefixIcon=l),i&&(r.suffixIcon=i),r}function BT({name:e,children:t}){const r=ST(e);return s.jsx("div",{ref:r,"data-field":e,style:{position:"relative"},children:t})}function V0(e){return e.startsWith("row|")?Object.fromEntries(e.slice(4).split(";").map(r=>r.split(":"))):{}}function ZT(e,t){const r=V0(e),n=V0(t);return r.ctx===n.ctx&&r.li===n.li&&r.s===n.s&&(r.t??"")===(n.t??"")}function D0(e,t){if(!e.startsWith("col|"))return Gn(e);const r=Object.fromEntries(e.slice(4).split(";").map(i=>i.split(":"))),n=r.ctx==="rows"?`rows|li:${r.li}|s:${r.s}|r:${r.r}|c:${r.c}`:`tabs|li:${r.li}|t:${r.t}|s:${r.s}|r:${r.r}|c:${r.c}`,o=(t[n]??[]).length,l=Object.prototype.hasOwnProperty.call(r,"insertAt");return{li:Number(r.li),tabIdx:r.t?Number(r.t):void 0,sectionIdx:Number(r.s),rowIdx:Number(r.r),colIdx:Number(r.c),fieldIdx:l?Number(r.insertAt):o}}function VT(e,t){const r=Array.from(e.querySelectorAll("[data-sortable-item]"));if(!r.length)return{insertAt:0,yAbs:e.getBoundingClientRect().top+8};let n=r.length,o=r[r.length-1].getBoundingClientRect().bottom;for(let l=0;l<r.length;l++){const i=r[l].getBoundingClientRect(),c=(i.top+i.bottom)/2;if(t<c){n=l,o=i.top;break}}return{insertAt:n,yAbs:o}}function DT(e){E.useEffect(()=>{if(!e)return;let t=0;const r=()=>{const n=document.getElementById("form-renderer-root");if(!n){t=requestAnimationFrame(r);return}const o=n.getBoundingClientRect(),l=window.__lastPointerY,i=80,c=14;typeof l=="number"&&(l<o.top+i?window.scrollBy({top:-c}):l>o.bottom-i&&window.scrollBy({top:c})),t=requestAnimationFrame(r)};return t=requestAnimationFrame(r),()=>cancelAnimationFrame(t)},[e])}function PT(e){const t=e.replaceAll("|",";");return t.startsWith("rows;")?`col|ctx:rows;${t.slice(5)}`:t.startsWith("tabs;")?`col|ctx:tabs;${t.slice(5)}`:`col|${t}`}function zT({droppableId:e,children:t,className:r,scope:n,li:o,tabIdx:l,sectionIdx:i,rowIdx:c,colIdx:u}){const d=n?{scope:n,...n==="rows-column"?{rowsNodeIdx:o}:{tabKey:`tab-${l}`},s:i,r:c,c:u,insertAt:0}:void 0,{isOver:m,setNodeRef:f}=tr({id:e,data:d});return s.jsx("div",{ref:f,className:["relative min-h-[28px] h-full overflow-visible transition-[box-shadow,border-color] duration-100",m?"ring-1 ring-[var(--color-ds-border-default-50)] rounded":"",r??""].join(" "),style:{isolation:"isolate"},"data-droppable-col":!0,children:t})}function HT(e,t){var n,o,l,i,c,u,d,m,f;const r=e.layout[t.li];if(r)return r.type==="rows"?(i=(l=(o=(n=r.sections[t.sectionIdx])==null?void 0:n.rows[t.rowIdx])==null?void 0:o.columns[t.colIdx])==null?void 0:l.fields)==null?void 0:i[t.fieldIdx]:(f=(m=(d=(u=(c=r.tabs[t.tabIdx])==null?void 0:c.sections[t.sectionIdx])==null?void 0:u.rows[t.rowIdx])==null?void 0:d.columns[t.colIdx])==null?void 0:m.fields)==null?void 0:f[t.fieldIdx]}function P0({ctx:e,visible:t}){const{t:r}=Ct(),n=oe(y=>y.addColumnToRow),o=oe(y=>y.setRowColumns),l=oe(y=>y.removeLastColumn),i=oe(y=>y.addRowToSectionAt),c=oe(y=>y.addColumnToTabRow),u=oe(y=>y.setTabRowColumns),d=oe(y=>y.removeLastTabColumn),m=oe(y=>y.addRowToTabSectionAt),f=()=>e.kind==="rows"?n==null?void 0:n(e.sectionIdx,e.rowIdx):c==null?void 0:c(e.tabKey,e.sectionIdx,e.rowIdx),h=()=>e.kind==="rows"?l==null?void 0:l(e.sectionIdx,e.rowIdx):d==null?void 0:d(e.tabKey,e.sectionIdx,e.rowIdx),p=y=>e.kind==="rows"?o==null?void 0:o(e.sectionIdx,e.rowIdx,y):u==null?void 0:u(e.tabKey,e.sectionIdx,e.rowIdx,y),v=()=>e.kind==="rows"?i==null?void 0:i(e.sectionIdx,e.rowIdx):m==null?void 0:m(e.tabKey,e.sectionIdx,e.rowIdx),b=()=>e.kind==="rows"?i==null?void 0:i(e.sectionIdx,e.rowIdx+1):m==null?void 0:m(e.tabKey,e.sectionIdx,e.rowIdx+1),[g,x]=E.useState({isOpen:!1,title:"",message:null,onConfirm:()=>{}}),w=(y,C,N)=>{x({isOpen:!0,title:y,message:C,onConfirm:N})},j=()=>{g.onConfirm(),x(y=>({...y,isOpen:!1}))},k=()=>{x(y=>({...y,isOpen:!1}))};return s.jsxs("div",{"aria-label":"Acciones de fila",style:{position:"absolute",insetInlineEnd:6,insetBlockStart:-25,zIndex:2147483646,pointerEvents:t?"auto":"none",opacity:t?1:0,transition:"opacity .12s ease"},className:"flex items-center gap-1",children:[s.jsxs("div",{className:"flex items-center gap-1 bg-[var(--color-ds-background-elevated)]/85 backdrop-blur-sm px-1.5 py-1 rounded-lg border border-[var(--color-ds-border-default-50)] shadow-sm",children:[s.jsx(fe,{size:"xs",variant:"ghost",title:r("ds.editor.actions.addRow"),onClick:v,children:"↑"}),s.jsx(fe,{size:"xs",variant:"ghost",title:r("ds.editor.actions.addRow"),onClick:b,children:"↓"}),s.jsx("span",{className:"w-px h-4 bg-[var(--color-ds-border-default-50)] mx-1","aria-hidden":!0}),s.jsx(fe,{size:"xs",variant:"ghost",title:r("ds.editor.actions.addColumn"),onClick:f,children:"+"}),s.jsx(fe,{size:"xs",variant:"ghost",title:r("ds.editor.actions.deleteColumn"),onClick:()=>w(r("ds.editor.confirmations.deleteColumn.title"),r("ds.editor.confirmations.deleteColumn.message"),h),children:"−"}),s.jsx("span",{className:"w-px h-4 bg-[var(--color-ds-border-default-50)] mx-1","aria-hidden":!0}),[1,2,3,4].map(y=>s.jsx(fe,{size:"xs",variant:"ghost",title:`Distribuir en ${y} columna(s)`,onClick:()=>p(y),children:y},y))]}),s.jsx(Et,{isOpen:g.isOpen,onClose:k,title:g.title,footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(fe,{variant:"outline",onClick:k,children:r("ds.editor.actions.cancel")}),s.jsx(fe,{variant:"danger",onClick:j,children:r("ds.editor.actions.delete")})]}),children:s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:g.message})})]})}function WT({schema:e,onSchemaChange:t,deps:r,layoutEditMode:n=!1}){const{t:o}=Ct(),l=oe(K=>K.updateField),i=oe(K=>K.mode),c=un(K=>K.setRuntimeState),u=un(K=>K.systemContext);E.useEffect(()=>{if(!e.variables)return;const K={};e.variables.forEach(re=>{re.type==="constant"&&(K[re.key]=re.value)}),e.variables.forEach(re=>{if(re.type==="computed"&&re.value)try{const ie=new Function("ctx",`return (${re.value});`);K[re.key]=ie(K)}catch(ie){console.warn(`[FormRendererDnd] Error evaluating computed variable "${re.key}":`,ie),K[re.key]=null}}),Object.keys(K).length>0&&c({systemContext:K})},[e.variables,c]);const d=E.useMemo(()=>({...r,translateFn:(K,re)=>{const ie=ct(o,K,re);return ie?bl(ie,u):""},onUpdateField:(K,re)=>{l(K,ie=>{Object.assign(ie,re)})},isDesignMode:i==="design"}),[r,o,l,i,u]),m=E.useCallback((K,re)=>{const ie=ct(o,K,re);return ie?bl(ie,u):""},[o,u]),f=E.useMemo(()=>OT(d),[d]),h=oe(K=>K.selection),p=(h==null?void 0:h.kind)==="field"?h.name:void 0,b=oe(K=>K.fieldPick).armed,{enabled:g,anchors:x,setSchema:w}=xu();E.useEffect(()=>{w(e)},[e,w]);const[j,k]=E.useState(null),[y,C]=E.useState(null),N=E.useRef({}),M=E.useCallback(K=>re=>{N.current[K]=re},[]),$=E.useRef(null),T=E.useRef(null),V=E.useRef(null),I=K=>{T.current==null&&(T.current=requestAnimationFrame(()=>{T.current=null;const re=V.current;JSON.stringify(re)!==JSON.stringify(K)&&(V.current=K,C(K))}))},z=E.useMemo(()=>{const K={};return e.layout.forEach((re,ie)=>{re.type==="tabs"&&(K[ie]=re.tabs[0].key)}),K},[e.layout]),[O,P]=E.useState(z),[Q,te]=E.useState({isOpen:!1,title:"",message:null,onConfirm:()=>{}}),ne=(K,re,ie)=>{te({isOpen:!0,title:K,message:re,onConfirm:ie})},ae=()=>{Q.onConfirm(),te(K=>({...K,isOpen:!1}))},W=()=>{te(K=>({...K,isOpen:!1}))},A=E.useMemo(()=>{const K={};return e.layout.forEach((re,ie)=>{re.type==="rows"?re.sections.forEach((pe,ve)=>{pe.rows.forEach((ye,Se)=>{ye.columns.forEach((ke,Fe)=>{const Oe=`rows|li:${ie}|s:${ve}|r:${Se}|c:${Fe}`;K[Oe]=(ke.fields??[]).map((Ce,xe)=>I0({li:ie,sectionIdx:ve,rowIdx:Se,colIdx:Fe,fieldIdx:xe}))})})}):re.type==="tabs"&&re.tabs.forEach((pe,ve)=>{pe.sections.forEach((ye,Se)=>{ye.rows.forEach((ke,Fe)=>{ke.columns.forEach((Oe,Ce)=>{const xe=`tabs|li:${ie}|t:${ve}|s:${Se}|r:${Fe}|c:${Ce}`;K[xe]=(Oe.fields??[]).map((Ne,Le)=>I0({li:ie,tabIdx:ve,sectionIdx:Se,rowIdx:Fe,colIdx:Ce,fieldIdx:Le}))})})})})}),K},[e]),F=E.useMemo(()=>{const K={};return Object.entries(A).forEach(([re,ie])=>ie.forEach(pe=>K[pe]=re)),K},[A]),Y=K5(Co(ts,{activationConstraint:{distance:6}}),Co(es,{coordinateGetter:yT})),U="__phantom__",[ee,le]=E.useState(!1),[ue,ge]=E.useState(null),[ce,se]=E.useState(null),[we,de]=E.useState(40),[me,R]=E.useState(null),[J,H]=E.useState(null),L=E.useCallback(K=>{if(!K)return!1;if(typeof K=="string"){const re=r.fieldsByName[K];return!!re&&re.type==="inputGroup"}return(K==null?void 0:K.type)==="inputGroup"},[r.fieldsByName]),S=K=>{var Se;const re=String(((Se=K.active)==null?void 0:Se.id)??""),ie=Y5(K),pe=ie[0],ve=pe?String(pe.id):null;if(ve&&F[ve]&&F[re]&&F[ve]===F[re])return ie;const ye=zO(K);if(re.startsWith("row|")||re.startsWith("tab-row|")){const ke=ye.filter(Fe=>String(Fe.id).startsWith("row-slot|")||String(Fe.id).startsWith("tab-row-slot|"));if(ke.length)return ke}else{const ke=ye.filter(Fe=>String(Fe.id).startsWith("col|"));if(ke.length)return ke}return ie};Ea({onDragStart:K=>{var pe,ve,ye,Se,ke,Fe;le(!0);const re=String(K.active.id??"");ge(re),se(F[re]??null),$.current=re.startsWith("row|")?"row":"field";const ie=((ve=(pe=K.active.rect.current)==null?void 0:pe.translated)==null?void 0:ve.height)??((Se=(ye=K.active.rect.current)==null?void 0:ye.initial)==null?void 0:Se.height)??40;if(de(Math.max(24,Math.floor(ie))),$.current==="field"&&!re.startsWith("col|")&&!re.startsWith("palette:"))try{const Oe=Gn(re),Ce=(ke=e.layout)==null?void 0:ke[Oe.li],Ne=(Fe=((Ce==null?void 0:Ce.type)==="rows"?Ce.sections[Oe.sectionIdx].rows[Oe.rowIdx].columns[Oe.colIdx]:Ce.tabs[Oe.tabIdx].sections[Oe.sectionIdx].rows[Oe.rowIdx].columns[Oe.colIdx]).fields)==null?void 0:Fe[Oe.fieldIdx??0],Le=Ne&&Ll(Ne);R(Le?f(Le):null)}catch{R(null)}else R(null)},onDragOver:K=>{var Fe,Oe;const re=String(((Fe=K.over)==null?void 0:Fe.id)??""),ie=String(((Oe=K.active)==null?void 0:Oe.id)??""),pe=K.activatorEvent;if(pe&&typeof pe.clientY=="number"&&(window.__lastPointerY=pe.clientY),$.current==="row"){if(re.startsWith("row|")&&ie.startsWith("row|"))if(ZT(ie,re)&&ie!==re){const Ce=N.current[re],xe=(pe==null?void 0:pe.clientY)??0;if(Ce&&xe){const Ne=Ce.getBoundingClientRect(),Le=xe<Ne.top+Ne.height/2?"before":"after";I({rid:re,pos:Le})}else I(null)}else I(null);else I(null);H(null);return}if(!re.startsWith("col|")){H(null);return}const ve=Object.fromEntries(re.slice(4).split(";").map(Ce=>Ce.split(":"))),ye=ve.ctx==="rows"?`rows|li:${ve.li}|s:${ve.s}|r:${ve.r}|c:${ve.c}`:`tabs|li:${ve.li}|t:${ve.t}|s:${ve.s}|r:${ve.r}|c:${ve.c}`,Se=document.querySelector(`[data-col-key="${ye}"]`),ke=(pe==null?void 0:pe.clientY)??0;if(Se&&ke){const{insertAt:Ce,yAbs:xe}=VT(Se,ke),Ne=Se.getBoundingClientRect().top;H({overId:re,keyId:ye,insertAt:Ce,yRel:xe-Ne})}else H(null)},onDragCancel:K=>{le(!1),ge(null),se(null),de(40),R(null),H(null),C(null),$.current=null,T.current&&(cancelAnimationFrame(T.current),T.current=null),V.current=null},onDragEnd:()=>{le(!1),ge(null),se(null),de(40),R(null),C(null),$.current=null,T.current&&(cancelAnimationFrame(T.current),T.current=null),V.current=null}}),DT(ee);const D=E.useCallback(K=>{const{active:re,over:ie}=K;if(!(re!=null&&re.id)||!(ie!=null&&ie.id)){H(null),C(null);return}const pe=re.data.current,ve=ie.data.current;if(((pe==null?void 0:pe.kind)==="row-in-section"||(pe==null?void 0:pe.kind)==="row-in-tab-section")&&((ve==null?void 0:ve.scope)==="row-slot"||(ve==null?void 0:ve.scope)==="tab-row-slot")){const Ce=pe.li,xe=pe.sIdx,Ne=pe.rIdx,Le=ve.li,Me=ve.sIdx,Te=ve.insertAt,Ie={...e,layout:[...e.layout]},Ae={...Ie.layout[Ce]};Ie.layout[Ce]=Ae;let qe=null,ze=null,De=null;if(pe.kind==="row-in-section"&&Ae.type==="rows")Ae.sections=[...Ae.sections],ze={...Ae.sections[xe]},Ae.sections[xe]=ze,ze.rows=[...ze.rows],qe=ze.rows;else if(pe.kind==="row-in-tab-section"&&Ae.type==="tabs"){Ae.tabs=[...Ae.tabs];const Je=Ae.tabs.findIndex(Ve=>Ve.key===pe.tabKey);Je>=0&&(De={...Ae.tabs[Je]},Ae.tabs[Je]=De,De.sections=[...De.sections],ze={...De.sections[xe]},De.sections[xe]=ze,ze.rows=[...ze.rows],qe=ze.rows)}if(!qe)return;let He=null,We=null;if(Ce===Le?We=Ae:(We={...Ie.layout[Le]},Ie.layout[Le]=We),ve.scope==="row-slot"&&We.type==="rows")if(We.sections===Ae.sections||(We.sections=[...We.sections]),Ce===Le&&xe===Me&&pe.kind==="row-in-section")He=qe;else{const Je={...We.sections[Me]};We.sections[Me]=Je,Je.rows=[...Je.rows],He=Je.rows}else if(ve.scope==="tab-row-slot"&&We.type==="tabs"){We.tabs===Ae.tabs||(We.tabs=[...We.tabs]);const Je=We.tabs.findIndex(Ve=>Ve.key===ve.tabKey);if(Je>=0){let Ve=We.tabs[Je];if(Ce===Le&&pe.kind==="row-in-tab-section"&&pe.tabKey===ve.tabKey?Ve=De:(Ve={...Ve},We.tabs[Je]=Ve),Ve.sections===(De==null?void 0:De.sections)||(Ve.sections=[...Ve.sections]),Ce===Le&&xe===Me&&pe.kind==="row-in-tab-section"&&pe.tabKey===ve.tabKey)He=qe;else{const tt={...Ve.sections[Me]};Ve.sections[Me]=tt,tt.rows=[...tt.rows],He=tt.rows}}}if(!He)return;const[Tt]=qe.splice(Ne,1);let Be=Te;qe===He&&Ne<Te&&(Be-=1),He.splice(Be,0,Tt),t(Ie),H(null),C(null);return}if((pe==null?void 0:pe.kind)==="palette-field"){const Ce=String(ie.id);if(!Ce.startsWith("col|")){H(null),C(null);return}const xe=Object.fromEntries(Ce.slice(4).split(";").map(Ae=>Ae.split(":"))),Ne=J&&J.overId===Ce?J.insertAt:xe.insertAt?Number(xe.insertAt):0,Le={li:Number(xe.li),tabIdx:xe.t!=null?Number(xe.t):void 0,sectionIdx:Number(xe.s),rowIdx:Number(xe.r),colIdx:Number(xe.c),fieldIdx:Ne},Me=pe.factoryKind,Te=_T(Me),Ie=CT(e,Te,Le);H(null),C(null),t(Ie);return}const ye=String(re.id),Se=String(ie.id);if(ye.startsWith("row|")&&Se.startsWith("row|"),ye.startsWith("palette:")){H(null),C(null);return}const ke=Gn(ye);let Fe;if(Se.startsWith("col|")&&J&&J.overId===Se){const Ce=Object.fromEntries(Se.slice(4).split(";").map(Ne=>Ne.split(":"))),xe=`col|${Object.entries(Ce).filter(([Ne])=>Ne!=="insertAt").map(([Ne,Le])=>`${Ne}:${Le}`).join(";")};insertAt:${J.insertAt}`;Fe=D0(xe,A)}else Fe=D0(Se,A);const Oe=kT(e,ke,Fe);H(null),C(null),t(Oe)},[e,t,A,J]);function _(K,re){let ie=K;if(ue&&ce&&ce!==re&&(ie=ie.filter(pe=>pe!==ue)),ee&&J&&J.keyId===re){const pe=Math.max(0,Math.min(J.insertAt,ie.length)),ve=ie.slice();return ve.splice(pe,0,U),ve}return ie}const Z=({keyId:K,ids:re,className:ie,tabKey:pe})=>{const ve=PT(K),ye=_(re,K),Se=Object.fromEntries(K.split("|").map(Te=>Te.split(":"))),ke=K.startsWith("rows|"),Fe=ke?"rows-column":"tabs-column",Oe=Number(Se.li),Ce=Se.t!=null?Number(Se.t):void 0,xe=Number(Se.s),Ne=Number(Se.r),Le=Number(Se.c),Me=re.length;return s.jsx(zT,{droppableId:ve,className:ie,scope:Fe,li:Oe,tabIdx:Ce,sectionIdx:xe,rowIdx:Ne,colIdx:Le,children:s.jsxs("div",{"data-col-key":K,className:"relative",children:[ke?s.jsx(Yt,{scope:"rows-column",rowsNodeIdx:Oe,s:xe,r:Ne,c:Le,insertAt:0,suppressAll:Me===0}):pe?s.jsx(Yt,{scope:"tabs-column",tabKey:pe,s:xe,r:Ne,c:Le,insertAt:0,suppressAll:Me===0}):null,ee&&J&&J.overId===ve?s.jsx("div",{"aria-hidden":!0,style:{position:"absolute",left:0,right:0,top:Math.max(0,J.yRel-1),height:2,background:"var(--color-ds-border-default)",borderRadius:2}}):null,s.jsx(uT,{items:ye,strategy:cT,children:s.jsx("div",{children:ye.map((Te,Ie)=>{if(Te===U)return s.jsx("div",{"data-sortable-item":!0,"aria-hidden":!0,style:{height:we,border:"1px dashed var(--color-ds-border-default-50)",borderRadius:8,background:"color-mix(in srgb, var(--color-ds-border-default-50) 8%, transparent)"}},`${K}-ph-${Ie}`);const Ae=Gn(String(Te)),qe=HT(e,Ae);if(!qe)return s.jsx("div",{"data-sortable-item":!0,"aria-hidden":!0},`${K}-miss-${Ie}`);const ze=Ll(qe),De=typeof ze=="string"?ze:(ze==null?void 0:ze.name)??"",He=!!p&&!!De&&p===De,We=f(ze),Tt=L(ze),Be=Ve=>{var tt;Ve.preventDefault(),Ve.stopPropagation(),(tt=Ve.nativeEvent)!=null&&tt.stopImmediatePropagation&&Ve.nativeEvent.stopImmediatePropagation()},Je=Tt?{onDoubleClick:Be,onDoubleClickCapture:Be,onClick:Be,onClickCapture:Be,onMouseDown:Be,onMouseDownCapture:Be,onMouseUp:Be,onMouseUpCapture:Be,onPointerDown:Be,onPointerDownCapture:Be,onPointerUp:Be,onPointerUpCapture:Be,onContextMenu:Be}:{};return s.jsx("div",{"data-sortable-item":!0,children:s.jsx(IT,{id:String(Te),fieldName:De,onDelete:Ve=>{const tt=Gn(Ve);ne("Eliminar campo","¿Estás seguro de que quieres eliminar este campo?",()=>{const Or=ET(e,tt);t(Or)})},chromeDisabled:b,children:s.jsx(BT,{name:De,children:s.jsx("div",{className:He?"selected-field":void 0,"data-field-name":De,"aria-selected":He||void 0,...Je,children:We})})})},String(Te))})})})]})})},B=ee&&$.current==="row",q=(K,re)=>s.jsx(s.Fragment,{children:K.sections.map((ie,pe)=>s.jsx("div",{className:"mb-6",children:s.jsx(ot,{title:m(ie.sectionTitle),defaultOpen:ie.defaultOpen,forceOpen:B,children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx(Ga,{scope:"row-slot",li:re,sIdx:pe,insertAt:0}),ie.rows.map((ve,ye)=>{const Se=`row|li:${re}|s:${pe}|r:${ye}`,ke=n&&j===Se,Fe=ue===Se;return s.jsxs(E.Fragment,{children:[s.jsxs("div",{ref:M(Se),className:`relative transition-all duration-200 ${Fe?"opacity-40 ring-1 ring-dashed ring-[var(--color-ds-border-default)] bg-[var(--color-ds-background-muted)]":n&&ke?"ring-1 ring-[var(--color-ds-border-default-50)]":""}`,onMouseEnter:()=>k(Se),onMouseLeave:()=>k(Oe=>Oe===Se?null:Oe),style:{borderRadius:8},children:[n&&s.jsxs(s.Fragment,{children:[s.jsx(P0,{ctx:{kind:"rows",li:re,sectionIdx:pe,rowIdx:ye},visible:!!ke&&!b}),s.jsx(Z0,{kind:"row-in-section",li:re,sIdx:pe,rIdx:ye,visible:!!ke&&!b})]}),ve.title&&s.jsx("h2",{className:"mb-2 text-lg text-[var(--color-ds-text-primary)]",children:m(ve.title)}),s.jsx("div",{className:"flex flex-wrap -mx-2 items-stretch",children:ve.columns.map((Oe,Ce)=>{const xe=`rows|li:${re}|s:${pe}|r:${ye}|c:${Ce}`,Ne=A[xe]??[];return s.jsx("div",{className:`${Oe.width} px-2 flex flex-col`,children:s.jsx(Z,{keyId:xe,ids:Ne})},`col-${re}-${pe}-${ye}-${Ce}`)})})]}),s.jsx(Ga,{scope:"row-slot",li:re,sIdx:pe,insertAt:ye+1})]},`rowwrap-${Se}`)})]})})},`sec-${re}-${pe}`))}),X=(K,re)=>{var pe;const ie=O[re]??((pe=K.tabs[0])==null?void 0:pe.key);return s.jsx(fr,{options:K.tabs.map(ve=>{const ye=ve.icon?Kn(ve.icon.name,ve.icon.style):null;return{label:m(ve.label),value:ve.key,disabled:ve.disabled,icon:ye?s.jsx(ye,{className:"w-4 h-4"}):null}}),value:ie,onChange:ve=>P(ye=>({...ye,[re]:ve})),children:Object.fromEntries(K.tabs.map((ve,ye)=>[ve.key,s.jsx("div",{className:"space-y-6",children:ve.sections.map((Se,ke)=>s.jsx("div",{className:"mb-6",children:s.jsx(ot,{title:m(Se.sectionTitle),defaultOpen:Se.defaultOpen,forceOpen:B,children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx(Ga,{scope:"tab-row-slot",li:re,tabKey:ve.key,sIdx:ke,insertAt:0}),Se.rows.map((Fe,Oe)=>{const Ce=`tab-row|li:${re}|t:${ve.key}|s:${ke}|r:${Oe}`,xe=n&&j===Ce,Ne=ue===Ce;return s.jsxs(E.Fragment,{children:[s.jsxs("div",{ref:M(Ce),className:`relative transition-all duration-200 ${Ne?"opacity-40 ring-1 ring-dashed ring-[var(--color-ds-border-default)] bg-[var(--color-ds-background-muted)]":n&&xe?"ring-1 ring-[var(--color-ds-border-default-50)]":""}`,onMouseEnter:()=>k(Ce),onMouseLeave:()=>k(Le=>Le===Ce?null:Le),style:{borderRadius:8},children:[n&&s.jsxs(s.Fragment,{children:[s.jsx(P0,{ctx:{kind:"tabs",li:re,tabKey:ve.key,tabIdx:ye,sectionIdx:ke,rowIdx:Oe},visible:!!xe&&!b}),s.jsx(Z0,{kind:"row-in-tab-section",li:re,tabKey:ve.key,sIdx:ke,rIdx:Oe,visible:!!xe&&!b})]}),Fe.title&&s.jsx("h2",{className:"mb-2 text-lg text-[var(--color-ds-text-primary)]",children:m(Fe.title)}),s.jsx("div",{className:"flex flex-wrap -mx-2 items-stretch",children:Fe.columns.map((Le,Me)=>{const Te=`tabs|li:${re}|t:${ye}|s:${ke}|r:${Oe}|c:${Me}`,Ie=A[Te]??[];return s.jsx("div",{className:`${Le.width??"flex-1"} px-2 flex flex-col`,children:s.jsx(Z,{keyId:Te,ids:Ie,tabKey:ve.key})},`col-${re}-${ye}-${ke}-${Oe}-${Me}`)})})]}),s.jsx(Ga,{scope:"tab-row-slot",li:re,tabKey:ve.key,sIdx:ke,insertAt:Oe+1})]},`rowwrap-${Ce}`)})]})})},`sec-${re}-${ye}-${ke}`))},`tabpanel-${re}-${ye}`)]))},`tabs-${re}`)},G=oe(K=>K.setSelection);return s.jsxs(ei,{...r.methods,children:[s.jsxs(h1,{sensors:Y,collisionDetection:S,onDragEnd:D,children:[s.jsxs("div",{id:"form-renderer-root",className:"relative overflow-visible",onDoubleClick:K=>{G({kind:"none"})},children:[s.jsx("div",{className:"space-y-6 ",children:e.layout.map((K,re)=>K.type==="rows"?s.jsx(E.Fragment,{children:q(K,re)},`rows-${re}`):s.jsx(E.Fragment,{children:X(K,re)},`tabs-${re}`))}),s.jsx(AT,{schema:e,anchors:x,enabled:g})]}),s.jsx(g1,{dropAnimation:null,children:me?s.jsx("div",{style:{pointerEvents:"none",opacity:.9},children:me}):null})]}),s.jsx(Et,{isOpen:Q.isOpen,onClose:W,title:Q.title,footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(fe,{variant:"outline",onClick:W,children:"Cancelar"}),s.jsx(fe,{variant:"danger",onClick:ae,children:"Eliminar"})]}),children:s.jsx("p",{className:"text-sm text-[var(--color-ds-text-secondary)]",children:Q.message})})]})}function UT(e,t,r,n){var w;const{fields:o=[],layout:l,validationSchema:i}=e,c=qT(),u=((w=c==null?void 0:c.services)==null?void 0:w.registry)??void 0,d=E.useMemo(()=>{if(t)return t;try{const j=i??ui(e);return ii(j)}catch{return}},[t,e,i]),m=ai({resolver:d,mode:"onBlur",reValidateMode:"onChange",defaultValues:e.defaultValues??{}}),f=E.useMemo(()=>(o??[]).filter(j=>j.type!=="inputGroup"&&j.type!=="button"),[o]),{optionsMap:h}=M5(f),p=C5(o),v=A5(o,m.control),[b,g]=E.useState({});E.useEffect(()=>{let j=!0;return(async()=>{const y=await Promise.all(f.filter(N=>N.type==="select"&&(N.optionSource||N.endpointConfig)).map(async N=>{const M=N.name,$=ho(N.optionSource,N.endpointConfig);if(!$)return[M,[]];const T=N.endpointConfig?Ir(N.endpointConfig.parameters,m.getValues,{ACTIVE_VARIANT:n}):{},V=u==null?void 0:u[$];if(typeof V!="function")return[M,[]];try{const I=await Promise.resolve(V("",{getValues:m.getValues,watch:m.watch,params:T})),z=Array.isArray(I)?I:[];return[M,z]}catch{return[M,[]]}}));if(!j)return;const C={};for(const[N,M]of y)C[N]=M;g(C)})(),()=>{j=!1}},[u,m.getValues,m.watch,JSON.stringify(f.map(j=>({n:j.name,os:j.optionSource??null,ec:j.endpointConfig??null}))),n]);const x=E.useCallback((j,k)=>{if(!(j!=null&&j.enabled)||!j.rule)return k;try{const y={...m.getValues(),ACTIVE_VARIANT:n};return!!vo(j.rule,y)}catch{return k}},[m,n]);return{methods:m,control:m.control,formState:m.formState,fields:o,fieldsByName:p,asyncOptionsMap:h,adapterOptionsMap:b,disabledMap:v,evalContainer:x,registry:u,layout:l}}function qT(){try{return St()??void 0}catch{return}}function GT(e,t,r){const n={...e};return t.top+e.y<=r.top?n.y=r.top-t.top:t.bottom+e.y>=r.top+r.height&&(n.y=r.top+r.height-t.bottom),t.left+e.x<=r.left?n.x=r.left-t.left:t.right+e.x>=r.left+r.width&&(n.x=r.left+r.width-t.right),n}const KT=e=>{let{transform:t,draggingNodeRect:r,windowRect:n}=e;return!r||!n?t:GT(t,r,n)};function tn(e){const r={text:()=>({label:"ds.fields.defaults.text.label",type:"text",width:"w-full",placeholder:"ds.fields.defaults.text.placeholder",size:"sm"}),number:()=>({label:"ds.fields.defaults.number.label",type:"number",width:"w-full",placeholder:"ds.fields.defaults.number.placeholder",size:"sm",validation:{required:!1}}),email:()=>({label:"ds.fields.defaults.email.label",type:"email",width:"w-full",placeholder:"ds.fields.defaults.email.placeholder",size:"sm"}),password:()=>({label:"ds.fields.defaults.password.label",type:"password",width:"w-full",placeholder:"ds.fields.defaults.password.placeholder",size:"sm",validation:{minLength:8}}),tel:()=>({label:"ds.fields.defaults.tel.label",type:"tel",width:"w-full",placeholder:"ds.fields.defaults.tel.placeholder",size:"sm"}),url:()=>({label:"ds.fields.defaults.url.label",type:"url",width:"w-full",placeholder:"ds.fields.defaults.url.placeholder",size:"sm"}),select:()=>({label:"ds.fields.defaults.select.label",type:"select",width:"w-full",size:"sm",options:[{label:"Opción A",value:"A"},{label:"Opción B",value:"B"}]}),checkbox:()=>({label:"ds.fields.defaults.checkbox.label",type:"checkbox",width:"w-full",size:"sm",defaultValue:!1}),textarea:()=>({label:"ds.fields.defaults.textarea.label",type:"textarea",width:"w-full",size:"sm",maxLength:300,showCounter:!0,placeholder:"ds.fields.defaults.textarea.placeholder"}),date:()=>({label:"ds.fields.defaults.date.label",type:"date",width:"w-full",size:"sm",showTime:!1}),file:()=>({label:"ds.fields.defaults.file.label",type:"file",width:"w-full",maxFiles:1,accept:".pdf,.doc,.docx"}),inputGroup:()=>({label:"Grupo",type:"inputGroup",width:"w-full",fields:[]}),search:()=>({label:"ds.fields.defaults.search.label",type:"search",width:"w-full",placeholder:"ds.fields.defaults.search.placeholder",size:"sm",searchMode:"button"}),optionGroup:()=>({label:"Selecciona opciones",type:"optionGroup",width:"w-full",size:"sm",multiple:!0,vertical:!0,options:[{label:"Opción 1",value:"opt1"},{label:"Opción 2",value:"opt2"},{label:"Opción 3",value:"opt3"}]}),array:()=>({label:"Lista repetible",type:"array",width:"w-full",items:[]})}[e];return r?r():{type:e}}function JT(e){if(!e)return null;const t=e.data;if(t.kind==="palette-field"){const r=t.factoryKind,n=g$[r];if(n)return s.jsx("div",{className:"pointer-events-none opacity-95",children:s.jsx("div",{className:`\r
296
296
  w-[320px]\r
297
297
  max-w-[80vw]\r
298
298
  rounded-xl \r
@@ -300,8 +300,8 @@ ${N.join(`
300
300
  shadow-lg \r
301
301
  px-3 \r
302
302
  py-2\r
303
- `,children:n})})}return s.jsxs("div",{className:"px-2 py-1 rounded-md border text-[var(--color-ds-text-primary)] border-[var(--color-ds-border-default)] bg-[var(--color-ds-background-surface)] shadow",children:[t.kind==="palette-field"&&`Nuevo: ${t.factoryKind}`,t.kind==="field-in-rows"&&t.name,t.kind==="field-in-tabs"&&t.name,t.kind==="field-in-inputgroup"&&t.name,t.kind==="rows-section"&&"Sección",t.kind==="tabs-tab"&&"Pestaña",t.kind==="tab-section"&&"Sección de pestaña"]})}function XT({children:e}){const t=oe(W=>W.moveField),r=oe(W=>W.moveFieldInTab),n=oe(W=>W.removeFieldFromLayout),o=oe(W=>W.removeFieldFromTabLayout),l=oe(W=>W.insertExistingFieldAt),i=oe(W=>W.insertExistingFieldInTabAt),c=oe(W=>W.addField),u=oe(W=>W.addFieldAndPlaceInTabAt),d=oe(W=>W.placeFieldInTabColumn),m=oe(W=>W.placeFieldInColumn),f=oe(W=>W.moveFieldAt),h=oe(W=>W.removeFieldFromLayoutAt),p=oe(W=>W.placeFieldInColumnAt),v=oe(W=>W.insertExistingFieldAtAt),b=oe(W=>W.addFieldAndPlaceAtAt),g=oe(W=>W.moveSection),x=oe(W=>W.moveTab),w=oe(W=>W.moveTabSection),j=oe(W=>W.moveSectionAcrossNodes),k=oe(W=>W.moveSectionToTab),y=oe(W=>W.placeFieldInInputGroup),C=oe(W=>W.moveFieldWithinInputGroup),N=oe(W=>W.removeFieldFromInputGroup),M=oe(W=>W.placeFieldInArray),$=oe(W=>W.moveFieldInArray);oe(W=>W.removeFieldFromArray);const[T,V]=E.useState(null),[I,z]=E.useState(null),O=K5(Co(ts,{activationConstraint:{distance:6}}),Co(es)),P=W=>{var F,Y;const A=(Y=(F=W==null?void 0:W.active)==null?void 0:F.data)==null?void 0:Y.current;A&&V({data:A})},Q=W=>{var F,Y;const A=(Y=(F=W==null?void 0:W.over)==null?void 0:F.data)==null?void 0:Y.current;z(A??null)},te=(W,A)=>W===void 0?A:Math.max(0,Math.min(W,A)),ne=W=>{var U,ee;const A=(ee=(U=W.active)==null?void 0:U.data)==null?void 0:ee.current;let F=null;switch(A==null?void 0:A.kind){case"rows-section":F=["rows-section","tab-section"];break;case"tabs-tab":F=["tabs-tab"];break;case"tab-section":F=["tab-section"];break;case"field-in-rows":F=["rows-column","tabs-column","input-group","array-items"];break;case"field-in-tabs":F=["tabs-column","rows-column","input-group","array-items"];break;case"field-in-inputgroup":F=["input-group"];break;case"field-in-array":F=["array-items"];break;case"palette-field":F=["rows-column","tabs-column","input-group","array-items"];break;default:F=null}const Y=F==null?W.droppableContainers:W.droppableContainers.filter(le=>{var ge,ce;const ue=(ce=(ge=le.data)==null?void 0:ge.current)==null?void 0:ce.scope;return ue&&F.includes(ue)});return Y.length?Y5({...W,droppableContainers:Y}):X5(W)},ae=W=>{var Y,U,ee,le,ue,ge,ce,se,we;const A=(U=(Y=W==null?void 0:W.active)==null?void 0:Y.data)==null?void 0:U.current,F=(le=(ee=W==null?void 0:W.over)==null?void 0:ee.data)==null?void 0:le.current;if(V(null),z(null),!(!A||!F)){if(A.kind==="rows-section"&&F.scope==="rows-section"){const de=A.nodeIdx,me=A.sIdx,R=F.nodeIdx,J=F.insertAt;if(de===R){if(typeof g=="function"){const H=oe.getState().schema.layout[de],L=((ue=H==null?void 0:H.sections)==null?void 0:ue.length)??0,S=te(J,L);if(S!==me){const D=S>me?S-1:S;g(de,me,D)}}}else if(typeof j=="function"){const H=oe.getState().schema.layout[R],L=((ge=H==null?void 0:H.sections)==null?void 0:ge.length)??0,S=te(J,L);j(de,me,R,S)}return}if(A.kind==="rows-section"&&F.scope==="tab-section"){const de=A.nodeIdx,me=A.sIdx,R=F.nodeIdx,J=F.tabKey,H=F.insertAt;typeof k=="function"&&k(de,me,R,J,H);return}if(A.kind==="tabs-tab"&&F.scope==="tabs-tab"){if(typeof x=="function"&&A.nodeIdx===F.nodeIdx){const de=oe.getState().schema.layout[A.nodeIdx],me=((ce=de==null?void 0:de.tabs)==null?void 0:ce.length)??0;x(A.nodeIdx,A.index,te(F.insertAt,me))}return}if(A.kind==="tab-section"&&F.scope==="tab-section"){if(typeof w=="function"&&A.nodeIdx===F.nodeIdx&&A.tabKey===F.tabKey){const de=oe.getState().schema.layout[A.nodeIdx],me=(se=de==null?void 0:de.tabs)==null?void 0:se.find(J=>J.key===A.tabKey),R=((we=me==null?void 0:me.sections)==null?void 0:we.length)??0;w(A.nodeIdx,A.tabKey,A.sIdx,te(F.insertAt,R))}return}if(F.scope==="input-group"){const de=F.groupName,me=F.insertAt;if(A.kind==="field-in-inputgroup"&&A.groupName===de){const R=A.path.idx,J=me??R;typeof C=="function"&&R!==J&&C(de,R,J);return}if(A.kind==="field-in-inputgroup"&&A.groupName!==de){typeof N=="function"&&N(A.groupName,A.path.idx),y==null||y(A.name,de,me);return}if(A.kind==="field-in-rows"){const R=A.rowsNodeIdx??0;typeof h=="function"?h(R,A.path):n({...A.path,nodeIdx:R}),y==null||y(A.name,de,me);return}if(A.kind==="field-in-tabs"){o({tabKey:A.tabKey,...A.path}),y==null||y(A.name,de,me);return}if(A.kind==="palette-field"){const R=oe.getState().schema.fields.length;c(tn(A.factoryKind));const J=oe.getState().schema.fields[R];y==null||y(J.name,de,me);return}}if(A.kind==="field-in-rows"&&F.scope==="rows-column"){const de=A.rowsNodeIdx??0,me=F.rowsNodeIdx??de;typeof f=="function"&&de!==me?f(de,A.path,me,{s:F.s,r:F.r,c:F.c,idx:F.insertAt}):t({...A.path,nodeIdx:de},{nodeIdx:me,s:F.s,r:F.r,c:F.c,idx:F.insertAt});return}if(A.kind==="field-in-tabs"&&F.scope==="tabs-column"&&A.tabKey===F.tabKey){r({tabKey:A.tabKey,...A.path},{tabKey:A.tabKey,s:F.s,r:F.r,c:F.c,idx:F.insertAt});return}if(A.kind==="field-in-tabs"&&F.scope==="tabs-column"&&A.tabKey!==F.tabKey){o({tabKey:A.tabKey,...A.path}),typeof F.insertAt=="number"?i(A.name,F.tabKey,F.s,F.r,F.c,F.insertAt):d(A.name,F.tabKey,F.s,F.r,F.c);return}if(A.kind==="field-in-rows"&&F.scope==="tabs-column"){const de=A.rowsNodeIdx??0;typeof h=="function"?h(de,A.path):n({...A.path,nodeIdx:de}),typeof F.insertAt=="number"?i(A.name,F.tabKey,F.s,F.r,F.c,F.insertAt):d(A.name,F.tabKey,F.s,F.r,F.c);return}if(A.kind==="field-in-tabs"&&F.scope==="rows-column"){o({tabKey:A.tabKey,...A.path});const de=F.rowsNodeIdx??0;if(typeof v=="function"){const me=typeof F.insertAt=="number"?F.insertAt:void 0;typeof me=="number"?v(de,A.name,F.s,F.r,F.c,me):typeof p=="function"?p(de,A.name,F.s,F.r,F.c):m(A.name,de,F.s,F.r,F.c)}else typeof F.insertAt=="number"?l(A.name,F.s,F.r,F.c,F.insertAt):m(A.name,de,F.s,F.r,F.c);return}if(A.kind==="palette-field"){if(F.scope==="rows-column"){const de=F.rowsNodeIdx??0;if(typeof F.insertAt=="number"&&typeof b=="function")b(de,tn(A.factoryKind),F.s,F.r,F.c,F.insertAt);else{const me=oe.getState().schema.fields.length;c(tn(A.factoryKind));const R=oe.getState().schema.fields[me];typeof p=="function"?p(de,R.name,F.s,F.r,F.c):m(R.name,de,F.s,F.r,F.c)}return}if(F.scope==="tabs-column"){if(typeof F.insertAt=="number"&&typeof u=="function")u(tn(A.factoryKind),F.tabKey,F.s,F.r,F.c,F.insertAt);else{const de=oe.getState().schema.fields.length;c(tn(A.factoryKind));const me=oe.getState().schema.fields[de];d(me.name,F.tabKey,F.s,F.r,F.c)}return}if(F.scope==="array-items"){const de=F.arrayName,me=F.insertAt;if(typeof M=="function"){const R=tn(A.factoryKind);M(de,R,me)}return}}if(F.scope==="array-items"){const de=F.arrayName,me=F.insertAt;if(A.kind==="field-in-array"){if(A.arrayName===de){const J=A.index;typeof $=="function"&&J!==me&&$(de,J,me)}return}if(A.kind==="field-in-rows"||A.kind==="field-in-tabs"||A.kind==="field-in-inputgroup"){const R=A.name,J=oe.getState(),H=J.schema.fields.find(L=>L.name===R);if(H){const L=JSON.parse(JSON.stringify(H));J.removeField&&J.removeField(R),typeof M=="function"&&M(de,L,me)}return}}}};return s.jsxs(h1,{sensors:O,collisionDetection:ne,onDragStart:P,onDragOver:Q,onDragEnd:ae,modifiers:[JT],children:[e,s.jsx(g1,{children:YT(T)})]})}function QT({code:e,language:t="json"}){const{t:r}=Ct(),n=E.useMemo(()=>e.split(`
304
- `),[e]),[o,l]=E.useState(!1),i=()=>{navigator.clipboard.writeText(e),l(!0),setTimeout(()=>l(!1),2e3)},c=(u,d)=>{if(!u)return s.jsx("span",{className:"inline-block w-full",children:" "});const m={keyword:"text-purple-600 dark:text-purple-400 font-bold",string:"text-green-600 dark:text-green-400",number:"text-blue-600 dark:text-blue-400",boolean:"text-blue-600 dark:text-blue-400 font-bold",comment:"text-gray-500 italic",punctuation:"text-gray-500 dark:text-gray-400",property:"text-sky-700 dark:text-sky-300",type:"text-yellow-600 dark:text-yellow-400"},f=[];let h=0;if(d==="json"){const p=/(".*?")(\s*:)?|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|([{},[\]])|([^\s]+)/g;let v,b=0;for(;(v=p.exec(u))!==null;){v.index>b&&f.push(s.jsx("span",{children:u.substring(b,v.index)},h++));const g=v[0],[x,w,j,k,y,C,N]=v;w?j?(f.push(s.jsx("span",{className:m.property,children:w},h++)),f.push(s.jsx("span",{className:m.punctuation,children:":"},h++))):f.push(s.jsx("span",{className:m.string,children:w},h++)):k?f.push(s.jsx("span",{className:m.boolean,children:k},h++)):y?f.push(s.jsx("span",{className:m.number,children:y},h++)):C?f.push(s.jsx("span",{className:m.punctuation,children:C},h++)):f.push(s.jsx("span",{children:g},h++)),b=p.lastIndex}return b<u.length&&f.push(s.jsx("span",{children:u.substring(b)},h++)),f}if(d==="typescript"||d==="yup"){const p="\\b(export|import|const|let|var|function|return|if|else|interface|type|from|as)\\b",v=new RegExp(`(\\/\\/.*)|(["'].*?["'])|(${p})|(\\b\\d+\\b)|(\\b[A-Z][a-zA-Z0-9]*\\b)|([{}[\\](),.;:])`,"g");let b,g=0;for(;(b=v.exec(u))!==null;){b.index>g&&f.push(s.jsx("span",{children:u.substring(g,b.index)},h++));const[x,w,j,k,y,C,N]=b;w?f.push(s.jsx("span",{className:m.comment,children:w},h++)):j?f.push(s.jsx("span",{className:m.string,children:j},h++)):k?f.push(s.jsx("span",{className:m.keyword,children:k},h++)):y?f.push(s.jsx("span",{className:m.number,children:y},h++)):C?f.push(s.jsx("span",{className:m.type,children:C},h++)):N?f.push(s.jsx("span",{className:m.punctuation,children:N},h++)):f.push(s.jsx("span",{children:x},h++)),g=v.lastIndex}return g<u.length&&f.push(s.jsx("span",{children:u.substring(g)},h++)),f}return u&&f.push(s.jsx("span",{children:u},h++)),f};return s.jsxs("div",{className:"flex-1 min-h-0 w-full bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)] font-mono text-sm flex flex-col relative group/codeviewer",children:[s.jsx("button",{onClick:i,className:he("absolute top-4 right-6 z-30 p-2 rounded-md transition-all duration-200","bg-[var(--color-ds-background-surface)] border border-[var(--color-ds-border-default)] shadow-sm","text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)] hover:border-[var(--color-ds-border-default-50)]","opacity-0 group-hover/codeviewer:opacity-100",o&&"opacity-100 border-green-500 text-green-600"),title:r("ds.editor.codeViewer.copy"),children:o?s.jsx(Br,{className:"w-4 h-4"}):s.jsx(Fl,{className:"w-4 h-4"})}),s.jsx("div",{className:"flex-1 min-h-0 relative outline-none",tabIndex:0,onClick:u=>{u.currentTarget.tabIndex>=0&&document.activeElement!==u.currentTarget&&u.currentTarget.focus({preventScroll:!0})},onKeyDown:u=>{if((u.ctrlKey||u.metaKey)&&u.key.toLowerCase()==="a"){u.preventDefault();const d=u.currentTarget.querySelector(".code-content-container");if(d){const m=document.createRange();m.selectNodeContents(d);const f=window.getSelection();f&&(f.removeAllRanges(),f.addRange(m))}}},children:s.jsx(bo,{className:"w-full bg-[var(--color-ds-background-page)]",children:s.jsx("div",{className:"min-w-fit min-h-full py-2 code-content-container",children:n.map((u,d)=>{const m=u.match(/^(\s*)/),f=m?m[1].length:0;return s.jsxs("div",{className:"flex leading-6 hover:bg-[color-mix(in_srgb,var(--color-ds-text-primary)_5%,transparent)] group relative",children:[s.jsx("div",{className:"absolute left-12 top-0 bottom-0 pointer-events-none select-none opacity-20",style:{width:`${f}ch`,background:"repeating-linear-gradient(to right, var(--color-ds-border-default-50) 0px, var(--color-ds-border-default-50) 1px, transparent 1px, transparent 2ch)"}}),s.jsx("div",{className:he("sticky left-0 z-20 w-12 shrink-0 text-right pr-4 select-none user-select-none","text-[var(--color-ds-text-secondary)] opacity-40","border-r border-[var(--color-ds-border-default-50)]/30 mr-4","bg-[var(--color-ds-background-page)]","group-hover:text-[var(--color-ds-text-primary)] group-hover:opacity-100 transition-colors"),style:{userSelect:"none"},children:d+1}),s.jsx("pre",{className:"flex-1 m-0 font-mono whitespace-pre text-[var(--color-ds-text-primary)] relative z-10",children:c(u,t)})]},d)})})})}),s.jsxs("div",{className:"flex items-center justify-between px-3 py-1 bg-[var(--color-ds-button-primary-bg)] text-[var(--color-ds-button-primary-text)] text-xs select-none",children:[s.jsx("div",{className:"flex items-center gap-4",children:s.jsxs("span",{className:"font-semibold uppercase flex items-center gap-1",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-[var(--rel-color-visible)]"}),t]})}),s.jsxs("div",{className:"flex items-center gap-4 opacity-80",children:[s.jsxs("span",{children:[n.length," ",r("ds.editor.codeViewer.lines")]}),s.jsx("span",{children:"UTF-8"}),s.jsx("span",{children:t==="json"?"JSON":"TypeScript"})]})]})]})}function eB({selected:e,onSelect:t}){const{services:r}=St(),n=E.useMemo(()=>{const c=(r==null?void 0:r.registry)||{},u=new Set;return Object.keys(c).forEach(d=>{const m=d.split(".");m.length>0&&u.add(m[0])}),Array.from(u).sort()},[r]),o=[{id:"json",label:"schema.json",icon:Cn},{id:"yup",label:"validation.ts",icon:Xt},{id:"translations",label:"translations.json",icon:To}],l=[];n.length>0?(l.push({id:"adapters",label:"📁 services/",icon:bd}),l.push({id:"adapters",label:" index.ts",icon:Xt,indent:!0}),n.forEach(c=>{const u=c.replace(/[^a-zA-Z0-9]/g," ").split(" ").filter(Boolean).map(d=>d.charAt(0).toUpperCase()+d.slice(1)).join("");l.push({id:`service-${c}`,label:` ${u}Service.ts`,icon:Xt,indent:!0})})):l.push({id:"adapters",label:"generated-services.ts",icon:Xt}),l.push({id:"metadata",label:"generated-metadata.ts",icon:Xt});const i=[...o,...l];return s.jsxs("div",{className:"h-full flex flex-col bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)]",children:[s.jsx("div",{className:"px-4 py-2 border-b border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)] shrink-0 flex items-center h-[41px]",children:s.jsx("strong",{className:"text-[var(--color-ds-text-primary)]",children:"Archivos"})}),s.jsx("div",{className:"flex-1 py-1 overflow-y-auto",children:i.map((c,u)=>{const d=e===c.id,m=c.label.includes("📁");return s.jsxs("button",{onClick:()=>!m&&t(c.id),className:he("w-full flex items-center gap-2 px-4 py-1.5 text-sm transition-colors text-left border-l-2",m&&"cursor-default opacity-60",!m&&d?"bg-[color-mix(in_srgb,var(--color-ds-button-primary-bg)_10%,transparent)] border-[var(--color-ds-button-primary-bg)] text-[var(--color-ds-text-primary)]":"border-transparent text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-background-neutral-hover)]",c.indent&&"pl-6"),disabled:m,children:[!m&&s.jsx(c.icon,{className:he("w-4 h-4 shrink-0",d?"text-[var(--color-ds-button-primary-bg)]":"opacity-70")}),s.jsx("span",{className:"truncate font-mono text-xs",children:c.label})]},`${c.id}-${u}`)})})]})}function tB({value:e,onChange:t}){const r=E.useMemo(()=>[{id:"mobile",label:"Mobile (375px)",icon:fd},{id:"tablet",label:"Tablet (768px)",icon:md},{id:"desktop",label:"Desktop (100%)",icon:Tl}],[]);return s.jsx(xa,{value:e,onChange:t,items:r,variant:"square",size:"sm"})}function rB(){const{t:e,i18n:t}=Ct(),r=oe(M=>M.schema),n=oe(M=>M.mode),o=oe(M=>M.activeVariantId),l=E.useMemo(()=>{var M;if(!(!o||!r.variants))return((M=r.variants.find($=>$.key===o))==null?void 0:M.label)||o},[r.variants,o]),{translations:i,services:c}=St(),u=oe(M=>M.setSchema??M.updateSchema??M.replaceSchema),d=oe(M=>M.setSelection),m=oe(M=>M.editorSettings),[f,h]=E.useState("desktop"),[p,v]=E.useState("json"),[b,g]=E.useState(""),x=oe(M=>M.recoverOrphans);E.useEffect(()=>{x==null||x()},[x]),E.useEffect(()=>{const M=(m==null?void 0:m.theme)||"system";M==="dark"||M==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches?(document.documentElement.setAttribute("data-mode","dark"),document.documentElement.classList.add("dark")):(document.documentElement.removeAttribute("data-mode"),document.documentElement.classList.remove("dark"))},[m==null?void 0:m.theme]),E.useEffect(()=>{if(n==="code"){if(p==="json")g(JSON.stringify(r,null,2));else if(p==="yup")try{const M=Ii(r,"validationSchema");g(M)}catch(M){g(`// Error generating Yup code
303
+ `,children:n})})}return s.jsxs("div",{className:"px-2 py-1 rounded-md border text-[var(--color-ds-text-primary)] border-[var(--color-ds-border-default)] bg-[var(--color-ds-background-surface)] shadow",children:[t.kind==="palette-field"&&`Nuevo: ${t.factoryKind}`,t.kind==="field-in-rows"&&t.name,t.kind==="field-in-tabs"&&t.name,t.kind==="field-in-inputgroup"&&t.name,t.kind==="rows-section"&&"Sección",t.kind==="tabs-tab"&&"Pestaña",t.kind==="tab-section"&&"Sección de pestaña"]})}function YT({children:e}){const t=oe(W=>W.moveField),r=oe(W=>W.moveFieldInTab),n=oe(W=>W.removeFieldFromLayout),o=oe(W=>W.removeFieldFromTabLayout),l=oe(W=>W.insertExistingFieldAt),i=oe(W=>W.insertExistingFieldInTabAt),c=oe(W=>W.addField),u=oe(W=>W.addFieldAndPlaceInTabAt),d=oe(W=>W.placeFieldInTabColumn),m=oe(W=>W.placeFieldInColumn),f=oe(W=>W.moveFieldAt),h=oe(W=>W.removeFieldFromLayoutAt),p=oe(W=>W.placeFieldInColumnAt),v=oe(W=>W.insertExistingFieldAtAt),b=oe(W=>W.addFieldAndPlaceAtAt),g=oe(W=>W.moveSection),x=oe(W=>W.moveTab),w=oe(W=>W.moveTabSection),j=oe(W=>W.moveSectionAcrossNodes),k=oe(W=>W.moveSectionToTab),y=oe(W=>W.placeFieldInInputGroup),C=oe(W=>W.moveFieldWithinInputGroup),N=oe(W=>W.removeFieldFromInputGroup),M=oe(W=>W.placeFieldInArray),$=oe(W=>W.moveFieldInArray);oe(W=>W.removeFieldFromArray);const[T,V]=E.useState(null),[I,z]=E.useState(null),O=K5(Co(ts,{activationConstraint:{distance:6}}),Co(es)),P=W=>{var F,Y;const A=(Y=(F=W==null?void 0:W.active)==null?void 0:F.data)==null?void 0:Y.current;A&&V({data:A})},Q=W=>{var F,Y;const A=(Y=(F=W==null?void 0:W.over)==null?void 0:F.data)==null?void 0:Y.current;z(A??null)},te=(W,A)=>W===void 0?A:Math.max(0,Math.min(W,A)),ne=W=>{var U,ee;const A=(ee=(U=W.active)==null?void 0:U.data)==null?void 0:ee.current;let F=null;switch(A==null?void 0:A.kind){case"rows-section":F=["rows-section","tab-section"];break;case"tabs-tab":F=["tabs-tab"];break;case"tab-section":F=["tab-section"];break;case"field-in-rows":F=["rows-column","tabs-column","input-group","array-items"];break;case"field-in-tabs":F=["tabs-column","rows-column","input-group","array-items"];break;case"field-in-inputgroup":F=["input-group"];break;case"field-in-array":F=["array-items"];break;case"palette-field":F=["rows-column","tabs-column","input-group","array-items"];break;default:F=null}const Y=F==null?W.droppableContainers:W.droppableContainers.filter(le=>{var ge,ce;const ue=(ce=(ge=le.data)==null?void 0:ge.current)==null?void 0:ce.scope;return ue&&F.includes(ue)});return Y.length?Y5({...W,droppableContainers:Y}):X5(W)},ae=W=>{var Y,U,ee,le,ue,ge,ce,se,we;const A=(U=(Y=W==null?void 0:W.active)==null?void 0:Y.data)==null?void 0:U.current,F=(le=(ee=W==null?void 0:W.over)==null?void 0:ee.data)==null?void 0:le.current;if(V(null),z(null),!(!A||!F)){if(A.kind==="rows-section"&&F.scope==="rows-section"){const de=A.nodeIdx,me=A.sIdx,R=F.nodeIdx,J=F.insertAt;if(de===R){if(typeof g=="function"){const H=oe.getState().schema.layout[de],L=((ue=H==null?void 0:H.sections)==null?void 0:ue.length)??0,S=te(J,L);if(S!==me){const D=S>me?S-1:S;g(de,me,D)}}}else if(typeof j=="function"){const H=oe.getState().schema.layout[R],L=((ge=H==null?void 0:H.sections)==null?void 0:ge.length)??0,S=te(J,L);j(de,me,R,S)}return}if(A.kind==="rows-section"&&F.scope==="tab-section"){const de=A.nodeIdx,me=A.sIdx,R=F.nodeIdx,J=F.tabKey,H=F.insertAt;typeof k=="function"&&k(de,me,R,J,H);return}if(A.kind==="tabs-tab"&&F.scope==="tabs-tab"){if(typeof x=="function"&&A.nodeIdx===F.nodeIdx){const de=oe.getState().schema.layout[A.nodeIdx],me=((ce=de==null?void 0:de.tabs)==null?void 0:ce.length)??0;x(A.nodeIdx,A.index,te(F.insertAt,me))}return}if(A.kind==="tab-section"&&F.scope==="tab-section"){if(typeof w=="function"&&A.nodeIdx===F.nodeIdx&&A.tabKey===F.tabKey){const de=oe.getState().schema.layout[A.nodeIdx],me=(se=de==null?void 0:de.tabs)==null?void 0:se.find(J=>J.key===A.tabKey),R=((we=me==null?void 0:me.sections)==null?void 0:we.length)??0;w(A.nodeIdx,A.tabKey,A.sIdx,te(F.insertAt,R))}return}if(F.scope==="input-group"){const de=F.groupName,me=F.insertAt;if(A.kind==="field-in-inputgroup"&&A.groupName===de){const R=A.path.idx,J=me??R;typeof C=="function"&&R!==J&&C(de,R,J);return}if(A.kind==="field-in-inputgroup"&&A.groupName!==de){typeof N=="function"&&N(A.groupName,A.path.idx),y==null||y(A.name,de,me);return}if(A.kind==="field-in-rows"){const R=A.rowsNodeIdx??0;typeof h=="function"?h(R,A.path):n({...A.path,nodeIdx:R}),y==null||y(A.name,de,me);return}if(A.kind==="field-in-tabs"){o({tabKey:A.tabKey,...A.path}),y==null||y(A.name,de,me);return}if(A.kind==="palette-field"){const R=oe.getState().schema.fields.length;c(tn(A.factoryKind));const J=oe.getState().schema.fields[R];y==null||y(J.name,de,me);return}}if(A.kind==="field-in-rows"&&F.scope==="rows-column"){const de=A.rowsNodeIdx??0,me=F.rowsNodeIdx??de;typeof f=="function"&&de!==me?f(de,A.path,me,{s:F.s,r:F.r,c:F.c,idx:F.insertAt}):t({...A.path,nodeIdx:de},{nodeIdx:me,s:F.s,r:F.r,c:F.c,idx:F.insertAt});return}if(A.kind==="field-in-tabs"&&F.scope==="tabs-column"&&A.tabKey===F.tabKey){r({tabKey:A.tabKey,...A.path},{tabKey:A.tabKey,s:F.s,r:F.r,c:F.c,idx:F.insertAt});return}if(A.kind==="field-in-tabs"&&F.scope==="tabs-column"&&A.tabKey!==F.tabKey){o({tabKey:A.tabKey,...A.path}),typeof F.insertAt=="number"?i(A.name,F.tabKey,F.s,F.r,F.c,F.insertAt):d(A.name,F.tabKey,F.s,F.r,F.c);return}if(A.kind==="field-in-rows"&&F.scope==="tabs-column"){const de=A.rowsNodeIdx??0;typeof h=="function"?h(de,A.path):n({...A.path,nodeIdx:de}),typeof F.insertAt=="number"?i(A.name,F.tabKey,F.s,F.r,F.c,F.insertAt):d(A.name,F.tabKey,F.s,F.r,F.c);return}if(A.kind==="field-in-tabs"&&F.scope==="rows-column"){o({tabKey:A.tabKey,...A.path});const de=F.rowsNodeIdx??0;if(typeof v=="function"){const me=typeof F.insertAt=="number"?F.insertAt:void 0;typeof me=="number"?v(de,A.name,F.s,F.r,F.c,me):typeof p=="function"?p(de,A.name,F.s,F.r,F.c):m(A.name,de,F.s,F.r,F.c)}else typeof F.insertAt=="number"?l(A.name,F.s,F.r,F.c,F.insertAt):m(A.name,de,F.s,F.r,F.c);return}if(A.kind==="palette-field"){if(F.scope==="rows-column"){const de=F.rowsNodeIdx??0;if(typeof F.insertAt=="number"&&typeof b=="function")b(de,tn(A.factoryKind),F.s,F.r,F.c,F.insertAt);else{const me=oe.getState().schema.fields.length;c(tn(A.factoryKind));const R=oe.getState().schema.fields[me];typeof p=="function"?p(de,R.name,F.s,F.r,F.c):m(R.name,de,F.s,F.r,F.c)}return}if(F.scope==="tabs-column"){if(typeof F.insertAt=="number"&&typeof u=="function")u(tn(A.factoryKind),F.tabKey,F.s,F.r,F.c,F.insertAt);else{const de=oe.getState().schema.fields.length;c(tn(A.factoryKind));const me=oe.getState().schema.fields[de];d(me.name,F.tabKey,F.s,F.r,F.c)}return}if(F.scope==="array-items"){const de=F.arrayName,me=F.insertAt;if(typeof M=="function"){const R=tn(A.factoryKind);M(de,R,me)}return}}if(F.scope==="array-items"){const de=F.arrayName,me=F.insertAt;if(A.kind==="field-in-array"){if(A.arrayName===de){const J=A.index;typeof $=="function"&&J!==me&&$(de,J,me)}return}if(A.kind==="field-in-rows"||A.kind==="field-in-tabs"||A.kind==="field-in-inputgroup"){const R=A.name,J=oe.getState(),H=J.schema.fields.find(L=>L.name===R);if(H){const L=JSON.parse(JSON.stringify(H));J.removeField&&J.removeField(R),typeof M=="function"&&M(de,L,me)}return}}}};return s.jsxs(h1,{sensors:O,collisionDetection:ne,onDragStart:P,onDragOver:Q,onDragEnd:ae,modifiers:[KT],children:[e,s.jsx(g1,{children:JT(T)})]})}function XT({code:e,language:t="json"}){const{t:r}=Ct(),n=E.useMemo(()=>e.split(`
304
+ `),[e]),[o,l]=E.useState(!1),i=()=>{navigator.clipboard.writeText(e),l(!0),setTimeout(()=>l(!1),2e3)},c=(u,d)=>{if(!u)return s.jsx("span",{className:"inline-block w-full",children:" "});const m={keyword:"text-purple-600 dark:text-purple-400 font-bold",string:"text-green-600 dark:text-green-400",number:"text-blue-600 dark:text-blue-400",boolean:"text-blue-600 dark:text-blue-400 font-bold",comment:"text-gray-500 italic",punctuation:"text-gray-500 dark:text-gray-400",property:"text-sky-700 dark:text-sky-300",type:"text-yellow-600 dark:text-yellow-400"},f=[];let h=0;if(d==="json"){const p=/(".*?")(\s*:)?|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|([{},[\]])|([^\s]+)/g;let v,b=0;for(;(v=p.exec(u))!==null;){v.index>b&&f.push(s.jsx("span",{children:u.substring(b,v.index)},h++));const g=v[0],[x,w,j,k,y,C,N]=v;w?j?(f.push(s.jsx("span",{className:m.property,children:w},h++)),f.push(s.jsx("span",{className:m.punctuation,children:":"},h++))):f.push(s.jsx("span",{className:m.string,children:w},h++)):k?f.push(s.jsx("span",{className:m.boolean,children:k},h++)):y?f.push(s.jsx("span",{className:m.number,children:y},h++)):C?f.push(s.jsx("span",{className:m.punctuation,children:C},h++)):f.push(s.jsx("span",{children:g},h++)),b=p.lastIndex}return b<u.length&&f.push(s.jsx("span",{children:u.substring(b)},h++)),f}if(d==="typescript"||d==="yup"){const p="\\b(export|import|const|let|var|function|return|if|else|interface|type|from|as)\\b",v=new RegExp(`(\\/\\/.*)|(["'].*?["'])|(${p})|(\\b\\d+\\b)|(\\b[A-Z][a-zA-Z0-9]*\\b)|([{}[\\](),.;:])`,"g");let b,g=0;for(;(b=v.exec(u))!==null;){b.index>g&&f.push(s.jsx("span",{children:u.substring(g,b.index)},h++));const[x,w,j,k,y,C,N]=b;w?f.push(s.jsx("span",{className:m.comment,children:w},h++)):j?f.push(s.jsx("span",{className:m.string,children:j},h++)):k?f.push(s.jsx("span",{className:m.keyword,children:k},h++)):y?f.push(s.jsx("span",{className:m.number,children:y},h++)):C?f.push(s.jsx("span",{className:m.type,children:C},h++)):N?f.push(s.jsx("span",{className:m.punctuation,children:N},h++)):f.push(s.jsx("span",{children:x},h++)),g=v.lastIndex}return g<u.length&&f.push(s.jsx("span",{children:u.substring(g)},h++)),f}return u&&f.push(s.jsx("span",{children:u},h++)),f};return s.jsxs("div",{className:"flex-1 min-h-0 w-full bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)] font-mono text-sm flex flex-col relative group/codeviewer",children:[s.jsx("button",{onClick:i,className:he("absolute top-4 right-6 z-30 p-2 rounded-md transition-all duration-200","bg-[var(--color-ds-background-surface)] border border-[var(--color-ds-border-default)] shadow-sm","text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)] hover:border-[var(--color-ds-border-default-50)]","opacity-0 group-hover/codeviewer:opacity-100",o&&"opacity-100 border-green-500 text-green-600"),title:r("ds.editor.codeViewer.copy"),children:o?s.jsx(Br,{className:"w-4 h-4"}):s.jsx(Fl,{className:"w-4 h-4"})}),s.jsx("div",{className:"flex-1 min-h-0 relative outline-none",tabIndex:0,onClick:u=>{u.currentTarget.tabIndex>=0&&document.activeElement!==u.currentTarget&&u.currentTarget.focus({preventScroll:!0})},onKeyDown:u=>{if((u.ctrlKey||u.metaKey)&&u.key.toLowerCase()==="a"){u.preventDefault();const d=u.currentTarget.querySelector(".code-content-container");if(d){const m=document.createRange();m.selectNodeContents(d);const f=window.getSelection();f&&(f.removeAllRanges(),f.addRange(m))}}},children:s.jsx(bo,{className:"w-full bg-[var(--color-ds-background-page)]",children:s.jsx("div",{className:"min-w-fit min-h-full py-2 code-content-container",children:n.map((u,d)=>{const m=u.match(/^(\s*)/),f=m?m[1].length:0;return s.jsxs("div",{className:"flex leading-6 hover:bg-[color-mix(in_srgb,var(--color-ds-text-primary)_5%,transparent)] group relative",children:[s.jsx("div",{className:"absolute left-12 top-0 bottom-0 pointer-events-none select-none opacity-20",style:{width:`${f}ch`,background:"repeating-linear-gradient(to right, var(--color-ds-border-default-50) 0px, var(--color-ds-border-default-50) 1px, transparent 1px, transparent 2ch)"}}),s.jsx("div",{className:he("sticky left-0 z-20 w-12 shrink-0 text-right pr-4 select-none user-select-none","text-[var(--color-ds-text-secondary)] opacity-40","border-r border-[var(--color-ds-border-default-50)]/30 mr-4","bg-[var(--color-ds-background-page)]","group-hover:text-[var(--color-ds-text-primary)] group-hover:opacity-100 transition-colors"),style:{userSelect:"none"},children:d+1}),s.jsx("pre",{className:"flex-1 m-0 font-mono whitespace-pre text-[var(--color-ds-text-primary)] relative z-10",children:c(u,t)})]},d)})})})}),s.jsxs("div",{className:"flex items-center justify-between px-3 py-1 bg-[var(--color-ds-button-primary-bg)] text-[var(--color-ds-button-primary-text)] text-xs select-none",children:[s.jsx("div",{className:"flex items-center gap-4",children:s.jsxs("span",{className:"font-semibold uppercase flex items-center gap-1",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-[var(--rel-color-visible)]"}),t]})}),s.jsxs("div",{className:"flex items-center gap-4 opacity-80",children:[s.jsxs("span",{children:[n.length," ",r("ds.editor.codeViewer.lines")]}),s.jsx("span",{children:"UTF-8"}),s.jsx("span",{children:t==="json"?"JSON":"TypeScript"})]})]})]})}function QT({selected:e,onSelect:t}){const{services:r}=St(),n=E.useMemo(()=>{const c=(r==null?void 0:r.registry)||{},u=new Set;return Object.keys(c).forEach(d=>{const m=d.split(".");m.length>0&&u.add(m[0])}),Array.from(u).sort()},[r]),o=[{id:"json",label:"schema.json",icon:Cn},{id:"yup",label:"validation.ts",icon:Xt},{id:"translations",label:"translations.json",icon:To}],l=[];n.length>0?(l.push({id:"adapters",label:"📁 services/",icon:bd}),l.push({id:"adapters",label:" index.ts",icon:Xt,indent:!0}),n.forEach(c=>{const u=c.replace(/[^a-zA-Z0-9]/g," ").split(" ").filter(Boolean).map(d=>d.charAt(0).toUpperCase()+d.slice(1)).join("");l.push({id:`service-${c}`,label:` ${u}Service.ts`,icon:Xt,indent:!0})})):l.push({id:"adapters",label:"generated-services.ts",icon:Xt}),l.push({id:"metadata",label:"generated-metadata.ts",icon:Xt});const i=[...o,...l];return s.jsxs("div",{className:"h-full flex flex-col bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)]",children:[s.jsx("div",{className:"px-4 py-2 border-b border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)] shrink-0 flex items-center h-[41px]",children:s.jsx("strong",{className:"text-[var(--color-ds-text-primary)]",children:"Archivos"})}),s.jsx("div",{className:"flex-1 py-1 overflow-y-auto",children:i.map((c,u)=>{const d=e===c.id,m=c.label.includes("📁");return s.jsxs("button",{onClick:()=>!m&&t(c.id),className:he("w-full flex items-center gap-2 px-4 py-1.5 text-sm transition-colors text-left border-l-2",m&&"cursor-default opacity-60",!m&&d?"bg-[color-mix(in_srgb,var(--color-ds-button-primary-bg)_10%,transparent)] border-[var(--color-ds-button-primary-bg)] text-[var(--color-ds-text-primary)]":"border-transparent text-[var(--color-ds-text-secondary)] hover:text-[var(--color-ds-text-primary)] hover:bg-[var(--color-ds-background-neutral-hover)]",c.indent&&"pl-6"),disabled:m,children:[!m&&s.jsx(c.icon,{className:he("w-4 h-4 shrink-0",d?"text-[var(--color-ds-button-primary-bg)]":"opacity-70")}),s.jsx("span",{className:"truncate font-mono text-xs",children:c.label})]},`${c.id}-${u}`)})})]})}function eB({value:e,onChange:t}){const r=E.useMemo(()=>[{id:"mobile",label:"Mobile (375px)",icon:fd},{id:"tablet",label:"Tablet (768px)",icon:md},{id:"desktop",label:"Desktop (100%)",icon:Tl}],[]);return s.jsx(xa,{value:e,onChange:t,items:r,variant:"square",size:"sm"})}function tB(){const{t:e,i18n:t}=Ct(),r=oe(M=>M.schema),n=oe(M=>M.mode),o=oe(M=>M.activeVariantId),l=E.useMemo(()=>{var M;if(!(!o||!r.variants))return((M=r.variants.find($=>$.key===o))==null?void 0:M.label)||o},[r.variants,o]),{translations:i,services:c}=St(),u=oe(M=>M.setSchema??M.updateSchema??M.replaceSchema),d=oe(M=>M.setSelection),m=oe(M=>M.editorSettings),[f,h]=E.useState("desktop"),[p,v]=E.useState("json"),[b,g]=E.useState(""),x=oe(M=>M.recoverOrphans);E.useEffect(()=>{x==null||x()},[x]),E.useEffect(()=>{const M=(m==null?void 0:m.theme)||"system";M==="dark"||M==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches?(document.documentElement.setAttribute("data-mode","dark"),document.documentElement.classList.add("dark")):(document.documentElement.removeAttribute("data-mode"),document.documentElement.classList.remove("dark"))},[m==null?void 0:m.theme]),E.useEffect(()=>{if(n==="code"){if(p==="json")g(JSON.stringify(r,null,2));else if(p==="yup")try{const M=Ii(r,"validationSchema");g(M)}catch(M){g(`// Error generating Yup code
305
305
  `+String(M))}else if(p==="translations")try{const M=Fi(r,i,t);g(JSON.stringify(M,null,2))}catch(M){g(`// Error generating translations
306
306
  `+String(M))}else if(p==="adapters"||p.startsWith("service-"))try{const M=(c==null?void 0:c.registry)||{},$=Object.entries(M);if($.length===0){g(`// Generated Services from OpenAPI
307
307
  // This code is automatically generated when importing OpenAPI specs
@@ -324,7 +324,7 @@ export const generatedMetadata: Record<string, EndpointMetadata> = {
324
324
  // Each endpoint will have: controller, name, type (options/search), parameters
325
325
  };
326
326
  `)}catch(M){g(`// Error generating metadata code
327
- `+String(M))}}},[n,p,r,i,t]);const w=E.useMemo(()=>{try{return ii(ui(r))}catch{return}},[r]),j=qT(r,w,void 0,l),k=E.useCallback(M=>{try{oe.setState($=>({...$,schema:M}));return}catch{}if(u){try{u($=>{$.schema=M});return}catch{}try{u(M);return}catch{}try{u("schema",M)}catch{}}},[u]),y=n==="design",C=n==="preview",N=n==="code";return s.jsx(XT,{children:s.jsxs("div",{className:"flex flex-col h-[calc(100vh-80px)] bg-[var(--color-ds-background-page)] pb-4",children:[s.jsx(V_,{}),s.jsx("div",{className:"flex-1 min-h-0 px-0 my-2",children:s.jsxs("div",{className:"grid grid-cols-[260px_minmax(0,1fr)_320px] gap-4 h-full",children:[s.jsx("div",{className:`min-h-0 h-full transition-opacity duration-200 ${C?"opacity-50 pointer-events-none grayscale":""}`,children:s.jsx("div",{className:"h-full flex flex-col border border-[var(--color-ds-border-default-50)] rounded-xl bg-[var(--color-ds-background-page)] shadow-xl overflow-hidden",children:N?s.jsx(eB,{selected:p,onSelect:v}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-4 py-2 border-b border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)] shrink-0 flex items-center justify-between h-[41px]",children:s.jsx("strong",{className:"text-[var(--color-ds-text-primary)] text-ds-md",children:"Herramientas"})}),s.jsx("div",{className:"flex-1 min-h-0",children:s.jsx(bo,{children:s.jsxs("div",{className:"p-3",children:[s.jsx(v$,{}),s.jsxs("div",{className:"flex items-center gap-2 mt-8 mb-4",children:[s.jsx("span",{className:"h-px flex-1 bg-[var(--color-ds-border-default-50)]"}),s.jsx("span",{className:"text-[10px] uppercase font-bold text-[var(--color-ds-text-secondary)] tracking-widest px-2",children:"Estructura"}),s.jsx("span",{className:"h-px flex-1 bg-[var(--color-ds-border-default-50)]"})]}),s.jsx(sT,{})]})})})]})})}),s.jsx("div",{className:"min-h-0 h-full",children:s.jsxs(D_,{className:"h-full min-h-0 flex flex-col rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-xl overflow-hidden",children:[s.jsxs("div",{className:"px-4 py-2 border-b border-[var(--color-ds-border-default-50)] text-[var(--color-ds-text-primary)] bg-[var(--color-ds-background-surface)] flex items-center justify-between shrink-0",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("strong",{children:e(N?"ds.editor.modes.code":C?"ds.editor.modes.preview":"ds.editor.modes.design")})}),C&&s.jsx(tB,{value:f,onChange:h})]}),N?s.jsx(QT,{code:b,language:["yup","adapters","metadata"].includes(p)?"typescript":"json"}):s.jsx(bo,{children:s.jsx("div",{className:`p-4 pb-6 transition-all duration-300 mx-auto ${C&&f!=="desktop"?"bg-[var(--color-ds-background-neutral)] min-h-full flex flex-col items-center justify-start !p-0":""}`,onDoubleClick:M=>{M.defaultPrevented||d({kind:"none"})},children:C?s.jsx("div",{className:`transition-all duration-300 ease-in-out ${f==="mobile"?"w-[375px] bg-[var(--color-ds-background-page)] min-h-full border-x border-[var(--color-ds-border-default-50)] shadow-2xl":f==="tablet"?"w-[768px] bg-[var(--color-ds-background-page)] min-h-full border-x border-[var(--color-ds-border-default-50)] shadow-xl":"w-full bg-transparent"}`,children:s.jsx(O5,{schema:r,activeVariantId:l})}):s.jsx(MT,{children:s.jsx(UT,{layoutEditMode:!0,schema:r,onSchemaChange:k,deps:{fields:j.fields,fieldsByName:j.fieldsByName,control:j.control,errors:j.formState.errors,isSubmitting:j.formState.isSubmitting,loadingDefaults:!1,asyncOptionsMap:j.asyncOptionsMap,adapterOptionsMap:j.adapterOptionsMap??{},evalContainer:j.evalContainer,disabledMap:j.disabledMap,registry:j.registry,methods:j.methods,translateFn:(M,$)=>ct(e,M,$)}})})})})]})}),s.jsx("div",{className:`min-h-0 h-full transition-opacity duration-200 ${y?"":"opacity-50 pointer-events-none grayscale"}`,children:s.jsx("div",{className:"h-full flex flex-col rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-xl overflow-hidden",children:s.jsx(XI,{})})})]})})]})})}function nB({title:e,baseDir:t="src/schemas",fs:r,services:n,onSchemaChange:o,rightPanel:l,rightPanelWidth:i="320px",rightPanelDefaultOpen:c=!1,rightPanelOpen:u,onRightPanelOpenChange:d,className:m,axiosInstance:f}){const{t:h}=Ct(),p=oe($=>$.schema),v=e||h("ds.editor.title"),b=typeof u=="boolean",[g,x]=E.useState(c),w=b?u:g,j=$=>{b||x($),d==null||d($)};E.useEffect(()=>{o==null||o(p)},[p,o]),E.useEffect(()=>{(!(r!=null&&r.list)||!(r!=null&&r.read)||!(r!=null&&r.write)||!(r!=null&&r.remove))&&console.warn("[SchemaEditorHost] fs adapter incompleto."),n!=null&&n.registry||console.warn("[SchemaEditorHost] services.adapter sin registry.")},[r,n]);const k=!!l,y=l&&w?{paddingRight:`calc(${i} + 1rem)`}:void 0,C={width:i},[N,M]=E.useState(n);return E.useEffect(()=>{M(n)},[n]),E.useEffect(()=>{const $=tu();if($.length>0){console.log(`[SchemaEditorHost] Hydrating ${$.length} saved OpenAPI specs...`);let T={},V={};$.forEach(I=>{try{const z=Oo(I),O=Li(z,f),P=$i(z);T={...T,...O},V={...V,...P}}catch(z){console.error("[SchemaEditorHost] Error hydrating spec:",z)}}),Si(V),M(I=>({...I,registry:{...I.registry,...T}}))}},[]),s.jsx(N5,{value:{fs:r,services:N,setServices:M,baseDir:t,translations:Xn},children:s.jsxs("div",{className:["grid grid-rows-[auto_1fr] h-full min-h-[480px]",m].filter(Boolean).join(" "),children:[s.jsxs("header",{className:"flex items-center justify-between px-4 py-0 bg-[var(--color-ds-background-page)] shrink-0 z-20",children:[s.jsx("div",{className:"flex items-center gap-4",children:s.jsx("h1",{className:"text-sm font-semibold text-[var(--color-ds-text-primary)] leading-tight",children:v})}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-[var(--color-ds-text-secondary)]",children:[s.jsx("span",{className:"opacity-60",children:h("ds.editor.context")}),s.jsx("code",{className:"px-1 py-0.5 rounded bg-[var(--color-ds-background-neutral)] border border-[var(--color-ds-border-default-50)] font-mono text-[var(--color-ds-text-primary)]",children:t})]}),k&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"w-px h-4 bg-[var(--color-ds-border-default-50)]"}),s.jsx(It,{icon:w?ld:sd,onClick:()=>j(!w),ariaLabel:h(w?"ds.editor.toolbar.toggleSidePanel.close":"ds.editor.toolbar.toggleSidePanel.open"),title:h(w?"ds.editor.toolbar.toggleSidePanel.close":"ds.editor.toolbar.toggleSidePanel.open"),className:w?"bg-[var(--color-ds-background-neutral)] text-[var(--color-ds-text-primary)]":"text-[var(--color-ds-text-secondary)]"})]})]})]}),s.jsxs("div",{className:"relative min-h-0 bg-[var(--color-ds-background-page)]",children:[s.jsx("div",{className:"min-h-0 h-full overflow-hidden transition-all duration-300 ease-in-out",style:y,children:s.jsx(rB,{})}),l&&w&&s.jsx("aside",{className:"absolute top-0 bottom-2 right-0 border border-[var(--color-ds-border-default-50)] rounded-xl min-h-0 overflow-hidden bg-[var(--color-ds-background-page)] shadow-xl z-10",style:C,children:s.jsx("div",{className:"h-full flex flex-col",children:l})})]})]})})}function aB({name:e,canUp:t,canDown:r,canLeft:n,canRight:o,onSelect:l,onUp:i,onDown:c,onLeft:u,onRight:d,onDuplicate:m,onRemove:f}){return s.jsxs("div",{className:`group flex items-center justify-between gap-2 rounded-md border px-2 py-1\r
327
+ `+String(M))}}},[n,p,r,i,t]);const w=E.useMemo(()=>{try{return ii(ui(r))}catch{return}},[r]),j=UT(r,w,void 0,l),k=E.useCallback(M=>{try{oe.setState($=>({...$,schema:M}));return}catch{}if(u){try{u($=>{$.schema=M});return}catch{}try{u(M);return}catch{}try{u("schema",M)}catch{}}},[u]),y=n==="design",C=n==="preview",N=n==="code";return s.jsx(YT,{children:s.jsxs("div",{className:"flex flex-col h-[calc(100vh-80px)] bg-[var(--color-ds-background-page)] pb-4",children:[s.jsx(Z_,{}),s.jsx("div",{className:"flex-1 min-h-0 px-0 my-2",children:s.jsxs("div",{className:"grid grid-cols-[260px_minmax(0,1fr)_320px] gap-4 h-full",children:[s.jsx("div",{className:`min-h-0 h-full transition-opacity duration-200 ${C?"opacity-50 pointer-events-none grayscale":""}`,children:s.jsx("div",{className:"h-full flex flex-col border border-[var(--color-ds-border-default-50)] rounded-xl bg-[var(--color-ds-background-page)] shadow-xl overflow-hidden",children:N?s.jsx(QT,{selected:p,onSelect:v}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-4 py-2 border-b border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)] shrink-0 flex items-center justify-between h-[41px]",children:s.jsx("strong",{className:"text-[var(--color-ds-text-primary)] text-ds-md",children:"Herramientas"})}),s.jsx("div",{className:"flex-1 min-h-0",children:s.jsx(bo,{children:s.jsxs("div",{className:"p-3",children:[s.jsx(v$,{}),s.jsxs("div",{className:"flex items-center gap-2 mt-8 mb-4",children:[s.jsx("span",{className:"h-px flex-1 bg-[var(--color-ds-border-default-50)]"}),s.jsx("span",{className:"text-[10px] uppercase font-bold text-[var(--color-ds-text-secondary)] tracking-widest px-2",children:"Estructura"}),s.jsx("span",{className:"h-px flex-1 bg-[var(--color-ds-border-default-50)]"})]}),s.jsx(oT,{})]})})})]})})}),s.jsx("div",{className:"min-h-0 h-full",children:s.jsxs(V_,{className:"h-full min-h-0 flex flex-col rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-xl overflow-hidden",children:[s.jsxs("div",{className:"px-4 py-2 border-b border-[var(--color-ds-border-default-50)] text-[var(--color-ds-text-primary)] bg-[var(--color-ds-background-surface)] flex items-center justify-between shrink-0",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("strong",{children:e(N?"ds.editor.modes.code":C?"ds.editor.modes.preview":"ds.editor.modes.design")})}),C&&s.jsx(eB,{value:f,onChange:h})]}),N?s.jsx(XT,{code:b,language:["yup","adapters","metadata"].includes(p)?"typescript":"json"}):s.jsx(bo,{children:s.jsx("div",{className:`p-4 pb-6 transition-all duration-300 mx-auto ${C&&f!=="desktop"?"bg-[var(--color-ds-background-neutral)] min-h-full flex flex-col items-center justify-start !p-0":""}`,onDoubleClick:M=>{M.defaultPrevented||d({kind:"none"})},children:C?s.jsx("div",{className:`transition-all duration-300 ease-in-out ${f==="mobile"?"w-[375px] bg-[var(--color-ds-background-page)] min-h-full border-x border-[var(--color-ds-border-default-50)] shadow-2xl":f==="tablet"?"w-[768px] bg-[var(--color-ds-background-page)] min-h-full border-x border-[var(--color-ds-border-default-50)] shadow-xl":"w-full bg-transparent"}`,children:s.jsx(O5,{schema:r,activeVariantId:l})}):s.jsx(NT,{children:s.jsx(WT,{layoutEditMode:!0,schema:r,onSchemaChange:k,deps:{fields:j.fields,fieldsByName:j.fieldsByName,control:j.control,errors:j.formState.errors,isSubmitting:j.formState.isSubmitting,loadingDefaults:!1,asyncOptionsMap:j.asyncOptionsMap,adapterOptionsMap:j.adapterOptionsMap??{},evalContainer:j.evalContainer,disabledMap:j.disabledMap,registry:j.registry,methods:j.methods,translateFn:(M,$)=>ct(e,M,$)}})})})})]})}),s.jsx("div",{className:`min-h-0 h-full transition-opacity duration-200 ${y?"":"opacity-50 pointer-events-none grayscale"}`,children:s.jsx("div",{className:"h-full flex flex-col rounded-xl border border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-page)] shadow-xl overflow-hidden",children:s.jsx(XI,{})})})]})})]})})}function rB({title:e,baseDir:t="src/schemas",fs:r,services:n,onSchemaChange:o,rightPanel:l,rightPanelWidth:i="320px",rightPanelDefaultOpen:c=!1,rightPanelOpen:u,onRightPanelOpenChange:d,className:m,axiosInstance:f}){const{t:h}=Ct(),p=oe($=>$.schema),v=e||h("ds.editor.title"),b=typeof u=="boolean",[g,x]=E.useState(c),w=b?u:g,j=$=>{b||x($),d==null||d($)};E.useEffect(()=>{o==null||o(p)},[p,o]),E.useEffect(()=>{(!(r!=null&&r.list)||!(r!=null&&r.read)||!(r!=null&&r.write)||!(r!=null&&r.remove))&&console.warn("[SchemaEditorHost] fs adapter incompleto."),n!=null&&n.registry||console.warn("[SchemaEditorHost] services.adapter sin registry.")},[r,n]);const k=!!l,y=l&&w?{paddingRight:`calc(${i} + 1rem)`}:void 0,C={width:i},[N,M]=E.useState(n);return E.useEffect(()=>{M(n)},[n]),E.useEffect(()=>{const $=tu();if($.length>0){console.log(`[SchemaEditorHost] Hydrating ${$.length} saved OpenAPI specs...`);let T={},V={};$.forEach(I=>{try{const z=Oo(I),O=Li(z,f),P=$i(z);T={...T,...O},V={...V,...P}}catch(z){console.error("[SchemaEditorHost] Error hydrating spec:",z)}}),Si(V),M(I=>({...I,registry:{...I.registry,...T}}))}},[]),s.jsx(N5,{value:{fs:r,services:N,setServices:M,baseDir:t,translations:Xn},children:s.jsxs("div",{className:["grid grid-rows-[auto_1fr] h-full min-h-[480px]",m].filter(Boolean).join(" "),children:[s.jsxs("header",{className:"flex items-center justify-between px-4 py-0 bg-[var(--color-ds-background-page)] shrink-0 z-20",children:[s.jsx("div",{className:"flex items-center gap-4",children:s.jsx("h1",{className:"text-sm font-semibold text-[var(--color-ds-text-primary)] leading-tight",children:v})}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-[var(--color-ds-text-secondary)]",children:[s.jsx("span",{className:"opacity-60",children:h("ds.editor.context")}),s.jsx("code",{className:"px-1 py-0.5 rounded bg-[var(--color-ds-background-neutral)] border border-[var(--color-ds-border-default-50)] font-mono text-[var(--color-ds-text-primary)]",children:t})]}),k&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"w-px h-4 bg-[var(--color-ds-border-default-50)]"}),s.jsx(It,{icon:w?ld:sd,onClick:()=>j(!w),ariaLabel:h(w?"ds.editor.toolbar.toggleSidePanel.close":"ds.editor.toolbar.toggleSidePanel.open"),title:h(w?"ds.editor.toolbar.toggleSidePanel.close":"ds.editor.toolbar.toggleSidePanel.open"),className:w?"bg-[var(--color-ds-background-neutral)] text-[var(--color-ds-text-primary)]":"text-[var(--color-ds-text-secondary)]"})]})]})]}),s.jsxs("div",{className:"relative min-h-0 bg-[var(--color-ds-background-page)]",children:[s.jsx("div",{className:"min-h-0 h-full overflow-hidden transition-all duration-300 ease-in-out",style:y,children:s.jsx(tB,{})}),l&&w&&s.jsx("aside",{className:"absolute top-0 bottom-2 right-0 border border-[var(--color-ds-border-default-50)] rounded-xl min-h-0 overflow-hidden bg-[var(--color-ds-background-page)] shadow-xl z-10",style:C,children:s.jsx("div",{className:"h-full flex flex-col",children:l})})]})]})})}function nB({name:e,canUp:t,canDown:r,canLeft:n,canRight:o,onSelect:l,onUp:i,onDown:c,onLeft:u,onRight:d,onDuplicate:m,onRemove:f}){return s.jsxs("div",{className:`group flex items-center justify-between gap-2 rounded-md border px-2 py-1\r
328
328
  bg-[var(--color-ds-background-surface)]\r
329
329
  border-[var(--color-ds-border-default)]\r
330
- text-[var(--color-ds-text-primary)]`,children:[s.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm hover:underline",onClick:l,children:[s.jsx(Cr,{className:"h-4 w-4 opacity-70"}),e]}),s.jsxs("div",{className:"invisible group-hover:visible flex items-center gap-1",children:[s.jsx(fe,{type:"button",variant:"ghost",ariaLabel:"Subir",icon:Q0,disabled:!t,onClick:i}),s.jsx(fe,{type:"button",variant:"ghost",ariaLabel:"Bajar",icon:G0,disabled:!r,onClick:c}),s.jsx(fe,{type:"button",variant:"ghost",ariaLabel:"Izquierda",icon:J0,disabled:!n,onClick:u}),s.jsx(fe,{type:"button",variant:"ghost",ariaLabel:"Derecha",icon:X0,disabled:!o,onClick:d}),s.jsx(fe,{type:"button",variant:"ghost",ariaLabel:"Duplicar",icon:Zo,onClick:m}),s.jsx(fe,{type:"button",variant:"ghost",ariaLabel:"Quitar",icon:bt,onClick:f})]})]})}function z0({id:e,data:t,className:r}){const{isOver:n,setNodeRef:o}=tr({id:e,data:t});return s.jsx("div",{ref:o,className:he("h-3 -my-1 rounded transition",n?"bg-[var(--color-ds-background-accent)]/30 outline outline-1 outline-[var(--color-ds-border-default-50)]":"bg-transparent",r)})}function oB({id:e,data:t,children:r}){const{isOver:n,setNodeRef:o}=tr({id:e,data:t});return s.jsx("div",{ref:o,className:he("min-h-8 h-full rounded-md border border-dashed flex items-center justify-center","border-[var(--color-ds-border-default-50)] text-[var(--color-ds-text-secondary)] text-ds-sm",n&&"bg-[var(--color-ds-background-accent)]/20"),children:r})}function $l({widthLabel:e,fields:t,indices:r,canMoveLeft:n,canMoveRight:o,onSelect:l,onMove:i,onDuplicate:c,onRemoveAt:u,onPlaceLast:d,placeDisabled:m,readOnly:f=!1,dnd:h}){const{sIdx:p,rIdx:v,cIdx:b}=r,g=w=>h?h.scope==="rows-column"?{scope:"rows-column",rowsNodeIdx:h.rowsNodeIdx,s:p,r:v,c:b,insertAt:w}:{scope:"tabs-column",tabKey:h.tabKey,s:p,r:v,c:b,insertAt:w}:{},x=(h==null?void 0:h.droppableIdBase)??((h==null?void 0:h.scope)==="rows-column"?`rows|s:${p}|r:${v}|c:${b}`:(h==null?void 0:h.scope)==="tabs-column"?`tabs|t:${h==null?void 0:h.tabKey}|s:${p}|r:${v}|c:${b}`:`col|s:${p}|r:${v}|c:${b}`);return s.jsxs("div",{className:he("flex-1 rounded-lg p-2 border border-dashed","bg-[var(--color-ds-background-page)]","border-[var(--color-ds-border-muted)]"),children:[s.jsx("div",{className:"text-[11px] mb-2 text-[var(--color-ds-text-secondary)]",children:e||"flex-1"}),s.jsx("ul",{className:"space-y-1",children:t.length===0?h?s.jsx("li",{children:s.jsx(oB,{id:`dz|${x}|at:0`,data:g(0),children:"Soltar aquí"})}):null:s.jsxs(s.Fragment,{children:[h&&s.jsx("li",{children:s.jsx(z0,{id:`dz|${x}|at:0`,data:g(0)})}),t.map((w,j)=>s.jsxs(E.Fragment,{children:[s.jsx("li",{children:s.jsx(aB,{name:w,canUp:j>0,canDown:j<t.length-1,canLeft:n,canRight:o,onSelect:()=>l(w),onUp:()=>i({s:p,r:v,c:b,idx:j},{idx:j-1}),onDown:()=>i({s:p,r:v,c:b,idx:j},{idx:j+1}),onLeft:()=>n&&i({s:p,r:v,c:b,idx:j},{c:b-1,idx:void 0}),onRight:()=>o&&i({s:p,r:v,c:b,idx:j},{c:b+1,idx:void 0}),onDuplicate:()=>c(w),onRemove:()=>u({s:p,r:v,c:b,idx:j})})}),h&&s.jsx("li",{children:s.jsx(z0,{id:`dz|${x}|at:${j+1}`,data:g(j+1)})})]},`${w}-${j}`))]})}),s.jsx("div",{className:"mt-3",children:s.jsx(fe,{type:"button",variant:"outline",onClick:d,disabled:f||m,"aria-disabled":f||m,children:"Colocar último campo"})})]})}const sB=e=>e.type!=="inputGroup"&&e.type!=="button";function lB(){const e=oe(m=>m.schema),t=oe(m=>m.setSelection),r=oe(m=>m.moveField),n=oe(m=>m.removeFieldFromLayout),o=oe(m=>m.placeFieldInColumn),l=oe(m=>m.duplicateField),[i,c]=E.useState({}),u=E.useMemo(()=>[...e.fields].reverse().find(sB),[e.fields]),d=E.useMemo(()=>{const m=[];return e.layout.forEach((f,h)=>{var p;if(f.type==="rows"&&f.sections.forEach((v,b)=>{const g=s.jsx("div",{className:"space-y-2",children:v.rows.map((x,w)=>s.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${x.columns.length}, minmax(0, 1fr))`},children:x.columns.map((j,k)=>s.jsx($l,{widthLabel:j.width||"flex-1",fields:j.fields??[],indices:{sIdx:b,rIdx:w,cIdx:k},canMoveLeft:k>0,canMoveRight:k<x.columns.length-1,onSelect:y=>t({kind:"field",name:y}),onMove:(y,C)=>r(y,{s:y.s,r:y.r,c:C.c??y.c,idx:C.idx}),onDuplicate:y=>l(y,`${y}_copy`),onRemoveAt:y=>n(y),onPlaceLast:()=>(u==null?void 0:u.name)&&o(u.name,h,b,w,k),placeDisabled:!(u!=null&&u.name)},`col-${b}-${w}-${k}`))},`row-${b}-${w}`))});m.push({id:`rows-${h}-sec-${b}`,title:v.sectionTitle,defaultOpen:v.defaultOpen,content:g})}),f.type==="tabs"){const v=f.tabs.map(j=>({label:j.label,value:j.key})),b=(p=f.tabs[0])==null?void 0:p.key,g=i[h]??b,x={};f.tabs.forEach(j=>{const k=s.jsx("div",{className:"space-y-4",children:j.sections.map((y,C)=>s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-ds-sm font-medium text-[var(--color-ds-text-primary)]",children:y.sectionTitle}),y.rows.map((N,M)=>s.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${N.columns.length}, minmax(0, 1fr))`},children:N.columns.map(($,T)=>s.jsx($l,{widthLabel:$.width||"flex-1",fields:$.fields??[],indices:{sIdx:0,rIdx:0,cIdx:0},canMoveLeft:!1,canMoveRight:!1,onSelect:V=>t({kind:"field",name:V}),onMove:()=>{},onDuplicate:()=>{},onRemoveAt:()=>{},onPlaceLast:()=>{},placeDisabled:!0,readOnly:!0},`tab-${j.key}-col-${M}-${T}`))},`tab-${j.key}-row-${M}`))]},`tab-${j.key}-sec-${C}`))});x[j.key]=k});const w=s.jsx("div",{className:"rounded-lg border border-[var(--color-ds-border-default-50)]",children:s.jsx("div",{className:"p-2 border-b border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)]",children:s.jsx(fr,{options:v,value:g,onChange:j=>c(k=>({...k,[h]:j})),children:x})})});m.push({id:`tabs-${h}`,title:"Contenedor de pestañas",defaultOpen:!0,content:w})}}),m},[e.layout,u==null?void 0:u.name,l,r,o,n,t,i]);return s.jsx("div",{className:"p-3",children:s.jsx(_5,{items:d})})}function iB(e){const t={};return Object.values(e).forEach(r=>{[r.default,...Object.values(r)].forEach(o=>{o&&typeof o=="object"&&"registry"in o&&Object.assign(t,o.registry)})}),{registry:t}}const cB={sm:"text-ds-sm h-8 px-2",md:"text-ds-md h-10 px-3",lg:"text-ds-lg h-12 px-3"};function dB({options:e,value:t,defaultValue:r,onChange:n,columns:o=2,size:l="sm",disabled:i=!1,ariaLabel:c,ariaLabelledBy:u,orientation:d="horizontal",className:m}){const f=t!==void 0,[h,p]=E.useState(r),v=f?t:h,b=E.useMemo(()=>o===4?"grid-cols-4":o===3?"grid-cols-3":"grid-cols-2",[o]),g=E.useCallback(j=>{i||(f||p(j),n==null||n(j))},[i,f,n]),x=E.useRef([]);E.useEffect(()=>{if(!v)return;const j=e.findIndex(k=>k.value===v);j>=0&&x.current[j]},[v,e]);const w=j=>{var C,N;if(i||e.length===0)return;const k=e.findIndex(M=>M.value===v),y=M=>{var T,V;if(k<0){const I=e.findIndex(z=>!z.disabled);I>=0&&(g(e[I].value),(T=x.current[I])==null||T.focus());return}let $=k;for(let I=0;I<e.length;I++)if($=($+M+e.length)%e.length,!e[$].disabled){g(e[$].value),(V=x.current[$])==null||V.focus();break}};switch(j.key){case"ArrowRight":case"ArrowDown":j.preventDefault(),y(1);break;case"ArrowLeft":case"ArrowUp":j.preventDefault(),y(-1);break;case"Home":j.preventDefault();{const M=e.findIndex($=>!$.disabled);M>=0&&(g(e[M].value),(C=x.current[M])==null||C.focus())}break;case"End":j.preventDefault();{const M=[...e].reverse().findIndex($=>!$.disabled);if(M>=0){const $=e.length-1-M;g(e[$].value),(N=x.current[$])==null||N.focus()}}break}};return s.jsx("div",{role:"radiogroup","aria-label":c,"aria-labelledby":c?void 0:u,"aria-orientation":d,className:he("grid gap-2",b,m),onKeyDown:w,children:e.map((j,k)=>{var $;const y=v===j.value,C=i||j.disabled,N=!v&&(($=e.find(T=>!T.disabled))==null?void 0:$.value)===j.value,M=y||N;return s.jsx("button",{ref:T=>{x.current[k]=T},type:"button",role:"radio","aria-checked":y,"aria-disabled":C||void 0,disabled:C,tabIndex:M&&!C?0:-1,onClick:()=>g(j.value),className:he("box-border rounded-lg border transition focus:outline-none","border-[var(--color-ds-border-default)]",!y&&"bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)] hover:bg-[color-mix(in_srgb,var(--color-ds-background-accent)_8%,transparent)]",y&&"bg-[var(--color-ds-background-accent)] text-[var(--color-ds-text-on-accent)] border-transparent","focus-visible:ring-2 focus-visible:ring-[var(--color-ds-background-accent)]",C&&"opacity-60 cursor-not-allowed",cB[l]),children:j.label},j.value)})})}exports.AdaptersProvider=N5;exports.Button=fe;exports.Canvas=lB;exports.Checkbox=rt;exports.ChoiceGroup=dB;exports.CollapsibleSection=ot;exports.ColumnDropZone=$l;exports.CompactAccordion=_5;exports.DateInput=wn;exports.DropdownMenu=sa;exports.FileUploader=li;exports.FormFieldInput=Ho;exports.FormLabel=Wt;exports.FormPageLayout=gM;exports.FormRenderer=O5;exports.Header=I5;exports.Icon=vt;exports.IconButton=It;exports.InfoButton=si;exports.Input=je;exports.InputGroup=fi;exports.LoadingScreen=YA;exports.Modal=Et;exports.OptionGroup=Uo;exports.PageLayout=eO;exports.SchemaEditorHost=nB;exports.ScrollIndicator=bo;exports.SearchField=mi;exports.Select=Ke;exports.Sidebar=F5;exports.SidebarNav=gi;exports.SkeletonLoader=cr;exports.Table=tO;exports.Tabs=fr;exports.TextArea=Nr;exports.ThemeProvider=JA;exports.ThemeToggle=L5;exports.Toast=E5;exports.ToastProvider=CA;exports.Toggle=xa;exports.ToggleSwitch=vi;exports.mergeAdaptersFromGlob=iB;exports.setComponentsLanguage=rA;exports.useToast=qr;
330
+ text-[var(--color-ds-text-primary)]`,children:[s.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm hover:underline",onClick:l,children:[s.jsx(Cr,{className:"h-4 w-4 opacity-70"}),e]}),s.jsxs("div",{className:"invisible group-hover:visible flex items-center gap-1",children:[s.jsx(fe,{type:"button",variant:"ghost",ariaLabel:"Subir",icon:Q0,disabled:!t,onClick:i}),s.jsx(fe,{type:"button",variant:"ghost",ariaLabel:"Bajar",icon:G0,disabled:!r,onClick:c}),s.jsx(fe,{type:"button",variant:"ghost",ariaLabel:"Izquierda",icon:J0,disabled:!n,onClick:u}),s.jsx(fe,{type:"button",variant:"ghost",ariaLabel:"Derecha",icon:X0,disabled:!o,onClick:d}),s.jsx(fe,{type:"button",variant:"ghost",ariaLabel:"Duplicar",icon:Zo,onClick:m}),s.jsx(fe,{type:"button",variant:"ghost",ariaLabel:"Quitar",icon:bt,onClick:f})]})]})}function z0({id:e,data:t,className:r}){const{isOver:n,setNodeRef:o}=tr({id:e,data:t});return s.jsx("div",{ref:o,className:he("h-3 -my-1 rounded transition",n?"bg-[var(--color-ds-background-accent)]/30 outline outline-1 outline-[var(--color-ds-border-default-50)]":"bg-transparent",r)})}function aB({id:e,data:t,children:r}){const{isOver:n,setNodeRef:o}=tr({id:e,data:t});return s.jsx("div",{ref:o,className:he("min-h-8 h-full rounded-md border border-dashed flex items-center justify-center","border-[var(--color-ds-border-default-50)] text-[var(--color-ds-text-secondary)] text-ds-sm",n&&"bg-[var(--color-ds-background-accent)]/20"),children:r})}function $l({widthLabel:e,fields:t,indices:r,canMoveLeft:n,canMoveRight:o,onSelect:l,onMove:i,onDuplicate:c,onRemoveAt:u,onPlaceLast:d,placeDisabled:m,readOnly:f=!1,dnd:h}){const{sIdx:p,rIdx:v,cIdx:b}=r,g=w=>h?h.scope==="rows-column"?{scope:"rows-column",rowsNodeIdx:h.rowsNodeIdx,s:p,r:v,c:b,insertAt:w}:{scope:"tabs-column",tabKey:h.tabKey,s:p,r:v,c:b,insertAt:w}:{},x=(h==null?void 0:h.droppableIdBase)??((h==null?void 0:h.scope)==="rows-column"?`rows|s:${p}|r:${v}|c:${b}`:(h==null?void 0:h.scope)==="tabs-column"?`tabs|t:${h==null?void 0:h.tabKey}|s:${p}|r:${v}|c:${b}`:`col|s:${p}|r:${v}|c:${b}`);return s.jsxs("div",{className:he("flex-1 rounded-lg p-2 border border-dashed","bg-[var(--color-ds-background-page)]","border-[var(--color-ds-border-muted)]"),children:[s.jsx("div",{className:"text-[11px] mb-2 text-[var(--color-ds-text-secondary)]",children:e||"flex-1"}),s.jsx("ul",{className:"space-y-1",children:t.length===0?h?s.jsx("li",{children:s.jsx(aB,{id:`dz|${x}|at:0`,data:g(0),children:"Soltar aquí"})}):null:s.jsxs(s.Fragment,{children:[h&&s.jsx("li",{children:s.jsx(z0,{id:`dz|${x}|at:0`,data:g(0)})}),t.map((w,j)=>s.jsxs(E.Fragment,{children:[s.jsx("li",{children:s.jsx(nB,{name:w,canUp:j>0,canDown:j<t.length-1,canLeft:n,canRight:o,onSelect:()=>l(w),onUp:()=>i({s:p,r:v,c:b,idx:j},{idx:j-1}),onDown:()=>i({s:p,r:v,c:b,idx:j},{idx:j+1}),onLeft:()=>n&&i({s:p,r:v,c:b,idx:j},{c:b-1,idx:void 0}),onRight:()=>o&&i({s:p,r:v,c:b,idx:j},{c:b+1,idx:void 0}),onDuplicate:()=>c(w),onRemove:()=>u({s:p,r:v,c:b,idx:j})})}),h&&s.jsx("li",{children:s.jsx(z0,{id:`dz|${x}|at:${j+1}`,data:g(j+1)})})]},`${w}-${j}`))]})}),s.jsx("div",{className:"mt-3",children:s.jsx(fe,{type:"button",variant:"outline",onClick:d,disabled:f||m,"aria-disabled":f||m,children:"Colocar último campo"})})]})}const oB=e=>e.type!=="inputGroup"&&e.type!=="button";function sB(){const e=oe(m=>m.schema),t=oe(m=>m.setSelection),r=oe(m=>m.moveField),n=oe(m=>m.removeFieldFromLayout),o=oe(m=>m.placeFieldInColumn),l=oe(m=>m.duplicateField),[i,c]=E.useState({}),u=E.useMemo(()=>[...e.fields].reverse().find(oB),[e.fields]),d=E.useMemo(()=>{const m=[];return e.layout.forEach((f,h)=>{var p;if(f.type==="rows"&&f.sections.forEach((v,b)=>{const g=s.jsx("div",{className:"space-y-2",children:v.rows.map((x,w)=>s.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${x.columns.length}, minmax(0, 1fr))`},children:x.columns.map((j,k)=>s.jsx($l,{widthLabel:j.width||"flex-1",fields:j.fields??[],indices:{sIdx:b,rIdx:w,cIdx:k},canMoveLeft:k>0,canMoveRight:k<x.columns.length-1,onSelect:y=>t({kind:"field",name:y}),onMove:(y,C)=>r(y,{s:y.s,r:y.r,c:C.c??y.c,idx:C.idx}),onDuplicate:y=>l(y,`${y}_copy`),onRemoveAt:y=>n(y),onPlaceLast:()=>(u==null?void 0:u.name)&&o(u.name,h,b,w,k),placeDisabled:!(u!=null&&u.name)},`col-${b}-${w}-${k}`))},`row-${b}-${w}`))});m.push({id:`rows-${h}-sec-${b}`,title:v.sectionTitle,defaultOpen:v.defaultOpen,content:g})}),f.type==="tabs"){const v=f.tabs.map(j=>({label:j.label,value:j.key})),b=(p=f.tabs[0])==null?void 0:p.key,g=i[h]??b,x={};f.tabs.forEach(j=>{const k=s.jsx("div",{className:"space-y-4",children:j.sections.map((y,C)=>s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-ds-sm font-medium text-[var(--color-ds-text-primary)]",children:y.sectionTitle}),y.rows.map((N,M)=>s.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${N.columns.length}, minmax(0, 1fr))`},children:N.columns.map(($,T)=>s.jsx($l,{widthLabel:$.width||"flex-1",fields:$.fields??[],indices:{sIdx:0,rIdx:0,cIdx:0},canMoveLeft:!1,canMoveRight:!1,onSelect:V=>t({kind:"field",name:V}),onMove:()=>{},onDuplicate:()=>{},onRemoveAt:()=>{},onPlaceLast:()=>{},placeDisabled:!0,readOnly:!0},`tab-${j.key}-col-${M}-${T}`))},`tab-${j.key}-row-${M}`))]},`tab-${j.key}-sec-${C}`))});x[j.key]=k});const w=s.jsx("div",{className:"rounded-lg border border-[var(--color-ds-border-default-50)]",children:s.jsx("div",{className:"p-2 border-b border-[var(--color-ds-border-default-50)] bg-[var(--color-ds-background-surface)]",children:s.jsx(fr,{options:v,value:g,onChange:j=>c(k=>({...k,[h]:j})),children:x})})});m.push({id:`tabs-${h}`,title:"Contenedor de pestañas",defaultOpen:!0,content:w})}}),m},[e.layout,u==null?void 0:u.name,l,r,o,n,t,i]);return s.jsx("div",{className:"p-3",children:s.jsx(_5,{items:d})})}function lB(e){const t={};return Object.values(e).forEach(r=>{[r.default,...Object.values(r)].forEach(o=>{o&&typeof o=="object"&&"registry"in o&&Object.assign(t,o.registry)})}),{registry:t}}const iB={sm:"text-ds-sm h-8 px-2",md:"text-ds-md h-10 px-3",lg:"text-ds-lg h-12 px-3"};function cB({options:e,value:t,defaultValue:r,onChange:n,columns:o=2,size:l="sm",disabled:i=!1,ariaLabel:c,ariaLabelledBy:u,orientation:d="horizontal",className:m}){const f=t!==void 0,[h,p]=E.useState(r),v=f?t:h,b=E.useMemo(()=>o===4?"grid-cols-4":o===3?"grid-cols-3":"grid-cols-2",[o]),g=E.useCallback(j=>{i||(f||p(j),n==null||n(j))},[i,f,n]),x=E.useRef([]);E.useEffect(()=>{if(!v)return;const j=e.findIndex(k=>k.value===v);j>=0&&x.current[j]},[v,e]);const w=j=>{var C,N;if(i||e.length===0)return;const k=e.findIndex(M=>M.value===v),y=M=>{var T,V;if(k<0){const I=e.findIndex(z=>!z.disabled);I>=0&&(g(e[I].value),(T=x.current[I])==null||T.focus());return}let $=k;for(let I=0;I<e.length;I++)if($=($+M+e.length)%e.length,!e[$].disabled){g(e[$].value),(V=x.current[$])==null||V.focus();break}};switch(j.key){case"ArrowRight":case"ArrowDown":j.preventDefault(),y(1);break;case"ArrowLeft":case"ArrowUp":j.preventDefault(),y(-1);break;case"Home":j.preventDefault();{const M=e.findIndex($=>!$.disabled);M>=0&&(g(e[M].value),(C=x.current[M])==null||C.focus())}break;case"End":j.preventDefault();{const M=[...e].reverse().findIndex($=>!$.disabled);if(M>=0){const $=e.length-1-M;g(e[$].value),(N=x.current[$])==null||N.focus()}}break}};return s.jsx("div",{role:"radiogroup","aria-label":c,"aria-labelledby":c?void 0:u,"aria-orientation":d,className:he("grid gap-2",b,m),onKeyDown:w,children:e.map((j,k)=>{var $;const y=v===j.value,C=i||j.disabled,N=!v&&(($=e.find(T=>!T.disabled))==null?void 0:$.value)===j.value,M=y||N;return s.jsx("button",{ref:T=>{x.current[k]=T},type:"button",role:"radio","aria-checked":y,"aria-disabled":C||void 0,disabled:C,tabIndex:M&&!C?0:-1,onClick:()=>g(j.value),className:he("box-border rounded-lg border transition focus:outline-none","border-[var(--color-ds-border-default)]",!y&&"bg-[var(--color-ds-background-page)] text-[var(--color-ds-text-primary)] hover:bg-[color-mix(in_srgb,var(--color-ds-background-accent)_8%,transparent)]",y&&"bg-[var(--color-ds-background-accent)] text-[var(--color-ds-text-on-accent)] border-transparent","focus-visible:ring-2 focus-visible:ring-[var(--color-ds-background-accent)]",C&&"opacity-60 cursor-not-allowed",iB[l]),children:j.label},j.value)})})}exports.AdaptersProvider=N5;exports.Button=fe;exports.Canvas=sB;exports.Checkbox=rt;exports.ChoiceGroup=cB;exports.CollapsibleSection=ot;exports.ColumnDropZone=$l;exports.CompactAccordion=_5;exports.DateInput=wn;exports.DropdownMenu=sa;exports.FileUploader=li;exports.FormFieldInput=Ho;exports.FormLabel=Wt;exports.FormPageLayout=gM;exports.FormRenderer=O5;exports.Header=I5;exports.Icon=vt;exports.IconButton=It;exports.InfoButton=si;exports.Input=je;exports.InputGroup=fi;exports.LoadingScreen=YA;exports.Modal=Et;exports.OptionGroup=Uo;exports.PageLayout=eO;exports.SchemaEditorHost=rB;exports.ScrollIndicator=bo;exports.SearchField=mi;exports.Select=Ke;exports.Sidebar=F5;exports.SidebarNav=gi;exports.SkeletonLoader=cr;exports.Table=tO;exports.Tabs=fr;exports.TextArea=Nr;exports.ThemeProvider=JA;exports.ThemeToggle=L5;exports.Toast=E5;exports.ToastProvider=CA;exports.Toggle=xa;exports.ToggleSwitch=vi;exports.mergeAdaptersFromGlob=lB;exports.setComponentsLanguage=rA;exports.useToast=qr;