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,CAAC,oBAAoB,IAAM;;ADjHpD","sources":["app/assets/lookbook/js/lookbook-core.js","app/assets/lookbook/js/lib/lookbook.js"],"sourcesContent":["import \"./lib/lookbook\";\n","window.Lookbook = window.Lookbook || {};\nwindow.Lookbook.initEmbeds = initEmbeds;\n\nconst embedUrlPrefix = \"embed\";\nconst whiteListedAttributes = [\n \"preview\",\n \"scenario\",\n \"panels\",\n \"actions\",\n \"param-*\",\n];\n\nfunction initEmbeds() {\n if (typeof window.iFrameResize !== \"function\") {\n console.error(\n \"Lookbook embeds require the 'iframe-resizer' library to be available. Skipping embed instantiation.\"\n );\n return;\n }\n\n const embeds = Array.from(document.querySelectorAll(\"lookbook-embed\"));\n\n embeds.forEach((embed) => {\n const attrs = Array.from(embed.attributes);\n const wrapper = createWrapper();\n const iframe = createIframe(attrs);\n\n wrapper.appendChild(iframe);\n embed.replaceWith(wrapper);\n });\n\n window.iFrameResize({ checkOrigin: false }, \"[data-lookbook-embed-iframe]\");\n}\n\nfunction createWrapper() {\n const wrapper = document.createElement(\"div\");\n\n wrapper.setAttribute(\"data-lookbook-embed\", true);\n wrapper.classList.add(\"lookbook-embed\");\n\n return wrapper;\n}\n\nfunction createIframe(attrs) {\n const src = buildSrc(attrs);\n const id = attrValue(attrs, \"id\");\n const styles = attrValue(attrs, \"style\");\n const classes = attrValue(attrs, \"class\", \"\")\n .split(\" \")\n .map((c) => c.trim())\n .filter((c) => c.length);\n\n const iframe = document.createElement(\"iframe\");\n iframe.src = src;\n if (id) iframe.id = id;\n\n iframe.setAttribute(\"frameborder\", 0);\n iframe.setAttribute(\"data-lookbook-embed-iframe\", true);\n\n if (classes.length) iframe.classList.add(...classes);\n if (styles) iframe.style.cssText = styles;\n\n iframe.style.width = \"100%\";\n iframe.style.transition = \"height 0.3s\";\n\n return iframe;\n}\n\nfunction buildSrc(attrs) {\n const appPath = attrValue(attrs, \"app\") || guessBasePath();\n const props = {};\n\n permittedAttrs(attrs).forEach(({ name, value }) => {\n console.log(name, value);\n name = name.replace(\"-\", \"_\").toLowerCase();\n props[name] = value;\n });\n\n return encodeURI(\n [appPath, embedUrlPrefix].join(\"/\") + `?props=${JSON.stringify(props)}`\n );\n}\n\nfunction attrValue(attrs, name, fallback = null) {\n const attr = attrs.find((attr) => attr.name === name);\n return attr ? attr.value : fallback;\n}\n\nfunction permittedAttrs(attrs) {\n return attrs.filter((attr) => {\n return whiteListedAttributes.find((key) => {\n const name = attr.name;\n return (\n key === name ||\n (key.includes(\"*\") && name.startsWith(key.replace(\"*\", \"\")))\n );\n });\n });\n}\n\nfunction guessBasePath() {\n const script =\n document.currentScript ||\n document.querySelector('script[src*=\"lookbook.js\"]');\n const scriptSrc = script.src;\n\n if (scriptSrc && scriptSrc.includes(\"lookbook-assets\")) {\n return scriptSrc.replace(\"lookbook-assets/js/lookbook.js\", \"lookbook\");\n }\n\n return `//${location.host}/lookbook`;\n}\n\ndocument.addEventListener(\"DOMContentLoaded\", () => initEmbeds());\n"],"names":[],"version":3,"file":"lookbook-core.js.map"}