@crystaldesign/diva-web-planner-react 26.13.0-beta.26 → 26.13.0-beta.27
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:(e,t,i)=>{i.r(t),i.d(t,{default:()=>v});var r=i(84658),s=i(61965),n=i(13125),l=i(43860),a=i(80248),c=i(50747),o=i.n(c),d=i(27058),h=i(79875),u=i(27896),f=i(69821);function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}var g=d.ZP.initLog("Planner","WEB-PLANNER-LOGIC"),v=function(){return(0,l.Z)((function ShelfPlanner(e,t){if((0,n.Z)(this,ShelfPlanner),(0,a.Z)(this,"article",void 0),(0,a.Z)(this,"grids",[]),(0,a.Z)(this,"isVisible",void 0),(0,a.Z)(this,"showOnRule",void 0),(0,a.Z)(this,"showAfterOPT",void 0),(0,a.Z)(this,"data",void 0),(0,a.Z)(this,"freeArticlesPossible",{}),(0,a.Z)(this,"freeArticlesPlanned",{}),(0,a.Z)(this,"gridAllowedOnCells",void 0),(0,a.Z)(this,"gridAllowedOntoArticles",void 0),(0,a.Z)(this,"takePlaceOnOtherGrids",void 0),(0,a.Z)(this,"disableCellsByElement",void 0),(0,a.Z)(this,"montageOptions",[]),(0,a.Z)(this,"restorePending",void 0),(0,a.Z)(this,"shelfDebugStack",[]),(0,a.Z)(this,"shelfDebugSeq",0),(0,a.Z)(this,"stashedAccessoires",{}),this.article=t,this.restorePending=!!t.shelfPlanData,this.disableCellsByElement=e.DisableCells,this.data=e,this.showAfterOPT=e.ShowAfterOPT,this.showOnRule=e.ShowOnRule?d.ZP.getRuleByFormula(e.ShowOnRule,t.catalogCodex,t.CatalogData.multiselectOptions):void 0,this.gridAllowedOnCells=e.GridAllowedOnCells,this.gridAllowedOntoArticles=e.GridAllowedOntoArticles,this.takePlaceOnOtherGrids=e.TakePlaceOnOtherGrids,this.initFreeArticles(),e.ShelfPlanner&&e.ShelfPlanner.length>0){for(var i=0;i<e.ShelfPlanner.length;i++)this.creatNewGrid(i),this.updateDisabledCells();this.montageOptions=(0,s.Z)(new Set(this.grids.reduce((function(e,t){return e=e.concat(t.montageOptionsList)}),[])))}}),[{key:"logShelfDebug",value:function logShelfDebug(e){this.shelfDebugStack.push(function _objectSpread(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(i),!0).forEach((function(t){(0,a.Z)(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({seq:this.shelfDebugSeq++},e)),this.shelfDebugStack.length>500&&this.shelfDebugStack.splice(0,this.shelfDebugStack.length-500)}},{key:"initFreeArticles",value:function initFreeArticles(){if(this.data.ShelfPlanner)for(var e=0;e<this.data.ShelfPlanner.length;e++){var t=this.data.ShelfPlanner[e];if(t.initAccArr)for(var i=0;i<t.initAccArr.length;i++){var r=t.initAccArr[i];r.noPrice&&(void 0===this.freeArticlesPossible[r.Codex]&&(this.freeArticlesPossible[r.Codex]=0),this.freeArticlesPossible[r.Codex]+=r.Quantity)}}}},{key:"canBeFree",value:function canBeFree(e){return void 0!==this.freeArticlesPossible[e]}},{key:"IsVisible",get:function get(){return this.isVisible}},{key:"RestorePending",get:function get(){return this.restorePending},set:function set(e){this.restorePending=e}},{key:"setIsVisible",value:(C=(0,r.Z)(o().mark((function _callee(e){return o().wrap((function _callee$(t){for(;;)switch(t.prev=t.next){case 0:if(this.isVisible==e){t.next=13;break}if(this.logShelfDebug({phase:"visibility",action:e?"plannerShown":"plannerHidden",detail:e?void 0:"showOnRule/visibility turned false — all placed accessories are deleted"}),!e){t.next=11;break}if(this.isVisible=e,this.article.shelfPlanData){t.next=9;break}return t.next=7,this.onConfigChanged({});case 7:return t.next=9,this.initAccList();case 9:t.next=13;break;case 11:return t.next=13,this.deleteAllAcc();case 13:this.isVisible=e;case 14:case"end":return t.stop()}}),_callee,this)}))),function setIsVisible(e){return C.apply(this,arguments)})},{key:"onConfigChanged",value:(y=(0,r.Z)(o().mark((function _callee2(e){var t,i,r,s,n,l,a,c,d,h,u,f,g;return o().wrap((function _callee2$(o){for(;;)switch(o.prev=o.next){case 0:for(t=!1,i=[],r=this.grids.map((function(e){return e.CurrentLoadedRuleIndex})),s=0;s<this.grids.length;s++)i.push(this.grids[s].onConfigChanged());n=0;case 5:if(!(n<i.length)){o.next=14;break}if(i[n].length){o.next=8;break}return o.abrupt("continue",11);case 8:l=this.grids[n],i[n].includes("disableGridRule")&&this.logShelfDebug({phase:"configChanged",action:l.DisabledByRule?"gridDisabledByRule":"gridEnabledByRule",gridIndex:l.ShelfIndex,detail:l.ShowOnRule}),i[n].includes("heightGridRule")&&this.logShelfDebug({phase:"configChanged",action:"gridRecreated",gridIndex:l.ShelfIndex,detail:"HeightGridCellCountOnRule match changed — grid rebuilt (cell count / placeable accessories can change), its accessories are deleted"});case 11:n++,o.next=5;break;case 14:a=0;case 15:if(!(a<i.length)){o.next=24;break}if(i[a].length){o.next=18;break}return o.abrupt("continue",21);case 18:return this.stashAccessoiresOfGrid(a,r[a]),o.next=21,this.grids[a].deleteAllAccOfGrid();case 21:a++,o.next=15;break;case 24:c=0;case 25:if(!(c<i.length)){o.next=41;break}if(i[c].length){o.next=28;break}return o.abrupt("continue",38);case 28:if(i[c].includes("heightGridRule")&&(this.creatNewGrid(c),t=!0),d=this.grids[c],!i[c].includes("heightGridRule")&&!i[c].includes("disableGridRule")||d.DisabledByRule){o.next=38;break}if(!this.restorePending){o.next=33;break}return o.abrupt("continue",38);case 33:return o.next=35,this.placeStashedAccessoiresOfGrid(c);case 35:if(o.sent){o.next=38;break}return o.next=38,this.initAccList(c);case 38:c++,o.next=25;break;case 41:if(t||!Object.keys(e).length){o.next=52;break}h=this.activeGrids,u=0;case 44:if(!(u<h.length)){o.next=52;break}if(g=h[u],!(null!==(f=g.DisableCellsByMeasures)&&void 0!==f&&f.options.find((function(t){return Object.keys(e).includes("OPT"+t.opt)}))||g.disableCellsByRules)){o.next=49;break}return t=!0,o.abrupt("break",52);case 49:u++,o.next=44;break;case 52:t&&this.updateDisabledCells();case 53:case"end":return o.stop()}}),_callee2,this)}))),function onConfigChanged(e){return y.apply(this,arguments)})},{key:"creatNewGrid",value:function creatNewGrid(e){this.grids[e]=new u.Z(e,this.article,this.data),this.grids[e].onConfigChanged()}},{key:"stashAccessoiresOfGrid",value:function stashAccessoiresOfGrid(e,t){var i=this.collectAccessoiresToStash(this.grids[e]);i.length&&(this.stashedAccessoires[this.stashKey(e,t)]=i)}},{key:"stashKey",value:function stashKey(e,t){return e+"#"+t}},{key:"collectAccessoiresToStash",value:function collectAccessoiresToStash(e){for(var t=[],i=0;i<e.Cells.length;i++){var r=e.Cells[i],s=r.Article;if(r.InUse===i&&s){for(var n={},l=s.shelfPlanner,a=0;a<(null!==(c=null==l?void 0:l.grids.length)&&void 0!==c?c:0);a++){var c,o=l.grids[a],d=l.collectAccessoiresToStash(o);d.length&&(n[o.ShelfIndex]={ruleIndex:o.CurrentLoadedRuleIndex,accessoires:d})}t.push({articleCodex:s.articleCodex,cellIndex:i,noMove:r.NoMove,noDelete:r.NoDelete,quantity:s.quantity,variantValues:s.VariantValues,accessoires:n})}}return t}},{key:"placeStashedAccessoiresOfGrid",value:(x=(0,r.Z)(o().mark((function _callee3(e){var t,i;return o().wrap((function _callee3$(r){for(;;)switch(r.prev=r.next){case 0:if(t=this.stashKey(e,this.grids[e].CurrentLoadedRuleIndex),null!=(i=this.stashedAccessoires[t])&&i.length){r.next=4;break}return r.abrupt("return",0);case 4:return delete this.stashedAccessoires[t],r.next=7,this.placeStashedAccessoiresInGrid(e,i);case 7:return r.abrupt("return",r.sent);case 8:case"end":return r.stop()}}),_callee3,this)}))),function placeStashedAccessoiresOfGrid(e){return x.apply(this,arguments)})},{key:"placeStashedAccessoiresByGrid",value:(A=(0,r.Z)(o().mark((function _callee4(e){var t,i,r,s,n;return o().wrap((function _callee4$(l){for(;;)switch(l.prev=l.next){case 0:t=Object.keys(e),i=0;case 2:if(!(i<t.length)){l.next=18;break}if(r=Number(t[i]),s=this.getGridByIndex(r),n=e[r],s&&s.CurrentLoadedRuleIndex===n.ruleIndex){l.next=8;break}return l.abrupt("continue",15);case 8:return l.next=10,s.deleteAllAccOfGrid();case 10:return l.next=12,this.placeStashedAccessoiresInGrid(r,n.accessoires);case 12:if(l.sent){l.next=15;break}return l.next=15,this.initAccList(r);case 15:i++,l.next=2;break;case 18:case"end":return l.stop()}}),_callee4,this)}))),function placeStashedAccessoiresByGrid(e){return A.apply(this,arguments)})},{key:"placeStashedAccessoiresInGrid",value:(p=(0,r.Z)(o().mark((function _callee5(e,t){var i,r,s,n,l,a,c;return o().wrap((function _callee5$(o){for(;;)switch(o.prev=o.next){case 0:if(i=0,r=this.getGridByIndex(e)){o.next=4;break}return o.abrupt("return",i);case 4:s=0;case 5:if(!(s<t.length)){o.next=28;break}return n=t[s],r.ActAccessoire=n.articleCodex,o.next=10,h.Z.addAccessorieOnShelfPlanner(this.article.set,e,n.cellIndex,this.article.basketId,{noMove:n.noMove,noDelete:n.noDelete,byInit:!0});case 10:if(l=o.sent,r.ActAccessoire=void 0,a=!1===l||void 0===l.index?void 0:l,c=null==a?void 0:a.accessoire,a&&c){o.next=17;break}return g.error(new d.GE("shelfaccessoire of a switched off grid does not fit anymore and gets dropped",{code:"WC_0015",custom:{stashed:n,gridName:r.GridName,result:l,parentPosNr:this.article.posNr,parentArticleCodex:this.article.articleCodex,parentBasketId:this.article.basketId}})),o.abrupt("continue",25);case 17:if(c.quantity=n.quantity,i++,!Object.keys(n.variantValues).length){o.next=22;break}return o.next=22,f.Z.updateCfgValues(c,n.variantValues,{});case 22:if(!c.shelfPlanner){o.next=25;break}return o.next=25,c.shelfPlanner.placeStashedAccessoiresByGrid(n.accessoires);case 25:s++,o.next=5;break;case 28:return o.abrupt("return",i);case 29:case"end":return o.stop()}}),_callee5,this)}))),function placeStashedAccessoiresInGrid(e,t){return p.apply(this,arguments)})},{key:"initAccList",value:(k=(0,r.Z)(o().mark((function _callee6(e){var t,i,r,s,n,l,a,c,d,u,f,g;return o().wrap((function _callee6$(o){for(;;)switch(o.prev=o.next){case 0:t=this.activeGrids,i=0;case 2:if(!(i<t.length)){o.next=37;break}if(r=t[i],void 0===e||r.ShelfIndex===e){o.next=6;break}return o.abrupt("continue",34);case 6:if(r.InitAccArr){o.next=8;break}return o.abrupt("continue",34);case 8:s=0;case 9:if(!(s<r.InitAccArr.length)){o.next=34;break}n=r.InitAccArr[s],l=0;case 12:if(!(l<n.initRH.length)){o.next=31;break}return r.ActAccessoire=n.Codex,this.logShelfDebug({phase:"initAccessories",action:"initAccessoryRequested",gridIndex:r.ShelfIndex,cellIndex:n.initRH[l],articleCodex:n.Codex,detail:"from InitAccArr — a missing matching accessoryPlaced entry right after means the init placement failed"}),o.next=17,h.Z.addAccessorieOnShelfPlanner(this.article.set,r.ShelfIndex,n.initRH[l],r.basketId,{noMove:n.noMove,noDelete:n.noDelete,byInit:!0});case 17:if(!n.replaceFromParent){o.next=27;break}if(!(c=this.getShelfParentShelfId())||null===(a=this.article.accessoireParentArticle)||void 0===a||!a.shelfPlanner){o.next=27;break}if(!((d=this.article.accessoireParentArticle.shelfPlanner.getAccessorireByCodex(c,n.Codex))&&d.length>0)){o.next=27;break}if(f=d[0],void 0===(g=null===(u=f.shelfPlanner)||void 0===u?void 0:u.getRHOnParentArticle())||void 0===f.relatedToShelfGrid){o.next=27;break}return o.next=27,h.Z.deleteAccessorieOnShelfPlanner(this.article.set,f.relatedToShelfGrid,g,this.article.accessoireParentArticle.basketId);case 27:r.ActAccessoire=void 0;case 28:l++,o.next=12;break;case 31:s++,o.next=9;break;case 34:i++,o.next=2;break;case 37:case"end":return o.stop()}}),_callee6,this)}))),function initAccList(e){return k.apply(this,arguments)})},{key:"getAccessorireByCodex",value:function getAccessorireByCodex(e,t){var i=this.grids.find((function(t){return t.ShelfId==e})),r=[];if(i)for(var s in i.Accessoires)i.Accessoires[s].articleCodex==t&&r.push(i.Accessoires[s]);return r}},{key:"triggerVisibility",value:(b=(0,r.Z)(o().mark((function _callee7(e){var t,i,r,s,n,l,a;return o().wrap((function _callee7$(c){for(;;)switch(c.prev=c.next){case 0:t=[],i=[],r=0;case 3:if(!(r<this.grids.length)){c.next=13;break}if((s=this.grids[r]).VisitOption){c.next=7;break}return c.abrupt("continue",10);case 7:if(!i.includes(s.VisitOption)&&!t.includes(s.VisitOption)){c.next=9;break}return c.abrupt("continue",10);case 9:e&&(s.gridGroup==e||s.alternativeGridGroups.includes(e))?(i.push(s.VisitOption),t.includes(s.VisitOption)&&t.splice(t.indexOf(s.VisitOption),1)):t.push(s.VisitOption);case 10:r++,c.next=3;break;case 13:n=0;case 14:if(!(n<[].concat(i,t).length)){c.next=23;break}if(l=[].concat(i,t)[n],!(a=this.article.getArticleOptionState((this.article.CatalogData.isIDMFormat?"":"OPT")+l))){c.next=20;break}return c.next=20,f.Z.updateOption(this.article,a.optionCodex,i.includes(l)?"OPVMIT":"OPVOHNE");case 20:n++,c.next=14;break;case 23:case"end":return c.stop()}}),_callee7,this)}))),function triggerVisibility(e){return b.apply(this,arguments)})},{key:"deleteAllAcc",value:(v=(0,r.Z)(o().mark((function _callee8(){var e;return o().wrap((function _callee8$(t){for(;;)switch(t.prev=t.next){case 0:this.article.shelfPlanData=void 0,this.restorePending=!1,e=0;case 3:if(!(e<this.grids.length)){t.next=9;break}return t.next=6,this.grids[e].deleteAllAccOfGrid();case 6:e++,t.next=3;break;case 9:case"end":return t.stop()}}),_callee8,this)}))),function deleteAllAcc(){return v.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(e,t,i){var r=i.shelfHeight,s=this.grids[e];if(!r||isNaN(r))return alert("Der artikel: "+i.name+" hat keine RH hinterlegt! Der Metatag 'HEIGHTGRIDUSED' ist: "+i.shelfHeight),!1;var n=!1,l=this.doesTakePlaceOnOtherGrids(i)?this.activeGrids:[s];if(s.checkAccessoireInGridRules(i))return{type:"notAllowedByMaxQuantityReached",size:r};for(var a=0;a<l.length;a++)if(!1===(n=l[a].tryFitOnShelf(i,t,i.shelfPlanner))||"doesNotFit"===n.type||n.type.startsWith("notAllowed")||void 0===n.index)return n;return n}},{key:"getFreeSpacesOfAccessoireOfGrids",value:function getFreeSpacesOfAccessoireOfGrids(e,t){for(var i=this.grids,r={},s=0;s<i.length;s++){var n=i[s];n.DisabledByRule||(r[n.GridName]={freeCells:n.getFreeSpacesOfAccessoire(t),idx:s})}return r}},{key:"getPlannedSpacesOfGrids",value:function getPlannedSpacesOfGrids(){for(var e=this.grids,t={},i=0;i<e.length;i++){var r=e[i];r.DisabledByRule||(t[r.GridName]={accessories:r.getPlannedSpaces(),idx:i})}return t}},{key:"deleteAccessoireOfCellInGrid",value:(c=(0,r.Z)(o().mark((function _callee9(e,t){var i,r,s,n,l,a;return o().wrap((function _callee9$(c){for(;;)switch(c.prev=c.next){case 0:if(i=this.grids[e],r=i.Cells[t].InUse,(n=i.Cells.find((function(e){return e.OnBoard==r})))?(s=n.InUse,n.Article):(s=t,l=i.Cells[t].Article),!l){c.next=8;break}return this.checkForNewFreeAccessoire(l,e),c.next=8,this.handleDeleteTakePlaceOnOtherGrids(e,s,l);case 8:return c.next=10,i.deleteAccessoireInCells(s);case 10:return(a=c.sent)&&this.logShelfDebug({phase:"placement",action:"accessoryDeleted",gridIndex:e,cellIndex:s,articleCodex:a.articleCodex,articleName:a.name}),c.abrupt("return",a);case 13:case"end":return c.stop()}}),_callee9,this)}))),function deleteAccessoireOfCellInGrid(e,t){return c.apply(this,arguments)})},{key:"checkForNewFreeAccessoire",value:function checkForNewFreeAccessoire(e,t){if(void 0!==this.freeArticlesPossible[e.articleCodex]&&e.noPrice){this.freeArticlesPlanned[e.articleCodex]-=e.quantity;var i=this.grids[t];for(var r in i.Accessoires)i.Accessoires[r].articleCodex!=e.articleCodex||i.Accessoires[r].noPrice||(i.Accessoires[r].noPrice=!0,this.freeArticlesPlanned[i.Accessoires[r].articleCodex]+=e.quantity)}}},{key:"handleDeleteTakePlaceOnOtherGrids",value:(i=(0,r.Z)(o().mark((function _callee10(e,t,i){var r,s,n,l,a,c,d;return o().wrap((function _callee10$(o){for(;;)switch(o.prev=o.next){case 0:if(i.shelfHeight){o.next=2;break}return o.abrupt("return");case 2:if(i.shelfHeightAbove)for(r=0;r<i.shelfHeightAbove;r++)(null==(n=this.grids[e].Cells[t+i.shelfHeight+r])||null===(s=n.Article)||void 0===s?void 0:s.basketId)===i.basketId&&n.ClearInUse();if(i.shelfHeightBelow)for(l=0;l<i.shelfHeightBelow;l++)(null==(c=this.grids[e].Cells[t-(l+1)])||null===(a=c.Article)||void 0===a?void 0:a.basketId)===i.basketId&&c.ClearInUse();if(!this.doesTakePlaceOnOtherGrids(i)){o.next=14;break}d=0;case 6:if(!(d<this.grids.length)){o.next=14;break}if(d!==e){o.next=9;break}return o.abrupt("continue",11);case 9:return o.next=11,this.grids[d].deleteAccessoireInCells(t);case 11:d++,o.next=6;break;case 14:case"end":return o.stop()}}),_callee10,this)}))),function handleDeleteTakePlaceOnOtherGrids(e,t,r){return i.apply(this,arguments)})},{key:"addAccessoireInCellInGrid",value:(t=(0,r.Z)(o().mark((function _callee11(e,t,i,r,s){var n,l,a;return o().wrap((function _callee11$(c){for(;;)switch(c.prev=c.next){case 0:n=this.doesTakePlaceOnOtherGrids(e)?this.activeGrids:[this.grids[t]],l=0;case 2:if(!(l<n.length)){c.next=13;break}if(!(a=n[l]).DisabledByRule){c.next=7;break}return this.logShelfDebug({phase:"placement",action:"placementSkippedGridDisabled",gridIndex:a.ShelfIndex,cellIndex:i,articleCodex:e.articleCodex}),c.abrupt("continue",10);case 7:return this.logShelfDebug({phase:"placement",action:"accessoryPlaced",gridIndex:a.ShelfIndex,cellIndex:i,articleCodex:e.articleCodex,articleName:e.name,detail:r+(a.ShelfIndex!==t?" (placeholder via TakePlaceOnOtherGrids)":"")}),c.next=10,n[l].addAccessoireInCells(i,e,r,a.ShelfIndex!==t||(null==s?void 0:s.noMove),a.ShelfIndex!==t||(null==s?void 0:s.noDelete),a.ShelfIndex!==t||void 0);case 10:l++,c.next=2;break;case 13:this.checkForFreeAccessoire(e);case 14:case"end":return c.stop()}}),_callee11,this)}))),function addAccessoireInCellInGrid(e,i,r,s,n){return t.apply(this,arguments)})},{key:"checkForFreeAccessoire",value:function checkForFreeAccessoire(e){void 0!==this.freeArticlesPossible[e.articleCodex]&&(void 0===this.freeArticlesPlanned[e.articleCodex]||this.freeArticlesPossible[e.articleCodex]>this.freeArticlesPlanned[e.articleCodex])&&(e.noPrice=!0,void 0===this.freeArticlesPlanned[e.articleCodex]&&(this.freeArticlesPlanned[e.articleCodex]=0),this.freeArticlesPlanned[e.articleCodex]+=e.quantity)}},{key:"doesTakePlaceOnOtherGrids",value:function doesTakePlaceOnOtherGrids(e){var t,i=null===(t=e.shelfPlanner)||void 0===t?void 0:t.takePlaceOnOtherGrids;if(i)for(var r=0;r<i.length;r++)if(i[r].onParent==this.article.articleCodex)return!0;return!1}},{key:"accessoires",get:function get(){for(var e={},t=this.activeGrids,i=0;i<t.length;i++)for(var r in t[i].Accessoires)e[r]=t[i].Accessoires[r];return Object.keys(e).length>0?e:void 0}},{key:"DisableCellsByElement",get:function get(){return this.disableCellsByElement}},{key:"getActAccessoireOfGrid",value:function getActAccessoireOfGrid(e){return this.grids[e].ActAccessoire}},{key:"setActAccessoireOfGrid",value:function setActAccessoireOfGrid(e,t){for(var i=!1,r=this.GridsOrGroupById(e),s=0;s<r.length;s++){var n=r[s];t&&n.getArticleRelationsById(e).includes(t)?n.ActAccessoire!==t&&(n.ActAccessoire=t,i=!0):n.ActAccessoire=void 0}return i}},{key:"generateShelfPlandata",value:function generateShelfPlandata(){for(var e,t=[],i=this.grids.filter((function(e){return!e.DisabledByRule||e.Cells.some((function(e){return e.InUse===e.Index&&e.Article}))})),r=0;r<i.length;r++){for(var s=[],n=i[r],l=0;l<n.Cells.length;l++){var a,c,o=n.Cells[l];if(s.push({inUse:o.InUse,noDelete:o.NoDelete,noMove:o.NoMove,onBoard:o.OnBoard}),n.ShelfIndex!=r&&(s[l].gridIndex=n.ShelfIndex),o.InUse==l)s[l].usedArticleData={Codex:null===(a=o.Article)||void 0===a?void 0:a.articleCodex,BasketID:null===(c=o.Article)||void 0===c?void 0:c.basketId}}t.push(s)}return{ShelfPlanner2:t,DoorPlannerData:null===(e=this.article.doorPlanner)||void 0===e?void 0:e.getMovedData(this.article.basketId)}}},{key:"getShelfPlannerAccessoires3DValues",value:function getShelfPlannerAccessoires3DValues(e){for(var t=this.activeGrids,i=0;i<t.length;i++)for(var r=t[i],s=0;s<r.Cells.length;s++){var n=r.Cells[s];if(n.InUse==s&&n.Article&&n.Article.model3DName&&!n.OnlyPlaceHolder){var l,a=n.Index;"vertikal"==r.Direction&&1!=this.article.CatalogData.useShelfPlannerRTV&&(a=r.Cells.length-1-n.Index),e.push({basketId:null===(l=n.Article)||void 0===l?void 0:l.basketId,gridId:r.ShelfIndex,gridName:r.GridName,model:n.Article.model3DName,parentBasketId:this.article.basketId,parentElementId:this.getShelfElementId(),rh:a}),n.Article.shelfPlanner&&(e=e.concat(n.Article.shelfPlanner.getShelfPlannerAccessoires3DValues([])))}}return e}},{key:"getShelfElementId",value:function getShelfElementId(){var e;if(null!==(e=this.article.accessoireParentArticle)&&void 0!==e&&e.shelfPlanner&&void 0!==this.article.relatedToShelfGrid&&this.grids.length>0){var t=this.getRHOnParentArticle();return this.article.accessoireParentArticle.shelfPlanner.getShelfElementId()+"."+this.article.relatedToShelfGrid+"."+t}return this.article.elementId.toString()}},{key:"getRHOnParentArticle",value:function getRHOnParentArticle(){var e,t=this;if(void 0!==this.article.relatedToShelfGrid)return null===(e=this.article.accessoireParentArticle)||void 0===e||null===(e=e.shelfPlanner)||void 0===e||null===(e=e.grids[this.article.relatedToShelfGrid].Cells.find((function(e){var i;return(null===(i=e.Article)||void 0===i?void 0:i.basketId)==t.article.basketId})))||void 0===e?void 0:e.InUse}},{key:"getShelfPlannerItems",value:function getShelfPlannerItems(e){for(var t=[],i=this.article.CatalogData,r=this.GridsOrGroupById(e),s=0;s<r.length;s++){var n=r[s].getArticleRelationsById(e);if(null!=n&&n.length)for(var l=function _loop(){var e=n[a];if(i.checkIfArticleCodexExists(e)){var r=i.getCatalogArticleByArticleCodex(e);if(!r||t.find((function(e){return e.articleCodex===r.articleCodex})))return 1;t.push({articleCodex:r.articleCodex,configStepKeys:[],image:r.image?i.getCatImageURL(r.image,""):void 0,name:r.name,longDescription:r.longDescription,price:i.dontShowBasePrice?0:Number(r.articlePrice),width:r.width,height:r.height,depth:r.depth,cellSize:r.shelfHeight,metaData:r.metaDataView,accessoireFamily:r.accessoireFamily,contentItemId:r.contentItemId,groupContentItemId:r.groupContentItemId,partlistcodexes:r.possiblePartlistCodexes})}},a=0;a<n.length;a++)l()}return{accessoires:t,grids:r}}},{key:"getShelfParentShelfId",value:function getShelfParentShelfId(){var e;if(void 0!==this.article.relatedToShelfGrid)return null===(e=this.article.accessoireParentArticle)||void 0===e||null===(e=e.shelfPlanner)||void 0===e||null===(e=e.grids[this.article.relatedToShelfGrid])||void 0===e?void 0:e.ShelfId}},{key:"updateOnDockingChanged",value:function updateOnDockingChanged(e){("AVL"==e&&"RH_OVER_AVL"==this.disableCellsByElement||"AVR"==e&&"RH_OVER_AVR"==this.disableCellsByElement)&&this.updateDisabledCells()}},{key:"updateDisabledCells",value:function updateDisabledCells(){this.updateDisabledCellsOnDockedElements(),this.checkOnDockedHeight()}},{key:"updateDisabledCellsOnDockedElements",value:function updateDisabledCellsOnDockedElements(){var e,t=this.activeGrids,i=this.article.dockedOnAV("L"),r=this.article.dockedOnAV("R");if("RH_OVER_AVR"==this.disableCellsByElement&&i)null===(e=i.shelfPlanner)||void 0===e||e.disableCellsByDockedShelfs(t[0].getCellCount("AVL"));else if("RH_OVER_AVL"==this.disableCellsByElement&&r){var s;null===(s=r.shelfPlanner)||void 0===s||s.disableCellsByDockedShelfs(t[0].getCellCount("AVR"))}}},{key:"checkOnDockedHeight",value:function checkOnDockedHeight(){var e=this.article.dockedOnAV("R"),t=this.article.dockedOnAV("L");null!=e&&e.shelfPlanner&&e.shelfPlanner.activeGrids.length>0&&"RH_OVER_AVR"==this.disableCellsByElement?this.disableCellsByDockedShelfs(e.shelfPlanner.activeGrids[0].getCellCount("AVL")):null!=t&&t.shelfPlanner&&t.shelfPlanner.activeGrids.length>0&&"RH_OVER_AVL"==this.disableCellsByElement?this.disableCellsByDockedShelfs(t.shelfPlanner.activeGrids[0].getCellCount("AVR")):this.disableCellsByDockedShelfs()}},{key:"disableCellsByDockedShelfs",value:(e=(0,r.Z)(o().mark((function _callee12(e){var t,i,r,s=this;return o().wrap((function _callee12$(n){for(;;)switch(n.prev=n.next){case 0:t=this.activeGrids,i=o().mark((function _loop2(){var i,n,l,a,c,d,u,f,g,v;return o().wrap((function _loop2$(o){for(;;)switch(o.prev=o.next){case 0:for(i=t[r],n=i.getCellCount(),l=i.getDisabledCellsByRule(),c=a=null==e||e>n?n:e;c<i.Cells.length;c++)l.push(c);d=l.filter((function(e){return i.Cells[e]&&!i.Cells[e].IsDisabled})),u=i.Cells.filter((function(e,t){return e.IsDisabled&&!l.includes(t)})).length,(d.length||u)&&s.logShelfDebug({phase:"docking",action:"disabledCellsUpdated",gridIndex:i.ShelfIndex,detail:"newlyDisabled=[".concat(d.slice(0,30).join(","),"] reEnabled=").concat(u," ")+"(sources: DisableCellsByRules/measures=".concat(i.getDisabledCellsByRule().length,", beyond cellCount/docking cap=").concat(i.Cells.length-a,"); ")+"an occupied cell that gets disabled deletes its accessory"}),f=0;case 9:if(!(f<l.length)){o.next=18;break}if((g=i.Cells[l[f]]).InUse!=l[f]){o.next=14;break}return o.next=14,h.Z.deleteAccessorieOnShelfPlanner(s.article.set,i.ShelfIndex,g.InUse,i.basketId);case 14:g.IsDisabled=!0;case 15:f++,o.next=9;break;case 18:v=0;case 19:if(!(v<i.Cells.length)){o.next=26;break}if(!l.includes(v)){o.next=22;break}return o.abrupt("continue",23);case 22:i.Cells[v].IsDisabled=!1;case 23:v++,o.next=19;break;case 26:case"end":return o.stop()}}),_loop2)})),r=0;case 3:if(!(r<t.length)){n.next=8;break}return n.delegateYield(i(),"t0",5);case 5:r++,n.next=3;break;case 8:case"end":return n.stop()}}),_callee12,this)}))),function disableCellsByDockedShelfs(t){return e.apply(this,arguments)})},{key:"getGridByGridName",value:function getGridByGridName(e){return this.grids.find((function(t){return t.GridName==e}))}},{key:"getGridByIndex",value:function getGridByIndex(e){return this.grids.find((function(t){return t.ShelfIndex==e}))}},{key:"GridsOrGroupById",value:function GridsOrGroupById(e){return this.activeGrids.filter((function(t){return t.ShelfId==e||t.group==e||t.alternativeGridGroups.includes(e)}))}},{key:"getSelectedAccessoireById",value:function getSelectedAccessoireById(e){var t;return null===(t=this.GridsOrGroupById(e).find((function(t){if(t.ActAccessoire&&t.getArticleRelationsById(e).includes(t.ActAccessoire))return t})))||void 0===t?void 0:t.ActAccessoire}},{key:"getCellIndexOfBasketId",value:function getCellIndexOfBasketId(e,t){var i;return null===(i=this.getGridByIndex(e))||void 0===i?void 0:i.getIndexOfBasketId(t)}},{key:"allGrids",get:function get(){return this.grids}},{key:"activeGrids",get:function get(){return this.grids.filter((function(e){return!e.DisabledByRule}))}},{key:"allMontageOptions",get:function get(){return this.montageOptions}},{key:"getRelatedToGridIdByArticleCodex",value:function getRelatedToGridIdByArticleCodex(e,t){var i=this.grids[t].getGridIdByArticleCodex(e);if(i)return i;for(var r=0;r<this.grids.length;r++){var s=this.grids[r].getGridIdByArticleCodex(e);if(s)return s}}}]);var e,t,i,c,v,b,k,p,A,x,y,C}()}}]);
|
|
2
|
+
"use strict";(self.webpackChunkCrystaldesignDivaWebPlannerReact=self.webpackChunkCrystaldesignDivaWebPlannerReact||[]).push([[3596],{33596:(t,r,i)=>{i.r(r),i.d(r,{default:()=>A});var l=i(84658),a=i(61965),c=i(13125),o=i(43860),d=i(80248),h=i(50747),u=i.n(h),g=i(27058),v=i(79875),b=i(27896),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 k=g.ZP.initLog("Planner","WEB-PLANNER-LOGIC"),A=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",{}),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)(u().mark((function _callee(t){return u().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)(u().mark((function _callee2(t){var r,i,l,a,c,o,d,h,g,v,b,p,k;return u().wrap((function _callee2$(u){for(;;)switch(u.prev=u.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)){u.next=14;break}if(i[c].length){u.next=8;break}return u.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++,u.next=5;break;case 14:d=0;case 15:if(!(d<i.length)){u.next=24;break}if(i[d].length){u.next=18;break}return u.abrupt("continue",21);case 18:return this.stashAccessoiresOfGrid(d,l[d]),u.next=21,this.grids[d].deleteAllAccOfGrid();case 21:d++,u.next=15;break;case 24:h=0;case 25:if(!(h<i.length)){u.next=41;break}if(i[h].length){u.next=28;break}return u.abrupt("continue",38);case 28:if(i[h].includes("heightGridRule")&&(this.creatNewGrid(h),r=!0),g=this.grids[h],!i[h].includes("heightGridRule")&&!i[h].includes("disableGridRule")||g.DisabledByRule){u.next=38;break}if(!this.restorePending){u.next=33;break}return u.abrupt("continue",38);case 33:return u.next=35,this.placeStashedAccessoiresOfGrid(h);case 35:if(u.sent){u.next=38;break}return u.next=38,this.initAccList(h);case 38:h++,u.next=25;break;case 41:if(r||!Object.keys(t).length){u.next=52;break}v=this.activeGrids,b=0;case 44:if(!(b<v.length)){u.next=52;break}if(k=v[b],!(null!==(p=k.DisableCellsByMeasures)&&void 0!==p&&p.options.find((function(r){return Object.keys(t).includes("OPT"+r.opt)}))||k.disableCellsByRules)){u.next=49;break}return r=!0,u.abrupt("break",52);case 49:b++,u.next=44;break;case 52:r&&this.updateDisabledCells();case 53:case"end":return u.stop()}}),_callee2,this)}))),function onConfigChanged(t){return P.apply(this,arguments)})},{key:"creatNewGrid",value:function creatNewGrid(t){this.grids[t]=new b.Z(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());i.length&&(this.stashedAccessoires[this.stashKey(t,r)]=i)}},{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=t.Cells[a],d=o.Article;if(o.InUse===a&&d){for(var h={},u=d.shelfPlanner,g=0;g<(null!==(v=null==u?void 0:u.grids.length)&&void 0!==v?v:0);g++){var v,b=u.grids[g],p=u.collectAccessoiresToStash(b,l);p.length&&(h[b.ShelfIndex]={ruleIndex:b.CurrentLoadedRuleIndex,accessoires:p})}for(var k=d.VariantValues,A=null!==(c=l[d.basketId])&&void 0!==c?c:{},y=0,x=Object.keys(A);y<x.length;y++){var O=x[y];k[O]===A[O]&&delete k[O]}i.push({articleCodex:d.articleCodex,cellIndex:a,noMove:o.NoMove,noDelete:o.NoDelete,quantity:d.quantity,variantValues:k,inheritedValues:A,accessoires:h})}}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:"placeStashedAccessoiresOfGrid",value:(I=(0,l.Z)(u().mark((function _callee3(t){var r,i;return u().wrap((function _callee3$(l){for(;;)switch(l.prev=l.next){case 0:if(r=this.stashKey(t,this.grids[t].CurrentLoadedRuleIndex),null!=(i=this.stashedAccessoires[r])&&i.length){l.next=4;break}return l.abrupt("return",0);case 4:return delete this.stashedAccessoires[r],l.next=7,this.placeStashedAccessoiresInGrid(t,i);case 7:return l.abrupt("return",l.sent);case 8:case"end":return l.stop()}}),_callee3,this)}))),function placeStashedAccessoiresOfGrid(t){return I.apply(this,arguments)})},{key:"placeStashedAccessoiresByGrid",value:(C=(0,l.Z)(u().mark((function _callee4(t){var r,i,l,a,c;return u().wrap((function _callee4$(o){for(;;)switch(o.prev=o.next){case 0:r=Object.keys(t),i=0;case 2:if(!(i<r.length)){o.next=18;break}if(l=Number(r[i]),a=this.getGridByIndex(l),c=t[l],a&&a.CurrentLoadedRuleIndex===c.ruleIndex){o.next=8;break}return o.abrupt("continue",15);case 8:return o.next=10,a.deleteAllAccOfGrid();case 10:return o.next=12,this.placeStashedAccessoiresInGrid(l,c.accessoires);case 12:if(o.sent){o.next=15;break}return o.next=15,this.initAccList(l);case 15:i++,o.next=2;break;case 18:case"end":return o.stop()}}),_callee4,this)}))),function placeStashedAccessoiresByGrid(t){return C.apply(this,arguments)})},{key:"placeStashedAccessoiresInGrid",value:(O=(0,l.Z)(u().mark((function _callee5(t,r){var i,l,a,c,o,d,h,b;return u().wrap((function _callee5$(u){for(;;)switch(u.prev=u.next){case 0:if(i=0,l=this.getGridByIndex(t)){u.next=4;break}return u.abrupt("return",i);case 4:a=0;case 5:if(!(a<r.length)){u.next=29;break}return c=r[a],l.ActAccessoire=c.articleCodex,u.next=10,v.Z.addAccessorieOnShelfPlanner(this.article.set,t,c.cellIndex,this.article.basketId,{noMove:c.noMove,noDelete:c.noDelete,byInit:!0});case 10:if(o=u.sent,l.ActAccessoire=void 0,d=!1===o||void 0===o.index?void 0:o,h=null==d?void 0:d.accessoire,d&&h){u.next=17;break}return k.error(new g.GE("shelfaccessoire of a switched off grid does not fit anymore and gets dropped",{code:"WC_0015",custom:{stashed:c,gridName:l.GridName,result:o,parentPosNr:this.article.posNr,parentArticleCodex:this.article.articleCodex,parentBasketId:this.article.basketId}})),u.abrupt("continue",26);case 17:if(h.quantity=c.quantity,i++,b=this.valuesToPlaceAgain(c,h),!Object.keys(b).length){u.next=23;break}return u.next=23,p.Z.updateCfgValues(h,b,{});case 23:if(!h.shelfPlanner){u.next=26;break}return u.next=26,h.shelfPlanner.placeStashedAccessoiresByGrid(c.accessoires);case 26:a++,u.next=5;break;case 29:return u.abrupt("return",i);case 30:case"end":return u.stop()}}),_callee5,this)}))),function placeStashedAccessoiresInGrid(t,r){return O.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 h=c.value;void 0!==o[h]&&o[h]!==t.inheritedValues[h]&&delete l[h]}}catch(t){d.e(t)}finally{d.f()}return l}},{key:"initAccList",value:(x=(0,l.Z)(u().mark((function _callee6(t){var r,i,l,a,c,o,d,h,g,b,p,k;return u().wrap((function _callee6$(u){for(;;)switch(u.prev=u.next){case 0:r=this.activeGrids,i=0;case 2:if(!(i<r.length)){u.next=37;break}if(l=r[i],void 0===t||l.ShelfIndex===t){u.next=6;break}return u.abrupt("continue",34);case 6:if(l.InitAccArr){u.next=8;break}return u.abrupt("continue",34);case 8:a=0;case 9:if(!(a<l.InitAccArr.length)){u.next=34;break}c=l.InitAccArr[a],o=0;case 12:if(!(o<c.initRH.length)){u.next=31;break}return l.ActAccessoire=c.Codex,this.logShelfDebug({phase:"initAccessories",action:"initAccessoryRequested",gridIndex:l.ShelfIndex,cellIndex:c.initRH[o],articleCodex:c.Codex,detail:"from InitAccArr — a missing matching accessoryPlaced entry right after means the init placement failed"}),u.next=17,v.Z.addAccessorieOnShelfPlanner(this.article.set,l.ShelfIndex,c.initRH[o],l.basketId,{noMove:c.noMove,noDelete:c.noDelete,byInit:!0});case 17:if(!c.replaceFromParent){u.next=27;break}if(!(h=this.getShelfParentShelfId())||null===(d=this.article.accessoireParentArticle)||void 0===d||!d.shelfPlanner){u.next=27;break}if(!((g=this.article.accessoireParentArticle.shelfPlanner.getAccessorireByCodex(h,c.Codex))&&g.length>0)){u.next=27;break}if(p=g[0],void 0===(k=null===(b=p.shelfPlanner)||void 0===b?void 0:b.getRHOnParentArticle())||void 0===p.relatedToShelfGrid){u.next=27;break}return u.next=27,v.Z.deleteAccessorieOnShelfPlanner(this.article.set,p.relatedToShelfGrid,k,this.article.accessoireParentArticle.basketId);case 27:l.ActAccessoire=void 0;case 28:o++,u.next=12;break;case 31:a++,u.next=9;break;case 34:i++,u.next=2;break;case 37:case"end":return u.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:(y=(0,l.Z)(u().mark((function _callee7(t){var r,i,l,a,c,o,d;return u().wrap((function _callee7$(h){for(;;)switch(h.prev=h.next){case 0:r=[],i=[],l=0;case 3:if(!(l<this.grids.length)){h.next=13;break}if((a=this.grids[l]).VisitOption){h.next=7;break}return h.abrupt("continue",10);case 7:if(!i.includes(a.VisitOption)&&!r.includes(a.VisitOption)){h.next=9;break}return h.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++,h.next=3;break;case 13:c=0;case 14:if(!(c<[].concat(i,r).length)){h.next=23;break}if(o=[].concat(i,r)[c],!(d=this.article.getArticleOptionState((this.article.CatalogData.isIDMFormat?"":"OPT")+o))){h.next=20;break}return h.next=20,p.Z.updateOption(this.article,d.optionCodex,i.includes(o)?"OPVMIT":"OPVOHNE");case 20:c++,h.next=14;break;case 23:case"end":return h.stop()}}),_callee7,this)}))),function triggerVisibility(t){return y.apply(this,arguments)})},{key:"deleteAllAcc",value:(A=(0,l.Z)(u().mark((function _callee8(){var t;return u().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 A.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:"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:(h=(0,l.Z)(u().mark((function _callee9(t,r){var i,l,a,c,o,d;return u().wrap((function _callee9$(h){for(;;)switch(h.prev=h.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){h.next=8;break}return this.checkForNewFreeAccessoire(o,t),h.next=8,this.handleDeleteTakePlaceOnOtherGrids(t,a,o);case 8:return h.next=10,i.deleteAccessoireInCells(a);case 10:return(d=h.sent)&&this.logShelfDebug({phase:"placement",action:"accessoryDeleted",gridIndex:t,cellIndex:a,articleCodex:d.articleCodex,articleName:d.name}),h.abrupt("return",d);case 13:case"end":return h.stop()}}),_callee9,this)}))),function deleteAccessoireOfCellInGrid(t,r){return h.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)(u().mark((function _callee10(t,r,i){var l,a,c,o,d,h,g;return u().wrap((function _callee10$(u){for(;;)switch(u.prev=u.next){case 0:if(i.shelfHeight){u.next=2;break}return u.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==(h=this.grids[t].Cells[r-(o+1)])||null===(d=h.Article)||void 0===d?void 0:d.basketId)===i.basketId&&h.ClearInUse();if(!this.doesTakePlaceOnOtherGrids(i)){u.next=14;break}g=0;case 6:if(!(g<this.grids.length)){u.next=14;break}if(g!==t){u.next=9;break}return u.abrupt("continue",11);case 9:return u.next=11,this.grids[g].deleteAccessoireInCells(r);case 11:g++,u.next=6;break;case 14:case"end":return u.stop()}}),_callee10,this)}))),function handleDeleteTakePlaceOnOtherGrids(t,r,l){return i.apply(this,arguments)})},{key:"addAccessoireInCellInGrid",value:(r=(0,l.Z)(u().mark((function _callee11(t,r,i,l,a){var c,o,d;return u().wrap((function _callee11$(h){for(;;)switch(h.prev=h.next){case 0:c=this.doesTakePlaceOnOtherGrids(t)?this.activeGrids:[this.grids[r]],o=0;case 2:if(!(o<c.length)){h.next=13;break}if(!(d=c[o]).DisabledByRule){h.next=7;break}return this.logShelfDebug({phase:"placement",action:"placementSkippedGridDisabled",gridIndex:d.ShelfIndex,cellIndex:i,articleCodex:t.articleCodex}),h.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)":"")}),h.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++,h.next=2;break;case 13:this.checkForFreeAccessoire(t);case 14:case"end":return h.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,h,u=c.Cells[o];if(a.push({inUse:u.InUse,noDelete:u.NoDelete,noMove:u.NoMove,onBoard:u.OnBoard}),c.ShelfIndex!=l&&(a[o].gridIndex=c.ShelfIndex),u.InUse==o)a[o].usedArticleData={Codex:null===(d=u.Article)||void 0===d?void 0:d.articleCodex,BasketID:null===(h=u.Article)||void 0===h?void 0:h.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)(u().mark((function _callee12(t){var r,i,l,a=this;return u().wrap((function _callee12$(c){for(;;)switch(c.prev=c.next){case 0:r=this.activeGrids,i=u().mark((function _loop2(){var i,c,o,d,h,g,b,p,k,A;return u().wrap((function _loop2$(u){for(;;)switch(u.prev=u.next){case 0:for(i=r[l],c=i.getCellCount(),o=i.getDisabledCellsByRule(),h=d=null==t||t>c?c:t;h<i.Cells.length;h++)o.push(h);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)){u.next=18;break}if((k=i.Cells[o[p]]).InUse!=o[p]){u.next=14;break}return u.next=14,v.Z.deleteAccessorieOnShelfPlanner(a.article.set,i.ShelfIndex,k.InUse,i.basketId);case 14:k.IsDisabled=!0;case 15:p++,u.next=9;break;case 18:A=0;case 19:if(!(A<i.Cells.length)){u.next=26;break}if(!o.includes(A)){u.next=22;break}return u.abrupt("continue",23);case 22:i.Cells[A].IsDisabled=!1;case 23:A++,u.next=19;break;case 26:case"end":return u.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 h=_objectSpread({},r),u=t.getAccessoriesToChangeFromGlobalOption(i),g=0,v=Object.keys(u);g<v.length;g++){var b=v[g];h[b]=_objectSpread(_objectSpread({},h[b]),u[b].variantValues)}return h}}]);var t,r,i,h,A,y,x,O,C,I,P,S}()}}]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see 8471.diva-web-planner-react.umd.min.js.LICENSE.txt */
|
|
2
|
-
"use strict";(self.webpackChunkCrystaldesignDivaWebPlannerReact=self.webpackChunkCrystaldesignDivaWebPlannerReact||[]).push([[8471],{28471:(t,r,a)=>{a.r(r),a.d(r,{default:()=>y});var o=a(61965),l=a(84658),i=a(13125),c=a(43860),d=a(80248),u=a(50747),g=a.n(u),h=a(57312),P=a(27058),p=a(50810),m=a(95212),D=a(64357),v=a(49134);function parseSetPlanData(t){var r=P.ZP.decodeBase64(t);return JSON.parse(r)}function isSavePlannerV2(t){return 2===t.v}function saveElementArticleCodex(t){return t.articleCodex||t.Codex}var k=a(58178);function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,l=function F(){};return{s:l,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:l}}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 i,c=!0,d=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return c=t.done,t},e:function e(t){d=!0,i=t},f:function f(){try{c||null==a.return||a.return()}finally{if(d)throw i}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}var E=P.ZP.initLog("Planner","WEB-PLANNER-LOGIC"),I=["AVO","AVU","AVC","AVS","AVN"],y=function(){function DivaStandardPlanner(t,r,a,o,l,c){var u=this;(0,i.Z)(this,DivaStandardPlanner),(0,d.Z)(this,"plannerID",void 0),(0,d.Z)(this,"set",void 0),(0,d.Z)(this,"plannerBoundingBox",void 0),(0,d.Z)(this,"plannerElements",void 0),(0,d.Z)(this,"doDisablePlanner2D",!1),(0,d.Z)(this,"plannerHasStaticBackground",void 0),(0,d.Z)(this,"isIDM3DCat",!1),(0,d.Z)(this,"IDM3DCatCodex",""),(0,d.Z)(this,"IDM3DEnvironment","diva.ro"),(0,d.Z)(this,"nextElementId",1),(0,d.Z)(this,"collisionHandler",void 0),(0,d.Z)(this,"dockToAVUorAVOororAVNorAVSorAVC",(function(t,r){var a=function hasFreeDP(r){return t.getFreeDockingPointsByType(r).length>0};if(a("AVU")){var o=v.Z.tryDockElement(t,"AVU",r);if(o)return u.updateWorldPos(t,o),!0;for(var l=0;l<r.length;l++){var i=r[l].getCurrentAccessorires().map((function(t){return u.plannerElements.get(t.getElementId())}));if(u.dockToAVUorAVOororAVNorAVSorAVC(t,i))return!0}}if(a("AVO")){var c=v.Z.tryDockElement(t,"AVO",r);if(c)return u.updateWorldPos(t,c),!0}if(a("AVN")){var d=v.Z.tryDockElement(t,"AVN",r);if(d)return u.updateWorldPos(t,d),!0}if(a("AVS")){var g=v.Z.tryDockElement(t,"AVS",r);if(g)return u.updateWorldPos(t,g),!0}if(a("AVC")){var h=v.Z.tryDockElement(t,"AVC",r);if(h)return u.updateWorldPos(t,h),!0}return!1})),this.set=t,this.plannerID=a,this.plannerElements=new Map,this.plannerBoundingBox=new k.Z,this.plannerBoundingBox.initPlannerBBox(o),this.doDisablePlanner2D=l,this.collisionHandler={updatePlannerMsgContainer:r,collisionDetected:!1,collisionPairs:[]},this.plannerHasStaticBackground=c}return(0,c.Z)(DivaStandardPlanner,[{key:"updatePlannerPosNr",value:function updatePlannerPosNr(){var t,r=this,a=[],o=new Map,l=this;this.plannerElements.forEach((function(t,r){o.set(r,!0),t.IsDockedAccessoire||t.HasAVL&&t.dockingTypeIsDocking("AVL")||a.push(t)})),this.getCatalogData().dontSetPosNrFromPlanner||(a=a.sort((function(t,r){return t.WorldPosCenter.x-r.WorldPosCenter.x})));for(var i=function updateAccessoiresOfElement(a,c){for(var d=[],u=function setPosNrForElementsOnDock(r,i){if(a["Has"+r]){var d=a.getDockingDockingPointsByType(r);d=d.sort((function(t,r){return l.plannerElements.get(t.OnElementId).WorldPosCorner.x-l.plannerElements.get(r.OnElementId).WorldPosCorner.x}));for(var u=0;u<d.length;u++){var g=d[u].OnElementId;if(o.has(g)){var h=l.plannerElements.get(g);h.PosNr=c,h.AccessoirePosNr=t,o.delete(g),t++,i.push(h)}}}},g=0;g<I.length;g++)u(I[g],d);r.plannerElements.forEach((function(r){r.getIsNotDockedAccessoire()&&r.getParentElementId()===a.getElementId()&&(r.PosNr=c,r.AccessoirePosNr=t,o.delete(r.getElementId()),t++,d.push(r))}));for(var h=0;h<d.length;h++)i(d[h],c)},c=function updatePosInChain(r,a){if(null==r)return a;if(r.PosNr=a,t=1,o.delete(r.ElementId),i(r,a),a++,r.HasAVR&&r.dockingTypeIsDocking("AVR")){var d=r.getDockingDockingPointsByType("AVR")[0].OnElementId;return c(l.plannerElements.get(d),a)}return a},d=1,u=0;u<a.length;u++)d=c(a[u],d)}},{key:"updateWorldPos",value:function updateWorldPos(t,r){var a=!1,o=this.plannerElements.get(r.OnElementId),l=o.getDockingPointById(r.OnDP.DpId);if(null==l)return a;this.applyDockTransform(t,o,r,l),a=this.set.onDockingChanged(t.ElementId,o.ElementId,"DOCK",r.Type);var i=this.set.getPlannerData(t.ElementId);t.updatePlannerData(i);var c=this.set.getPlannerData(o.ElementId);return o.updatePlannerData(c),a}},{key:"applyDockTransform",value:function applyDockTransform(t,r,a,o){var l=(0,p.eY)(r,o,t,a);t.RotDeg=l.rotDeg,t.WorldPosCorner=new D.P(l.worldPosCorner.x,l.worldPosCorner.y,l.worldPosCorner.z),t.WorldPosCornerIgnoreOLF=new D.P(l.worldPosCornerIgnoreOLF.x,l.worldPosCornerIgnoreOLF.y,l.worldPosCornerIgnoreOLF.z)}},{key:"getDockSnapPreview",value:function getDockSnapPreview(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=this.plannerElements.get(t);if(!o)return null;var l,i=this.getAllPlannerElements().filter((function(r){return r.getElementId()!==t&&!a.includes(r.getElementId())})),c=v.Z.searchDockableElementsInArea(o,i,r);if(!c||0===c.size)return null;if(c.forEach((function(t){(null==l||t.distance<l.distance)&&(l=t)})),null==l)return null;var d=this.plannerElements.get(l.targetDP.ElementId);if(!d)return null;var u=o.RotDeg,g=o.WorldPosCenter,h=g.x,P=g.y,p=g.z;this.applyDockTransform(o,d,l.sourceDP,l.targetDP);var m=o.WorldPosCenter,k={dx:m.x-h,dz:m.z-p,dRotDeg:o.RotDeg-u};return o.RotDeg=u,o.WorldPosCenter=new D.P(h,P,p),k}},{key:"updateAllElementsWorldPos",value:function updateAllElementsWorldPos(t,r){if(this.doDisablePlanner2D)return!1;var a=function getDockedDPsInPriorityOrder(t){return t.getDockingDockingPointsByType("AVL").concat(t.getDockingDockingPointsByType("AVR")).concat(t.getDockingDockingPointsByType("AVU")).concat(t.getDockingDockingPointsByType("AVO")).concat(t.getDockingDockingPointsByType("AVN")).concat(t.getDockingDockingPointsByType("AVS")).concat(t.getDockingDockingPointsByType("AVC"))},o=!1,l=[],i=[];this.plannerElements.forEach((function(t,r){t.IsDockedAccessoire?i.push(t):l[t.PosNr-1]=t})),l=l.concat(i);for(var c=[],d=0,u=0;u<l.length;u++)if(l[u]){var g=l[u];if(c.push(g.ElementId),u>d)for(var h=a(g),P=0;P<h.length;P++)if(c.indexOf(h[P].OnElementId)>=0){o=this.updateWorldPos(g,h[P]);break}}else d=u;if(r&&r.length>0)for(var p=new Set(r),m=!0;m;){m=!1;var D,v=_createForOfIteratorHelper(l);try{for(v.s();!(D=v.n()).done;){var k=D.value;if(k&&!p.has(k.ElementId)){var E=a(k).find((function(t){return p.has(t.OnElementId)}));E&&(o=this.updateWorldPos(k,E)||o,p.add(k.ElementId),m=!0)}}}catch(t){v.e(t)}finally{v.f()}}return this.checkCollision(!1,t),o}},{key:"addElementToWorld",value:(b=(0,l.Z)(g().mark((function _callee(t,r,a,o){var l,i,c,d,u,h,P,p,m,k,E,I,y=arguments;return g().wrap((function _callee$(g){for(;;)switch(g.prev=g.next){case 0:if(l=y.length>4&&void 0!==y[4]?y[4]:100,!(i=y.length>5?y[5]:void 0)||!i.forceSetToTrans){g.next=8;break}t.WorldPosCenter=i.transform.worldPosCenter,t.RotDeg=i.transform.rotDeg,this.set.onDockingChanged(t.ElementId,-1,"NOT_DOCKED"),g.next=48;break;case 8:if(c=!1,!r){g.next=47;break}d=0;case 11:if(!(d<r.length)){g.next=47;break}if(u=r[d].targetElemIdToDock,h=r[d].targetDockingPointId,!(u&&u>-1&&this.plannerElements.has(u))){g.next=44;break}if(!h||""==h){g.next=32;break}if(!(P=this.plannerElements.get(u))){g.next=30;break}if(!(p=P.getDockingPointById(h))){g.next=30;break}if(!(m=v.Z.tryDockElementToDP(t,P,p))){g.next=26;break}this.updateWorldPos(t,m),c=!0,g.next=30;break;case 26:return g.next=28,this.tryToDockWithDifferentSVGWithFormula(t,u);case 28:if(!g.sent){g.next=30;break}c=!0;case 30:g.next=44;break;case 32:if(k=!1,(t.HasAVL||t.HasAVR)&&(k=this.dockToAVLorAVR(t,[this.plannerElements.get(u)])),k||(k=this.dockToAVUorAVOororAVNorAVSorAVC(t,[this.plannerElements.get(u)])),k){g.next=43;break}return g.next=38,this.tryToDockWithDifferentSVGWithFormula(t,u);case 38:if(k=g.sent){g.next=43;break}return g.next=42,this.addElementToWorld(t,void 0,void 0,void 0,50);case 42:return g.abrupt("return");case 43:k&&(c=!0);case 44:d++,g.next=11;break;case 47:c||(E=this.getAllPlannerElements(),I=this.dockToAVLorAVR(t,E),a&&(I=!1),I||(I=this.dockToAVUorAVOororAVNorAVSorAVC(t,E),a&&(I=!1),I||(null==o&&(t.WorldPosCenter=new D.P(this.plannerBoundingBox.WorldPos.x+this.plannerBoundingBox.Size.x+(0==this.plannerBoundingBox.Size.x?0:t.Width/2+l),this.plannerBoundingBox.WorldPos.y,this.plannerBoundingBox.WorldPos.z+t.Depth/2)),this.set.onDockingChanged(t.ElementId,-1,"NOT_DOCKED"))));case 48:this.updatePlannerPosNr(),this.updateAllElementsWorldPos(),this.updatePlannerPosNr(),this.checkCollision(!1,t.getElementId()),this.updatePlannerBoundingBox();case 53:case"end":return g.stop()}}),_callee,this)}))),function addElementToWorld(t,r,a,o){return b.apply(this,arguments)})},{key:"tryToDockWithDifferentSVGWithFormula",value:(C=(0,l.Z)(g().mark((function _callee2(t,r){var a,o,l,i,c,d,u,h,p,m,D,v,k;return g().wrap((function _callee2$(g){for(;;)switch(g.prev=g.next){case 0:if(a=!1,o=this.set.getArticleByElementId(t.ElementId),l=null==o?void 0:o.VariantValues,i=t.getSVGsWithFormula(),!t.FilterAVL.length&&!t.FilterAVR.length){g.next=52;break}if(null==i||!i.length){g.next=18;break}c=0;case 7:if(!(c<i.length)){g.next=18;break}return d=P.ZP.getVariantValuesFromRule(i[c].JsFormula,{}),g.next=11,this.applyVariantValuesAndTryDock(t,r,d);case 11:if(!(a=g.sent)){g.next=15;break}return E.debug("svgWithFormula nr: "+c+" did dock: "+i[c].SVG),g.abrupt("break",18);case 15:c++,g.next=7;break;case 18:if(a||!o){g.next=31;break}u=this.getVariantValuesMatchingTargetFilters(o,this.plannerElements.get(r)),h=0;case 21:if(!(h<u.length&&h<20)){g.next=31;break}return g.next=24,this.applyVariantValuesAndTryDock(t,r,u[h]);case 24:if(!(a=g.sent)){g.next=28;break}return E.debug("following variantValues matching the target avl/avr filter did dock: ",u[h]),g.abrupt("break",31);case 28:h++,g.next=21;break;case 31:if(null==(p=t.getVaraintValuesInfluencingAVLAVRFilter())||!p.length||a){g.next=44;break}m=0;case 34:if(!(m<p.length&&m<20)){g.next=44;break}return g.next=37,this.applyVariantValuesAndTryDock(t,r,p[m]);case 37:if(!(a=g.sent)){g.next=41;break}return E.debug("following variantValues did dock: ",p[m]),g.abrupt("break",44);case 41:m++,g.next=34;break;case 44:if(a){g.next=52;break}for(k in D=new Map,v=new Map,l)v.set(k,l[k]);return D.set(t.ElementId,v),g.next=51,this.set.updateCfgValuesByPlanner(D,!0);case 51:o&&this.commitPendingConnectorFilters(o);case 52:return g.abrupt("return",a);case 53:case"end":return g.stop()}}),_callee2,this)}))),function tryToDockWithDifferentSVGWithFormula(t,r){return C.apply(this,arguments)})},{key:"applyVariantValuesAndTryDock",value:(A=(0,l.Z)(g().mark((function _callee3(t,r,a){var o,l,i,c;return g().wrap((function _callee3$(d){for(;;)switch(d.prev=d.next){case 0:for(i in o=new Map,l=new Map,a)l.set(i,a[i]);return o.set(t.ElementId,l),d.next=6,this.set.updateCfgValuesByPlanner(o,!0);case 6:return(c=this.set.getArticleByElementId(t.ElementId))&&this.commitPendingConnectorFilters(c),d.abrupt("return",this.dockToAVLorAVR(t,[this.plannerElements.get(r)]));case 9:case"end":return d.stop()}}),_callee3,this)}))),function applyVariantValuesAndTryDock(t,r,a){return A.apply(this,arguments)})},{key:"commitPendingConnectorFilters",value:function commitPendingConnectorFilters(t){t.newPossibleAVRFilters&&(t.avr=t.newPossibleAVRFilters,t.newPossibleAVRFilters=void 0),t.newPossibleAVLFilters&&(t.avl=t.newPossibleAVLFilters,t.newPossibleAVLFilters=void 0)}},{key:"getVariantValuesMatchingTargetFilters",value:function getVariantValuesMatchingTargetFilters(t,r){if(!r)return[];var a=t.CatalogData.isIDMFormat?"":"OPT",o=t.CatalogData.isIDMFormat?"":"OPV",l=[],i=new Set,c=function collect(r,c){var d,u=_createForOfIteratorHelper(c);try{for(u.s();!(d=u.n()).done;){var g,h=d.value,P=_createForOfIteratorHelper(t.getVariantValuesInfluencingOptions([a+r],o+h));try{for(P.s();!(g=P.n()).done;){var p=g.value,m=JSON.stringify(p);i.has(m)||(i.add(m),l.push(p))}}catch(t){P.e(t)}finally{P.f()}}}catch(t){u.e(t)}finally{u.f()}};return c("89",r.FilterAVR),c("90",r.FilterAVL),l}},{key:"dockToAVLorAVR",value:function dockToAVLorAVR(t,r){var a=!1,o=!1;if(t.HasAVL){var l=v.Z.tryDockElement(t,"AVL",r);l&&(this.updateWorldPos(t,l),a=!0)}if(!a&&t.HasAVR){var i=v.Z.tryDockElement(t,"AVR",r);i&&(o=!0,this.updateWorldPos(t,i))}return a||o}},{key:"getAllViewPlannerElements",value:function getAllViewPlannerElements(){return this.getAllPlannerElements()}},{key:"getFreeDockingPointsByElementId",value:function getFreeDockingPointsByElementId(t,r){if(!this.plannerElements.has(t))return{dockingPoints:[],filter:[]};var a=this.plannerElements.get(t),o=a.getFreeDockingPointsByType(r),l=[];switch(r){case"AVR":l=a.getFilterAVR();break;case"AVL":l=a.getFilterAVL()}return{dockingPoints:o,filter:l}}},{key:"getDockedDockingPointsByElementId",value:function getDockedDockingPointsByElementId(t,r){if(!this.plannerElements.has(t))return[];for(var a=this.plannerElements.get(t),o=[],l=0;l<r.length;l++)o=o.concat(a.getDockingDockingPointsByType(r[l]));return o}},{key:"getNeighborElements",value:function getNeighborElements(t,r){if(!this.plannerElements.has(t))return[];var a=this.plannerElements.get(t),o=null==a?void 0:a.getDockingDockingPointsByType(r);if(!o)return[];for(var l=[],i=0;i<(null==o?void 0:o.length);i++)null!=o[i]&&l.push(o[i].OnElementId);return l}},{key:"getDockedGroups",value:function getDockedGroups(){for(var t=[],r=this.getAllPlannerElements(),a=[],o=0;o<this.getAllPlannerElements().length;o++){var l=r[o];if(a.push(l.getElementId()),!l.IsAccessoire){var i=l.getDockingPointsByType("AVL");if(i&&0!=i.length)for(var c=0;c<i.length;c++)i[c].IsDocking||t.push(l);else t.push(l)}}t.sort((function(t,r){return t.WorldPosCorner.x<r.WorldPosCorner.x?1:0}));var d=[],u=function removeFromElementsToAdd(t){var r=a.indexOf(t);r>=0&&a.splice(r,1)};for(o=0;o<t.length;o++){var g=t[o],h=[];u(g.getElementId());for(var P=!1,p=g;!P;){h.push(p.getElementId()),u(p.getElementId());var m=this.getAccessoiresRecursive(p.getElementId());for(c=0;c<m.length;c++)h.push(m[c]),u(m[c]);var D=this.getNeighborElements(p.getElementId(),"AVR");D&&0!=D.length?p=this.plannerElements.get(D[0]):P=!0}d.push(h)}for(o=0;o<a.length;o++)d.push([a[o]]);return d}},{key:"getAccessoiresRecursive",value:function getAccessoiresRecursive(t){var r=this,a=function calcAccs(t,o,l){l.push(t);for(var i=r.getNeighborElements(t,"AVC"),c=r.getNeighborElements(t,"AVO"),d=r.getNeighborElements(t,"AVU"),u=r.getNeighborElements(t,"AVN"),g=r.getNeighborElements(t,"AVS"),h=i.concat(c).concat(d).concat(u).concat(g),P=0;P<h.length;P++)l.indexOf(h[P])>=0||(o.push(h[P]),l.push(h[P]),a(h[P],o,l))},o=[];return a(t,o,[]),o}},{key:"getBoundingBox",value:function getBoundingBox(){return this.plannerBoundingBox}},{key:"initIDM3DMeta",value:function initIDM3DMeta(t,r){this.isIDM3DCat=!0,this.IDM3DCatCodex=t||this.set.getCatalogCodex(),r&&(this.IDM3DEnvironment=r)}},{key:"updatePlanner",value:(x=(0,l.Z)(g().mark((function _callee4(){var t,r,a,o,l,i;return g().wrap((function _callee4$(c){for(;;)switch(c.prev=c.next){case 0:t=this.getAllPlannerElements(),r=[],a=0;case 3:if(!(a<t.length)){c.next=13;break}if(!(o=t[a]).updatePlannerData(this.set.getPlannerData(o.getElementId()))){c.next=10;break}return r.push(o.ElementId),c.next=10,m.Z.loadSVG(o,this.set);case 10:a++,c.next=3;break;case 13:if(l=[],r.length){for(E.debug("Configuration changed one plannerElement. UpdateDockingRelations","DivaStandardPlanner - updatePlanner"),i=v.Z.updateDockingRelations(this.plannerElements),a=0;a<i.length;a++)i[a].IsDockedAccessoire&&l.push(i[a].ElementId);this.updateAllElementsWorldPos(void 0,r),this.updatePlannerPosNr(),this.updatePlannerBoundingBox()}return c.abrupt("return",{doDeleteBackGrid:!1,elemIdsToDelete:l,elementIdsToUpdateSelection:r,failed:!1});case 16:case"end":return c.stop()}}),_callee4,this)}))),function updatePlanner(){return x.apply(this,arguments)})},{key:"extendPlanner",value:(y=(0,l.Z)(g().mark((function _callee5(t,r){var a,l,i,c,d,u,p,k,I,y,x,A,C,b,V,S,B,w,T,N,W,O;return g().wrap((function _callee5$(g){for(;;)switch(g.prev=g.next){case 0:if(!isSavePlannerV2(a=parseSetPlanData(t))){g.next=39;break}l=a.set.elements,i=[],c=[],d=new Map,u=0;case 7:if(!(u<l.length)){g.next=35;break}if(g.prev=8,x=l[u],(null!==(p=null===(k=this.set.getArticleByBasketId(x.basketID))||void 0===k?void 0:k.catalogArticle)&&void 0!==p?p:this.set.CatalogData.getCatalogArticleByArticleCodex(null!==(I=saveElementArticleCodex(x))&&void 0!==I?I:""))||null===(y=x.AccessoireInitParams)||void 0===y||!y.RelatedToBasketID||this.set.getSetState.onlyRunLogic){g.next=14;break}return E.error(new P.GE("Error initializing element nr "+u+" in the Standard Web Planner. PlanData V2",{code:"WC_0012"})),g.abrupt("continue",32);case 14:if(A=new h.Z(this.set.getSetId(),x.basketID,this.nextElementId,DivaStandardPlanner.plannerType),d.set(x.elementID,A),this.nextElementId=A.getElementId()+1,this.plannerElements.set(A.ElementId,A),this.set.setElementId(x.basketID,A.ElementId),C=this.set.getPlannerData(A.ElementId),A.updatePlannerData(C),this.doDisablePlanner2D){g.next=24;break}return g.next=24,m.Z.loadSVG(A,this.set);case 24:A.WorldPosCenter=new D.P(r.WorldPos.x+r.Size.x+x.x+100,r.WorldPos.y+x.y,r.WorldPos.z+x.z),A.RotDeg=x.rot,A.IsDockedAccessoire?(c.push(x),A.PosNr=x.posNr,null!=x.accNr&&(A.AccessoirePosNr=x.accNr)):(i[x.posNr-1]=x,A.PosNr=x.posNr),g.next=32;break;case 29:g.prev=29,g.t0=g.catch(8),E.error(new P.GE("Error initializing element nr "+u+" in the Standard Web Planner. PlanData V2",{cause:g.t0,code:"WC_0012"}));case 32:u++,g.next=7;break;case 35:for(b=[].concat((0,o.Z)(i.filter((function(t){return null!=t}))),c),u=0;u<b.length;u++)if(V=b[u],S=d.get(V.elementID),b.length>1&&u>0)for(B=V.DP,w=0;w<B.length;w++)T=B[w],N=null==S?void 0:S.getDockingPointById(T.id),W=d.get(T.onID),O=null==W?void 0:W.getDockingPointById(T.onDPID),N&&O&&v.Z.tryDockElementDPToDP(S,W,N,O);g.next=40;break;case 39:E.error(new P.GE("The function extend Planner works only with products that are saved in the configurator 2.0",{code:"WC_0012"}));case 40:case"end":return g.stop()}}),_callee5,this,[[8,29]])}))),function extendPlanner(t,r){return y.apply(this,arguments)})},{key:"initPlanner",value:(u=(0,l.Z)(g().mark((function _callee6(t){var r,a,l,i,c,d,u,p,k,I,y,x,A,C,b,V,S,B,w,T,N,W,O,_,L,Z,R,M,G,H,z,U,X,Y,$,J,j,K,q,Q,ee,ne,te,re,ae,oe,le,ie,se,ce,de,ue,ge,he;return g().wrap((function _callee6$(g){for(;;)switch(g.prev=g.next){case 0:if(!isSavePlannerV2(r=parseSetPlanData(t))){g.next=63;break}if(E.debug("Initialize set Plan Data - V2\n"+r,"DivaStandardPlanner initPlanner"),null!==(a=r.set)&&void 0!==a&&null!==(a=a.elements)&&void 0!==a&&a.length){g.next=5;break}return g.abrupt("return");case 5:l=r.set.elements,i=[],c=[],d=0;case 9:if(!(d<l.length)){g.next=37;break}if(g.prev=10,y=l[d],(null!==(u=null===(p=this.set.getArticleByBasketId(y.basketID))||void 0===p?void 0:p.catalogArticle)&&void 0!==u?u:this.set.CatalogData.getCatalogArticleByArticleCodex(null!==(k=saveElementArticleCodex(y))&&void 0!==k?k:""))||null===(I=y.AccessoireInitParams)||void 0===I||!I.RelatedToBasketID||this.set.getSetState.onlyRunLogic){g.next=16;break}return E.error(new P.GE("Error initializing element nr "+d+" in the Standard Web Planner. PlanData V2",{code:"WC_0012"})),g.abrupt("continue",34);case 16:if(x=y.elementID,A=new h.Z(this.set.getSetId(),y.basketID,x,DivaStandardPlanner.plannerType),this.nextElementId=x+1,this.plannerElements.set(A.ElementId,A),this.set.setElementId(y.basketID,A.ElementId),C=this.set.getPlannerData(A.ElementId),A.updatePlannerData(C),this.doDisablePlanner2D){g.next=26;break}return g.next=26,m.Z.loadSVG(A,this.set);case 26:A.WorldPosCenter=new D.P(this.plannerBoundingBox.WorldPos.x+y.x,this.plannerBoundingBox.WorldPos.y+y.y,this.plannerBoundingBox.WorldPos.z+y.z),A.RotDeg=y.rot,A.IsDockedAccessoire?(c.push(y),A.PosNr=y.posNr,null!=y.accNr&&(A.AccessoirePosNr=y.accNr)):(i[y.posNr-1]=y,A.PosNr=y.posNr),g.next=34;break;case 31:g.prev=31,g.t0=g.catch(10),E.error(new P.GE("Error initializing element nr "+d+" in the Standard Web Planner. PlanData V2",{cause:g.t0,code:"WC_0012"}));case 34:d++,g.next=9;break;case 37:b=1==i.filter(Boolean).length,V=[].concat((0,o.Z)(i.filter((function(t){return null!=t}))),c),d=0;case 40:if(!(d<V.length)){g.next=61;break}if(g.prev=41,S=V[d],0!=d||!b||!this.plannerHasStaticBackground){g.next=48;break}return null!=(null==(B=i[d])?void 0:B.x)||null!=(null==B?void 0:B.y)||null!=(null==B?void 0:B.z)||(w=this.plannerElements.get(S.elementID))&&(w.WorldPosCenter=new D.P(0,w.Height/2,w.Depth/2)),g.abrupt("continue",58);case 48:if(null!=S.DP&&0!=S.DP.length){g.next=50;break}return g.abrupt("continue",58);case 50:for(T=S.DP,N=0;N<T.length;N++)(W=T[N]).id&&null!=W.onID&&W.onDPID&&(O=this.plannerElements.get(S.elementID),_=null==O?void 0:O.getDockingPointById(W.id),L=this.plannerElements.get(W.onID),Z=null==L?void 0:L.getDockingPointById(W.onDPID),_&&Z?_.IsDocking&&_.OnDP==Z||v.Z.tryDockElementDPToDP(O,L,_,Z)||this.doDisablePlanner2D||E.error(new P.GE("Saved docking relation rejected on init: "+W.id+" (elem "+(null==O?void 0:O.ElementId)+") -> "+W.onDPID+" (elem "+(null==L?void 0:L.ElementId)+")",{code:"WC_0012"})):this.doDisablePlanner2D||E.error(new P.GE("Error initializing docking point between source element with id: "+(null==O?void 0:O.ElementId)+" and target Element with id: "+(null==L?void 0:L.ElementId)+". SourceDPID: "+W.id+"; targetDPID: "+W.onDPID)));g.next=58;break;case 54:g.prev=54,g.t1=g.catch(41),M=null===(R=V[d])||void 0===R?void 0:R.elementID,E.error(new P.GE("Error initializing dockingPoints of element with elementID "+M,{cause:g.t1,code:"WC_0012"}));case 58:d++,g.next=40;break;case 61:g.next=116;break;case 63:if(E.debug("Initialize set Plan Data - old V1\n"+r,"DivaStandardPlanner initPlanner"),null!=(z=null===(G=r.Sets)||void 0===G?void 0:G[0])&&null!==(H=z.Elements)&&void 0!==H&&H.length){g.next=67;break}return g.abrupt("return");case 67:U=z.Elements,X=[],Y=[],d=0;case 71:if(!(d<U.length)){g.next=105;break}if(g.prev=72,j=U[d],this.set.CatalogData.getCatalogArticleByArticleCodex(null!==($=saveElementArticleCodex(j))&&void 0!==$?$:"")||null===(J=j.AccessoireInitParams)||void 0===J||!J.RelatedToBasketID||this.set.getSetState.onlyRunLogic){g.next=78;break}return E.error(new P.GE("Error initializing element nr "+d+" in the Standard Web Planner. PlanData V1",{code:"WC_0012"})),g.abrupt("continue",102);case 78:if(K=j.BasketID,-1==this.set.getElementId(K)&&this.set.setElementId(K,Number(j.ID)),q=this.set.getElementId(K),j.elementId=q,-1!=q){g.next=85;break}return E.error(new P.GE("Error when initializing planner. The elementID Was not saved in the article. ",{code:"WC_0012"})),g.abrupt("continue",102);case 85:if(Q=new h.Z(this.set.getSetId(),K,q,DivaStandardPlanner.plannerType),this.nextElementId=q+1,this.plannerElements.set(Q.ElementId,Q),ee=this.set.getPlannerData(Q.ElementId),Q.updatePlannerData(ee),this.doDisablePlanner2D){g.next=93;break}return g.next=93,m.Z.loadSVG(Q,this.set);case 93:ne=new D.P(j.PosX,j.PosZ,j.PosY),Q.WorldPosCenter=new D.P(this.plannerBoundingBox.WorldPos.x+ne.x,this.plannerBoundingBox.WorldPos.y+ne.y,this.plannerBoundingBox.WorldPos.z+ne.z),Q.RotDeg=j.Rot,Q.IsDockedAccessoire?(Y.push(j),j.PosNum.toString().indexOf(".")>0&&(te=j.PosNum.toString().split(".")[0],re=j.PosNum.toString().split(".")[1],Q.PosNr=Number(te),Q.AccessoirePosNr=Number(re))):(X[j.PosNum-1]=j,Q.PosNr=j.PosNum),g.next=102;break;case 99:g.prev=99,g.t2=g.catch(72),E.error(new P.GE("Error initializing element nr "+d+" in the Standard Web Planner - Plan Data old Planner",{cause:g.t2,code:"WC_0012"}));case 102:d++,g.next=71;break;case 105:ae=[].concat((0,o.Z)(X.filter((function(t){return null!=t}))),Y),d=0;case 107:if(!(d<ae.length)){g.next=116;break}if(null!=(oe=ae[d]).DP&&0!=oe.DP.length){g.next=111;break}return g.abrupt("continue",113);case 111:for(le=oe.DP,N=0;N<le.length;N++)(ie=le[N]).DP&&""!=ie.DP&&ie.onID&&""!=ie.onID&&(ce=parseInt(String(ie.onID)),de=ie.DP,ue=null!=oe.elementId?this.plannerElements.get(oe.elementId):void 0,ge=null!==(se=this.plannerElements.get(ce))&&void 0!==se?se:this.getPlannerElementByIndex(ce-1),ue&&ge?v.Z.initDockingPointRelationByArea(ue,ge,de):E.error(new P.GE("Error initializing dockingPoints of element with elementID "+oe.elementId,{code:"WC_0012"})));case 113:d++,g.next=107;break;case 116:this.plannerElements.forEach((function(t){!t.IsDockedAccessoire&&(null==he||t.PosNr<he.PosNr)&&(he=t)})),this.updateAllElementsWorldPos(void 0,he?[he.ElementId]:void 0),this.updatePlannerPosNr();case 119:case"end":return g.stop()}}),_callee6,this,[[10,31],[41,54],[72,99]])}))),function initPlanner(t){return u.apply(this,arguments)})},{key:"getPlannerElementByIndex",value:function getPlannerElementByIndex(t){var r=void 0,a=0;return this.plannerElements.forEach((function(o,l){t==a&&(r=o),a++})),r}},{key:"addPlannerElement",value:(a=(0,l.Z)(g().mark((function _callee7(t,r){var a,o,l,i,c,d,u;return g().wrap((function _callee7$(g){for(;;)switch(g.prev=g.next){case 0:if(c=new h.Z(this.set.getSetId(),t,this.nextElementId,DivaStandardPlanner.plannerType),this.nextElementId++,this.plannerElements.set(c.ElementId,c),this.set.setElementId(t,c.ElementId),d=this.set.getPlannerData(c.ElementId),c.updatePlannerData(d),this.doDisablePlanner2D){g.next=9;break}return g.next=9,m.Z.loadSVG(c,this.set);case 9:if(null==(u=null!==(a=r.dockingPointInfos)&&void 0!==a?a:[{targetDockingPointId:r.targetDockingPointId,targetElemIdToDock:r.targetElemIdToDock}])||null===(o=u[0])||void 0===o||!o.targetElemIdToDock||null==u||null===(l=u[0])||void 0===l||!l.targetDockingPointId){g.next=15;break}return g.next=13,this.addElementToWorld(c,u);case 13:g.next=27;break;case 15:if(null==u||null===(i=u[0])||void 0===i||!i.targetElemIdToDock){g.next=20;break}return g.next=18,this.addElementToWorld(c,u);case 18:g.next=27;break;case 20:if(!r.oldPlannerTransform){g.next=25;break}return g.next=23,this.addElementToWorld(c,void 0,void 0,void 0,void 0,{forceSetToTrans:!0,transform:r.oldPlannerTransform});case 23:g.next=27;break;case 25:return g.next=27,this.addElementToWorld(c);case 27:this.updatePlannerBoundingBox();case 28:case"end":return g.stop()}}),_callee7,this)}))),function addPlannerElement(t,r){return a.apply(this,arguments)})},{key:"movePlannerElement",value:function movePlannerElement(){throw Error("move planner not implemented in standard")}},{key:"copyPlannerElement",value:(r=(0,l.Z)(g().mark((function _callee8(t,r){var a,o,l,i,c,d;return g().wrap((function _callee8$(u){for(;;)switch(u.prev=u.next){case 0:a=0;case 1:if(!(a<t.length)){u.next=24;break}if(l=t[a],null!=r){u.next=7;break}return u.next=6,this.addPlannerElement(l.value,{});case 6:return u.abrupt("continue",21);case 7:if(-1==(i=null===(o=r.copyIndex)||void 0===o?void 0:o.x)||1==i){u.next=12;break}return u.next=11,this.addPlannerElement(l.value,{});case 11:return u.abrupt("continue",21);case 12:if(c=this.plannerElements.get(l.key),d=null==c?void 0:c.getFreeDockingPointsByType(-1==i?"AVL":"AVR").find((function(t){return!t.IsDisabled})),!c||!d){u.next=19;break}return u.next=17,this.addPlannerElement(l.value,{targetElemIdToDock:c.ElementId,targetDockingPointId:d.DpId});case 17:u.next=21;break;case 19:return u.next=21,this.addPlannerElement(l.value,{});case 21:a++,u.next=1;break;case 24:case"end":return u.stop()}}),_callee8,this)}))),function copyPlannerElement(t,a){return r.apply(this,arguments)})},{key:"getPlannerElementsInfluencedByDeletion",value:function getPlannerElementsInfluencedByDeletion(t,r){return[]}},{key:"getPlannerElementsInfluencedByCopy",value:function getPlannerElementsInfluencedByCopy(t,r){if(!r||"BoxPlanner_backside"!=r.copyType&&"STD"!=r.copyType)throw new Error("copyType needs to be BoxPlanner_backside or STD here");return this.plannerElements.has(t)?[t]:[]}},{key:"deletePlannerElement",value:(t=(0,l.Z)(g().mark((function _callee9(t,r){var a,o,l,i,c,d,u,h,p,m,D,k,E,I,y;return g().wrap((function _callee9$(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,P.ZP.Sleep(1);case 2:if(this.plannerElements.has(t)){g.next=4;break}return g.abrupt("return",{});case 4:return a=this.plannerElements.get(t),o=this.getParentElement(a),l=-1,i=999,c=-1,d=-1,u=!1,this.plannerElements.forEach((function(t,r){u||(null!=a&&a.IsAccessoire&&a.PosNr==t.PosNr&&(c=t.getElementId(),u=!0),t.getPosNr()<a.getPosNr()&&t.getPosNr()>l?(l=t.getPosNr(),c=t.getElementId()):t.getPosNr()>a.getPosNr()&&t.getPosNr()<i&&(i=t.getPosNr(),d=t.getElementId()))})),h=!1,r&&(p=a.getDockingDockingPointsByType("AVL"),m=a.getDockingDockingPointsByType("AVR"),p.length>0&&m.length>0&&(D=this.plannerElements.get(p[0].OnElementId),k=this.plannerElements.get(m[0].OnElementId),D&&k&&(E=D.getDockingDockingPointsByType("AVR"),I=k.getDockingDockingPointsByType("AVL"),E.length>0&&I.length>0&&(v.Z.removeDockingPointRelations(a),h=!0,v.Z.tryDockElementDPToDP(D,k,E[0],I[0]))))),y={rotDeg:a.getRotDeg(),worldPosCenter:a.WorldPosCenter},h||v.Z.removeDockingPointRelations(a),this.plannerElements.delete(t),this.tryToDockForNotDockedAccessoire(o),this.updatePlannerPosNr(),this.updateAllElementsWorldPos(),this.updatePlannerPosNr(),this.checkCollision(!1,a.getElementId()),this.updatePlannerBoundingBox(),g.abrupt("return",{newElementToSelect:c>=0?c:d>=0?d:void 0,transform:y});case 24:case"end":return g.stop()}}),_callee9,this)}))),function deletePlannerElement(r,a){return t.apply(this,arguments)})},{key:"tryToDockForNotDockedAccessoire",value:function tryToDockForNotDockedAccessoire(t){if(t)for(var r=t.getCurrentAccessorires().filter((function(t){return t.getIsNotDockedAccessoire()})),a=0;a<r.length;a++){var o=r[a].getElementId(),l=this.plannerElements.get(o);if(l)if(this.dockToAVUorAVOororAVNorAVSorAVC(l,[t]))break}}},{key:"checkCollision",value:function checkCollision(t,r){if(!this.doDisablePlanner2D){for(var a,o,l=this.getAllPlannerElements(),i=!1,c=[],d=0;d<l.length;d++){var u=l[d];if(!r||u.getElementId()==r)for(var g=r?0:d+1;g<l.length;g++){var h,P,p=l[g];if(u.getElementId()!=p.getElementId()&&!v.Z.checkElementsAreDocking(u,p)){var D=!1;if((this.set.CatalogData.doCheckConstructionWarnings||null!==(h=this.set.CatalogData.forceConstructionWarningForArticles)&&void 0!==h&&h.includes(u.ArticleCodex)||null!==(P=this.set.CatalogData.forceConstructionWarningForArticles)&&void 0!==P&&P.includes(p.ArticleCodex))&&(D=m.Z.checkCollision(u,p,this.set.CatalogData.checkCollisionForDifferentLayers)),D&&(i=!0,c.push({elementId1:u.getElementId(),elementId2:p.getElementId()}),E.debug("Collision Found between element1: "+u.ElementId+"; and element2: "+p.ElementId),!t))break}}}if(this.collisionHandler.collisionDetected&&!i)null===(a=(o=this.collisionHandler).updatePlannerMsgContainer)||void 0===a||a.call(o,"COLLISION_MSG",!1,"WARNING","COLLISION_MSG",!1);else if(!this.collisionHandler.collisionDetected&&i){var k,I;null===(k=(I=this.collisionHandler).updatePlannerMsgContainer)||void 0===k||k.call(I,"COLLISION_MSG",!0,"WARNING","COLLISION_MSG",!1)}this.collisionHandler.collisionPairs=c,this.collisionHandler.collisionDetected=i}}},{key:"updateSetPosNr",value:function updateSetPosNr(t){for(var r=this.getAllPlannerElements(),a=0;a<r.length;a++){var o=r[a];o.SetPosNr=t+o.PosNr-1,this.set.setPosNr(o.ElementId,o.getPosNr())}for(var l=0;l<r.length;l++)r[l].IsAccessoire||this.set.giveAccNewPosNrByBasketId(r[l].getBasketId());return r.length}},{key:"updatePlannerTrans",value:function updatePlannerTrans(t,r,a,o,l,i,c){var d=this,u=!1;if(this.plannerElements.has(t)){var g=this.plannerElements.get(t);if(null==g||g.updateDeltaTrans(r,a,o,"END"==l,c),"START"==l){if(g){var h=["AVR","AVL"];g.IsDockedAccessoire&&(h=h.concat(["AVO","AVU","AVN","AVS","AVC"]));for(var P=v.Z.removeDockingPointRelationsByType(g,h),p=0;p<P.length;p++)u=this.set.onDockingChanged(g.ElementId,P[p],"UNDOCK")}}else if("END"==l){var m=v.Z.searchDockableElementsInArea(g,this.getAllPlannerElements(),i);null!=m&&m.size>0&&m.forEach((function(t,r){var a=d.plannerElements.get(t.targetDP.ElementId);a&&v.Z.tryDockElementDPToDP(g,a,t.sourceDP,t.targetDP)})),u=this.updateAllElementsWorldPos(t),this.updatePlannerPosNr(),this.updatePlannerBoundingBox()}}return u}},{key:"destroyPlanner",value:function destroyPlanner(){this.plannerElements.forEach((function(t,r){t.destroy()})),this.plannerElements.clear()}},{key:"saveSetPlanner",value:function saveSetPlanner(){var t=this;if(0==this.plannerElements.size)return null;var r=[];return this.plannerElements.forEach((function(a,o){for(var l=a.getDockingDockingPoints(),i=[],c=0;c<l.length;c++){var d,u={id:l[c].DpId,onID:l[c].OnElementId,onDPID:null===(d=l[c].OnDP)||void 0===d?void 0:d.DpId};i.push(u)}var g={elementID:a.getElementId(),basketID:t.set.getBasketId(a.getElementId()),CatalogCodex:t.set.getCatalogCodex(),Codex:t.set.getArticleCodex(a.getElementId()),posNr:a.PosNr,accNr:a.IsDockedAccessoire?a.AccessoirePosNr:void 0,x:a.WorldPosCenter.x,y:a.WorldPosCenter.y,z:a.WorldPosCenter.z,rot:a.RotDeg,width:a.Width?a.Width:-1,height:a.Height?a.Height:-1,depth:a.Depth?a.Depth:-1,DP:i};if(a.IsAccessoire){var h=t.set.getParentBasketIdOfElementId(a.getElementId());null!=h&&(g.AccessoireInitParams={RelatedToBasketID:h})}r.push(g)})),{setId:this.set.getSetId(),x:0,y:0,z:0,width:this.plannerBoundingBox.Size.x,height:this.plannerBoundingBox.Size.y,depth:this.plannerBoundingBox.Size.z,rot:0,elements:r}}},{key:"getPlannerId",value:function getPlannerId(){return this.plannerID}},{key:"getSetData",value:function getSetData(t,r,a,o){var l=this,i={ID:r?this.set.getSetId():"S1",H:"",x:0,y:0,z:0,w:0,ELE:[],Blob:this.set.CatalogData.supplierILN,Cat:this.set.getCatalogCodex()},c=this.set.getAlternateRenderInfo();c&&(i.AlternateImg=c),a&&(i.ShowDim=a),this.isIDM3DCat&&(i.IsIDM3D=!0,i.IDM3DCatCodex=this.IDM3DCatCodex,i.IDM3DEnvironment=this.IDM3DEnvironment),this.plannerElements.forEach((function(r,c){var d=l.set.getPlannerConfigData(c,o),u=d.config,g=[];if(d.accs&&d.accs.length>0)for(var h=0;h<d.accs.length;h++)l.plannerElements.has(d.accs[h])&&g.push("E"+d.accs[h]);if(!t||null!=u.Model){var p,m,D,v,k=l.set.getArticleByElementId(c),E={ID:"E"+c,Model:u.Model,x:-Math.round(100*r.WorldPosCenterIgnoreOLF.x)/100,y:Math.round(100*r.WorldPosCenterIgnoreOLF.y)/100,z:Math.round(100*r.WorldPosCenterIgnoreOLF.z)/100,PosPivot:"Center",w:Math.round(100*r.getRotDeg())/100,RotPivot:"Center",DP:r.getDockingPointJS3D(),MAT:u.MAT,MOVE:null!==(p=u.MOVE)&&void 0!==p?p:void 0,CFG:u.CFG,H:"",ACCs:g.length>0?g:void 0};if(a)E.TechSize={Width:null==r.Width||isNaN(r.Width)?null!==(m=null==k?void 0:k.width)&&void 0!==m?m:0:r.Width,Height:null==r.Height||isNaN(r.Height)?null!==(D=null==k?void 0:k.height)&&void 0!==D?D:0:r.Height,Depth:null==r.Depth||isNaN(r.Depth)?null!==(v=null==k?void 0:k.depth)&&void 0!==v?v:0:r.Depth};var I=(0,P.FB)(JSON.stringify(E));E.H=I,i.ELE.push(E)}var y=l.set.getShelfPlannerData(c);if(y)for(var x=0;x<y.length;x++){var A=y[x],C=l.set.getShelfPlannerConfigData(A.basketId).config,b=[];if(C.accs&&C.accs.length>0)for(var V=0;V<C.accs.length;V++)l.plannerElements.has(C.accs[V])&&b.push("E"+C.accs[V]);var S={ID:"E"+A.parentElementId+"."+A.gridId+"."+A.rh,H:"",Model:A.model,x:0,y:0,z:1,w:0,PosPivot:"Center",RotPivot:"Center",DP:"RH"+A.rh+":E"+A.parentElementId,GN:A.gridName,MAT:C.MAT,CFG:C.CFG,ACCs:b.length>0?b:void 0};I=(0,P.FB)(JSON.stringify(S));S.H=I,i.ELE.push(S)}}));var d=(0,P.FB)(JSON.stringify(i));return i.H=d,{constructionSet:i}}},{key:"getElementPosInfo",value:function getElementPosInfo(){var t={};return this.plannerElements.forEach((function(r,a){r.IsDockedAccessoire?t[a]={pos:r.PosNr,isAcc:!0,accPos:r.AccessoirePosNr}:t[a]={pos:r.PosNr,isAcc:!1}})),t}},{key:"getPlanningIsComplete",value:function getPlanningIsComplete(t){var r=this,a=!t&&(this.set.CatalogData.doHideCompletenessWarning||!this.set.CatalogData.doCheckConstructionWarnings),o=!1;return this.plannerElements.forEach((function(t,l){var i;(!a||null!==(i=r.set.CatalogData.forceConstructionWarningForArticles)&&void 0!==i&&i.includes(t.ArticleCodex))&&!o&&(t.getFreeDockingPointsByType("AVL").length>0||t.getFreeDockingPointsByType("AVR").length>0)&&(o=!0)})),!o}},{key:"getPlannerBoundingBox",value:function getPlannerBoundingBox(){var t=this.set.CatalogData,r=this.plannerBoundingBox.getWidth(t.PlannerMeasureDigits),a=this.plannerBoundingBox.getDepth(t.PlannerMeasureDigits),o=this.plannerBoundingBox.getHeight(t.PlannerMeasureDigits),l=this.plannerBoundingBox.getWidth(t.PlannerMeasureDigits,!0),i=this.plannerBoundingBox.getDepth(t.PlannerMeasureDigits,!0),c=this.plannerBoundingBox.getHeight(t.PlannerMeasureDigits,!0),d=l!==r||i!==a||c!==o;return{width:r,height:o,depth:a,widthIgnoreOLF:d?l:void 0,depthIgnoreOLF:d?i:void 0,heightIgnoreOLF:d?c:void 0}}},{key:"updatePlannerBoundingBox",value:function updatePlannerBoundingBox(){this.plannerBoundingBox.calcPlannerBoundingBox(this.getAllPlannerElements()),this.plannerBoundingBox.calcPlannerBoundingBoxIgnoreOLF(this.getAllPlannerElements())}},{key:"getCatalogData",value:function getCatalogData(){return this.set.CatalogData}},{key:"getAllPlannerElements",value:function getAllPlannerElements(){var t=[];return this.plannerElements.forEach((function(r,a){t.push(r)})),t}},{key:"getParentElement",value:function getParentElement(t){var r=void 0,a=t.getParentElementId();return a&&(r=this.plannerElements.get(a)),r}},{key:"getPositionOfPlannerElements",value:function getPositionOfPlannerElements(){var t=this.set.getSetId();this.plannerElements.forEach((function(r,a){E.log("SetID:",t),E.log("Elementid:",r.ElementId),E.log("X:",r.WorldPosCenter.x),E.log("Y:",r.WorldPosCenter.y),E.log("X:",r.WorldPosCenter.z),E.log("ROT:",r.RotDeg),E.log("___________________________")}))}},{key:"clonePlanner",value:function clonePlanner(t,r){return new DivaStandardPlanner(t,(function(){}),r,new k.Z,!0,!1)}},{key:"getPlannerInteractionInformation",value:function getPlannerInteractionInformation(){return E.error(new P.GE("The function getPlannerInteractionInformation is not implemented yet for standard planner. Dont call it or ask roadmap when its its turn",{code:"WC_0012"})),{boxPlannerInteractionInformationPerElement:new Map}}},{key:"getGeneralPlanningState",value:function getGeneralPlanningState(t){return E.error(new P.GE("The function getGeneralPlanningState is not implemented yet for standard planner. Dont call it or ask roadmap when its its turn",{code:"WC_0012"})),{grids:[]}}}]);var t,r,a,u,y,x,A,C,b}();(0,d.Z)(y,"plannerType","STD")},49134:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(13125),l=a(43860),i=a(89429),c=a(49736);function _superPropBase(t,r){for(;!{}.hasOwnProperty.call(t,r)&&null!==(t=(0,c.Z)(t)););return t}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,r,a){var o=_superPropBase(t,r);if(o){var l=Object.getOwnPropertyDescriptor(o,r);return l.get?l.get.call(arguments.length<3?t:a):l.value}},_get.apply(null,arguments)}var d=a(91870);function _callSuper(t,r,a){return r=(0,c.Z)(r),(0,i.Z)(t,_isNativeReflectConstruct()?Reflect.construct(r,a||[],(0,c.Z)(t).constructor):r.apply(t,a))}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}const u=new(function(t){function DockingPointHandler(){return(0,o.Z)(this,DockingPointHandler),_callSuper(this,DockingPointHandler,arguments)}return(0,d.Z)(DockingPointHandler,t),(0,l.Z)(DockingPointHandler,[{key:"initDockingPointsFromSvg",value:function initDockingPointsFromSvg(t,r,a,o){var l="minX"in a?a:{minX:a.svgMinXVal,minY:a.svgMinYVal};!function _superPropGet(t,r,a,o){var l=_get((0,c.Z)(1&o?t.prototype:t),r,a);return 2&o&&"function"==typeof l?function(t){return l.apply(a,t)}:l}(DockingPointHandler,"initDockingPointsFromSvg",this,3)([t,r,l,o])}}])}(a(50810).pD))},95212:(t,r,a)=>{a.d(r,{Z:()=>v});var o=a(84658),l=a(13125),i=a(43860),c=a(80248),d=a(50747),u=a.n(d),g=a(58129),h=a(49134),P=a(64357),p=a(27058),m=a(50810),D=p.ZP.initLog("Planner","WEB-PLANNER-LOGIC");const v=new(function(){return(0,i.Z)((function PlannerHandler2D(){(0,l.Z)(this,PlannerHandler2D),(0,c.Z)(this,"svgUtils",void 0),this.svgUtils=new g.Z}),[{key:"checkCollision",value:function checkCollision(t,r,a){if(p.ZP.startSpanOfApm("PlannerHandler2D checkCollision"),!(t.Layer==r.Layer||a.includes(Number(t.Layer))&&a.includes(Number(r.Layer))))return p.ZP.endSpanOfApm("PlannerHandler2D checkCollision"),!1;var o=t.getWorld2DBBoxOutline(),l=r.getWorld2DBBoxOutline();if((0,m.JU)(o,l)){if(!t.HasOLTPolygon&&!t.HasOLFPolygon)return D.error(new p.GE("checkCollision PlannerHandler2D - The element with id: "+t.getElementId()+" has no OLT AND no OLF",{code:"WC_0012"})),p.ZP.endSpanOfApm("PlannerHandler2D checkCollision"),!1;if(!r.HasOLTPolygon&&!r.HasOLFPolygon)return D.error(new p.GE("checkCollision PlannerHandler2D - The element with id: "+r.getElementId()+" has no OLT AND no OLF",{code:"WC_0012"})),p.ZP.endSpanOfApm("PlannerHandler2D checkCollision"),!1;var i=t.HasOLFPolygon?t.getOLFPolygonWorldPos():t.getOLTPolygonWorldPos(),c=r.HasOLFPolygon?r.getOLFPolygonWorldPos():r.getOLTPolygonWorldPos();return p.ZP.endSpanOfApm("PlannerHandler2D checkCollision"),(0,m.JU)(i,c)}return p.ZP.endSpanOfApm("PlannerHandler2D checkCollision"),(0,m.uA)(o,l)}},{key:"parseSvg",value:function parseSvg(t,r,a,o,l){var i,c;r=this.svgUtils.removeMaskFromSvg(r),h.Z.initDockingPointsFromSvg(t,this.svgUtils.getDPsInSVG(r),a,o);var d=this.svgUtils.getPointOfPoligonById(r,"OLT");null!=d&&d.length||D.warn("no olt fount in svg for element"+t.ArticleCodex+" with id "+t.getElementId()),t.OLTPolygon=d;var u=this.svgUtils.getPointOfPoligonById(r,"OLF"),g=(0,m.Qq)(r);if(null!=u&&u.length){var v,k,E=this.svgUtils.getBoundingBoxOfPoints(u),I=null!==(v=null==g?void 0:g.width)&&void 0!==v?v:E.width,y=null!==(k=null==g?void 0:g.height)&&void 0!==k?k:E.height;t.setupOLF(u,I,y)}else if(g){var x=[new P.FM(g.minX,g.minY),new P.FM(g.minX+g.width,g.minY),new P.FM(g.minX+g.width,g.minY+g.height),new P.FM(g.minX,g.minY+g.height)];t.setupOLF(x,g.width,g.height)}else null!=l&&l.heightOLF,null!=l&&l.widthOLF?t.setupOLF(u,null==l?void 0:l.widthOLF,null==l?void 0:l.heightOLF):t.clearOLF();var A=(0,m.hd)(r);if(t.OLTWidth=null!==(i=null==A?void 0:A.width)&&void 0!==i?i:0,t.OLTDepth=null!==(c=null==A?void 0:A.height)&&void 0!==c?c:0,t.OLTLeft=A&&g?A.x-g.minX:0,t.OLTTop=A&&g?A.y-g.minY:0,t.DoSetWidthFromSVG||t.DoSetDepthFromSVG){var C=(0,m.O3)(r);t.DoSetWidthFromSVG&&null!=C&&C.width&&(t.WidthFromSVG=C.width/p.ZP.UnitRecalc),t.DoSetDepthFromSVG&&null!=C&&C.height&&(t.DepthFromSVG=C.height/p.ZP.UnitRecalc)}t.SvgData=r,t.cleanShapeOLF2D(),t.cleanShapeOLT2D()}},{key:"getMinBorderSVG",value:function getMinBorderSVG(t){var r=(0,m.dI)(t);return{svgMinXVal:r.minX,svgMinYVal:r.minY}}},{key:"loadSVG",value:(t=(0,o.Z)(u().mark((function _callee(t,r){var a,o,l,i,c,d,g,h,P,m,v,k=this;return u().wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:if(o=t.SvgFileName){u.next=3;break}return u.abrupt("return",!1);case 3:if(!r.CatalogData.isIDMFormat){u.next=9;break}return u.next=6,r.api.fetchData(o,{method:"GET",config:{},data:{}});case 6:l=u.sent,u.next=16;break;case 9:return u.next=11,r.api.getDataCache(this.getSVGUrl(o,r.CatalogData.mediaUrl),void 0,r.CatalogData.accountSessionGuid);case 11:if(!(c=u.sent).Error){u.next=14;break}throw new Error(c.Error);case 14:"success"==c.Result.toLowerCase()&&(i=c.Content),l=p.ZP.decodeBase64(i);case 16:if(l||D.error(new p.GE("Fehler beim laden des SVGs ",{code:"WC_0009",custom:{svgFile:o}})),t.svgBefore=l,d=t.DoSetWidthFromSVG?void 0:t.Width,null==(g=t.DoSetDepthFromSVG?void 0:t.Depth)&&null!=d&&(null!==(a=t.Height)&&void 0!==a?a:-1)>0&&(g=t.Height),!(r.CatalogData.isIDMFormat?null!=d||null!=g:null!=d&&null!=g)){u.next=32;break}return P=this.getMinBorderSVG(l),m=r.CatalogData.isIDMFormat?o:"".concat(r.CatalogData.mediaUrl,"pln_").concat(o),v="",u.next=28,new Promise((function(t,a){var o;h=k.svgUtils.ccCheckStretchAreas(l,null!=d?d:0,null!==(o=g)&&void 0!==o?o:0,r.CatalogData.useGlobalSVGScale,P.svgMinXVal,P.svgMinYVal,(function(r){v=r,t()}),m,{width:null==d,depth:null==g})}));case 28:t.svgAfter=v,this.parseSvg(t,v,P,r.CatalogData.getPlannerConfig(),h),u.next=34;break;case 32:t.svgAfter=l,this.parseSvg(t,l,{svgMinXVal:0,svgMinYVal:0},r.CatalogData.getPlannerConfig());case 34:return u.abrupt("return",!0);case 35:case"end":return u.stop()}}),_callee,this)}))),function loadSVG(r,a){return t.apply(this,arguments)})},{key:"getSVGUrl",value:function getSVGUrl(t,r){var a=r+"pln_"+t,o=a.indexOf("/files/");return a=a.substring(o),"function=GetFileAsString&fileUrl="+encodeURIComponent(a)}}]);var t}())}}]);
|
|
2
|
+
"use strict";(self.webpackChunkCrystaldesignDivaWebPlannerReact=self.webpackChunkCrystaldesignDivaWebPlannerReact||[]).push([[8471],{28471:(t,r,a)=>{a.r(r),a.d(r,{default:()=>y});var o=a(61965),l=a(84658),i=a(13125),c=a(43860),d=a(80248),u=a(50747),g=a.n(u),h=a(57312),P=a(27058),p=a(50810),m=a(95212),D=a(64357),v=a(49134);function parseSetPlanData(t){var r=P.ZP.decodeBase64(t);return JSON.parse(r)}function isSavePlannerV2(t){return 2===t.v}function saveElementArticleCodex(t){return t.articleCodex||t.Codex}var k=a(58178);function _createForOfIteratorHelper(t,r){var a="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!a){if(Array.isArray(t)||(a=function _unsupportedIterableToArray(t,r){if(t){if("string"==typeof t)return _arrayLikeToArray(t,r);var a={}.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){a&&(t=a);var o=0,l=function F(){};return{s:l,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:l}}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 i,c=!0,d=!1;return{s:function s(){a=a.call(t)},n:function n(){var t=a.next();return c=t.done,t},e:function e(t){d=!0,i=t},f:function f(){try{c||null==a.return||a.return()}finally{if(d)throw i}}}}function _arrayLikeToArray(t,r){(null==r||r>t.length)&&(r=t.length);for(var a=0,o=Array(r);a<r;a++)o[a]=t[a];return o}var E=P.ZP.initLog("Planner","WEB-PLANNER-LOGIC"),I=["AVO","AVU","AVC","AVS","AVN"],y=function(){function DivaStandardPlanner(t,r,a,o,l,c){var u=this;(0,i.Z)(this,DivaStandardPlanner),(0,d.Z)(this,"plannerID",void 0),(0,d.Z)(this,"set",void 0),(0,d.Z)(this,"plannerBoundingBox",void 0),(0,d.Z)(this,"plannerElements",void 0),(0,d.Z)(this,"doDisablePlanner2D",!1),(0,d.Z)(this,"plannerHasStaticBackground",void 0),(0,d.Z)(this,"isIDM3DCat",!1),(0,d.Z)(this,"IDM3DCatCodex",""),(0,d.Z)(this,"IDM3DEnvironment","diva.ro"),(0,d.Z)(this,"nextElementId",1),(0,d.Z)(this,"collisionHandler",void 0),(0,d.Z)(this,"dockToAVUorAVOororAVNorAVSorAVC",(function(t,r){var a=function hasFreeDP(r){return t.getFreeDockingPointsByType(r).length>0};if(a("AVU")){var o=v.Z.tryDockElement(t,"AVU",r);if(o)return u.updateWorldPos(t,o),!0;for(var l=0;l<r.length;l++){var i=r[l].getCurrentAccessorires().map((function(t){return u.plannerElements.get(t.getElementId())}));if(u.dockToAVUorAVOororAVNorAVSorAVC(t,i))return!0}}if(a("AVO")){var c=v.Z.tryDockElement(t,"AVO",r);if(c)return u.updateWorldPos(t,c),!0}if(a("AVN")){var d=v.Z.tryDockElement(t,"AVN",r);if(d)return u.updateWorldPos(t,d),!0}if(a("AVS")){var g=v.Z.tryDockElement(t,"AVS",r);if(g)return u.updateWorldPos(t,g),!0}if(a("AVC")){var h=v.Z.tryDockElement(t,"AVC",r);if(h)return u.updateWorldPos(t,h),!0}return!1})),this.set=t,this.plannerID=a,this.plannerElements=new Map,this.plannerBoundingBox=new k.Z,this.plannerBoundingBox.initPlannerBBox(o),this.doDisablePlanner2D=l,this.collisionHandler={updatePlannerMsgContainer:r,collisionDetected:!1,collisionPairs:[]},this.plannerHasStaticBackground=c}return(0,c.Z)(DivaStandardPlanner,[{key:"updatePlannerPosNr",value:function updatePlannerPosNr(){var t,r=this,a=[],o=new Map,l=this;this.plannerElements.forEach((function(t,r){o.set(r,!0),t.IsDockedAccessoire||t.HasAVL&&t.dockingTypeIsDocking("AVL")||a.push(t)})),this.getCatalogData().dontSetPosNrFromPlanner||(a=a.sort((function(t,r){return t.WorldPosCenter.x-r.WorldPosCenter.x})));for(var i=function updateAccessoiresOfElement(a,c){for(var d=[],u=function setPosNrForElementsOnDock(r,i){if(a["Has"+r]){var d=a.getDockingDockingPointsByType(r);d=d.sort((function(t,r){return l.plannerElements.get(t.OnElementId).WorldPosCorner.x-l.plannerElements.get(r.OnElementId).WorldPosCorner.x}));for(var u=0;u<d.length;u++){var g=d[u].OnElementId;if(o.has(g)){var h=l.plannerElements.get(g);h.PosNr=c,h.AccessoirePosNr=t,o.delete(g),t++,i.push(h)}}}},g=0;g<I.length;g++)u(I[g],d);r.plannerElements.forEach((function(r){r.getIsNotDockedAccessoire()&&r.getParentElementId()===a.getElementId()&&(r.PosNr=c,r.AccessoirePosNr=t,o.delete(r.getElementId()),t++,d.push(r))}));for(var h=0;h<d.length;h++)i(d[h],c)},c=function updatePosInChain(r,a){if(null==r)return a;if(r.PosNr=a,t=1,o.delete(r.ElementId),i(r,a),a++,r.HasAVR&&r.dockingTypeIsDocking("AVR")){var d=r.getDockingDockingPointsByType("AVR")[0].OnElementId;return c(l.plannerElements.get(d),a)}return a},d=1,u=0;u<a.length;u++)d=c(a[u],d)}},{key:"updateWorldPos",value:function updateWorldPos(t,r){var a=!1,o=this.plannerElements.get(r.OnElementId),l=o.getDockingPointById(r.OnDP.DpId);if(null==l)return a;this.applyDockTransform(t,o,r,l),a=this.set.onDockingChanged(t.ElementId,o.ElementId,"DOCK",r.Type);var i=this.set.getPlannerData(t.ElementId);t.updatePlannerData(i);var c=this.set.getPlannerData(o.ElementId);return o.updatePlannerData(c),a}},{key:"applyDockTransform",value:function applyDockTransform(t,r,a,o){var l=(0,p.eY)(r,o,t,a);t.RotDeg=l.rotDeg,t.WorldPosCorner=new D.P(l.worldPosCorner.x,l.worldPosCorner.y,l.worldPosCorner.z),t.WorldPosCornerIgnoreOLF=new D.P(l.worldPosCornerIgnoreOLF.x,l.worldPosCornerIgnoreOLF.y,l.worldPosCornerIgnoreOLF.z)}},{key:"getDockSnapPreview",value:function getDockSnapPreview(t,r){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=this.plannerElements.get(t);if(!o)return null;var l,i=this.getAllPlannerElements().filter((function(r){return r.getElementId()!==t&&!a.includes(r.getElementId())})),c=v.Z.searchDockableElementsInArea(o,i,r);if(!c||0===c.size)return null;if(c.forEach((function(t){(null==l||t.distance<l.distance)&&(l=t)})),null==l)return null;var d=this.plannerElements.get(l.targetDP.ElementId);if(!d)return null;var u=o.RotDeg,g=o.WorldPosCenter,h=g.x,P=g.y,p=g.z;this.applyDockTransform(o,d,l.sourceDP,l.targetDP);var m=o.WorldPosCenter,k={dx:m.x-h,dz:m.z-p,dRotDeg:o.RotDeg-u};return o.RotDeg=u,o.WorldPosCenter=new D.P(h,P,p),k}},{key:"updateAllElementsWorldPos",value:function updateAllElementsWorldPos(t,r){if(this.doDisablePlanner2D)return!1;var a=function getDockedDPsInPriorityOrder(t){return t.getDockingDockingPointsByType("AVL").concat(t.getDockingDockingPointsByType("AVR")).concat(t.getDockingDockingPointsByType("AVU")).concat(t.getDockingDockingPointsByType("AVO")).concat(t.getDockingDockingPointsByType("AVN")).concat(t.getDockingDockingPointsByType("AVS")).concat(t.getDockingDockingPointsByType("AVC"))},o=!1,l=[],i=[];this.plannerElements.forEach((function(t,r){t.IsDockedAccessoire?i.push(t):l[t.PosNr-1]=t})),l=l.concat(i);for(var c=[],d=0,u=0;u<l.length;u++)if(l[u]){var g=l[u];if(c.push(g.ElementId),u>d)for(var h=a(g),P=0;P<h.length;P++)if(c.indexOf(h[P].OnElementId)>=0){o=this.updateWorldPos(g,h[P]);break}}else d=u;if(r&&r.length>0)for(var p=new Set(r),m=!0;m;){m=!1;var D,v=_createForOfIteratorHelper(l);try{for(v.s();!(D=v.n()).done;){var k=D.value;if(k&&!p.has(k.ElementId)){var E=a(k).find((function(t){return p.has(t.OnElementId)}));E&&(o=this.updateWorldPos(k,E)||o,p.add(k.ElementId),m=!0)}}}catch(t){v.e(t)}finally{v.f()}}return this.checkCollision(!1,t),o}},{key:"addElementToWorld",value:(b=(0,l.Z)(g().mark((function _callee(t,r,a,o){var l,i,c,d,u,P,p,m,k,E,I,y,x,A,C,b,V=arguments;return g().wrap((function _callee$(g){for(;;)switch(g.prev=g.next){case 0:if(l=V.length>4&&void 0!==V[4]?V[4]:100,!(i=V.length>5?V[5]:void 0)||!i.forceSetToTrans){g.next=10;break}c=i.transform,d=c.worldPosCenter,u=c.height,P=h.Z.standsOnFloor(d.y,u),t.WorldPosCenter=P&&Number.isFinite(t.Height)?new D.P(d.x,t.Height/2,d.z):d,t.RotDeg=i.transform.rotDeg,this.set.onDockingChanged(t.ElementId,-1,"NOT_DOCKED"),g.next=50;break;case 10:if(p=!1,!r){g.next=49;break}m=0;case 13:if(!(m<r.length)){g.next=49;break}if(k=r[m].targetElemIdToDock,E=r[m].targetDockingPointId,!(k&&k>-1&&this.plannerElements.has(k))){g.next=46;break}if(!E||""==E){g.next=34;break}if(!(I=this.plannerElements.get(k))){g.next=32;break}if(!(y=I.getDockingPointById(E))){g.next=32;break}if(!(x=v.Z.tryDockElementToDP(t,I,y))){g.next=28;break}this.updateWorldPos(t,x),p=!0,g.next=32;break;case 28:return g.next=30,this.tryToDockWithDifferentSVGWithFormula(t,k);case 30:if(!g.sent){g.next=32;break}p=!0;case 32:g.next=46;break;case 34:if(A=!1,(t.HasAVL||t.HasAVR)&&(A=this.dockToAVLorAVR(t,[this.plannerElements.get(k)])),A||(A=this.dockToAVUorAVOororAVNorAVSorAVC(t,[this.plannerElements.get(k)])),A){g.next=45;break}return g.next=40,this.tryToDockWithDifferentSVGWithFormula(t,k);case 40:if(A=g.sent){g.next=45;break}return g.next=44,this.addElementToWorld(t,void 0,void 0,void 0,50);case 44:return g.abrupt("return");case 45:A&&(p=!0);case 46:m++,g.next=13;break;case 49:p||(C=this.getAllPlannerElements(),b=this.dockToAVLorAVR(t,C),a&&(b=!1),b||(b=this.dockToAVUorAVOororAVNorAVSorAVC(t,C),a&&(b=!1),b||(null==o&&(t.WorldPosCenter=new D.P(this.plannerBoundingBox.WorldPos.x+this.plannerBoundingBox.Size.x+(0==this.plannerBoundingBox.Size.x?0:t.Width/2+l),this.plannerBoundingBox.WorldPos.y,this.plannerBoundingBox.WorldPos.z+t.Depth/2)),this.set.onDockingChanged(t.ElementId,-1,"NOT_DOCKED"))));case 50:this.updatePlannerPosNr(),this.updateAllElementsWorldPos(),this.updatePlannerPosNr(),this.checkCollision(!1,t.getElementId()),this.updatePlannerBoundingBox();case 55:case"end":return g.stop()}}),_callee,this)}))),function addElementToWorld(t,r,a,o){return b.apply(this,arguments)})},{key:"tryToDockWithDifferentSVGWithFormula",value:(C=(0,l.Z)(g().mark((function _callee2(t,r){var a,o,l,i,c,d,u,h,p,m,D,v,k;return g().wrap((function _callee2$(g){for(;;)switch(g.prev=g.next){case 0:if(a=!1,o=this.set.getArticleByElementId(t.ElementId),l=null==o?void 0:o.VariantValues,i=t.getSVGsWithFormula(),!t.FilterAVL.length&&!t.FilterAVR.length){g.next=52;break}if(null==i||!i.length){g.next=18;break}c=0;case 7:if(!(c<i.length)){g.next=18;break}return d=P.ZP.getVariantValuesFromRule(i[c].JsFormula,{}),g.next=11,this.applyVariantValuesAndTryDock(t,r,d);case 11:if(!(a=g.sent)){g.next=15;break}return E.debug("svgWithFormula nr: "+c+" did dock: "+i[c].SVG),g.abrupt("break",18);case 15:c++,g.next=7;break;case 18:if(a||!o){g.next=31;break}u=this.getVariantValuesMatchingTargetFilters(o,this.plannerElements.get(r)),h=0;case 21:if(!(h<u.length&&h<20)){g.next=31;break}return g.next=24,this.applyVariantValuesAndTryDock(t,r,u[h]);case 24:if(!(a=g.sent)){g.next=28;break}return E.debug("following variantValues matching the target avl/avr filter did dock: ",u[h]),g.abrupt("break",31);case 28:h++,g.next=21;break;case 31:if(null==(p=t.getVaraintValuesInfluencingAVLAVRFilter())||!p.length||a){g.next=44;break}m=0;case 34:if(!(m<p.length&&m<20)){g.next=44;break}return g.next=37,this.applyVariantValuesAndTryDock(t,r,p[m]);case 37:if(!(a=g.sent)){g.next=41;break}return E.debug("following variantValues did dock: ",p[m]),g.abrupt("break",44);case 41:m++,g.next=34;break;case 44:if(a){g.next=52;break}for(k in D=new Map,v=new Map,l)v.set(k,l[k]);return D.set(t.ElementId,v),g.next=51,this.set.updateCfgValuesByPlanner(D,!0);case 51:o&&this.commitPendingConnectorFilters(o);case 52:return g.abrupt("return",a);case 53:case"end":return g.stop()}}),_callee2,this)}))),function tryToDockWithDifferentSVGWithFormula(t,r){return C.apply(this,arguments)})},{key:"applyVariantValuesAndTryDock",value:(A=(0,l.Z)(g().mark((function _callee3(t,r,a){var o,l,i,c;return g().wrap((function _callee3$(d){for(;;)switch(d.prev=d.next){case 0:for(i in o=new Map,l=new Map,a)l.set(i,a[i]);return o.set(t.ElementId,l),d.next=6,this.set.updateCfgValuesByPlanner(o,!0);case 6:return(c=this.set.getArticleByElementId(t.ElementId))&&this.commitPendingConnectorFilters(c),d.abrupt("return",this.dockToAVLorAVR(t,[this.plannerElements.get(r)]));case 9:case"end":return d.stop()}}),_callee3,this)}))),function applyVariantValuesAndTryDock(t,r,a){return A.apply(this,arguments)})},{key:"commitPendingConnectorFilters",value:function commitPendingConnectorFilters(t){t.newPossibleAVRFilters&&(t.avr=t.newPossibleAVRFilters,t.newPossibleAVRFilters=void 0),t.newPossibleAVLFilters&&(t.avl=t.newPossibleAVLFilters,t.newPossibleAVLFilters=void 0)}},{key:"getVariantValuesMatchingTargetFilters",value:function getVariantValuesMatchingTargetFilters(t,r){if(!r)return[];var a=t.CatalogData.isIDMFormat?"":"OPT",o=t.CatalogData.isIDMFormat?"":"OPV",l=[],i=new Set,c=function collect(r,c){var d,u=_createForOfIteratorHelper(c);try{for(u.s();!(d=u.n()).done;){var g,h=d.value,P=_createForOfIteratorHelper(t.getVariantValuesInfluencingOptions([a+r],o+h));try{for(P.s();!(g=P.n()).done;){var p=g.value,m=JSON.stringify(p);i.has(m)||(i.add(m),l.push(p))}}catch(t){P.e(t)}finally{P.f()}}}catch(t){u.e(t)}finally{u.f()}};return c("89",r.FilterAVR),c("90",r.FilterAVL),l}},{key:"dockToAVLorAVR",value:function dockToAVLorAVR(t,r){var a=!1,o=!1;if(t.HasAVL){var l=v.Z.tryDockElement(t,"AVL",r);l&&(this.updateWorldPos(t,l),a=!0)}if(!a&&t.HasAVR){var i=v.Z.tryDockElement(t,"AVR",r);i&&(o=!0,this.updateWorldPos(t,i))}return a||o}},{key:"getAllViewPlannerElements",value:function getAllViewPlannerElements(){return this.getAllPlannerElements()}},{key:"getFreeDockingPointsByElementId",value:function getFreeDockingPointsByElementId(t,r){if(!this.plannerElements.has(t))return{dockingPoints:[],filter:[]};var a=this.plannerElements.get(t),o=a.getFreeDockingPointsByType(r),l=[];switch(r){case"AVR":l=a.getFilterAVR();break;case"AVL":l=a.getFilterAVL()}return{dockingPoints:o,filter:l}}},{key:"getDockedDockingPointsByElementId",value:function getDockedDockingPointsByElementId(t,r){if(!this.plannerElements.has(t))return[];for(var a=this.plannerElements.get(t),o=[],l=0;l<r.length;l++)o=o.concat(a.getDockingDockingPointsByType(r[l]));return o}},{key:"getNeighborElements",value:function getNeighborElements(t,r){if(!this.plannerElements.has(t))return[];var a=this.plannerElements.get(t),o=null==a?void 0:a.getDockingDockingPointsByType(r);if(!o)return[];for(var l=[],i=0;i<(null==o?void 0:o.length);i++)null!=o[i]&&l.push(o[i].OnElementId);return l}},{key:"getDockedGroups",value:function getDockedGroups(){for(var t=[],r=this.getAllPlannerElements(),a=[],o=0;o<this.getAllPlannerElements().length;o++){var l=r[o];if(a.push(l.getElementId()),!l.IsAccessoire){var i=l.getDockingPointsByType("AVL");if(i&&0!=i.length)for(var c=0;c<i.length;c++)i[c].IsDocking||t.push(l);else t.push(l)}}t.sort((function(t,r){return t.WorldPosCorner.x<r.WorldPosCorner.x?1:0}));var d=[],u=function removeFromElementsToAdd(t){var r=a.indexOf(t);r>=0&&a.splice(r,1)};for(o=0;o<t.length;o++){var g=t[o],h=[];u(g.getElementId());for(var P=!1,p=g;!P;){h.push(p.getElementId()),u(p.getElementId());var m=this.getAccessoiresRecursive(p.getElementId());for(c=0;c<m.length;c++)h.push(m[c]),u(m[c]);var D=this.getNeighborElements(p.getElementId(),"AVR");D&&0!=D.length?p=this.plannerElements.get(D[0]):P=!0}d.push(h)}for(o=0;o<a.length;o++)d.push([a[o]]);return d}},{key:"getAccessoiresRecursive",value:function getAccessoiresRecursive(t){var r=this,a=function calcAccs(t,o,l){l.push(t);for(var i=r.getNeighborElements(t,"AVC"),c=r.getNeighborElements(t,"AVO"),d=r.getNeighborElements(t,"AVU"),u=r.getNeighborElements(t,"AVN"),g=r.getNeighborElements(t,"AVS"),h=i.concat(c).concat(d).concat(u).concat(g),P=0;P<h.length;P++)l.indexOf(h[P])>=0||(o.push(h[P]),l.push(h[P]),a(h[P],o,l))},o=[];return a(t,o,[]),o}},{key:"getBoundingBox",value:function getBoundingBox(){return this.plannerBoundingBox}},{key:"initIDM3DMeta",value:function initIDM3DMeta(t,r){this.isIDM3DCat=!0,this.IDM3DCatCodex=t||this.set.getCatalogCodex(),r&&(this.IDM3DEnvironment=r)}},{key:"updatePlanner",value:(x=(0,l.Z)(g().mark((function _callee4(){var t,r,a,o,l,i;return g().wrap((function _callee4$(c){for(;;)switch(c.prev=c.next){case 0:t=this.getAllPlannerElements(),r=[],a=0;case 3:if(!(a<t.length)){c.next=14;break}if(!(o=t[a]).updatePlannerData(this.set.getPlannerData(o.getElementId()))){c.next=11;break}return r.push(o.ElementId),o.keepOnFloorOnHeightChange(),c.next=11,m.Z.loadSVG(o,this.set);case 11:a++,c.next=3;break;case 14:if(l=[],r.length){for(E.debug("Configuration changed one plannerElement. UpdateDockingRelations","DivaStandardPlanner - updatePlanner"),i=v.Z.updateDockingRelations(this.plannerElements),a=0;a<i.length;a++)i[a].IsDockedAccessoire&&l.push(i[a].ElementId);this.updateAllElementsWorldPos(void 0,r),this.updatePlannerPosNr(),this.updatePlannerBoundingBox()}return c.abrupt("return",{doDeleteBackGrid:!1,elemIdsToDelete:l,elementIdsToUpdateSelection:r,failed:!1});case 17:case"end":return c.stop()}}),_callee4,this)}))),function updatePlanner(){return x.apply(this,arguments)})},{key:"extendPlanner",value:(y=(0,l.Z)(g().mark((function _callee5(t,r){var a,l,i,c,d,u,p,k,I,y,x,A,C,b,V,S,B,w,T,N,W,O;return g().wrap((function _callee5$(g){for(;;)switch(g.prev=g.next){case 0:if(!isSavePlannerV2(a=parseSetPlanData(t))){g.next=39;break}l=a.set.elements,i=[],c=[],d=new Map,u=0;case 7:if(!(u<l.length)){g.next=35;break}if(g.prev=8,x=l[u],(null!==(p=null===(k=this.set.getArticleByBasketId(x.basketID))||void 0===k?void 0:k.catalogArticle)&&void 0!==p?p:this.set.CatalogData.getCatalogArticleByArticleCodex(null!==(I=saveElementArticleCodex(x))&&void 0!==I?I:""))||null===(y=x.AccessoireInitParams)||void 0===y||!y.RelatedToBasketID||this.set.getSetState.onlyRunLogic){g.next=14;break}return E.error(new P.GE("Error initializing element nr "+u+" in the Standard Web Planner. PlanData V2",{code:"WC_0012"})),g.abrupt("continue",32);case 14:if(A=new h.Z(this.set.getSetId(),x.basketID,this.nextElementId,DivaStandardPlanner.plannerType),d.set(x.elementID,A),this.nextElementId=A.getElementId()+1,this.plannerElements.set(A.ElementId,A),this.set.setElementId(x.basketID,A.ElementId),C=this.set.getPlannerData(A.ElementId),A.updatePlannerData(C),this.doDisablePlanner2D){g.next=24;break}return g.next=24,m.Z.loadSVG(A,this.set);case 24:A.WorldPosCenter=new D.P(r.WorldPos.x+r.Size.x+x.x+100,r.WorldPos.y+x.y,r.WorldPos.z+x.z),A.RotDeg=x.rot,A.IsDockedAccessoire?(c.push(x),A.PosNr=x.posNr,null!=x.accNr&&(A.AccessoirePosNr=x.accNr)):(i[x.posNr-1]=x,A.PosNr=x.posNr),g.next=32;break;case 29:g.prev=29,g.t0=g.catch(8),E.error(new P.GE("Error initializing element nr "+u+" in the Standard Web Planner. PlanData V2",{cause:g.t0,code:"WC_0012"}));case 32:u++,g.next=7;break;case 35:for(b=[].concat((0,o.Z)(i.filter((function(t){return null!=t}))),c),u=0;u<b.length;u++)if(V=b[u],S=d.get(V.elementID),b.length>1&&u>0)for(B=V.DP,w=0;w<B.length;w++)T=B[w],N=null==S?void 0:S.getDockingPointById(T.id),W=d.get(T.onID),O=null==W?void 0:W.getDockingPointById(T.onDPID),N&&O&&v.Z.tryDockElementDPToDP(S,W,N,O);g.next=40;break;case 39:E.error(new P.GE("The function extend Planner works only with products that are saved in the configurator 2.0",{code:"WC_0012"}));case 40:case"end":return g.stop()}}),_callee5,this,[[8,29]])}))),function extendPlanner(t,r){return y.apply(this,arguments)})},{key:"initPlanner",value:(u=(0,l.Z)(g().mark((function _callee6(t){var r,a,l,i,c,d,u,p,k,I,y,x,A,C,b,V,S,B,w,T,N,W,O,_,L,Z,R,M,G,H,z,U,X,Y,$,J,j,K,q,Q,ee,ne,te,re,ae,oe,le,ie,se,ce,de,ue,ge,he;return g().wrap((function _callee6$(g){for(;;)switch(g.prev=g.next){case 0:if(!isSavePlannerV2(r=parseSetPlanData(t))){g.next=63;break}if(E.debug("Initialize set Plan Data - V2\n"+r,"DivaStandardPlanner initPlanner"),null!==(a=r.set)&&void 0!==a&&null!==(a=a.elements)&&void 0!==a&&a.length){g.next=5;break}return g.abrupt("return");case 5:l=r.set.elements,i=[],c=[],d=0;case 9:if(!(d<l.length)){g.next=37;break}if(g.prev=10,y=l[d],(null!==(u=null===(p=this.set.getArticleByBasketId(y.basketID))||void 0===p?void 0:p.catalogArticle)&&void 0!==u?u:this.set.CatalogData.getCatalogArticleByArticleCodex(null!==(k=saveElementArticleCodex(y))&&void 0!==k?k:""))||null===(I=y.AccessoireInitParams)||void 0===I||!I.RelatedToBasketID||this.set.getSetState.onlyRunLogic){g.next=16;break}return E.error(new P.GE("Error initializing element nr "+d+" in the Standard Web Planner. PlanData V2",{code:"WC_0012"})),g.abrupt("continue",34);case 16:if(x=y.elementID,A=new h.Z(this.set.getSetId(),y.basketID,x,DivaStandardPlanner.plannerType),this.nextElementId=x+1,this.plannerElements.set(A.ElementId,A),this.set.setElementId(y.basketID,A.ElementId),C=this.set.getPlannerData(A.ElementId),A.updatePlannerData(C),this.doDisablePlanner2D){g.next=26;break}return g.next=26,m.Z.loadSVG(A,this.set);case 26:A.WorldPosCenter=new D.P(this.plannerBoundingBox.WorldPos.x+y.x,this.plannerBoundingBox.WorldPos.y+y.y,this.plannerBoundingBox.WorldPos.z+y.z),A.RotDeg=y.rot,A.IsDockedAccessoire?(c.push(y),A.PosNr=y.posNr,null!=y.accNr&&(A.AccessoirePosNr=y.accNr)):(i[y.posNr-1]=y,A.PosNr=y.posNr),g.next=34;break;case 31:g.prev=31,g.t0=g.catch(10),E.error(new P.GE("Error initializing element nr "+d+" in the Standard Web Planner. PlanData V2",{cause:g.t0,code:"WC_0012"}));case 34:d++,g.next=9;break;case 37:b=1==i.filter(Boolean).length,V=[].concat((0,o.Z)(i.filter((function(t){return null!=t}))),c),d=0;case 40:if(!(d<V.length)){g.next=61;break}if(g.prev=41,S=V[d],0!=d||!b||!this.plannerHasStaticBackground){g.next=48;break}return null!=(null==(B=i[d])?void 0:B.x)||null!=(null==B?void 0:B.y)||null!=(null==B?void 0:B.z)||(w=this.plannerElements.get(S.elementID))&&(w.WorldPosCenter=new D.P(0,w.Height/2,w.Depth/2)),g.abrupt("continue",58);case 48:if(null!=S.DP&&0!=S.DP.length){g.next=50;break}return g.abrupt("continue",58);case 50:for(T=S.DP,N=0;N<T.length;N++)(W=T[N]).id&&null!=W.onID&&W.onDPID&&(O=this.plannerElements.get(S.elementID),_=null==O?void 0:O.getDockingPointById(W.id),L=this.plannerElements.get(W.onID),Z=null==L?void 0:L.getDockingPointById(W.onDPID),_&&Z?_.IsDocking&&_.OnDP==Z||v.Z.tryDockElementDPToDP(O,L,_,Z)||this.doDisablePlanner2D||E.error(new P.GE("Saved docking relation rejected on init: "+W.id+" (elem "+(null==O?void 0:O.ElementId)+") -> "+W.onDPID+" (elem "+(null==L?void 0:L.ElementId)+")",{code:"WC_0012"})):this.doDisablePlanner2D||E.error(new P.GE("Error initializing docking point between source element with id: "+(null==O?void 0:O.ElementId)+" and target Element with id: "+(null==L?void 0:L.ElementId)+". SourceDPID: "+W.id+"; targetDPID: "+W.onDPID)));g.next=58;break;case 54:g.prev=54,g.t1=g.catch(41),M=null===(R=V[d])||void 0===R?void 0:R.elementID,E.error(new P.GE("Error initializing dockingPoints of element with elementID "+M,{cause:g.t1,code:"WC_0012"}));case 58:d++,g.next=40;break;case 61:g.next=116;break;case 63:if(E.debug("Initialize set Plan Data - old V1\n"+r,"DivaStandardPlanner initPlanner"),null!=(z=null===(G=r.Sets)||void 0===G?void 0:G[0])&&null!==(H=z.Elements)&&void 0!==H&&H.length){g.next=67;break}return g.abrupt("return");case 67:U=z.Elements,X=[],Y=[],d=0;case 71:if(!(d<U.length)){g.next=105;break}if(g.prev=72,j=U[d],this.set.CatalogData.getCatalogArticleByArticleCodex(null!==($=saveElementArticleCodex(j))&&void 0!==$?$:"")||null===(J=j.AccessoireInitParams)||void 0===J||!J.RelatedToBasketID||this.set.getSetState.onlyRunLogic){g.next=78;break}return E.error(new P.GE("Error initializing element nr "+d+" in the Standard Web Planner. PlanData V1",{code:"WC_0012"})),g.abrupt("continue",102);case 78:if(K=j.BasketID,-1==this.set.getElementId(K)&&this.set.setElementId(K,Number(j.ID)),q=this.set.getElementId(K),j.elementId=q,-1!=q){g.next=85;break}return E.error(new P.GE("Error when initializing planner. The elementID Was not saved in the article. ",{code:"WC_0012"})),g.abrupt("continue",102);case 85:if(Q=new h.Z(this.set.getSetId(),K,q,DivaStandardPlanner.plannerType),this.nextElementId=q+1,this.plannerElements.set(Q.ElementId,Q),ee=this.set.getPlannerData(Q.ElementId),Q.updatePlannerData(ee),this.doDisablePlanner2D){g.next=93;break}return g.next=93,m.Z.loadSVG(Q,this.set);case 93:ne=new D.P(j.PosX,j.PosZ,j.PosY),Q.WorldPosCenter=new D.P(this.plannerBoundingBox.WorldPos.x+ne.x,this.plannerBoundingBox.WorldPos.y+ne.y,this.plannerBoundingBox.WorldPos.z+ne.z),Q.RotDeg=j.Rot,Q.IsDockedAccessoire?(Y.push(j),j.PosNum.toString().indexOf(".")>0&&(te=j.PosNum.toString().split(".")[0],re=j.PosNum.toString().split(".")[1],Q.PosNr=Number(te),Q.AccessoirePosNr=Number(re))):(X[j.PosNum-1]=j,Q.PosNr=j.PosNum),g.next=102;break;case 99:g.prev=99,g.t2=g.catch(72),E.error(new P.GE("Error initializing element nr "+d+" in the Standard Web Planner - Plan Data old Planner",{cause:g.t2,code:"WC_0012"}));case 102:d++,g.next=71;break;case 105:ae=[].concat((0,o.Z)(X.filter((function(t){return null!=t}))),Y),d=0;case 107:if(!(d<ae.length)){g.next=116;break}if(null!=(oe=ae[d]).DP&&0!=oe.DP.length){g.next=111;break}return g.abrupt("continue",113);case 111:for(le=oe.DP,N=0;N<le.length;N++)(ie=le[N]).DP&&""!=ie.DP&&ie.onID&&""!=ie.onID&&(ce=parseInt(String(ie.onID)),de=ie.DP,ue=null!=oe.elementId?this.plannerElements.get(oe.elementId):void 0,ge=null!==(se=this.plannerElements.get(ce))&&void 0!==se?se:this.getPlannerElementByIndex(ce-1),ue&&ge?v.Z.initDockingPointRelationByArea(ue,ge,de):E.error(new P.GE("Error initializing dockingPoints of element with elementID "+oe.elementId,{code:"WC_0012"})));case 113:d++,g.next=107;break;case 116:this.plannerElements.forEach((function(t){!t.IsDockedAccessoire&&(null==he||t.PosNr<he.PosNr)&&(he=t)})),this.updateAllElementsWorldPos(void 0,he?[he.ElementId]:void 0),this.updatePlannerPosNr();case 119:case"end":return g.stop()}}),_callee6,this,[[10,31],[41,54],[72,99]])}))),function initPlanner(t){return u.apply(this,arguments)})},{key:"getPlannerElementByIndex",value:function getPlannerElementByIndex(t){var r=void 0,a=0;return this.plannerElements.forEach((function(o,l){t==a&&(r=o),a++})),r}},{key:"addPlannerElement",value:(a=(0,l.Z)(g().mark((function _callee7(t,r){var a,o,l,i,c,d,u;return g().wrap((function _callee7$(g){for(;;)switch(g.prev=g.next){case 0:if(c=new h.Z(this.set.getSetId(),t,this.nextElementId,DivaStandardPlanner.plannerType),this.nextElementId++,this.plannerElements.set(c.ElementId,c),this.set.setElementId(t,c.ElementId),d=this.set.getPlannerData(c.ElementId),c.updatePlannerData(d),this.doDisablePlanner2D){g.next=9;break}return g.next=9,m.Z.loadSVG(c,this.set);case 9:if(null==(u=null!==(a=r.dockingPointInfos)&&void 0!==a?a:[{targetDockingPointId:r.targetDockingPointId,targetElemIdToDock:r.targetElemIdToDock}])||null===(o=u[0])||void 0===o||!o.targetElemIdToDock||null==u||null===(l=u[0])||void 0===l||!l.targetDockingPointId){g.next=15;break}return g.next=13,this.addElementToWorld(c,u);case 13:g.next=27;break;case 15:if(null==u||null===(i=u[0])||void 0===i||!i.targetElemIdToDock){g.next=20;break}return g.next=18,this.addElementToWorld(c,u);case 18:g.next=27;break;case 20:if(!r.oldPlannerTransform){g.next=25;break}return g.next=23,this.addElementToWorld(c,void 0,void 0,void 0,void 0,{forceSetToTrans:!0,transform:r.oldPlannerTransform});case 23:g.next=27;break;case 25:return g.next=27,this.addElementToWorld(c);case 27:this.updatePlannerBoundingBox();case 28:case"end":return g.stop()}}),_callee7,this)}))),function addPlannerElement(t,r){return a.apply(this,arguments)})},{key:"movePlannerElement",value:function movePlannerElement(){throw Error("move planner not implemented in standard")}},{key:"copyPlannerElement",value:(r=(0,l.Z)(g().mark((function _callee8(t,r){var a,o,l,i,c,d;return g().wrap((function _callee8$(u){for(;;)switch(u.prev=u.next){case 0:a=0;case 1:if(!(a<t.length)){u.next=24;break}if(l=t[a],null!=r){u.next=7;break}return u.next=6,this.addPlannerElement(l.value,{});case 6:return u.abrupt("continue",21);case 7:if(-1==(i=null===(o=r.copyIndex)||void 0===o?void 0:o.x)||1==i){u.next=12;break}return u.next=11,this.addPlannerElement(l.value,{});case 11:return u.abrupt("continue",21);case 12:if(c=this.plannerElements.get(l.key),d=null==c?void 0:c.getFreeDockingPointsByType(-1==i?"AVL":"AVR").find((function(t){return!t.IsDisabled})),!c||!d){u.next=19;break}return u.next=17,this.addPlannerElement(l.value,{targetElemIdToDock:c.ElementId,targetDockingPointId:d.DpId});case 17:u.next=21;break;case 19:return u.next=21,this.addPlannerElement(l.value,{});case 21:a++,u.next=1;break;case 24:case"end":return u.stop()}}),_callee8,this)}))),function copyPlannerElement(t,a){return r.apply(this,arguments)})},{key:"getPlannerElementsInfluencedByDeletion",value:function getPlannerElementsInfluencedByDeletion(t,r){return[]}},{key:"getPlannerElementsInfluencedByCopy",value:function getPlannerElementsInfluencedByCopy(t,r){if(!r||"BoxPlanner_backside"!=r.copyType&&"STD"!=r.copyType)throw new Error("copyType needs to be BoxPlanner_backside or STD here");return this.plannerElements.has(t)?[t]:[]}},{key:"deletePlannerElement",value:(t=(0,l.Z)(g().mark((function _callee9(t,r){var a,o,l,i,c,d,u,h,p,m,D,k,E,I,y;return g().wrap((function _callee9$(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,P.ZP.Sleep(1);case 2:if(this.plannerElements.has(t)){g.next=4;break}return g.abrupt("return",{});case 4:return a=this.plannerElements.get(t),o=this.getParentElement(a),l=-1,i=999,c=-1,d=-1,u=!1,this.plannerElements.forEach((function(t,r){u||(null!=a&&a.IsAccessoire&&a.PosNr==t.PosNr&&(c=t.getElementId(),u=!0),t.getPosNr()<a.getPosNr()&&t.getPosNr()>l?(l=t.getPosNr(),c=t.getElementId()):t.getPosNr()>a.getPosNr()&&t.getPosNr()<i&&(i=t.getPosNr(),d=t.getElementId()))})),h=!1,r&&(p=a.getDockingDockingPointsByType("AVL"),m=a.getDockingDockingPointsByType("AVR"),p.length>0&&m.length>0&&(D=this.plannerElements.get(p[0].OnElementId),k=this.plannerElements.get(m[0].OnElementId),D&&k&&(E=D.getDockingDockingPointsByType("AVR"),I=k.getDockingDockingPointsByType("AVL"),E.length>0&&I.length>0&&(v.Z.removeDockingPointRelations(a),h=!0,v.Z.tryDockElementDPToDP(D,k,E[0],I[0]))))),y={rotDeg:a.getRotDeg(),worldPosCenter:a.WorldPosCenter,height:a.Height},h||v.Z.removeDockingPointRelations(a),this.plannerElements.delete(t),this.tryToDockForNotDockedAccessoire(o),this.updatePlannerPosNr(),this.updateAllElementsWorldPos(),this.updatePlannerPosNr(),this.checkCollision(!1,a.getElementId()),this.updatePlannerBoundingBox(),g.abrupt("return",{newElementToSelect:c>=0?c:d>=0?d:void 0,transform:y});case 24:case"end":return g.stop()}}),_callee9,this)}))),function deletePlannerElement(r,a){return t.apply(this,arguments)})},{key:"tryToDockForNotDockedAccessoire",value:function tryToDockForNotDockedAccessoire(t){if(t)for(var r=t.getCurrentAccessorires().filter((function(t){return t.getIsNotDockedAccessoire()})),a=0;a<r.length;a++){var o=r[a].getElementId(),l=this.plannerElements.get(o);if(l)if(this.dockToAVUorAVOororAVNorAVSorAVC(l,[t]))break}}},{key:"checkCollision",value:function checkCollision(t,r){if(!this.doDisablePlanner2D){for(var a,o,l=this.getAllPlannerElements(),i=!1,c=[],d=0;d<l.length;d++){var u=l[d];if(!r||u.getElementId()==r)for(var g=r?0:d+1;g<l.length;g++){var h,P,p=l[g];if(u.getElementId()!=p.getElementId()&&!v.Z.checkElementsAreDocking(u,p)){var D=!1;if((this.set.CatalogData.doCheckConstructionWarnings||null!==(h=this.set.CatalogData.forceConstructionWarningForArticles)&&void 0!==h&&h.includes(u.ArticleCodex)||null!==(P=this.set.CatalogData.forceConstructionWarningForArticles)&&void 0!==P&&P.includes(p.ArticleCodex))&&(D=m.Z.checkCollision(u,p,this.set.CatalogData.checkCollisionForDifferentLayers)),D&&(i=!0,c.push({elementId1:u.getElementId(),elementId2:p.getElementId()}),E.debug("Collision Found between element1: "+u.ElementId+"; and element2: "+p.ElementId),!t))break}}}if(this.collisionHandler.collisionDetected&&!i)null===(a=(o=this.collisionHandler).updatePlannerMsgContainer)||void 0===a||a.call(o,"COLLISION_MSG",!1,"WARNING","COLLISION_MSG",!1);else if(!this.collisionHandler.collisionDetected&&i){var k,I;null===(k=(I=this.collisionHandler).updatePlannerMsgContainer)||void 0===k||k.call(I,"COLLISION_MSG",!0,"WARNING","COLLISION_MSG",!1)}this.collisionHandler.collisionPairs=c,this.collisionHandler.collisionDetected=i}}},{key:"updateSetPosNr",value:function updateSetPosNr(t){for(var r=this.getAllPlannerElements(),a=0;a<r.length;a++){var o=r[a];o.SetPosNr=t+o.PosNr-1,this.set.setPosNr(o.ElementId,o.getPosNr())}for(var l=0;l<r.length;l++)r[l].IsAccessoire||this.set.giveAccNewPosNrByBasketId(r[l].getBasketId());return r.length}},{key:"updatePlannerTrans",value:function updatePlannerTrans(t,r,a,o,l,i,c){var d=this,u=!1;if(this.plannerElements.has(t)){var g=this.plannerElements.get(t);if(null==g||g.updateDeltaTrans(r,a,o,"END"==l,c),"START"==l){if(g){var h=["AVR","AVL"];g.IsDockedAccessoire&&(h=h.concat(["AVO","AVU","AVN","AVS","AVC"]));for(var P=v.Z.removeDockingPointRelationsByType(g,h),p=0;p<P.length;p++)u=this.set.onDockingChanged(g.ElementId,P[p],"UNDOCK")}}else if("END"==l){var m=v.Z.searchDockableElementsInArea(g,this.getAllPlannerElements(),i);null!=m&&m.size>0&&m.forEach((function(t,r){var a=d.plannerElements.get(t.targetDP.ElementId);a&&v.Z.tryDockElementDPToDP(g,a,t.sourceDP,t.targetDP)})),u=this.updateAllElementsWorldPos(t),this.updatePlannerPosNr(),this.updatePlannerBoundingBox()}}return u}},{key:"destroyPlanner",value:function destroyPlanner(){this.plannerElements.forEach((function(t,r){t.destroy()})),this.plannerElements.clear()}},{key:"saveSetPlanner",value:function saveSetPlanner(){var t=this;if(0==this.plannerElements.size)return null;var r=[];return this.plannerElements.forEach((function(a,o){for(var l=a.getDockingDockingPoints(),i=[],c=0;c<l.length;c++){var d,u={id:l[c].DpId,onID:l[c].OnElementId,onDPID:null===(d=l[c].OnDP)||void 0===d?void 0:d.DpId};i.push(u)}var g={elementID:a.getElementId(),basketID:t.set.getBasketId(a.getElementId()),CatalogCodex:t.set.getCatalogCodex(),Codex:t.set.getArticleCodex(a.getElementId()),posNr:a.PosNr,accNr:a.IsDockedAccessoire?a.AccessoirePosNr:void 0,x:a.WorldPosCenter.x,y:a.WorldPosCenter.y,z:a.WorldPosCenter.z,rot:a.RotDeg,width:a.Width?a.Width:-1,height:a.Height?a.Height:-1,depth:a.Depth?a.Depth:-1,DP:i};if(a.IsAccessoire){var h=t.set.getParentBasketIdOfElementId(a.getElementId());null!=h&&(g.AccessoireInitParams={RelatedToBasketID:h})}r.push(g)})),{setId:this.set.getSetId(),x:0,y:0,z:0,width:this.plannerBoundingBox.Size.x,height:this.plannerBoundingBox.Size.y,depth:this.plannerBoundingBox.Size.z,rot:0,elements:r}}},{key:"getPlannerId",value:function getPlannerId(){return this.plannerID}},{key:"getSetData",value:function getSetData(t,r,a,o){var l=this,i={ID:r?this.set.getSetId():"S1",H:"",x:0,y:0,z:0,w:0,ELE:[],Blob:this.set.CatalogData.supplierILN,Cat:this.set.getCatalogCodex()},c=this.set.getAlternateRenderInfo();c&&(i.AlternateImg=c),a&&(i.ShowDim=a),this.isIDM3DCat&&(i.IsIDM3D=!0,i.IDM3DCatCodex=this.IDM3DCatCodex,i.IDM3DEnvironment=this.IDM3DEnvironment),this.plannerElements.forEach((function(r,c){var d=l.set.getPlannerConfigData(c,o),u=d.config,g=[];if(d.accs&&d.accs.length>0)for(var h=0;h<d.accs.length;h++)l.plannerElements.has(d.accs[h])&&g.push("E"+d.accs[h]);if(!t||null!=u.Model){var p,m,D,v,k=l.set.getArticleByElementId(c),E={ID:"E"+c,Model:u.Model,x:-Math.round(100*r.WorldPosCenterIgnoreOLF.x)/100,y:Math.round(100*r.WorldPosCenterIgnoreOLF.y)/100,z:Math.round(100*r.WorldPosCenterIgnoreOLF.z)/100,PosPivot:"Center",w:Math.round(100*r.getRotDeg())/100,RotPivot:"Center",DP:r.getDockingPointJS3D(),MAT:u.MAT,MOVE:null!==(p=u.MOVE)&&void 0!==p?p:void 0,CFG:u.CFG,H:"",ACCs:g.length>0?g:void 0};if(a)E.TechSize={Width:null==r.Width||isNaN(r.Width)?null!==(m=null==k?void 0:k.width)&&void 0!==m?m:0:r.Width,Height:null==r.Height||isNaN(r.Height)?null!==(D=null==k?void 0:k.height)&&void 0!==D?D:0:r.Height,Depth:null==r.Depth||isNaN(r.Depth)?null!==(v=null==k?void 0:k.depth)&&void 0!==v?v:0:r.Depth};var I=(0,P.FB)(JSON.stringify(E));E.H=I,i.ELE.push(E)}var y=l.set.getShelfPlannerData(c);if(y)for(var x=0;x<y.length;x++){var A=y[x],C=l.set.getShelfPlannerConfigData(A.basketId).config,b=[];if(C.accs&&C.accs.length>0)for(var V=0;V<C.accs.length;V++)l.plannerElements.has(C.accs[V])&&b.push("E"+C.accs[V]);var S={ID:"E"+A.parentElementId+"."+A.gridId+"."+A.rh,H:"",Model:A.model,x:0,y:0,z:1,w:0,PosPivot:"Center",RotPivot:"Center",DP:"RH"+A.rh+":E"+A.parentElementId,GN:A.gridName,MAT:C.MAT,CFG:C.CFG,ACCs:b.length>0?b:void 0};I=(0,P.FB)(JSON.stringify(S));S.H=I,i.ELE.push(S)}}));var d=(0,P.FB)(JSON.stringify(i));return i.H=d,{constructionSet:i}}},{key:"getElementPosInfo",value:function getElementPosInfo(){var t={};return this.plannerElements.forEach((function(r,a){r.IsDockedAccessoire?t[a]={pos:r.PosNr,isAcc:!0,accPos:r.AccessoirePosNr}:t[a]={pos:r.PosNr,isAcc:!1}})),t}},{key:"getPlanningIsComplete",value:function getPlanningIsComplete(t){var r=this,a=!t&&(this.set.CatalogData.doHideCompletenessWarning||!this.set.CatalogData.doCheckConstructionWarnings),o=!1;return this.plannerElements.forEach((function(t,l){var i;(!a||null!==(i=r.set.CatalogData.forceConstructionWarningForArticles)&&void 0!==i&&i.includes(t.ArticleCodex))&&!o&&(t.getFreeDockingPointsByType("AVL").length>0||t.getFreeDockingPointsByType("AVR").length>0)&&(o=!0)})),!o}},{key:"getPlannerBoundingBox",value:function getPlannerBoundingBox(){var t=this.set.CatalogData,r=this.plannerBoundingBox.getWidth(t.PlannerMeasureDigits),a=this.plannerBoundingBox.getDepth(t.PlannerMeasureDigits),o=this.plannerBoundingBox.getHeight(t.PlannerMeasureDigits),l=this.plannerBoundingBox.getWidth(t.PlannerMeasureDigits,!0),i=this.plannerBoundingBox.getDepth(t.PlannerMeasureDigits,!0),c=this.plannerBoundingBox.getHeight(t.PlannerMeasureDigits,!0),d=l!==r||i!==a||c!==o;return{width:r,height:o,depth:a,widthIgnoreOLF:d?l:void 0,depthIgnoreOLF:d?i:void 0,heightIgnoreOLF:d?c:void 0}}},{key:"updatePlannerBoundingBox",value:function updatePlannerBoundingBox(){this.plannerBoundingBox.calcPlannerBoundingBox(this.getAllPlannerElements()),this.plannerBoundingBox.calcPlannerBoundingBoxIgnoreOLF(this.getAllPlannerElements())}},{key:"getCatalogData",value:function getCatalogData(){return this.set.CatalogData}},{key:"getAllPlannerElements",value:function getAllPlannerElements(){var t=[];return this.plannerElements.forEach((function(r,a){t.push(r)})),t}},{key:"getParentElement",value:function getParentElement(t){var r=void 0,a=t.getParentElementId();return a&&(r=this.plannerElements.get(a)),r}},{key:"getPositionOfPlannerElements",value:function getPositionOfPlannerElements(){var t=this.set.getSetId();this.plannerElements.forEach((function(r,a){E.log("SetID:",t),E.log("Elementid:",r.ElementId),E.log("X:",r.WorldPosCenter.x),E.log("Y:",r.WorldPosCenter.y),E.log("X:",r.WorldPosCenter.z),E.log("ROT:",r.RotDeg),E.log("___________________________")}))}},{key:"clonePlanner",value:function clonePlanner(t,r){return new DivaStandardPlanner(t,(function(){}),r,new k.Z,!0,!1)}},{key:"getPlannerInteractionInformation",value:function getPlannerInteractionInformation(){return E.error(new P.GE("The function getPlannerInteractionInformation is not implemented yet for standard planner. Dont call it or ask roadmap when its its turn",{code:"WC_0012"})),{boxPlannerInteractionInformationPerElement:new Map}}},{key:"getGeneralPlanningState",value:function getGeneralPlanningState(t){return E.error(new P.GE("The function getGeneralPlanningState is not implemented yet for standard planner. Dont call it or ask roadmap when its its turn",{code:"WC_0012"})),{grids:[]}}}]);var t,r,a,u,y,x,A,C,b}();(0,d.Z)(y,"plannerType","STD")},49134:(t,r,a)=>{a.d(r,{Z:()=>u});var o=a(13125),l=a(43860),i=a(89429),c=a(49736);function _superPropBase(t,r){for(;!{}.hasOwnProperty.call(t,r)&&null!==(t=(0,c.Z)(t)););return t}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,r,a){var o=_superPropBase(t,r);if(o){var l=Object.getOwnPropertyDescriptor(o,r);return l.get?l.get.call(arguments.length<3?t:a):l.value}},_get.apply(null,arguments)}var d=a(91870);function _callSuper(t,r,a){return r=(0,c.Z)(r),(0,i.Z)(t,_isNativeReflectConstruct()?Reflect.construct(r,a||[],(0,c.Z)(t).constructor):r.apply(t,a))}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}const u=new(function(t){function DockingPointHandler(){return(0,o.Z)(this,DockingPointHandler),_callSuper(this,DockingPointHandler,arguments)}return(0,d.Z)(DockingPointHandler,t),(0,l.Z)(DockingPointHandler,[{key:"initDockingPointsFromSvg",value:function initDockingPointsFromSvg(t,r,a,o){var l="minX"in a?a:{minX:a.svgMinXVal,minY:a.svgMinYVal};!function _superPropGet(t,r,a,o){var l=_get((0,c.Z)(1&o?t.prototype:t),r,a);return 2&o&&"function"==typeof l?function(t){return l.apply(a,t)}:l}(DockingPointHandler,"initDockingPointsFromSvg",this,3)([t,r,l,o])}}])}(a(50810).pD))},95212:(t,r,a)=>{a.d(r,{Z:()=>v});var o=a(84658),l=a(13125),i=a(43860),c=a(80248),d=a(50747),u=a.n(d),g=a(58129),h=a(49134),P=a(64357),p=a(27058),m=a(50810),D=p.ZP.initLog("Planner","WEB-PLANNER-LOGIC");const v=new(function(){return(0,i.Z)((function PlannerHandler2D(){(0,l.Z)(this,PlannerHandler2D),(0,c.Z)(this,"svgUtils",void 0),this.svgUtils=new g.Z}),[{key:"checkCollision",value:function checkCollision(t,r,a){if(p.ZP.startSpanOfApm("PlannerHandler2D checkCollision"),!(t.Layer==r.Layer||a.includes(Number(t.Layer))&&a.includes(Number(r.Layer))))return p.ZP.endSpanOfApm("PlannerHandler2D checkCollision"),!1;var o=t.getWorld2DBBoxOutline(),l=r.getWorld2DBBoxOutline();if((0,m.JU)(o,l)){if(!t.HasOLTPolygon&&!t.HasOLFPolygon)return D.error(new p.GE("checkCollision PlannerHandler2D - The element with id: "+t.getElementId()+" has no OLT AND no OLF",{code:"WC_0012"})),p.ZP.endSpanOfApm("PlannerHandler2D checkCollision"),!1;if(!r.HasOLTPolygon&&!r.HasOLFPolygon)return D.error(new p.GE("checkCollision PlannerHandler2D - The element with id: "+r.getElementId()+" has no OLT AND no OLF",{code:"WC_0012"})),p.ZP.endSpanOfApm("PlannerHandler2D checkCollision"),!1;var i=t.HasOLFPolygon?t.getOLFPolygonWorldPos():t.getOLTPolygonWorldPos(),c=r.HasOLFPolygon?r.getOLFPolygonWorldPos():r.getOLTPolygonWorldPos();return p.ZP.endSpanOfApm("PlannerHandler2D checkCollision"),(0,m.JU)(i,c)}return p.ZP.endSpanOfApm("PlannerHandler2D checkCollision"),(0,m.uA)(o,l)}},{key:"parseSvg",value:function parseSvg(t,r,a,o,l){var i,c;r=this.svgUtils.removeMaskFromSvg(r),h.Z.initDockingPointsFromSvg(t,this.svgUtils.getDPsInSVG(r),a,o);var d=this.svgUtils.getPointOfPoligonById(r,"OLT");null!=d&&d.length||D.warn("no olt fount in svg for element"+t.ArticleCodex+" with id "+t.getElementId()),t.OLTPolygon=d;var u=this.svgUtils.getPointOfPoligonById(r,"OLF"),g=(0,m.Qq)(r);if(null!=u&&u.length){var v,k,E=this.svgUtils.getBoundingBoxOfPoints(u),I=null!==(v=null==g?void 0:g.width)&&void 0!==v?v:E.width,y=null!==(k=null==g?void 0:g.height)&&void 0!==k?k:E.height;t.setupOLF(u,I,y)}else if(g){var x=[new P.FM(g.minX,g.minY),new P.FM(g.minX+g.width,g.minY),new P.FM(g.minX+g.width,g.minY+g.height),new P.FM(g.minX,g.minY+g.height)];t.setupOLF(x,g.width,g.height)}else null!=l&&l.heightOLF,null!=l&&l.widthOLF?t.setupOLF(u,null==l?void 0:l.widthOLF,null==l?void 0:l.heightOLF):t.clearOLF();var A=(0,m.hd)(r);if(t.OLTWidth=null!==(i=null==A?void 0:A.width)&&void 0!==i?i:0,t.OLTDepth=null!==(c=null==A?void 0:A.height)&&void 0!==c?c:0,t.OLTLeft=A&&g?A.x-g.minX:0,t.OLTTop=A&&g?A.y-g.minY:0,t.DoSetWidthFromSVG||t.DoSetDepthFromSVG){var C=(0,m.O3)(r);t.DoSetWidthFromSVG&&null!=C&&C.width&&(t.WidthFromSVG=C.width/p.ZP.UnitRecalc),t.DoSetDepthFromSVG&&null!=C&&C.height&&(t.DepthFromSVG=C.height/p.ZP.UnitRecalc)}t.SvgData=r,t.cleanShapeOLF2D(),t.cleanShapeOLT2D()}},{key:"getMinBorderSVG",value:function getMinBorderSVG(t){var r=(0,m.dI)(t);return{svgMinXVal:r.minX,svgMinYVal:r.minY}}},{key:"loadSVG",value:(t=(0,o.Z)(u().mark((function _callee(t,r){var a,o,l,i,c,d,g,h,P,m,v,k=this;return u().wrap((function _callee$(u){for(;;)switch(u.prev=u.next){case 0:if(o=t.SvgFileName){u.next=3;break}return u.abrupt("return",!1);case 3:if(!r.CatalogData.isIDMFormat){u.next=9;break}return u.next=6,r.api.fetchData(o,{method:"GET",config:{},data:{}});case 6:l=u.sent,u.next=16;break;case 9:return u.next=11,r.api.getDataCache(this.getSVGUrl(o,r.CatalogData.mediaUrl),void 0,r.CatalogData.accountSessionGuid);case 11:if(!(c=u.sent).Error){u.next=14;break}throw new Error(c.Error);case 14:"success"==c.Result.toLowerCase()&&(i=c.Content),l=p.ZP.decodeBase64(i);case 16:if(l||D.error(new p.GE("Fehler beim laden des SVGs ",{code:"WC_0009",custom:{svgFile:o}})),t.svgBefore=l,d=t.DoSetWidthFromSVG?void 0:t.Width,null==(g=t.DoSetDepthFromSVG?void 0:t.Depth)&&null!=d&&(null!==(a=t.Height)&&void 0!==a?a:-1)>0&&(g=t.Height),!(r.CatalogData.isIDMFormat?null!=d||null!=g:null!=d&&null!=g)){u.next=32;break}return P=this.getMinBorderSVG(l),m=r.CatalogData.isIDMFormat?o:"".concat(r.CatalogData.mediaUrl,"pln_").concat(o),v="",u.next=28,new Promise((function(t,a){var o;h=k.svgUtils.ccCheckStretchAreas(l,null!=d?d:0,null!==(o=g)&&void 0!==o?o:0,r.CatalogData.useGlobalSVGScale,P.svgMinXVal,P.svgMinYVal,(function(r){v=r,t()}),m,{width:null==d,depth:null==g})}));case 28:t.svgAfter=v,this.parseSvg(t,v,P,r.CatalogData.getPlannerConfig(),h),u.next=34;break;case 32:t.svgAfter=l,this.parseSvg(t,l,{svgMinXVal:0,svgMinYVal:0},r.CatalogData.getPlannerConfig());case 34:return u.abrupt("return",!0);case 35:case"end":return u.stop()}}),_callee,this)}))),function loadSVG(r,a){return t.apply(this,arguments)})},{key:"getSVGUrl",value:function getSVGUrl(t,r){var a=r+"pln_"+t,o=a.indexOf("/files/");return a=a.substring(o),"function=GetFileAsString&fileUrl="+encodeURIComponent(a)}}]);var t}())}}]);
|