{"version":3,"sources":["jsdelivr-header.js","/npm/vue-immutable-props-mixin@1.0.1/src/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,aAEA,IAAI,UAAY,QAAQ,uBAExB,OAAO,QAAU,CACf,QAAS,CAIP,mBAAoB,SAAU,GAC5B,IAAI,EAAQ,KAEZ,KAAgB,kBADK,GACO,aAAe,OAGzC,MAAM,IAAI,UAAU,0DAFpB,EAAqB,iBAAR,EAAmB,CAAC,GAAO,EAK1C,IAAI,EAAW,EAAM,iBAAmB,EAAM,kBAAoB,CAAC,EACnE,EAAI,SAAQ,SAAU,GAEhB,EAAS,GACX,QAAQ,KAAK,YAAc,EAAO,yCAKpC,EAAM,KAAK,EAAO,mBAAoB,EAAM,KAAK,IACjD,EAAM,KAAK,EAAM,UAAU,EAAM,KAAK,KAGtC,EAAS,GAAQ,EAAM,OAAO,EAAO,oBAAoB,SAAU,GACjE,EAAM,KAAK,EAAM,UAAU,GAC7B,GAAG,CAAC,MAAM,IAEZ,IAGI,EAAS,OAAS,UACb,EAAM,gBAGjB,GAGF,QAAS,WACH,KAAK,oBACP,KAAK,mBAAmB,KAAK,mBAEjC,EAEA,cAAe,WACT,KAAK,kBACP,KAAK,iBAAiB,SAAQ,SAAU,GACtC,GACF,GAEJ","file":"/npm/vue-immutable-props-mixin@1.0.1/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/vue-immutable-props-mixin@1.0.1/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict'\n\nvar cloneDeep = require('lodash/cloneDeep.js')\n\nmodule.exports = {\n  methods: {\n    // copy true props to immutable cache, deep copy props to prop name\n    // so that your edition will never change the parent data\n    // and watch the data from parent, if it changes change the deep copy\n    makeImmutableProps: function (arr) {\n      var $this = this;\n      var arrType = typeof arr;\n      if (arrType === 'string' || arr instanceof Array) {\n        arr = typeof arr === 'string' ? [arr] : arr;\n      } else {\n        throw new TypeError('you should pass a string or an array to make immutable');\n      }\n      \n      var iWatcher = $this.immutableWatcher = $this.immutableWatcher || {};\n      arr.forEach(function (item) {\n        \n        if (iWatcher[item]) {\n          console.warn('you turn ' + item + ' to immutable twice, check your code');\n          return;\n        }\n        \n        // init immutable props\n        $this.$set(item + '_immutable_cache', $this.$get(item));\n        $this.$set(item, cloneDeep($this.$get(item)));\n        \n        // everytime parent data changes change the clone\n        iWatcher[item] = $this.$watch(item + '_immutable_cache', function (newVal) {\n          $this.$set(item, cloneDeep(newVal));\n        }, {deep: true});\n        \n      });\n      \n      // if no props need to be made immutable, remove immutableWatcher\n      if (iWatcher.length < 1) {\n        delete $this.immutableWatcher;\n      }\n      \n    }\n  },\n  \n  created: function () {\n    if (this.props_to_immutable) {\n      this.makeImmutableProps(this.props_to_immutable);\n    }\n  },\n  \n  beforeDestroy: function () {\n    if (this.immutableWatcher) {\n      this.immutableWatcher.forEach(function (unwatch) {\n        unwatch();\n      });\n    }\n  }\n}"]}