@crystaldesign/diva-web-planner-react 26.14.0-beta.45 → 26.14.0-beta.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 3596.diva-web-planner-react.umd.min.js.LICENSE.txt */
|
|
2
|
-
"use strict";(self.webpackChunkCrystaldesignDivaWebPlannerReact=self.webpackChunkCrystaldesignDivaWebPlannerReact||[]).push([[3596],{33596:(t,r,i)=>{i.r(r),i.d(r,{default:()=>k});var l=i(84658),a=i(61965),c=i(13125),o=i(43860),d=i(80248),u=i(50747),h=i.n(u),g=i(2221),v=i(69209),b=i(77189),p=i(69821);function _createForOfIteratorHelper(t,r){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){i&&(t=i);var l=0,a=function F(){};return{s:a,n:function n(){return l>=t.length?{done:!0}:{done:!1,value:t[l++]}},e:function e(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,o=!0,d=!1;return{s:function s(){i=i.call(t)},n:function n(){var t=i.next();return o=t.done,t},e:function e(t){d=!0,c=t},f:function f(){try{o||null==i.return||i.return()}finally{if(d)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var i=0,l=Array(r);i<r;i++)l[i]=t[i];return l}function ownKeys(t,r){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);r&&(l=l.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),i.push.apply(i,l)}return i}function _objectSpread(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(i),!0).forEach((function(r){(0,d.Z)(t,r,i[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(i,r))}))}return t}var y=g.ZP.initLog("Planner","WEB-PLANNER-LOGIC");function isPlaced(t){return!1!==t&&void 0!==t.index&&!!t.accessoire&&"doesNotFit"!==t.type&&!t.type.startsWith("notAllowed")}var k=function(){function ShelfPlanner(t,r){if((0,c.Z)(this,ShelfPlanner),(0,d.Z)(this,"article",void 0),(0,d.Z)(this,"grids",[]),(0,d.Z)(this,"isVisible",void 0),(0,d.Z)(this,"showOnRule",void 0),(0,d.Z)(this,"showAfterOPT",void 0),(0,d.Z)(this,"data",void 0),(0,d.Z)(this,"freeArticlesPossible",{}),(0,d.Z)(this,"freeArticlesPlanned",{}),(0,d.Z)(this,"gridAllowedOnCells",void 0),(0,d.Z)(this,"gridAllowedOntoArticles",void 0),(0,d.Z)(this,"takePlaceOnOtherGrids",void 0),(0,d.Z)(this,"disableCellsByElement",void 0),(0,d.Z)(this,"montageOptions",[]),(0,d.Z)(this,"restorePending",void 0),(0,d.Z)(this,"shelfDebugStack",[]),(0,d.Z)(this,"shelfDebugSeq",0),(0,d.Z)(this,"stashedAccessoires",{}),(0,d.Z)(this,"editEpoch",0),(0,d.Z)(this,"stashEpochs",{}),this.article=r,this.restorePending=!!r.shelfPlanData,this.disableCellsByElement=t.DisableCells,this.data=t,this.showAfterOPT=t.ShowAfterOPT,this.showOnRule=t.ShowOnRule?g.ZP.getRuleByFormula(t.ShowOnRule,r.catalogCodex,r.CatalogData.multiselectOptions):void 0,this.gridAllowedOnCells=t.GridAllowedOnCells,this.gridAllowedOntoArticles=t.GridAllowedOntoArticles,this.takePlaceOnOtherGrids=t.TakePlaceOnOtherGrids,this.initFreeArticles(),t.ShelfPlanner&&t.ShelfPlanner.length>0){for(var i=0;i<t.ShelfPlanner.length;i++)this.creatNewGrid(i),this.updateDisabledCells();this.montageOptions=(0,a.Z)(new Set(this.grids.reduce((function(t,r){return t=t.concat(r.montageOptionsList)}),[])))}}return(0,o.Z)(ShelfPlanner,[{key:"logShelfDebug",value:function logShelfDebug(t){this.shelfDebugStack.push(_objectSpread({seq:this.shelfDebugSeq++},t)),this.shelfDebugStack.length>500&&this.shelfDebugStack.splice(0,this.shelfDebugStack.length-500)}},{key:"initFreeArticles",value:function initFreeArticles(){if(this.data.ShelfPlanner)for(var t=0;t<this.data.ShelfPlanner.length;t++){var r=this.data.ShelfPlanner[t];if(r.initAccArr)for(var i=0;i<r.initAccArr.length;i++){var l=r.initAccArr[i];l.noPrice&&(void 0===this.freeArticlesPossible[l.Codex]&&(this.freeArticlesPossible[l.Codex]=0),this.freeArticlesPossible[l.Codex]+=l.Quantity)}}}},{key:"canBeFree",value:function canBeFree(t){return void 0!==this.freeArticlesPossible[t]}},{key:"IsVisible",get:function get(){return this.isVisible}},{key:"RestorePending",get:function get(){return this.restorePending},set:function set(t){this.restorePending=t}},{key:"setIsVisible",value:(S=(0,l.Z)(h().mark((function _callee(t){return h().wrap((function _callee$(r){for(;;)switch(r.prev=r.next){case 0:if(this.isVisible==t){r.next=13;break}if(this.logShelfDebug({phase:"visibility",action:t?"plannerShown":"plannerHidden",detail:t?void 0:"showOnRule/visibility turned false — all placed accessories are deleted"}),!t){r.next=11;break}if(this.isVisible=t,this.article.shelfPlanData){r.next=9;break}return r.next=7,this.onConfigChanged({});case 7:return r.next=9,this.initAccList();case 9:r.next=13;break;case 11:return r.next=13,this.deleteAllAcc();case 13:this.isVisible=t;case 14:case"end":return r.stop()}}),_callee,this)}))),function setIsVisible(t){return S.apply(this,arguments)})},{key:"onConfigChanged",value:(P=(0,l.Z)(h().mark((function _callee2(t){var r,i,l,a,c,o,d,u,g,v,b,p,y,k,A,x,C;return h().wrap((function _callee2$(h){for(;;)switch(h.prev=h.next){case 0:for(r=!1,i=[],l=this.grids.map((function(t){return t.CurrentLoadedRuleIndex})),a=0;a<this.grids.length;a++)i.push(this.grids[a].onConfigChanged());c=0;case 5:if(!(c<i.length)){h.next=14;break}if(i[c].length){h.next=8;break}return h.abrupt("continue",11);case 8:o=this.grids[c],i[c].includes("disableGridRule")&&this.logShelfDebug({phase:"configChanged",action:o.DisabledByRule?"gridDisabledByRule":"gridEnabledByRule",gridIndex:o.ShelfIndex,detail:o.ShowOnRule}),i[c].includes("heightGridRule")&&this.logShelfDebug({phase:"configChanged",action:"gridRecreated",gridIndex:o.ShelfIndex,detail:"HeightGridCellCountOnRule match changed — grid rebuilt (cell count / placeable accessories can change), its accessories are deleted"});case 11:c++,h.next=5;break;case 14:d=new Map,u=0;case 16:if(!(u<i.length)){h.next=26;break}if(i[u].length){h.next=19;break}return h.abrupt("continue",23);case 19:return g=this.stashAccessoiresOfGrid(u,l[u]),this.isOnlyInitContent(this.grids[u],g)||d.set(u,g),h.next=23,this.grids[u].deleteAllAccOfGrid();case 23:u++,h.next=16;break;case 26:v=0;case 27:if(!(v<i.length)){h.next=65;break}if(i[v].length){h.next=30;break}return h.abrupt("continue",62);case 30:if(i[v].includes("heightGridRule")&&(this.creatNewGrid(v),r=!0),b=this.grids[v],!i[v].includes("heightGridRule")&&!i[v].includes("disableGridRule")||b.DisabledByRule){h.next=62;break}if(!this.restorePending){h.next=35;break}return h.abrupt("continue",62);case 35:if(p=this.takeStashOfGrid(v),y=this.article.set.CatalogData.divaUseRtvNext,h.t0=p&&(!p.outdated||!y),!h.t0){h.next=42;break}return h.next=41,this.placeStashedAccessoiresInGrid(v,p.accessoires);case 41:h.t0=h.sent;case 42:if(!h.t0){h.next=45;break}return d.delete(v),h.abrupt("continue",62);case 45:if(h.t1=y,!h.t1){h.next=50;break}return h.next=49,this.placeTransferredAccessoires(v,d);case 49:h.t1=h.sent;case 50:if(!h.t1){h.next=54;break}return h.next=53,this.initAccList(v);case 53:return h.abrupt("continue",62);case 54:if(!y||null==p||!p.outdated){h.next=60;break}return this.logShelfDebug({phase:"configChanged",action:"stashOutdatedRestored",gridIndex:v,detail:"edited since, but nothing to carry over"}),h.next=58,this.placeStashedAccessoiresInGrid(v,p.accessoires);case 58:if(!h.sent){h.next=60;break}return h.abrupt("continue",62);case 60:return h.next=62,this.initAccList(v);case 62:v++,h.next=27;break;case 65:if(r||!Object.keys(t).length){h.next=76;break}k=this.activeGrids,A=0;case 68:if(!(A<k.length)){h.next=76;break}if(C=k[A],!(null!==(x=C.DisableCellsByMeasures)&&void 0!==x&&x.options.find((function(r){return Object.keys(t).includes("OPT"+r.opt)}))||C.disableCellsByRules)){h.next=73;break}return r=!0,h.abrupt("break",76);case 73:A++,h.next=68;break;case 76:r&&this.updateDisabledCells();case 77:case"end":return h.stop()}}),_callee2,this)}))),function onConfigChanged(t){return P.apply(this,arguments)})},{key:"creatNewGrid",value:function creatNewGrid(t){this.grids[t]=new b.ZP(t,this.article,this.data),this.grids[t].onConfigChanged()}},{key:"stashAccessoiresOfGrid",value:function stashAccessoiresOfGrid(t,r){var i=this.collectAccessoiresToStash(this.grids[t],this.valuesPassedOnByParents());if(!i.length)return i;var l=this.stashKey(t,r);return this.stashedAccessoires[l]=i,this.stashEpochs[l]=this.editEpoch,i}},{key:"noteUserEdit",value:function noteUserEdit(){var t;this.editEpoch++,null===(t=this.article.accessoireParentArticle)||void 0===t||null===(t=t.shelfPlanner)||void 0===t||t.noteUserEdit()}},{key:"withdrawUserEdit",value:function withdrawUserEdit(){var t;this.editEpoch--,null===(t=this.article.accessoireParentArticle)||void 0===t||null===(t=t.shelfPlanner)||void 0===t||t.withdrawUserEdit()}},{key:"isOnlyInitContent",value:function isOnlyInitContent(t,r){return r.every((function(r){var i;return null===(i=t.InitAccArr)||void 0===i?void 0:i.some((function(t){return t.Codex===r.articleCodex&&t.initRH.includes(r.cellIndex)}))}))}},{key:"placeTransferredAccessoires",value:(I=(0,l.Z)(h().mark((function _callee3(t,r){var i,l,c,o,d,u,g=this;return h().wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:i=[t].concat((0,a.Z)((0,a.Z)(r.keys()).filter((function(r){return r!==t&&g.grids[r].DisabledByRule})))),l=_createForOfIteratorHelper(i),h.prev=2,l.s();case 4:if((c=l.n()).done){h.next=18;break}if(o=c.value,d=r.get(o)){h.next=9;break}return h.abrupt("continue",16);case 9:return h.next=11,this.placeStashedAccessoiresInGrid(t,d,!0);case 11:if(u=h.sent){h.next=14;break}return h.abrupt("continue",16);case 14:return r.delete(o),h.abrupt("return",u);case 16:h.next=4;break;case 18:h.next=23;break;case 20:h.prev=20,h.t0=h.catch(2),l.e(h.t0);case 23:return h.prev=23,l.f(),h.finish(23);case 26:return h.abrupt("return",0);case 27:case"end":return h.stop()}}),_callee3,this,[[2,20,23,26]])}))),function placeTransferredAccessoires(t,r){return I.apply(this,arguments)})},{key:"countPlacedOfFamily",value:function countPlacedOfFamily(t,r){var i=[r].concat((0,a.Z)((0,b.A6)(r,this.article.CatalogData.allCatalogArticles)));return t.Cells.filter((function(t){var r,l;return function startsHere(t){return t.InUse===t.Index&&!t.OnlyPlaceHolder}(t)&&i.includes(null!==(r=null===(l=t.Article)||void 0===l?void 0:l.articleCodex)&&void 0!==r?r:"")})).length}},{key:"familyCandidates",value:function familyCandidates(t,r){var i=t.getAllArticleRelations(),l=(0,b.A6)(r,this.article.CatalogData.allCatalogArticles).filter((function(t){return t!==r}));return[r].concat((0,a.Z)(l)).filter((function(t){return i.includes(t)}))}},{key:"stashKey",value:function stashKey(t,r){return t+"#"+r}},{key:"collectAccessoiresToStash",value:function collectAccessoiresToStash(t,r){for(var i=[],l=ShelfPlanner.addValuesPassedOnBy(this.article,r),a=0;a<t.Cells.length;a++){var c,o,d,u=t.Cells[a],h=u.Article;if(u.InUse===a&&h){for(var g=null!==(c=null===(o=h.shelfPlanner)||void 0===o?void 0:o.collectOwnAccessoiresToStash(l))&&void 0!==c?c:{},v=h.VariantValues,b=null!==(d=l[h.basketId])&&void 0!==d?d:{},p=0,y=Object.keys(b);p<y.length;p++){var k=y[p];v[k]===b[k]&&delete v[k]}i.push({articleCodex:h.articleCodex,cellIndex:a,noMove:u.NoMove,noDelete:u.NoDelete,quantity:h.quantity,variantValues:v,inheritedValues:b,accessoires:g})}}return i}},{key:"valuesPassedOnByParents",value:function valuesPassedOnByParents(){for(var t=[],r=this.article.accessoireParentArticle;r;r=r.accessoireParentArticle)t.unshift(r);return t.reduce((function(t,r){return ShelfPlanner.addValuesPassedOnBy(r,t)}),{})}},{key:"collectOwnAccessoiresToStash",value:function collectOwnAccessoiresToStash(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.valuesPassedOnByParents(),r={},i=0;i<this.grids.length;i++){var l=this.grids[i],a=this.collectAccessoiresToStash(l,t);a.length&&(r[l.ShelfIndex]={ruleIndex:l.CurrentLoadedRuleIndex,accessoires:a})}return r}},{key:"takeStashOfGrid",value:function takeStashOfGrid(t){var r=this.stashKey(t,this.grids[t].CurrentLoadedRuleIndex),i=this.stashedAccessoires[r],l=this.stashEpochs[r]!==this.editEpoch;return delete this.stashedAccessoires[r],delete this.stashEpochs[r],null!=i&&i.length?{accessoires:i,outdated:l}:void 0}},{key:"placeStashedAccessoiresByGrid",value:(O=(0,l.Z)(h().mark((function _callee4(t){var r,i,l,a,c,o,d=arguments;return h().wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:r=d.length>1&&void 0!==d[1]&&d[1],i=Object.keys(t),l=0;case 3:if(!(l<i.length)){u.next=19;break}if(a=Number(i[l]),c=this.getGridByIndex(a),o=t[a],c&&(r||c.CurrentLoadedRuleIndex===o.ruleIndex)){u.next=9;break}return u.abrupt("continue",16);case 9:return u.next=11,c.deleteAllAccOfGrid();case 11:return u.next=13,this.placeStashedAccessoiresInGrid(a,o.accessoires,r);case 13:if(u.sent){u.next=16;break}return u.next=16,this.initAccList(a);case 16:l++,u.next=3;break;case 19:case"end":return u.stop()}}),_callee4,this)}))),function placeStashedAccessoiresByGrid(t){return O.apply(this,arguments)})},{key:"placeStashedAccessoiresInGrid",value:(C=(0,l.Z)(h().mark((function _callee5(t,r){var i,l,a,c,o,d,u,b,k,A,x,C,O,I=arguments;return h().wrap((function _callee5$(h){for(;;)switch(h.prev=h.next){case 0:if(i=I.length>2&&void 0!==I[2]&&I[2],l=0,a=this.getGridByIndex(t)){h.next=5;break}return h.abrupt("return",l);case 5:c=0;case 6:if(!(c<r.length)){h.next=53;break}o=r[c],d=!1,u=_createForOfIteratorHelper(i?this.familyCandidates(a,o.articleCodex):[o.articleCodex]),h.prev=10,u.s();case 12:if((b=u.n()).done){h.next=23;break}return k=b.value,a.ActAccessoire=k,h.next=17,v.Z.addAccessorieOnShelfPlanner(this.article.set,t,o.cellIndex,this.article.basketId,{noMove:o.noMove,noDelete:o.noDelete,byInit:!0,onlyOfferedCells:i});case 17:if(d=h.sent,a.ActAccessoire=void 0,!isPlaced(d)){h.next=21;break}return h.abrupt("break",23);case 21:h.next=12;break;case 23:h.next=28;break;case 25:h.prev=25,h.t0=h.catch(10),u.e(h.t0);case 28:return h.prev=28,u.f(),h.finish(28);case 31:if(A=i?isPlaced(d)?d:void 0:!1===d||void 0===d.index?void 0:d,x=null==A?void 0:A.accessoire,!i||A&&x){h.next=36;break}return this.logShelfDebug({phase:"configChanged",action:"accessoryNotTransferred",gridIndex:t,cellIndex:o.cellIndex,articleCodex:o.articleCodex,detail:"no member of its family fits into this grid"}),h.abrupt("continue",50);case 36:if(A&&x){h.next=39;break}return y.error(new g.GE("shelfaccessoire of a switched off grid does not fit anymore and gets dropped",{code:"WC_0015",custom:{stashed:o,gridName:a.GridName,result:d,parentPosNr:this.article.posNr,parentArticleCodex:this.article.articleCodex,parentBasketId:this.article.basketId}})),h.abrupt("continue",50);case 39:if(x.quantity=o.quantity,l++,C=x.articleCodex!==o.articleCodex,i&&this.logShelfDebug({phase:"configChanged",action:"accessoryTransferred",gridIndex:t,cellIndex:o.cellIndex,articleCodex:x.articleCodex,detail:C?"as family member of ".concat(o.articleCodex):"same article"}),O=this.valuesToPlaceAgain(o,x),!Object.keys(O).length){h.next=47;break}return h.next=47,p.Z.updateCfgValues(x,O,{});case 47:if(!x.shelfPlanner){h.next=50;break}return h.next=50,x.shelfPlanner.placeStashedAccessoiresByGrid(o.accessoires,i||C);case 50:c++,h.next=6;break;case 53:return h.abrupt("return",l);case 54:case"end":return h.stop()}}),_callee5,this,[[10,25,28,31]])}))),function placeStashedAccessoiresInGrid(t,r){return C.apply(this,arguments)})},{key:"valuesToPlaceAgain",value:function valuesToPlaceAgain(t,r){var i,l=_objectSpread({},t.variantValues),a=Object.keys(t.inheritedValues).filter((function(t){return t in l}));if(!a.length)return l;var c,o=null!==(i=ShelfPlanner.addValuesPassedOnBy(this.article,this.valuesPassedOnByParents())[r.basketId])&&void 0!==i?i:{},d=_createForOfIteratorHelper(a);try{for(d.s();!(c=d.n()).done;){var u=c.value;void 0!==o[u]&&o[u]!==t.inheritedValues[u]&&delete l[u]}}catch(t){d.e(t)}finally{d.f()}return l}},{key:"initAccList",value:(x=(0,l.Z)(h().mark((function _callee6(t){var r,i,l,a,c,o,d,u,g,b,p,y,k,A,x,C,O,I,P,S;return h().wrap((function _callee6$(h){for(;;)switch(h.prev=h.next){case 0:r=this.activeGrids,i=0;case 2:if(!(i<r.length)){h.next=43;break}if(l=r[i],void 0===t||l.ShelfIndex===t){h.next=6;break}return h.abrupt("continue",40);case 6:if(l.InitAccArr){h.next=8;break}return h.abrupt("continue",40);case 8:a=new Map,c=0;case 10:if(!(c<l.InitAccArr.length)){h.next=40;break}g=l.InitAccArr[c],b=null!==(o=null===(d=this.article.CatalogData.allCatalogArticles[g.Codex])||void 0===d?void 0:d.accessoireFamily)&&void 0!==o?o:g.Codex,p=null!==(u=a.get(b))&&void 0!==u?u:this.countPlacedOfFamily(l,g.Codex),y=Math.min(p,g.initRH.length),a.set(b,p-y),k=y;case 17:if(!(k<g.initRH.length)){h.next=37;break}return l.ActAccessoire=g.Codex,this.logShelfDebug({phase:"initAccessories",action:"initAccessoryRequested",gridIndex:l.ShelfIndex,cellIndex:g.initRH[k],articleCodex:g.Codex,detail:"from InitAccArr — a missing matching accessoryPlaced entry right after means the init placement failed"}),h.next=22,v.Z.addAccessorieOnShelfPlanner(this.article.set,l.ShelfIndex,g.initRH[k],l.basketId,{noMove:g.noMove,noDelete:g.noDelete,byInit:!0});case 22:if(A=!v.Z.isDryRunArticle(this.article.accessoireParentArticle),!g.replaceFromParent||v.Z.isDryRunArticle(this.article)&&A){h.next=33;break}if(!(C=this.getShelfParentShelfId())||null===(x=this.article.accessoireParentArticle)||void 0===x||!x.shelfPlanner){h.next=33;break}if(!((O=this.article.accessoireParentArticle.shelfPlanner.getAccessorireByCodex(C,g.Codex))&&O.length>0)){h.next=33;break}if(P=O[0],void 0===(S=null===(I=P.shelfPlanner)||void 0===I?void 0:I.getRHOnParentArticle())||void 0===P.relatedToShelfGrid){h.next=33;break}return h.next=33,v.Z.deleteAccessorieOnShelfPlanner(this.article.set,P.relatedToShelfGrid,S,this.article.accessoireParentArticle.basketId);case 33:l.ActAccessoire=void 0;case 34:k++,h.next=17;break;case 37:c++,h.next=10;break;case 40:i++,h.next=2;break;case 43:case"end":return h.stop()}}),_callee6,this)}))),function initAccList(t){return x.apply(this,arguments)})},{key:"getAccessorireByCodex",value:function getAccessorireByCodex(t,r){var i=this.grids.find((function(r){return r.ShelfId==t})),l=[];if(i)for(var a in i.Accessoires)i.Accessoires[a].articleCodex==r&&l.push(i.Accessoires[a]);return l}},{key:"triggerVisibility",value:(A=(0,l.Z)(h().mark((function _callee7(t){var r,i,l,a,c,o,d;return h().wrap((function _callee7$(u){for(;;)switch(u.prev=u.next){case 0:r=[],i=[],l=0;case 3:if(!(l<this.grids.length)){u.next=13;break}if((a=this.grids[l]).VisitOption){u.next=7;break}return u.abrupt("continue",10);case 7:if(!i.includes(a.VisitOption)&&!r.includes(a.VisitOption)){u.next=9;break}return u.abrupt("continue",10);case 9:t&&(a.gridGroup==t||a.alternativeGridGroups.includes(t))?(i.push(a.VisitOption),r.includes(a.VisitOption)&&r.splice(r.indexOf(a.VisitOption),1)):r.push(a.VisitOption);case 10:l++,u.next=3;break;case 13:c=0;case 14:if(!(c<[].concat(i,r).length)){u.next=23;break}if(o=[].concat(i,r)[c],!(d=this.article.getArticleOptionState((this.article.CatalogData.isIDMFormat?"":"OPT")+o))){u.next=20;break}return u.next=20,p.Z.updateOption(this.article,d.optionCodex,i.includes(o)?"OPVMIT":"OPVOHNE");case 20:c++,u.next=14;break;case 23:case"end":return u.stop()}}),_callee7,this)}))),function triggerVisibility(t){return A.apply(this,arguments)})},{key:"deleteAllAcc",value:(k=(0,l.Z)(h().mark((function _callee8(){var t;return h().wrap((function _callee8$(r){for(;;)switch(r.prev=r.next){case 0:this.article.shelfPlanData=void 0,this.restorePending=!1,t=0;case 3:if(!(t<this.grids.length)){r.next=9;break}return r.next=6,this.grids[t].deleteAllAccOfGrid();case 6:t++,r.next=3;break;case 9:case"end":return r.stop()}}),_callee8,this)}))),function deleteAllAcc(){return k.apply(this,arguments)})},{key:"GridAllowedOnCells",get:function get(){return this.gridAllowedOnCells}},{key:"GridAllowedOntoArticles",get:function get(){return this.gridAllowedOntoArticles}},{key:"TakePlaceOnOtherGrids",get:function get(){return this.takePlaceOnOtherGrids}},{key:"tryFitOnShelfOfGrid",value:function tryFitOnShelfOfGrid(t,r,i){var l=i.shelfHeight,a=this.grids[t];if(!l||isNaN(l))return alert("Der artikel: "+i.name+" hat keine RH hinterlegt! Der Metatag 'HEIGHTGRIDUSED' ist: "+i.shelfHeight),!1;var c=!1,o=this.doesTakePlaceOnOtherGrids(i)?this.activeGrids:[a];if(a.checkAccessoireInGridRules(i))return{type:"notAllowedByMaxQuantityReached",size:l};for(var d=0;d<o.length;d++)if(!1===(c=o[d].tryFitOnShelf(i,r,i.shelfPlanner))||"doesNotFit"===c.type||c.type.startsWith("notAllowed")||void 0===c.index)return c;return c}},{key:"tryFitOnOfferedCellOfGrid",value:function tryFitOnOfferedCellOfGrid(t,r,i){var l=this.tryFitOnShelfOfGrid(t,r,i);return!1===l||void 0===l.index||"doesNotFit"===l.type||l.type.startsWith("notAllowed")||this.grids[t].getFreeSpacesOfAccessoire(i).includes(l.index)?l:{type:"doesNotFit",size:l.size}}},{key:"getFreeSpacesOfAccessoireOfGrids",value:function getFreeSpacesOfAccessoireOfGrids(t,r){for(var i=this.grids,l={},a=0;a<i.length;a++){var c=i[a];c.DisabledByRule||(l[c.GridName]={freeCells:c.getFreeSpacesOfAccessoire(r),idx:a})}return l}},{key:"getPlannedSpacesOfGrids",value:function getPlannedSpacesOfGrids(){for(var t=this.grids,r={},i=0;i<t.length;i++){var l=t[i];l.DisabledByRule||(r[l.GridName]={accessories:l.getPlannedSpaces(),idx:i})}return r}},{key:"deleteAccessoireOfCellInGrid",value:(u=(0,l.Z)(h().mark((function _callee9(t,r){var i,l,a,c,o,d;return h().wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:if(i=this.grids[t],l=i.Cells[r].InUse,(c=i.Cells.find((function(t){return t.OnBoard==l})))?(a=c.InUse,c.Article):(a=r,o=i.Cells[r].Article),!o){u.next=8;break}return this.checkForNewFreeAccessoire(o,t),u.next=8,this.handleDeleteTakePlaceOnOtherGrids(t,a,o);case 8:return u.next=10,i.deleteAccessoireInCells(a);case 10:return(d=u.sent)&&this.logShelfDebug({phase:"placement",action:"accessoryDeleted",gridIndex:t,cellIndex:a,articleCodex:d.articleCodex,articleName:d.name}),u.abrupt("return",d);case 13:case"end":return u.stop()}}),_callee9,this)}))),function deleteAccessoireOfCellInGrid(t,r){return u.apply(this,arguments)})},{key:"checkForNewFreeAccessoire",value:function checkForNewFreeAccessoire(t,r){if(void 0!==this.freeArticlesPossible[t.articleCodex]&&t.noPrice){this.freeArticlesPlanned[t.articleCodex]-=t.quantity;var i=this.grids[r];for(var l in i.Accessoires)i.Accessoires[l].articleCodex!=t.articleCodex||i.Accessoires[l].noPrice||(i.Accessoires[l].noPrice=!0,this.freeArticlesPlanned[i.Accessoires[l].articleCodex]+=t.quantity)}}},{key:"handleDeleteTakePlaceOnOtherGrids",value:(i=(0,l.Z)(h().mark((function _callee10(t,r,i){var l,a,c,o,d,u,g;return h().wrap((function _callee10$(h){for(;;)switch(h.prev=h.next){case 0:if(i.shelfHeight){h.next=2;break}return h.abrupt("return");case 2:if(i.shelfHeightAbove)for(l=0;l<i.shelfHeightAbove;l++)(null==(c=this.grids[t].Cells[r+i.shelfHeight+l])||null===(a=c.Article)||void 0===a?void 0:a.basketId)===i.basketId&&c.ClearInUse();if(i.shelfHeightBelow)for(o=0;o<i.shelfHeightBelow;o++)(null==(u=this.grids[t].Cells[r-(o+1)])||null===(d=u.Article)||void 0===d?void 0:d.basketId)===i.basketId&&u.ClearInUse();if(!this.doesTakePlaceOnOtherGrids(i)){h.next=14;break}g=0;case 6:if(!(g<this.grids.length)){h.next=14;break}if(g!==t){h.next=9;break}return h.abrupt("continue",11);case 9:return h.next=11,this.grids[g].deleteAccessoireInCells(r);case 11:g++,h.next=6;break;case 14:case"end":return h.stop()}}),_callee10,this)}))),function handleDeleteTakePlaceOnOtherGrids(t,r,l){return i.apply(this,arguments)})},{key:"addAccessoireInCellInGrid",value:(r=(0,l.Z)(h().mark((function _callee11(t,r,i,l,a){var c,o,d;return h().wrap((function _callee11$(u){for(;;)switch(u.prev=u.next){case 0:c=this.doesTakePlaceOnOtherGrids(t)?this.activeGrids:[this.grids[r]],o=0;case 2:if(!(o<c.length)){u.next=13;break}if(!(d=c[o]).DisabledByRule){u.next=7;break}return this.logShelfDebug({phase:"placement",action:"placementSkippedGridDisabled",gridIndex:d.ShelfIndex,cellIndex:i,articleCodex:t.articleCodex}),u.abrupt("continue",10);case 7:return this.logShelfDebug({phase:"placement",action:"accessoryPlaced",gridIndex:d.ShelfIndex,cellIndex:i,articleCodex:t.articleCodex,articleName:t.name,detail:l+(d.ShelfIndex!==r?" (placeholder via TakePlaceOnOtherGrids)":"")}),u.next=10,c[o].addAccessoireInCells(i,t,l,d.ShelfIndex!==r||(null==a?void 0:a.noMove),d.ShelfIndex!==r||(null==a?void 0:a.noDelete),d.ShelfIndex!==r||void 0);case 10:o++,u.next=2;break;case 13:this.checkForFreeAccessoire(t);case 14:case"end":return u.stop()}}),_callee11,this)}))),function addAccessoireInCellInGrid(t,i,l,a,c){return r.apply(this,arguments)})},{key:"checkForFreeAccessoire",value:function checkForFreeAccessoire(t){void 0!==this.freeArticlesPossible[t.articleCodex]&&(void 0===this.freeArticlesPlanned[t.articleCodex]||this.freeArticlesPossible[t.articleCodex]>this.freeArticlesPlanned[t.articleCodex])&&(t.noPrice=!0,void 0===this.freeArticlesPlanned[t.articleCodex]&&(this.freeArticlesPlanned[t.articleCodex]=0),this.freeArticlesPlanned[t.articleCodex]+=t.quantity)}},{key:"doesTakePlaceOnOtherGrids",value:function doesTakePlaceOnOtherGrids(t){var r,i=null===(r=t.shelfPlanner)||void 0===r?void 0:r.takePlaceOnOtherGrids;if(i)for(var l=0;l<i.length;l++)if(i[l].onParent==this.article.articleCodex)return!0;return!1}},{key:"accessoires",get:function get(){for(var t={},r=this.activeGrids,i=0;i<r.length;i++)for(var l in r[i].Accessoires)t[l]=r[i].Accessoires[l];return Object.keys(t).length>0?t:void 0}},{key:"DisableCellsByElement",get:function get(){return this.disableCellsByElement}},{key:"getActAccessoireOfGrid",value:function getActAccessoireOfGrid(t){return this.grids[t].ActAccessoire}},{key:"setActAccessoireOfGrid",value:function setActAccessoireOfGrid(t,r){for(var i=!1,l=this.GridsOrGroupById(t),a=0;a<l.length;a++){var c=l[a];r&&c.getArticleRelationsById(t).includes(r)?c.ActAccessoire!==r&&(c.ActAccessoire=r,i=!0):c.ActAccessoire=void 0}return i}},{key:"generateShelfPlandata",value:function generateShelfPlandata(){for(var t,r=[],i=this.grids.filter((function(t){return!t.DisabledByRule||t.Cells.some((function(t){return t.InUse===t.Index&&t.Article}))})),l=0;l<i.length;l++){for(var a=[],c=i[l],o=0;o<c.Cells.length;o++){var d,u,h=c.Cells[o];if(a.push({inUse:h.InUse,noDelete:h.NoDelete,noMove:h.NoMove,onBoard:h.OnBoard}),c.ShelfIndex!=l&&(a[o].gridIndex=c.ShelfIndex),h.InUse==o)a[o].usedArticleData={Codex:null===(d=h.Article)||void 0===d?void 0:d.articleCodex,BasketID:null===(u=h.Article)||void 0===u?void 0:u.basketId}}r.push(a)}return{ShelfPlanner2:r,DoorPlannerData:null===(t=this.article.doorPlanner)||void 0===t?void 0:t.getMovedData(this.article.basketId)}}},{key:"getShelfPlannerAccessoires3DValues",value:function getShelfPlannerAccessoires3DValues(t){for(var r=this.activeGrids,i=0;i<r.length;i++)for(var l=r[i],a=0;a<l.Cells.length;a++){var c=l.Cells[a];if(c.InUse==a&&c.Article&&c.Article.model3DName&&!c.OnlyPlaceHolder){var o,d=c.Index;"vertikal"==l.Direction&&1!=this.article.CatalogData.useShelfPlannerRTV&&(d=l.Cells.length-1-c.Index),t.push({basketId:null===(o=c.Article)||void 0===o?void 0:o.basketId,gridId:l.ShelfIndex,gridName:l.GridName,model:c.Article.model3DName,parentBasketId:this.article.basketId,parentElementId:this.getShelfElementId(),rh:d}),c.Article.shelfPlanner&&(t=t.concat(c.Article.shelfPlanner.getShelfPlannerAccessoires3DValues([])))}}return t}},{key:"getShelfElementId",value:function getShelfElementId(){var t;if(null!==(t=this.article.accessoireParentArticle)&&void 0!==t&&t.shelfPlanner&&void 0!==this.article.relatedToShelfGrid&&this.grids.length>0){var r=this.getRHOnParentArticle();return this.article.accessoireParentArticle.shelfPlanner.getShelfElementId()+"."+this.article.relatedToShelfGrid+"."+r}return this.article.elementId.toString()}},{key:"getRHOnParentArticle",value:function getRHOnParentArticle(){var t,r=this;if(void 0!==this.article.relatedToShelfGrid)return null===(t=this.article.accessoireParentArticle)||void 0===t||null===(t=t.shelfPlanner)||void 0===t||null===(t=t.grids[this.article.relatedToShelfGrid].Cells.find((function(t){var i;return(null===(i=t.Article)||void 0===i?void 0:i.basketId)==r.article.basketId})))||void 0===t?void 0:t.InUse}},{key:"getShelfPlannerItems",value:function getShelfPlannerItems(t){for(var r=[],i=this.article.CatalogData,l=this.GridsOrGroupById(t),a=0;a<l.length;a++){var c=l[a].getArticleRelationsById(t);if(null!=c&&c.length)for(var o=function _loop(){var t=c[d];if(i.checkIfArticleCodexExists(t)){var l=i.getCatalogArticleByArticleCodex(t);if(!l||r.find((function(t){return t.articleCodex===l.articleCodex})))return 1;r.push({articleCodex:l.articleCodex,configStepKeys:[],image:l.image?i.getCatImageURL(l.image,""):void 0,name:l.name,longDescription:l.longDescription,price:i.dontShowBasePrice?0:Number(l.articlePrice),width:l.width,height:l.height,depth:l.depth,cellSize:l.shelfHeight,metaData:l.metaDataView,accessoireFamily:l.accessoireFamily,contentItemId:l.contentItemId,groupContentItemId:l.groupContentItemId,partlistcodexes:l.possiblePartlistCodexes})}},d=0;d<c.length;d++)o()}return{accessoires:r,grids:l}}},{key:"getShelfParentShelfId",value:function getShelfParentShelfId(){var t;if(void 0!==this.article.relatedToShelfGrid)return null===(t=this.article.accessoireParentArticle)||void 0===t||null===(t=t.shelfPlanner)||void 0===t||null===(t=t.grids[this.article.relatedToShelfGrid])||void 0===t?void 0:t.ShelfId}},{key:"updateOnDockingChanged",value:function updateOnDockingChanged(t){("AVL"==t&&"RH_OVER_AVL"==this.disableCellsByElement||"AVR"==t&&"RH_OVER_AVR"==this.disableCellsByElement)&&this.updateDisabledCells()}},{key:"updateDisabledCells",value:function updateDisabledCells(){this.updateDisabledCellsOnDockedElements(),this.checkOnDockedHeight()}},{key:"updateDisabledCellsOnDockedElements",value:function updateDisabledCellsOnDockedElements(){var t,r=this.activeGrids,i=this.article.dockedOnAV("L"),l=this.article.dockedOnAV("R");if("RH_OVER_AVR"==this.disableCellsByElement&&i)null===(t=i.shelfPlanner)||void 0===t||t.disableCellsByDockedShelfs(r[0].getCellCount("AVL"));else if("RH_OVER_AVL"==this.disableCellsByElement&&l){var a;null===(a=l.shelfPlanner)||void 0===a||a.disableCellsByDockedShelfs(r[0].getCellCount("AVR"))}}},{key:"checkOnDockedHeight",value:function checkOnDockedHeight(){var t=this.article.dockedOnAV("R"),r=this.article.dockedOnAV("L");null!=t&&t.shelfPlanner&&t.shelfPlanner.activeGrids.length>0&&"RH_OVER_AVR"==this.disableCellsByElement?this.disableCellsByDockedShelfs(t.shelfPlanner.activeGrids[0].getCellCount("AVL")):null!=r&&r.shelfPlanner&&r.shelfPlanner.activeGrids.length>0&&"RH_OVER_AVL"==this.disableCellsByElement?this.disableCellsByDockedShelfs(r.shelfPlanner.activeGrids[0].getCellCount("AVR")):this.disableCellsByDockedShelfs()}},{key:"disableCellsByDockedShelfs",value:(t=(0,l.Z)(h().mark((function _callee12(t){var r,i,l,a=this;return h().wrap((function _callee12$(c){for(;;)switch(c.prev=c.next){case 0:r=this.activeGrids,i=h().mark((function _loop2(){var i,c,o,d,u,g,b,p,y,k;return h().wrap((function _loop2$(h){for(;;)switch(h.prev=h.next){case 0:for(i=r[l],c=i.getCellCount(),o=i.getDisabledCellsByRule(),u=d=null==t||t>c?c:t;u<i.Cells.length;u++)o.push(u);g=o.filter((function(t){return i.Cells[t]&&!i.Cells[t].IsDisabled})),b=i.Cells.filter((function(t,r){return t.IsDisabled&&!o.includes(r)})).length,(g.length||b)&&a.logShelfDebug({phase:"docking",action:"disabledCellsUpdated",gridIndex:i.ShelfIndex,detail:"newlyDisabled=[".concat(g.slice(0,30).join(","),"] reEnabled=").concat(b," ")+"(sources: DisableCellsByRules/measures=".concat(i.getDisabledCellsByRule().length,", beyond cellCount/docking cap=").concat(i.Cells.length-d,"); ")+"an occupied cell that gets disabled deletes its accessory"}),p=0;case 9:if(!(p<o.length)){h.next=18;break}if((y=i.Cells[o[p]]).InUse!=o[p]){h.next=14;break}return h.next=14,v.Z.deleteAccessorieOnShelfPlanner(a.article.set,i.ShelfIndex,y.InUse,i.basketId);case 14:y.IsDisabled=!0;case 15:p++,h.next=9;break;case 18:k=0;case 19:if(!(k<i.Cells.length)){h.next=26;break}if(!o.includes(k)){h.next=22;break}return h.abrupt("continue",23);case 22:i.Cells[k].IsDisabled=!1;case 23:k++,h.next=19;break;case 26:case"end":return h.stop()}}),_loop2)})),l=0;case 3:if(!(l<r.length)){c.next=8;break}return c.delegateYield(i(),"t0",5);case 5:l++,c.next=3;break;case 8:case"end":return c.stop()}}),_callee12,this)}))),function disableCellsByDockedShelfs(r){return t.apply(this,arguments)})},{key:"getGridByGridName",value:function getGridByGridName(t){return this.grids.find((function(r){return r.GridName==t}))}},{key:"getGridByIndex",value:function getGridByIndex(t){return this.grids.find((function(r){return r.ShelfIndex==t}))}},{key:"GridsOrGroupById",value:function GridsOrGroupById(t){return this.activeGrids.filter((function(r){return r.ShelfId==t||r.group==t||r.alternativeGridGroups.includes(t)}))}},{key:"getSelectedAccessoireById",value:function getSelectedAccessoireById(t){var r;return null===(r=this.GridsOrGroupById(t).find((function(r){if(r.ActAccessoire&&r.getArticleRelationsById(t).includes(r.ActAccessoire))return r})))||void 0===r?void 0:r.ActAccessoire}},{key:"getCellIndexOfBasketId",value:function getCellIndexOfBasketId(t,r){var i;return null===(i=this.getGridByIndex(t))||void 0===i?void 0:i.getIndexOfBasketId(r)}},{key:"allGrids",get:function get(){return this.grids}},{key:"activeGrids",get:function get(){return this.grids.filter((function(t){return!t.DisabledByRule}))}},{key:"allMontageOptions",get:function get(){return this.montageOptions}},{key:"getRelatedToGridIdByArticleCodex",value:function getRelatedToGridIdByArticleCodex(t,r){var i=this.grids[r].getGridIdByArticleCodex(t);if(i)return i;for(var l=0;l<this.grids.length;l++){var a=this.grids[l].getGridIdByArticleCodex(t);if(a)return a}}}],[{key:"addValuesPassedOnBy",value:function addValuesPassedOnBy(t,r){for(var i={},l=0,a=Object.keys(t.getGlobalOptions());l<a.length;l++){var c,o=a[l],d=null===(c=t.getArticleOptionState(o))||void 0===c?void 0:c.valCodex;d&&(i[o]=d)}for(var u=_objectSpread({},r),h=t.getAccessoriesToChangeFromGlobalOption(i),g=0,v=Object.keys(h);g<v.length;g++){var b=v[g];u[b]=_objectSpread(_objectSpread({},u[b]),h[b].variantValues)}return u}}]);var t,r,i,u,k,A,x,C,O,I,P,S}()}}]);
|
|
2
|
+
"use strict";(self.webpackChunkCrystaldesignDivaWebPlannerReact=self.webpackChunkCrystaldesignDivaWebPlannerReact||[]).push([[3596],{33596:(t,r,i)=>{i.r(r),i.d(r,{default:()=>k});var l=i(84658),a=i(61965),c=i(13125),o=i(43860),d=i(80248),u=i(50747),h=i.n(u),g=i(2221),v=i(28805),b=i(77189),p=i(69821);function _createForOfIteratorHelper(t,r){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){i&&(t=i);var l=0,a=function F(){};return{s:a,n:function n(){return l>=t.length?{done:!0}:{done:!1,value:t[l++]}},e:function e(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,o=!0,d=!1;return{s:function s(){i=i.call(t)},n:function n(){var t=i.next();return o=t.done,t},e:function e(t){d=!0,c=t},f:function f(){try{o||null==i.return||i.return()}finally{if(d)throw c}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var i=0,l=Array(r);i<r;i++)l[i]=t[i];return l}function ownKeys(t,r){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);r&&(l=l.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),i.push.apply(i,l)}return i}function _objectSpread(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(i),!0).forEach((function(r){(0,d.Z)(t,r,i[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(i,r))}))}return t}var y=g.ZP.initLog("Planner","WEB-PLANNER-LOGIC");function isPlaced(t){return!1!==t&&void 0!==t.index&&!!t.accessoire&&"doesNotFit"!==t.type&&!t.type.startsWith("notAllowed")}var k=function(){function ShelfPlanner(t,r){if((0,c.Z)(this,ShelfPlanner),(0,d.Z)(this,"article",void 0),(0,d.Z)(this,"grids",[]),(0,d.Z)(this,"isVisible",void 0),(0,d.Z)(this,"showOnRule",void 0),(0,d.Z)(this,"showAfterOPT",void 0),(0,d.Z)(this,"data",void 0),(0,d.Z)(this,"freeArticlesPossible",{}),(0,d.Z)(this,"freeArticlesPlanned",{}),(0,d.Z)(this,"gridAllowedOnCells",void 0),(0,d.Z)(this,"gridAllowedOntoArticles",void 0),(0,d.Z)(this,"takePlaceOnOtherGrids",void 0),(0,d.Z)(this,"disableCellsByElement",void 0),(0,d.Z)(this,"montageOptions",[]),(0,d.Z)(this,"restorePending",void 0),(0,d.Z)(this,"shelfDebugStack",[]),(0,d.Z)(this,"shelfDebugSeq",0),(0,d.Z)(this,"stashedAccessoires",{}),(0,d.Z)(this,"editEpoch",0),(0,d.Z)(this,"stashEpochs",{}),this.article=r,this.restorePending=!!r.shelfPlanData,this.disableCellsByElement=t.DisableCells,this.data=t,this.showAfterOPT=t.ShowAfterOPT,this.showOnRule=t.ShowOnRule?g.ZP.getRuleByFormula(t.ShowOnRule,r.catalogCodex,r.CatalogData.multiselectOptions):void 0,this.gridAllowedOnCells=t.GridAllowedOnCells,this.gridAllowedOntoArticles=t.GridAllowedOntoArticles,this.takePlaceOnOtherGrids=t.TakePlaceOnOtherGrids,this.initFreeArticles(),t.ShelfPlanner&&t.ShelfPlanner.length>0){for(var i=0;i<t.ShelfPlanner.length;i++)this.creatNewGrid(i),this.updateDisabledCells();this.montageOptions=(0,a.Z)(new Set(this.grids.reduce((function(t,r){return t=t.concat(r.montageOptionsList)}),[])))}}return(0,o.Z)(ShelfPlanner,[{key:"logShelfDebug",value:function logShelfDebug(t){this.shelfDebugStack.push(_objectSpread({seq:this.shelfDebugSeq++},t)),this.shelfDebugStack.length>500&&this.shelfDebugStack.splice(0,this.shelfDebugStack.length-500)}},{key:"initFreeArticles",value:function initFreeArticles(){if(this.data.ShelfPlanner)for(var t=0;t<this.data.ShelfPlanner.length;t++){var r=this.data.ShelfPlanner[t];if(r.initAccArr)for(var i=0;i<r.initAccArr.length;i++){var l=r.initAccArr[i];l.noPrice&&(void 0===this.freeArticlesPossible[l.Codex]&&(this.freeArticlesPossible[l.Codex]=0),this.freeArticlesPossible[l.Codex]+=l.Quantity)}}}},{key:"canBeFree",value:function canBeFree(t){return void 0!==this.freeArticlesPossible[t]}},{key:"IsVisible",get:function get(){return this.isVisible}},{key:"RestorePending",get:function get(){return this.restorePending},set:function set(t){this.restorePending=t}},{key:"setIsVisible",value:(S=(0,l.Z)(h().mark((function _callee(t){return h().wrap((function _callee$(r){for(;;)switch(r.prev=r.next){case 0:if(this.isVisible==t){r.next=13;break}if(this.logShelfDebug({phase:"visibility",action:t?"plannerShown":"plannerHidden",detail:t?void 0:"showOnRule/visibility turned false — all placed accessories are deleted"}),!t){r.next=11;break}if(this.isVisible=t,this.article.shelfPlanData){r.next=9;break}return r.next=7,this.onConfigChanged({});case 7:return r.next=9,this.initAccList();case 9:r.next=13;break;case 11:return r.next=13,this.deleteAllAcc();case 13:this.isVisible=t;case 14:case"end":return r.stop()}}),_callee,this)}))),function setIsVisible(t){return S.apply(this,arguments)})},{key:"onConfigChanged",value:(P=(0,l.Z)(h().mark((function _callee2(t){var r,i,l,a,c,o,d,u,g,v,b,p,y,k,A,x,C;return h().wrap((function _callee2$(h){for(;;)switch(h.prev=h.next){case 0:for(r=!1,i=[],l=this.grids.map((function(t){return t.CurrentLoadedRuleIndex})),a=0;a<this.grids.length;a++)i.push(this.grids[a].onConfigChanged());c=0;case 5:if(!(c<i.length)){h.next=14;break}if(i[c].length){h.next=8;break}return h.abrupt("continue",11);case 8:o=this.grids[c],i[c].includes("disableGridRule")&&this.logShelfDebug({phase:"configChanged",action:o.DisabledByRule?"gridDisabledByRule":"gridEnabledByRule",gridIndex:o.ShelfIndex,detail:o.ShowOnRule}),i[c].includes("heightGridRule")&&this.logShelfDebug({phase:"configChanged",action:"gridRecreated",gridIndex:o.ShelfIndex,detail:"HeightGridCellCountOnRule match changed — grid rebuilt (cell count / placeable accessories can change), its accessories are deleted"});case 11:c++,h.next=5;break;case 14:d=new Map,u=0;case 16:if(!(u<i.length)){h.next=26;break}if(i[u].length){h.next=19;break}return h.abrupt("continue",23);case 19:return g=this.stashAccessoiresOfGrid(u,l[u]),this.isOnlyInitContent(this.grids[u],g)||d.set(u,g),h.next=23,this.grids[u].deleteAllAccOfGrid();case 23:u++,h.next=16;break;case 26:v=0;case 27:if(!(v<i.length)){h.next=65;break}if(i[v].length){h.next=30;break}return h.abrupt("continue",62);case 30:if(i[v].includes("heightGridRule")&&(this.creatNewGrid(v),r=!0),b=this.grids[v],!i[v].includes("heightGridRule")&&!i[v].includes("disableGridRule")||b.DisabledByRule){h.next=62;break}if(!this.restorePending){h.next=35;break}return h.abrupt("continue",62);case 35:if(p=this.takeStashOfGrid(v),y=this.article.set.CatalogData.divaUseRtvNext,h.t0=p&&(!p.outdated||!y),!h.t0){h.next=42;break}return h.next=41,this.placeStashedAccessoiresInGrid(v,p.accessoires);case 41:h.t0=h.sent;case 42:if(!h.t0){h.next=45;break}return d.delete(v),h.abrupt("continue",62);case 45:if(h.t1=y,!h.t1){h.next=50;break}return h.next=49,this.placeTransferredAccessoires(v,d);case 49:h.t1=h.sent;case 50:if(!h.t1){h.next=54;break}return h.next=53,this.initAccList(v);case 53:return h.abrupt("continue",62);case 54:if(!y||null==p||!p.outdated){h.next=60;break}return this.logShelfDebug({phase:"configChanged",action:"stashOutdatedRestored",gridIndex:v,detail:"edited since, but nothing to carry over"}),h.next=58,this.placeStashedAccessoiresInGrid(v,p.accessoires);case 58:if(!h.sent){h.next=60;break}return h.abrupt("continue",62);case 60:return h.next=62,this.initAccList(v);case 62:v++,h.next=27;break;case 65:if(r||!Object.keys(t).length){h.next=76;break}k=this.activeGrids,A=0;case 68:if(!(A<k.length)){h.next=76;break}if(C=k[A],!(null!==(x=C.DisableCellsByMeasures)&&void 0!==x&&x.options.find((function(r){return Object.keys(t).includes("OPT"+r.opt)}))||C.disableCellsByRules)){h.next=73;break}return r=!0,h.abrupt("break",76);case 73:A++,h.next=68;break;case 76:r&&this.updateDisabledCells();case 77:case"end":return h.stop()}}),_callee2,this)}))),function onConfigChanged(t){return P.apply(this,arguments)})},{key:"creatNewGrid",value:function creatNewGrid(t){this.grids[t]=new b.ZP(t,this.article,this.data),this.grids[t].onConfigChanged()}},{key:"stashAccessoiresOfGrid",value:function stashAccessoiresOfGrid(t,r){var i=this.collectAccessoiresToStash(this.grids[t],this.valuesPassedOnByParents());if(!i.length)return i;var l=this.stashKey(t,r);return this.stashedAccessoires[l]=i,this.stashEpochs[l]=this.editEpoch,i}},{key:"noteUserEdit",value:function noteUserEdit(){var t;this.editEpoch++,null===(t=this.article.accessoireParentArticle)||void 0===t||null===(t=t.shelfPlanner)||void 0===t||t.noteUserEdit()}},{key:"withdrawUserEdit",value:function withdrawUserEdit(){var t;this.editEpoch--,null===(t=this.article.accessoireParentArticle)||void 0===t||null===(t=t.shelfPlanner)||void 0===t||t.withdrawUserEdit()}},{key:"isOnlyInitContent",value:function isOnlyInitContent(t,r){return r.every((function(r){var i;return null===(i=t.InitAccArr)||void 0===i?void 0:i.some((function(t){return t.Codex===r.articleCodex&&t.initRH.includes(r.cellIndex)}))}))}},{key:"placeTransferredAccessoires",value:(I=(0,l.Z)(h().mark((function _callee3(t,r){var i,l,c,o,d,u,g=this;return h().wrap((function _callee3$(h){for(;;)switch(h.prev=h.next){case 0:i=[t].concat((0,a.Z)((0,a.Z)(r.keys()).filter((function(r){return r!==t&&g.grids[r].DisabledByRule})))),l=_createForOfIteratorHelper(i),h.prev=2,l.s();case 4:if((c=l.n()).done){h.next=18;break}if(o=c.value,d=r.get(o)){h.next=9;break}return h.abrupt("continue",16);case 9:return h.next=11,this.placeStashedAccessoiresInGrid(t,d,!0);case 11:if(u=h.sent){h.next=14;break}return h.abrupt("continue",16);case 14:return r.delete(o),h.abrupt("return",u);case 16:h.next=4;break;case 18:h.next=23;break;case 20:h.prev=20,h.t0=h.catch(2),l.e(h.t0);case 23:return h.prev=23,l.f(),h.finish(23);case 26:return h.abrupt("return",0);case 27:case"end":return h.stop()}}),_callee3,this,[[2,20,23,26]])}))),function placeTransferredAccessoires(t,r){return I.apply(this,arguments)})},{key:"countPlacedOfFamily",value:function countPlacedOfFamily(t,r){var i=[r].concat((0,a.Z)((0,b.A6)(r,this.article.CatalogData.allCatalogArticles)));return t.Cells.filter((function(t){var r,l;return function startsHere(t){return t.InUse===t.Index&&!t.OnlyPlaceHolder}(t)&&i.includes(null!==(r=null===(l=t.Article)||void 0===l?void 0:l.articleCodex)&&void 0!==r?r:"")})).length}},{key:"familyCandidates",value:function familyCandidates(t,r){var i=t.getAllArticleRelations(),l=(0,b.A6)(r,this.article.CatalogData.allCatalogArticles).filter((function(t){return t!==r}));return[r].concat((0,a.Z)(l)).filter((function(t){return i.includes(t)}))}},{key:"stashKey",value:function stashKey(t,r){return t+"#"+r}},{key:"collectAccessoiresToStash",value:function collectAccessoiresToStash(t,r){for(var i=[],l=ShelfPlanner.addValuesPassedOnBy(this.article,r),a=0;a<t.Cells.length;a++){var c,o,d,u=t.Cells[a],h=u.Article;if(u.InUse===a&&h){for(var g=null!==(c=null===(o=h.shelfPlanner)||void 0===o?void 0:o.collectOwnAccessoiresToStash(l))&&void 0!==c?c:{},v=h.VariantValues,b=null!==(d=l[h.basketId])&&void 0!==d?d:{},p=0,y=Object.keys(b);p<y.length;p++){var k=y[p];v[k]===b[k]&&delete v[k]}i.push({articleCodex:h.articleCodex,cellIndex:a,noMove:u.NoMove,noDelete:u.NoDelete,quantity:h.quantity,variantValues:v,inheritedValues:b,accessoires:g})}}return i}},{key:"valuesPassedOnByParents",value:function valuesPassedOnByParents(){for(var t=[],r=this.article.accessoireParentArticle;r;r=r.accessoireParentArticle)t.unshift(r);return t.reduce((function(t,r){return ShelfPlanner.addValuesPassedOnBy(r,t)}),{})}},{key:"collectOwnAccessoiresToStash",value:function collectOwnAccessoiresToStash(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.valuesPassedOnByParents(),r={},i=0;i<this.grids.length;i++){var l=this.grids[i],a=this.collectAccessoiresToStash(l,t);a.length&&(r[l.ShelfIndex]={ruleIndex:l.CurrentLoadedRuleIndex,accessoires:a})}return r}},{key:"takeStashOfGrid",value:function takeStashOfGrid(t){var r=this.stashKey(t,this.grids[t].CurrentLoadedRuleIndex),i=this.stashedAccessoires[r],l=this.stashEpochs[r]!==this.editEpoch;return delete this.stashedAccessoires[r],delete this.stashEpochs[r],null!=i&&i.length?{accessoires:i,outdated:l}:void 0}},{key:"placeStashedAccessoiresByGrid",value:(O=(0,l.Z)(h().mark((function _callee4(t){var r,i,l,a,c,o,d=arguments;return h().wrap((function _callee4$(u){for(;;)switch(u.prev=u.next){case 0:r=d.length>1&&void 0!==d[1]&&d[1],i=Object.keys(t),l=0;case 3:if(!(l<i.length)){u.next=19;break}if(a=Number(i[l]),c=this.getGridByIndex(a),o=t[a],c&&(r||c.CurrentLoadedRuleIndex===o.ruleIndex)){u.next=9;break}return u.abrupt("continue",16);case 9:return u.next=11,c.deleteAllAccOfGrid();case 11:return u.next=13,this.placeStashedAccessoiresInGrid(a,o.accessoires,r);case 13:if(u.sent){u.next=16;break}return u.next=16,this.initAccList(a);case 16:l++,u.next=3;break;case 19:case"end":return u.stop()}}),_callee4,this)}))),function placeStashedAccessoiresByGrid(t){return O.apply(this,arguments)})},{key:"placeStashedAccessoiresInGrid",value:(C=(0,l.Z)(h().mark((function _callee5(t,r){var i,l,a,c,o,d,u,b,k,A,x,C,O,I=arguments;return h().wrap((function _callee5$(h){for(;;)switch(h.prev=h.next){case 0:if(i=I.length>2&&void 0!==I[2]&&I[2],l=0,a=this.getGridByIndex(t)){h.next=5;break}return h.abrupt("return",l);case 5:c=0;case 6:if(!(c<r.length)){h.next=53;break}o=r[c],d=!1,u=_createForOfIteratorHelper(i?this.familyCandidates(a,o.articleCodex):[o.articleCodex]),h.prev=10,u.s();case 12:if((b=u.n()).done){h.next=23;break}return k=b.value,a.ActAccessoire=k,h.next=17,v.Z.addAccessorieOnShelfPlanner(this.article.set,t,o.cellIndex,this.article.basketId,{noMove:o.noMove,noDelete:o.noDelete,byInit:!0,onlyOfferedCells:i});case 17:if(d=h.sent,a.ActAccessoire=void 0,!isPlaced(d)){h.next=21;break}return h.abrupt("break",23);case 21:h.next=12;break;case 23:h.next=28;break;case 25:h.prev=25,h.t0=h.catch(10),u.e(h.t0);case 28:return h.prev=28,u.f(),h.finish(28);case 31:if(A=i?isPlaced(d)?d:void 0:!1===d||void 0===d.index?void 0:d,x=null==A?void 0:A.accessoire,!i||A&&x){h.next=36;break}return this.logShelfDebug({phase:"configChanged",action:"accessoryNotTransferred",gridIndex:t,cellIndex:o.cellIndex,articleCodex:o.articleCodex,detail:"no member of its family fits into this grid"}),h.abrupt("continue",50);case 36:if(A&&x){h.next=39;break}return y.error(new g.GE("shelfaccessoire of a switched off grid does not fit anymore and gets dropped",{code:"WC_0015",custom:{stashed:o,gridName:a.GridName,result:d,parentPosNr:this.article.posNr,parentArticleCodex:this.article.articleCodex,parentBasketId:this.article.basketId}})),h.abrupt("continue",50);case 39:if(x.quantity=o.quantity,l++,C=x.articleCodex!==o.articleCodex,i&&this.logShelfDebug({phase:"configChanged",action:"accessoryTransferred",gridIndex:t,cellIndex:o.cellIndex,articleCodex:x.articleCodex,detail:C?"as family member of ".concat(o.articleCodex):"same article"}),O=this.valuesToPlaceAgain(o,x),!Object.keys(O).length){h.next=47;break}return h.next=47,p.Z.updateCfgValues(x,O,{});case 47:if(!x.shelfPlanner){h.next=50;break}return h.next=50,x.shelfPlanner.placeStashedAccessoiresByGrid(o.accessoires,i||C);case 50:c++,h.next=6;break;case 53:return h.abrupt("return",l);case 54:case"end":return h.stop()}}),_callee5,this,[[10,25,28,31]])}))),function placeStashedAccessoiresInGrid(t,r){return C.apply(this,arguments)})},{key:"valuesToPlaceAgain",value:function valuesToPlaceAgain(t,r){var i,l=_objectSpread({},t.variantValues),a=Object.keys(t.inheritedValues).filter((function(t){return t in l}));if(!a.length)return l;var c,o=null!==(i=ShelfPlanner.addValuesPassedOnBy(this.article,this.valuesPassedOnByParents())[r.basketId])&&void 0!==i?i:{},d=_createForOfIteratorHelper(a);try{for(d.s();!(c=d.n()).done;){var u=c.value;void 0!==o[u]&&o[u]!==t.inheritedValues[u]&&delete l[u]}}catch(t){d.e(t)}finally{d.f()}return l}},{key:"initAccList",value:(x=(0,l.Z)(h().mark((function _callee6(t){var r,i,l,a,c,o,d,u,g,b,p,y,k,A,x,C,O,I,P,S;return h().wrap((function _callee6$(h){for(;;)switch(h.prev=h.next){case 0:r=this.activeGrids,i=0;case 2:if(!(i<r.length)){h.next=43;break}if(l=r[i],void 0===t||l.ShelfIndex===t){h.next=6;break}return h.abrupt("continue",40);case 6:if(l.InitAccArr){h.next=8;break}return h.abrupt("continue",40);case 8:a=new Map,c=0;case 10:if(!(c<l.InitAccArr.length)){h.next=40;break}g=l.InitAccArr[c],b=null!==(o=null===(d=this.article.CatalogData.allCatalogArticles[g.Codex])||void 0===d?void 0:d.accessoireFamily)&&void 0!==o?o:g.Codex,p=null!==(u=a.get(b))&&void 0!==u?u:this.countPlacedOfFamily(l,g.Codex),y=Math.min(p,g.initRH.length),a.set(b,p-y),k=y;case 17:if(!(k<g.initRH.length)){h.next=37;break}return l.ActAccessoire=g.Codex,this.logShelfDebug({phase:"initAccessories",action:"initAccessoryRequested",gridIndex:l.ShelfIndex,cellIndex:g.initRH[k],articleCodex:g.Codex,detail:"from InitAccArr — a missing matching accessoryPlaced entry right after means the init placement failed"}),h.next=22,v.Z.addAccessorieOnShelfPlanner(this.article.set,l.ShelfIndex,g.initRH[k],l.basketId,{noMove:g.noMove,noDelete:g.noDelete,byInit:!0});case 22:if(A=!v.Z.isDryRunArticle(this.article.accessoireParentArticle),!g.replaceFromParent||v.Z.isDryRunArticle(this.article)&&A){h.next=33;break}if(!(C=this.getShelfParentShelfId())||null===(x=this.article.accessoireParentArticle)||void 0===x||!x.shelfPlanner){h.next=33;break}if(!((O=this.article.accessoireParentArticle.shelfPlanner.getAccessorireByCodex(C,g.Codex))&&O.length>0)){h.next=33;break}if(P=O[0],void 0===(S=null===(I=P.shelfPlanner)||void 0===I?void 0:I.getRHOnParentArticle())||void 0===P.relatedToShelfGrid){h.next=33;break}return h.next=33,v.Z.deleteAccessorieOnShelfPlanner(this.article.set,P.relatedToShelfGrid,S,this.article.accessoireParentArticle.basketId);case 33:l.ActAccessoire=void 0;case 34:k++,h.next=17;break;case 37:c++,h.next=10;break;case 40:i++,h.next=2;break;case 43:case"end":return h.stop()}}),_callee6,this)}))),function initAccList(t){return x.apply(this,arguments)})},{key:"getAccessorireByCodex",value:function getAccessorireByCodex(t,r){var i=this.grids.find((function(r){return r.ShelfId==t})),l=[];if(i)for(var a in i.Accessoires)i.Accessoires[a].articleCodex==r&&l.push(i.Accessoires[a]);return l}},{key:"triggerVisibility",value:(A=(0,l.Z)(h().mark((function _callee7(t){var r,i,l,a,c,o,d;return h().wrap((function _callee7$(u){for(;;)switch(u.prev=u.next){case 0:r=[],i=[],l=0;case 3:if(!(l<this.grids.length)){u.next=13;break}if((a=this.grids[l]).VisitOption){u.next=7;break}return u.abrupt("continue",10);case 7:if(!i.includes(a.VisitOption)&&!r.includes(a.VisitOption)){u.next=9;break}return u.abrupt("continue",10);case 9:t&&(a.gridGroup==t||a.alternativeGridGroups.includes(t))?(i.push(a.VisitOption),r.includes(a.VisitOption)&&r.splice(r.indexOf(a.VisitOption),1)):r.push(a.VisitOption);case 10:l++,u.next=3;break;case 13:c=0;case 14:if(!(c<[].concat(i,r).length)){u.next=23;break}if(o=[].concat(i,r)[c],!(d=this.article.getArticleOptionState((this.article.CatalogData.isIDMFormat?"":"OPT")+o))){u.next=20;break}return u.next=20,p.Z.updateOption(this.article,d.optionCodex,i.includes(o)?"OPVMIT":"OPVOHNE");case 20:c++,u.next=14;break;case 23:case"end":return u.stop()}}),_callee7,this)}))),function triggerVisibility(t){return A.apply(this,arguments)})},{key:"deleteAllAcc",value:(k=(0,l.Z)(h().mark((function _callee8(){var t;return h().wrap((function _callee8$(r){for(;;)switch(r.prev=r.next){case 0:this.article.shelfPlanData=void 0,this.restorePending=!1,t=0;case 3:if(!(t<this.grids.length)){r.next=9;break}return r.next=6,this.grids[t].deleteAllAccOfGrid();case 6:t++,r.next=3;break;case 9:case"end":return r.stop()}}),_callee8,this)}))),function deleteAllAcc(){return k.apply(this,arguments)})},{key:"GridAllowedOnCells",get:function get(){return this.gridAllowedOnCells}},{key:"GridAllowedOntoArticles",get:function get(){return this.gridAllowedOntoArticles}},{key:"TakePlaceOnOtherGrids",get:function get(){return this.takePlaceOnOtherGrids}},{key:"tryFitOnShelfOfGrid",value:function tryFitOnShelfOfGrid(t,r,i){var l=i.shelfHeight,a=this.grids[t];if(!l||isNaN(l))return alert("Der artikel: "+i.name+" hat keine RH hinterlegt! Der Metatag 'HEIGHTGRIDUSED' ist: "+i.shelfHeight),!1;var c=!1,o=this.doesTakePlaceOnOtherGrids(i)?this.activeGrids:[a];if(a.checkAccessoireInGridRules(i))return{type:"notAllowedByMaxQuantityReached",size:l};for(var d=0;d<o.length;d++)if(!1===(c=o[d].tryFitOnShelf(i,r,i.shelfPlanner))||"doesNotFit"===c.type||c.type.startsWith("notAllowed")||void 0===c.index)return c;return c}},{key:"tryFitOnOfferedCellOfGrid",value:function tryFitOnOfferedCellOfGrid(t,r,i){var l=this.tryFitOnShelfOfGrid(t,r,i);return!1===l||void 0===l.index||"doesNotFit"===l.type||l.type.startsWith("notAllowed")||this.grids[t].getFreeSpacesOfAccessoire(i).includes(l.index)?l:{type:"doesNotFit",size:l.size}}},{key:"getFreeSpacesOfAccessoireOfGrids",value:function getFreeSpacesOfAccessoireOfGrids(t,r){for(var i=this.grids,l={},a=0;a<i.length;a++){var c=i[a];c.DisabledByRule||(l[c.GridName]={freeCells:c.getFreeSpacesOfAccessoire(r),idx:a})}return l}},{key:"getPlannedSpacesOfGrids",value:function getPlannedSpacesOfGrids(){for(var t=this.grids,r={},i=0;i<t.length;i++){var l=t[i];l.DisabledByRule||(r[l.GridName]={accessories:l.getPlannedSpaces(),idx:i})}return r}},{key:"deleteAccessoireOfCellInGrid",value:(u=(0,l.Z)(h().mark((function _callee9(t,r){var i,l,a,c,o,d;return h().wrap((function _callee9$(u){for(;;)switch(u.prev=u.next){case 0:if(i=this.grids[t],l=i.Cells[r].InUse,(c=i.Cells.find((function(t){return t.OnBoard==l})))?(a=c.InUse,c.Article):(a=r,o=i.Cells[r].Article),!o){u.next=8;break}return this.checkForNewFreeAccessoire(o,t),u.next=8,this.handleDeleteTakePlaceOnOtherGrids(t,a,o);case 8:return u.next=10,i.deleteAccessoireInCells(a);case 10:return(d=u.sent)&&this.logShelfDebug({phase:"placement",action:"accessoryDeleted",gridIndex:t,cellIndex:a,articleCodex:d.articleCodex,articleName:d.name}),u.abrupt("return",d);case 13:case"end":return u.stop()}}),_callee9,this)}))),function deleteAccessoireOfCellInGrid(t,r){return u.apply(this,arguments)})},{key:"checkForNewFreeAccessoire",value:function checkForNewFreeAccessoire(t,r){if(void 0!==this.freeArticlesPossible[t.articleCodex]&&t.noPrice){this.freeArticlesPlanned[t.articleCodex]-=t.quantity;var i=this.grids[r];for(var l in i.Accessoires)i.Accessoires[l].articleCodex!=t.articleCodex||i.Accessoires[l].noPrice||(i.Accessoires[l].noPrice=!0,this.freeArticlesPlanned[i.Accessoires[l].articleCodex]+=t.quantity)}}},{key:"handleDeleteTakePlaceOnOtherGrids",value:(i=(0,l.Z)(h().mark((function _callee10(t,r,i){var l,a,c,o,d,u,g;return h().wrap((function _callee10$(h){for(;;)switch(h.prev=h.next){case 0:if(i.shelfHeight){h.next=2;break}return h.abrupt("return");case 2:if(i.shelfHeightAbove)for(l=0;l<i.shelfHeightAbove;l++)(null==(c=this.grids[t].Cells[r+i.shelfHeight+l])||null===(a=c.Article)||void 0===a?void 0:a.basketId)===i.basketId&&c.ClearInUse();if(i.shelfHeightBelow)for(o=0;o<i.shelfHeightBelow;o++)(null==(u=this.grids[t].Cells[r-(o+1)])||null===(d=u.Article)||void 0===d?void 0:d.basketId)===i.basketId&&u.ClearInUse();if(!this.doesTakePlaceOnOtherGrids(i)){h.next=14;break}g=0;case 6:if(!(g<this.grids.length)){h.next=14;break}if(g!==t){h.next=9;break}return h.abrupt("continue",11);case 9:return h.next=11,this.grids[g].deleteAccessoireInCells(r);case 11:g++,h.next=6;break;case 14:case"end":return h.stop()}}),_callee10,this)}))),function handleDeleteTakePlaceOnOtherGrids(t,r,l){return i.apply(this,arguments)})},{key:"addAccessoireInCellInGrid",value:(r=(0,l.Z)(h().mark((function _callee11(t,r,i,l,a){var c,o,d;return h().wrap((function _callee11$(u){for(;;)switch(u.prev=u.next){case 0:c=this.doesTakePlaceOnOtherGrids(t)?this.activeGrids:[this.grids[r]],o=0;case 2:if(!(o<c.length)){u.next=13;break}if(!(d=c[o]).DisabledByRule){u.next=7;break}return this.logShelfDebug({phase:"placement",action:"placementSkippedGridDisabled",gridIndex:d.ShelfIndex,cellIndex:i,articleCodex:t.articleCodex}),u.abrupt("continue",10);case 7:return this.logShelfDebug({phase:"placement",action:"accessoryPlaced",gridIndex:d.ShelfIndex,cellIndex:i,articleCodex:t.articleCodex,articleName:t.name,detail:l+(d.ShelfIndex!==r?" (placeholder via TakePlaceOnOtherGrids)":"")}),u.next=10,c[o].addAccessoireInCells(i,t,l,d.ShelfIndex!==r||(null==a?void 0:a.noMove),d.ShelfIndex!==r||(null==a?void 0:a.noDelete),d.ShelfIndex!==r||void 0);case 10:o++,u.next=2;break;case 13:this.checkForFreeAccessoire(t);case 14:case"end":return u.stop()}}),_callee11,this)}))),function addAccessoireInCellInGrid(t,i,l,a,c){return r.apply(this,arguments)})},{key:"checkForFreeAccessoire",value:function checkForFreeAccessoire(t){void 0!==this.freeArticlesPossible[t.articleCodex]&&(void 0===this.freeArticlesPlanned[t.articleCodex]||this.freeArticlesPossible[t.articleCodex]>this.freeArticlesPlanned[t.articleCodex])&&(t.noPrice=!0,void 0===this.freeArticlesPlanned[t.articleCodex]&&(this.freeArticlesPlanned[t.articleCodex]=0),this.freeArticlesPlanned[t.articleCodex]+=t.quantity)}},{key:"doesTakePlaceOnOtherGrids",value:function doesTakePlaceOnOtherGrids(t){var r,i=null===(r=t.shelfPlanner)||void 0===r?void 0:r.takePlaceOnOtherGrids;if(i)for(var l=0;l<i.length;l++)if(i[l].onParent==this.article.articleCodex)return!0;return!1}},{key:"accessoires",get:function get(){for(var t={},r=this.activeGrids,i=0;i<r.length;i++)for(var l in r[i].Accessoires)t[l]=r[i].Accessoires[l];return Object.keys(t).length>0?t:void 0}},{key:"DisableCellsByElement",get:function get(){return this.disableCellsByElement}},{key:"getActAccessoireOfGrid",value:function getActAccessoireOfGrid(t){return this.grids[t].ActAccessoire}},{key:"setActAccessoireOfGrid",value:function setActAccessoireOfGrid(t,r){for(var i=!1,l=this.GridsOrGroupById(t),a=0;a<l.length;a++){var c=l[a];r&&c.getArticleRelationsById(t).includes(r)?c.ActAccessoire!==r&&(c.ActAccessoire=r,i=!0):c.ActAccessoire=void 0}return i}},{key:"generateShelfPlandata",value:function generateShelfPlandata(){for(var t,r=[],i=this.grids.filter((function(t){return!t.DisabledByRule||t.Cells.some((function(t){return t.InUse===t.Index&&t.Article}))})),l=0;l<i.length;l++){for(var a=[],c=i[l],o=0;o<c.Cells.length;o++){var d,u,h=c.Cells[o];if(a.push({inUse:h.InUse,noDelete:h.NoDelete,noMove:h.NoMove,onBoard:h.OnBoard}),c.ShelfIndex!=l&&(a[o].gridIndex=c.ShelfIndex),h.InUse==o)a[o].usedArticleData={Codex:null===(d=h.Article)||void 0===d?void 0:d.articleCodex,BasketID:null===(u=h.Article)||void 0===u?void 0:u.basketId}}r.push(a)}return{ShelfPlanner2:r,DoorPlannerData:null===(t=this.article.doorPlanner)||void 0===t?void 0:t.getMovedData(this.article.basketId)}}},{key:"getShelfPlannerAccessoires3DValues",value:function getShelfPlannerAccessoires3DValues(t){for(var r=this.activeGrids,i=0;i<r.length;i++)for(var l=r[i],a=0;a<l.Cells.length;a++){var c=l.Cells[a];if(c.InUse==a&&c.Article&&c.Article.model3DName&&!c.OnlyPlaceHolder){var o,d=c.Index;"vertikal"==l.Direction&&1!=this.article.CatalogData.useShelfPlannerRTV&&(d=l.Cells.length-1-c.Index),t.push({basketId:null===(o=c.Article)||void 0===o?void 0:o.basketId,gridId:l.ShelfIndex,gridName:l.GridName,model:c.Article.model3DName,parentBasketId:this.article.basketId,parentElementId:this.getShelfElementId(),rh:d}),c.Article.shelfPlanner&&(t=t.concat(c.Article.shelfPlanner.getShelfPlannerAccessoires3DValues([])))}}return t}},{key:"getShelfElementId",value:function getShelfElementId(){var t;if(null!==(t=this.article.accessoireParentArticle)&&void 0!==t&&t.shelfPlanner&&void 0!==this.article.relatedToShelfGrid&&this.grids.length>0){var r=this.getRHOnParentArticle();return this.article.accessoireParentArticle.shelfPlanner.getShelfElementId()+"."+this.article.relatedToShelfGrid+"."+r}return this.article.elementId.toString()}},{key:"getRHOnParentArticle",value:function getRHOnParentArticle(){var t,r=this;if(void 0!==this.article.relatedToShelfGrid)return null===(t=this.article.accessoireParentArticle)||void 0===t||null===(t=t.shelfPlanner)||void 0===t||null===(t=t.grids[this.article.relatedToShelfGrid].Cells.find((function(t){var i;return(null===(i=t.Article)||void 0===i?void 0:i.basketId)==r.article.basketId})))||void 0===t?void 0:t.InUse}},{key:"getShelfPlannerItems",value:function getShelfPlannerItems(t){for(var r=[],i=this.article.CatalogData,l=this.GridsOrGroupById(t),a=0;a<l.length;a++){var c=l[a].getArticleRelationsById(t);if(null!=c&&c.length)for(var o=function _loop(){var t=c[d];if(i.checkIfArticleCodexExists(t)){var l=i.getCatalogArticleByArticleCodex(t);if(!l||r.find((function(t){return t.articleCodex===l.articleCodex})))return 1;r.push({articleCodex:l.articleCodex,configStepKeys:[],image:l.image?i.getCatImageURL(l.image,""):void 0,name:l.name,longDescription:l.longDescription,price:i.dontShowBasePrice?0:Number(l.articlePrice),width:l.width,height:l.height,depth:l.depth,cellSize:l.shelfHeight,metaData:l.metaDataView,accessoireFamily:l.accessoireFamily,contentItemId:l.contentItemId,groupContentItemId:l.groupContentItemId,partlistcodexes:l.possiblePartlistCodexes})}},d=0;d<c.length;d++)o()}return{accessoires:r,grids:l}}},{key:"getShelfParentShelfId",value:function getShelfParentShelfId(){var t;if(void 0!==this.article.relatedToShelfGrid)return null===(t=this.article.accessoireParentArticle)||void 0===t||null===(t=t.shelfPlanner)||void 0===t||null===(t=t.grids[this.article.relatedToShelfGrid])||void 0===t?void 0:t.ShelfId}},{key:"updateOnDockingChanged",value:function updateOnDockingChanged(t){("AVL"==t&&"RH_OVER_AVL"==this.disableCellsByElement||"AVR"==t&&"RH_OVER_AVR"==this.disableCellsByElement)&&this.updateDisabledCells()}},{key:"updateDisabledCells",value:function updateDisabledCells(){this.updateDisabledCellsOnDockedElements(),this.checkOnDockedHeight()}},{key:"updateDisabledCellsOnDockedElements",value:function updateDisabledCellsOnDockedElements(){var t,r=this.activeGrids,i=this.article.dockedOnAV("L"),l=this.article.dockedOnAV("R");if("RH_OVER_AVR"==this.disableCellsByElement&&i)null===(t=i.shelfPlanner)||void 0===t||t.disableCellsByDockedShelfs(r[0].getCellCount("AVL"));else if("RH_OVER_AVL"==this.disableCellsByElement&&l){var a;null===(a=l.shelfPlanner)||void 0===a||a.disableCellsByDockedShelfs(r[0].getCellCount("AVR"))}}},{key:"checkOnDockedHeight",value:function checkOnDockedHeight(){var t=this.article.dockedOnAV("R"),r=this.article.dockedOnAV("L");null!=t&&t.shelfPlanner&&t.shelfPlanner.activeGrids.length>0&&"RH_OVER_AVR"==this.disableCellsByElement?this.disableCellsByDockedShelfs(t.shelfPlanner.activeGrids[0].getCellCount("AVL")):null!=r&&r.shelfPlanner&&r.shelfPlanner.activeGrids.length>0&&"RH_OVER_AVL"==this.disableCellsByElement?this.disableCellsByDockedShelfs(r.shelfPlanner.activeGrids[0].getCellCount("AVR")):this.disableCellsByDockedShelfs()}},{key:"disableCellsByDockedShelfs",value:(t=(0,l.Z)(h().mark((function _callee12(t){var r,i,l,a=this;return h().wrap((function _callee12$(c){for(;;)switch(c.prev=c.next){case 0:r=this.activeGrids,i=h().mark((function _loop2(){var i,c,o,d,u,g,b,p,y,k;return h().wrap((function _loop2$(h){for(;;)switch(h.prev=h.next){case 0:for(i=r[l],c=i.getCellCount(),o=i.getDisabledCellsByRule(),u=d=null==t||t>c?c:t;u<i.Cells.length;u++)o.push(u);g=o.filter((function(t){return i.Cells[t]&&!i.Cells[t].IsDisabled})),b=i.Cells.filter((function(t,r){return t.IsDisabled&&!o.includes(r)})).length,(g.length||b)&&a.logShelfDebug({phase:"docking",action:"disabledCellsUpdated",gridIndex:i.ShelfIndex,detail:"newlyDisabled=[".concat(g.slice(0,30).join(","),"] reEnabled=").concat(b," ")+"(sources: DisableCellsByRules/measures=".concat(i.getDisabledCellsByRule().length,", beyond cellCount/docking cap=").concat(i.Cells.length-d,"); ")+"an occupied cell that gets disabled deletes its accessory"}),p=0;case 9:if(!(p<o.length)){h.next=18;break}if((y=i.Cells[o[p]]).InUse!=o[p]){h.next=14;break}return h.next=14,v.Z.deleteAccessorieOnShelfPlanner(a.article.set,i.ShelfIndex,y.InUse,i.basketId);case 14:y.IsDisabled=!0;case 15:p++,h.next=9;break;case 18:k=0;case 19:if(!(k<i.Cells.length)){h.next=26;break}if(!o.includes(k)){h.next=22;break}return h.abrupt("continue",23);case 22:i.Cells[k].IsDisabled=!1;case 23:k++,h.next=19;break;case 26:case"end":return h.stop()}}),_loop2)})),l=0;case 3:if(!(l<r.length)){c.next=8;break}return c.delegateYield(i(),"t0",5);case 5:l++,c.next=3;break;case 8:case"end":return c.stop()}}),_callee12,this)}))),function disableCellsByDockedShelfs(r){return t.apply(this,arguments)})},{key:"getGridByGridName",value:function getGridByGridName(t){return this.grids.find((function(r){return r.GridName==t}))}},{key:"getGridByIndex",value:function getGridByIndex(t){return this.grids.find((function(r){return r.ShelfIndex==t}))}},{key:"GridsOrGroupById",value:function GridsOrGroupById(t){return this.activeGrids.filter((function(r){return r.ShelfId==t||r.group==t||r.alternativeGridGroups.includes(t)}))}},{key:"getSelectedAccessoireById",value:function getSelectedAccessoireById(t){var r;return null===(r=this.GridsOrGroupById(t).find((function(r){if(r.ActAccessoire&&r.getArticleRelationsById(t).includes(r.ActAccessoire))return r})))||void 0===r?void 0:r.ActAccessoire}},{key:"getCellIndexOfBasketId",value:function getCellIndexOfBasketId(t,r){var i;return null===(i=this.getGridByIndex(t))||void 0===i?void 0:i.getIndexOfBasketId(r)}},{key:"allGrids",get:function get(){return this.grids}},{key:"activeGrids",get:function get(){return this.grids.filter((function(t){return!t.DisabledByRule}))}},{key:"allMontageOptions",get:function get(){return this.montageOptions}},{key:"getRelatedToGridIdByArticleCodex",value:function getRelatedToGridIdByArticleCodex(t,r){var i=this.grids[r].getGridIdByArticleCodex(t);if(i)return i;for(var l=0;l<this.grids.length;l++){var a=this.grids[l].getGridIdByArticleCodex(t);if(a)return a}}}],[{key:"addValuesPassedOnBy",value:function addValuesPassedOnBy(t,r){for(var i={},l=0,a=Object.keys(t.getGlobalOptions());l<a.length;l++){var c,o=a[l],d=null===(c=t.getArticleOptionState(o))||void 0===c?void 0:c.valCodex;d&&(i[o]=d)}for(var u=_objectSpread({},r),h=t.getAccessoriesToChangeFromGlobalOption(i),g=0,v=Object.keys(h);g<v.length;g++){var b=v[g];u[b]=_objectSpread(_objectSpread({},u[b]),h[b].variantValues)}return u}}]);var t,r,i,u,k,A,x,C,O,I,P,S}()}}]);
|