(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{0:function(e,t,r){"use strict";r.d(t,"z",(function(){return f})),r.d(t,"A",(function(){return I})),r.d(t,"b",(function(){return S})),r.d(t,"C",(function(){return N})),r.d(t,"u",(function(){return T})),r.d(t,"B",(function(){return w})),r.d(t,"e",(function(){return P})),r.d(t,"g",(function(){return E})),r.d(t,"d",(function(){return D})),r.d(t,"l",(function(){return J})),r.d(t,"m",(function(){return M})),r.d(t,"q",(function(){return k})),r.d(t,"r",(function(){return R})),r.d(t,"w",(function(){return V})),r.d(t,"v",(function(){return B})),r.d(t,"x",(function(){return U})),r.d(t,"f",(function(){return z})),r.d(t,"n",(function(){return G})),r.d(t,"p",(function(){return _})),r.d(t,"o",(function(){return X})),r.d(t,"k",(function(){return W})),r.d(t,"s",(function(){return Z})),r.d(t,"t",(function(){return Q})),r.d(t,"i",(function(){return $})),r.d(t,"j",(function(){return H})),r.d(t,"c",(function(){return K})),r.d(t,"h",(function(){return ee})),r.d(t,"y",(function(){return ie}));var n=r(18),o=r(35),c=(r(57),r(2),r(58),r(22),r(9),r(102),r(3),r(96),r(19),r(42),r(6),r(12),r(13),r(23),r(41),function e(t){function r(e,t){return e>>>t|e<<32-t}for(var i,n,o=Math.pow,c=o(2,32),l="",d=[],O=8*t.length,v=e.h=e.h||[],h=e.k=e.k||[],j=h.length,m={},f=2;j<64;f++)if(!m[f]){for(i=0;i<313;i+=f)m[i]=f;v[j]=o(f,.5)*c|0,h[j++]=o(f,1/3)*c|0}for(t+="€";t.length%64-56;)t+="\0";for(i=0;i>8)return;d[i>>2]|=n<<(3-i)%4*8}for(d[d.length]=O/c|0,d[d.length]=O,n=0;n>>3)+y[i-7]+(r(C,17)^r(C,19)^C>>>10)|0);(v=[A+((r(a,2)^r(a,13)^r(a,22))+(a&v[1]^a&v[2]^v[1]&v[2]))|0].concat(v))[4]=v[4]+A|0}for(i=0;i<8;i++)v[i]=v[i]+I[i]|0}for(i=0;i<8;i++)for(n=3;n+1;n--){var b=v[i]>>8*n&255;l+=(b<16?0:"")+b.toString(16)}return l}),l=function(e){var t=function(e){for(var t,r="0123456789ABCDEF",n="",o=0;o>>4&15)+r.charAt(15&t);return n}(function(e){for(var t="",r=0;r<32*e.length;r+=8)t+=String.fromCharCode(e[r>>5]>>>r%32&255);return t}(function(e,t){e[t>>5]|=128<>>9<<4)]=t;for(var r=1732584193,n=-271733879,o=-1732584194,i=271733878,c=0;c>2),r=0;r>5]|=(255&e.charCodeAt(r/8))<>>32-t}(m(m(t,e),m(n,i)),o),r)}function O(e,t,r,n,o,i,c){return d(t&r|~t&n,e,t,o,i,c)}function v(e,t,r,n,o,i,c){return d(t&n|r&~n,e,t,o,i,c)}function h(e,t,r,n,o,i,c){return d(t^r^n,e,t,o,i,c)}function j(e,t,r,n,o,i,c){return d(r^(t|~n),e,t,o,i,c)}function m(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}var f=l,y=c,I=/[^\d]/g,S=/[1-9]+[0-9]+/,C=/\r/g,x=/-|:|T+/g,A=/^([1-3]0|[1-2][1-9]|31|0?[1-9])\/(0[1-9]|10|11|12|[1-9])\/[0-9]{4}$/g;function N(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};B(e)||(e={});var t=e.item||this,r=e.entity||this.entity;return new Promise((function(n,o){try{B(t)||o("Item inválido");var c=r.options.decimalPlaces,l=function(e,t){return"fromUV"===t?parseFloat(e.unitValueCost?((e.unitValue-e.unitValueCost)/e.unitValueCost*100).toFixed(c):0):parseFloat(e.cover?e.cover:e.unitValueCost?((e.unitValue-e.unitValueCost)/e.unitValueCost*100).toFixed(c):0)};if(e.fromUVD)t.discount=parseFloat((100*(1-(t.unitValueDiscount||t.unitValue)/t.unitValue)).toFixed(c));else if(e.fromUV)t.cover=l(t,"fromUV");else if(e.fromC)parseFloat(t.cover)<0&&(t.cover=0),t.unitValue=parseFloat(t.unitValueCost?(t.unitValueCost*(1+.01*t.cover)).toFixed(c):t.unitValue);else if(e.fromA){if(t.amount=parseFloat(t.amount||1),isNaN(t.unitValueDiscount))return;return t.total=parseFloat((t.amount*t.unitValueDiscount).toFixed(c))}t.amount=parseFloat(t.amount||1),t.unitValueCost=parseFloat(parseFloat(t.unitValueCost||0).toFixed(c)),t.unitValue=parseFloat(parseFloat(t.unitValue||0).toFixed(c)),t.cover=l(t),t.discount=parseFloat(t.discount)||null,t.unitValueDiscount=t.discount?parseFloat((t.unitValue*(1-.01*t.discount)).toFixed(c)):t.unitValue;var d=parseFloat((t.unitValueDiscount-(t.unitValueCost||0)).toFixed(2)),O=parseFloat((t.amount*t.unitValue).toFixed(2)),v=parseFloat((t.amount*t.unitValueDiscount).toFixed(2));t.discountTotal=parseFloat((O-v).toFixed(2)),t.costTotal=parseFloat((t.unitValueCost*t.amount).toFixed(2)),t.profitTotal=parseFloat((t.amount*d).toFixed(2)),t.total=parseFloat((t.amount*(t.discount?t.unitValueDiscount:t.unitValue)).toFixed(2)),t.totalWithoutDiscount=parseFloat((t.amount*t.unitValue).toFixed(2)),n(t)}catch(e){o(e)}}))}var T=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{permissions:{}},path=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];try{if(B(e)||(e={permissions:{}}),B(e.permissions)||(e.permissions={}),"string"!=typeof path)return!1;var r=path.split("."),n=r[0],o=r[1],c=n&&o?e.permissions[n]&&e.permissions[n][o]:e.permissions[n];return!c&&t?e.permissions.admin:c}catch(e){return console.error(e),!1}},F="Usuário sem permissão!!!",w={havePermission:T,permissionErrorText:F,pError:F,pEError:"Entidade sem permissão!!!"},P=function(e){return V(e)&&(e="true"===e||"false"!==e&&null),"number"==typeof e&&(0===e?e=!1:1===e&&(e=!0)),!0===e||!1===e?e:null};var E=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=e?String(e).substring(0,10):null,r=String(t).match(A);if(r){var n=String(t).split("/"),o=n[0],c=n[1],l=n[2];e=[l,c,o].join("-")+e.substring(10)}e&&10===String(e).length&&(e+=" 00:00:00");var d=null!==e?new Date(e):null;return isNaN(Date.parse(d))?null:d},D=function(e){return Array.isArray(e)?e:null},J=function(e,t){var r=parseFloat(e);return!isNaN(r)&&isFinite(r)?t?parseFloat(r.toFixed(t)):r:null},M=function(e){var t=parseInt(e);return!isNaN(t)&&isFinite(t)?t:null},k=function e(t){t=B(t)?t:null;var r={};return null!=t&&Object.entries(t).forEach((function(t){r[t[0]]=B(t[1])&&!Date.parse(t[1])?e(t[1]):t[1]})),r},R=function(e){return null!=e&&(e=String(e).replace(C,"")),V(e)?e.trim():null},V=function(e){return"string"==typeof e&&""!==e.trim()};var B=function(e){return e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e},L=function(input){return"[object Date]"===Object.prototype.toString.call(input)},U=function e(t){if(B(t)&&!Date.parse(t)){var r={};return Object.keys(t).forEach((function(n){var o;r[(o=n,o&&"_"===o.substring(0,1)?o:o.replace(/([-_][a-z])/gi,(function(e){return e.toUpperCase().replace("-","").replace("_","")})))]=e(t[n])})),r}return Array.isArray(t)?t.map((function(i){return e(i)})):t},z=function(e){return 1048576*e},G=function(e){return e/1024},_=function(e){return e/1024},X=function(e){return e/1024/1024};function W(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];e&&10===String(e).length&&(e+=" 00:00:00");var r=new Date(e||(t?new Date:void 0)),n=""+(r.getMonth()+1),o=""+r.getDate(),c=r.getFullYear();return n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),[c,n,o].join("-")}function Z(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=new Date(e||(t?new Date:void 0)),n=""+r.getHours(),o=""+r.getMinutes(),c=""+r.getSeconds();return n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),c.length<2&&(c="0"+c),[n,o,c].join(":")}function Q(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=new Date(e||(t?new Date:void 0)),n=""+r.getHours(),o=""+r.getMinutes();return n.length<2&&(n="0"+n),o.length<2&&(o="0"+o),[n,o].join(":")}function $(e,t){var r=e?new Date(e):t?new Date:null;return"".concat(W(r),"T").concat(Z(r))}function H(e,t){var r=e?new Date(e):t?new Date:null;return"".concat(W(r),"T").concat(Q(r))}function K(e){if(!e)return"";var t=String(e).replace(/[^\d]/g,""),r=t.length;return 3===r?t+".":6===r?t.substring(0,3)+"."+t.substring(3,6)+".":9===r?t.substring(0,3)+"."+t.substring(3,6)+"."+t.substring(6,9)+"-":11===r?t.substring(0,3)+"."+t.substring(3,6)+"."+t.substring(6,9)+"-"+t.substring(9,11):12===r?t.substring(0,2)+"."+t.substring(2,5)+"."+t.substring(5,8)+"/"+t.substring(8,12)+"-":14===r?t.substring(0,2)+"."+t.substring(2,5)+"."+t.substring(5,8)+"/"+t.substring(8,12)+"-"+t.substring(12,14):e}var Y=function(e){return 24*parseInt(e)*60*60},ee=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{date:date,days:days,months:months};return function(){var t=e.days,r=e.months,n=e.date||Date.now();return t?n+(t=24*parseInt(t)*60*60*1e3):r?n+(r=parseInt(30.41666666666667*parseInt(r)*24*60*60*1e3)):n}()},te=function(){var e=Object(n.a)(regeneratorRuntime.mark((function e(table,t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(){var e=Object(n.a)(regeneratorRuntime.mark((function e(o,c){var l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,l={entity_id:t},e.next=4,r(table).where(l).whereNotNull("personal_id").orderBy("personal_id","desc").first().then(Object(n.a)(regeneratorRuntime.mark((function e(){var t,r=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{personal_id:0},e.abrupt("return",o(parseInt(t.personal_id)+1));case 2:case"end":return e.stop()}}),e)})))).catch(c);case 4:e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),c(e.t0);case 9:case"end":return e.stop()}}),e,null,[[0,6]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),ie=function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{keepFalse:!0,keepNull:!0,keepZeros:!0,keepEmpty:!1};B(r)||(r={keepFalse:!0,keepNull:!0});var n=null===P(r.keepFalse)||r.keepFalse,c=null===P(r.keepNull)||r.keepNull,l=null===P(r.keepZeros)||r.keepZeros,d=null!==P(r.keepEmpty)&&r.keepEmpty,O=function(t,O){if(null===O[1]&&!c)return t;if(null===O[1]&&c)t[O[0]]=O[1];else{if(void 0===O[1])return t;if(JSON.stringify(O[1])===JSON.stringify([])){if(!d)return t;t[O[0]]=O[1]}else if(JSON.stringify(O[1])===JSON.stringify({})){if(!d)return t;t[O[0]]=O[1]}else L(O[1])?t[O[0]]=O[1]:"boolean"==typeof O[1]||"number"==typeof O[1]||"string"==typeof O[1]?("boolean"==typeof O[1]&&n||"number"==typeof O[1]&&0===parseInt(O[1])&&l||O[1])&&(t[O[0]]=O[1]):"object"!==Object(o.a)(O[1])||Array.isArray(O[1])?Array.isArray(O[1])&&(t[O[0]]=O[1]):(t[O[0]]=e(O[1],r),t[O[0]]||delete t[O[0]])}return t},v={};if(t)return Object.entries(t).reduce(O,v),Object.entries(v).length?v:void 0};t.a={onlyNumbersRegex:I,digitsNotInitWithZeroRegex:S,cpfCnpjRegex:/^\d{2}\.?\d{3}\.?\d{3}\/?\d{4}-?\d{2}$|^\d{3}\.?\d{3}\.?\d{3}-?\d{2}$/,cpfRegex:/^\d{3}\.?\d{3}\.?\d{3}-?\d{2}$/,cnpjRegex:/^\d{2}\.?\d{3}\.?\d{3}\/?\d{4}-?\d{2}$/,passwordRegex:/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,50}$/,ipRegex:/^(([1-2][1-5][1-5]|1[0-9]{0,2}|[0-9])\.){3}([1-2][1-5][1-5]|1[0-9]{0,2}|[0-9])$/,regexToFileName:x,emailRegex:/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/,youtubeRegex:/(?<=v=|\/)([\w\d]|\-|_){11}/,updateItem:N,keysToCamel:U,keysToUnderscore:function(e){var t,r={};for(var n in e)r[(t=n,t.replace(/([A-Z])/g,"_$1").toLowerCase())]=e[n];return r},isObject:B,isDate:L,isString:V,sortProps:function(){function e(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e))+e}return e(0,100)-e(0,100)},getBoolean:P,getString:R,getObject:k,getInt:M,getFloat:J,getMonthPeriodDates:function(e){var t=e?new Date(e):new Date,r=t.getFullYear(),n=t.getMonth()+1,o=t.getMonth()+2,c="01";1===String(n).length&&(n="0"+n),12===o&&(o=1),1===String(o).length&&(o="0"+o);var l=[r,n,c].join("-"),d=[r,o,c].join("-"),O=new Date(l+" 00:00:00"),v=new Date(d+" 23:59:59.999");return{start:O,end:new Date(new Date(v).getTime()-864e5)}},getDate:E,getArray:D,havePermission:T,permission:w,isPromise:function(p){return"object"===Object(o.a)(p)&&"function"==typeof p.then},checkObject:function(e){return null!==e.id&&void 0!==e.id||delete e.id,null!==e.createdAt&&void 0!==e.createdAt||delete e.createdAt,null!==e.updatedAt&&void 0!==e.updatedAt||delete e.updatedAt,null!==e.active&&void 0!==e.active||delete e.active,null!==e.deleted&&void 0!==e.deleted||delete e.deleted,e},getDays:Y,getDateToInput:W,getTimeToInput:Z,getTimeWSToInput:Q,getDateTimeToInput:$,getDateTimeWSToInput:H,getDateTimeString:function(e){return $(e?new Date(e):new Date).replace(x,"")},formatCpfCnpj:K,formatCep:function(e){if(!e)return"";var t=String(e).replace(/[^\d]/g,""),r=t.length;return 5===r?t.substring(0,5)+"-":8===r?t.substring(0,5)+"-"+t.substring(5,8):e},formatPhone:function(e){if(!e)return"";var t=String(e).replace(/[^\d]/g,"");"0"===t.substring(0,1)&&(t=t.substring(1));var r=t.length;return 2===r?"("+t+")":6===r?"("+t.substring(0,2)+") "+t.substring(2,6)+"-":8===r?t.substring(0,4)+"-"+t.substring(4,8):10===r?"("+t.substring(0,2)+") "+t.substring(2,6)+"-"+t.substring(6,10):11===r?"("+t.substring(0,2)+") "+t.substring(2,3)+"-"+t.substring(3,7)+"-"+t.substring(7,11):e},validDate:function(e,t){var r=(new Date).getTime()/1e3;return(e=new Date(e).getTime()/1e3)+Y(t)>r},makeObj:ie,prepareToDB:function(e){null!==e.id&&void 0!==e.id||delete e.id,null!==e.createdAt&&void 0!==e.createdAt||delete e.createdAt,null!==e.created_at&&void 0!==e.created_at||delete e.created_at,null!==e.updatedAt&&void 0!==e.updatedAt||delete e.updatedAt,null!==e.updated_at&&void 0!==e.updated_at||delete e.updated_at,null!==e.active&&void 0!==e.active||delete e.active,null!==e.deleted&&void 0!==e.deleted||delete e.deleted,Object.entries(e).forEach((function(t){"object"!==Object(o.a)(t[1])||"function"==typeof t[1]||void 0===t[1]||null===t[1]||L(t[1])||(e[t[0]]=JSON.stringify(t[1]),"{}"!==e[t[0]]&&"[]"!==e[t[0]]||(e[t[0]]=null))}))},md5:f,sha256:y,gGetPersonalId:te,getBytesFromMb:z,getKbFromBytes:G,getMbFromKb:_,getMbFromBytes:X,getDateFromNow:ee,getMonthName:function(e){switch(e){case 0:return"Janeiro";case 1:return"Fevereiro";case 2:return"Março";case 3:return"Abril";case 4:return"Maio";case 5:return"Junho";case 6:return"Julho";case 7:return"Agosto";case 8:return"Setembro";case 9:return"Outubro";case 10:return"Novembro";case 11:return"Dezembro"}},getWeekNumber:function(e){for(var t=e?new Date(e):new Date,r=1,n=new Date(t.getFullYear(),0,r),o=1;1!=n.getDay()&&o<7;)r++,o++,n=new Date(t.getFullYear(),0,r);var c=Math.ceil((t-n)/864e5);return Math.ceil(c/7)}}},174:function(e,t,r){r(58),r(13);var n=r(358),o=n.default.models.Property,c=n.default.static.keysToCamel,l=function(area){return parseInt(area)?parseFloat(parseFloat(area).toFixed(2)).toLocaleString("pt-BR",{minimumFractionDigits:0,useGrouping:!0}):""},d={name:"ncp",Property:o,toCC:c,getFeature:function(e){if((e=c(e)).coordinate){e.coordinate.lat=parseFloat(e.coordinate.lat),e.coordinate.lng=parseFloat(e.coordinate.lng);var t=e.coordinate.lat,r=e.coordinate.lng;e.coordinate.string="".concat(t,",").concat(r),e.position=e.coordinate}return e.type="default",e.value=parseFloat(e.value)?parseFloat(parseFloat(e.value).toFixed(2)).toLocaleString("pt-BR",{style:"currency",currency:"BRL"}):"",e.area=l(e.area),e.propertyArea=l(e.propertyArea),e}};e.exports=function(e,t){e.app;t("ncp",d)}},175:function(e,t,r){"use strict";var n=r(11),o=r(251),c=r.n(o),l={install:function(e,t){e.component("VueTinySlider",c.a)}};n.default.use(l)},176:function(e,t,r){"use strict";var n=r(11),o=r(55),c=r(252),l=r(45),d=r(119),O=r(253);o.a.autoAddCss=!1,o.c.add(d.c,d.d,d.a,d.b,l.j,l.k,l.a,l.b,l.h,l.d,O.a,l.i,l.m,l.f,l.l,l.g,l.n,l.e,l.c),n.default.component("font-awesome-icon",c.a)},229:function(e,t,r){var content=r(324);content.__esModule&&(content=content.default),"string"==typeof content&&(content=[[e.i,content,""]]),content.locals&&(e.exports=content.locals);(0,r(67).default)("087bdb5d",content,!0,{sourceMap:!1})},256:function(e,t,r){"use strict";r(323);var n=r(79),component=Object(n.a)({},(function(){var e=this._self._c;return e("div",[e("Nuxt")],1)}),[],!1,null,null,null);t.a=component.exports},263:function(e,t,r){r(264),e.exports=r(265)},315:function(e,t,r){var content=r(316);content.__esModule&&(content=content.default),"string"==typeof content&&(content=[[e.i,content,""]]),content.locals&&(e.exports=content.locals);(0,r(67).default)("b2ce80fa",content,!0,{sourceMap:!1})},316:function(e,t,r){var n=r(66),o=r(257),c=r(317),l=r(318),d=r(319),O=r(320),v=n(!1),h=o(c),j=o(l),m=o(d),f=o(O);v.push([e.i,"@font-face{font-family:Blinker;src:url("+h+")}@font-face{font-family:Blinker;src:url("+j+");font-weight:600}@font-face{font-family:SpaceMono;src:url("+m+")}@font-face{font-family:SpaceMono;src:url("+f+");font-weight:700}.text-mono-weight{font-weight:700}.text-mono,.text-mono-weight{font-family:SpaceMono}.text-center{text-align:center}.text-right{text-align:right}.mt-50{margin-top:50px}",""]),e.exports=v},317:function(e,t,r){e.exports=r.p+"fonts/Blinker-Regular.546d036.ttf"},318:function(e,t,r){e.exports=r.p+"fonts/Blinker-SemiBold.8b82fab.ttf"},319:function(e,t,r){e.exports=r.p+"fonts/SpaceMono-Regular.ab58bed.ttf"},320:function(e,t,r){e.exports=r.p+"fonts/SpaceMono-Bold.1553b1e.ttf"},323:function(e,t,r){"use strict";r(229)},324:function(e,t,r){var n=r(66)(!1);n.push([e.i,'html{font-family:"Source Sans Pro",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:16px;word-spacing:1px;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;box-sizing:border-box}*,:after,:before{box-sizing:border-box;margin:0}.button--green{display:inline-block;border-radius:4px;border:1px solid #3b8070;color:#3b8070;text-decoration:none;padding:10px 30px}.button--green:hover{color:#fff;background-color:#3b8070}.button--grey{display:inline-block;border-radius:4px;border:1px solid #35495e;color:#35495e;text-decoration:none;padding:10px 30px;margin-left:15px}.button--grey:hover{color:#fff;background-color:#35495e}',""]),e.exports=n},325:function(e,t,r){"use strict";r.r(t),r.d(t,"state",(function(){return o})),r.d(t,"mutations",(function(){return c}));var n=r(20),o=(r(39),r(13),r(12),r(4),r(2),r(3),r(96),function(){return{allProperties:[],properties:[],loading:!0,storeQuery:{city:null,district:null,businessType:null,propertyType:null,id:null},features:[]}}),c={setProperties:function(e,t){var r;(r=e.properties).splice.apply(r,[0,e.properties.length].concat(Object(n.a)(t.map(this.$ncp.toCC))))},setFeatures:function(e,t){var r;(r=e.features).splice.apply(r,[0,e.features.length].concat(Object(n.a)(t.map(this.$ncp.getFeature))))},setAllProperties:function(e,t){var r,o,c;t=JSON.parse(JSON.stringify(t)),(r=e.allProperties).splice.apply(r,[0,e.allProperties.length].concat(Object(n.a)(t.map(this.$ncp.toCC)))),(o=e.features).splice.apply(o,[0,e.features.length].concat(Object(n.a)(t.map(this.$ncp.getFeature)))),(c=e.properties).splice.apply(c,[0,e.properties.length].concat(Object(n.a)(t)))},filter:function(e,t){var r,o,c=JSON.parse(JSON.stringify(e.allProperties));t.id?c=c.filter((function(e){return e.personalId==t.id})):Object.entries(t).forEach((function(e){null!==e[1]&&(c=c.filter((function(t){return t[e[0]]==e[1]})))})),(r=e.features).splice.apply(r,[0,e.features.length].concat(Object(n.a)(c.map(this.$ncp.getFeature)))),(o=e.properties).splice.apply(o,[0,e.properties.length].concat(Object(n.a)(c)))},setStoreQuery:function(e,t){e.storeQuery=t},loading:function(e,t){e.loading=t}}},358:function(e,t,r){"use strict";r.r(t),r.d(t,"ncp",(function(){return jr}));var n=r(0),o={havePermission:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},path=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",t=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];try{if("string"!=typeof path)return!1;var r=path.split("."),n=r[0],o=r[1],c=n&&o?e.permissions[n]&&e.permissions[n][o]:e.permissions[n];return!c&&t?e.permissions.admin:c}catch(e){return console.error(e),!1}},errorString:"Usuário sem permissão!!!"},c=(r(15),r(27),r(2),r(39),r(13),r(12),r(3),r(106),r(6),r(5),r(4),r(7),r(8),r(20)),l=r(1),d=(r(9),r(19),r(38),function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),this.id=Object(n.m)(t.id),this.createdAt=Object(n.g)(t.createdAt),this.updatedAt=Object(n.g)(t.updatedAt),this.deleted=Object(n.e)(t.deleted),this.active=Object(n.e)(t.active),this.name=Object(n.r)(t.name),this.description=Object(n.r)(t.description),this.value=Object(n.l)(t.value,2),this.config=new O(t.config,r),this.getTitle=function(){var title="";return e.name&&(title+=e.name),title},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),deleted:Object(n.e)(e.deleted),active:Object(n.e)(e.active),name:Object(n.r)(e.name),description:Object(n.r)(e.description),value:Object(n.l)(e.value,2),config:e.config.getObject()})))}}),O=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),this.options=[],this.userLimit=Object(n.m)(t.userLimit),this.dbLimit=Object(n.m)(t.dbLimit),this.fileLimit=Object(n.m)(t.fileLimit),this.insertOption=function(option){e.options.forEach((function(e){if(JSON.stringify(new v(e,r))===JSON.stringify(new v(option,r)))throw"Opção já consta no plano"})),e.options.push(new v(option,r))},this.removeOption=function(t){if(!e.options[t])throw"Opção inválida";e.options.splice(t,1)},Array.isArray(t.options)&&t.options.forEach((function(option){e.insertOption(option)})),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({options:e.options.map((function(option){return option.getObject()})),userLimit:Object(n.m)(e.userLimit),dbLimit:Object(n.m)(e.dbLimit),fileLimit:Object(n.m)(e.fileLimit)})),{keepNull:!1})}},v=function(){var e=this,option=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(option)||(option={}),Object(n.v)(t)||(t={}),this.recurrenceType=Object(n.r)(option.recurrenceType),this.recurrenceTypeAmount=Object(n.r)(option.recurrenceTypeAmount),this.discount=Object(n.l)(option.discount,2),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({recurrenceType:Object(n.r)(e.recurrenceType),recurrenceTypeAmount:Object(n.r)(e.recurrenceTypeAmount),discount:Object(n.l)(e.discount,2)})),{keepNull:!1})}};d.recurrenceTypeOptions=[{value:"month",text:"Mensal"},{value:"year",text:"Anual"}],d.recurrenceTypeAmountOptions=[{value:1,text:"1"},{value:3,text:"3"},{value:6,text:"6"}];var h=d,j=[{value:"ALAMEDA",text:"ALAMEDA"},{value:"AVENIDA",text:"AVENIDA"},{value:"CHÁCARA",text:"CHÁCARA"},{value:"COLÔNIA",text:"COLÔNIA"},{value:"CONDOMÍNIO",text:"CONDOMÍNIO"},{value:"EQNP",text:"EQNP"},{value:"ESTÂNCIA",text:"ESTÂNCIA"},{value:"ESTRADA",text:"ESTRADA"},{value:"FAZENDA",text:"FAZENDA"},{value:"PRAÇA",text:"PRAÇA"},{value:"PROLONGAMENTO",text:"PROLONGAMENTO"},{value:"RODOVIA",text:"RODOVIA"},{value:"RUA",text:"RUA"},{value:"SÍTIO",text:"SÍTIO"},{value:"TRAVESSA",text:"TRAVESSA"},{value:"VICINAL",text:"VICINAL"}],m=[{value:"BAIRRO",text:"BAIRRO"},{value:"BOSQUE",text:"BOSQUE"},{value:"CHÁCARA",text:"CHÁCARA"},{value:"CONJUNTO",text:"CONJUNTO"},{value:"DESMEMBRAMENTO",text:"DESMEMBRAMENTO"},{value:"DISTRITO",text:"DISTRITO"},{value:"FAVELA",text:"FAVELA"},{value:"FAZENDA",text:"FAZENDA"},{value:"GLEBA",text:"GLEBA"},{value:"HORTO",text:"HORTO"},{value:"JARDIM",text:"JARDIM"},{value:"LOTEAMENTO",text:"LOTEAMENTO"},{value:"NÚCLEO",text:"NÚCLEO"},{value:"PARQUE",text:"PARQUE"},{value:"RESIDENCIAL",text:"RESIDENCIAL"},{value:"SÍTIO",text:"SÍTIO"},{value:"TROPICAL",text:"TROPICAL"},{value:"VILA",text:"VILA"},{value:"ZONA",text:"ZONA"},{value:"CENTRO",text:"CENTRO"},{value:"SETOR",text:"SETOR"}],f=[{value:"01",text:"01 - Dinheiro",textAlt:"Dinheiro"},{value:"02",text:"02 - Cheque",textAlt:"Cheque"},{value:"03",text:"03 - Cartão de Crédito",textAlt:"Cartão de Crédito"},{value:"04",text:"04 - Cartão de Débito",textAlt:"Cartão de Débito"},{value:"05",text:"05 - Crédito Loja",textAlt:"Crédito Loja"},{value:"10",text:"10 - Vale Alimentação",textAlt:"Vale Alimentação"},{value:"11",text:"11 - Vale Refeição",textAlt:"Vale Refeição"},{value:"12",text:"12 - Vale Presente",textAlt:"Vale Presente"},{value:"13",text:"13 - Vale Combustível",textAlt:"Vale Combustível"},{value:"15",text:"15 - Boleto Bancário",textAlt:"Boleto Bancário"},{value:"16",text:"16 - Depósito Bancário",textAlt:"Depósito Bancário"},{value:"17",text:"17 - Pagamento Instantâneo (PIX)",textAlt:"Pagamento Instantâneo (PIX)"},{value:"18",text:"18 - Transferência bancária, Carteira Digital",textAlt:"Transferência bancária, Carteira Digital"},{value:"19",text:"19 - Programa de fidelidade, Cashback, Crédito Virtual",textAlt:"Programa de fidelidade, Cashback, Crédito Virtual"},{value:"90",text:"90 - Sem pagamento"},Object(l.a)({value:"99",text:"99 - Outros"},"text","Outros")],y={finalidadeOptions:[{value:"1",text:"1 - NF-e Normal"},{value:"2",text:"2 - NF-e Complementar"},{value:"3",text:"3 - NF-e Ajuste"},{value:"4",text:"4 - NF-e Devolução de Mercadoria"}],tipoImpressaoOptions:[{value:"0",text:"0 - Sem geração de DANFE"},{value:"1",text:"1 - Modelo Retrato"},{value:"2",text:"2 - Modelo Paisagem"},{value:"3",text:"3 - Modelo Simplificado"}],tipoImpressaoNFCeOptions:[{value:"4",text:"4 - DANFE NFC-e"},{value:"5",text:"5 - DANFE NFC-e em mensagem eletrônica"}],tipoEmissaoOptions:[{value:"1",text:" Emissão normal"},{value:"2",text:"Contingência FS-IA, com impressão do DANFE em formulário de segurança"},{value:"3",text:"Contingência SCAN (Sistema de Contingência do Ambiente Nacional)"},{value:"4",text:"Contingência DPEC (Declaração Prévia da Emissão em Contingência)"},{value:"5",text:"Contingência FS-DA, com impressão do DANFE em formulário de segurança"},{value:"6",text:"Contingência SVC-AN (SEFAZ Virtual de Contingência do AN)"},{value:"7",text:"Contingência SVC-RS (SEFAZ Virtual de Contingência do RS)"}],tipoEmissaoNFCeOptions:[{value:"1",text:"1 - Emissão normal"},{value:"4",text:"4 - Contigência EPEC (Evento Prévio da Emissão em Contigência)"},{value:"9",text:"9 - Contigência off-line da NFC-e"}],codigoIdentificacaoDestinoOptions:[{value:"1",text:"Operação Interna"},{value:"2",text:"Operação Interestadual"},{value:"3",text:"Operação com Exterior"}],regimeTributarioOptions:[{value:0,text:"0 - Nenhum"},{value:1,text:"1 - Simples Nacional"},{value:2,text:"2 - Simples Nacional - Excesso"},{value:3,text:"3 - Normal - Lucro Presumido"},{value:4,text:"4 - Normal - Lucro Real"}],regimeTributarioEspecialOptions:[{value:0,text:"0 - Sem Regime Tributário Especial"},{value:1,text:"1 - Micro Empresa Municipal"},{value:2,text:"2 - Estimativa"},{value:3,text:"3 - Sociedade de Profissionais"},{value:4,text:"4 - Cooperativa"},{value:5,text:"5 - Microempresário Individual - MEI"},{value:6,text:"6 - Microempresa ou Pequeno Porte - ME EPP"}],origemOptions:[{value:"0",text:"0 - Nacional, exceto as indicadas nos códigos 3, 4, 5 e 8"},{value:"1",text:"1 - Estrangeira - Importação direta, exceto a indicada no código 6"},{value:"2",text:"2 - Estrangeira - Adquirida no mercado interno, exceto a indicada no código 7"},{value:"3",text:"3 - Nacional, mercadoria ou bem com Conteúdo de Importação superior a 40% e inferior ou igual a 70%"},{value:"4",text:"4 - Nacional, cuja produção tenha sido feita em conformidade com os processos produtivos básicos de que tratam as legislações citadas nos Ajustes"},{value:"5",text:"5 - Nacional, mercadoria ou bem com Conteúdo de Importação inferior ou igual a 40%"},{value:"6",text:"6 - Estrangeira - Importação direta, sem similar nacional, constante em lista da CAMEX e gás natural"},{value:"7",text:"7 - Estrangeira - Adquirida no mercado interno, sem similar nacional, constante lista CAMEX e gás natural"},{value:"8",text:"8 - Nacional, mercadoria ou bem com Conteúdo de Importação superior a 70%"}],tipoLogradouroOptions:j,tipoBairroOptions:m,icmsCstOptions:[{value:"00",text:"00 - Tributada integralmente"},{value:"10",text:"10 - Tributada e com cobrança do ICMS por substituição tributária"},{value:"20",text:"20 - Com redução da BC"},{value:"30",text:"30 - Isenta / não tributada e com cobrança do ICMS por substituição tributária"},{value:"40",text:"40 - Isenta"},{value:"41",text:"41 - Não tributada"},{value:"50",text:"50 - Com suspensão"},{value:"51",text:"51 - Com diferimento"},{value:"60",text:"60 - ICMS cobrado anteriormente por substituição tributária"},{value:"70",text:"70 - Com redução da BC e cobrança do ICMS por substituição tributária"},{value:"90",text:"90 - Outras"}],icmsCsosnOptions:[{value:"101",text:"101 - Tributação pelo Simples com Permissão de Crédito"},{value:"102",text:"102 - Tributação pelo Simples sem Permissão de Crédito"},{value:"103",text:"103 - Isenção do ICMS no Simples para receita bruta"},{value:"201",text:"201 - Simples Nacional com Permissão de Crédito e ICMS por Substituição Tributária"},{value:"202",text:"202 - Simples Nacional sem Permissão de crédito e com cobrança de ICMS por substituição tributária"},{value:"203",text:"203 - Isenção do ICMS no Simples para faixa da Receita Bruta e com cobrança de ICMS por substituição tributária"},{value:"300",text:"300 - Imunidade"},{value:"400",text:"400 - Não tributado pelo Simples"},{value:"500",text:"500 - ICMS cobrado anteriormente por substituição"},{value:"900",text:"900 - Outros. (neste código estão todas as operações que não se encaixam nos demais já citados)."}],pisCofinsCstOptions:[{value:"01",text:"01 - Operação Tributável (base de cálculo = valor da operação alíquota normal (cumulativo/não cumulativo));"},{value:"02",text:"02 - Operação Tributável (base de cálculo = valor da operação (alíquota diferenciada));"},{value:"03",text:"03 - Operação Tributável (base de cálculo = quantidade vendida x alíquota por unidade de produto);"},{value:"04",text:"04 - Operação Tributável (tributação monofásica (alíquota zero));"},{value:"05",text:"05 - Operação Tributável (Substituição Tributária);"},{value:"06",text:"06 - Operação Tributável (alíquota zero);"},{value:"07",text:"07 - Operação Isenta da Contribuição;"},{value:"08",text:"08 - Operação Sem Incidência da Contribuição;"},{value:"09",text:"09 - Operação com Suspensão da Contribuição;"},{value:"49",text:"49 - Outras Operações de Saída;"},{value:"50",text:"50 - Operação com Direito a Crédito - Vinculada Exclusivamente a Receita Tributada no Mercado Interno;"},{value:"51",text:"51 - Operação com Direito a Crédito - Vinculada Exclusivamente a Receita Não Tributada no Mercado Interno;"},{value:"52",text:"52 - Operação com Direito a Crédito – Vinculada Exclusivamente a Receita de Exportação;"},{value:"53",text:"53 - Operação com Direito a Crédito - Vinculada a Receitas Tributadas e Não-Tributadas no Mercado Interno;"},{value:"54",text:"54 - Operação com Direito a Crédito - Vinculada a Receitas Tributadas no Mercado Interno e de Exportação;"},{value:"55",text:"55 - Operação com Direito a Crédito - Vinculada a Receitas Não-Tributadas no Mercado Interno e de Exportação;"},{value:"56",text:"56 - Operação com Direito a Crédito - Vinculada a Receitas Tributadas e Não-Tributadas no Mercado Interno, e de Exportação;"},{value:"60",text:"60 - Crédito Presumido - Operação de Aquisição Vinculada Exclusivamente a Receita Tributada no Mercado Interno;"},{value:"61",text:"61 - Crédito Presumido - Operação de Aquisição Vinculada Exclusivamente a Receita Não-Tributada no Mercado Interno;"},{value:"62",text:"62 - Crédito Presumido - Operação de Aquisição Vinculada Exclusivamente a Receita de Exportação;"},{value:"63",text:"63 - Crédito Presumido - Operação de Aquisição Vinculada a Receitas Tributadas e Não-Tributadas no Mercado Interno;"},{value:"64",text:"64 - Crédito Presumido - Operação de Aquisição Vinculada a Receitas Tributadas no Mercado Interno e de Exportação;"},{value:"65",text:"65 - Crédito Presumido - Operação de Aquisição Vinculada a Receitas Não-Tributadas no Mercado Interno e de Exportação;"},{value:"66",text:"66 - Crédito Presumido - Operação de Aquisição Vinculada a Receitas Tributadas e Não-Tributadas no Mercado Interno, e de Exportação;"},{value:"67",text:"67 - Crédito Presumido - Outras Operações;"},{value:"70",text:"70 - Operação de Aquisição sem Direito a Crédito;"},{value:"71",text:"71 - Operação de Aquisição com Isenção;"},{value:"72",text:"72 - Operação de Aquisição com Suspensão;"},{value:"73",text:"73 - Operação de Aquisição a Alíquota Zero;"},{value:"74",text:"74 - Operação de Aquisição; sem Incidência da Contribuição;"},{value:"75",text:"75 - Operação de Aquisição por Substituição Tributária;"},{value:"98",text:"98 - Outras Operações de Entrada;"},{value:"99",text:"99 - Outras Operações;"}],pagamentosMeioOptions:f,tipoTributacaoOptions:[{value:1,text:"1 - Isento de ISS"},{value:2,text:"2 - Imune"},{value:3,text:"3 - Não Incidência no Município"},{value:4,text:"4 - Não Tributável"},{value:5,text:"5 - Retido"},{value:6,text:"6 - Tributável Dentro do Município"},{value:7,text:"7 - Tributável Fora do Município"},{value:8,text:"8 - Tributável Dentro do Município pelo tomador"}],exigibilidadeOptions:[{value:1,text:"1 - Exigível"},{value:2,text:"2 - Não Incidência"},{value:3,text:"3 - Isenção"},{value:4,text:"4 - Exportação"},{value:5,text:"5 - Imunidade"},{value:6,text:"6 - Supenso por Ação Judicial"},{value:7,text:"7 - Suspenso por Ação Administrativa"}],deducaoOptions:[{value:0,text:"0 - Sem Deduções"},{value:1,text:"1 - Materiais"},{value:2,text:"2 - Subempreitada de Mão de Obra"},{value:3,text:"3 - Serviços"},{value:4,text:"4 - Produção Externa"},{value:5,text:"5 - Alimentação e Bebidas"},{value:6,text:"6 - Reembolso de Despesas"},{value:7,text:"7 - Repasse Consorciado"},{value:8,text:"8 - Repasse Plano de Saúde"},{value:99,text:"99 - Outras Deduções"}],modalidadeDeterminacaoOptions:[{value:0,text:"0 - Margem Valor Agregado (%)"},{value:1,text:"1 - Pauta (valor)"},{value:2,text:"2 - Preço Tabelado Máx. (valor)"},{value:3,text:"3 - Valor da Operação"}],modalidadeDeterminacaoSTOptions:[{value:0,text:"0 - Preço tabelado ou máximo sugerido"},{value:1,text:"1 - Lista Negativa (valor)"},{value:2,text:"2 - Lista Positiva (valor)"},{value:3,text:"3 - Lista Neutra (valor)"},{value:4,text:"4 - Margem Valor Agregado (%)"},{value:5,text:"5 - Pauta (valor)"}],intermediadorOptions:[{value:0,text:"0 - Operação sem intermediador (em site ou plataforma própria)"},{value:1,text:"1 - Operação em site ou plataforma de terceiros (intermediadores/marketplace"}]};function I(object,e){var t=Object.keys(object);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(object);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(object,e).enumerable}))),t.push.apply(t,r)}return t}function S(e){for(var i=1;i0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{plan:""};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),Object(n.w)(t.historic)&&(t.historic=JSON.parse(t.historic)),Object(n.w)(t.permissions)&&(t.permissions=JSON.parse(t.permissions)),Object(n.w)(t.options)&&(t.options=JSON.parse(t.options)),Object(n.w)(t.gdata)&&(t.gdata=JSON.parse(t.gdata)),this.id=Object(n.m)(t.id),this.planId=Object(n.m)(t.planId),this.name=Object(n.r)(t.name),this.fantasyName=Object(n.r)(t.fantasyName),this.cpfCnpj=Object(n.w)(t.cpfCnpj)?Object(n.r)(t.cpfCnpj.replace(n.A,"")):Object(n.r)(t.cpfCnpj),this.customerSupplierId=Object(n.m)(t.customerSupplierId),this.permissions=new x(t.permissions,r),this.options=new N(t.options),this.gdata=new A(t.gdata),this.historic=Object(n.d)(t.historic),this.logo=Object(n.r)(t.logo),this.createdAt=Object(n.g)(t.createdAt),this.updatedAt=Object(n.g)(t.updatedAt),this.active=Object(n.e)(t.active),this.address=Object(n.r)(t.address),this.addressNumber=Object(n.r)(t.addressNumber),this.district=Object(n.r)(t.district),this.city=Object(n.r)(t.city),this.uf=Object(n.r)(t.uf),this.zipcode=Object(n.r)(t.zipcode),this.ibge=Object(n.r)(t.ibge),this.complement=Object(n.r)(t.complement),this.contactEmail=Object(n.r)(t.contactEmail),this.businessEmail=Object(n.r)(t.businessEmail),this.notificationEmail=Object(n.r)(t.notificationEmail),this.contactPhone=Object(n.r)(t.contactPhone),this.businessPhone=Object(n.r)(t.businessPhone),this.dbSize=Object(n.m)(t.dbSize),this.fileSize=Object(n.m)(t.fileSize),this.users=Object(n.m)(t.users),this.getTitle=function(){var t=Object(n.m)(e.id),r=Object(n.r)(e.name);return t&&r?"".concat(t," - ").concat(r):""},this.insertCertificado=function(t){if(!t.id)throw"Certificado inválido";e.gdata.certificados.find((function(e){return e.id==t.id}))||e.gdata.certificados.push(new Certificado(t))},this.getObject=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{keepFalse:!0,keepNull:!0};Object(n.v)(r)||(r={});var o=JSON.parse(JSON.stringify({id:Object(n.m)(e.id),planId:Object(n.m)(e.planId),name:Object(n.r)(e.name),fantasyName:Object(n.r)(e.fantasyName),cpfCnpj:Object(n.w)(e.cpfCnpj)?Object(n.r)(e.cpfCnpj.replace(n.A,"")):Object(n.r)(e.cpfCnpj),customerSupplierId:Object(n.m)(e.customerSupplierId),permissions:e.permissions.getObject(),options:e.options.getObject(),gdata:e.gdata.getObject(),historic:Object(n.d)(e.historic),logo:Object(n.r)(e.logo),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),address:Object(n.r)(e.address),complement:Object(n.r)(e.complement),addressNumber:Object(n.r)(e.addressNumber),district:Object(n.r)(e.district),city:Object(n.r)(e.city),uf:Object(n.r)(e.uf),zipcode:Object(n.w)(e.zipcode)?Object(n.r)(e.zipcode.replace(n.A,"")):Object(n.r)(e.zipcode),ibge:Object(n.r)(e.ibge),contactEmail:Object(n.r)(e.contactEmail),businessEmail:Object(n.r)(e.businessEmail),notificationEmail:Object(n.r)(e.notificationEmail),contactPhone:Object(n.w)(e.contactPhone)?Object(n.r)(e.contactPhone.replace(n.A,"")):e.contactPhone,businessPhone:Object(n.w)(e.businessPhone)?Object(n.r)(e.businessPhone.replace(n.A,"")):e.businessPhone})),c=JSON.parse(JSON.stringify({id:o.customerSupplierId,name:o.name,fantasyName:o.fantasyName,cpfCnpj:o.cpfCnpj,email:o.contactEmail,phone:o.contactPhone,entityId:1})),l=String(o.cpfCnpj).length,d={entityId:1,customerSupplierId:o.customerSupplierId,name:o.name};11===l?d.cpf=o.cpfCnpj:14===l&&(d.cnpj=o.cpfCnpj);var O=JSON.parse(JSON.stringify(d)),address=JSON.parse(JSON.stringify({entityId:1,customerSupplierId:o.customerSupplierId,type:"general",zipcode:o.zipcode,uf:o.uf,city:o.city,district:o.district,address:o.address,addressNumber:o.addressNumber,ibge:o.ibge}));return t?"customer"===t?Object(n.y)(S(S({},c),{},{person:O}),r):"person"===t?Object(n.y)(O,r):"address"===t?Object(n.y)(address,r):"options"===t?Object(n.y)({id:Object(n.m)(e.id),options:e.options.getObject()},r):"permissions"===t?Object(n.y)({id:Object(n.m)(e.id),permissions:e.permissions.getObject()||{},options:e.options.getObject()||{}},r):void 0:Object(n.y)(o,r)}};function x(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.w)(t)&&(t=JSON.parse(t)),Object(n.v)(t)||(t={}),this.validity=Object(n.g)(t.validity),this.ticket=Object(n.e)(t.ticket),this.asset=Object(n.e)(t.asset),this.invoice=new T(t.invoice),this.retail=Object(n.e)(t.retail),this.service=Object(n.e)(t.service),this.mechanics=Object(n.e)(t.mechanics),this.realState=Object(n.e)(t.realState),this.checkin=Object(n.e)(t.checkin),this.getObject=function(){return JSON.parse(JSON.stringify({validity:Object(n.g)(e.validity),ticket:Object(n.e)(e.ticket),asset:Object(n.e)(e.asset),invoice:e.invoice.getObject(),retail:Object(n.e)(e.retail),service:Object(n.e)(e.service),mechanics:Object(n.e)(e.mechanics),realState:Object(n.e)(e.realState),checkin:Object(n.e)(e.checkin)}))}}var A=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=function(e){var t=this;Object(n.v)(e)||(e={}),this.serie=Object(n.m)(e.serie),this.numero=Object(n.m)(e.numero),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({serie:Object(n.m)(t.serie),numero:Object(n.m)(t.numero)})))}};Object(n.v)(t)||(t={}),this.lote=Object(n.m)(t.lote),this.numeracao=[],this.insertSerie=function(t){if(e.numeracao.find((function(e){return e.serie==t.serie})))throw"Série já consta";e.numeracao.push(new r(t))},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({lote:Object(n.m)(e.lote),numeracao:e.numeracao.map((function(e){return e.getObject()}))})))},Array.isArray(t.numeracao)&&t.numeracao.forEach((function(t){return e.insertSerie(t)}))},o=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.login=Object(n.r)(t.login),this.senha=Object(n.r)(t.senha),this.receitaBruta=Object(n.l)(t.receitaBruta,2),this.lei=Object(n.r)(t.lei),this.dataInicio=Object(n.g)(t.dataInicio),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({login:Object(n.r)(e.login),senha:Object(n.r)(e.senha),receitaBruta:Object(n.l)(e.receitaBruta,2),lei:Object(n.r)(e.lei),dataInicio:Object(n.g)(e.dataInicio)})))}},c=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.envio=Object(n.e)(t.envio),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({envio:Object(n.e)(e.envio)})))}},l=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.ativo=Object(n.e)(t.ativo),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({ativo:Object(n.e)(e.ativo)})))}};Object(n.v)(t)||(t={});var d=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.producao=Object(n.e)(t.producao),this.rps=new r(t.rps),this.prefeitura=new o(t.prefeitura),this.email=new c(t.email),this.calculoAutomaticoIbpt=new l(t.calculoAutomaticoIbpt),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({producao:Object(n.e)(e.producao),rps:e.rps.getObject(),prefeitura:e.prefeitura.getObject(),email:e.email.getObject(),calculoAutomaticoIbpt:e.calculoAutomaticoIbpt.getObject()})))}};this.regimeTributario=Object(n.m)(t.regimeTributario),this.simplesNacional=Object(n.e)(1==this.regimeTributario||2==this.regimeTributario),this.regimeTributarioEspecial=Object(n.m)(t.regimeTributarioEspecial),this.inscricaoEstadual=Object(n.r)(t.inscricaoEstadual),this.inscricaoMunicipal=Object(n.r)(t.inscricaoMunicipal),this.incentivoFiscal=Object(n.e)(t.incentivoFiscal),this.incentivadorCultural=Object(n.e)(t.incentivadorCultural),this.email=Object(n.r)(t.email);var O=j.find((function(e){return e.value==t.tipoLogradouro}));this.tipoLogradouro=O?O.value:null;var v=m.find((function(e){return e.value==t.tipoBairro}));this.tipoBairro=v?v.value:null,this.certificado=Object(n.q)(t.certificado),this.nfse=new d(t.nfse),this.getObject=function(){var t=j.find((function(t){return t.value==e.tipoLogradouro})),r=m.find((function(t){return t.value==e.tipoBairro}));return Object(n.y)(JSON.parse(JSON.stringify({simplesNacional:Object(n.e)(e.simplesNacional),regimeTributario:Object(n.m)(e.regimeTributario),regimeTributarioEspecial:Object(n.m)(e.regimeTributarioEspecial),inscricaoEstadual:Object(n.r)(e.inscricaoEstadual),inscricaoMunicipal:Object(n.r)(e.inscricaoMunicipal),incentivoFiscal:Object(n.e)(e.incentivoFiscal),incentivadorCultural:Object(n.e)(e.incentivadorCultural),email:Object(n.r)(e.email),tipoLogradouro:t,tipoBairro:r,certificado:Object(n.q)(e.certificado),nfse:e.nfse.getObject()})))}};function N(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.w)(t)&&(t=JSON.parse(t)),Object(n.v)(t)||(t={}),Object(n.v)(t.defaultFaAccIds)||(t.defaultFaAccIds={});var r=t.defaultFaAccIds;this.defaultFaAccIds={aReceber:r.aReceber,aPagar:r.aPagar},this.decimalPlaces=Object(n.m)(t.decimalPlaces)?t.decimalPlaces:2,this.dueDateBudget=Object(n.m)(t.dueDateBudget),this.printOnUpperCase=Object(n.e)(t.printOnUpperCase),this.closeOrderWithoutPayment=Object(n.e)(t.closeOrderWithoutPayment),this.getObject=function(){return JSON.parse(JSON.stringify({defaultFaAccIds:Object(n.q)(e.defaultFaAccIds),decimalPlaces:Object(n.m)(e.decimalPlaces),dueDateBudget:Object(n.m)(e.dueDateBudget),printOnUpperCase:Object(n.e)(e.printOnUpperCase),closeOrderWithoutPayment:Object(n.e)(e.closeOrderWithoutPayment)}))}}var T=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.nfe=Object(n.e)(t.nfe),this.nfce=Object(n.e)(t.nfce),this.nfse=Object(n.e)(t.nfse),this.multipleServices=Object(n.e)(t.multipleServices),this.getObject=function(){return JSON.parse(JSON.stringify({nfe:Object(n.e)(e.nfe),nfce:Object(n.e)(e.nfce),nfse:Object(n.e)(e.nfse),multipleServices:Object(n.e)(e.multipleServices)}))}},F="Entidade inválida";C.checkEntities=function(e,t){if(parseInt(e.entityId)&&t.entity&&parseInt(t.entity.id)&&parseInt(t.entity.id)!==parseInt(e.entityId))throw F},C.insertToQuery=function(e,t){t.splice.apply(t,[0,t.length].concat(Object(c.a)(e.map((function(e){return{id:(e=Object(n.x)(e)).id,name:e.name,cpfCnpj:e.cpfCnpj}})))))},C.invalidEntityError=F;var w=C,P=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(e)||(e={}),Object(n.v)(t)||(t={}),Object(n.w)(e.historic)&&(e.historic=JSON.parse(e.historic)),w.checkEntities(e,t),this.id=Object(n.m)(e.id),this.entity=new w(t.entity).getObject("permissions"),this.entityId=parseInt(e.entityId)?e.entityId:this.entity.id||null,this.personalId=Object(n.m)(e.personalId),this.createdAt=Object(n.g)(e.createdAt),this.updatedAt=Object(n.g)(e.updatedAt),this.active=Object(n.e)(e.active),this.deleted=Object(n.e)(e.deleted),this.historic=Object(n.d)(e.historic)},E={ncpObject:P,options:{tzOptions:[{value:"America/Campo_Grande",text:"UTC -4"},{value:"America/Sao_Paulo",text:"UTC -3"}]}},D=[{name:"Planta",type:"list",default:!0,required:!0,fixedList:!0},{name:"Área",type:"list",default:!0,required:!0,fixedList:!0},{name:"Tag",type:"text",unique:!0,required:!0,default:!0,readonly:!0},{name:"Fabricante",type:"list",default:!0,fixedList:!0},{name:"Modelo",type:"list",default:!0,fixedList:!0},{name:"Nome",type:"text",default:!0},{name:"Localização",type:"text",default:!0},{name:"Instalação",type:"date",default:!0,canRemove:!0},{name:"Observações",type:"textArea",default:!0}],J=[{value:"text",text:"Texto"},{value:"textArea",text:"Caixa de Texto"},{value:"number",text:"Número"},{value:"list",text:"Lista"},{value:"date",text:"Data"},{value:"datetime",text:"Data e Hora"}],M=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),r.entity=this.entity,this.name=Object(n.r)(t.name),this.tag=Object(n.r)(t.tag),this.parentId=Object(n.m)(t.parentId),this.properties=[];var o=function(t){if(e.properties.find((function(p){return p.name===t.name})))throw"Propriedade ".concat(t.name," já consta no tipo de ativo")};this.insertProperty=function(t){o(t),e.properties.push(new k(t,r))},this.saveProperty=function(t,n){!isNaN(parseInt(n))&&n>=0?e.properties.splice(n,1,new k(t,r)):(o(t),e.properties.push(new k(t,r)))},this.changePropertyOrder=function(t,n){var o=new k(e.properties[t+n].getObject(),r),c=new k(e.properties[t].getObject(),r);if(-1===n){var l,d=[c,o];(l=e.properties).splice.apply(l,[t+n,2].concat(d))}else if(1===n){var O,v=[o,c];(O=e.properties).splice.apply(O,[t,2].concat(v))}},this.getTitle=function(){var t=e.name,r=e.tag;if(!t&&!r)return"";var title="";return t&&(title+=t),r&&(title+=" - ".concat(r)),title},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),personalId:Object(n.m)(e.personalId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),name:Object(n.r)(e.name),tag:Object(n.r)(e.tag),parentId:Object(n.m)(e.parentId),properties:e.properties.map((function(e){return e.getObject()}))})))},Array.isArray(t.properties)&&t.properties.forEach((function(t){return e.insertProperty(t)})),this.properties.length||D.forEach((function(p){return e.insertProperty(p)}))},k=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=r.entity,c=o.options.decimalPlaces;this.name=Object(n.r)(t.name);var l=J.find((function(e){return e.value===t.type}));this.type=l?l.value:null,this.unique=Object(n.e)(t.unique),this.required=Object(n.e)(t.required),this.default=Object(n.e)(t.default),this.canRemove=Object(n.e)(t.canRemove),this.readonly=Object(n.e)(t.readonly),this.fixedList=Object(n.e)(t.fixedList),this.minimumLength=Object(n.m)(t.minimumLength),this.maximumLength=Object(n.m)(t.maximumLength),this.length=Object(n.m)(t.length),this.minValue=Object(n.l)(t.minValue,c),this.maxValue=Object(n.l)(t.maxValue,c),this.regex=Object(n.r)(t.regex),this.insertListOption=function(option){if(e.listOptions.findIndex((function(e){return e.value==option.value}))>=0)throw"Opção ".concat(option.text," já consta na lista");e.listOptions.push(option)},this.listOptions=[{value:null,text:""}],Array.isArray(t.listOptions)&&t.listOptions.forEach((function(t){t.value&&e.insertListOption(t)})),this.getObject=function(){var t={name:Object(n.r)(e.name),type:Object(n.r)(e.type),unique:Object(n.e)(e.unique),required:Object(n.e)(e.required),default:Object(n.e)(e.default),canRemove:Object(n.e)(e.canRemove),readonly:Object(n.e)(e.readonly),fixedList:Object(n.e)(e.fixedList),minimumLength:Object(n.m)(e.minimumLength),maximumLength:Object(n.m)(e.maximumLength),length:Object(n.m)(e.length),minValue:Object(n.l)(e.minValue,c),maxValue:Object(n.l)(e.maxValue,c),regex:Object(n.r)(e.regex)};return"list"===t.type&&(t.listOptions=Object(n.d)(e.listOptions)),Object(n.y)(JSON.parse(JSON.stringify(t)),{keepFalse:!1,keepNull:!1})}};(M.prototype=Object.create(P.prototype)).constructor=M,M.propertyTypes=J,M.defaultProperties=D,M.Property=k;var R=M,V=(r(22),r(18)),B=(r(57),r(47),r(53),r(355),r(224),["jpeg","png"]),L=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=r.inputFile,image=o&&Object(n.w)(o.type)&&B.find((function(e){return e===o.type.substring(o.type.indexOf("/")+1)})),c=function(){e.src=URL.createObjectURL(o);var link=document.createElement("a");link.href=e.src,link.setAttribute("download",e.name),link.click(),link.remove(),URL.revokeObjectURL(e.src)};o?(this.md5=Object(n.r)(o.md5),this.name=Object(n.r)(o.name),this.size=Object(n.m)(o.size),this.hashed=this.md5+this.name.substring(this.name.lastIndexOf(".")),this.mimetype=o.mimetype||o.type,this.newFile=!0,image&&(this.src=URL.createObjectURL(o)),this.getNewFile=c):(this.md5=Object(n.r)(t.md5),this.name=Object(n.r)(t.name),this.size=Object(n.m)(t.size),this.hashed=Object(n.r)(t.hashed),this.mimetype=Object(n.r)(t.mimetype));var label=z.find((function(label){return label.value==t.label}));this.label=label?label.value:null,this.description=Object(n.r)(t.description),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({md5:Object(n.r)(e.md5),name:Object(n.r)(e.name),size:Object(n.m)(e.size),hashed:Object(n.r)(e.hashed),mimetype:Object(n.r)(e.mimetype),label:Object(n.r)(e.label),description:Object(n.r)(e.description)})))}},U=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e=r?new L(null,{inputFile:e}):new L(e),t.find((function(t){return t.hashed==e.hashed})))throw"Arquivo '".concat(e.name,"' já consta na lista");t.push(e)},z=[{value:"Imagem/Foto",text:"Imagem/Foto"},{value:"Documento",text:"Documento"}];L.getFile=function(e){return new Promise(function(){var t=Object(V.a)(regeneratorRuntime.mark((function t(r,o){var c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:try{(c=new FileReader).readAsBinaryString(e),c.onload=function(){try{e.md5=Object(n.z)(c.result),r(new L(null,{inputFile:e}))}catch(e){o(e)}},c.onerror=function(){throw c.error}}catch(e){o(e)}case 1:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}())},L.insertFile=U,L.insertNewFile=function(e,t){return new Promise(function(){var r=Object(V.a)(regeneratorRuntime.mark((function r(o,c){var l;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:try{(l=new FileReader).readAsBinaryString(e),l.onload=function(){try{e.md5=Object(n.z)(l.result),U(e,t,!0),o(e)}catch(e){c(e)}},l.onerror=function(){throw l.error}}catch(e){c(e)}case 1:case"end":return r.stop()}}),r)})));return function(e,t){return r.apply(this,arguments)}}())};var G=L,_=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),Object(n.w)(t.document)&&(t.document=JSON.parse(t.document)),Object(n.w)(t.images)&&(t.images=JSON.parse(t.images)),Object(n.w)(t.files)&&(t.files=JSON.parse(t.files));var o=r.type,c=t.document||{};if(!o)throw"Impossível Carregar o Ativo sem informar o tipo";w.checkEntities(t,r),P.call(this,t,r),this.type=o,this.assetTypeId=Object(n.m)(t.assetTypeId||o.id),this.document={},o.properties.forEach((function(t){e.document[t.name]="number"===t.type?Object(n.l)(c[t.name]):"text"===t.type||"textArea"===t.type?Object(n.r)(c[t.name]):"list"===t.type?"number"==typeof c[t.name]?Object(n.l)(c[t.name]):Object(n.r)(c[t.name]):Object(n.g)(c[t.name])})),this.images=[],this.files=[],this.insertFile=G.insertFile,this.insertNewFile=G.insertNewFile,this.removeImage=function(t){e.images.splice(t,1)};var l=null;this.getTitle=function(){var t=e.document.Tag?String(e.document.Tag):"";if(!t)return"";var title="";return t&&(title+=t),title},this.getTag=function(){return e.document.Tag||l},this.mountTag=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{siteTag:"",siteAreaTag:"",assetTypeTag:"",id:""};if(!(Object(n.w)(t.siteTag)&&Object(n.w)(t.siteAreaTag)&&Object(n.w)(t.assetTypeTag)&&Object(n.w)(t.id)))throw"Configuração inválida na geração da tag do ativo";var r=t.siteTag,o=t.siteAreaTag,c=t.assetTypeTag,l=t.id;if(4!==r.length)throw"Planta inválida na geração da tag";if(3!==o.length)throw"Área inválida na geração da tag";if(3!==c.length)throw"Tipo do ativo inválido na geração da tag";if(4!==l.length)throw"Número inválido na geração da tag";e.document.Tag=[r,o,c,l].join("-")},this.cleanTag=function(){null===l&&(l=String(e.document.Tag)),e.document.Tag=null},this.getObject=function(){var t=function(e){return e.getObject()};return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),assetTypeId:Object(n.m)(e.assetTypeId),document:Object(n.q)(e.document),images:e.images.map(t),files:e.files.map(t)})))},Array.isArray(t.images)&&t.images.forEach((function(image){return e.insertFile(image,e.images)})),Array.isArray(t.files)&&t.files.forEach((function(t){return e.insertFile(t,e.files)}))};(_.prototype=Object.create(P.prototype)).constructor=_;var X=_,W=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.name=Object(n.r)(t.name),this.tag=Object(n.r)(t.tag),this.description=Object(n.r)(t.description),this.logo=Object(n.r)(t.logo),this.getTitle=function(){var t=e.name?String(e.name):"",r=e.tag?String(e.tag):"";if(t||r){var title="";return t&&(title+=t),r&&(title+=" - ".concat(r)),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),name:Object(n.r)(e.name),tag:Object(n.r)(e.tag),description:Object(n.r)(e.description),logo:Object(n.r)(e.logo)})))}};(W.prototype=Object.create(P.prototype)).constructor=W;var Z=W,Q=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.siteId=Object(n.m)(t.siteId),this.parentId=Object(n.m)(t.parentId),this.name=Object(n.r)(t.name),this.tag=Object(n.r)(t.tag),this.description=Object(n.r)(t.description),this.logo=Object(n.r)(t.logo),this.getTitle=function(){var t=e.name?String(e.name):"",r=e.tag?String(e.tag):"";if(t||r){var title="";return t&&(title+=t),r&&(title+=" - ".concat(r)),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),siteId:Object(n.m)(e.siteId),parentId:Object(n.m)(e.parentId),name:Object(n.r)(e.name),tag:Object(n.r)(e.tag),description:Object(n.r)(e.description),logo:Object(n.r)(e.logo)})))}};(Q.prototype=Object.create(P.prototype)).constructor=Q;var $=Q,H=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.name=Object(n.r)(t.name),this.default=Object(n.e)(t.default)||!1,this.balance=Object(n.l)(t.balance,2)||0,this.config=Object(n.q)(t.config),this.getTitle=function(){var t=e.name?String(e.name):"";if(t){var title="";return t&&(title+=t),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),name:Object(n.r)(e.name),default:Object(n.e)(e.default),config:Object(n.q)(e.config)})))}};(H.prototype=Object.create(P.prototype)).constructor=H,H.defaultAccountsPersonalIds={caixa:1,aReceber:2,aPagar:3};var K=H,Y=(r(58),function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),Object(n.w)(t.gdata)&&(t.gdata=JSON.parse(t.gdata)),Object(n.w)(t.receipt)&&(t.receipt=JSON.parse(t.receipt));var o=r.order;w.checkEntities(t,r),P.call(this,t,r),this.financialAccountId=Object(n.m)(t.financialAccountId),this.pCustomerSupplierId=o?Object(n.m)(o.customerSupplierId):Object(n.m)(t.pCustomerSupplierId),this.rCustomerSupplierId=Object(n.m)(t.rCustomerSupplierId),this.date=Object(n.g)(t.date)||new Date,this.value=Object(n.l)(t.value,2),this.docId=Object(n.r)(t.docId),this.productInvoiceId=Object(n.m)(t.productInvoiceId),this.serviceInvoiceId=Object(n.m)(t.serviceInvoiceId),this.orderId=Object(n.m)(t.orderId)||(o?o.id:null),this.reversed=Object(n.e)(t.reversed),this.gdata=new ee(t.gdata,r),this.receipt=t.receipt?new G(t.receipt):null,this.total=0,this.getTitle=function(){var form=f.find((function(t){return t.value==e.gdata.form})),t=form?form.text.substring(form.text.indexOf("-")+1):null,r=parseFloat(e.value);r&&(r=r.toLocaleString("pt-BR",{style:"currency",currency:"BRL"}));var title="";return t?(t&&(title+=t),r&&(title+=" ".concat(r)),title):""},this.update=function(){var t=e.gdata.fees?parseFloat(e.gdata.fees):null,r=e.gdata.discount?parseFloat(e.gdata.discount):null,n=e.gdata.addition?parseFloat(e.gdata.addition):null,o=parseFloat(e.value);t&&(o=parseFloat((o+t).toFixed(2))),r&&(o=parseFloat((o-r).toFixed(2))),n&&(o=parseFloat((o+n).toFixed(2))),e.total=o},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),financialAccountId:Object(n.m)(e.financialAccountId),pCustomerSupplierId:Object(n.m)(e.pCustomerSupplierId),rCustomerSupplierId:Object(n.m)(e.rCustomerSupplierId),date:Object(n.g)(e.date),value:Object(n.l)(e.value,2),docId:Object(n.r)(e.docId),productInvoiceId:Object(n.m)(e.productInvoiceId),serviceInvoiceId:Object(n.m)(e.serviceInvoiceId),orderId:Object(n.m)(e.orderId),reversed:Object(n.e)(e.reversed),gdata:e.gdata.getObject(),receipt:e.receipt?e.receipt.getObject():null,total:Object(n.l)(e.total,2)})),{keepNull:!1})},this.update()}),ee=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=r.fromPosting,form=f.find((function(e){return e.value==t.form}));this.form=form?form.value:o?"15":"01",this.paymentMethodId=Object(n.m)(t.paymentMethodId),this.cashierId=Object(n.m)(t.cashierId||r.cashierId),this.status=Object(n.r)(t.status),this.change=Object(n.l)(t.change,2),this.discount=Object(n.l)(t.discount,2),this.fees=Object(n.l)(t.fees,2),this.addition=Object(n.l)(t.addition,2),this.tax=Object(n.l)(t.tax,2),this.dueDate=Object(n.g)(t.dueDate)||new Date,this.competence=Object(n.g)(t.competence)||new Date,this.payDate=Object(n.g)(t.payDate),this.occurrence=Object(n.r)(t.occurrence),this.note=Object(n.r)(t.note),this.postings=[],this.insertPosting=function(t){e.postings.find((function(e){return e==t}))||e.postings.push(t)},this.getObject=function(){var form=f.find((function(t){return t.value==e.form}));return Object(n.y)(JSON.parse(JSON.stringify({form:form?form.value:null,paymentMethodId:Object(n.m)(e.paymentMethodId),cashierId:Object(n.m)(e.cashierId),status:Object(n.r)(e.status),change:Object(n.l)(e.change,2),discount:Object(n.l)(e.discount,2),fees:Object(n.l)(e.fees,2),addition:Object(n.l)(e.addition,2),tax:Object(n.l)(e.tax,2),dueDate:Object(n.g)(e.dueDate),competence:Object(n.g)(e.competence),payDate:Object(n.g)(e.payDate),occurrence:Object(n.r)(e.occurrence),note:Object(n.r)(e.note),postings:e.postings.map((function(e){return e.id?e.id:e}))})),{keepZeros:!1,keepNull:!1})},Array.isArray(t.postings)&&t.postings.forEach((function(t){return e.insertPosting(t)}))};(Y.prototype=Object.create(P.prototype)).constructor=Y,Y.occurrenceOptions=[{value:"Única",text:"Única"},{value:"Parcelada",text:"Parcelada",disabled:!0},{value:"Mensal",text:"Mensal",disabled:!0},{value:"Bimestral",text:"Bimestral",disabled:!0},{value:"Trimestral",text:"Trimestral",disabled:!0},{value:"Semestral",text:"Semestral",disabled:!0},{value:"Anual",text:"Anual",disabled:!0}];var te=Y,ie=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),this.id=Object(n.m)(t.id),this.entity=new w(r.entity).getObject("permissions"),this.entityId=parseInt(t.entityId)?t.entityId:this.entity.id||null,this.date=Object(n.g)(t.date),this.financialAccountId=Object(n.m)(t.financialAccountId),this.value=Object(n.l)(t.value,2),this.paymentMethodId=Object(n.m)(t.paymentMethodId),this.payments=[],this.in=Object(n.e)(t.in),this.userId=Object(n.m)(t.userId||(r.user&&r.user.id?r.user.id:null)),this.note=Object(n.r)(t.note),this.getTitle=function(){var t=e.date?new Date(e.date).toLocaleDateString():"";if(t){var title="";return t&&(title+=t),title}return""},this.updateTotal=function(){var t=0;e.payments.forEach((function(e){t+=parseFloat(e.total),t=parseFloat(t.toFixed(2))})),e.value=t},this.getObject=function(t){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),date:Object(n.g)(e.date),value:Object(n.l)(e.value,2),financialAccountId:Object(n.m)(e.financialAccountId),paymentMethodId:Object(n.m)(e.paymentMethodId),payments:e.payments.map((function(e){return e.getObject?"toDB"===t?e.id:e.getObject():e})),in:Object(n.e)(e.in),userId:Object(n.m)(e.userId),note:Object(n.r)(e.note)})),{keepNull:!1})},Array.isArray(t.payments)&&t.payments.forEach((function(p){return e.payments.push(p.id?new te(p,r):p)}))},re=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.name=Object(n.r)(t.name),this.type=Object(n.r)(t.type),this.default=Object(n.e)(t.default),this.financialAccountId=Object(n.m)(t.financialAccountId),this.getTitle=function(){var t=e.name?String(e.name):"";if(t){var title="";return t&&(title+=t),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),name:Object(n.r)(e.name),type:Object(n.r)(e.type),default:Object(n.e)(e.default),financialAccountId:Object(n.m)(e.financialAccountId)})))}};(re.prototype=Object.create(P.prototype)).constructor=re;var ae=re,ne=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.name=Object(n.r)(t.name),this.options=new oe(t.options),this.getTitle=function(){var t=e.name?String(e.name):"";if(t){var title="";return t&&(title+=t),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),name:Object(n.r)(e.name),options:e.options.getObject()})))}},oe=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),this.parts=[],this.minimumValue=t.minimumValue,this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({parts:e.parts.map((function(e){return e.getObject()})),minimumValue:Object(n.l)(e.minimumValue)})))}};(ne.prototype=Object.create(P.prototype)).constructor=ne;var ce=ne,se=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.parentId=Object(n.m)(t.parentId),this.name=Object(n.r)(t.name),this.path=Object(n.r)(t.path),this.getObject=function(t){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),personalId:Object(n.m)(e.personalId),parentId:Object(n.m)(e.parentId),name:Object(n.r)(e.name),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt)})),{keepNull:!0})},this.getTitle=function(){var t=e.name;return t||""}};se.insertCategoryOptions=function(e,t){var r=new se(e);e={value:r.id,obj:r,text:e.path},t.find((function(e){return e.text===e.path}))||t.push(e)},(se.prototype=Object.create(P.prototype)).constructor=se;var le=se,ue={weekday:"long",year:"numeric",month:"long",day:"numeric"},de=["start","pause","back","end","pauseNd","backNd","endNd"],pe=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),this.entity=new w(r.entity).getObject("permissions"),this.entityId=parseInt(t.entityId)?t.entityId:this.entity.id||null,this.createdAt=Object(n.g)(t.createdAt),this.updatedAt=Object(n.g)(t.updatedAt),this.userId=Object(n.m)(t.userId);var o=de.find((function(e){return e==t.type}));this.type=o?Object(n.r)(o):null,this.datetime=Object(n.g)(t.datetime),this.coordinate=Object(n.r)(t.coordinate),this.local=Object(n.r)(t.local),this.note=Object(n.r)(t.note),this.getTitle=function(){var title="";return e.datetime&&(title+="".concat(new Date(Object(n.g)(e.datetime)).toLocaleString("pt-BR",ue))),title},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),userId:Object(n.m)(e.userId),type:Object(n.r)(e.type),datetime:Object(n.g)(e.datetime),coordinate:Object(n.r)(e.coordinate),local:Object(n.r)(e.local),note:Object(n.r)(e.note)})),{keepNull:!1})}},be=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=r.manufacturer||{};w.checkEntities(t,r),P.call(this,t,r),this.manufacturerId=Object(n.m)(t.manufacturerId||o.id),this.model=Object(n.r)(t.model),this.serie=Object(n.r)(t.serie),this.files=[],this.getTitle=function(){var t=e.serie?String(e.serie):"",r=e.model?String(e.model):"";if(t||r){var title="";return t&&(title+=t),r&&(title+=" - ".concat(r)),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),manufacturerId:Object(n.m)(e.manufacturerId),model:Object(n.r)(e.model),serie:Object(n.r)(e.serie),files:Object(n.d)(e.files)})))}};(be.prototype=Object.create(P.prototype)).constructor=be;var Oe=be,ve=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.name=Object(n.r)(t.name),this.products=[],this.insertProduct=function(t){if(e.products.find((function(p){return p.model==t.model})))throw"Modelo de produto já consta na lista do fabricante";e.products.push(new Oe(t))},this.removeProduct=function(t){e.products.splice(t,1)},this.getObject=function(t){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),personalId:Object(n.m)(e.personalId),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),name:Object(n.r)(e.name)})))},this.getTitle=function(){var t=e.name;return t||""},t.products&&t.products.forEach((function(t){e.insertProduct(t)}))};ve.insertManufacturerOptions=function(e,t){var r=new ve(e);e={value:r.id,obj:r,text:e.name},t.find((function(e){return e.text===e.name}))||t.push(e)},(ve.prototype=Object.create(P.prototype)).constructor=ve;var he=ve,je=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.name=Object(n.r)(t.name),this.initials=Object(n.w)(Object(n.r)(t.initials))?Object(n.r)(t.initials).toUpperCase():Object(n.r)(t.initials),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),personalId:Object(n.m)(e.personalId),name:Object(n.r)(e.name),initials:Object(n.w)(Object(n.r)(e.initials))?Object(n.r)(e.initials).toUpperCase():Object(n.r)(e.initials),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt)})))},this.getTitle=function(){var t=e.name,r=e.initials;return t&&r?"".concat(t," - ").concat(r):""}};je.insertUnitType=function(e,t){var r=new je(e);e={value:r.id,obj:r,text:"".concat(e.name," - ").concat(e.initials)},t.find((function(e){return e.text===e.name}))||t.push(e)},(je.prototype=Object.create(P.prototype)).constructor=je;var me=je;function fe(object,e){var t=Object.keys(object);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(object);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(object,e).enumerable}))),t.push.apply(t,r)}return t}function ge(e){for(var i=1;i0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r);var o=Ae.find((function(e){return e.value===t.type}));this.cpfCnpj=Object(n.r)(t.cpfCnpj),this.type=o?o.value:ye(this.cpfCnpj),this.status=Object(n.r)(t.status)?Object(n.r)(t.status):"Ativo",this.name=Object(n.r)(t.name),this.fantasyName=Object(n.r)(t.fantasyName),this.email=Object(n.r)(t.email),this.emailNfe=Object(n.r)(t.emailNfe),this.phone=Object(n.r)(t.phone),this.adresses=[],this.contacts=[],this.stateId=Object(n.r)(t.stateId),this.districtId=Object(n.r)(t.districtId),this.suframa=Object(n.r)(t.suframa),this.note=Object(n.r)(t.note),this.options=new Se(t.options),Object(n.v)(t.person)||(t.person={}),this.person={type:this.type,customerSupplierId:Object(n.m)(t.person.customerSupplierId),name:Object(n.r)(t.person.name),cpf:Object(n.r)(t.person.cpf),rg:Object(n.r)(t.person.rg),birthday:Object(n.g)(t.person.birthday),cnpj:Object(n.r)(t.person.cnpj),opened:Object(n.g)(t.person.opened)},this.getTitle=function(){var t=Object(n.m)(e.personalId),r=Object(n.r)(e.name);return t&&r?"".concat(t," - ").concat(r):""},this.insertAddress=function(address){if(2===e.adresses.length)throw"Adresses full";!address.customerSupplierId&&e.id&&(address.customerSupplierId=e.id),e.adresses.push(new xe(address))},this.getObject=function(t){var r=Ae.find((function(t){return t.value===e.type})),o=JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),type:r?r.value:null,cpfCnpj:Object(n.r)(Object(n.w)(e.cpfCnpj)?e.cpfCnpj.replace(n.A,""):e.cpfCnpj),status:Object(n.r)(e.status),name:Object(n.r)(e.name),fantasyName:Object(n.r)(e.fantasyName),email:Object(n.r)(e.email),emailNfe:Object(n.r)(e.emailNfe),phone:Object(n.r)(Object(n.w)(e.phone)?e.phone.replace(n.A,""):e.phone),stateId:Object(n.r)(e.stateId),districtId:Object(n.r)(e.districtId),suframa:Object(n.r)(e.suframa),note:Object(n.r)(e.note),historic:Object(n.d)(e.historic),options:e.options.getObject(),contacts:Object(n.d)(e.contacts.map((function(e){return e.getObject()})))})),c="pf"===e.person.type?JSON.parse(JSON.stringify({customerSupplierId:Object(n.m)(e.id),cpf:Object(n.r)(Object(n.w)(e.cpfCnpj)?e.cpfCnpj.replace(n.A,""):e.cpfCnpj),name:Object(n.r)(e.name),rg:Object(n.r)(e.person.rg),birthday:Object(n.g)(e.person.birthday)})):"pj"===e.person.type?JSON.parse(JSON.stringify({customerSupplierId:Object(n.m)(e.id),cnpj:Object(n.r)(Object(n.w)(e.cpfCnpj)?e.cpfCnpj.replace(n.A,""):e.cpfCnpj),name:Object(n.r)(e.name),opened:Object(n.g)(e.person.opened)})):{},l=Object(n.d)(e.adresses.map((function(address){return address.getObject()})));return l.forEach((function(e){e.customerSupplierId||(e.customerSupplierId=o.id)})),l[1].useGeneral&&l.splice(1,1),t?"customerSupplier"===t?Object(n.y)(o):"person"===t?Object(n.y)(c):"adresses"===t?l:void 0:Object(n.y)(ge(ge({},o),{},{person:c,adresses:l}))},Array.isArray(t.contacts)&&t.contacts.forEach((function(t){return e.contacts.push(new Ce(t))})),Array.isArray(t.adresses)?(t.adresses.forEach((function(a){e.insertAddress(a)})),t.adresses[0]||this.insertAddress({type:"general"}),t.adresses[1]||this.insertAddress({type:"charge",useGeneral:!0})):(this.insertAddress({type:"general"}),this.insertAddress({type:"charge",useGeneral:!0}))};function Se(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};function r(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.creditLimit=Object(n.l)(t.creditLimit),this.defaultCommercialConditionId=Object(n.m)(t.defaultCommercialConditionId),this.category=Object(n.q)(t.category),this.getObject=function(){return JSON.parse(JSON.stringify({creditLimit:Object(n.l)(e.creditLimit),defaultCommercialConditionId:Object(n.m)(e.defaultCommercialConditionId),category:Object(n.q)(e.category)}))}}Object(n.v)(t)||(t={}),this.since=Object(n.g)(t.since),this.seller=Object(n.q)(t.seller),this.sellerNextVisit=Object(n.g)(t.sellerNextVisit),this.type=Object(n.d)(t.type)?t.type:["Cliente"],this.photo=Object(n.r)(t.photo),this.financial=new r(t.financial),this.getObject=function(){return JSON.parse(JSON.stringify({since:Object(n.g)(e.since),seller:Object(n.q)(e.seller),sellerNextVisit:Object(n.g)(e.sellerNextVisit),type:Object(n.d)(e.type),photo:Object(n.r)(e.photo),financial:e.financial.getObject()}))}}var Ce=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.name=Object(n.r)(t.name),this.phone=Object(n.r)(t.phone),this.phoneExt=Object(n.r)(t.phoneExt),this.email=Object(n.r)(t.email),this.type=Object(n.r)(t.type),this.note=Object(n.r)(t.note),this.getTitle=function(){return e.type?"".concat(e.name+(e.type&&""!==e.type?" - ".concat(e.type):"")):e.name},this.getObject=function(){return JSON.parse(JSON.stringify({name:Object(n.r)(e.name),phone:Object(n.r)(Object(n.w)(e.phone)?e.phone.replace(n.A,""):e.phone),phoneExt:Object(n.r)(e.phoneExt),email:Object(n.r)(e.email),type:Object(n.r)(e.type),note:Object(n.r)(e.note)}))}};function xe(){var e=this,address=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(address)||(address={}),this.customerSupplierId=Object(n.m)(address.customerSupplierId),this.type=Object(n.r)(address.type),this.zipcode=Object(n.r)(address.zipcode),this.uf=Object(n.r)(address.uf),this.city=Object(n.r)(address.city),this.district=Object(n.r)(address.district),this.address=Object(n.r)(address.address),this.addressNumber=Object(n.r)(address.addressNumber),this.complement=Object(n.r)(address.complement),this.ibge=Object(n.r)(address.ibge),this.useGeneral=Object(n.e)(address.useGeneral),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({customerSupplierId:Object(n.m)(e.customerSupplierId),type:Object(n.r)(e.type),zipcode:Object(n.r)(Object(n.w)(e.zipcode)?e.zipcode.replace(n.A,""):e.zipcode),uf:Object(n.r)(e.uf),city:Object(n.r)(e.city),district:Object(n.r)(e.district),address:Object(n.r)(e.address),addressNumber:Object(n.r)(e.addressNumber),complement:Object(n.r)(e.complement),ibge:Object(n.m)(e.ibge),useGeneral:Object(n.e)(e.useGeneral)})))}}var Ae=[{value:"pf",text:"Pessoa Física"},{value:"pj",text:"Pessoa Jurídica"}];(Ie.prototype=Object.create(P.prototype)).constructor=Ie,Ie.Contact=Ce,Ie.Address=xe,Ie.typeOptions=Ae;var Ne=Ie,Te=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.name=Object(n.r)(t.name),this.getTitle=function(){var t=e.name?String(e.name):"";if(t){var title="";return t&&(title+=t),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),name:Object(n.r)(e.name)})))}};(Te.prototype=Object.create(P.prototype)).constructor=Te;var Fe=Te,we=(r(62),r(69),function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),P.call(this,t,r),this.name=Object(n.r)(t.name),this.email=Object(n.r)(t.email),this.password=Object(n.r)(t.password),this.confirmPassword=Object(n.r)(t.confirmPassword),this.admin=Object(n.e)(t.admin)||!1,this.lastLogin=Object(n.g)(t.lastLogin),this.lastAction=Object(n.g)(t.lastAction),this.permissions=new Pe(t.permissions,r),this.options=new Ee(t.options,r),this.setUserType=function(t){"seller"===t?(e.permissions.seller=!0,e.permissions.technician=!1,e.permissions.noAccess=!1):"technician"===t?(e.permissions.seller=!1,e.permissions.technician=!0,e.permissions.noAccess=!1):"technician-noAccess"===t&&(e.permissions.seller=!1,e.permissions.technician=!0,e.permissions.noAccess=!0)},this.getObject=function(t){var r=Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),historic:Object(n.d)(e.historic),name:Object(n.r)(e.name),email:Object(n.r)(e.email),password:Object(n.r)(e.password),confirmPassword:Object(n.r)(e.confirmPassword),admin:Object(n.e)(e.admin),lastLogin:Object(n.g)(e.lastLogin),lastAction:Object(n.g)(e.lastAction),permissions:e.permissions.getObject(),options:e.options.getObject()})),{keepNull:!1});return"toDB"===t&&(delete r.confirmPassword,r.password||delete r.password),r},this.getTitle=function(){var t=e.name;return t||""}}),Pe=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.closeOrder=Object(n.e)(t.closeOrder),this.insertOrder=Object(n.e)(t.insertOrder),this.insertServiceOrder=Object(n.e)(t.insertServiceOrder),this.insertBudget=Object(n.e)(t.insertBudget),this.selectOrder=Object(n.e)(t.selectOrder),this.selectServiceOrder=Object(n.e)(t.selectServiceOrder),this.selectBudget=Object(n.e)(t.selectBudget),this.getObject=function(){return JSON.parse(JSON.stringify({closeOrder:Object(n.e)(e.closeOrder),insertOrder:Object(n.e)(e.insertOrder),insertServiceOrder:Object(n.e)(e.insertServiceOrder),insertBudget:Object(n.e)(e.insertBudget),selectOrder:Object(n.e)(e.selectOrder)||e.insertOrder,selectServiceOrder:Object(n.e)(e.selectServiceOrder)||e.insertServiceOrder,selectBudget:Object(n.e)(e.selectBudget)||e.insertBudget}))}},c=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.insertProduct=Object(n.e)(t.insertProduct),this.insertCategory=Object(n.e)(t.insertCategory),this.insertManufacturer=Object(n.e)(t.insertManufacturer),this.insertUnitType=Object(n.e)(t.insertUnitType),this.selectProduct=Object(n.e)(t.selectProduct),this.getObject=function(){return JSON.parse(JSON.stringify({insertProduct:Object(n.e)(e.insertProduct),insertCategory:Object(n.e)(e.insertCategory),insertManufacturer:Object(n.e)(e.insertManufacturer),insertUnitType:Object(n.e)(e.insertUnitType),selectProduct:Object(n.e)(e.selectProduct)||e.insertProduct}))}},l=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.insertCustomerSupplier=Object(n.e)(t.insertCustomerSupplier),this.selectCustomerSupplier=Object(n.e)(t.selectCustomerSupplier),this.getObject=function(){return JSON.parse(JSON.stringify({insertCustomerSupplier:Object(n.e)(e.insertCustomerSupplier),selectCustomerSupplier:Object(n.e)(e.selectCustomerSupplier)||e.insertCustomerSupplier}))}},d=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.insertService=Object(n.e)(t.insertService),this.selectService=Object(n.e)(t.selectService),this.getObject=function(){return JSON.parse(JSON.stringify({insertService:Object(n.e)(e.insertService),selectService:Object(n.e)(e.selectService)||e.insertService}))}},O=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.insertInvoice=Object(n.e)(t.insertInvoice),this.selectInvoice=Object(n.e)(t.selectInvoice),this.getObject=function(){return JSON.parse(JSON.stringify({insertInvoice:Object(n.e)(e.insertInvoice),selectInvoice:Object(n.e)(e.selectInvoice)||e.insertInvoice}))}},v=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.insertFinancial=Object(n.e)(t.insertFinancial),this.selectFinancial=Object(n.e)(t.selectFinancial),this.getObject=function(){return JSON.parse(JSON.stringify({insertFinancial:Object(n.e)(e.insertFinancial),selectFinancial:Object(n.e)(e.selectFinancial)||e.insertFinancial}))}},h=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.insertAsset=Object(n.e)(t.insertAsset),this.insertAssetType=Object(n.e)(t.insertAssetType),this.selectAsset=Object(n.e)(t.selectAsset),this.getObject=function(){return JSON.parse(JSON.stringify({insertAsset:Object(n.e)(e.insertAsset),insertAssetType:Object(n.e)(e.insertAssetType),selectAsset:Object(n.e)(e.selectAsset)||e.insertAsset}))}},j=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.insertCheckin=Object(n.e)(t.insertCheckin),this.selectCheckin=Object(n.e)(t.selectCheckin),this.tz=Object(n.r)(t.tz),this.getObject=function(){return JSON.parse(JSON.stringify({insertCheckin:Object(n.e)(e.insertCheckin),selectCheckin:Object(n.e)(e.selectCheckin),tz:Object(n.r)(e.tz)}))}},m=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.insertSite=Object(n.e)(t.insertSite),this.insertArea=Object(n.e)(t.insertArea),this.getObject=function(){return JSON.parse(JSON.stringify({insertSite:Object(n.e)(e.insertSite),insertArea:Object(n.e)(e.insertArea)}))}},f=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.insertTicket=Object(n.e)(t.insertTicket),this.selectTicket=Object(n.e)(t.selectTicket),this.ticketAdmin=Object(n.e)(t.ticketAdmin),this.getObject=function(){return JSON.parse(JSON.stringify({insertTicket:Object(n.e)(e.insertTicket),selectTicket:Object(n.e)(e.selectTicket),ticketAdmin:Object(n.e)(e.ticketAdmin)}))}};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),this.admin=Object(n.e)(t.admin),this.technician=Object(n.e)(t.technician),this.requester=Object(n.e)(t.requester),this.seller=Object(n.e)(t.seller),this.cashier=Object(n.e)(t.cashier),this.noAccess=Object(n.e)(t.noAccess),this.stockPostings=Object(n.e)(t.stockPostings),this.businessUnits=[],this.sites=[],this.order=new o(t.order),this.product=new c(t.product),this.customerSupplier=new l(t.customerSupplier),this.service=new d(t.service),this.asset=new h(t.asset),this.checkin=new j(t.checkin),this.site=new m(t.site),this.ticket=new f(t.ticket),this.invoice=new O(t.invoice),this.financial=new v(t.financial),this.insertSite=function(t){if(e.sites.find((function(s){return s.id==t.id})))throw"Site já consta";e.sites.push(t)},this.insertBusinessUnit=function(t){t.id?e.businessUnits.find((function(e){return e.id==t.id}))||e.businessUnits.push(t):e.businessUnits.includes(t)||e.businessUnits.push(t)},this.getObject=function(){return JSON.parse(JSON.stringify({admin:Object(n.e)(e.admin),technician:Object(n.e)(e.technician),requester:Object(n.e)(e.requester),seller:Object(n.e)(e.seller),cashier:Object(n.e)(e.cashier),noAccess:Object(n.e)(e.noAccess),stockPostings:Object(n.e)(e.stockPostings),businessUnits:e.businessUnits.map((function(e){return e.id?e.id:e})),sites:Object(n.d)(e.sites),order:e.order.getObject(),product:e.product.getObject(),customerSupplier:e.customerSupplier.getObject(),service:e.service.getObject(),asset:e.asset.getObject(),checkin:e.checkin.getObject(),site:e.site.getObject(),ticket:e.ticket.getObject(),invoice:e.invoice.getObject(),financial:e.financial.getObject()}))},Array.isArray(t.businessUnits)&&t.businessUnits.forEach((function(t){return e.insertBusinessUnit(t)})),Array.isArray(t.sites)&&t.sites.forEach((function(s){return e.insertSite(s)}))},Ee=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=new w(r.entity),c=o.options.decimalPlaces;this.new=Object(n.e)(t.new),this.newPassword=Object(n.e)(t.newPassword),this.appMode=Object(n.r)(t.appMode),this.userType=Object(n.r)(t.userType),this.cpf=Object(n.w)(t.cpf)?t.cpf.replace(n.A,""):t.cpf,this.fieldsRemoved=Object(n.q)(t.fieldsRemoved),this.comission=Object(n.l)(t.comission,c),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({new:Object(n.e)(e.new),newPassword:Object(n.e)(e.newPassword),appMode:Object(n.r)(e.appMode),userType:Object(n.r)(e.userType),cpf:Object(n.w)(e.cpf)?e.cpf.replace(n.A,""):e.cpf,fieldsRemoved:Object(n.q)(e.fieldsRemoved),comission:Object(n.l)(e.comission,c)})))}},De=[{value:null,text:""},{value:"seller",text:"Vendedor"},{value:"technician",text:"Técnico"},{value:"technician-noAccess",text:"Técnico (Sem Acesso)"}];(we.prototype=Object.create(P.prototype)).constructor=we,we.getUserTypeOptions=function(e){var t=e.entity,r=[].concat(De);if(e.id&&e.email){var o=r.findIndex((function(e){return"technician-noAccess"===e.value}));r.splice(o,1)}return Object(n.u)(t,"service")||r.splice(2),r},we.insertToQuery=function(e,t){t.splice.apply(t,[0,t.length].concat(Object(c.a)(e.map((function(e){return{id:(e=Object(n.x)(e)).id,personalId:e.personalId,name:e.name,email:e.email,entityName:e.entity?e.entity.name:null,lastLogin:e.lastLogin,lastAction:e.lastAction}})))))},we.passwordCombinationError="Combinação da senha inválida. A senha deve ter 8 ou mais caracteres, conter letra maiúscula, número e caracter especial ex: !@#$%¨&*()`",we.Options=Ee;var Je=we,Me="Falta configurações do histórico",ke="Usuário inválido em histórico",Re="Falta objeto de primeira atualização do histórico",qe="Falta objeto do histórico",Ve="Lista de diff inváida",Be=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{historic:{},user:{},diff:[]};if(!Object(n.v)(t))throw Me;if(!Object(n.v)(t.user))throw ke;var r=t.new;if(r&&!Object(n.v)(t.obj))throw Re;var o=t.user,c=t.diff;this.date=new Date,this.user={id:o.id,name:o.name,email:o.email},this.difference=[],Array.isArray(c)&&c.forEach((function(t){e.difference.push(t)}))};Be.insertHistoric=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{obj:{},user:{},difference:[]};if(!Object(n.v)(e))throw Me;var t=e.obj,r=e.user,o=e.difference;if(!Object(n.v)(t))throw qe;if(!Array.isArray(o))throw Ve;if(!Object(n.v)(r))throw ke;Array.isArray(t.historic)||(t.historic=[]),t.historic.push(new Be({user:r,difference:o}))};var Le=Be,Ue=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r);var o=this.entity.options.decimalPlaces;this.description=Object(n.r)(t.description),this.categoryId=Object(n.m)(t.categoryId),this.code=Object(n.r)(t.code),this.manufacturerId=Object(n.m)(t.manufacturerId),this.unitTypeId=Object(n.m)(t.unitTypeId),this.salePrice=Object(n.l)(t.salePrice,o),this.costPrice=Object(n.l)(t.costPrice,o),this.sku=Object(n.r)(t.sku),this.gtin=Object(n.r)(t.gtin),this.gtinTrib=Object(n.r)(t.gtinTrib),this.gdata=new ze(t.gdata),this.tax=new We(t.tax),this.logistic=new Ge(t.logistic),this.stock=new _e(t.stock),this.suppliers=[],this.tags=[],this.note=Object(n.r)(t.note),this.balance=Object(n.l)(t.balance,4),this.insertSupplier=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Object(n.v)(t)||(t={}),e.suppliers.find((function(s){return s.id===t.id})))throw"Fornecedor já consta na lista";e.suppliers.push(new Xe(t))},this.insertTag=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if(!Object(n.w)(t))throw"Invalid tag";if(e.tags.find((function(e){return e===t})))throw"Tag já consta na lista";e.tags.push(t)},this.getTitle=function(){var t=Object(n.m)(e.personalId),r=Object(n.r)(e.description);return t&&r?"".concat(t," - ").concat(r):""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:parseInt(e.entityId),personalId:Object(n.m)(e.personalId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),description:Object(n.r)(e.description),categoryId:Object(n.m)(e.categoryId),code:Object(n.r)(e.code),manufacturerId:Object(n.m)(e.manufacturerId),unitTypeId:Object(n.m)(e.unitTypeId),salePrice:Object(n.l)(e.salePrice,o),costPrice:Object(n.l)(e.costPrice,o),sku:Object(n.r)(e.sku),gtin:Object(n.r)(e.gtin),gtinTrib:Object(n.r)(e.gtinTrib),gdata:e.gdata.getObject(),tax:e.tax.getObject(),logistic:e.logistic.getObject(),stock:e.stock.getObject(),suppliers:e.suppliers.map((function(e){return e.getObject()})),tags:Object(n.d)(e.tags),note:Object(n.r)(e.note)})))},Array.isArray(t.suppliers)&&t.suppliers.forEach((function(t){return e.insertSupplier(t)})),Array.isArray(t.tags)&&t.tags.forEach((function(t){return e.insertTag(t)}))},ze=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.consumable=Object(n.e)(t.consumable),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({consumable:Object(n.e)(e.consumable)})))}},Ge=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.unitMeter=Object(n.r)(t.unitMeter),this.netWeight=Object(n.m)(t.netWeight),this.grossWeight=Object(n.m)(t.grossWeight),this.volumes=Object(n.m)(t.volumes),this.width=Object(n.m)(t.width),this.height=Object(n.m)(t.height),this.depth=Object(n.m)(t.depth),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({unitMeter:Object(n.r)(e.unitMeter),netWeight:Object(n.m)(e.netWeight),grossWeight:Object(n.m)(e.grossWeight),volumes:Object(n.m)(e.volumes),width:Object(n.m)(e.width),height:Object(n.m)(e.height),depth:Object(n.m)(e.depth)})))}},_e=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.minimum=Object(n.m)(t.minimum),this.maximum=Object(n.m)(t.maximum),this.crossdocking=Object(n.m)(t.crossdocking),this.location=Object(n.r)(t.location),this.getObject=function(){return JSON.parse(JSON.stringify({minimum:Object(n.m)(e.minimum),maximum:Object(n.m)(e.maximum),crossdocking:Object(n.m)(e.crossdocking),location:Object(n.r)(e.location)}))}},Xe=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.name=Object(n.r)(t.name),this.id=Object(n.m)(t.id),this.invoiceDescription=Object(n.r)(t.invoiceDescription),this.invoiceId=Object(n.r)(t.invoiceId),this.costPrice=Object(n.l)(t.costPrice),this.purchasePrice=Object(n.l)(t.purchasePrice),this.warranty=Object(n.m)(t.warranty),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),invoiceDescription:Object(n.r)(e.invoiceDescription),invoiceId:Object(n.r)(e.invoiceId),costPrice:Object(n.l)(e.costPrice),purchasePrice:Object(n.l)(e.purchasePrice),warranty:Object(n.m)(e.warranty)})))}},We=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={});var r=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.valorBaseSTRetido=Object(n.l)(t.valorBaseSTRetido),this.valorSTRetido=Object(n.l)(t.valorSTRetido),this.valorSubstituto=Object(n.l)(t.valorSubstituto),this.getObject=function(){return JSON.parse(JSON.stringify({valorBaseSTRetido:Object(n.l)(e.valorBaseSTRetido),valorSTRetido:Object(n.l)(e.valorSTRetido),valorSubstituto:Object(n.l)(e.valorSubstituto)}))}},o=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.excecaoTipi=Object(n.m)(t.excecaoTipi),this.getObject=function(){return JSON.parse(JSON.stringify({excecaoTipi:Object(n.m)(e.excecaoTipi)}))}},c=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.valorPis=Object(n.l)(t.valorPis),this.valorCofins=Object(n.l)(t.valorCofins),this.getObject=function(){return JSON.parse(JSON.stringify({valorPis:Object(n.l)(e.valorPis),valorCofins:Object(n.l)(e.valorCofins)}))}};this.origem=Object(n.r)(t.origem),this.ncm=Object(n.r)(Object(n.w)(t.ncm)?t.ncm.replace(/\./g,""):t.ncm),this.cest=Object(n.r)(t.cest),this.valorAproximadoTributos=Object(n.l)(t.valorAproximadoTributos),this.informacoesAdicionais=Object(n.r)(t.informacoesAdicionais),this.icms=new r(t.icms),this.ipi=new o(t.ipi),this.pisCofins=new c(t.pisCofins),this.getObject=function(){return JSON.parse(JSON.stringify({origem:Object(n.r)(e.origem),ncm:Object(n.r)(Object(n.w)(e.ncm)?e.ncm.replace(/\./g,""):e.ncm),cest:Object(n.r)(e.cest),valorAproximadoTributos:Object(n.l)(e.valorAproximadoTributos),informacoesAdicionais:Object(n.r)(e.informacoesAdicionais),icms:e.icms.getObject(),ipi:e.ipi.getObject(),pisCofins:e.pisCofins.getObject()}))}};Ge.unitMeterTypes=["Milímetro","Centímetro","Metro"],(Ue.prototype=Object.create(P.prototype)).constructor=Ue,Ue.Logistic=Ge,Ue.Supplier=Xe;var Ze=Ue;r(246),r(72);function Qe(e){var t,r,n,o=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new $e(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function $e(s){function e(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return $e=function(s){this.s=s,this.n=s.next},$e.prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(t){var r=this.s.return;return void 0===r?Promise.resolve({value:t,done:!0}):e(r.apply(this.s,arguments))},throw:function(t){var r=this.s.return;return void 0===r?Promise.reject(t):e(r.apply(this.s,arguments))}},new $e(s)}var He=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r);var o=this.entity.options.decimalPlaces,c=function(){var t=Object(V.a)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.updateTotal();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();this.name=Object(n.r)(t.name||t.description),this.description=Object(n.r)(t.description),this.costs=[],this.consumables=[],this.total=null,this.profitTotal=null,this.costSum=null,this.costTotal=null,this.costCostTotal=null,this.costProfitTotal=null,this.consumableTotal=null,this.consumableCostTotal=null,this.consumableProfitTotal=null,this.insertCostSync=function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e&&e.name&&this.costs.find((function(t){return t.name===e.name})))throw"Custo ".concat(e.name," já existe");(e=new Ke(e,{entity:this.entity,updateServiceTotal:c,decimalPlaces:o})).update().then((function(){return t.updateTotal()})),r.beforeInsert&&"function"==typeof r.beforeInsert&&r.beforeInsert(e),this.costs.push(e)},this.insertConsumableSync=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),t.unitValue=t.unitValue||t.salePrice,t.unitValueCost=t.unitValueCost||t.costPrice,t.amount=t.amount||1,(t=new Ye(t,{entity:this.entity,updateServiceTotal:c,decimalPlaces:o})).update().then((function(){return e.updateTotal()})),r.beforeInsert&&"function"==typeof r.beforeInsert&&r.beforeInsert(t),this.consumables.push(t)},this.insertCost=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this;return new Promise((function(l,d){try{if(Object(n.v)(e)||(e={}),e&&e.name&&r.costs.find((function(t){return t.name===e.name})))throw'Custo "'.concat(e.name,'" já consta no serviço');(e=new Ke(e,{entity:r.entity,updateServiceTotal:c,decimalPlaces:o})).update().then((function(){t.beforeInsert&&"function"==typeof t.beforeInsert&&t.beforeInsert(e),r.costs.push(e),r.updateTotal().then((function(){return l(e)})).catch(d)})).catch(d)}catch(e){d(e)}}))},this.insertConsumable=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this;return new Promise((function(l,d){try{if(Object(n.v)(e)||(e={}),e.unitValue=e.unitValue||e.salePrice,e.unitValueCost=e.unitValueCost||e.costPrice,e.amount=e.amount||1,e&&e.id&&r.consumables.find((function(t){return t.id===e.id})))throw'Consumível "'.concat(e.description,'" já consta no serviço');(e=new Ye(e,{entity:r.entity,updateServiceTotal:c,decimalPlaces:o})).update().then((function(){t.beforeInsert&&"function"==typeof t.beforeInsert&&t.beforeInsert(e),r.consumables.push(e),r.updateTotal().then((function(){l(e)})).catch(d)})).catch(d)}catch(e){d(e)}}))},this.removeCost=function(e){var t=this;return new Promise((function(r,n){try{if(isNaN(parseInt(e)))throw"Invalid index";t.costs.splice(e,1),t.updateTotal().then(r()).catch(n)}catch(e){n(e)}}))},this.removeConsumable=function(e){var t=this;return new Promise((function(r,n){try{if(isNaN(parseInt(e)))throw"Invalid index";t.consumables.splice(e,1),t.updateTotal().then(r()).catch(n)}catch(e){n(e)}}))},this.getTitle=function(){var t=Object(n.m)(e.personalId),r=Object(n.r)(e.name);return t&&r?"".concat(t," - ").concat(r):""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),personalId:Object(n.m)(e.personalId),name:Object(n.r)(e.name),description:Object(n.r)(e.description),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),costs:Object(n.d)(e.costs.map((function(e){return e.getObject()}))),consumables:Object(n.d)(e.consumables.map((function(e){return e.getObject()}))),total:Object(n.l)(e.total),historic:Object(n.d)(e.historic)})))},this.updateTotal=at,this.update=nt,Array.isArray(t.costs)&&t.costs.forEach((function(t){return e.insertCostSync(t,{beforeInsert:r.beforeInsertCost&&"function"==typeof r.beforeInsertCost?r.beforeInsertCost:null})})),Array.isArray(t.consumables)&&t.consumables.forEach((function(t){return e.insertConsumableSync(t,{beforeInsert:r.beforeInsertConsumable&&"function"==typeof r.beforeInsertConsumable?r.beforeInsertConsumable:null})}))};function Ke(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r);var o=this.entity.options.decimalPlaces,c=r.updateServiceTotal||function(){console.warn("No cost update service total")};this.name=Object(n.r)(t.name),this.values=[],this.cover=Object(n.l)(t.cover,o),this.totalSetted=Object(n.l)(t.totalSetted,o),this.total=Object(n.l)(t.total,o),this.costTotal=null,this.profitTotal=null,Array.isArray(t.values)?t.values.forEach((function(t){return e.values.push(new et(t,{entity:e.entity,decimalPlaces:o}))})):this.values.push(new et(null,{entity:this.entity,decimalPlaces:o})),this.copy=function(){return new Ke(this,{entity:this.entity,updateServiceTotal:c,decimalPlaces:o})},this.insertValue=function(e,t){var r=this;return new Promise((function(n,c){try{e=new et(e,{entity:r.entity,decimalPlaces:o}),r.values.splice(t?t+1:1,0,e),n(e)}catch(e){c(e)}}))},this.removeValue=function(e){var t=this;return new Promise(function(){var r=Object(V.a)(regeneratorRuntime.mark((function r(n,o){return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(r.prev=0,!isNaN(parseInt(e))){r.next=3;break}throw"Invalid index";case 3:t.values.splice(e,1),t.update().then(c().catch(o)).then(n()).catch(o),r.next=10;break;case 7:r.prev=7,r.t0=r.catch(0),o(r.t0);case 10:case"end":return r.stop()}}),r,null,[[0,7]])})));return function(e,t){return r.apply(this,arguments)}}())},this.update=it,this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),personalId:Object(n.m)(e.personalId),name:Object(n.r)(e.name),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),values:Object(n.d)(e.values.map((function(e){return e.getObject()}))),cover:Object(n.l)(e.cover,o),totalSetted:Object(n.l)(e.totalSetted,o),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic)})),{keepNull:!1,keepFalse:!1})}}function Ye(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),this.entity=new w(r.entity).getObject("options");var o=this.entity.options.decimalPlaces;this.id=Object(n.m)(t.id),this.personalId=Object(n.m)(t.personalId),this.amount=Object(n.l)(t.amount,4),this.code=Object(n.r)(t.code),this.description=Object(n.r)(t.description),this.manufacturer=Object(n.q)(t.manufacturer),this.unit=Object(n.q)(t.unit),this.unitValue=Object(n.l)(t.unitValue,o),this.unitValueCost=Object(n.l)(t.unitValueCost,o),this.costTotal=null,this.cover=null,this.total=null,this.update=n.C,this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),amount:Object(n.l)(e.amount,4),code:Object(n.r)(e.code),description:Object(n.r)(e.description),manufacturer:Object(n.q)(e.manufacturer),unit:Object(n.q)(e.unit),unitValue:Object(n.l)(e.unitValue,o),unitValueCost:Object(n.l)(e.unitValueCost,o),cover:Object(n.l)(e.cover,o)})),{keepFalse:null,keepNull:!1})}}function et(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),this.entity=new w(r.entity).getObject("options");var o=this.entity.options.decimalPlaces;this.operator=Object(n.r)(t.operator)||"*",this.name=Object(n.r)(t.name),this.value=null!==Object(n.l)(t.value,o)?Object(n.l)(t.value,o):1,this.amount=null!==Object(n.l)(t.amount,o)?Object(n.l)(t.amount,o):1,this.total=null,this.update=tt,this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({operator:Object(n.r)(e.operator),name:Object(n.r)(e.name),value:Object(n.l)(e.value,o),amount:Object(n.l)(e.amount,o)})),{keepFalse:null,keepNull:!1})}}function tt(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(e)||(e={});var t=e.value||this,r=e.entity||this.entity;return new Promise((function(e,n){try{var o=parseFloat(t.amount),c=parseFloat(t.value);if(isNaN(o)||isNaN(c))return;var l=r.options.decimalPlaces;t.total=parseFloat((o*c).toFixed(l)),e(t)}catch(e){n(e)}}))}function it(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};function t(e,t){parseFloat(((parseFloat(e.total)-parseFloat(e.costTotal))/e.costTotal*100).toFixed(t))===parseFloat(((parseFloat(e.totalSetted)-parseFloat(e.costTotal))/e.costTotal*100).toFixed(t))&&(e.total=e.totalSetted)}Object(n.v)(e)||(e={});var r=e.cost||this,o=e.entity||this.entity;return new Promise((function(c,l){try{Object(n.v)(r)||l("Invalid Cost");var d=o.options.decimalPlaces,O=e.fromTotal,v=0;r.values.forEach((function(e,t){if(!isNaN(parseFloat(e.amount))&&!isNaN(parseFloat(e.value))){var r=parseFloat((parseFloat(e.amount)*parseFloat(e.value)).toFixed(d));if(0!==t)switch(e.operator){case"*":v*=r;break;case"+":v+=r;break;case"/":v/=r;break;case"-":v-=r;break;case"=":e.total=v,e.value=1,e.amount=1}else v=r;"="!==e.operator&&(e.total=r)}})),r.costTotal=v<0?0:parseFloat(v.toFixed(d));var h=parseFloat(r.cover);if(O&&r.costTotal){var j=parseFloat(((parseFloat(r.total)-parseFloat(r.costTotal))/r.costTotal*100).toFixed(d));parseFloat(j)?r.cover=j:r.cover=null,r.totalSetted=r.total}else h?(r.cover=h,r.total=parseFloat((r.costTotal*(1+.01*r.cover)).toFixed(d))):r.total=r.costTotal;r.profitTotal=parseFloat((r.total-r.costTotal).toFixed(d)),t(r,d),c(r)}catch(e){l(e)}}))}function at(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(e)||(e={});var t=e.service||this,r=e.entity||this.entity;return new Promise((function(e,n){try{var o=r.options.decimalPlaces,c=0,l=0,d=0,O=0,v=0,h=0;Array.isArray(t.costs)&&t.costs.forEach((function(e){var t=parseFloat(e.total),r=parseFloat(e.costTotal),n=parseFloat(e.profitTotal);isNaN(t)||isNaN(r)||isNaN(n)||(c=parseFloat((c+t).toFixed(o)),l=parseFloat((l+r).toFixed(o)),d=parseFloat((d+n).toFixed(o)))})),Array.isArray(t.consumables)&&t.consumables.forEach((function(e){O=parseFloat((O+e.total).toFixed(o)),v=parseFloat((v+e.costTotal).toFixed(o)),h=parseFloat((h+e.profitTotal).toFixed(o))})),t.consumableCostTotal=v,t.consumableTotal=O,t.consumableProfitTotal=h,t.costCostTotal=l,t.costTotal=c,t.costProfitTotal=d,t.profitTotal=parseFloat((h+d).toFixed(o)),t.costSum=parseFloat((l+v).toFixed(o)),t.total=parseFloat((O+c).toFixed(o)),e(t)}catch(e){n(e)}}))}function nt(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(e)||(e={});var t=e.service||this,r=e.entity||this.entity;return new Promise(function(){var o=Object(V.a)(regeneratorRuntime.mark((function o(c,l){var d,O,v,h,j,m,f,y,I,S,C,x,A,N,T,F,w,P,E,D;return regeneratorRuntime.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(o.prev=0,d=e.toDB,O=e.toOrder,!Array.isArray(t.costs)){o.next=62;break}v=!1,h=!1,o.prev=6,m=Qe(t.costs);case 8:return o.next=10,m.next();case 10:if(!(v=!(f=o.sent).done)){o.next=46;break}y=f.value,I=!1,S=!1,o.prev=14,x=Qe(y.values);case 16:return o.next=18,x.next();case 18:if(!(I=!(A=o.sent).done)){o.next=25;break}return N=A.value,o.next=22,tt({value:N,entity:r}).catch(l);case 22:I=!1,o.next=16;break;case 25:o.next=31;break;case 27:o.prev=27,o.t0=o.catch(14),S=!0,C=o.t0;case 31:if(o.prev=31,o.prev=32,!I||null==x.return){o.next=36;break}return o.next=36,x.return();case 36:if(o.prev=36,!S){o.next=39;break}throw C;case 39:return o.finish(36);case 40:return o.finish(31);case 41:return o.next=43,it({cost:y,entity:r});case 43:v=!1,o.next=8;break;case 46:o.next=52;break;case 48:o.prev=48,o.t1=o.catch(6),h=!0,j=o.t1;case 52:if(o.prev=52,o.prev=53,!v||null==m.return){o.next=57;break}return o.next=57,m.return();case 57:if(o.prev=57,!h){o.next=60;break}throw j;case 60:return o.finish(57);case 61:return o.finish(52);case 62:if(!Array.isArray(t.consumables)){o.next=92;break}T=!1,F=!1,o.prev=65,P=Qe(t.consumables);case 67:return o.next=69,P.next();case 69:if(!(T=!(E=o.sent).done)){o.next=76;break}return D=E.value,o.next=73,Object(n.C)({item:D,entity:r}).catch(l);case 73:T=!1,o.next=67;break;case 76:o.next=82;break;case 78:o.prev=78,o.t2=o.catch(65),F=!0,w=o.t2;case 82:if(o.prev=82,o.prev=83,!T||null==P.return){o.next=87;break}return o.next=87,P.return();case 87:if(o.prev=87,!F){o.next=90;break}throw w;case 90:return o.finish(87);case 91:return o.finish(82);case 92:at({service:t,entity:r}),d?(delete t.costTotal,delete t.consumableTotal,delete t.consumableCostTotal,delete t.consumableProfitTotal,delete t.costCostTotal,delete t.costProfitTotal,delete t.profitTotal,delete t.costSum):O&&(t.unitValueCost=t.costSum,t.unitValue=t.total,t.description=t.description||t.name),c(t),o.next=100;break;case 97:o.prev=97,o.t3=o.catch(0),l(o.t3);case 100:case"end":return o.stop()}}),o,null,[[0,97],[6,48,52,62],[14,27,31,41],[32,,36,40],[53,,57,61],[65,78,82,92],[83,,87,91]])})));return function(e,t){return o.apply(this,arguments)}}())}var ot=[{value:"*",text:"Multiplicar ( * )"},{value:"/",text:"Dividir ( / )"},{value:"+",text:"Somar ( + )"},{value:"-",text:"Subtrair ( - )"},{value:"=",text:"Igual ( = )"}];(He.prototype=Object.create(P.prototype)).constructor=He,Ke.prototype=Object.create(P.prototype),Ke.prototype.constructor=Ke,He.updateCost=it,He.update=nt,(He.Cost=Ke).Value=et,He.Cost.Value.operatorOptions=ot;var ct=He,st=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),Object(n.w)(t.files)&&(t.files=JSON.parse(t.files)),Object(n.w)(t.technical)&&(t.technical=JSON.parse(t.technical));var o=r.user||null,c=r.order,l=r.props,d=l?l.ncp:null,O=d?d.ticket:null,v=r.type,h=r.approve,j=r.disapproval,m=r.close;if(this.id=Object(n.m)(t.id),this.createdAt=Object(n.g)(t.createdAt),this.updatedAt=Object(n.g)(t.updatedAt),this.creatorUserId=Object(n.m)(t.creatorUserId||(o?o.id:null)),this.creator=Object(n.q)(t.creator),"budget"===v||"order"===v)this.orderId=Object(n.m)(t.orderId);else{if("ticket"!==v)throw"Tipo de opção inválida";this.ticketId=Object(n.m)(t.ticketId||O.id)}if(this.showStartEnd=!1,this.description=Object(n.r)(t.description),this.status=Object(n.r)(t.status),this.start=Object(n.g)(t.start),this.end=Object(n.g)(t.end),this.scheduledDate=Object(n.g)(t.scheduledDate),this.files=[],this.technical=[],this.getObject=function(){var t=JSON.parse(JSON.stringify({id:Object(n.m)(e.id),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),creatorUserId:Object(n.m)(e.creatorUserId),description:Object(n.r)(e.description),status:Object(n.r)(e.status),start:Object(n.g)(e.start),end:Object(n.g)(e.end),scheduledDate:Object(n.g)(e.scheduledDate),files:e.files.map((function(e){return e.getObject()})),technical:Object(n.d)(e.technical)}));return"order"===v||"budget"===v?t.orderId=Object(n.m)(e.orderId):"ticket"===v&&(t.ticketId=Object(n.m)(e.ticketId)),Object(n.y)(t)},Array.isArray(t.files)&&t.files.forEach((function(t){return G.insertFile(t,e.files)})),Array.isArray(t.technical)&&t.technical.forEach((function(t){return e.technical.push(t)})),"budget"===v&&h){var f=void 0!==h.reviewIndex?parseInt(h.reviewIndex):void 0;this.description="Orçamento aprovado ".concat(h.by?"por "+h.by:""," na ").concat(void 0!==f?"revisão "+(f+1):"Última Revisão")+(h.description?"\n".concat(h.description):""),h&&h.approveFiles&&Array.isArray(h.approveFiles)&&h.approveFiles.forEach((function(t){return G.insertFile(t,e.files,!0)}))}else if("budget"===v&&j){var y=void 0!==j.reviewIndex?parseInt(j.reviewIndex):void 0;this.description="Orçamento recusado ".concat(j.by?"por "+j.by:""," na ").concat("revisão "+(void 0!==y?y+1:Array.isArray(j.order.gdata.reviews)&&j.order.gdata.reviews.length?j.order.gdata.reviews.length:1))+(j.description?"\n".concat(j.description):""),j&&j.approveFiles&&Array.isArray(j.approveFiles)&&j.approveFiles.forEach((function(t){return G.insertFile(t,e.files,!0)}))}if("order"===v&&m){var I="order"===c.type?"Pedido":"Ordem de Serviço";this.description="".concat(I," Fechado(a) ").concat(m.by?"por "+m.by:"")+(m.description?"\n".concat(m.description):""),m&&m.closeFiles&&Array.isArray(m.closeFiles)&&m.closeFiles.forEach((function(t){return G.insertFile(t,e.files,!0)}))}};function lt(object,e){var t=Object.keys(object);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(object);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(object,e).enumerable}))),t.push.apply(t,r)}return t}function ut(e){for(var i=1;i0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),Object(n.v)(r.user)||(r.user={}),w.checkEntities(t,r),P.call(this,t,r),Object(n.w)(t.gdata)&&(t.gdata=JSON.parse(t.gdata)),Object(n.w)(t.groups)&&(t.groups=JSON.parse(t.groups)),Object(n.w)(t.files)&&(t.files=JSON.parse(t.files));var o=this.entity.options.decimalPlaces;this.creatorUserId=Object(n.m)(t.creatorUserId||r.user.id),this.type=Object(n.r)(r.type)||Object(n.r)(t.type),this.title=Object(n.r)(t.title),this.date=Object(n.g)(t.date),this.closingDate=Object(n.g)(t.closingDate),this.description=Object(n.r)(t.description),this.customerSupplierId=Object(n.m)(t.customerSupplierId),this.status=Object(n.r)(t.status),this.productTotal=null,this.serviceTotal=null,this.discountTotal=null,this.profitTotal=null,this.total=null,this.totalWithoutDiscount=null,this.reviewIndex=null,this.gdata=new At(t.gdata,ut(ut({},r),{},{order:this})),this.followUp=[],this.files=[],this.groups=[],this.hasServices=null,this.hasProducts=null,this.totalPaid=0,this.totalChange=0,this.itsPaid=!1,this.products=Object(n.d)(t.products),this.allBilled=null,this.productsBilled=null,this.servicesBilled=null,this.payments=[],this.updateTotal=Ft,this.update=wt,this.getTitle=function(){if("consumer"===r.type)return"Venda Balcão";var t=Array.isArray(e.gdata.reviews)?parseInt(e.gdata.reviews.length):null,n=isNaN(parseInt(e.reviewIndex))?null:parseInt(e.reviewIndex+1),o=e.personalId,c=e.title,l=e.description?String(e.description):null;if(l&&(l=l.substring(0,47)+(l.length>50?"...":"")),o||l||c){var title="".concat(o?"".concat(o):"");return title+="".concat(c?" - ".concat(c):l?" - ".concat(l):""),n?title+=" - ".concat(n===t?"Última Revisão":"Revisão ".concat(n)):!n&&t>=2&&(title+=" - Última Revisão"),title}return""},this.getObject=function(t){var r=JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),personalId:Object(n.m)(e.personalId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),creatorUserId:Object(n.m)(e.creatorUserId),type:Object(n.r)(e.type),title:Object(n.r)(e.title),date:Object(n.g)(e.date),closingDate:Object(n.g)(e.closingDate),description:Object(n.r)(e.description),customerSupplierId:Object(n.m)(e.customerSupplierId),status:Object(n.r)(e.status),productTotal:Object(n.l)(e.productTotal,o),serviceTotal:Object(n.l)(e.serviceTotal,o),total:Object(n.l)(e.total,o),gdata:e.gdata.getObject(),groups:e.groups.map(mt),files:e.files.map((function(e){return e.getObject()}))}));return"new"===t?Object(n.y)({customerSupplierId:r.customerSupplierId,description:r.description,groups:r.groups,files:r.files,gdata:{budgetId:r.id,budgetPersonalId:r.personalId,vehicleId:r.gdata.vehicleId,vehicleOdometer:r.gdata.vehicleOdometer}},{keepNull:!1}):Object(n.y)(r)},this.getOptions=function(){return r},this.insertFollowUp=function(t){e.followUp.splice(0,e.followUp.length),t.forEach((function(t){e.followUp.push(new st(t,{type:"order"}))}))},this.insertGroups=function(t){e.groups.splice(0,e.groups.length),t.forEach((function(t){e.insertGroupSync(t,{beforeInsert:r.beforeInsertGroup&&"function"==typeof r.beforeInsertGroup?r.beforeInsertGroup:null})}))},this.insertGroupSync=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.index;if(e&&e.name&&this.groups.find((function(t){return t.name===e.name})))throw"Grupo ".concat(e.name," já existe");e=new yt(e,{entity:t.entity||this.entity,order:this,decimalPlaces:o}),t.beforeInsert&&"function"==typeof t.beforeInsert&&t.beforeInsert(e),isNaN(parseInt(r))?this.groups.push(e):this.groups.splice(void 0!==r?r:this.groups.length-1,0,e)},this.insertPayment=function(t){if(e.itsPaid)throw"Total pendente R$ 0,00";e.gdata.payments.push(new te(t,{order:e})),e.getTotalPaid()},this.removePayment=function(t){var r=parseFloat(parseFloat(e.total).toFixed(2)),n=0;if(!e.gdata.payments[t])throw"Pagamento não encontrado";e.gdata.payments.splice(t,1);var o=e.gdata.payments.length-1;e.gdata.payments.forEach((function(e,t){n+=parseFloat(parseFloat(e.value).toFixed(2)),e.gdata.change=n>r&&o==t?parseFloat((n-r).toFixed(2)):null})),e.totalPaid=n,e.getTotalPaid()};var c=function(e,t){var r;return null!==(r=t.gdata)&&void 0!==r&&r.change&&(e+=parseFloat(t.gdata.change)),e=parseFloat(e.toFixed(2))},l=function(e,t){var r;return e=parseFloat((e+parseFloat((parseFloat(t.value)-parseFloat((null==t||null===(r=t.gdata)||void 0===r?void 0:r.change)||0)).toFixed(2))).toFixed(2))};this.getPendency=function(){var t=e.total-e.gdata.payments.reduce(l,0);return t>0?t:0},this.getTotalPaid=Object(V.a)(regeneratorRuntime.mark((function t(){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.updateTotal();case 2:if(e.total){t.next=4;break}return t.abrupt("return");case 4:e.gdata.payments.length||null!==(r=e.gdata.payments[0])&&void 0!==r&&r.id?(e.totalPaid=e.gdata.payments.reduce(l,0),e.totalChange=e.gdata.payments.reduce(c,0),e.totalPaid>=e.total?(e.itsPaid=!0,e.difference=e.totalPaid-e.total):e.itsPaid=!1):(e.totalPaid=0,e.itsPaid=!1);case 5:case"end":return t.stop()}}),t)})));var d=function(){if("Faturado(a)"===e.status){var t=e.gdata.invoices.filter((function(i){return i.productInvoiceId&&i.statusApi&&("CONCLUIDO"===i.statusApi.status||"REJEITADO"===i.statusApi.status)})),r=e.gdata.invoices.filter((function(i){return i.serviceInvoiceId&&i.statusApi&&("CONCLUIDO"===i.statusApi.situacao||"REJEITADO"===i.statusApi.situacao)})),n=t.reduce((function(e,t){return e+t.total.valorProdutosServicos}),0),o=r.reduce((function(e,t){var r=0;return t.servico.forEach((function(s){return r+=s.valor.servico})),e+r}),0),c=e.productTotal,l=e.serviceTotal;e.productsBilled=n>=c,e.servicesBilled=o>=l,e.allBilled=e.productsBilled&&e.servicesBilled}};this.loadReview=function(t){var r=e.gdata.reviews[e.gdata.reviews.length-1],o=void 0!==t?e.gdata.reviews[parseInt(t)]:r;return e.gdata.commercialConditionsIds=Object(n.d)(o.commercialConditionsIds),e.insertGroups(o.groups),e.description=Object(n.r)(o.description),e.date=Object(n.g)(o.date),e.status=Object(n.r)(o.status),e.gdata.validity=Object(n.m)(o.validity),e.reviewIndex=t,o},this.renameGroup=function(e,t){this.groups[t].name=e},this.insertGroup=this.insertGroupSync,this.removeGroup=function(t){e.groups.splice(t,1)},this.approve=function(r){var n=e.loadReview(r);if("Orçamento"!==n.status)throw"Revisão inválida - ".concat(r);n.status=vt,e.gdata.reviews.forEach((function(e,n){void 0!==r?n!=r&&(e.status=jt):n!=t.gdata.reviews.length-1&&(e.status=jt)})),e.gdata.budgetApproveDate=new Date,e.status=vt},this.disapproval=function(t){var r=e.loadReview(t);if("Orçamento"!==r.status)throw"Revisão inválida - ".concat(t);r.status=jt,t||e.gdata.reviews.length||(e.status=jt)},Array.isArray(t.groups)&&this.insertGroups(t.groups),Array.isArray(t.followUp)&&this.insertFollowUp(t.followUp),Array.isArray(t.files)&&t.files.forEach((function(t){return G.insertFile(t,e.files)})),ft(this)&&(this.allOverdue=!0),Array.isArray(t.payments)&&t.payments.forEach((function(t){return e.payments.push(new te(t,r))})),this.getTotalPaid(),d()};function yt(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=r.order;this.entity=r.entity,this.name=Object(n.r)(t.name)||"default",this.products=[],this.services=[],this.productTotal=null,this.productCostTotal=null,this.productProfitTotal=null,this.productDiscountTotal=null,this.serviceTotal=null,this.serviceCostTotal=null,this.serviceProfitTotal=null,this.serviceDiscountTotal=null,this.discountTotal=null,this.costTotal=null,this.profitTotal=null,this.total=null,this.update=Tt,this.insertProduct=function(t,n){if(!(t=new It(t,r)).personalId)throw"Produto inválido";if(e.products.find((function(p){return parseInt(p.id)===t.id})))throw"Produto já consta no grupo";return n>=0?e.products.splice(n+1,0,t):e.products.push(t),t.update().then(e.update()).then((function(){o&&o.getTotalPaid()})).catch((function(e){throw e})),o&&(o.hasProducts=!0),e.products.findIndex((function(p){return p.id===t.id}))},this.insertService=function(t,n){if(!Ot(e.entity,"service"))throw"Entidade não tem permissão para ler esse documento";if(t=new St(t,ut(ut({},r),{},{service:t.service?null:t})),e.services.find((function(s){return s.description===t.description})))throw"Serviço já consta no grupo";n>=0?e.services.splice(n+1,0,t):e.services.push(t),t.update().then(e.update()).then((function(){o&&o.getTotalPaid()})).catch((function(e){throw e})),o&&(o.hasServices=!0)},this.removeProduct=function(t){e.products.splice(t,1),e.update().then((function(){return o.updateTotal()}))},this.removeService=function(t){e.services.splice(t,1),e.update().then((function(){return o.updateTotal()}))},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({name:Object(n.r)(e.name),products:e.products.map((function(e){return e.getObject()})),services:e.services.map((function(e){return e.getObject()}))})))},Array.isArray(t.products)&&t.products.forEach((function(p){e.insertProduct(p)})),Array.isArray(t.services)&&t.services.forEach((function(s){e.insertService(s)}))}var It=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),this.entity=new w(r.entity).getObject(null,{keepFalse:!1,keepNull:!1});var o=this.entity.options.decimalPlaces;this.id=Object(n.m)(t.id),this.personalId=Object(n.m)(t.personalId),this.code=Object(n.r)(t.code),this.manufacturer=Object(n.q)(t.manufacturer),this.description=Object(n.r)(t.description),this.unit=Object(n.q)(t.unit),this.unitValueCost=Object(n.l)(t.unitValueCost,o),this.amount=Object(n.l)(t.amount,4),this.unitValue=Object(n.l)(t.unitValue,o),this.discount=Object(n.l)(t.discount,4),this.unitValueDiscount=Object(n.l)(t.unitValueDiscount,o),this._cellVariants=Object(n.q)(t._cellVariants),this.update=n.C,this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),code:Object(n.r)(e.code),manufacturer:Object(n.q)(e.manufacturer),description:Object(n.r)(e.description),unit:Object(n.q)(e.unit),unitValueCost:Object(n.l)(e.unitValueCost,o),amount:Object(n.l)(e.amount,4),unitValue:Object(n.l)(e.unitValue,o),discount:Object(n.l)(e.discount,4),unitValueDiscount:Object(n.l)(e.unitValueDiscount,o),_cellVariants:Object(n.q)(e._cellVariants)})),{keepFalse:!1,keepNull:!1})}},St=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),this.service=new ct(r.service||t.service,r),this.entity=new w(r.entity).getObject(null,{keepFalse:!1,keepNull:!1});var o=this.entity.options.decimalPlaces;this.id=Object(n.m)(t.id),this.personalId=Object(n.m)(t.personalId),this.description=Object(n.r)(t.description),this.unitValueCost=Object(n.l)(t.unitValueCost,o),this.amount=Object(n.l)(t.amount,4),this.unitValue=Object(n.l)(t.unitValue,o),this.discount=Object(n.l)(t.discount,4),this.unitValueDiscount=Object(n.l)(t.unitValueDiscount,o),this.technical=[],this._cellVariants=Object(n.q)(t._cellVariants),this.insertTechnician=function(t){if(e.technical.find((function(e){return e.id===t.id})))throw"Técnico já consta no serviço";e.technical.push(t)},this.removeTechnician=function(t){var r=e.technical.findIndex((function(e){return e.id==t.id}));if(!(r>=0))throw"Técnico não consta no serviço";e.technical.splice(r,1)},Array.isArray(t.technical)&&t.technical.forEach((function(t){e.insertTechnician(t)})),this.update=n.C,this.updateService=function(){var t=Object(V.a)(regeneratorRuntime.mark((function t(c){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e.service=new ct(c,r),t.next=3,e.service.update().then(function(){var t=Object(V.a)(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e.unitValueCost=Object(n.l)(r.costSum,o),e.unitValue=Object(n.l)(r.total,o),e.description=Object(n.r)(r.description||r.name),t.next=5,e.update({fromUV:!0});case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({service:e.service.getObject(),id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),description:Object(n.r)(e.description),unitValueCost:Object(n.l)(e.unitValueCost,o),amount:Object(n.l)(e.amount,4),unitValue:Object(n.l)(e.unitValue,o),discount:Object(n.l)(e.discount,4),unitValueDiscount:Object(n.l)(e.unitValueDiscount,o),technical:Object(n.d)(e.technical),_cellVariants:Object(n.q)(e._cellVariants)})),{keepFalse:!1,keepNull:!1})}};function Ct(e,t){var r=this;this.reviews.splice(0,this.reviews.length),e.forEach((function(e){return r.reviews.push(new Nt(e,t))}))}var xt=function(e){return e.getObject()},At=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o,c=r.order,l=r.entity;"consumer"===c.type&&(this.consumerCpfCnpj=Object(n.r)(t.consumerCpfCnpj)?Object(n.r)(t.consumerCpfCnpj).replace(n.A,""):null,this.cashierId=Object(n.m)(t.cashierId||(null===(o=r.cashier)||void 0===o?void 0:o.id)));this.commercialConditionsIds=Object(n.d)(t.commercialConditionsIds)||[],this.tags=[],this.payments=[],this.reviews=[],this.validity=Object(n.m)(t.validity),this.invoices=[],this.budgetApproveDate=Object(n.g)(t.budgetApproveDate),this.budgetId=Object(n.m)(t.budgetId),this.budgetPersonalId=Object(n.m)(t.budgetPersonalId),this.orderId=Object(n.m)(t.orderId),this.orderPersonalId=Object(n.m)(t.orderPersonalId),l.permissions.mechanics&&(this.vehicleId=Object(n.m)(t.vehicleId),this.vehicleOdometer=Object(n.m)(t.vehicleOdometer),this.vehicle=Object(n.q)(t.vehicle)),this.insertReviews=Ct,this.insertReview=function(t){e.reviews.push(new Nt(t,r))},this.getObject=function(){var t=JSON.parse(JSON.stringify({consumerCpfCnpj:Object(n.r)(e.consumerCpfCnpj)?Object(n.r)(e.consumerCpfCnpj).replace(n.A,""):null,cashierId:Object(n.m)(e.cashierId),commercialConditionsIds:Object(n.d)(e.commercialConditionsIds),tags:Object(n.d)(e.tags),payments:e.payments.map((function(e){return e.id?e.id:e})),reviews:e.reviews.map(xt),validity:Object(n.m)(e.validity),invoices:Object(n.d)(e.invoices),budgetApproveDate:Object(n.g)(e.budgetApproveDate),budgetId:Object(n.m)(e.budgetId),budgetPersonalId:Object(n.m)(e.budgetPersonalId),orderId:Object(n.m)(e.orderId),orderPersonalId:Object(n.m)(e.orderPersonalId)}));return l.permissions.mechanics&&(t.vehicleId=Object(n.m)(e.vehicleId),t.vehicleOdometer=Object(n.m)(e.vehicleOdometer)),Object(n.y)(t,{keepNull:!1,keepFalse:!1})},Array.isArray(t.tags)&&t.tags.forEach((function(t){e.tags.find((function(e){return e===t}))||e.tags.push(t)})),Array.isArray(t.reviews)&&this.insertReviews(t.reviews,r),Array.isArray(t.invoices)&&t.invoices.forEach((function(t){return e.invoices.push(t)})),Array.isArray(t.payments)&&t.payments.forEach((function(t){t.id?e.payments.push(new te(t,{order:c})):e.payments.push(t)}))},Nt=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),this.user=Object(n.q)(t.user),this.title=Object(n.r)(t.title),this.status=Object(n.r)(t.status),this.date=Object(n.g)(t.date),this.description=Object(n.r)(t.description),this.validity=Object(n.m)(t.validity),this.commercialConditionsIds=Object(n.d)(t.commercialConditionsIds),this.groups=[],Array.isArray(t.groups)&&t.groups.forEach((function(g){return e.groups.push(new yt(g,r).getObject())})),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({user:Object(n.q)(e.user),title:Object(n.r)(e.title),status:Object(n.r)(e.status),date:Object(n.g)(e.date),description:Object(n.r)(e.description),validity:Object(n.m)(e.validity),groups:Object(n.d)(e.groups),commercialConditionsIds:Object(n.d)(e.commercialConditionsIds)})),{keepFalse:!1,keepNull:!1})}},Tt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(e)||(e={});var t=e.group||this,r=e.entity||this.entity;r.options.decimalPlaces;return new Promise(function(){var e=Object(V.a)(regeneratorRuntime.mark((function e(r,n){var o,c,l,d,O,v,h,j;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{o=0,c=0,l=0,d=0,O=0,v=0,h=0,j=0,t.products.forEach((function(p){o=parseFloat((o+p.total).toFixed(2)),l=parseFloat((l+p.discountTotal).toFixed(2)),O=parseFloat((O+p.profitTotal).toFixed(2)),h=parseFloat((h+p.costTotal).toFixed(2))})),t.services.forEach((function(s){c=parseFloat((c+s.total).toFixed(2)),d=parseFloat((d+s.discountTotal).toFixed(2)),v=parseFloat((v+s.profitTotal).toFixed(2)),j=parseFloat((j+s.costTotal).toFixed(2))})),t.productCostTotal=h,t.serviceCostTotal=j,t.productProfitTotal=O,t.serviceProfitTotal=v,t.productTotal=o,t.serviceTotal=c,t.productDiscountTotal=l,t.serviceDiscountTotal=d,t.discountTotal=parseFloat((l+d).toFixed(2)),t.costTotal=parseFloat((h+j).toFixed(2)),t.profitTotal=parseFloat((O+v).toFixed(2)),t.total=parseFloat((o+c).toFixed(2)),t.totalWithoutDiscount=parseFloat((t.total+t.discountTotal).toFixed(2)),r(t)}catch(e){n(e)}case 1:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}())},Ft=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(e)||(e={});var t=e.order||this,r=e.entity||this.entity;r.options.decimalPlaces;return new Promise(function(){var e=Object(V.a)(regeneratorRuntime.mark((function e(r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{t.total=0,t.profitTotal=0,t.costTotal=0,t.discountTotal=0,t.productTotal=0,t.serviceTotal=0,t.totalWithoutDiscount=0,t.groups.forEach((function(g){t.total=parseFloat((t.total+g.total).toFixed(2)),t.discountTotal=parseFloat((t.discountTotal+g.discountTotal).toFixed(2)),t.productTotal=parseFloat((t.productTotal+g.productTotal).toFixed(2)),t.serviceTotal=parseFloat((t.serviceTotal+g.serviceTotal).toFixed(2)),t.profitTotal=parseFloat((t.profitTotal+g.profitTotal).toFixed(2)),t.costTotal=parseFloat((t.costTotal+g.costTotal).toFixed(2))})),t.totalWithoutDiscount=parseFloat((t.total+t.discountTotal).toFixed(2)),r(t)}catch(e){n(e)}case 1:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}())},wt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(e)||(e={});var t=e.order||this;return new Promise(function(){var e=Object(V.a)(regeneratorRuntime.mark((function e(r,n){var o,c,l,d,O,v,h,j,m,f,y,I,S,C,x,A,N,T;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,o=!1,c=!1,e.prev=3,d=pt(t.groups);case 5:return e.next=7,d.next();case 7:if(!(o=!(O=e.sent).done)){e.next=72;break}v=O.value,h=!1,j=!1,e.prev=11,f=pt(v.products);case 13:return e.next=15,f.next();case 15:if(!(h=!(y=e.sent).done)){e.next=22;break}return I=y.value,e.next=19,I.update().catch((function(e){throw e}));case 19:h=!1,e.next=13;break;case 22:e.next=28;break;case 24:e.prev=24,e.t0=e.catch(11),j=!0,m=e.t0;case 28:if(e.prev=28,e.prev=29,!h||null==f.return){e.next=33;break}return e.next=33,f.return();case 33:if(e.prev=33,!j){e.next=36;break}throw m;case 36:return e.finish(33);case 37:return e.finish(28);case 38:S=!1,C=!1,e.prev=40,A=pt(v.services);case 42:return e.next=44,A.next();case 44:if(!(S=!(N=e.sent).done)){e.next=51;break}return T=N.value,e.next=48,T.update().catch((function(e){throw e}));case 48:S=!1,e.next=42;break;case 51:e.next=57;break;case 53:e.prev=53,e.t1=e.catch(40),C=!0,x=e.t1;case 57:if(e.prev=57,e.prev=58,!S||null==A.return){e.next=62;break}return e.next=62,A.return();case 62:if(e.prev=62,!C){e.next=65;break}throw x;case 65:return e.finish(62);case 66:return e.finish(57);case 67:return e.next=69,v.update().catch((function(e){throw e}));case 69:o=!1,e.next=5;break;case 72:e.next=78;break;case 74:e.prev=74,e.t2=e.catch(3),c=!0,l=e.t2;case 78:if(e.prev=78,e.prev=79,!o||null==d.return){e.next=83;break}return e.next=83,d.return();case 83:if(e.prev=83,!c){e.next=86;break}throw l;case 86:return e.finish(83);case 87:return e.finish(78);case 88:t.updateTotal().then(r).catch(n),e.next=94;break;case 91:e.prev=91,e.t3=e.catch(0),n(e.t3);case 94:case"end":return e.stop()}}),e,null,[[0,91],[3,74,78,88],[11,24,28,38],[29,,33,37],[40,53,57,67],[58,,62,66],[79,,83,87]])})));return function(t,r){return e.apply(this,arguments)}}())};(gt.prototype=Object.create(P.prototype)).constructor=gt,gt.obsolete="Orçamento em todas revisões vencidas e obsoleto",gt.displayProductComplete=function(e){var t,r=String((null==e?void 0:e.description)||""),code=String((null==e?void 0:e.code)||""),n=String((null==e||null===(t=e.manufacturer)||void 0===t?void 0:t.name)||""),o=!(!r||!code)&&r.includes(code),c=!(!r||!n)&&r.includes(n),l="";return l+=r,!o&&code&&(l+=" ".concat(code)),!c&&n&&(l+=" ".concat(n)),l};var Pt=gt,Et=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),Object(n.w)(t.historic)&&(t.historic=JSON.parse(t.historic)),Object(n.w)(t.assets)&&(t.assets=JSON.parse(t.assets)),Object(n.w)(t.files)&&(t.files=JSON.parse(t.files)),Object(n.w)(t.followUp)&&(t.followUp=JSON.parse(t.followUp)),w.checkEntities(t,r),P.call(this,t,r),this.creatorUserId=Object(n.m)(t.creatorUserId),this.requesterUserId=Object(n.m)(t.requesterUserId),this.siteId=Object(n.m)(t.siteId),this.siteAreaId=Object(n.m)(t.siteAreaId),this.technicianUserId=Object(n.m)(t.technicianUserId),this.ticketsCategoryId=Object(n.m)(t.ticketsCategoryId),this.type=Object(n.r)(t.type),this.title=Object(n.r)(t.title),this.description=Object(n.r)(t.description),this.priority=Object(n.r)(t.priority),this.date=Object(n.g)(t.date),this.scheduleDate=Object(n.g)(t.scheduleDate),this.solutionDate=Object(n.g)(t.solutionDate),this.closingDate=Object(n.g)(t.closingDate),this.status=Object(n.r)(t.status),this.creator=Object(n.q)(t.creator),this.technician=Object(n.q)(t.technician),this.requester=Object(n.q)(t.requester),this.assets=[],this.files=[],this.followUp=[],this.insertFollowUp=function(t){e.followUp.push(new st(t,{type:"ticket"}))},this.insertAsset=function(t){if(t.id&&(t.document.Planta!=e.siteId||t.document.Área!=e.siteAreaId))throw"Equipamento inválido";if(!t.id||e.assets.find((function(a){return a.id==t.id}))||e.assets.find((function(a){return a==t.id}))){if(e.assets.find((function(a){return a==t}))||e.assets.find((function(a){return a.id==t})))throw"Equipamento já consta na lista";e.assets.push(t)}else e.assets.push(t)},this.removeAsset=function(t){var r=e.assets.findIndex((function(a){return a.id==t.id}));if(!(r>=0))throw"Equipamento não encontrado";e.assets.splice(r,1)},this.getTitle=function(){var title="";return e.personalId&&(title+=e.personalId),e.title&&(title+=" - ".concat(e.title)),e.description&&(title+=" - ".concat(e.description)),title.substring(0,50)},this.getObject=function(t){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),personalId:Object(n.m)(e.personalId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),creatorUserId:Object(n.m)(e.creatorUserId),requesterUserId:Object(n.m)(e.requesterUserId),siteId:Object(n.m)(e.siteId),siteAreaId:Object(n.m)(e.siteAreaId),technicianUserId:Object(n.m)(e.technicianUserId),ticketsCategoryId:Object(n.m)(e.ticketsCategoryId),type:Object(n.r)(e.type),title:Object(n.r)(e.title),description:Object(n.r)(e.description),priority:Object(n.r)(e.priority),date:Object(n.g)(e.date),scheduleDate:Object(n.g)(e.scheduleDate),solutionDate:Object(n.g)(e.solutionDate),closingDate:Object(n.g)(e.closingDate),status:Object(n.r)(e.status),assets:e.assets.map((function(e){return e.id||e})),files:e.files.map((function(e){return e.getObject()}))})),{keepEmpty:!0})},Array.isArray(t.assets)&&t.assets.forEach((function(t){return e.insertAsset(t)})),Array.isArray(t.files)&&t.files.forEach((function(t){return G.insertFile(t,e.files)})),Array.isArray(t.followUp)&&t.followUp.forEach((function(t){return e.insertFollowUp(t)}))};(Et.prototype=Object.create(P.prototype)).constructor=Et,Et.type=["Incidente","Requisição"],Et.status=["Novo","Atribuído","Em Andamento","Programado","Pendente","Solucionado","Fechado"],Et.priorityOptions=[{value:0,text:"0 - Urgente"},{value:1,text:"1 - Alta"},{value:2,text:"2 - Média"},{value:3,text:"3 - Baixa"}];var Dt=Et,Jt=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.parentId=Object(n.m)(t.parentId),this.name=Object(n.r)(t.name),this.path=Object(n.r)(t.path),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),personalId:Object(n.m)(e.personalId),parentId:Object(n.m)(e.parentId),name:Object(n.r)(e.name),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt)})),{keepNull:!0})},this.getTitle=function(){var t=e.name;return t||""}};(Jt.prototype=Object.create(P.prototype)).constructor=Jt;var Mt=Jt,kt=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.brand=Object(n.r)(t.brand),this.model=Object(n.r)(t.model),this.engine=Object(n.r)(t.engine),this.lp=Object(n.r)(t.lp),this.getTitle=function(){var t=e.brand?String(e.brand):"",r=e.model?String(e.model):"",n=e.lp?String(e.lp):"";if(t||r||n){var title="";return t&&(title+=t),r&&(title+=" - ".concat(r)),n&&(title+=" - ".concat(n)),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),lp:Object(n.r)(e.lp),model:Object(n.r)(e.model),brand:Object(n.r)(e.brand),engine:Object(n.r)(e.engine)})))}};(kt.prototype=Object.create(P.prototype)).constructor=kt;var Rt=kt,qt=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.name=Object(n.r)(t.name),this.products=[],Array.isArray(t.products)&&t.products.forEach((function(t){return e.products.push(t)})),this.getTitle=function(){var t=e.name?String(e.name):"";if(t){var title="";return t&&(title+=t),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),name:Object(n.r)(e.name)})))}};(qt.prototype=Object.create(P.prototype)).constructor=qt;var Vt=qt,Bt=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),this.entity=new w(r.entity).getObject("permissions"),this.entityId=parseInt(t.entityId)?t.entityId:this.entity.id||null,this.date=Object(n.g)(t.date),this.productId=Object(n.m)(t.productId),this.stockId=Object(n.m)(t.stockId),this.productInvoiceId=Object(n.m)(t.productInvoiceId),this.productInvoiceItemCodigo=Object(n.r)(t.productInvoiceItemCodigo),this.orderId=Object(n.m)(t.orderId);var o=Object(n.e)(t.in);this.in=null===o||o,this.amount=Object(n.l)(t.amount,4),this.userId=Object(n.m)(t.userId||(r.user&&r.user.id?r.user.id:null)),this.note=Object(n.r)(t.note),this.getTitle=function(){var t=e.date?new Date(e.date).toLocaleDateString():"";if(t){var title="";return t&&(title+=t),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({entityId:Object(n.m)(e.entityId),date:Object(n.g)(e.date),productId:Object(n.m)(e.productId),stockId:Object(n.m)(e.stockId),productInvoiceId:Object(n.m)(e.productInvoiceId),productInvoiceItemCodigo:Object(n.r)(e.productInvoiceItemCodigo),orderId:Object(n.m)(e.orderId),in:Object(n.e)(e.in),amount:Object(n.l)(e.amount,4),userId:Object(n.m)(e.userId),note:Object(n.r)(e.note)})))}},Lt=(r(96),r(163),r(102),{ufsOptions:function(){return[{value:"AC",textComplete:"AC - Acre",text:"AC"},{value:"AL",textComplete:"AL - Alagoas",text:"AL"},{value:"AP",textComplete:"AP - Amapá",text:"AP"},{value:"AM",textComplete:"AM - Amazonas",text:"AM"},{value:"BA",textComplete:"BA - Bahia",text:"BA"},{value:"CE",textComplete:"CE - Ceará",text:"CE"},{value:"DF",textComplete:"DF - Distrito Federal",text:"DF"},{value:"ES",textComplete:"ES - Espírito Santo",text:"ES"},{value:"GO",textComplete:"GO - Goiás",text:"GO"},{value:"MA",textComplete:"MA - Maranhão",text:"MA"},{value:"MT",textComplete:"MT - Mato Grosso",text:"MT"},{value:"MS",textComplete:"MS - Mato Grosso do Sul",text:"MS"},{value:"MG",textComplete:"MG - Minas Gerais",text:"MG"},{value:"PA",textComplete:"PA - Pará",text:"PA"},{value:"PB",textComplete:"PB - Paraíba",text:"PB"},{value:"PR",textComplete:"PR - Paraná",text:"PR"},{value:"PE",textComplete:"PE - Pernambuco",text:"PE"},{value:"PI",textComplete:"PI - Piauí",text:"PI"},{value:"RJ",textComplete:"RJ - Rio de Janeiro",text:"RJ"},{value:"RN",textComplete:"RN - Rio Grande do Norte",text:"RN"},{value:"RS",textComplete:"RS - Rio Grande do Sul",text:"RS"},{value:"RO",textComplete:"RO - Rondônia",text:"RO"},{value:"RR",textComplete:"RR - Roraima",text:"RR"},{value:"SC",textComplete:"SC - Santa Catarina",text:"SC"},{value:"SP",textComplete:"SP - São Paulo",text:"SP"},{value:"SE",textComplete:"SE - Sergipe",text:"SE"},{value:"TO",textComplete:"TO - Tocantins",text:"TO"}]}}),Ut=Ne.typeOptions,zt=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),this.name=Object(n.r)(t.name),this.operation=new Gt(t.operation),this.getTitle=function(){var t=e.name?String(e.name):"";if(t){var title="";return t&&(title+=t),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),name:Object(n.r)(e.name),operation:e.operation.getObject()})))}},Gt=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=["ICMS","PIS","COFINS"];this.natureza=Object(n.r)(t.natureza),this.saida=Object(n.e)(t.saida),this.consumidorFinal=Object(n.e)(t.consumidorFinal),this.informacoesComplementares=Object(n.r)(t.informacoesComplementares),this.tax=[],this.invoiceTypes=[],this.insertTax=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.tax.push(new _t(t))},this.insertInvoiceType=function(t){if(e.invoiceTypes.includes(t))throw"Tipo já consta na lista";e.invoiceTypes.push(t)},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({natureza:Object(n.r)(e.natureza),saida:Object(n.e)(e.saida),consumidorFinal:Object(n.e)(e.consumidorFinal),informacoesComplementares:Object(n.r)(e.informacoesComplementares),tax:e.tax.map((function(e){return e.getObject()})),invoiceTypes:Object(n.d)(e.invoiceTypes)})))},Array.isArray(t.tax)&&t.tax.forEach((function(t){return e.tax.push(new _t(t))})),this.tax.length||o.forEach((function(t){return e.tax.push(new _t({type:t}))})),Array.isArray(t.invoiceTypes)&&t.invoiceTypes.forEach((function(t){return e.insertInvoiceType(t)}))},_t=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object(n.v)(t)||(t={}),this.type=Object(n.r)(t.type),this.rules=[],this.insertRule=function(t,r){r>=0?e.rules.splice(r,0,new Xt(t)):e.rules.push(new Xt(t))},this.removeRule=function(t){if(!(t>=0))throw"Índice inválido";e.rules.splice(t,1)},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({type:Object(n.r)(e.type),rules:e.rules.map((function(e){return e.getObject()}))})))},Array.isArray(t.rules)?t.rules.forEach((function(t){return e.rules.push(new Xt(t))})):this.rules.length||this.rules.push(new Xt)},Xt=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),this.conditions=Object(n.q)(t.conditions)||{},this.cst=Object(n.r)(t.cst),this.cfop=Object(n.r)(t.cfop),this.bc=Object(n.l)(t.bc,4),this.aliquota=Object(n.l)(t.aliquota,4),this.modalidadeDeterminacao=Object(n.m)(t.modalidadeDeterminacao),this.substituicaoTributaria=Object(n.q)(t.substituicaoTributaria)||{},this.margemValorAdicionado=Object(n.l)(t.margemValorAdicionado,4),this.match=function(t,r){var o,c="string"==typeof(null===(o=r.destinatario)||void 0===o?void 0:o.cpfCnpj)?r.destinatario.cpfCnpj.replace(n.A,""):null,l=null==c?void 0:c.length,d=11===l?"pf":14===l?"pj":null,O=r.destinatario&&r.destinatario.uf?r.destinatario.uf:null,v=t.tax,h=v?v.ncm:null,j=t.id;return!Object.entries(e.conditions).length||(!!(Array.isArray(e.conditions.cpfCnpj)&&e.conditions.cpfCnpj.length&&c&&e.conditions.cpfCnpj.includes(c))||(!(!Array.isArray(e.conditions.personType)||1!==e.conditions.personType.length||!d||e.conditions.personType[0]!==d||"pj"!==d||1!==r.destinatario.indicadorInscricaoEstadual)||(!!(Array.isArray(e.conditions.uf)&&O&&e.conditions.uf.includes(O))||(!!(Array.isArray(e.conditions.ncm)&&h&&e.conditions.ncm.map((function(e){return e.replace(/\./g,"")})).includes(h.replace(/\./g,"")))||(!!(Array.isArray(e.conditions.productId)&&id&&e.conditions.productId.includes(j))||void 0)))))},this.insertCondition=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Object.entries(e.conditions).length>0)throw"Só é permitido uma condição por regra";Object.entries(Object(n.y)(t,{keepNull:!1})).forEach((function(t){var r=t[0];if(e.conditions[r]){if(e.conditions[r].find((function(e){return e==t[1]})))throw"Valor já consta na regra";e.conditions[r].push(t[1])}else e.conditions[r]=[t[1]]}))},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({conditions:Object(n.q)(e.conditions),cst:Object(n.r)(e.cst),cfop:Object(n.r)(e.cfop),bc:Object(n.l)(e.bc,4),aliquota:Object(n.l)(e.aliquota,4),modalidadeDeterminacao:Object(n.m)(e.modalidadeDeterminacao),substituicaoTributaria:Object(n.q)(e.substituicaoTributaria),margemValorAdicionado:Object(n.l)(e.margemValorAdicionado,4)})))},Array.isArray(t.conditions)&&t.conditions.forEach((function(t){e.conditions.push(new Wt(t))}))},Wt=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=Ut.find((function(e){return e.value===t.personType}));this.personType=o?o.value:null,this.uf=Object(n.r)(t.uf),this.ncm=Object(n.r)(t.ncm),this.categoryId=Object(n.r)(t.categoryId),this.productId=Object(n.m)(t.productId),this.cpfCnpj=Object(n.r)(t.cpfCnpj),this.getObject=function(){var t=Ut.find((function(t){return t.value===e.personType}));return Object(n.y)(JSON.parse(JSON.stringify({personType:t?t.value:null,uf:Object(n.r)(e.uf),ncm:Object(n.r)(e.ncm),categoryId:Object(n.r)(e.categoryId),productId:Object(n.m)(e.productId),cpfCnpj:Object(n.r)(e.cpfCnpj)})))}};(zt.prototype=Object.create(P.prototype)).constructor=zt,Xt.Condition=Wt,_t.Rule=Xt,Gt.Tax=_t,zt.Operation=Gt;var Zt=zt;function Qt(object,e){var t=Object.keys(object);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(object);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(object,e).enumerable}))),t.push.apply(t,r)}return t}function $t(e){for(var i=1;i1&&void 0!==arguments[1]?arguments[1]:{};if(!Object(n.v)(t))throw"Responsável autorizado inválido";Object.entries(t).forEach((function(e){if("CPF"===e[0]){if(11!==String(e[1]).length)throw"CPF inválido para responsável autorizado"}else{if("CNPJ"!==e[0])throw"Responsável autorizado inválido";if(14!==String(e[1]).length)throw"CNPJ inválido para responsável autorizado"}})),e.responsavelAutorizado.push(t)},yi=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Object(n.v)(e))throw"Pagamento inválido na inserção de pagamentos";if(!Object(n.v)(t))throw"Opções inválidas na inserção de pagamentos";if(!Object(n.v)(t.entity))throw"Entidade inválida na inserçao de pagamentos";var r=t.nfe;e=new _i(e,t),r.pagamentos.push(e)},Ii=function(e,t,r){if(!Object(n.v)(t)&&!r.orderProduct)throw"Item inválido na inserção de itens";if(!Object(n.v)(r))throw"Opções inválidas na inserção de itens";if(!Object(n.v)(r.entity))throw"Entidade inválida na inserção de itens";t=new Mi(t,r),e.itens.push(t)},Si=function(e){e.itens.splice(0,e.itens.length)},Ci=function(e,t){if(!e)throw"Nenhuma nota informada";if(!t)throw"Falta configurações";var r=t.orders,n=t.taxOperation;r&&r.forEach((function(r){r.groups.forEach((function(o){return o.products.forEach((function(o){var c=r.products.find((function(e){return e.id==o.id}));Ii(e,null,$t($t({},t),{},{orderProduct:o,product:c,nfe:e,taxOperation:n}))}))}))})),e.total.update()},xi=function(e,t){try{return e.startsWith("x")?"1"===t.codigoIdentificacaoDestino?e.replace("x","5"):"2"===t.codigoIdentificacaoDestino?e.replace("x","6"):null:e}catch(e){throw console.error(e),"Falha na captura do cfop"}},Ai=function(e,t){try{return e.tax.find((function(e){return e.type===t}))}catch(e){throw console.error(e),"Falha na captura do imposto"}},Ni=function(e){return e?{ddd:(e=(e=e.replace(n.A,"")).match(n.b)[0]).substring(0,2),numero:e.substring(2)}:null},Ti=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{product:product,taxOperation:taxOperation,type:type,nfe:nfe};try{var t=e.product,r=e.taxOperation,n=e.type,o=e.nfe,c=new Zt(r),l=Ai(c.operation,n),d=l.rules,O=null;return d.every((function(e){return!e.match(t,o)||(O=e,!1)})),O}catch(e){throw console.error(e),"Falha na captura da regra"}},Fi=function(e){return!!(e&&1===e.length&&new Date(e[0]&&e[0].gdata?e[0].gdata.dueDate:null)0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=function(){var e;return v.uf===(null==l||null===(e=l.adresses)||void 0===e?void 0:e[0].uf)?"1":"2"};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var c=r,l=c.customerSupplier,d=c.orders,O=c.fromXML,v=c.entity;this.setOperation=function(t,n){fi(e,t,$t($t({},r),n))},this.reloadEmitente=function(t){e.emitente=new Ei(null,{entity:t})},this.reloadDestinatario=function(t){e.destinatario=new Di(null,{customerSupplier:t})},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({idIntegracao:Object(n.r)(e.idIntegracao),versaoManual:Object(n.r)(e.versaoManual),codigo:Object(n.r)(e.codigo),serie:Object(n.l)(e.serie),finalidade:Object(n.r)(e.finalidade),natureza:Object(n.r)(e.natureza),dataEmissao:Object(n.g)(e.dataEmissao),dataSaidaEntrada:Object(n.g)(e.dataSaidaEntrada),saida:Object(n.e)(e.saida),presencial:Object(n.e)(e.presencial),tipoImpressao:Object(n.r)(e.tipoImpressao),tipoEmissao:Object(n.r)(e.tipoEmissao),codigoIdentificacaoDestino:Object(n.r)(e.codigoIdentificacaoDestino),codigoMunicipioFatoGerador:Object(n.r)(e.codigoMunicipioFatoGerador),consumidorFinal:Object(n.e)(e.consumidorFinal),emitente:e.emitente.getObject(),destinatario:e.destinatario.getObject(),itens:e.itens.map((function(e){return e.getObject()})),total:e.total.getObject(),pagamentos:e.pagamentos.map((function(e){return e.getObject()})),cobranca:e.cobranca.getObject(),informacoesComplementaresContribuinte:Object(n.r)(e.informacoesComplementaresContribuinte),informacoesComplementares:Object(n.r)(e.informacoesComplementares),enviaremail:Object(n.e)(e.enviaremail),responsavelAutorizado:Object(n.d)(e.responsavelAutorizado),intermediador:Object(n.m)(e.intermediador)})),{keepNull:!1})},this.idIntegracao=Object(n.r)(t.idIntegracao),this.versaoManual=Object(n.r)(O?t["@_versao"]:t.versaoManual),this.codigo=Object(n.r)(O?t.ide.cNF:t.codigo),this.serie=Object(n.l)(O?t.ide.serie:t.serie);var h=Ht.find((function(e){return e.value===Object(n.r)(O?t.ide.finNFe:t.finalidade)}));this.finalidade=h?h.value:null,this.natureza=Object(n.r)(t.natureza),this.dataEmissao=Object(n.g)(O?t.ide.dhEmi:t.dataEmissao||new Date),this.dataSaidaEntrada=Object(n.g)(O?t.ide.dhSaiEnt:t.dataSaidaEntrada||new Date),this.saida=Object(n.e)(O?t.ide.tpNF:t.saida),this.presencial=Object(n.e)(O?t.ide.indPres:t.presencial);var j=Kt.find((function(e){return e.value===Object(n.r)(O?t.ide.tpImp:t.tipoImpressao)}));this.tipoImpressao=j?j.value:null;var m=ei.find((function(e){return e.value===Object(n.r)(O?t.ide.tpEmis:t.tipoEmissao)}));this.tipoEmissao=m?m.value:null;var f=ii.find((function(e){return e.value===Object(n.r)(O?t.ide.idDest:t.codigoIdentificacaoDestino||o())}));this.codigoIdentificacaoDestino=f?f.value:null,this.codigoMunicipioFatoGerador=Object(n.r)(O?t.ide.cMunFG:t.codigoMunicipioFatoGerador||v.ibge),this.consumidorFinal=Object(n.e)(O?t.ide.indFinal:t.consumidorFinal),this.emitente=new Ei(O?t.emit:t.emitente,r),this.destinatario=new Di(O?t.dest:t.destinatario,r),this.itens=[],this.total=new Gi(t.total,$t($t({},r),{},{nfe:this})),this.pagamentos=[],this.cobranca=new Xi(O?t.cobr:t.cobranca),this.informacoesComplementaresContribuinte=Object(n.r)(O&&t.infAdic&&t.infAdic.infAdFisco?t.infAdic.infAdFisco:t.informacoesComplementaresContribuinte),this.informacoesComplementares=Object(n.r)(O&&t.infAdic&&t.infAdic.infCpl?t.infAdic.infCpl:t.informacoesComplementares),this.enviaremail=Object(n.e)(t.enviaremail),this.responsavelAutorizado=[];var y=hi.find((function(e){return e.value===Object(n.m)(O?t.ide.indIntermed:t.intermediador)}));this.intermediador=Object(n.m)(y?y.value:null);var I=$t($t({},r),{},{nfe:this});O?(Array.isArray(t.det)?t.det.forEach((function(t){return Ii(e,t,I)})):t.det&&Ii(this,t.det,I),t.pag&&Array.isArray(t.pag.detPag)?t.pag.detPag.forEach((function(e){return yi(e,I)})):t.pag&&t.pag.detPag&&yi(t.pag.detPag,I),Array.isArray(t.autXML)?t.autXML.forEach((function(t){return gi(e,t)})):t.autXML&&gi(this,t.autXML)):(t.itens&&t.itens.forEach((function(t){return Ii(e,t,I)})),t.pagamentos?t.pagamentos.forEach((function(e){return yi(e,I)})):d&&d.forEach((function(t){var n;if(d.length>1&&null!==(n=t.gdata.payments)&&void 0!==n&&n.length)throw"Documento já consta informação de pagamentos";t.gdata.payments&&t.gdata.payments.forEach((function(n){e.pagamentos.push(new _i(null,$t($t({},r),{},{payment:n,payments:t.gdata.payments})))}))})),t.responsavelAutorizado&&t.responsavelAutorizado.forEach((function(t){return gi(e,t)}))),Ci(this,r)},Pi=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.competencia=Object(n.g)(t.competencia||new Date),this.dataEmissao=Object(n.g)(t.dataEmissao||new Date),this.dataVencimento=Object(n.g)(t.dataVencimento),this.serie=Object(n.r)(t.serie),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({competencia:Object(n.g)(e.competencia),dataEmissao:Object(n.g)(e.dataEmissao),dataVencimento:Object(n.g)(e.dataVencimento),serie:Object(n.r)(e.serie)})),{keepNull:!1})}},Ei=function(){var e,t,r,o,c=this,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},d=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{entity:{},fromXML:!1};Object(n.v)(l)||(l={}),Object(n.v)(d)||(d={entity:{},fromXML:!1}),Object(n.v)(d.entity)||(d.entity={});var O=new w(d.entity),v=d.fromXML;this.cpfCnpj=Object(n.r)(v?l.CNPJ||l.CPF:l.cpfCnpj||O.cpfCnpj),this.codigoEstrangeiro=Object(n.r)(l.codigoEstrangeiro),this.endereco=new Ji(v?l.enderEmit:l.endereco,$t($t({},d),{},{getFrom:d.entity})),this.email=Object(n.r)(l.email||O.contactEmail),this.incentivadorCultural=Object(n.e)(l.incentivadorCultural)||!1,this.incentivoFiscal=Object(n.e)(l.incentivoFiscal)||!1,this.inscricaoEstadual=Object(n.r)(v?l.IE:l.inscricaoEstadual||O.gdata.inscricaoEstadual),this.inscricaoMunicipal=Object(n.r)(v?l.IM:l.inscricaoMunicipal||O.gdata.inscricaoMunicipal),this.nomeFantasia=Object(n.r)(v?l.xFant:l.nomeFantasia||O.fantasyName),this.razaoSocial=Object(n.r)(v?l.xNome:l.razaoSocial||O.name);var h=ri.find((function(rt){return rt.value===Object(n.m)(v?l.CRT:l.regimeTributario||O.gdata.regimeTributario)}));this.regimeTributario=h?h.value:null;var j=ai.find((function(e){var t;return e.value===Object(n.m)(null!==(t=l.regimeTributarioEspecial)&&void 0!==t?t:O.gdata.regimeTributarioEspecial)}));this.regimeTributarioEspecial=j?j.value:null,this.simplesNacional=Object(n.e)(l.simplesNacional||O.gdata.simplesNacional),this.telefone=v?Object(n.q)({numero:l.enderEmit.fone}):Object(n.q)(null!==(e=l)&&void 0!==e&&null!==(t=e.telefone)&&void 0!==t&&t.ddd&&null!==(r=l)&&void 0!==r&&null!==(o=r.telefone)&&void 0!==o&&o.numero?l.telefone:Ni(O.contactPhone)),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({cpfCnpj:Object(n.r)(c.cpfCnpj),endereco:c.endereco.getObject(),telefone:Object(n.q)(c.telefone),inscricaoEstadual:Object(n.r)(c.inscricaoEstadual),inscricaoMunicipal:Object(n.r)(c.inscricaoMunicipal),nomeFantasia:Object(n.r)(c.nomeFantasia),razaoSocial:Object(n.r)(c.razaoSocial),regimeTributario:Object(n.m)(c.regimeTributario),incentivadorCultural:Object(n.e)(c.incentivadorCultural),incentivoFiscal:Object(n.e)(c.incentivoFiscal),regimeTributarioEspecial:Object(n.m)(c.regimeTributarioEspecial),simplesNacional:Object(n.e)(c.simplesNacional),email:Object(n.r)(c.email)})),{keepNull:!1})}},Di=function(){var e,t,r,o,c=this,l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},d=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{fromXML:!1};Object(n.v)(l)||(l={}),Object(n.v)(d)||(d={});var O=d,v=O.customerSupplier,h=O.fromXML;this.cpfCnpj=Object(n.r)(h?l.CNPJ||l.CPF:l.cpfCnpj||(null==v?void 0:v.cpfCnpj)),this.razaoSocial=Object(n.r)(h?l.xNome:l.razaoSocial||(null==v?void 0:v.name)),this.endereco=new Ji(h?l.enderDest:l.endereco,$t($t({},d),{},{address:null===(e=d.customerSupplier)||void 0===e||null===(t=e.adresses)||void 0===t?void 0:t[0]})),this.email=Object(n.r)(l.email||(null==v?void 0:v.email)),this.inscricaoEstadual=Object(n.r)(h?l.IE:l.inscricaoEstadual||(null==v?void 0:v.stateId)),this.inscricaoMunicipal=Object(n.r)(h?l.IM:l.inscricaoMunicipal||(null==v?void 0:v.districtId)),this.inscricaoSuframa=Object(n.r)(h?l.ISUF:l.inscricaoSuframa||(null==v?void 0:v.suframa)),this.nomeFantasia=Object(n.r)(l.nomeFantasia||(null==v?void 0:v.fantasyName)),this.orgaoPublico=Object(n.e)(l.orgaoPublico),this.telefone=h?Object(n.q)({numero:l.enderDest.fone}):Object(n.q)(null!==(r=l.telefone)&&void 0!==r&&r.ddd&&null!==(o=l.telefone)&&void 0!==o&&o.numero?l.telefone:Ni(null==v?void 0:v.phone)),this.indicadorInscricaoEstadual=Object(n.m)(h?l.indIEDest:l.indicadorInscricaoEstadual?l.indicadorInscricaoEstadual:"ISENTO"===this.inscricaoEstadual?2:this.inscricaoEstadual?1:9),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({cpfCnpj:Object(n.r)(c.cpfCnpj),razaoSocial:Object(n.r)(c.razaoSocial),endereco:c.endereco.getObject(),email:Object(n.r)(c.email),inscricaoEstadual:Object(n.r)(c.inscricaoEstadual),inscricaoMunicipal:Object(n.r)(c.inscricaoMunicipal),inscricaoSuframa:Object(n.r)(c.inscricaoSuframa),nomeFantasia:Object(n.r)(c.nomeFantasia),orgaoPublico:Object(n.e)(c.orgaoPublico),telefone:Object(n.q)(c.telefone),indicadorInscricaoEstadual:Object(n.m)(c.indicadorInscricaoEstadual)})),{keepNull:!1})}},Ji=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{fromXML:!1,NFSe:!1};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={fromXML:!1,NFSe:!1});var o=r,address=o.address,c=o.fromXML;this.bairro=Object(n.r)(c?t.xBairro:t.bairro||(null==address?void 0:address.district)),this.cep=Object(n.r)(c?t.CEP:t.cep||(null==address?void 0:address.zipcode)),this.codigoCidade=Object(n.r)(c?t.cMun:t.codigoCidade||(null==address?void 0:address.ibge));var l=mi.find((function(e){return e.value===Object(n.r)(c?t.UF:t.estado||(null==address?void 0:address.uf))}));this.estado=l?l.value:null,this.logradouro=Object(n.r)(c?t.xLgr:t.logradouro||(null==address?void 0:address.address)),this.numero=Object(n.r)(c?t.nro:t.numero||(null==address?void 0:address.addressNumber));var d=this.tipoLogradouro=oi.find((function(e){return e.value===Object(n.r)(t.tipoLogradouro)}));this.tipoLogradouro=d?d.value:null,this.codigoPais=Object(n.r)(c?t.cPais:t.codigoPais),this.complemento=Object(n.r)(c?t.xCpl:t.complemento),this.descricaoCidade=Object(n.r)(c?t.xMun:t.descricaoCidade||(null==address?void 0:address.city)),this.descricaoPais=Object(n.r)(c?t.xPais:t.descricaoPais);var O=ci.find((function(br){return br.value===Object(n.r)(t.tipoBairro)}));this.tipoBairro=O?O.value:null,this.getObject=function(){var t=mi.find((function(t){return t.value===Object(n.r)(e.estado)})),r=oi.find((function(t){return t.value===Object(n.r)(e.tipoLogradouro)})),o=ci.find((function(br){return br.value===Object(n.r)(e.tipoBairro)}));return Object(n.y)(JSON.parse(JSON.stringify({bairro:Object(n.r)(e.bairro),cep:Object(n.r)(e.cep),codigoCidade:Object(n.r)(e.codigoCidade),estado:t?t.value:null,logradouro:Object(n.r)(e.logradouro),numero:Object(n.r)(e.numero),codigoPais:Object(n.r)(e.codigoPais),complemento:Object(n.r)(e.complemento),descricaoCidade:Object(n.r)(e.descricaoCidade),descricaoPais:Object(n.r)(e.descricaoPais),tipoLogradouro:r?r.value:null,tipoBairro:o?o.value:null})),{keepNull:!1})}},Mi=function(){var e,t,r,o=this,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Object(n.v)(c)||(c={}),!Object(n.v)(l))throw"Opções inválidas em NFeItem";if(!Object(n.v)(l.nfe))throw"Referencia de NFe inválida no item";var d=l.nfe,O=l.taxOperation,v=l.orderProduct,h=l.product,j=l.fromXML,m=h?h.tax:null,f=(null===(e=l.entity)||void 0===e||null===(t=e.config)||void 0===t?void 0:t.decimalPlaces)||2,y=j?c.prod:c,I={product:h,taxOperation:O,nfe:d},S=(null==h?void 0:h.id)&&(null==O?void 0:O.id),C=S?Ti($t($t({},I),{},{type:"ICMS"})):null,x=S?Ti($t($t({},I),{},{type:"PIS"})):null,A=S?Ti($t($t({},I),{},{type:"COFINS"})):null;this.codigo=Object(n.r)(j?y.cProd:y.codigo||(null==v?void 0:v.personalId)),this.codigoBarras=Object(n.r)(j?y.cEAN:y.codigoBarras||(null==h?void 0:h.gtin)),this.codigoBarrasTributavel=Object(n.r)(j?y.cEANTrib:y.codigoBarrasTributavel||(null==h?void 0:h.gtinTrib)||(null==h?void 0:h.gtin)),this.descricao=Object(n.r)(j?y.xProd:y.descricao||Pt.displayProductComplete(v)),this.ncm=Object(n.r)(j?y.NCM:y.ncm||(null==m?void 0:m.ncm)),this.cest=Object(n.r)(j?y.CEST:y.cest||(null==m?void 0:m.cest)),this.cfop=Object(n.r)(j?y.CFOP:y.cfop)||(null!=C&&C.cfop?xi(C.cfop,d):null),this.valor=Object(n.l)(j?y.vProd:y.valor||(null==v?void 0:v.total),2),this.tributos=new Bi(j?c.imposto:y.tributos,$t($t({},l),{},{item:this,icmsRule:C,pisRule:x,cofinsRule:A})),this.campoeTotal=Object(n.e)(j?y.indTot:y.compoeTotal)||!0,this.nve=Object(n.r)(j?y.NVE:y.nve),this.indicadorEscalaRelevante=Object(n.r)(y.indicadorEscalaRelevante),this.cnpjFabricante=Object(n.r)(y.cnpjFabricante),this.codigoBeneficioFiscal=Object(n.r)(y.codigoBeneficioFiscal),this.exTipi=Object(n.r)(j?y.EXTIPI:y.exTipi||(null==m||null===(r=m.ipi)||void 0===r?void 0:r.excecaoTipi)),this.valorFrete=Object(n.l)(j?y.vFrete:y.valorFrete,2),this.valorSeguro=Object(n.l)(j?y.vSeg:y.valorSeguro,2),this.valorDesconto=Object(n.l)(j?y.vDesc:y.valorDesconto||(null==v?void 0:v.discountTotal),2),this.valorOutros=Object(n.l)(j?y.vOutro:y.valorOutros,2),this.numeroCompra=Object(n.r)(j?y.xPed:y.numeroCompra),this.pedidoCompra=Object(n.r)(j?y.nItemPed:y.pedidoCompra),this.numeroFci=Object(n.r)(j?y.nFCI:y.numeroFci),this.unidade=Object(n.q)(j?{comercial:Object(n.r)(y.uCom),tributavel:Object(n.r)(y.uTrib)}:{comercial:Object(n.r)(y.unidade?y.unidade.comercial:v&&v.unit&&v.unit.initials?v.unit.initials:"UN"),tributavel:Object(n.r)(y.unidade?y.unidade.tributavel:v&&v.unit&&v.unit.initials?v.unit.initials:"UN")}),this.quantidade=Object(n.q)(j?{comercial:Object(n.l)(y.qCom),tributavel:Object(n.l)(y.qTrib)}:{comercial:Object(n.l)(y.quantidade?y.quantidade.comercial:v&&v.amount?v.amount:null,f>4?4:f),tributavel:Object(n.l)(y.quantidade?y.quantidade.tributavel:v&&v.amount?v.amount:null,f>4?4:f)}),this.valorUnitario=Object(n.q)(j?{comercial:Object(n.l)(y.vUnCom),tributavel:Object(n.l)(y.vUnTrib)}:{comercial:Object(n.l)(y.valorUnitario?y.valorUnitario.comercial:v&&v.unitValue?v.unitValue:null,f),tributavel:Object(n.l)(y.valorUnitario?y.valorUnitario.tributavel:v&&v.unitValue?v.unitValue:null,f)}),this.informacoesComplementares=Object(n.r)(j?c.infAdProd:y.informacoesComplementares),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({codigo:Object(n.r)(o.codigo),codigoBarras:Object(n.r)(o.codigoBarras),codigoBarrasTributavel:Object(n.r)(o.codigoBarrasTributavel),descricao:Object(n.r)(o.descricao),ncm:Object(n.r)(o.ncm),cest:Object(n.r)(o.cest),cfop:Object(n.r)(o.cfop),valor:Object(n.l)(o.valor),tributos:o.tributos.getObject(),nve:Object(n.r)(o.nve),exTipi:Object(n.r)(o.exTipi),valorFrete:Object(n.l)(o.valorFrete,2),valorSeguro:Object(n.l)(o.valorSeguro,2),valorDesconto:Object(n.l)(o.valorDesconto,2),valorOutros:Object(n.l)(o.valorOutros,2),numeroCompra:Object(n.r)(o.numeroCompra),pedidoCompra:Object(n.r)(o.pedidoCompra),numeroFci:Object(n.r)(o.numeroFci),unidade:Object(n.q)(o.unidade),quantidade:Object(n.q)(o.quantidade),valorUnitario:Object(n.q)(o.valorUnitario),informacoesComplementares:Object(n.r)(o.informacoesComplementares)})),{keepNull:!1})}},ki=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={});var o=r.orderService||{},c=r.order||{};this.codigo=Object(n.r)(t.codigo),this.discriminacao=Object(n.r)(t.discriminacao||o.description||c.description),this.discriminacao=this.discriminacao?this.discriminacao.normalize("NFD").replace(/[\u0300-\u036f]/g,""):null,this.discriminacao=this.discriminacao?this.discriminacao.replace(/\n/g," "):null,this.quantidade=Object(n.l)(t.quantidade||o.amount||1,4),this.iss=new Ri(t.iss,r),this.valor=new qi(t.valor,r),this.deducao=new Vi(t.deducao,r),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({codigo:Object(n.r)(e.codigo),discriminacao:Object(n.r)(e.discriminacao),quantidade:Object(n.l)(e.quantidade,4),iss:e.iss.getObject(),valor:e.valor.getObject(),deducao:e.deducao.getObject()})),{keepNull:!1})}},Ri=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.NFSe,c=function(){return o&&1===o.prestador.regimeTributario&&5===o.prestador.regimeTributarioEspecial?0:null},l=bi.find((function(e){return e.value==t.tipoTributacao}));this.tipoTributacao=l?l.value:null;var d=Oi.find((function(e){return e.value==t.exigibilidade}));this.exigibilidade=d?d.value:null,this.retido=Object(n.e)(t.retido)||!1,this.aliquota=Object(n.l)(isNaN(parseFloat(t.aliquota))?c():t.aliquota,4),this.valor=Object(n.l)(t.valor,2),this.valorRetido=Object(n.l)(t.valorRetido,2),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({tipoTributacao:Object(n.m)(e.tipoTributacao),exigibilidade:Object(n.m)(e.exigibilidade),retido:Object(n.e)(e.retido),aliquota:Object(n.l)(e.aliquota,4),valor:Object(n.l)(e.valor,2),valorRetido:Object(n.l)(e.valorRetido,2)})),{keepNull:!1})}},qi=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={});var o=r.orderService||{},c=r.order||{};this.servico=Object(n.l)(t.servico||o.totalWithoutDiscount||c.totalWithoutDiscount,2),this.baseCalculo=Object(n.l)(t.baseCalculo,2),this.deducoes=Object(n.l)(t.deducoes,2),this.descontoCondicionado=Object(n.l)(t.descontoCondicionado,2),this.descontoIncondicionado=Object(n.l)(t.descontoIncondicionado,2),this.liquido=Object(n.l)(t.liquido||o.total||c.total,2),this.unitario=Object(n.l)(t.unitario||o.unitValue||c.total,2),this.valorAproximadoTributos=Object(n.l)(t.valorAproximadoTributos,2),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({servico:Object(n.l)(e.servico,2),baseCalculo:Object(n.l)(e.baseCalculo,2),deducoes:Object(n.l)(e.deducoes,2),descontoCondicionado:Object(n.l)(e.descontoCondicionado,2),descontoIncondicionado:Object(n.l)(e.descontoIncondicionado,2),liquido:Object(n.l)(e.liquido,2),unitario:Object(n.l)(e.unitario,2),valorAproximadoTributos:Object(n.l)(e.valorAproximadoTributos,2)})),{keepNull:!1})}},Vi=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=vi.find((function(e){return e.value==t.tipoDeducao}));this.tipoDeducao=r?r.value:null,this.descricao=Object(n.r)(t.descricao),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({tipoDeducao:Object(n.m)(e.tipoDeducao),descricao:Object(n.r)(e.descricao)})),{keepNull:!1})}},Bi=function(){var e,t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Object(n.v)(r)||(r={}),!Object(n.v)(o))throw"Opções inválidas em tributos";if(!Object(n.v)(o.nfe))throw"NFe inválida em tributos";if(!Object(n.v)(o.item))throw"Item inválido em tributos";var c=o.icmsRule,l=o.pisRule,d=o.cofinsRule,O=o.product,v=o.item,h=o.fromXML,j=o.nfe,m="2"===j.codigoIdentificacaoDestino,f=!0===j.consumidorFinal,y=9===(null===(e=j.destinatario)||void 0===e?void 0:e.indicadorInscricaoEstadual),I={rule:c,product:O,item:v,fromXML:h,nfe:j};if(m&&f&&y){if(!h)throw"Erro em tributos, partilha não apta";this.partilha=new Li(h?r.ICMS:r.partilha,I)}this.icms=new Ui(h?r.ICMS:r.icms,I),this.pis=new zi(h?r.PIS:r.pis,{rule:l,product:O,item:v,fromXML:h,nfe:j}),this.cofins=new zi(h?r.COFINS:r.cofins,{rule:d,product:O,item:v,fromXML:h,nfe:j}),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({icms:t.icms.getObject(),pis:t.pis.getObject(),cofins:t.cofins.getObject()})))}},Li=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=r,c=o.fromXML,l=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=r,c=o.fromXML,l={};if(c){var d=t.ICMSUFDest;d&&(l.baseCalculoIcms=Object(n.l)(d.vBCUFDest,2),l.baseCalculoFcp=Object(n.l)(d.vBCFCPUFDest,2),l.percentualIcmsFcp=Object(n.l)(d.pFCPUFDest,4),l.aliquotaInterna=Object(n.l)(d.pICMSUFDest,4),l.aliquotaInterestadual=Object(n.l)(d.pICMSInter,2),l.icmsRelativoFcp=Object(n.l)(d.vFCPUFDest,2),l.icmsInterestadual=Object(n.l)(d.vICMSUFDest,2))}this.baseCalculoIcms=Object(n.l)(l.baseCalculoIcms,2)?baseCalculoIcms:null,this.baseCalculoFcp=Object(n.l)(l.baseCalculoFcp,2),this.percentualIcmsFcp=Object(n.l)(l.percentualIcmsFcp,4),this.aliquotaInterna=Object(n.l)(l.aliquotaInterna,4),this.aliquotaInterestadual=Object(n.l)(l.aliquotaInterestadual,2),this.icmsRelativoFcp=Object(n.l)(l.icmsRelativoFcp,2),this.icmsInterestadual=Object(n.l)(l.icmsInterestadual,2),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({baseCalculoIcms:Object(n.l)(e.baseCalculoIcms,2),baseCalculoFcp:Object(n.l)(e.baseCalculoFcp,2),percentualIcmsFcp:Object(n.l)(e.percentualIcmsFcp,4),aliquotaInterna:Object(n.l)(e.aliquotaInterna,4),aliquotaInterestadual:Object(n.l)(e.aliquotaInterestadual,2),icmsRelativoFcp:Object(n.l)(e.icmsRelativoFcp,2),icmsInterestadual:Object(n.l)(e.icmsInterestadual,2)})),{keepNull:!1})}};this.ufDestino=new l(c?t:t.ufDestino,r),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({ufDestino:e.ufDestino.getObject()})),{keepNull:!1})}},Ui=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};function o(e,t){var r=Object(n.l)(.01*e.aliquota,4),o=Object(n.l)(t*(1+.01*e.margemValorAdicionado),2),c=Object(n.l)(o*r,2),l=Object(n.l)(t*r,2);return Object(n.l)(c-l,2)}function l(e,t){return Object(n.l)(t*(1+.01*e.margemValorAdicionado),2)}var d=r.rule,O=r.product,v=r.item,h=r.fromXML,j=O?O.tax:{};if(!v)throw"Item inválido em ICMS";var m=h?{}:t;if(h){var f=t.ICMS00,y=t.ICMS10,I=t.ICMS20,S=t.ICMS30,C=t.ICMS40,x=t.ICMS51,A=t.ICMS60,N=t.ICMS70,T=t.ICMS90,F=t.ICMSST;t.ICMSSN101,t.ICMSSN102,t.ICMSSN201,t.ICMSSN202,t.ICMSSN500,t.ICMSSN900;f?(m.origem=f.orig,m.cst=f.CST,m.baseCalculo={modalidadeDeterminacao:f.modBC,valor:f.vBC},m.aliquota=f.pICMS,m.valor=f.vICMS,m.fundoCombatePobreza={aliquota:f.pFCP,valor:f.vFCP}):y?(m.origem=y.orig,m.cst=y.CST,m.baseCalculo={modalidadeDeterminacao:y.modBC,valor:y.vBC},m.aliquota=y.pICMS,m.valor=y.vICMS,m.fundoCombatePobreza={baseCalculo:{valor:y.vBCFCP},aliquota:y.pFCP,valor:y.vFCP},m.substituicaoTributaria={baseCalculo:{modalidadeDeterminacao:y.modBCST,percentualReducao:y.pRedBCST,valor:y.vBCST},aliquota:y.pICMSST,valor:y.vICMSST,margemValorAdicionado:{percentual:y.pMVAST},fundoCombatePobreza:{baseCalculo:{valor:y.vBCFCPST},aliquota:y.pFCPST,valor:y.vFCPST}}):I?(m.origem=I.orig,m.cst=I.CST,m.baseCalculo={modalidadeDeterminacao:I.modBC,percentualReducao:I.pRedBC,valor:I.vBC},m.aliquota=I.pICMS,m.valor=I.vICMS,m.fundoCombatePobreza={baseCalculo:{valor:I.vBCFCP},aliquota:I.pFCP,valor:I.vFCP},m.desoneracao={valor:I.vICMSDeson,motivo:I.motDesICMS}):S?(m.origem=S.orig,m.cst=S.CST,m.substituicaoTributaria={baseCalculo:{modalidadeDeterminacao:S.modBCST,percentualReducao:S.pRedBCST,valor:S.vBCST},margemValorAdicionado:{percentual:S.pMVAST},aliquota:S.pICMSST,valor:S.vICMSST,fundoCombatePobreza:{baseCalculo:{valor:S.vBCFCPST},aliquota:S.pFCPST,valor:S.vFCPST}},m.desoneracao={valor:S.vICMSDeson,motivo:S.motDesICMS}):C?(m.origem=C.orig,m.cst=C.CST,m.desoneracao={valor:C.vICMSDeson,motivo:C.motDesICMS}):x?(m.origem=x.orig,m.cst=x.CST,m.baseCalculo={modalidadeDeterminacao:x.modBC,percentualReducao:x.pRedBC,valor:x.vBC},m.aliquota=x.pICMS,m.valor=x.vICMSOp,m.diferimento={percentual:x.pDif,valor:x.vICMSDif,valorIcmsDevido:x.vICMS},m.fundoCombatePobreza={baseCalculo:{valor:x.vBCFCP},aliquota:x.pFCP,valor:x.vFCP}):A?(m.origem=A.orig,m.cst=A.CST,m.substituicaoTributaria={baseCalculo:{valor:A.vBCST},aliquota:A.pICMSST,valor:A.vICMSST,fundoCombatePobreza:{baseCalculo:{valor:A.vBCFCPST},aliquota:A.pFCPST,valor:A.vFCPST}},m.valor=A.vICMS,m.efetivo={baseCalculo:{valor:A.vBCEfet,percentualReducao:A.pRedBCEfet},aliquota:A.pICMSEfet,valor:A.vICMSEfet}):N?(m.origem=N.orig,m.cst=N.CST,m.baseCalculo={modalidadeDeterminacao:N.modBC,percentualReducao:N.pRedBC,valor:N.vBC},m.aliquota=N.pICMS,m.valor=N.vICMS,m.fundoCombatePobreza={baseCalculo:{valor:N.vBCFCP},aliquota:N.pFCP,valor:N.vFCP},m.substituicaoTributaria={baseCalculo:{modalidadeDeterminacao:N.modBCST,percentualReducao:N.pRedBCST,valor:N.vBCST},aliquota:N.pICMSST,valor:N.vICMSST,margemValorAdicionado:{percentual:N.pMVAST},fundoCombatePobreza:{baseCalculo:{valor:N.vBCFCPST},aliquota:N.pFCPST,valor:N.vFCPST}},m.desoneracao={valor:N.vICMSDeson,motivo:N.motDesICMS}):T?(m.origem=T.orig,m.cst=T.CST,m.baseCalculo={modalidadeDeterminacao:T.modBC,percentualReducao:T.pRedBC,valor:T.vBC},m.aliquota=T.pICMS,m.valor=T.vICMS,m.fundoCombatePobreza={baseCalculo:{valor:T.vBCFCP},aliquota:T.pFCP,valor:T.vFCP},m.substituicaoTributaria={baseCalculo:{modalidadeDeterminacao:T.modBCST,percentualReducao:T.pRedBCST,valor:T.vBCST},aliquota:T.pICMSST,valor:T.vICMSST,margemValorAdicionado:{percentual:T.pMVAST},fundoCombatePobreza:{baseCalculo:{valor:T.vBCFCPST},aliquota:T.pFCPST,valor:T.vFCPST}},m.desoneracao={valor:T.vICMSDeson,motivo:T.motDesICMS}):F?(m.origem=F.orig,m.cst=F.CST,m.substituicaoTributaria={baseCalculo:{valor:F.vBCSTRet},aliquota:F.pSTm,valor:F.vICMSSTRet,fundoCombatePobreza:{baseCalculo:{valor:F.vBCFCPSTRet},aliquota:F.pFCPSTRet,valor:F.vFCPSTRet},ufDestino:{baseCalculo:{valor:F.vBCSTDest},valor:F.vICMSSTDest}},m.valor=F.vICMSSubstituto,m.efetivo={baseCalculo:{valor:F.vBCEfet,percentualReducao:F.pRedBCEfet},aliquota:F.pICMSEfet,valor:F.vICMSEfet}):t.ICMSSN101?(m.origem=t.ICMSSN101.orig,m.cst=t.ICMSSN101.CSOSN,m.creditoSimplesNacional={percentual:t.ICMSSN101.pCredSN,valor:t.ICMSSN101.vCrediICMSSN}):t.ICMSSN102&&(m.origem=t.ICMSSN102.orig,m.cst=t.ICMSSN102.CSOSN)}else{var w,P,E,D,J,M,k,R,V,B,L=v.valor;if(m.origem=t.origem||(null==j?void 0:j.origem),m.cst=t.cst||(null==d?void 0:d.cst),"202"===m.cst)m.substituicaoTributaria={baseCalculo:{modalidadeDeterminacao:(null===(w=t.substituicaoTributaria)||void 0===w||null===(P=w.baseCalculo)||void 0===P?void 0:P.modalidadeDeterminacao)||(null==d?void 0:d.substituicaoTributaria.modalidadeDeterminacao),percentualReducao:(null===(E=t.substituicaoTributaria)||void 0===E||null===(D=E.baseCalculo)||void 0===D?void 0:D.percentualReducao)||(null==d?void 0:d.substituicaoTributaria.percentualReducao),valor:(null===(J=t.substituicaoTributaria)||void 0===J||null===(M=J.baseCalculo)||void 0===M?void 0:M.valor)||(d?l(d,L):null)},margemValorAdicionado:{percentual:(null===(k=t.substituicaoTributaria)||void 0===k||null===(R=k.margemValorAdicionado)||void 0===R?void 0:R.percentual)||(null==d?void 0:d.margemValorAdicionado)},aliquota:(null===(V=t.substituicaoTributaria)||void 0===V?void 0:V.aliquota)||(null==d?void 0:d.aliquota),valor:(null===(B=t.substituicaoTributaria)||void 0===B?void 0:B.valor)||(d?o(d,L):null)}}var U=ni.find((function(e){return e.value==m.origem}));this.origem=U?U.value:null;var z=[].concat(Object(c.a)(si),Object(c.a)(ui)).find((function(e){return e.value==m.cst}));this.cst=z?z.value:null,this.baseCalculo=Object(n.q)(m.baseCalculo),this.aliquota=Object(n.l)(m.aliquota,4),this.valor=Object(n.l)(m.valor,4),this.substituicaoTributaria=Object(n.q)(m.substituicaoTributaria),this.efetivo=Object(n.q)(m.efetivo),this.getObject=function(){var t={},r=ni.find((function(t){return t.value==e.origem}));t.origem=r?r.value:null;var o=[].concat(Object(c.a)(si),Object(c.a)(ui)).find((function(t){return t.value==e.cst}));return t.cst=o?o.value:null,"00"===t.cst?(t.baseCalculo=Object(n.q)(e.baseCalculo),t.aliquota=Object(n.l)(e.aliquota,4),t.valor=Object(n.l)(e.valor,4)):"10"===t.cst?(t.baseCalculo=Object(n.q)(e.baseCalculo),t.aliquota=Object(n.l)(e.aliquota,4),t.valor=Object(n.l)(e.valor,4),t.substituicaoTributaria=Object(n.q)(e.substituicaoTributaria)):"20"===t.cst?(t.baseCalculo=Object(n.q)(e.baseCalculo),t.aliquota=Object(n.l)(e.aliquota,4),t.valor=Object(n.l)(e.valor,4)):"60"===t.cst?(t.substituicaoTributaria=Object(n.q)(e.substituicaoTributaria),t.valor=Object(n.l)(e.valor,4),t.efetivo=Object(n.q)(e.efetivo)):"70"===t.cst?(t.baseCalculo=Object(n.q)(e.baseCalculo),t.aliquota=Object(n.l)(e.aliquota,4),t.valor=Object(n.l)(e.valor,4),t.substituicaoTributaria=Object(n.q)(e.substituicaoTributaria)):"202"===t.cst&&(t.substituicaoTributaria=Object(n.q)(e.substituicaoTributaria)),Object(n.y)(t,{keepFalse:!1,keepNull:!1})}},zi=function(){var e,t,r,o,c,l,d=this,O=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},v=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},h=v.rule,j=v.item,m=v.fromXML,f=v.nfe,y=f.emitente;if(!y)throw"Erro em PIS, falta emitente item '".concat(j.descricao,"'");var I={};if(m){var S=O.PISAliq||O.COFINSAliq,C=O.PISQtde||O.COFINSQtde,x=O.PISNT||O.COFINSNT,A=O.PISOutr||O.COFINSOutr,N=O.PISST||O.COFINSST;if(S?(I.cst=S.CST,I.baseCalculo={valor:S.vBC},I.aliquota=S.pPIS||S.pCOFINS,I.valor=S.vPIS||S.vCOFINS):C?(I.cst=C.CST,I.quantidadeVendida=C.qBCProd,I.aliquotaReais=C.vAliqProd,I.valor=C.vPIS||C.vCOFINS):x?I.cst=x.CST:A&&(I.cst=A.CST,I.baseCalculo={valor:A.vBC},I.aliquota=A.pPIS||A.pCOFINS,I.quantidadeVendida=A.qBCProd,I.aliquotaReais=A.vAliqProd),N){var T={baseCalculo:N.vBC,aliquota:N.pPIS||N.pCOFINS,quantidadeVendida:N.qBCProd,aliquotaReais:N.vAliqProd,valor:N.vPIS||N.vCOFINS};I.substituicaoTributaria=T}}else{var F,w,P,E,D,J;if(I.cst=(null==h?void 0:h.cst)||O.cst,"99"===I.cst&&null!=y&&y.simplesNacional)I.baseCalculo={valor:0},I.aliquota=0,I.valor=0;else I.baseCalculo={valor:Object(n.l)(null===(F=O.baseCalculo)||void 0===F?void 0:F.valor,2)},I.aliquota=Object(n.l)(O.aliquota,4),I.valor=Object(n.l)(O.valor,2),I.quantidadeVendida=Object(n.l)(O.quantidadeVendida,4),I.aliquotaReais=Object(n.l)(O.aliquotaReais,4),I.substituicaoTributaria={baseCalculo:Object(n.l)(null===(w=O.substituicaoTributaria)||void 0===w?void 0:w.baseCalculo,2),aliquota:Object(n.l)(null===(P=O.substituicaoTributaria)||void 0===P?void 0:P.aliquota,4),quantidadeVendida:Object(n.l)(null===(E=O.substituicaoTributaria)||void 0===E?void 0:E.quantidadeVendida,4),aliquotaReais:Object(n.l)(null===(D=O.substituicaoTributaria)||void 0===D?void 0:D.aliquotaReais,4),valor:Object(n.l)(null===(J=O.substituicaoTributaria)||void 0===J?void 0:J.valor,2)}}var M=di.find((function(e){return e.value==I.cst}));this.cst=M?M.value:null,this.baseCalculo={valor:Object(n.l)(null===(e=I.baseCalculo)||void 0===e?void 0:e.valor,2)},this.aliquota=Object(n.l)(I.aliquota,4),this.valor=Object(n.l)(I.valor,2),this.quantidadeVendida=Object(n.l)(I.quantidadeVendida,4),this.aliquotaReais=Object(n.l)(I.aliquotaReais,4),this.substituicaoTributaria={baseCalculo:Object(n.l)(null===(t=I.substituicaoTributaria)||void 0===t?void 0:t.baseCalculo,2),aliquota:Object(n.l)(null===(r=I.substituicaoTributaria)||void 0===r?void 0:r.aliquota,4),quantidadeVendida:Object(n.l)(null===(o=I.substituicaoTributaria)||void 0===o?void 0:o.quantidadeVendida,4),aliquotaReais:Object(n.l)(null===(c=I.substituicaoTributaria)||void 0===c?void 0:c.aliquotaReais,4),valor:Object(n.l)(null===(l=I.substituicaoTributaria)||void 0===l?void 0:l.valor,2)},this.getObject=function(){var e={cst:Object(n.r)(d.cst),baseCalculo:Object(n.q)(d.baseCalculo),aliquota:Object(n.l)(d.aliquota,4),valor:Object(n.l)(d.valor,2),quantidadeVendida:Object(n.l)(d.quantidadeVendida,4),aliquotaReais:Object(n.l)(d.aliquotaReais,4),substituicaoTributaria:Object(n.q)(d.substituicaoTributaria)};return Object(n.y)(e,{keepFalse:!1,keepNull:!1})}},Gi=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Object(n.v)(t)||(t={}),!Object(n.v)(r))throw"Opções inválidas em total";if(!Object(n.v)(r.nfe))throw"NFe inválida em total";var o=r.fromXML,c=r.nfe,l=r.isNfce,d=o?t.ICMSTot:null,O=o?t.retTrib:null;this.baseCalculoIcms=Object(n.l)(o?d.vBC:t.baseCalculoIcms,2),this.valorIcms=Object(n.l)(o?d.vICMS:t.valorIcms,2),this.valorFcp=Object(n.l)(o?d.vFCP:t.valorFcp,2),this.valorFcpSt=Object(n.l)(o?d.vFCPST:t.valorFcpSt,2),this.baseCalculoIrrf=Object(n.l)(o&&O?O.vBCIRRF:t.baseCalculoIrrf,2),this.valorIrrfRetido=Object(n.l)(o&&O?O.vIRRF:t.valorIrrfRetido,2),this.valorFcpStRetido=Object(n.l)(o?d.vFCPSTRet:t.valorFcpStRetido,2),this.valorIcmsDesonerado=Object(n.l)(o?d.vICMSDeson:t.valorIcmsDesonerado,2),this.baseCalculoIcmsSt=Object(n.l)(o?d.vBCST:t.baseCalculoIcmsSt,2),this.valorIcmsSt=Object(n.l)(o?d.vST:t.valorIcmsSt,2),this.valorProdutosServicos=Object(n.l)(o?d.vProd:t.valorProdutosServicos,2),this.valorFrete=Object(n.l)(o?d.vFrete:t.valorFrete,2),this.valorSeguro=Object(n.l)(o?d.vSeg:t.valorSeguro,2),this.valorDesconto=Object(n.l)(o?d.vDesc:t.valorDesconto,2),this.valorIi=Object(n.l)(o?d.vII:t.valorIi,2),this.valorIpi=Object(n.l)(o?d.vIPI:t.valorIpi,2),this.valorIpiDevolvido=Object(n.l)(o?d.vIPIDevol:t.valorIpiDevolvido,2),this.valorPis=Object(n.l)(o?d.vPIS:t.valorPis,2),this.valorCofins=Object(n.l)(o?d.vCOFINS:t.valorCofins,2),this.valorOutros=Object(n.l)(o?d.vOutro:t.valorOutros,2),this.valorNfe=Object(n.l)(o?d.vNF:t.valorNfe,2),this.valorAproximadoTributos=Object(n.l)(o?d.vTotTrib:t.valorAproximadoTributos,2),this.valorPisRetido=Object(n.l)(o&&O?O.vRetPIS:t.valorPisRetido,2),this.valorCofinsRetido=Object(n.l)(o&&O?O.vRetCOFINS:t.valorCofinsRetido,2),this.valorCsllRetido=Object(n.l)(o&&O?O.vRetCSLL:t.valorCsllRetido,2),this.baseCalculoRetencao=Object(n.l)(o&&O?O.vBCRetPrev:t.baseCalculoRetencao,2),this.valorPrevidenciaRetido=Object(n.l)(o&&O?O.vRetPrev:t.valorPrevidenciaRetido,2),this.valorIcmsEstadoDestino=Object(n.l)(o?d.vICMSUFDest:t.valorIcmsEstadoDestino,2),l&&(this.valorIcmsEstadoRemetente=Object(n.l)(o?d.vICMSUFRemet:t.valorIcmsEstadoRemetente)),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({baseCalculoIcms:Object(n.l)(e.baseCalculoIcms,2),valorIcms:Object(n.l)(e.valorIcms,2),valorFcp:Object(n.l)(e.valorFcp,2),valorFcpSt:Object(n.l)(e.valorFcpSt,2),baseCalculoIrrf:Object(n.l)(e.baseCalculoIrrf,2),valorIrrfRetido:Object(n.l)(e.valorIrrfRetido,2),valorFcpStRetido:Object(n.l)(e.valorFcpStRetido,2),valorIcmsDesonerado:Object(n.l)(e.valorIcmsDesonerado,2),baseCalculoIcmsSt:Object(n.l)(e.baseCalculoIcmsSt,2),valorIcmsSt:Object(n.l)(e.valorIcmsSt,2),valorProdutosServicos:Object(n.l)(e.valorProdutosServicos,2),valorFrete:Object(n.l)(e.valorFrete,2),valorSeguro:Object(n.l)(e.valorSeguro,2),valorDesconto:Object(n.l)(e.valorDesconto,2),valorIi:Object(n.l)(e.valorIi,2),valorIpi:Object(n.l)(e.valorIpi,2),valorIpiDevolvido:Object(n.l)(e.valorIpiDevolvido,2),valorPis:Object(n.l)(e.valorPis,2),valorCofins:Object(n.l)(e.valorCofins,2),valorOutros:Object(n.l)(e.valorOutros,2),valorNfe:Object(n.l)(e.valorNfe,2),valorAproximadoTributos:Object(n.l)(e.valorAproximadoTributos,2),valorPisRetido:Object(n.l)(e.valorPisRetido,2),valorCofinsRetido:Object(n.l)(e.valorCofinsRetido,2),valorCsllRetido:Object(n.l)(e.valorCsllRetido,2),baseCalculoRetencao:Object(n.l)(e.baseCalculoRetencao,2),valorPrevidenciaRetido:Object(n.l)(e.valorPrevidenciaRetido,2),valorIcmsEstadoDestino:Object(n.l)(e.valorIcmsEstadoDestino,2),valorIcmsEstadoRemetente:Object(n.l)(e.valorIcmsEstadoRemetentem,2)})),{keepZeros:!1})},this.update=function(){var t,r=0,o=0,l=0,d=0,O=0,v=0,h=0,j=0,m=0,f=0,y=0,I=0;c.itens.forEach((function(i){var e,t;(r+=i.tributos.icms.baseCalculo&&i.tributos.icms.baseCalculo.valor?Object(n.l)(i.tributos.icms.baseCalculo.valor,2):0,o+=i.tributos.icms.valor?Object(n.l)(i.tributos.icms.valor,2):0,i.tributos.icms.substituicaoTributaria)&&(l+=Object(n.l)((null===(e=i.tributos.icms.substituicaoTributaria)||void 0===e||null===(t=e.baseCalculo)||void 0===t?void 0:t.valor)||0,2),d+=i.tributos.icms.substituicaoTributaria?Object(n.l)(i.tributos.icms.substituicaoTributaria.valor,2):0);O+=Object(n.l)(i.valor,2)||0,v+=Object(n.l)(i.valorFrete,2)||0,h+=Object(n.l)(i.valorSeguro,2)||0,j+=Object(n.l)(i.valorDesconto,2)||0,m+=Object(n.l)(i.tributos.pis.valor,2)||0,f+=Object(n.l)(i.tributos.cofins.valor,2)||0,y+=Object(n.l)(i.valorOutros,2)||0,I+=Object(n.l)(i.tributos.valorAproximadoTributos,2)||0})),t=Object(n.l)(O,2)-Object(n.l)(j,2)+Object(n.l)(d,2)+Object(n.l)(e.valorFcpSt,2)+Object(n.l)(v,2)+Object(n.l)(h,2)+Object(n.l)(y,2)+Object(n.l)(e.valorIi,2)+Object(n.l)(e.valorIpi,2)+Object(n.l)(e.valorIpiDevolvido,2),e.baseCalculoIcms=Object(n.l)(r,2),e.valorIcms=Object(n.l)(o,2),e.baseCalculoIcmsSt=Object(n.l)(l,2),e.valorIcmsSt=Object(n.l)(d,2),e.valorProdutosServicos=Object(n.l)(O,2),e.valorFrete=Object(n.l)(v,2),e.valorSeguro=Object(n.l)(h,2),e.valorDesconto=Object(n.l)(j,2),e.valorPis=Object(n.l)(m,2),e.valorCofins=Object(n.l)(f,2),e.valorOutros=Object(n.l)(y,2),e.valorNfe=Object(n.l)(t,2),e.valorAproximadoTributos=Object(n.l)(I,2)}},_i=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.payment;if(!Object(n.v)(t)&&!Object(n.v)(o))throw"Pagamento inválido";if(Object(n.v)(t)||(t={}),!Object(n.v)(r))throw"Opções inválidas em Pagamento";var c=r.fromXML;this.aVista=Object(n.e)(c?t.indPag:void 0!==t.aVista&&null!==t.aVista?t.aVista:Fi(r.payments,r.order));var l=pi.find((function(p){return p.value==(c?t.tPag:t.meio?t.meio:o&&o.gdata&&o.gdata.form?o.gdata.form:null)}));this.meio=l?l.value:null,"99"==this.meio&&(this.descricaoMeio=Object(n.r)(c?t.xPag:t.descricaoMeio)),this.valor=Object(n.l)(c?t.vPag:t.valor?t.valor:"90"===this.meio?null:o.value,2),this.getObject=function(){var t=pi.find((function(p){return p.value==e.meio}));return Object(n.y)(JSON.parse(JSON.stringify({aVista:Object(n.e)(e.aVista),meio:t?t.value:null,descricaoMeio:Object(n.r)(e.descricaoMeio),valor:Object(n.l)(e.valor,2)})),{keepNull:!1})}},Xi=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Object(n.v)(t))throw"Cobrança inválida";if(!Object(n.v)(r))throw"Opções inválidas em cobrança";var o=r.fromXML;this.numero=Object(n.r)(o?t.fat.nFat:t.numero),this.valorTotal=Object(n.l)(o?t.fat.vOrig:t.valorTotal,2),this.valorDesconto=Object(n.l)(o?t.fat.vDesc:t.valorDesconto,2),this.valorLiquido=Object(n.l)(o?t.fat.vLiq:t.valorLiquido,2),this.parcelas=[],o?Array.isArray(t.dup)?t.dup.forEach((function(t){return e.parcelas.push(new Wi(t))})):t.dup&&this.parcelas.push(new Wi(t.dup)):Array.isArray(t.parcelas)&&t.parcelas.forEach((function(t){return e.parcelas.push(new Wi(t))})),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({numero:Object(n.r)(e.numero),valorTotal:Object(n.l)(e.valorTotal,2),valorDesconto:Object(n.l)(e.valorDesconto,2),valorLiquido:Object(n.l)(e.valorLiquido,2),parcelas:e.parcelas.map((function(e){return e.getObject()}))})))}},Wi=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.numero=Object(n.r)(fromXML?t.nDup:t.numero),this.dataVencimento=Object(n.g)(fromXML?t.dVenc:t.dataVencimento,"date"),this.valor=Object(n.l)(fromXML?t.vDup:t.valor,2),this.getObject=function(){Object(n.y)(JSON.parse(JSON.stringify({numero:Object(n.r)(e.numero),dataVencimento:Object(n.g)(e.dataVencimento,"date"),valor:Object(n.l)(e.valor,2)})))}};Ui.origemOptions=ni;var Zi=$t($t({getNfeObj:function(e){return new Promise(function(){var t=Object(V.a)(regeneratorRuntime.mark((function t(r,n){var o,c;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:try{"4.00"!==(o=e).nfeProc["@_versao"]&&n("Versão do xml não suportada"),o.nfeProc&&o.nfeProc.NFe&&o.nfeProc.NFe.infNFe||n("Objeto inválido"),c=new wi(o.nfeProc.NFe.infNFe,{fromXML:!0}),r(c)}catch(e){n(e)}case 1:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}())},getEmitToCustomerSupplier:function(e,t){var r=e.nfeProc&&e.nfeProc.NFe&&e.nfeProc.NFe.infNFe?e.nfeProc.NFe.infNFe.emit:null;if(!r)throw"Não foi possível carregar o emitente";var n=r.enderEmit;return{name:r.xNome,fantasyName:r.xFant,cpfCnpj:r.CNPJ||r.CPF,stateId:r.IE,districtId:r.IM,phone:n.fone,options:{type:"supplier"===t?["Fornecedor"]:"customer"===t?["Cliente"]:["Cliente","Fornecedor"]},adresses:[{type:"general",zipcode:n.CEP,uf:n.UF,city:n.xMun,district:n.xBairro,address:n.xLgr,addressNumber:n.nro,complement:n.xCpl,ibge:n.cMun}]}},getDetToProducts:function(e){var t,r,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{customerSupplierId:"",toStock:""},c=function(e){var t=null;return Object.entries(e).every((function(e){return!!isNaN(parseInt(e[1].orig))||(t=e[1].orig,!1)})),t},l=null==e||null===(t=e.nfeProc)||void 0===t||null===(r=t.NFe)||void 0===r||null===(n=r.infNFe)||void 0===n?void 0:n.det;if(!l)throw"Não foi possível carregar os produtos";var d=function(e){var t=e.prod,r=parseFloat(t.vUnCom);return{gdata:{consumable:null},costPrice:r,total:t.vProd,amount:t.qCom,description:t.xProd,uCom:t.uCom,gtin:t.cEAN,gtinTrib:t.cEANTrib,tax:{origem:c(e.imposto.ICMS),ncm:t.NCM,cest:t.CEST},suppliers:[{id:o.customerSupplierId,invoiceId:t.cProd,invoiceDescription:t.xProd,purchasePrice:r}]}};return Array.isArray(l)?l.map(d):[d(l)]},insertPagamento:yi,NFe:wi,NFCe:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=function(e,t,r){var n,o=null==t||null===(n=t.gdata)||void 0===n?void 0:n.consumerCpfCnpj;if(0===r)e=o;else if(e!==o)throw"Vendas inválidas para emissão de NFC-e";return e};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var c=r,l=c.orders,d=c.fromXML,O=c.entity,v=null==l?void 0:l.reduce(o,"");this.setOperation=function(t){fi(e,t,r)};var h=function(){return"1"};this.getObject=function(){var t;return Object(n.y)(JSON.parse(JSON.stringify({idIntegracao:Object(n.r)(e.idIntegracao),versaoManual:Object(n.r)(e.versaoManual),codigo:Object(n.r)(e.codigo),serie:Object(n.l)(e.serie),finalidade:Object(n.r)(e.finalidade),natureza:Object(n.r)(e.natureza),dataEmissao:Object(n.g)(e.dataEmissao),presencial:Object(n.e)(e.presencial),tipoImpressao:Object(n.r)(e.tipoImpressao),tipoEmissao:Object(n.r)(e.tipoEmissao),codigoIdentificacaoDestino:Object(n.r)(e.codigoIdentificacaoDestino),codigoMunicipioFatoGerador:Object(n.r)(e.codigoMunicipioFatoGerador),consumidorFinal:Object(n.e)(e.consumidorFinal),emitente:e.emitente.getObject(),destinatario:null!==(t=e.destinatario)&&void 0!==t&&t.getObject?e.destinatario.getObject():null,itens:e.itens.map((function(e){return e.getObject()})),total:e.total.getObject(),pagamentos:e.pagamentos.map((function(e){return e.getObject()})),cobranca:e.cobranca.getObject(),informacoesComplementaresContribuinte:Object(n.r)(e.informacoesComplementaresContribuinte),informacoesComplementares:Object(n.r)(e.informacoesComplementares),enviaremail:Object(n.e)(e.enviaremail),responsavelAutorizado:Object(n.d)(e.responsavelAutorizado),intermediador:Object(n.m)(e.intermediador),valorTroco:Object(n.l)(e.valorTroco,2)})),{keepNull:!1})},this.idIntegracao=Object(n.r)(t.idIntegracao),this.versaoManual=Object(n.r)(d?t["@_versao"]:t.versaoManual),this.codigo=Object(n.r)(d?t.ide.cNF:t.codigo),this.serie=Object(n.l)(d?t.ide.serie:t.serie);var j=Ht.find((function(e){return e.value===Object(n.r)(d?t.ide.finNFe:t.finalidade)}));this.finalidade=j?j.value:null,this.natureza=Object(n.r)(t.natureza),this.dataEmissao=Object(n.g)(d?t.ide.dhEmi:t.dataEmissao||new Date),this.presencial=Object(n.e)(d?t.ide.indPres:t.presencial);var m=Yt.find((function(e){return e.value===Object(n.r)(d?t.tpImp:t.tipoImpressao)}));this.tipoImpressao=m?m.value:null;var f=ti.find((function(r){return r.value===Object(n.r)(d?t.ide.tpEmis:e.tipoEmissao)}));this.tipoEmissao=f?f.value:null;var y=ii.find((function(e){return e.value===Object(n.r)(d?t.ide.idDest:t.codigoIdentificacaoDestino||h())}));this.codigoIdentificacaoDestino=y?y.value:null,this.codigoMunicipioFatoGerador=Object(n.r)(d?t.ide.cMunFG:t.codigoMunicipioFatoGerador||O.ibge),this.consumidorFinal=Object(n.e)(d?t.ide.indFinal:t.consumidorFinal),this.emitente=new Ei(d?t.emit:t.emitente,r),this.destinatario=v?{cpfCnpj:v}:d||t.destinatario?new Di(d?t.dest:t.destinatario,r):null,this.itens=[],this.total=new Gi(t.total,$t($t({},r),{},{nfe:this,isNFCe:!0})),this.pagamentos=[],this.cobranca=new Xi(d?t.cobr:t.cobranca),this.informacoesComplementaresContribuinte=Object(n.r)(d&&t.infAdic&&t.infAdic.infAdFisco?t.infAdic.infAdFisco:t.informacoesComplementaresContribuinte),this.informacoesComplementares=Object(n.r)(d&&t.infAdic&&t.infAdic.infCpl?t.infAdic.infCpl:t.informacoesComplementares),this.enviaremail=Object(n.e)(t.enviaremail),this.responsavelAutorizado=[];var I=hi.find((function(e){return e.value===Object(n.m)(d?t.ide.indIntermed:t.intermediador)}));this.intermediador=Object(n.m)(I?I.value:null),this.valorTroco=Object(n.l)(d?t.infNfe.pag.vTroco:t.valorTroco);var S=$t($t({},r),{},{nfe:this});if(d)Array.isArray(t.det)?t.det.forEach((function(t){return Ii(e,t,S)})):t.det&&Ii(this,t.det,S),t.pag&&Array.isArray(t.pag.detPag)?t.pag.detPag.forEach((function(e){return yi(e,S)})):t.pag&&t.pag.detPag&&yi(t.pag.detPag,S),Array.isArray(t.autXML)?t.autXML.forEach((function(t){return gi(e,t)})):t.autXML&&gi(this,t.autXML);else{if(t.itens&&t.itens.forEach((function(t){return Ii(e,t,S)})),t.pagamentos)t.pagamentos.forEach((function(e){return yi(e,S)}));else if(l){var C=0;l.forEach((function(t){var n,o;if(l.length>1&&null!==(n=t.gdata.payments)&&void 0!==n&&n.length)throw"Documento já consta informação de pagamentos";null!==(o=t.gdata)&&void 0!==o&&o.payments&&t.gdata.payments.forEach((function(n){var o;null!==(o=n.gdata)&&void 0!==o&&o.change&&(C+=parseFloat(parseFloat(n.gdata.change).toFixed(2)),C=parseFloat(C.toFixed(2))),e.pagamentos.push(new _i(null,$t($t({},r),{},{payment:n,payments:t.gdata.payments})))})),e.valorTroco=C}))}t.responsavelAutorizado&&t.responsavelAutorizado.forEach((function(t){return gi(e,t)}))}Ci(this,r)},NFSe:function(e,t){var r=this;Object(n.v)(e)||(e={}),Object(n.v)(t)||(t={entity:{},newNfse:!1,orders:[],totalValue:!1,customerSupplier:{}});var o=t.orders,c=t.newNfse,l=t.customerSupplier,d=(t.entity,function(e){var t=r.prestador.endereco.codigoCidade,n=ji.find((function(e){return e.code==t}));return!n||!(n.maxServices=e||void 0)});if(this.insertServico=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Object(n.v)(e)&&!t.orderService)throw"Serviço inválido na inserção de serviço";if(!Object(n.v)(t))throw"Opções inválidas na inserção de serviço";if(!Object(n.v)(t.entity))throw"Entidade inválida na inserção de serviço";e=new ki(e,t),r.servico.push(e)},this.insertServicoGrouped=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Object(n.v)(t))throw"Configurações inválidas na inserção de serviço";if(!Object(n.v)(e)&&!Object(n.v)(t.orders))throw"O.S inválidas na inserção de servico";var o=new ki(null,$t($t({},t),{},{order:e}));r.servico.push(o)},this.reloadPrestador=function(e){r.prestador=new Ei(null,{entity:e,newNfse:!0})},this.reloadTomador=function(e){r.destinatario=new Di(null,{customerSupplier:e,newNfse:!0})},this.reloadServico=function(e){if(r.servico.splice(0,r.servico.length),d(e.length))e.forEach((function(e){return r.insertServicoGrouped(e,$t($t({},t),{},{NFSe:r}))}));else{var n="Serviços realizados na(s) O.S nrº ",o=0,c=0;e.forEach((function(t,r){o+=t.totalWithoutDiscount,c+=t.total,o=parseFloat(o.toFixed(2)),c=parseFloat(c.toFixed(2)),n+=0==r?"".concat(t.personalId):", ".concat(t.personalId),r===e.length-1&&(n+=".")}));var l={description:n,totalWithoutDiscount:o,total:c};r.insertServicoGrouped(l,$t($t({},t),{},{NFSe:r}))}},this.idIntegracao=Object(n.r)(e.idIntegracao),this.prestador=new Ei(e.prestador,$t($t({},t),{},{newNfse:c})),this.tomador=new Di(e.tomador,$t($t({},t),{},{newNfse:c,customerSupplier:l})),this.servico=[],c&&o.length){var O=function(e){var t=!1;return e.forEach((function(e){e.hasProducts&&(t=!0)})),t}(o);if(!d(o.length))throw"Limite de itens da prefeitura excedido";o.forEach((function(e){o.length>1||1===o.length&&O&&t.totalValue?r.insertServicoGrouped(e,$t($t({},t),{},{NFSe:r})):e.groups.forEach((function(e){Array.isArray(e.services)&&e.services.length&&e.services.forEach((function(e){r.insertServico(null,$t($t({},t),{},{orderService:e,NFSe:r}))}))}))}))}this.enviarEmail=Object(n.e)(e.enviarEmail)||!0,this.informacoesComplementares=Object(n.r)(e.informacoesComplementares),this.rps=new Pi(e.rps),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({idIntegracao:Object(n.r)(r.idIntegracao),prestador:r.prestador.getObject(),tomador:r.tomador.getObject(),servico:r.servico.map((function(e){return e.getObject()})),enviarEmail:Object(n.e)(r.enviarEmail),informacoesComplementares:Object(n.r)(r.informacoesComplementares),rps:r.rps.getObject()})),{keepNull:!1})},this.getTotal=function(){var e=0;return r.servico.forEach((function(s){e+=s.valor.liquido,e=parseFloat(e.toFixed(2))})),e},Array.isArray(e.servico)&&e.servico.forEach((function(e){return r.insertServico(e,t)}))},Icms:Ui},y),{},{districtRule:ji}),Qi=Zi.NFe,$i=function(e){return e&&e.nfeProc&&e.nfeProc.NFe&&e.nfeProc.NFe.infNFe&&e.nfeProc.NFe.infNFe["@_Id"]?String(e.nfeProc.NFe.infNFe["@_Id"]).replace("NFe",""):null},Hi=function(e){return e&&e.nfeProc&&e.nfeProc.NFe&&e.nfeProc.NFe.infNFe&&e.nfeProc.NFe.infNFe.ide&&e.nfeProc.NFe.infNFe.ide.nNF?String(e.nfeProc.NFe.infNFe.ide.nNF):null},Ki=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.w)(t)&&(t=JSON.parse(t)),Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),Object(n.w)(t.invoice)&&(t.invoice=JSON.parse(t.invoice)),Object(n.w)(t.gdata)&&(t.gdata=JSON.parse(t.gdata)),Object(n.w)(t.xmlFile)&&(t.xmlFile=JSON.parse(t.xmlFile)),w.checkEntities(t,r);var o=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=r.orders||[];this.orderIds=[],this.orderPersonalIds=[],this.protocols=[],this.productsImported=[],this.insertOrderId=function(t){e.orderIds.find((function(e){return e==t}))||e.orderIds.push(t)},this.insertOrderPersonalId=function(t){e.orderPersonalIds.find((function(e){return e==t}))||e.orderPersonalIds.push(t)},this.insertOrderData=function(t){if(t.id&&e.insertOrderId(t.id),t.personalId&&e.insertOrderPersonalId(t.personalId),!t.id&&!t.personalId)throw"Sem informações"};var c=function(t){if(e.productsImported.find((function(e){return e.invoiceId==t.invoiceId})))throw"Falha ao inserir ids, produto já consta na lista";e.productsImported.push(t)};Array.isArray(t.protocols)&&t.protocols.forEach((function(t){return e.protocols.push(t)})),o.length&&o.forEach((function(t){e.insertOrderId(t.id)})),Array.isArray(t.orderIds)&&t.orderIds.forEach((function(t){return e.insertOrderId(t)})),Array.isArray(t.productsImported)&&t.productsImported.forEach((function(e){return c(e)})),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({orderIds:Object(n.d)(e.orderIds),orderPersonalIds:Object(n.d)(e.orderPersonalIds),protocols:Object(n.d)(e.protocols),productsImported:Object(n.d)(e.productsImported)})),{keepNull:!1,keepFalse:!1})}},c=r.json;this.id=Object(n.m)(t.id),this.entity=new w(r.entity).getObject("permissions"),this.entityId=parseInt(t.entityId)?t.entityId:this.entity.id||null,this.createdAt=Object(n.g)(t.createdAt),this.updatedAt=Object(n.g)(t.updatedAt),this.historic=Object(n.d)(t.historic),this.invoice=new Qi(t.invoice,r),this.apiId=Object(n.r)(t.apiId),this.statusApi=Object(n.q)(t.statusApi),this.xmlJson=Object(n.q)(t.xmlJson),this.number=Object(n.r)(t.number||Hi(c)),this.key=Object(n.r)(t.key||$i(c)),this.gdata=new o(t.gdata,r),this.xmlFile=new G(t.xmlFile,r),this.getTitle=function(){return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),historic:Object(n.d)(e.historic),invoice:e.invoice.getObject(),apiId:Object(n.r)(e.apiId),statusApi:Object(n.q)(e.statusApi),number:Object(n.r)(e.number),key:Object(n.r)(e.key),gdata:e.gdata.getObject(),xmlFile:e.xmlFile.getObject()})))}};Ki.getKey=$i,Ki.getNumber=Hi;var Yi=Ki,er=Zi.NFCe,ir=function(e){return e&&e.nfeProc&&e.nfeProc.NFe&&e.nfeProc.NFe.infNFe&&e.nfeProc.NFe.infNFe["@_Id"]?String(e.nfeProc.NFe.infNFe["@_Id"]).replace("NFe",""):null},rr=function(e){return e&&e.nfeProc&&e.nfeProc.NFe&&e.nfeProc.NFe.infNFe&&e.nfeProc.NFe.infNFe.ide&&e.nfeProc.NFe.infNFe.ide.nNF?String(e.nfeProc.NFe.infNFe.ide.nNF):null},ar=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.w)(t)&&(t=JSON.parse(t)),Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),Object(n.w)(t.invoice)&&(t.invoice=JSON.parse(t.invoice)),Object(n.w)(t.gdata)&&(t.gdata=JSON.parse(t.gdata)),Object(n.w)(t.xmlFile)&&(t.xmlFile=JSON.parse(t.xmlFile)),w.checkEntities(t,r);var o=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=r.orders||[];this.orderIds=[],this.orderPersonalIds=[],this.protocols=[],this.insertOrderId=function(t){e.orderIds.find((function(e){return e==t}))||e.orderIds.push(t)},this.insertOrderPersonalId=function(t){e.orderPersonalIds.find((function(e){return e==t}))||e.orderPersonalIds.push(t)},this.insertOrderData=function(t){if(t.id&&e.insertOrderId(t.id),t.personalId&&e.insertOrderPersonalId(t.personalId),!t.id&&!t.personalId)throw"Sem informações"},Array.isArray(t.protocols)&&t.protocols.forEach((function(t){return e.protocols.push(t)})),o.length&&o.forEach((function(t){e.insertOrderId(t.id)})),Array.isArray(t.orderIds)&&t.orderIds.forEach((function(t){return e.insertOrderId(t)})),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({orderIds:Object(n.d)(e.orderIds),protocols:Object(n.d)(e.protocols)})),{keepNull:!1,keepFalse:!1})}},c=r.json;this.id=Object(n.m)(t.id),this.entity=new w(r.entity).getObject("permissions"),this.entityId=parseInt(t.entityId)?t.entityId:this.entity.id||null,this.createdAt=Object(n.g)(t.createdAt),this.updatedAt=Object(n.g)(t.updatedAt),this.historic=Object(n.d)(t.historic),this.invoice=new er(t.invoice,r),this.apiId=Object(n.r)(t.apiId),this.statusApi=Object(n.q)(t.statusApi),this.xmlJson=Object(n.q)(t.xmlJson),this.number=Object(n.r)(t.number||rr(c)),this.key=Object(n.r)(t.key||ir(c)),this.gdata=new o(t.gdata,r),this.xmlFile=new G(t.xmlFile,r),this.getTitle=function(){return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),historic:Object(n.d)(e.historic),invoice:e.invoice.getObject(),apiId:Object(n.r)(e.apiId),statusApi:Object(n.q)(e.statusApi),number:Object(n.r)(e.number),key:Object(n.r)(e.key),gdata:e.gdata.getObject(),xmlFile:e.xmlFile.getObject()})))}};ar.getKey=ir,ar.getNumber=rr;var nr=ar,or=Zi.NFSe,cr=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r);var o=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={});var o=r.orders||[];this.orderIds=[],this.orderPersonalIds=[],this.protocols=[],this.insertOrderId=function(t){e.orderIds.find((function(e){return e==t}))||e.orderIds.push(t)},this.insertOrderPersonalId=function(t){e.orderPersonalIds.find((function(e){return e==t}))||e.orderPersonalIds.push(t)},this.insertOrderData=function(t){if(t.id&&e.insertOrderId(t.id),t.personalId&&e.insertOrderPersonalId(t.personalId),!t.id&&!t.personalId)throw"Sem informações"},Array.isArray(t.protocols)&&t.protocols.forEach((function(t){return e.protocols.push(t)})),o.length&&o.forEach((function(t){e.insertOrderId(t.id)})),Array.isArray(t.orderIds)&&t.orderIds.forEach((function(t){return e.insertOrderId(t)})),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({orderIds:Object(n.d)(e.orderIds),protocols:Object(n.d)(e.protocols)})),{keepNull:!1,keepFalse:!1})}};this.id=Object(n.m)(t.id),this.entity=new w(r.entity).getObject("permissions"),this.entityId=parseInt(t.entityId)?t.entityId:this.entity.id||null,this.createdAt=Object(n.g)(t.createdAt),this.updatedAt=Object(n.g)(t.updatedAt),this.historic=Object(n.d)(t.historic),this.invoice=new or(t.invoice,r),this.apiId=Object(n.r)(t.apiId),this.statusApi=Object(n.q)(t.statusApi),this.xmlJson=Object(n.q)(t.xmlJson),this.number=Object(n.r)(t.number),this.key=Object(n.r)(t.key),this.gdata=new o(t.gdata,r),this.getTitle=function(){return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),historic:Object(n.d)(e.historic),invoice:e.invoice.getObject(),apiId:Object(n.r)(e.apiId),statusApi:Object(n.q)(e.statusApi),number:Object(n.r)(e.number),key:Object(n.r)(e.key),gdata:e.gdata.getObject()})))}};function sr(object,e){var t=Object.keys(object);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(object);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(object,e).enumerable}))),t.push.apply(t,r)}return t}function lr(e){for(var i=1;i0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),Object(n.w)(t.file)&&(t.file=JSON.parse(t.file)),Object(n.w)(t.customerSupplier)&&(t.customerSupplier=JSON.parse(t.customerSupplier)),Object(n.w)(t.invoice)&&(t.invoice=JSON.parse(t.invoice)),Object(n.w)(t.products)&&(t.products=JSON.parse(t.products));var o=r.json,c=o&&o.nfeProc&&o.nfeProc.NFe?o.nfeProc.NFe.infNFe:null;this.customerSupplier=Object(n.q)(t.customerSupplier),this.hasCustomerSupplierId=Object(n.e)(t.hasCustomerSupplierId),this.pInvoice=new Yi(t.pInvoice,r),this.products=[],this.getTitle=function(){var e=c?c.ide.nNF:null,t=c?c.emit.xFant||c.emit.xNome:null,r=c?c.emit.CNPJ||c.emit.CPF:null,title="";return e||t?(e&&(title+="".concat(e," - ")),t&&(title+="".concat(t," - ")),r&&(title+="".concat(Object(n.c)(r)))," - "===title.substring(title.length-3)&&(title=title.substring(0,title.length-3)),title):title},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({customerSupplier:Object(n.q)(e.customerSupplier),pInvoice:e.pInvoice.getObject(),products:Object(n.d)(e.products)})))},Array.isArray(t.products)&&t.products.forEach((function(t){return e.products.push(lr({id:null,personalId:null},t))}))},dr=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=function(){var e,t,r=this,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(o)||(o={}),Object(n.v)(c)||(c={}),this.initialValue=Object(n.l)(o.initialValue,2),this.fortifications=[],this.bleeds=[],this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({initialValue:Object(n.l)(r.initialValue,2),fortifications:Object(n.d)(r.fortifications),bleeds:Object(n.d)(r.bleeds)})))},null!==(e=o.fortifications)&&void 0!==e&&e.length&&o.fortifications.forEach((function(e){r.fortifications.push(e)})),null!==(t=o.bleeds)&&void 0!==t&&t.length&&o.bleeds.forEach((function(e){r.bleeds.push(e)}))};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),this.id=Object(n.m)(t.id),this.entity=new w(r.entity).getObject("permissions");var c=this.entity;this.entityId=parseInt(t.entityId)?t.entityId:this.entity.id||null,this.personalId=Object(n.m)(t.personalId),this.createdAt=Object(n.g)(t.createdAt),this.updatedAt=Object(n.g)(t.updatedAt),this.userId=Object(n.m)(t.userId),this.closeDate=Object(n.g)(t.closeDate),this.gdata=new o(t.gdata,r),this.orders=[],this.opened=this.createdAt,this.sales=null,this.payments=[],this.total=0,this.fortify=function(e){var t={date:new Date,value:e};this.gdata.fortifications.push(t)},this.bleed=function(e){if(e>this.total)throw"Saldo insuficiente";var t={date:new Date,value:e};this.gdata.bleeds.push(t)},this.getValues=function(){var t,r,n=0,o=0,c=e.gdata.initialValue;return null!==(t=e.gdata.fortifications)&&void 0!==t&&t.length&&e.gdata.fortifications.forEach((function(e){n+=e.value,n=parseFloat(n.toFixed(2))})),null!==(r=e.gdata.bleeds)&&void 0!==r&&r.length&&e.gdata.bleeds.forEach((function(e){o+=e.value,o=parseFloat(o.toFixed(2))})),{initialValue:c,fortifications:n,bleeds:o}},this.checkSales=function(){var e=this.getValues(),t=e.initialValue,r=e.fortifications,n=e.bleeds,o=0,c=[],l=[];this.orders.forEach((function(e){"Aberto(a)"!==e.status&&e.payments.forEach((function(e){var t,r=parseFloat((e.value-((null===(t=e.gdata)||void 0===t?void 0:t.change)||0)).toFixed(2));o+=r,o=parseFloat(o.toFixed(2));var n=c.findIndex((function(form){return form.form==e.gdata.form})),d=l.findIndex((function(t){return t.id==e.gdata.paymentMethodId}));n>=0?c[n].total+=r:c.push({form:e.gdata.form,total:r}),d>=0?l[d].total+=r:l.push({id:e.gdata.paymentMethodId,total:r,form:e.gdata.form})}))})),this.total=t+r-n+o,this.total=parseFloat(this.total.toFixed(2));var d={initialValue:t,fortifications:r,bleeds:n,total:o,forms:c,paymentMethods:l,cashierTotal:this.total};return this.sales=d,d},this.setInitialValue=function(e){if(this.gdata.initialValue)throw"Valor já foi informado";if(this.opened)throw"Caixa já se encontra aberto, faça um reforço";this.gdata.initialValue=null!=e?e:0},this.insertOrder=function(t){var r=null!=t&&t.id?new Pt(t,{entity:c}):t,n=null!=r&&r.id?r.id:r;if(e.orders.findIndex((function(e){return null!=e&&e.id?e.id==n:e==n}))>=0)throw"O.S já consta na lista";e.orders.push(r)},this.getTitle=function(){return e.createdAt&&!e.closeDate?"Caixa Aberto":"Caixa Fechado"},this.getObject=function(t){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),entityId:Object(n.m)(e.entityId),personalId:Object(n.m)(e.personalId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),userId:Object(n.m)(e.userId),closeDate:Object(n.g)(e.closeDate),gdata:e.gdata.getObject(),orders:e.orders.map((function(e){return null!=e&&e.id?e.id:e}))})))},Array.isArray(t.orders)&&t.orders.forEach((function(t){return e.insertOrder(t)}))};dr.prototype.constructor=dr;var pr=dr,Or=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=function(e){var t=this;Object(n.v)(e)||(e={}),this.video=Object(n.r)(e.video),this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({video:Object(n.r)(t.video)})))}};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),w.checkEntities(t,r),P.call(this,t,r),Object(n.w)(t.images)&&(t.images=JSON.parse(t.images)),Object(n.w)(t.coordinate)&&(t.coordinate=JSON.parse(t.coordinate)),Object(n.w)(t.details)&&(t.details=JSON.parse(t.details)),Object(n.w)(t.gdata)&&(t.gdata=JSON.parse(t.gdata)),this.businessType=Object(n.r)(t.businessType),this.propertyType=Object(n.r)(t.propertyType),this.area=Object(n.l)(t.area),this.propertyArea=Object(n.l)(t.propertyArea),this.value=Object(n.l)(t.value),this.address=Object(n.r)(t.address),this.addressNumber=Object(n.m)(t.addressNumber),this.zipcode=Object(n.r)(Object(n.w)(t.zipcode)?t.zipcode.replace(n.A,""):t.zipcode),this.district=Object(n.r)(t.district),this.city=Object(n.r)(t.city),this.uf=Object(n.r)(t.uf),this.content=Object(n.r)(t.content),this.cover=Object(n.r)(t.cover),this.coordinate=Object(n.q)(t.coordinate),this.details=Object(n.q)(t.details),this.images=[],this.gdata=new o(t.gdata),this.views=t.views,null===this.active&&(this.active=!0),this.insertImage=function(t){if(e.images.find((function(img){return img.hashed==t.hashed})))throw"Imagem '".concat(t.name,"' já consta na lista");e.images.push(t)},this.insertNewImage=function(t){return new Promise(function(){var r=Object(V.a)(regeneratorRuntime.mark((function r(o,c){var l,d;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:l=e.insertImage;try{(d=new FileReader).readAsBinaryString(t),d.onload=function(){try{t.md5=Object(n.z)(d.result);var e=new G(null,{inputFile:t});l(e),o(e)}catch(e){c(e)}},d.onerror=function(){throw d.error}}catch(e){c(e)}case 2:case"end":return r.stop()}}),r)})));return function(e,t){return r.apply(this,arguments)}}())},this.removeImage=function(t){e.images.splice(t,1)},this.setCover=function(t){var image=new G(e.images[t].getObject());e.images.splice(t,1),e.images.unshift(image),e.cover=image.hashed},this.changeImageOrder=function(t,r){var n=e.images[t+r],o=e.images[t];if(-1===r){var c,l=[o,n];(c=e.images).splice.apply(c,[t+r,2].concat(l))}else if(1===r){var d,O=[n,o];(d=e.images).splice.apply(d,[t,2].concat(O))}},this.getTitle=function(){var t=e.personalId?String(e.personalId):"",r=e.businessTypeId?String(e.businessTypeId):"";if(t||r){var title="";return t&&(title+=t),r&&(title+=r),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({id:Object(n.m)(e.id),personalId:Object(n.m)(e.personalId),entityId:Object(n.m)(e.entityId),createdAt:Object(n.g)(e.createdAt),updatedAt:Object(n.g)(e.updatedAt),active:Object(n.e)(e.active),deleted:Object(n.e)(e.deleted),historic:Object(n.d)(e.historic),businessType:Object(n.r)(e.businessType),propertyType:Object(n.r)(e.propertyType),area:Object(n.l)(e.area),propertyArea:Object(n.l)(e.propertyArea),value:Object(n.l)(e.value),address:Object(n.r)(e.address),addressNumber:Object(n.m)(e.addressNumber),zipcode:Object(n.r)(Object(n.w)(e.zipcode)?e.zipcode.replace(n.A,""):e.zipcode),district:Object(n.r)(e.district),city:Object(n.r)(e.city),uf:Object(n.r)(e.uf),content:Object(n.r)(e.content),cover:Object(n.r)(e.cover),coordinate:e.coordinate,details:e.details,images:e.images.map((function(e){return e.getObject()})),gdata:e.gdata.getObject()})),{keepZeros:!1,keepEmpty:!0})},Array.isArray(t.images)&&t.images.forEach((function(img){return e.insertImage(new G(img))}))};Or.publicTitle=function(e){var t="";return e.propertyType&&(t+=e.propertyType),"Vender"===e.businessType?t+=" para Venda":"Alugar"===e.businessType&&(t+=" para Alugar"),e.district&&(t+=" ".concat(e.district)),e.city&&(t+="/".concat(e.city)),e.uf&&(t+=" - ".concat(e.uf)),t},Or.publicAddress=function(e){return"".concat(e.address," ").concat(null!==e.addressNumber&&"0"!==e.addressNumber?"nº"+e.addressNumber:"")},Or.businessTypeOptions=[{value:"Vender",text:"Vender"},{value:"Alugar",text:"Alugar"}],Or.propertyDetailOptions=[{value:"Área de Lazer",text:"Área de Lazer",type:"check"},{value:"Banheiros",text:"Banheiros",type:"integer"},{value:"Garagem",text:"Garagem",type:"integer"},{value:"Quartos",text:"Quartos",type:"integer"},{value:"Quiosques",text:"Quiosques",type:"integer"},{value:"Suítes",text:"Suítes",type:"integer"}],Or.propertyTypeOptions=[{value:"Apartamento",text:"Apartamento"},{value:"Casa",text:"Casa"},{value:"Chácara",text:"Chácara"},{value:"Cobertura",text:"Cobertura"},{value:"Duplex/Triplex",text:"Duplex/Triplex"},{value:"Fazenda",text:"Fazenda"},{value:"Galpão/Depósito",text:"Galpão/Depósito"},{value:"Kitnet",text:"Kitnet"},{value:"Loja Comercial",text:"Loja Comercial"},{value:"Lote",text:"Lote"},{value:"Outros",text:"Outros"},{value:"Prédio",text:"Prédio"},{value:"Pousada",text:"Pousada"},{value:"Sala Comercial",text:"Sala Comercial"},{value:"Sítio",text:"Sítio"},{value:"Sobrado",text:"Sobrado"},{value:"Terreno",text:"Terreno"}],(Or.prototype=Object.create(P.prototype)).constructor=Or;var vr=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(n.v)(t)||(t={}),Object(n.v)(r)||(r={}),"string"==typeof t.target&&(t.target=JSON.parse(t.target)),w.checkEntities(t,r),this.entity=new w(r.entity).getObject("permissions"),this.entityId=parseInt(t.entityId)?t.entityId:this.entity.id||null,this.title=Object(n.r)(t.title),this.text=Object(n.r)(t.text),this.target=Object(n.q)(t.target),this.image=new G(t.image,r),this.getTitle=function(){var t=e.name?String(e.name):"";if(t){var title="";return t&&(title+=t),title}return""},this.getObject=function(){return Object(n.y)(JSON.parse(JSON.stringify({entityId:Object(n.m)(e.entityId),title:Object(n.r)(e.title),text:Object(n.r)(e.text),target:Object(n.q)(e.target),image:e.image.getObject()})))}},jr={},mr={AssetType:R,Asset:X,Site:Z,SiteArea:$,FinancialAccount:K,FinancialPosting:ie,Payment:te,PaymentMethod:ae,CommercialCondition:ce,Category:le,Checkin:pe,Manufacturer:he,ManufacturerProduct:Oe,UnitType:me,CustomerSupplier:Ne,Entity:w,BusinessUnit:Fe,General:E,User:Je,Historic:Le,Product:Ze,Service:ct,Order:Pt,Ticket:Dt,TicketCategory:Mt,FollowUp:st,Vehicle:Rt,Stock:Vt,StockPosting:Bt,ProductInvoice:Yi,ConsumerInvoice:nr,ServiceInvoice:cr,InvoiceImport:ur,TaxOperation:Zt,Plan:h,Cashier:pr,Property:Or,MainLocation:vr,File:G,Uf:Lt,Nf:Zi};jr.models=mr,jr.permission=o,jr.pass=o.havePermission,jr.static=n.a,jr.toCC=n.a.keysToCamel,jr.toUS=n.a.keysToUnderscore;t.default=jr}},[[263,25,5,26]]]);