{"version":3,"sources":["https://lively-kernel.org/lively4/lively4-xray/src/client/reactive/babel-plugin-active-expression-rewriting/utils.js"],"names":["GENERATED_IMPORT_IDENTIFIER","getParentWithScope","isVariable","addCustomTemplate","file","name","declar","declarations","identifier","addImport","path","parentPath","isImportNamespaceSpecifier","parentKey","isLabeledStatement","isBreakStatement","isMemberExpression","findParent","par","scope","hasOwnBinding","node"],"mappings":";;;;;;AACQA,iC,gBAAAA,2B;;;;;;;;;;;wCAoEQC,mD;;;;;;;;;;;;;;gCATAC,2C;;;;;;;;;;;;;;uCA1DAC,kD;;;;;;;;;;;;;;AADRH,sE;;;;;;;AACD,eAASG,iBAAT,CAA2BC,IAA3B,EAAiCC,IAAjC,EAAuC;AAC5C,YAAIC,SAASF,KAAKG,YAAL,CAAkBF,IAAlB,CAAb;AACA,YAAIC,MAAJ,EAAY,OAAOA,MAAP;;AAEZ,YAAIE,aAAaJ,KAAKG,YAAL,CAAkBF,IAAlB,IAA0BD,KAAKK,SAAL,CAAe,6BAAf,EAA8CJ,IAA9C,EAAoDA,IAApD,CAA3C;AACAG,mBAAWR,2BAAX,IAA0C,IAA1C;AACA,eAAOQ,UAAP;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACD;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AAEO,eAASN,UAAT,CAAoBQ,IAApB,EAA0B;AAC/B,YAAGA,KAAKC,UAAL,CAAgBC,0BAAhB,MAAgDF,KAAKG,SAAL,KAAmB,OAAtE,EAA+E;AAAE,iBAAO,KAAP;AAAe,SADjE,CACkE;AACjG,YAAGH,KAAKC,UAAL,CAAgBG,kBAAhB,MAAwCJ,KAAKG,SAAL,KAAmB,OAA9D,EAAuE;AAAE,iBAAO,KAAP;AAAe,SAFzD,CAE0D;AACzF,YAAGH,KAAKC,UAAL,CAAgBI,gBAAhB,MAAsCL,KAAKG,SAAL,KAAmB,OAA5D,EAAqE;AAAE,iBAAO,KAAP;AAAe,SAHvD,CAGwD;AACvF,YAAGH,KAAKC,UAAL,CAAgBK,kBAAhB,MAAwCN,KAAKG,SAAL,KAAmB,UAA9D,EAA0E;AAAE,iBAAO,KAAP;AAAe,SAJ5D,CAI6D;;AAE5F,eAAO,IAAP;AACD;;;;AAEM,eAASZ,kBAAT,CAA4BS,IAA5B,EAAkC;AACvC,eAAOA,KAAKO,UAAL,CAAgBC,OAAOA,IAAIC,KAAJ,CAAUC,aAAV,CAAwBV,KAAKW,IAAL,CAAUhB,IAAlC,CAAvB,CAAP;AACD","file":"utils.js","sourcesContent":["\nimport {GENERATED_IMPORT_IDENTIFIER } from './constants.js';\nexport function addCustomTemplate(file, name) {\n  let declar = file.declarations[name];\n  if (declar) return declar;\n\n  let identifier = file.declarations[name] = file.addImport(\"active-expression-rewriting\", name, name);\n  identifier[GENERATED_IMPORT_IDENTIFIER] = true;\n  return identifier;\n\n  // let ref = customTemplates[name];\n  // console.log(file.addImport(\"active-expression-rewriting\", \"aexpr\"));\n  // let uid = file.declarations[name] = file.scope.generateUidIdentifier(name);\n  //\n  // ref = ref().expression;\n  // ref[GENERATED_FUNCTION] = true;\n  //\n  // if (t.isFunctionExpression(ref) && !ref.id) {\n  //     ref.body._compact = true;\n  //     ref._generated = true;\n  //     ref.id = uid;\n  //     ref.type = \"FunctionDeclaration\";\n  //     file.path.unshiftContainer(\"body\", ref);\n  // } else {\n  //     ref._compact = true;\n  //     file.scope.push({\n  //         id: uid,\n  //         init: ref,\n  //         unique: true\n  //     });\n  // }\n  //\n  // return uid;\n}\n\n//     let customTemplates = {};\n//     customTemplates[SET_MEMBER] = template(`\n//   (function(obj, prop, operator, val) {\n//     return obj[prop] = val;\n//   });\n// `);\n//\n//     customTemplates[GET_MEMBER] = template(`\n//   (function(obj, prop) {\n//     return obj[prop];\n//   });\n// `);\n//\n//     customTemplates[GET_AND_CALL_MEMBER] = template(`\n//   (function(obj, prop, args) {\n//     return obj[prop](...args)\n//   });\n// `);\n//\n//     customTemplates[AEXPR_IDENTIFIER_NAME] = template(`\n//   (function(expr) {\n//     return { onChange(cb) {}};\n//   });\n// `);\n\nexport function isVariable(path) {\n  if(path.parentPath.isImportNamespaceSpecifier() && path.parentKey === 'local') { return false; } // import * as foo from 'utils';\n  if(path.parentPath.isLabeledStatement() && path.parentKey === 'label') { return false; } // always: { ... }\n  if(path.parentPath.isBreakStatement() && path.parentKey === 'label') { return false; } // break: foo;\n  if(path.parentPath.isMemberExpression() && path.parentKey === 'property') { return false; } // super.foo\n\n  return true;\n}\n\nexport function getParentWithScope(path) {\n  return path.findParent(par => par.scope.hasOwnBinding(path.node.name));\n}\n"]}