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AAkB,YACtBf,EAAW,KAAQ,KAE3BG,EAAoBL,EAAOC,GAC3BD,EAAMU,MAAMM,UAAY,cAAchB,EAAMW,mBAAmBT,QAC/DF,EAAMU,MAAMO,gBAAkB,aAE9BjB,EAAMU,MAAMM,UAAY,UAAUd,QAClCF,EAAMU,MAAMO,gBAAkB,SAC9BjB,EAAMU,MAAMC,MAAQ,OACpBX,EAAMU,MAAME,OAAS,QAIzBZ,EAAMI,QAAQF,SAAWA,CAC7B,GACJ,CD9CEgB,EACF,G","sources":["webpack://app/./app/javascript/hub/MainMenuComponent.js","webpack://app/./app/javascript/packs/hub.js","webpack://app/./app/javascript/hub/image_rotate.js"],"sourcesContent":["export default function MainMenuComponent() {\n const mainMenu = document.querySelector('[data-component=\"MainMenuComponent\"]');\n highlightSelectedPageNavigation(mainMenu);\n toggleSidebarExpandCollapse(mainMenu);\n}\n\nfunction highlightSelectedPageNavigation(mainMenu) {\n mainMenu.querySelectorAll('.menu-item').forEach((item) => {\n if (item.href === window.location.href) {\n item.classList.toggle('selected');\n }\n });\n}\n\nfunction toggleSidebarExpandCollapse(mainMenu) {\n mainMenu.querySelector('.toggle').addEventListener(\"click\", () => {\n const classes = mainMenu.classList;\n classes.toggle(\"collapsed\");\n\n if (classes.contains(\"collapsed\")) {\n document.cookie = \"sidebar=collapsed\";\n } else {\n document.cookie = \"sidebar=\";\n }\n });\n}\n","// See `app/javascript/hub/README.md`\nimport MainMenuComponent from \"../hub/MainMenuComponent\";\nimport imageRotate from \"../hub/image_rotate\";\n\nwindow.addEventListener(\"load\", function() {\n MainMenuComponent();\n imageRotate();\n})\n","export default function imageRotate() {\n const rotateButton = document.getElementById(\"rotate-button\");\n let rotationAngle = document.getElementById(\"rotation-angle\");\n\n if(!rotateButton) {\n return\n }\n\n rotateButton.addEventListener(\"click\", function(e) {\n e.preventDefault();\n // Get the image element\n const image = document.getElementById(\"image\");\n const container = document.getElementById(\"image-container\");\n\n // Increment the rotation angle by 90 degrees\n let rotation = parseInt(image.dataset.rotation, 10);\n rotation += 90;\n rotationAngle.value = rotation;\n\n function fitImageForRotation(image, container) {\n if (image.naturalWidth < image.naturalHeight) {\n let newHeight = container.offsetWidth < image.naturalHeight ? `${container.offsetWidth}px` : 'auto';\n image.style.width = `auto`;\n image.style.height = newHeight;\n } else {\n let newWidth = container.offsetHeight < image.naturalWidth ? `${container.offsetHeight}px` : 'auto';\n image.style.width = newWidth;\n image.style.height = `auto`;\n }\n }\n\n // // Apply the rotation using CSS transform\n if ((rotation % 360) == 90) {\n // For a 90 degree rotation, choose top left rotation corner, push left by the image's height (which becomes its width after rotation), rotate\n fitImageForRotation(image, container);\n image.style.transform = `translateX(${image.height}px) rotate(${rotation}deg)`;\n image.style.transformOrigin = `top left`;\n } else if ((rotation % 360) == 270) {\n // For a 270 degree rotation, choose top left rotation corner, push down by the image's width (which becomes its height after rotation), rotate\n fitImageForRotation(image, container);\n image.style.transform = `translateY(${image.width}px) rotate(${rotation}deg)`;\n image.style.transformOrigin = `top left`;\n } else {\n image.style.transform = `rotate(${rotation}deg)`;\n image.style.transformOrigin = `center`;\n image.style.width = 'auto';\n image.style.height = 'auto';\n }\n\n // Update the rotation angle in the dataset attribute\n image.dataset.rotation = rotation;\n });\n};"],"names":["MainMenuComponent","mainMenu","document","querySelector","querySelectorAll","forEach","item","href","window","location","classList","toggle","highlightSelectedPageNavigation","addEventListener","classes","contains","cookie","toggleSidebarExpandCollapse","rotateButton","getElementById","rotationAngle","e","preventDefault","image","container","rotation","parseInt","dataset","fitImageForRotation","naturalWidth","naturalHeight","newHeight","offsetWidth","style","width","height","newWidth","offsetHeight","value","transform","transformOrigin","imageRotate"],"sourceRoot":""}