ByKatja Vujić,
a social media editor at the Cut.She also writes about culture, sustainability, news, wellness, and style.
Photo: Guido Mieth/Getty Images
Lucid dreaming can be a divisive topic among sleep and dream experts — like author and dream analysis expert Dr. Jean Benedict Raffa, who says, “My personal goal has not been to lucid dream — I’m more interested in how conscious I am when I’m awake, how self-aware I am and how much I know what’s happening inside of me.”
Similarly, Em Hexe, a dreamworker and tarot reader, was initially resistant to the practice. “I was under the impression that it would mean I would be controlling my dreams,” they explain. “Whenever I’m lucid dreaming, I’m already within a dream that I didn’t decide upon. My concern was that, by controlling my dreams, I wouldn’t be allowing my subconscious to do the things that it needed to do.”
But as Hexe sees it now, lucid dreaming can be more about respectfully and consciously exploring the dreamscape rather than immediately changing it dramatically. So what actually is lucid dreaming? Can you teach yourself to do it? Should you? Read on for our everything guide to this dream practice.
What is lucid dreaming?
A relatively self-explanatory term, lucid dreaming is exactly what it sounds like: It’s when you are lucid while dreaming. The term implies some level of consciousness or awareness while dreaming. “Most of us use the term to mean, ‘A dream where you know you’re dreaming while you’re dreaming,’” says Dr. Deirdre Barrett, a Harvard lecturer, hypnotherapist, and the editor-in-chief of the journal Dreaming. “There are a few researchers who add on criteria to that, to say that you have to have some degree of control over the content or just want to define the state as especially heightened awareness in a few other ways. Most of us consider those to be things that can accompany lucid dreams, but that the definition of a lucid dream itself is just that you know you’re dreaming at some point in the dream.”
And what is “dream recall”?
Dream recall — your ability to remember your dreams — is a necessary prerequisite for lucid dreaming. Nearly every expert I spoke to said that the first step to building a lucid-dreaming practice is actually to develop a deeper relationship with your regular dreams, the ones that happen every night without your input. Whether you wake up with no memory of what you dreamed about whatsoever or already can recollect bits and pieces, it’s a good idea to start keeping a dream journal. “Allow the experience of your night to wash over you, then open up your phone or a dream journal, whatever works for you, and write down anything you remember — anything,” recommends Samantha Fey, author of The Awake Dreamer: Lucid Dreaming, Astral Travel and Mastering the Dreamscape. “‘I slept well. I slept like crap. I woke up two times. Woke up with this song running through my head. Thought of my friend Amy.’ Whatever you remember. And if you remember nothing, write, ‘I remember nothing.’ The more you do that, the more you’re going to increase your dream recall. After a while of learning to remember your dreams, it does greatly enhance your chances of spontaneous lucid dreaming.”
There are also some techniques you can use to improve your recall. “When you wake up in the morning, it’s essential that you do not move,” advises Hexe. “Don’t try to turn over; there’s so much that’s somatically connected to your dreams. Get into the habit of saying, ‘What was I just thinking about?’ Sometimes all you’ll get is one little snippet or image. I believe that dreams are actually very excited to be in conversation with us. As soon as you start paying attention, the muscle just begins to flex.”
Are lucid dreams dangerous?
Dream analyst, researcher, and author Jane Teresa Anderson says lucid dreaming can be a “profoundly and amazingly exciting” perspective-opening endeavor, because after experiencing your dream consciousness and your waking consciousness simultaneously, you might wake up from a lucid dream with a loosened view of reality. “Spiritually, emotionally, mentally, it opens up questions,” says Anderson. But although it can feel truly delightful, she cautions against an overly frequent lucid-dreaming practice. “The purpose of dreams is to process your experiences, to update your mind-set and make better sense of your world,” says Anderson. “If you lucid dream and you interrupt that process by taking control, you’re stopping the natural process that you need to have to be emotionally and spiritually secure. People who aim for lucid dreaming every night of the week are in danger of losing that mental and emotional stability, and indeed losing the benefits of allowing normal and natural dreaming.”
Amanda Takuapu, a Guarani spiritual practitioner and apprentice to the Tupi-Guarani traditions, says that above all, you should be extremely clear on why you want to lucid dream. “People should ask themselves, ‘Why is it that I want to control my dreams?’ Some people think that it might give them stronger spiritual practices. Some people want to seek meaning in something outside the material world. Others might feel desperate for answers, and feel ‘This is how I can get them.’ When you get to the root of what your ‘why’ is, a lot of the time it’s more self-serving.”
Although the Tupi-Guarani people deeply value dreams and incorporate conversation about dreams into the fabric of daily life, Takuapu says that for the most part, they don’t practice lucid dreaming. “Overall, we don’t believe in lucid dreaming or controlling our dreams, because we respect those territories the same way that we would respect going into a forest of another tribe,” she says. “We respect all territories; we don’t want to invade territories. We might be asking for prayers or seeking some kind of answer that might be available to us in the dreamscape, but we’re not seeking to control an outcome or result.”
Still, no one is saying that you shouldn’t lucid dream; some people experience lucid dreams without ever even intending to. And even if you are making an intentional choice, it could be that the practice is emotionally, intellectually, or spiritually fulfilling. It’s just important to understand why you’re doing it. For Hexe, lucid dreaming has been a meaningful spiritual practice. “I became really fascinated with lucid dreams for their potential to support creativity and to heal,” says Hexe. “There’s only so much you can control within a lucid dream because the framework of the dream has already been laid out for you. I think it is a disservice to the deeper spiritual work to go in and think that you have control. The experiences of lucid dreaming that have felt the most meaningful are when I go in with an open mind and allow myself to be in co-creation with what the dream has to offer. If you’re a guest in this space, and you’re lucid in that space, then what can you do to fold yourself into it in a way that honors what is happening?”
So how do I lucid dream?
Nothing is 100 percent guaranteed to trigger lucid dreaming; some lucid dreamers experience it completely spontaneously, while others use their own tried-and-true personal methods. But there are ways to prepare both your physical space and your mental space to encourage lucidity while you sleep. Every expert I spoke to recommended general good sleep hygiene, like having a clean, dark environment to sleep in; avoiding any stimulants (think: caffeine, alcohol) for at least three hours before bed; and keeping electronics out of the room. Fey says fluctuating temperatures can be beneficial; she recommends taking a hot shower or bath before bed. She also says drinking water before bed can be helpful, because it could cause you to be woken up by your bladder’s needs in the middle of the night, allowing you to enter a semi-lucid state as you’re falling back asleep.
Hexe explains that like all dreaming, lucid dreaming mostly occurs during the deepest REM stage of your sleep cycle. “If you wake up at four in the morning, walk around or meditate for 40 minutes, and then go back to sleep, you’re more likely to have a lucid dream toward the end of your last REM cycle,” says Hexe. “That’s one way that people will ‘hack’ lucid dreaming.”
“Most people tend to fall asleep thinking about the day that they’ve just had, and they tend to think about what’s coming up,” says Athena Laz, author of The Alchemy of Your Dreams. “A really good sleep-hygiene practice, especially if you’re trying to lucid dream, is to clear up that sort of automatic behavior.” Dr. Anderson suggests a literal clearing of your thoughts before bedtime: “I often suggest having an actual piece of paper and a pen — nothing digital — by your bed and writing down a list of things that can be saved for tomorrow, like work projects. It’s like a list of things I don’t need to dream about.” She also says you can try visualizing what you’d like to dream about as you fall asleep, and name the intention to lucid dream. The important thing, she says, is to have an intentional ritual.
It’s not just about what you do before bed, though. “A lot of studies have shown that what you do during the day impacts your ability to lucid dream,” says Fey. “If you have any time in your day where you can do something creative that fires your right brain, that’s going to help a lot.” She also says that reducing stress wherever possible can help. “We release a lot of cortisol when we sleep,” says Fey. “It’s the brain’s way of dumping excess stress. If you’re stressed out during the day, you’re building up more cortisol, which means your brain is going to be so busy dumping it all that you’re not going to remember your dream, never mind have a lucid dream.”
“Any practice with lucid dreaming is just conditioning the mind to believe that it is possible,” says Laz. She recommends priming your psyche throughout the day, ahead of bedtime, to expect a lucid-dreaming experience. “You’re going to say to yourself, whilst you’re doing your chores or whatever, ‘I’m going to have a lucid dream tonight and I’m going to remember.’ You say it over and over and you repeat it as many times as you can in the day.”
What is dream alchemy, and how is it connected?
According to Dr. Anderson, dream alchemy is a practice you can do with your dreams to overcome or resolve a conflict. Let’s say you’ve had a bad dream, or you’re dealing with a recurring nightmare. Once you’ve woken up, says Dr. Anderson, you can close your eyes, put yourself back into the dream scenario, and make a different choice. If, for example, you dreamed that you were about to jump off a cliff, you can imagine yourself back there — and then decide to turn around and go back. “You’re using the language that your unconscious mind spoke to you in,” explains Dr. Anderson. “It said, ‘Your life is a cliff edge,’ and you’re saying, ‘Actually, it’s not. I have all these choices.’ You really take yourself by surprise by responding differently in a situation or noticing other alternatives. It does wonders to reprogram and overcome self-doubt and fears.” This is most often achieved through mental visualization but can also be done in writing, or even with movement, but the core process of rewriting the story remains.
So what does this have to do with lucid dreaming, exactly? Well, says Dr. Anderson, dream alchemy can help prepare you for lucid dreaming. “The more you practice visualizing something, particularly a dream alchemy, the better you become at playing with dream images,” she explains.
Can you force a lucid dream?
Short answer: no. You might try for years and never experience a lucid dream. However, there are several popular and expert-recommended techniques you can try to increase your chances, in addition to the prepwork from the previous section. One of the most common methods is called “reality testing.” There are several variations; one of the most common is to tie a string around your wrist and to consciously look down at your wrist throughout the day, notice the string, and remind yourself that you’re awake. Then when you’re asleep, you might look down at your wrist and notice the string isn’t there, which could alert you to the fact that you’re dreaming.
One of Laz’s favorite methods is another form of reality testing. “As you walk throughout the day, you push on something very concrete, like a wall or table,” she explains. “Every time you see a wall, you push it and you just ask yourself, ‘Is this a dream? Am I dreaming?’ It seeps into the subconscious and that thought naturally arises in the dream, and you might find yourself looking at a wall or a table and you try to put your hand on it, and it often will change shape or color, or you’re all of a sudden in a different space. So then you know you’re dreaming.”
Laz also favors something she calls “all-day awareness,” which is a practice of hypermindfulness. It involves paying extremely close attention to details and mentally pointing them out to yourself as you go about your day. For example, when you have a conversation with someone, you might take note of the colors of their clothing, the warm or cold weather, the shape of the trees nearby. “You begin to really pay attention,” says Laz. “That creates a strong awareness within you, and lucidity is really about awareness. I say to people, if you can do that practice for 21 days, it can radically shift how you think about things. You’re trying to pay attention to your surroundings more than your thinking mind, and then the lucid dreaming naturally should arise because you’ve primed yourself to be aware.”
Our Experts:
Em Hexeis a dreamworker and tarot reader who has studied alchemical dreamwork, somatic dreamwork, and their own lifelong vivid dreams. Hexe has served on the ethics committee for the International Association for the Study of Dreams since 2018.
Jane Teresa Andersonis a dream analyst. She has been researching dreams since 1992 and is the author of seven books on the subject. Her most recent, Bird of Paradise: Taming the Unconscious to Bring Your Dreams to Fruition, was published in May 2020. She also hosts The Dream Show With Jane Teresa Anderson, a podcast where she analyzes guests’ dreams and shares dream-interpretation guidance.
Amanda Takuapuis a Guarani spiritual practitioner from Paraguay and an apprentice to the Tupi-Guarani traditions. She also co-hosts online workshops and courses with Indigenous leaders and medicine practitioners.
Athena Lazis the author of The Alchemy of Your Dreams and The Deliberate Dreamer’s Journal. She is a psychologist, a dream teacher specializing in lucid dreams, and a spiritual mentor.
By submitting your email, you agree to our
Terms and Privacy Notice
and to receive email correspondence from us. This site is protected by reCAPTCHA and the Google
Privacy Policy and
Terms of Service apply.
or
Already a subscriber?
What is your email?
This email will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
Password must be at least 8 characters and contain:
Lower case letters (a-z)
Upper case letters (A-Z)
Numbers (0-9)
Special Characters (!@#$%^&*)
This password will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
You’re in!
As part of your account, you’ll receive occasional updates and offers from New York, which you can opt out of anytime.
or
Already a subscriber?
What is your email?
This email will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
Password must be at least 8 characters and contain:
Lower case letters (a-z)
Upper case letters (A-Z)
Numbers (0-9)
Special Characters (!@#$%^&*)
This password will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
You’re in!
As part of your account, you’ll receive occasional updates and offers from New York, which you can opt out of anytime.
Already a subscriber?
Already a subscriber?
`;
// integrate Sub(x) scripts and elements
if (hostname !== 'subs.nymag.com') { // do not integrate on this subdomain
document.head.appendChild(trackingScript);
document.body.insertAdjacentHTML('beforeend', subXAnimationElements);
}
There was an error processing the request. Please try again later."}).catch(e=>console.error("Error verifying email: ",e)))(r.querySelector(".content"),o.bannerCTAVerification)})):(l.remove(),s.remove()),o.dismissable||n.remove(),o.useAlertIcon||a.remove(),r.classList.add("show"),n.addEventListener("click",()=>{u(),r.classList.remove("show")})}else r.remove()}});
}, {"3":3,"6":6,"17":17,"35":35,"40":40}];
window.modules["global-nav.client"] = [function(require,module,exports){"use strict";const dom=require(4),auth=require(17),signInButton=dom.find(".user-signin"),signOutButton=dom.find(".user-signout"),globalNav=dom.find('[class^="global-nav"]'),body=dom.find("body"),dropdownItems=dom.findAll(".dropdown-wrap"),gtm=require(3),appendLandingPageParams=require(135),pageUri=require(124).getPageUri(),subscriptionPromoLinks=dom.findAll(".persist-params"),searchString=window.location.search||"";function closeDropdowns(e){let n=globalNav.querySelectorAll(".dropdown.open");dropdownItems.forEach(function(t){let i=t.querySelector(".dropdown");!n||t.contains(e.target)&&27!==e.keyCode||i.classList.remove("open")})}function gtmSendReport(e,n,t){let i={eventCategory:"ecommerce",eventAction:"componentClick",brand:e,dimension23:"global-nav",list:pageUri,pageZone:"header",variant:"nav-link"};"global-nav-link"===t&&(i.eventLabel=n.href),gtm.reportNow(i)}function updateElementTargetUrlsIfQueryStrings(e){if(searchString){const n=new URLSearchParams(searchString);let t=e.href;if(t.includes("?")){const i=t.split("?"),o=new URLSearchParams(i[1]);for(let e of n.entries())o.set(e[0],e[1]);t=`${i[0]}?${o.toString()}`,e.href=t}else e.href=`${t}?${n.toString()}`}}function init(e){const n=e.querySelectorAll(".to-landing-page");window.addEventListener("auth:init",()=>{signInButton.addEventListener("click",function(e){e.preventDefault(),auth.showEmbeddedLoginFlow("top navigation")}),signOutButton.addEventListener("click",function(e){e.preventDefault(),gtmSendReport("Sign Out",e.target,"user-info-link"),auth.logout()}),auth.isAuthenticated()&&e.classList.add("signed-in"),(auth.isSubscriber()||auth.isMobileAppRequest())&&e.classList.add("subscribed"),e.querySelectorAll(".user-link").forEach(e=>{e.classList.add("active")}),subscriptionPromoLinks.forEach(e=>{updateElementTargetUrlsIfQueryStrings(e)}),appendLandingPageParams(n)})}dropdownItems.forEach(function(e){e.addEventListener("click",function(){e.querySelector(".dropdown").classList.toggle("open")})}),body.addEventListener("click",closeDropdowns),document.addEventListener("keydown",closeDropdowns),globalNav.addEventListener("click",function(e){let n=e.target;n.classList.contains("global-nav-track")&>mSendReport(n.text,n,"global-nav-link")}),module.exports=init;
}, {"3":3,"4":4,"17":17,"124":124,"135":135}];
window.modules["aaa-module-mounting.legacy"] = [function(require,module,exports){"use strict";const _pickBy=require(221),_each=require(406),Fingerprint2=require(408),DS=require(407),Eventify=require(246);function registerGlobals(){window.DS=DS,window.Eventify=Eventify,window.Fingerprint2=Fingerprint2,DS.value("Eventify",Eventify),DS.value("Fingerprint2",Fingerprint2),DS.value("$document",window.document),DS.value("$window",window)}function mountDollarSliceComponents(){DS.service("components",["$document","$module",function(e,n){var o=_pickBy(n.definitions,e=>e.providerStrategy===n.providers.controller),r=Object.keys(o);function t(e){return o=>{try{n.get(e,o)}catch(e){logMountError(o,e)}}}_each(r,n=>{var o=e.querySelectorAll('[data-uri*="/_components/'+n+'/"]'),r=e.querySelectorAll('[data-uri$="/_components/'+n+'"]');_each(o,t(n)),_each(r,t(n))}),this.components=r}]),DS.get("components")}function logMountError(e,n){const o=e.outerHTML.slice(0,e.outerHTML.indexOf(e.innerHTML));console.error("Error attaching controller to "+o,n)}registerGlobals(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{mountDollarSliceComponents()}):mountDollarSliceComponents();
}, {"221":221,"246":246,"406":406,"407":407,"408":408}];
window.modules["ads.legacy"] = [function(require,module,exports){"use strict";const _map=require(118),_forEach=require(107),_isString=require(268),_intersectionWith=require(409),_isEqual=require(274),_each=require(406),_debounce=require(182),_sortBy=require(205),page=require(124),visit=require(114);DS.service("adService",["Eventify","$cid","$document","$window",function(e,t,a,i){var o,n,s,r,d,c,u,l,g={},p=this,h=[],f=visit.getQueryParamsObject(["utm_campaign"]),m=document.querySelector('script[data-type="ad-a9"]'),b=[],w=!1,v=[],y=document.querySelector('script[data-name="ad-doubleverify"]');document.querySelector('script[data-name="concert-ads"]')||(i.NYM={},i.NYM.analytics={},i.NYM.analytics.adStartTime=i.performance.now(),i.googletag=i.googletag||{},i.googletag.cmd=i.googletag.cmd||[],u=i.googletag,(m||y)&&(i.googletag.cmd=i.googletag.cmd||[],i.googletag.cmd.push(function(){i.googletag.pubads().disableInitialLoad()})),m&&(l=i.setInterval(function(){void 0!==window.apstag&&void 0!==window.apstag.timeout&&(i.clearInterval(l),window.apstag.cleared=!0,l=null)},10),setTimeout(function(){l&&(i.clearInterval(l),i.googletag.pubads().refresh(),window.apstag||console.log("MESSAGE: Timeout for A9 load exceeded, aborting"))},500)),y&&(b.push(new Promise(function(e){w?e():v.push(e)})),c=i.setTimeout(T,2500)),o=function(e){var t,a,o=e.data,n=[];return o.loaded?e:(o.loaded=!0,t=null,(t=o.sizes?u.defineSlot(o.name,o.sizes,o.id).addService(u.pubads()):u.defineOutOfPageSlot(o.name,o.id).addService(u.pubads())).setTargeting("adid",o.id),f.hasOwnProperty("utm_campaign")&&t.setTargeting("utmcamp",f.utm_campaign),a=p.getAdCount(o.label),t.setTargeting("label",o.label+"_"+o.site+"-"+a),u.display(o.id),u.pubads().addEventListener("slotOnload",function(){i.NYM.analytics.firstAdLoadTime||(i.NYM.analytics.firstAdLoadTime=i.performance.now(),i.NYM.analytics.firstAdLoadLabel=e.data.label)}),n=_(o),Promise.all(b).then(function(){n?window.apstag&&window.apstag.cleared?window.apstag.fetchBids({slots:[n],timeout:window.apstag.timeout},function(){u.cmd.push(function(){window.apstag.setDisplayBids(),u.pubads().refresh([t],{changeCorrelator:!1})})}):y&&u.pubads().refresh([t],{changeCorrelator:!1}):u.pubads().refresh([t],{changeCorrelator:!1})}),e.slot=t,e)},n=function(e){var a,i,o,n=t(),s=e.getAttribute("data-name"),r=e.getAttribute("data-sizes"),d=e.getAttribute("data-label"),c=e.getAttribute("data-site");n=e.id,r&&r.length?(r=r.split(","),a=[],_map(r,function(e){e=e.split("x"),i=parseInt(e[0]),o=parseInt(e[1]),a.push([i,o])})):(e.classList.add("oop"),a=!1),this.data={id:n,name:s,sizes:a,loaded:!1,label:d,site:c},g[n]=this},r=function(e){u.cmd.push(function(){var t=o(e);g[e.data.id]=t})},s=function(e){var t=[];e.slot?(t=_(e))&&window.apstag&&window.apstag.cleared&&window.apstag.fetchBids({slots:[t],timeout:window.apstag.timeout},function(){u.cmd.push(function(){window.apstag.setDisplayBids(),u.pubads().refresh([e.slot],{changeCorrelator:!1})})}):e&&r(e)},u.cmd.push(function(){var e,t,o,n=page.getMeta("article:tag"),s=page.getMeta("author"),r=i.location.href,d=(e=a.head.querySelector(".head-gtm"),t=a.body.querySelector(".gtm"),e&&"top"===e.getAttribute("data-gtm")?"gtmtop":t&&"bottom"===t.getAttribute("data-gtm")?"gtmbottom":"");o=[],_forEach([n,s,d],function(e){_forEach(e.split(","),function(e){(e=e.trim().toLowerCase().replace(/\s/g,"-").replace(/\'|\’/g,"")).length&&o.push(e)})}),u.pubads().setTargeting("kw",o),u.pubads().setTargeting("entry_group",o),r=r.slice(r.lastIndexOf("/")+1),u.pubads().setTargeting("pn",r),u.companionAds().setRefreshUnfilledSlots(!0),u.pubads().enableAsyncRendering(),u.enableServices()}),this.load=r,this.create=function(e){return new n(e)},this.refresh=function(e){var t;_isString(e)?(t=this.getById(e),s(t)):s(e)},this.remove=function(e){var t=e.data.id;a.getElementById(t).innerHTML=""},this.getAdCount=function(e){var t,a=0,i=Object.keys(g);return _each(i,function(i){(t=g[i]).data.loaded&&t.data.label===e&&a++}),a},this.getById=function(e){return g[e]},d=_debounce(function(){var e={TopLeaderboard:1,RightColTopMPU:2,outOfPage:99,"homepageTakeover/TopLeaderboard":1},t=_sortBy(h,function(t){return e[t.data.label]||10});_forEach(t,function(e){return e.data.sizes?r(e):i.setTimeout(function(){r(e)},2e3)}),y&&window.PQ.cmd.push(()=>{try{window.PQ.loadSignals(["ids","bsc","vlp"],T)}catch(e){T(),console.error(`There has been an error loading Double Verify signals: ${e}`)}}),h=[]},10),this.addToPageLoadQueue=function(e){h.push(e),d()});function _(e){var t,a=e.sizes;return a=_intersectionWith(a,[[970,250],[970,90],[728,90],[300,600],[300,250],[320,100],[320,50]],_isEqual),e.sizes&&e.sizes.length&&(t={slotID:e.id,sizes:a,slotName:e.label}),t}function T(){i.clearTimeout(c),w=!0,_forEach(v,function(e){e()})}}]);
}, {"107":107,"114":114,"118":118,"124":124,"182":182,"205":205,"268":268,"274":274,"406":406,"409":409}];
window.modules["cid.legacy"] = [function(require,module,exports){"use strict";DS.service("$cid",function(){var r=Math.floor(100*Math.random());return function(){return"cid-"+ ++r}});
}, {}];
window.modules["client.legacy"] = [function(require,module,exports){"use strict";require("cid.legacy"),require("ads.legacy"),require("facebook.legacy"),require("aaa-module-mounting.legacy");
}, {"cid.legacy":"cid.legacy","ads.legacy":"ads.legacy","facebook.legacy":"facebook.legacy","aaa-module-mounting.legacy":"aaa-module-mounting.legacy"}];
window.modules["facebook.legacy"] = [function(require,module,exports){"use strict";DS.service("facebook",[function(){this.fb=function(i){window.FB&&window.FB[i].apply(this,Array.prototype.slice.call(arguments,1))}}]);
}, {}];
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o typeof key === 'string' && key.match(/\.legacy$/)).forEach(key => window.require(key));
}
function tryToMount(fn, el, name) {
try {
fn(el); // init the controller
} catch (e) {
const elementTag = el.outerHTML.slice(0, el.outerHTML.indexOf(el.innerHTML));
console.error(`Error initializing controller for "${name}" on "${elementTag}"`, e);
}
}
/**
* mount client.js component controllers
*/
function mountComponentModules() {
Object.keys(window.modules).filter(key => typeof key === 'string' && key.match(/\.client$/)).forEach(key => {
let controllerFn = window.require(key);
if (typeof controllerFn === 'function') {
const name = key.replace('.client', ''),
instancesSelector = `[data-uri*="_components/${name}/"]`,
defaultSelector = `[data-uri$="_components${name}"]`,
instances = document.querySelectorAll(instancesSelector),
defaults = document.querySelectorAll(defaultSelector);
for (let el of instances) {
tryToMount(controllerFn, el, name);
}
for (let el of defaults) {
tryToMount(controllerFn, el, name);
}
}
});
}
// Make sure that a `window.process.env.NODE_ENV` is available in the client for any dependencies,
// services, or components that could require it
// note: the `` value is swapped for the actual environment variable in /lib/cmd/compile/scripts.js
window.process = window.process || {};
window.process.env = window.process.env || {};
if (!window.process.env.NODE_ENV) {
window.process.env.NODE_ENV = '';
}
// note: legacy controllers that require legacy services (e.g. dollar-slice) must
// wait for DOMContentLoaded to initialize themselves, as the files themselves must be mounted first
mountLegacyServices();
mountComponentModules();
// ]]