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EAAKC,MAAOA,MAG1C,IAAKrD,EAAS0D,GAEZ,OADAhF,QAAQU,MAAM,gCAAgCY,EAAS2D,eAChD,EAGT,MAAMC,QAAe5D,EAAS6D,OAC9B,MAAsB,YAAlBD,EAAO1D,SAGTxB,QAAQU,MAAM,iBAAiBwE,EAAO5E,YAC/B,EAEX,CAAE,MAAOI,GAEP,OADAV,QAAQU,MAAM,6BAA8BA,IACrC,CACT,CACF,C","sources":["webpack://app/./app/javascript/packs/application.js"],"sourcesContent":["/* eslint no-console:0 */\n// This file is automatically compiled by Webpack, along with any other files\n// present in this directory. You're encouraged to place your actual application logic in\n// a relevant structure within app/javascript and only use these pack files to reference\n// that code so it'll be compiled.\n//\n// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate\n// layout file, like app/views/layouts/application.html.erb\n\n// Uncomment to copy all static images under ./images to the output folder and reference\n// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)\n// or the `imagePath` JavaScript helper below.\n//\n// const images = require.context('./images', true)\n// const imagePath = (name) => images(name, true)\n\n\nimport './application-bundle'\nimport * as bootstrap from 'bootstrap';\nimport html2canvas from 'html2canvas';\nimport Rails from '@rails/ujs'; // Import the rails-ujs library\nRails.start(); // Initialize rails-ujs\n\n$(document).ready(function() {\n $(\".dropdown-toggle\").dropdown();\n});\nwindow.html2canvas = html2canvas;\n$(function () {\n $('[data-toggle=\"tooltip\"]').tooltip()\n});\n\n\ndocument.addEventListener('turbo:load', () => {\n console.log('Turbo has loaded the page!');\n});\ndocument.addEventListener('turbo:before-stream-render', () => {\n console.log('Before stream render!');\n });\n \n document.addEventListener('turbo:stream-render', () => {\n console.log('Stream rendered!');\n });\ndocument.addEventListener('turbo:render', () => {\n console.log('Turbo has rendered the page!');\n \n });\nTurbo.session.drive = true;\n\n\nwindow.onerror = function(message, source, lineno, colno, error) {\n // Prepare error data\n var errorData = {\n message: message,\n source: 'web',\n backtrace: error ? error.stack : null\n };\n\n // Send error data to backend\n $.ajax({\n url: '/errors',\n type: 'POST',\n data: JSON.stringify(errorData),\n contentType: 'application/json',\n success: function(response) {\n console.log('Error sent to backend successfully.');\n },\n error: function(xhr, status, error) {\n console.error('Error sending error to backend:', error);\n }\n });\n};\n// TODO: find a better way to do this. Since color palette is loaded dynamically as html in chat session importing using content_for doesn't work.\nwindow.copyHexCode = function copyHexCode(hex, element) {\n navigator.clipboard.writeText(hex).then(\n () => {\n // Show a temporary \"Copied!\" message\n const successMessage = document.createElement('span');\n successMessage.innerText = 'Copied!';\n successMessage.style.color = 'green';\n successMessage.style.fontSize = '0.75em';\n successMessage.style.marginLeft = '10px';\n\n element.appendChild(successMessage);\n\n // Remove the message after a short delay\n setTimeout(() => successMessage.remove(), 2000);\n },\n (err) => console.error(\"Failed to copy text: \", err)\n );\n}\n\ndocument.addEventListener(\"DOMContentLoaded\", () => {\n // Function to add copy button to a code block\n function addCopyButton(block) {\n // Check if a copy button is already added to avoid duplicates\n if (block.querySelector(\"button\")) return;\n\n // Create the copy button\n const copyButton = document.createElement(\"button\");\n copyButton.innerText = \"Copy\";\n copyButton.className = \"tw-absolute tw-top-2 tw-right-2 tw-bg-gray-500 tw-text-white tw-py-1 tw-px-2 tw-rounded tw-text-xs hover:tw-bg-gray-700 tw-transition tw-duration-200\";\n\n // Add the copy functionality\n copyButton.addEventListener(\"click\", async () => {\n // Get the inner text of the element inside the
\n      let code = block.querySelector(\"code\")?.innerText;\n      // the hex is replaced with span to display color. Because of that it adds new line. Remove it before coping.\n      code = code.replace(/\\n(?=#([0-9A-Fa-f]{6}))/g, \"\");\n      if (!code) return;\n\n      try {\n        await navigator.clipboard.writeText(code);\n        copyButton.innerText = \"Copied!\";\n        setTimeout(() => {\n          copyButton.innerText = \"Copy\";\n        }, 1500);\n      } catch (err) {\n        console.error(\"Failed to copy text: \", err);\n      }\n    });\n    block.classList.add(\"tw-relative\", \"tw-p-4\", \"tw-bg-gray-800\", \"tw-rounded\");\n    block.appendChild(copyButton);\n  }\n  const codeBlocks = document.querySelectorAll(\"pre\");\n  codeBlocks.forEach(addCopyButton);\n\n  // Use MutationObserver to add copy button to dynamically added code blocks\n  const observer = new MutationObserver((mutations) => {\n    mutations.forEach((mutation) => {\n      mutation.addedNodes.forEach((node) => {\n        if (node.nodeName === \"PRE\") {\n          addCopyButton(node);\n        } else if (node.querySelectorAll) {\n          node.querySelectorAll(\"pre\").forEach(addCopyButton);\n        }\n      });\n    });\n  });\n  observer.observe(document.body, { childList: true, subtree: true });\n});\nwindow.shareColorPalette = function sharePalette(event, url) {\n  event.preventDefault();\n\n  // Check if the browser supports the Web Share API\n  if (navigator.share) {\n      navigator.share({\n          title: 'Check out this color palette!',\n          text: 'Here’s a color palette you might like:',\n          url: url,\n      })\n      .then(() => console.log('Successfully shared'))\n      .catch((error) => console.error('Something went wrong sharing:', error));\n  } else {\n      // Fallback: Copy the URL to the clipboard\n      navigator.clipboard.writeText(url)\n          .then(() => alert('Link copied to clipboard!'))\n          .catch(() => alert('Failed to copy link to clipboard.'));\n  }\n}\n\nwindow.saveSessionData = async function saveSessionData(key, value) {\n  try {\n    const response = await fetch('/save_session_data', {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n        'X-CSRF-Token': document.querySelector('meta[name=\"csrf-token\"]').content,\n      },\n      body: JSON.stringify({ key: key, value: value }),\n    });\n\n    if (!response.ok) {\n      console.error(`Failed to save session data: ${response.statusText}`);\n      return false;\n    }\n\n    const result = await response.json();\n    if (result.status === 'success') {\n      return true;\n    } else {\n      console.error(`Server error: ${result.message}`);\n      return false;\n    }\n  } catch (error) {\n    console.error(\"Error saving session data:\", error);\n    return false;\n  }\n}"],"names":["Rails","start","$","document","ready","dropdown","window","html2canvas","tooltip","addEventListener","console","log","Turbo","session","drive","onerror","message","source","lineno","colno","error","errorData","backtrace","stack","ajax","url","type","data","JSON","stringify","contentType","success","response","xhr","status","copyHexCode","hex","element","navigator","clipboard","writeText","then","successMessage","createElement","innerText","style","color","fontSize","marginLeft","appendChild","setTimeout","remove","err","addCopyButton","block","querySelector","copyButton","className","async","code","replace","classList","add","querySelectorAll","forEach","MutationObserver","mutations","mutation","addedNodes","node","nodeName","observe","body","childList","subtree","shareColorPalette","event","preventDefault","share","title","text","catch","alert","saveSessionData","key","value","fetch","method","headers","content","ok","statusText","result","json"],"sourceRoot":""}