"use strict";const c=require("../../../../../../../../_virtual/cloneNode.js"),O=require("../definitions/index.js");require("../validators/generated/index.js");const m=require("../../../../../../../../_virtual/index35.js");Object.defineProperty(c.__exports,"__esModule",{value:!0});c.__exports.default=v;var u=O.__require(),p=m.__exports;const s=Function.call.bind(Object.prototype.hasOwnProperty);function y(r,e,t,i){return r&&typeof r.type=="string"?g(r,e,t,i):r}function _(r,e,t,i){return Array.isArray(r)?r.map(l=>y(l,e,t,i)):y(r,e,t,i)}function v(r,e=!0,t=!1){return g(r,e,t,new Map)}function g(r,e=!0,t=!1,i){if(!r)return r;const{type:l}=r,n={type:r.type};if((0,p.isIdentifier)(r))n.name=r.name,s(r,"optional")&&typeof r.optional=="boolean"&&(n.optional=r.optional),s(r,"typeAnnotation")&&(n.typeAnnotation=e?_(r.typeAnnotation,!0,t,i):r.typeAnnotation);else if(s(u.NODE_FIELDS,l))for(const a of Object.keys(u.NODE_FIELDS[l]))s(r,a)&&(e?n[a]=(0,p.isFile)(r)&&a==="comments"?f(r.comments,e,t,i):_(r[a],!0,t,i):n[a]=r[a]);else throw new Error(`Unknown node type: "${l}"`);return s(r,"loc")&&(t?n.loc=null:n.loc=r.loc),s(r,"leadingComments")&&(n.leadingComments=f(r.leadingComments,e,t,i)),s(r,"innerComments")&&(n.innerComments=f(r.innerComments,e,t,i)),s(r,"trailingComments")&&(n.trailingComments=f(r.trailingComments,e,t,i)),s(r,"extra")&&(n.extra=Object.assign({},r.extra)),n}function f(r,e,t,i){return!r||!e?r:r.map(l=>{const n=i.get(l);if(n)return n;const{type:a,value:x,loc:N}=l,o={type:a,value:x,loc:N};return t&&(o.loc=null),i.set(l,o),o})}
//# sourceMappingURL=cloneNode.js.map
