diff --git a/static/assets/app.js b/static/assets/app.js index 0d2699707..228d1bb6d 100644 --- a/static/assets/app.js +++ b/static/assets/app.js @@ -559,7 +559,7 @@ ${n.message}`)))}function one(){return import("./mermaid.core-E4MJ3BNQ.js" `}var Ise=new Or(t=>t.isLoaded?Xse(t):Rse(t)),gg=Nr("picker","skeleton","placeholder","searchSkeleton","searchInput","categoryTabsSkeleton","headerSkeleton","categoryTab","contentSkeleton","categoryName","emojiGrid","emoji","previewSkeleton","previewEmoji","previewName","tagList","tag","overlay","content","fullHeight","pluginContainer","header"),bg={emojisPerRow:"--emojis-per-row",visibleRows:"--row-count",emojiSize:"--emoji-size"},cw=class extends ot{constructor(){super({template:Ise,classes:gg}),this.pickerReady=!1,this.externalEvents=new Y5,this.updaters={styleProperty:e=>r=>this.el.style.setProperty(bg[e],r.toString()),theme:e=>{let r=this.options.theme,i=this.el.closest(`.${r}`);this.el.classList.remove(r),i==null||i.classList.remove(r),this.el.classList.add(e),i==null||i.classList.add(e)},className:e=>{this.options.className&&this.el.classList.remove(this.options.className),this.el.classList.add(e)},emojisPerRow:this.updateStyleProperty.bind(this,"emojisPerRow"),emojiSize:this.updateStyleProperty.bind(this,"emojiSize"),visibleRows:this.updateStyleProperty.bind(this,"visibleRows")}}initialize(){this.uiElements={pickerContent:ot.byClass(gg.content),header:ot.byClass(gg.header)},this.uiEvents=[ot.uiEvent("keydown",this.handleKeyDown)],this.appEvents={error:this.onError,reinitialize:this.reinitialize,"data:ready":this.onDataReady,"content:show":this.showContent,"variantPopup:hide":this.hideVariantPopup,"emoji:select":this.selectEmoji},super.initialize(),this.options.recentsProvider}destroy(){var e,r;super.destroy(),(e=this.search)==null||e.destroy(),this.emojiArea.destroy(),(r=this.categoryTabs)==null||r.destroy(),this.events.removeAll(),this.externalEvents.removeAll()}clearRecents(){this.options.recentsProvider.clear()}addEventListener(e,r){this.externalEvents.on(e,r)}removeEventListener(e,r){this.externalEvents.off(e,r)}initializePickerView(){this.pickerReady&&(this.showContent(),this.emojiArea.reset(!1))}handleKeyDown(e){let r=e.ctrlKey||e.metaKey;e.key==="s"&&r&&this.search&&(e.preventDefault(),this.search.focus())}buildChildViews(){return this.options.showPreview&&(this.preview=this.viewFactory.create(nw)),this.options.showSearch&&(this.search=this.viewFactory.create(ow,{categories:this.categories,emojiVersion:this.emojiVersion})),this.options.showCategoryTabs&&(this.categoryTabs=this.viewFactory.create(lw,{categories:this.categories})),this.currentView=this.emojiArea=this.viewFactory.create(rw,{categoryTabs:this.categoryTabs,categories:this.categories,emojiVersion:this.emojiVersion}),[this.preview,this.search,this.emojiArea,this.categoryTabs]}setStyleProperties(){this.options.showSearch||this.el.style.setProperty("--search-height-full","0px"),this.options.showCategoryTabs||(this.el.style.setProperty("--category-tabs-height","0px"),this.el.style.setProperty("--category-tabs-offset","0px")),this.options.showPreview||this.el.style.setProperty("--emoji-preview-height-full","0px"),Object.keys(bg).forEach(e=>{this.options[e]&&this.el.style.setProperty(bg[e],this.options[e].toString())})}updateStyleProperty(e,r){this.el.style.setProperty(bg[e],r.toString())}reinitialize(){this.renderSync()}onError(e){let r=this.viewFactory.createWithOptions({data:!1},iw,{message:this.i18n.get("error.load")}),i=this.el.offsetHeight||375;throw this.el.style.height=`${i}px`,iu(this.el,r.renderSync()),e}async onDataReady(e){let r=this.el;try{e?this.emojiData=e:await this.emojiDataPromise,this.options.emojiVersion==="auto"?this.emojiVersion=Ase()||parseFloat(Oae):this.emojiVersion=this.options.emojiVersion,this.categories=await this.emojiData.getCategories(this.options);let[i,n,o,a]=this.buildChildViews();await super.render({isLoaded:!0,search:n,categoryTabs:a,emojiArea:o,preview:i,showHeader:!!(this.search||this.categoryTabs),theme:this.options.theme,className:this.options.className}),this.el.style.setProperty("--category-count",this.categories.length.toString()),this.pickerReady=!0,r.replaceWith(this.el),this.setStyleProperties(),this.initializePickerView(),this.setInitialFocus(),this.externalEvents.emit("data:ready")}catch(i){this.events.emit("error",i)}}renderSync(){var e;let r=((e=this.options.categories)==null?void 0:e.length)||10;if(this.options.showRecents&&(r+=1),super.renderSync({isLoaded:!1,theme:this.options.theme,className:this.options.className,showSearch:this.options.showSearch,showPreview:this.options.showPreview,showCategoryTabs:this.options.showCategoryTabs,showHeader:this.options.showSearch||this.options.showCategoryTabs,emojiCount:this.options.emojisPerRow*this.options.visibleRows,categoryCount:r}),this.el.style.setProperty("--category-count",r.toString()),!this.options.rootElement)throw new Error("Picker must be given a root element via the rootElement option");return iu(this.options.rootElement,this.el),this.setStyleProperties(),this.pickerReady&&this.initializePickerView(),this.el}getInitialFocusTarget(){if(typeof this.options.autoFocus<"u")switch(this.options.autoFocus){case"emojis":return this.emojiArea.focusableEmoji;case"search":return this.search;case"auto":return this.search||this.emojiArea.focusableEmoji;default:return null}if(this.options.autoFocusSearch===!0)return console.warn("options.autoFocusSearch is deprecated, please use options.focusTarget instead"),this.search}setInitialFocus(){var e;!this.pickerReady||(e=this.getInitialFocusTarget())==null||e.focus()}reset(e=!0){var r;this.pickerReady&&(this.emojiArea.reset(e),this.showContent(this.emojiArea)),(r=this.search)==null||r.clear(),this.hideVariantPopup()}showContent(e=this.emojiArea){var r,i;e!==this.currentView&&(this.currentView!==this.emojiArea&&((r=this.currentView)==null||r.destroy()),this.ui.pickerContent.classList.toggle(gg.fullHeight,e!==this.emojiArea),iu(this.ui.pickerContent,e.el),this.currentView=e,e===this.emojiArea?(this.emojiArea.reset(),this.categoryTabs&&this.ui.header.appendChild(this.categoryTabs.el)):(i=this.categoryTabs)==null||i.el.remove())}hideVariantPopup(){var e;(e=this.variantPopup)==null||e.destroy()}isPickerClick(e){var r,i;let n=e.target,o=this.el.contains(n),a=(i=(r=this.variantPopup)==null?void 0:r.el)==null?void 0:i.contains(n);return o||a}async selectEmoji({emoji:e}){var r,i;(r=e.skins)!=null&&r.length&&this.options.showVariants&&!this.isVariantPopupOpen?this.showVariantPopup(e):(await((i=this.variantPopup)==null?void 0:i.animateHide()),this.events.emit("variantPopup:hide"),await this.emitEmoji(e))}get isVariantPopupOpen(){return this.variantPopup&&!this.variantPopup.isDestroyed}async showVariantPopup(e){let r=document.activeElement;this.events.once("variantPopup:hide",()=>{r==null||r.focus()}),this.variantPopup=this.viewFactory.create(aw,{emoji:e,parent:this.el}),this.el.appendChild(this.variantPopup.renderSync()),this.variantPopup.activate()}async emitEmoji(e){this.externalEvents.emit("emoji:select",await this.renderer.doEmit(e)),this.options.recentsProvider.addOrUpdateRecent(e,this.options.maxRecents),this.events.emit("recent:add",e)}updateOptions(e){Object.keys(e).forEach(r=>{this.updaters[r](e[r])}),Object.assign(this.options,e)}},uw=class{constructor({events:e,i18n:r,renderer:i,emojiData:n,options:o,customEmojis:a=[],pickerId:s}){this.events=e,this.i18n=r,this.renderer=i,this.emojiData=n,this.options=o,this.customEmojis=a,this.pickerId=s}setEmojiData(e){this.emojiData=Promise.resolve(e)}createWithOptions(e={},r,...i){let n=new r(...i);return n.setPickerId(this.pickerId),n.setEvents(this.events),n.setI18n(this.i18n),n.setRenderer(this.renderer),e.data!==!1&&n.setEmojiData(this.emojiData),n.setOptions(this.options),n.setCustomEmojis(this.customEmojis),n.viewFactory=this,n.initialize(),n}create(e,...r){return this.createWithOptions({},e,...r)}},Eg,fw=class{constructor(e={}){sa(this,Eg,void 0),X5(this,Eg,new Map(Object.entries(e)))}get(e,r=e){return la(this,Eg).get(e)||r}};Eg=new WeakMap;function Lse(t,e){e===void 0&&(e={});var r=e.insertAt;if(!(!t||typeof document>"u")){var i=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",r==="top"&&i.firstChild?i.insertBefore(n,i.firstChild):i.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}}function Ow(){let t=!1;return function(e){ase.injectStyles&&!t&&(Lse(e),t=!0)}}var Mse=`.picmo__picker .picmo__icon{width:1.25em;height:1em;fill:currentColor}.picmo__icon-small{font-size:.8em}.picmo__icon-medium{font-size:1em}.picmo__icon-large{font-size:1.25em}.picmo__icon-2x{font-size:2em}.picmo__icon-3x{font-size:3em}.picmo__icon-4x{font-size:4em}.picmo__icon-5x{font-size:5em}.picmo__icon-8x{font-size:8em}.picmo__icon-10x{font-size:10em}.picmo__light,.picmo__auto{color-scheme:light;--accent-color: #4f46e5;--background-color: #f9fafb;--border-color: #cccccc;--category-name-background-color: #f9fafb;--category-name-button-color: #999999;--category-name-text-color: hsl(214, 30%, 50%);--category-tab-active-background-color: rgba(255, 255, 255, .6);--category-tab-active-color: var(--accent-color);--category-tab-color: #666;--category-tab-highlight-background-color: rgba(0, 0, 0, .15);--error-color-dark: hsl(0, 100%, 45%);--error-color: hsl(0, 100%, 40%);--focus-indicator-background-color: hsl(198, 65%, 85%);--focus-indicator-color: #333333;--hover-background-color: #c7d2fe;--placeholder-background-color: #cccccc;--search-background-color: #f9fafb;--search-focus-background-color: #ffffff;--search-icon-color: #999999;--search-placeholder-color: #71717a;--secondary-background-color: #e2e8f0;--secondary-text-color: #666666;--tag-background-color: rgba(162, 190, 245, .3);--text-color: #000000;--variant-popup-background-color: #ffffff}.picmo__dark{color-scheme:dark;--accent-color: #A580F9;--background-color: #333333;--border-color: #666666;--category-name-background-color: #333333;--category-name-button-color: #eeeeee;--category-name-text-color: #ffffff;--category-tab-active-background-color: #000000;--category-tab-active-color: var(--accent-color);--category-tab-color: #cccccc;--category-tab-highlight-background-color: #4A4A4A;--error-color-dark: hsl(0, 7%, 3%);--error-color: hsl(0, 30%, 60%);--focus-indicator-background-color: hsl(0, 0%, 50%);--focus-indicator-color: #999999;--hover-background-color: hsla(0, 0%, 40%, .85);--image-placeholder-color: #ffffff;--placeholder-background-color: #666666;--search-background-color: #71717a;--search-focus-background-color: #52525b;--search-icon-color: #cccccc;--search-placeholder-color: #d4d4d8;--secondary-background-color: #000000;--secondary-text-color: #999999;--tag-background-color: rgba(162, 190, 245, .3);--text-color: #ffffff;--variant-popup-background-color: #333333}@media (prefers-color-scheme: dark){.picmo__auto{color-scheme:dark;--accent-color: #A580F9;--background-color: #333333;--border-color: #666666;--category-name-background-color: #333333;--category-name-button-color: #eeeeee;--category-name-text-color: #ffffff;--category-tab-active-background-color: #000000;--category-tab-active-color: var(--accent-color);--category-tab-color: #cccccc;--category-tab-highlight-background-color: #4A4A4A;--error-color-dark: hsl(0, 7%, 3%);--error-color: hsl(0, 30%, 60%);--focus-indicator-background-color: hsl(0, 0%, 50%);--focus-indicator-color: #999999;--hover-background-color: hsla(0, 0%, 40%, .85);--image-placeholder-color: #ffffff;--placeholder-background-color: #666666;--search-background-color: #71717a;--search-focus-background-color: #52525b;--search-icon-color: #cccccc;--search-placeholder-color: #d4d4d8;--secondary-background-color: #000000;--secondary-text-color: #999999;--tag-background-color: rgba(162, 190, 245, .3);--text-color: #ffffff;--variant-popup-background-color: #333333}}.picmo__picker .picmo__categoryButtonsContainer{overflow:auto;padding:2px 0}.picmo__picker .picmo__categoryButtonsContainer.picmo__has-overflow-right{mask-image:linear-gradient(270deg,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 10%);-webkit-mask-image:linear-gradient(270deg,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 10%)}.picmo__picker .picmo__categoryButtonsContainer.picmo__has-overflow-left{mask-image:linear-gradient(90deg,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 10%);-webkit-mask-image:linear-gradient(90deg,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 10%)}.picmo__picker .picmo__categoryButtonsContainer.picmo__has-overflow-both{mask-image:linear-gradient(90deg,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 10%,rgba(255,255,255,1) 90%,rgba(255,255,255,0) 100%);-webkit-mask-image:linear-gradient(90deg,rgba(255,255,255,0) 0%,rgba(255,255,255,1) 10%,rgba(255,255,255,1) 90%,rgba(255,255,255,0) 100%)}.picmo__picker .picmo__categoryButtons{display:flex;flex-direction:row;gap:var(--tab-gap);margin:0;padding:0 .5em;align-items:center;height:var(--category-tabs-height);box-sizing:border-box;width:100%;justify-content:space-between;position:relative;list-style-type:none;justify-self:center;max-width:min(23.55rem,calc(var(--category-count, 1) * 2.5rem))}.picmo__picker .picmo__categoryButtons .picmo__categoryTab{display:flex;align-items:center;transition:all .1s;width:2em}.picmo__picker .picmo__categoryButtons .picmo__categoryTab.picmo__categoryTabActive .picmo__categoryButton{color:var(--category-tab-active-color);background:linear-gradient(rgba(255,255,255,.75) 0%,rgba(255,255,255,.75) 100%),linear-gradient(var(--category-tab-active-color) 0%,var(--category-tab-active-color) 100%);border:2px solid var(--category-tab-active-color)}.picmo__picker .picmo__categoryButtons .picmo__categoryTab.picmo__categoryTabActive .picmo__categoryButton:hover{background-color:var(--category-tab-active-background-color)}.picmo__picker .picmo__categoryButtons .picmo__categoryTab button.picmo__categoryButton{border-radius:5px;background:transparent;border:2px solid transparent;color:var(--category-tab-color);cursor:pointer;padding:2px;vertical-align:middle;display:flex;align-items:center;justify-content:center;font-size:1.2rem;width:1.6em;height:1.6em;transition:all .1s}.picmo__picker .picmo__categoryButtons .picmo__categoryTab button.picmo__categoryButton:is(img){width:var(--category-tab-size);height:var(--category-tab-size)}.picmo__picker .picmo__categoryButtons .picmo__categoryTab button.picmo__categoryButton:hover{background:var(--category-tab-highlight-background-color)}.picmo__dataError [data-icon]{opacity:.8}@keyframes appear{0%{opacity:0}to{opacity:.8}}@keyframes appear-grow{0%{opacity:0;transform:scale(.8)}to{opacity:.8;transform:scale(1)}}.picmo__picker .picmo__error{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--secondary-text-color)}.picmo__picker .picmo__error .picmo__iconContainer{opacity:.8;animation:appear-grow .25s cubic-bezier(.175,.885,.32,1.275);--color-primary: var(--error-color);--color-secondary: var(--error-color-dark)}.picmo__picker .picmo__error .picmo__title{animation:appear .25s;animation-delay:50ms;animation-fill-mode:both}.picmo__picker .picmo__error button{padding:8px 16px;cursor:pointer;background:var(--background-color);border:1px solid var(--text-color);border-radius:5px;color:var(--text-color)}.picmo__picker .picmo__error button:hover{background:var(--text-color);color:var(--background-color)}.picmo__emojiButton{background:transparent;border:none;border-radius:15px;cursor:pointer;display:flex;font-family:var(--emoji-font);font-size:var(--emoji-size);height:100%;justify-content:center;align-items:center;margin:0;overflow:hidden;padding:0;width:100%}.picmo__emojiButton:hover{background:var(--hover-background-color)}.picmo__emojiButton:focus{border-radius:0;background:var(--focus-indicator-background-color);outline:1px solid var(--focus-indicator-color)}.picmo__picker .picmo__emojiArea{height:var(--emoji-area-height);overflow-y:auto;position:relative}.picmo__picker .picmo__emojiCategory{position:relative}.picmo__picker .picmo__emojiCategory .picmo__categoryName{font-size:.9em;padding:.5rem;margin:0;background:var(--category-name-background-color);color:var(--category-name-text-color);top:0;z-index:1;display:grid;gap:4px;grid-template-columns:auto 1fr auto;align-items:center;line-height:1;box-sizing:border-box;height:var(--category-name-height);justify-content:flex-start;text-transform:uppercase}.picmo__picker .picmo__emojiCategory .picmo__categoryName button{background:transparent;border:none;display:flex;align-items:center;cursor:pointer;color:var(--category-name-button-color)}.picmo__picker .picmo__emojiCategory .picmo__categoryName button:hover{opacity:1}.picmo__picker .picmo__emojiCategory .picmo__noRecents{color:var(--secondary-text-color);grid-column:1 / span var(--emojis-per-row);font-size:.9em;text-align:center;display:flex;align-items:center;justify-content:center;min-height:calc(var(--emoji-size) * var(--emoji-size-multiplier))}.picmo__picker .picmo__emojiCategory .picmo__recentEmojis[data-empty=true]{display:none}:is(.picmo__picker .picmo__emojiCategory) .picmo__recentEmojis[data-empty=false]+div{display:none}.picmo__picker .picmo__emojiContainer{display:grid;justify-content:space-between;gap:1px;padding:0 .5em;grid-template-columns:repeat(var(--emojis-per-row),calc(var(--emoji-size) * var(--emoji-size-multiplier)));grid-auto-rows:calc(var(--emoji-size) * var(--emoji-size-multiplier));align-items:center;justify-items:center}.picmo__picker.picmo__picker{--border-radius: 5px;--emoji-area-height: calc( (var(--row-count) * var(--emoji-size) * var(--emoji-size-multiplier)) + var(--category-name-height) );--content-height: var(--emoji-area-height);--emojis-per-row: 8;--row-count: 6;--emoji-preview-margin: 4px;--emoji-preview-height: calc(var(--emoji-preview-size) + 1em + 1px);--emoji-preview-height-full: calc(var(--emoji-preview-height) + var(--emoji-preview-margin));--emoji-preview-size: 2.75em;--emoji-size: 2rem;--emoji-size-multiplier: 1.3;--content-margin: 8px;--category-tabs-height:calc(1.5em + 9px);--category-tabs-offset: 8px;--category-tab-size: 1.2rem;--category-name-height: 2rem;--category-name-padding-y: 6px;--search-height: 2em;--search-margin: .5em;--search-margin-bottom: 4px;--search-height-full: calc(var(--search-height) + var(--search-margin) + var(--search-margin-bottom));--overlay-background-color: rgba(0, 0, 0, .8);--emoji-font: "Segoe UI Emoji", "Segoe UI Symbol", "Segoe UI", "Apple Color Emoji", "Twemoji Mozilla", "Noto Color Emoji", "EmojiOne Color", "Android Emoji";--ui-font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;--ui-font-size: 16px;--picker-width: calc(var(--emojis-per-row) * var(--emoji-size) * var(--emoji-size-multiplier) + 2.75rem);--preview-background-color: var(--secondary-background-color);background:var(--background-color);border-radius:var(--border-radius);border:1px solid var(--border-color);font-family:var(--ui-font);font-size:var(--ui-font-size);overflow:hidden;position:relative;width:var(--picker-width);display:grid;gap:8px}.picmo__picker.picmo__picker>*{font-family:var(--ui-font)}.picmo__picker.picmo__skeleton{background:var(--background-color);border-radius:var(--border-radius);border:1px solid var(--border-color);font-family:var(--ui-font);width:var(--picker-width);color:var(--secondary-text-color)}.picmo__picker.picmo__skeleton *{box-sizing:border-box}.picmo__picker.picmo__skeleton .picmo__placeholder{background:var(--placeholder-background-color);position:relative;overflow:hidden}.picmo__picker.picmo__skeleton .picmo__placeholder:after{position:absolute;top:0;right:0;bottom:0;left:0;transform:translate(-100%);background-image:linear-gradient(90deg,rgba(255,255,255,0) 0,rgba(255,255,255,.2) 20%,rgba(255,255,255,.5) 60%,rgba(255,255,255,0) 100%);animation:shine 2s infinite;content:""}.picmo__picker.picmo__skeleton .picmo__headerSkeleton{background-color:var(--secondary-background-color);padding-top:8px;padding-bottom:8px;display:flex;flex-direction:column;overflow:hidden;gap:8px;border-bottom:1px solid var(--border-color);width:var(--picker-width)}.picmo__picker.picmo__skeleton .picmo__searchSkeleton{padding:0 8px;height:var(--search-height)}.picmo__picker.picmo__skeleton .picmo__searchSkeleton .picmo__searchInput{width:100%;height:28px;border-radius:3px}.picmo__picker.picmo__skeleton .picmo__categoryTabsSkeleton{height:var(--category-tabs-height);display:flex;flex-direction:row;align-items:center;justify-self:center;width:calc(2rem * var(--category-count, 1))}.picmo__picker.picmo__skeleton .picmo__categoryTabsSkeleton .picmo__categoryTab{width:25px;height:25px;padding:2px;border-radius:5px;margin:.25em}.picmo__picker.picmo__skeleton .picmo__contentSkeleton{height:var(--content-height);padding-right:8px;opacity:.7}.picmo__picker.picmo__skeleton .picmo__contentSkeleton .picmo__categoryName{width:50%;height:1rem;margin:.5rem;box-sizing:border-box}.picmo__picker.picmo__skeleton .picmo__contentSkeleton .picmo__emojiGrid{display:grid;justify-content:space-between;gap:1px;padding:0 .5em;grid-template-columns:repeat(var(--emojis-per-row),calc(var(--emoji-size) * var(--emoji-size-multiplier)));grid-auto-rows:calc(var(--emoji-size) * var(--emoji-size-multiplier));align-items:center;justify-items:center;width:var(--picker-width)}.picmo__picker.picmo__skeleton .picmo__contentSkeleton .picmo__emojiGrid .picmo__emoji{width:var(--emoji-size);height:var(--emoji-size);border-radius:50%}.picmo__picker.picmo__skeleton .picmo__previewSkeleton{height:var(--emoji-preview-height);border-top:1px solid var(--border-color);display:grid;align-items:center;padding:.5em;gap:6px;grid-template-columns:auto 1fr;grid-template-rows:auto 1fr;grid-template-areas:"emoji name" "emoji tags"}.picmo__picker.picmo__skeleton .picmo__previewSkeleton .picmo__previewEmoji{grid-area:emoji;border-radius:50%;width:var(--emoji-preview-size);height:var(--emoji-preview-size)}.picmo__picker.picmo__skeleton .picmo__previewSkeleton .picmo__previewName{grid-area:name;height:.8em;width:80%}.picmo__picker.picmo__skeleton .picmo__previewSkeleton .picmo__tagList{grid-area:tags;list-style-type:none;display:flex;flex-direction:row;padding:0;margin:0}.picmo__picker.picmo__skeleton .picmo__previewSkeleton .picmo__tagList .picmo__tag{border-radius:3px;padding:2px 8px;margin-right:.25em;height:1em;width:20%}.picmo__overlay{background:rgba(0,0,0,.75);height:100%;left:0;position:fixed;top:0;width:100%;z-index:1000}.picmo__content{position:relative;overflow:hidden;height:var(--content-height)}.picmo__content.picmo__fullHeight{height:calc(var(--content-height) + var(--category-tabs-height) + var(--category-tabs-offset));overflow-y:auto}.picmo__pluginContainer{margin:.5em;display:flex;flex-direction:row}.picmo__header{background-color:var(--secondary-background-color);padding-top:8px;padding-bottom:8px;display:grid;gap:8px;border-bottom:1px solid var(--border-color)}@media (prefers-reduced-motion: reduce){.picmo__placeholder{background:var(--placeholder-background-color);position:relative;overflow:hidden}.picmo__placeholder:after{display:none}}.picmo__picker .picmo__preview{border-top:1px solid var(--border-color);display:grid;align-items:center;gap:6px;grid-template-columns:auto 1fr;grid-template-rows:auto 1fr;grid-template-areas:"emoji name" "emoji tags";height:var(--emoji-preview-height);box-sizing:border-box;padding:.5em;position:relative;background:var(--preview-background-color)}.picmo__picker .picmo__preview .picmo__previewEmoji{grid-area:emoji;font-size:var(--emoji-preview-size);font-family:var(--emoji-font);width:1.25em;display:flex;align-items:center;justify-content:center}.picmo__picker .picmo__preview .picmo__previewName{grid-area:name;color:var(--text-color);font-size:.8em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:500}.picmo__picker .picmo__preview .picmo__tagList{grid-area:tags;list-style-type:none;display:flex;flex-direction:row;padding:0;margin:0;font-size:.75em;overflow:hidden}.picmo__picker .picmo__preview .picmo__tag{border-radius:3px;background:var(--tag-background-color);color:var(--text-color);padding:2px 8px;margin-right:.25em;white-space:nowrap}.picmo__picker .picmo__preview .picmo__tag:last-child{margin-right:0}.picmo__picker .picmo__searchContainer{display:flex;height:var(--search-height);box-sizing:border-box;padding:0 8px;position:relative}.picmo__picker .picmo__searchContainer .picmo__searchField{background:var(--search-background-color);border-radius:3px;border:none;box-sizing:border-box;color:var(--text-color);font-size:.9em;outline:none;padding:.5em 2.25em .5em .5em;width:100%}.picmo__picker .picmo__searchContainer .picmo__searchField:focus{background:var(--search-focus-background-color)}.picmo__picker .picmo__searchContainer .picmo__searchField::placeholder{color:var(--search-placeholder-color)}.picmo__picker .picmo__searchContainer .picmo__searchAccessory{color:var(--search-icon-color);height:100%;position:absolute;right:1em;top:0;width:1.25rem;display:flex;align-items:center}.picmo__picker .picmo__searchContainer .picmo__searchAccessory svg{fill:var(--search-icon-color)}.picmo__picker .picmo__searchContainer .picmo__clearButton{border:0;color:var(--search-icon-color);background:transparent;cursor:pointer}.picmo__picker .picmo__searchContainer .picmo__clearSearchButton{cursor:pointer;border:none;background:transparent;color:var(--search-icon-color);font-size:1em;width:100%;height:100%;display:flex;align-items:center;padding:0}.picmo__picker .picmo__searchContainer .picmo__notFound [data-icon]{fill:#f3e265}.picmo__picker .picmo__variantOverlay{background:var(--overlay-background-color);border-radius:5px;display:flex;flex-direction:column;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%;z-index:1}.picmo__picker .picmo__variantOverlay .picmo__variantPopup{background:var(--variant-popup-background-color);border-radius:5px;margin:.5em;padding:.5em;text-align:center;user-select:none;display:flex;align-items:center;justify-content:center}.picmo__customEmoji{width:1em;height:1em}@keyframes shine{to{transform:translate(100%)}}.picmo__picker .picmo__imagePlaceholder{width:2rem;height:2rem;border-radius:50%}.picmo__placeholder{background:#DDDBDD;position:relative}.picmo__placeholder:after{position:absolute;top:0;right:0;bottom:0;left:0;transform:translate(-100%);background-image:linear-gradient(90deg,rgba(255,255,255,0) 0,rgba(255,255,255,.2) 20%,rgba(255,255,255,.5) 60%,rgba(255,255,255,0) 100%);animation:shine 2s infinite;content:""} `;function zse(t){return zI(t.locale,t.dataStore,t.messages,t.emojiData)}var Dse=0,yg;function Nse(){return`picmo-${Date.now()}-${Dse++}`}var Use=Ow();function UI(t){Use(Mse);let e=mw(t),r=((e==null?void 0:e.custom)||[]).map(a=>Be(oe({},a),{custom:!0,tags:["custom",...a.tags||[]]})),i=new Z5;yg||(yg=zse(e));let n=new fw(e.i18n);yg.then(a=>{i.emit("data:ready",a)}).catch(a=>{i.emit("error",a)});let o=new uw({events:i,i18n:n,customEmojis:r,renderer:e.renderer,options:e,emojiData:yg,pickerId:Nse()}).create(cw);return o.renderSync(),o}function Cl(t){return t.split("-")[0]}function nu(t){return t.split("-")[1]}function zg(t){return["top","bottom"].includes(Cl(t))?"x":"y"}function GI(t){return t==="y"?"height":"width"}function qI(t,e,r){let{reference:i,floating:n}=t,o=i.x+i.width/2-n.width/2,a=i.y+i.height/2-n.height/2,s=zg(e),l=GI(s),c=i[l]/2-n[l]/2,u=Cl(e),f=s==="x",d;switch(u){case"top":d={x:o,y:i.y-n.height};break;case"bottom":d={x:o,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:a};break;case"left":d={x:i.x-n.width,y:a};break;default:d={x:i.x,y:i.y}}switch(nu(e)){case"start":d[s]-=c*(r&&f?-1:1);break;case"end":d[s]+=c*(r&&f?-1:1);break}return d}var qse=async(t,e,r)=>{let{placement:i="bottom",strategy:n="absolute",middleware:o=[],platform:a}=r,s=await(a.isRTL==null?void 0:a.isRTL(e)),l=await a.getElementRects({reference:t,floating:e,strategy:n}),{x:c,y:u}=qI(l,i,s),f=i,d={},p=0;for(let O=0;OFse[e])}function KI(t,e,r){r===void 0&&(r=!1);let i=nu(t),n=zg(t),o=GI(n),a=n==="x"?i===(r?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(a=Ig(a)),{main:a,cross:Ig(a)}}var Zse={start:"end",end:"start"};function gw(t){return t.replace(/start|end/g,e=>Zse[e])}var Yse=["top","right","bottom","left"],Hse=Yse.reduce((t,e)=>t.concat(e,e+"-start",e+"-end"),[]);function Gse(t,e,r){return(t?[...r.filter(i=>nu(i)===t),...r.filter(i=>nu(i)!==t)]:r.filter(i=>Cl(i)===i)).filter(i=>t?nu(i)===t||(e?gw(i)!==i:!1):!0)}var Kse=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var r,i,n,o,a;let{x:s,y:l,rects:c,middlewareData:u,placement:f,platform:d,elements:p}=e,ge=t,{alignment:O=null,allowedPlacements:x=Hse,autoAlignment:k=!0}=ge,w=Wr(ge,["alignment","allowedPlacements","autoAlignment"]),C=Gse(O,k,x),Q=await vw(e,w),L=(r=(i=u.autoPlacement)==null?void 0:i.index)!=null?r:0,N=C[L];if(N==null)return{};let{main:I,cross:H}=KI(N,c,await(d.isRTL==null?void 0:d.isRTL(p.floating)));if(f!==N)return{x:s,y:l,reset:{placement:C[0]}};let j=[Q[Cl(N)],Q[I],Q[H]],Y=[...(n=(o=u.autoPlacement)==null?void 0:o.overflows)!=null?n:[],{placement:N,overflows:j}],V=C[L+1];if(V)return{data:{index:L+1,overflows:Y},reset:{placement:V}};let ne=Y.slice().sort((ve,_e)=>ve.overflows[0]-_e.overflows[0]),ue=(a=ne.find(ve=>{let{overflows:_e}=ve;return _e.every(ae=>ae<=0)}))==null?void 0:a.placement,he=ue!=null?ue:ne[0].placement;return he!==f?{data:{index:L+1,overflows:Y},reset:{placement:he}}:{}}}};function Jse(t){let e=Ig(t);return[gw(t),e,gw(e)]}var ele=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var r;let{placement:i,middlewareData:n,rects:o,initialPlacement:a,platform:s,elements:l}=e,j=t,{mainAxis:c=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:d="bestFit",flipAlignment:p=!0}=j,O=Wr(j,["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","flipAlignment"]),x=Cl(i),k=f||(x===a||!p?[Ig(a)]:Jse(a)),w=[a,...k],C=await vw(e,O),Q=[],L=((r=n.flip)==null?void 0:r.overflows)||[];if(c&&Q.push(C[x]),u){let{main:Y,cross:V}=KI(i,o,await(s.isRTL==null?void 0:s.isRTL(l.floating)));Q.push(C[Y],C[V])}if(L=[...L,{placement:i,overflows:Q}],!Q.every(Y=>Y<=0)){var N,I;let Y=((N=(I=n.flip)==null?void 0:I.index)!=null?N:0)+1,V=w[Y];if(V)return{data:{index:Y,overflows:L},reset:{placement:V}};let ne="bottom";switch(d){case"bestFit":{var H;let ue=(H=L.map(he=>[he,he.overflows.filter(ge=>ge>0).reduce((ge,ve)=>ge+ve,0)]).sort((he,ge)=>he[1]-ge[1])[0])==null?void 0:H[0].placement;ue&&(ne=ue);break}case"initialPlacement":ne=a;break}if(i!==ne)return{reset:{placement:ne}}}return{}}}};async function tle(t,e){let{placement:r,platform:i,elements:n}=t,o=await(i.isRTL==null?void 0:i.isRTL(n.floating)),a=Cl(r),s=nu(r),l=zg(r)==="x",c=["left","top"].includes(a)?-1:1,u=o&&l?-1:1,f=typeof e=="function"?e(t):e,{mainAxis:d,crossAxis:p,alignmentAxis:O}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:oe({mainAxis:0,crossAxis:0,alignmentAxis:null},f);return s&&typeof O=="number"&&(p=s==="end"?O*-1:O),l?{x:p*u,y:d*c}:{x:d*c,y:p*u}}var jI=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){let{x:r,y:i}=e,n=await tle(e,t);return{x:r+n.x,y:i+n.y,data:n}}}};function rle(t){return t==="x"?"y":"x"}var WI=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:r,y:i,placement:n}=e,k=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:s={fn:w=>{let{x:C,y:Q}=w;return{x:C,y:Q}}}}=k,l=Wr(k,["mainAxis","crossAxis","limiter"]),c={x:r,y:i},u=await vw(e,l),f=zg(Cl(n)),d=rle(f),p=c[f],O=c[d];if(o){let w=f==="y"?"top":"left",C=f==="y"?"bottom":"right",Q=p+u[w],L=p-u[C];p=BI(Q,p,L)}if(a){let w=d==="y"?"top":"left",C=d==="y"?"bottom":"right",Q=O+u[w],L=O-u[C];O=BI(Q,O,L)}let x=s.fn(Be(oe({},e),{[f]:p,[d]:O}));return Be(oe({},x),{data:{x:x.x-r,y:x.y-i}})}}};function JI(t){return t&&t.document&&t.location&&t.alert&&t.setInterval}function fa(t){if(t==null)return window;if(!JI(t)){let e=t.ownerDocument;return e&&e.defaultView||window}return t}function Oo(t){return fa(t).getComputedStyle(t)}function ca(t){return JI(t)?"":t?(t.nodeName||"").toLowerCase():""}function eL(){let t=navigator.userAgentData;return t!=null&&t.brands?t.brands.map(e=>e.brand+"/"+e.version).join(" "):navigator.userAgent}function go(t){return t instanceof fa(t).HTMLElement}function gs(t){return t instanceof fa(t).Element}function ile(t){return t instanceof fa(t).Node}function ou(t){if(typeof ShadowRoot>"u")return!1;let e=fa(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Dg(t){let{overflow:e,overflowX:r,overflowY:i}=Oo(t);return/auto|scroll|overlay|hidden/.test(e+i+r)}function nle(t){return["table","td","th"].includes(ca(t))}function tL(t){let e=/firefox/i.test(eL()),r=Oo(t);return r.transform!=="none"||r.perspective!=="none"||r.contain==="paint"||["transform","perspective"].includes(r.willChange)||e&&r.willChange==="filter"||e&&(r.filter?r.filter!=="none":!1)}function rL(){return!/^((?!chrome|android).)*safari/i.test(eL())}var VI=Math.min,gd=Math.max,Lg=Math.round;function ua(t,e,r){var i,n,o,a;e===void 0&&(e=!1),r===void 0&&(r=!1);let s=t.getBoundingClientRect(),l=1,c=1;e&&go(t)&&(l=t.offsetWidth>0&&Lg(s.width)/t.offsetWidth||1,c=t.offsetHeight>0&&Lg(s.height)/t.offsetHeight||1);let u=gs(t)?fa(t):window,f=!rL()&&r,d=(s.left+(f&&(i=(n=u.visualViewport)==null?void 0:n.offsetLeft)!=null?i:0))/l,p=(s.top+(f&&(o=(a=u.visualViewport)==null?void 0:a.offsetTop)!=null?o:0))/c,O=s.width/l,x=s.height/c;return{width:O,height:x,top:p,right:d+O,bottom:p+x,left:d,x:d,y:p}}function bs(t){return((ile(t)?t.ownerDocument:t.document)||window.document).documentElement}function Ng(t){return gs(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function iL(t){return ua(bs(t)).left+Ng(t).scrollLeft}function ole(t){let e=ua(t);return Lg(e.width)!==t.offsetWidth||Lg(e.height)!==t.offsetHeight}function ale(t,e,r){let i=go(e),n=bs(e),o=ua(t,i&&ole(e),r==="fixed"),a={scrollLeft:0,scrollTop:0},s={x:0,y:0};if(i||!i&&r!=="fixed")if((ca(e)!=="body"||Dg(n))&&(a=Ng(e)),go(e)){let l=ua(e,!0);s.x=l.x+e.clientLeft,s.y=l.y+e.clientTop}else n&&(s.x=iL(n));return{x:o.left+a.scrollLeft-s.x,y:o.top+a.scrollTop-s.y,width:o.width,height:o.height}}function nL(t){return ca(t)==="html"?t:t.assignedSlot||t.parentNode||(ou(t)?t.host:null)||bs(t)}function FI(t){return!go(t)||Oo(t).position==="fixed"?null:sle(t)}function sle(t){let{offsetParent:e}=t,r=t,i=!1;for(;r&&r!==e;){let{assignedSlot:n}=r;if(n){let o=n.offsetParent;if(Oo(n).display==="contents"){let a=n.hasAttribute("style"),s=n.style.display;n.style.display=Oo(r).display,o=n.offsetParent,n.style.display=s,a||n.removeAttribute("style")}r=n,e!==o&&(e=o,i=!0)}else if(ou(r)&&r.host&&i)break;r=ou(r)&&r.host||r.parentNode}return e}function lle(t){let e=nL(t);for(ou(e)&&(e=e.host);go(e)&&!["html","body"].includes(ca(e));){if(tL(e))return e;{let r=e.parentNode;e=ou(r)?r.host:r}}return null}function bw(t){let e=fa(t),r=FI(t);for(;r&&nle(r)&&Oo(r).position==="static";)r=FI(r);return r&&(ca(r)==="html"||ca(r)==="body"&&Oo(r).position==="static"&&!tL(r))?e:r||lle(t)||e}function ZI(t){if(go(t))return{width:t.offsetWidth,height:t.offsetHeight};let e=ua(t);return{width:e.width,height:e.height}}function cle(t){let{rect:e,offsetParent:r,strategy:i}=t,n=go(r),o=bs(r);if(r===o)return e;let a={scrollLeft:0,scrollTop:0},s={x:0,y:0};if((n||!n&&i!=="fixed")&&((ca(r)!=="body"||Dg(o))&&(a=Ng(r)),go(r))){let l=ua(r,!0);s.x=l.x+r.clientLeft,s.y=l.y+r.clientTop}return Be(oe({},e),{x:e.x-a.scrollLeft+s.x,y:e.y-a.scrollTop+s.y})}function ule(t,e){let r=fa(t),i=bs(t),n=r.visualViewport,o=i.clientWidth,a=i.clientHeight,s=0,l=0;if(n){o=n.width,a=n.height;let c=rL();(c||!c&&e==="fixed")&&(s=n.offsetLeft,l=n.offsetTop)}return{width:o,height:a,x:s,y:l}}function fle(t){var e;let r=bs(t),i=Ng(t),n=(e=t.ownerDocument)==null?void 0:e.body,o=gd(r.scrollWidth,r.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),a=gd(r.scrollHeight,r.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),s=-i.scrollLeft+iL(t),l=-i.scrollTop;return Oo(n||r).direction==="rtl"&&(s+=gd(r.clientWidth,n?n.clientWidth:0)-o),{width:o,height:a,x:s,y:l}}function oL(t){let e=nL(t);return["html","body","#document"].includes(ca(e))?t.ownerDocument.body:go(e)&&Dg(e)?e:oL(e)}function Mg(t,e){var r;e===void 0&&(e=[]);let i=oL(t),n=i===((r=t.ownerDocument)==null?void 0:r.body),o=fa(i),a=n?[o].concat(o.visualViewport||[],Dg(i)?i:[]):i,s=e.concat(a);return n?s:s.concat(Mg(a))}function hle(t,e){let r=e.getRootNode==null?void 0:e.getRootNode();if(t.contains(e))return!0;if(r&&ou(r)){let i=e;do{if(i&&t===i)return!0;i=i.parentNode||i.host}while(i)}return!1}function dle(t,e){let r=ua(t,!1,e==="fixed"),i=r.top+t.clientTop,n=r.left+t.clientLeft;return{top:i,left:n,x:n,y:i,right:n+t.clientWidth,bottom:i+t.clientHeight,width:t.clientWidth,height:t.clientHeight}}function YI(t,e,r){return e==="viewport"?Rg(ule(t,r)):gs(e)?dle(e,r):Rg(fle(bs(t)))}function ple(t){let e=Mg(t),r=["absolute","fixed"].includes(Oo(t).position)&&go(t)?bw(t):t;return gs(r)?e.filter(i=>gs(i)&&hle(i,r)&&ca(i)!=="body"):[]}function mle(t){let{element:e,boundary:r,rootBoundary:i,strategy:n}=t,o=[...r==="clippingAncestors"?ple(e):[].concat(r),i],a=o[0],s=o.reduce((l,c)=>{let u=YI(e,c,n);return l.top=gd(u.top,l.top),l.right=VI(u.right,l.right),l.bottom=VI(u.bottom,l.bottom),l.left=gd(u.left,l.left),l},YI(e,a,n));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}var Ole={getClippingRect:mle,convertOffsetParentRelativeRectToViewportRelativeRect:cle,isElement:gs,getDimensions:ZI,getOffsetParent:bw,getDocumentElement:bs,getElementRects:t=>{let{reference:e,floating:r,strategy:i}=t;return{reference:ale(e,bw(r),i),floating:Be(oe({},ZI(r)),{x:0,y:0})}},getClientRects:t=>Array.from(t.getClientRects()),isRTL:t=>Oo(t).direction==="rtl"};function gle(t,e,r,i){i===void 0&&(i={});let{ancestorScroll:n=!0,ancestorResize:o=!0,elementResize:a=!0,animationFrame:s=!1}=i,l=n&&!s,c=o&&!s,u=l||c?[...gs(t)?Mg(t):[],...Mg(e)]:[];u.forEach(x=>{l&&x.addEventListener("scroll",r,{passive:!0}),c&&x.addEventListener("resize",r)});let f=null;if(a){let x=!0;f=new ResizeObserver(()=>{x||r(),x=!1}),gs(t)&&!s&&f.observe(t),f.observe(e)}let d,p=s?ua(t):null;s&&O();function O(){let x=ua(t);p&&(x.x!==p.x||x.y!==p.y||x.width!==p.width||x.height!==p.height)&&r(),p=x,d=requestAnimationFrame(O)}return r(),()=>{var x;u.forEach(k=>{l&&k.removeEventListener("scroll",r),c&&k.removeEventListener("resize",r)}),(x=f)==null||x.disconnect(),f=null,s&&cancelAnimationFrame(d)}}var ble=(t,e,r)=>qse(t,e,oe({platform:Ole},r));async function yle(t,e,r,i){if(!i)throw new Error("Must provide a positioning option");return await(typeof i=="string"?vle(t,e,r,i):xle(e,i))}async function vle(t,e,r,i){if(!r)throw new Error("Reference element is required for relative positioning");let n;return i==="auto"?n={middleware:[Kse(),WI(),jI({mainAxis:5,crossAxis:12})]}:n={placement:i,middleware:[ele(),WI(),jI(5)]},gle(r,e,async()=>{if((!r.isConnected||!r.offsetParent)&&wle(t))return;let{x:o,y:a}=await ble(r,e,n);Object.assign(e.style,{position:"absolute",left:`${o}px`,top:`${a}px`})})}function xle(t,e){return t.style.position="fixed",Object.entries(e).forEach(([r,i])=>{t.style[r]=i}),()=>{}}function wle(t){switch(t.options.onPositionLost){case"close":return t.close(),!0;case"destroy":return t.destroy(),!0;case"hold":return!0}}var kle={hideOnClickOutside:!0,hideOnEmojiSelect:!0,hideOnEscape:!0,position:"auto",showCloseButton:!0,onPositionLost:"none"};function Sle(t={}){return oe(Be(oe({},kle),{rootElement:document.body}),t)}var Tle='',HI=Nr("popupContainer","closeButton"),yw=class{constructor(e,r){this.isOpen=!1,this.externalEvents=new Tl,this.options=oe(oe({},Sle(r)),mw(e)),this.popupEl=document.createElement("div"),this.popupEl.classList.add(HI.popupContainer),this.popupEl.classList.add(this.options.theme),r.className&&this.popupEl.classList.add(r.className),this.options.showCloseButton&&(this.closeButton=document.createElement("button"),this.closeButton.type="button",this.closeButton.classList.add(HI.closeButton),this.closeButton.innerHTML=Tle,this.closeButton.addEventListener("click",()=>{this.close()}),this.popupEl.appendChild(this.closeButton));let i=document.createElement("div");this.popupEl.appendChild(i),this.picker=UI(Be(oe({},this.options),{rootElement:i})),this.focusTrap=new pd,this.picker.addEventListener("data:ready",()=>{this.focusTrap.activate(this.picker.el),this.picker.setInitialFocus()}),this.options.hideOnEmojiSelect&&this.picker.addEventListener("emoji:select",()=>{var n;this.close(),(n=this.triggerElement)==null||n.focus()}),this.options.hideOnClickOutside&&(this.onDocumentClick=this.onDocumentClick.bind(this),document.addEventListener("click",this.onDocumentClick)),this.options.hideOnEscape&&(this.handleKeydown=this.handleKeydown.bind(this),this.popupEl.addEventListener("keydown",this.handleKeydown)),this.referenceElement=this.options.referenceElement,this.triggerElement=this.options.triggerElement}addEventListener(e,r){this.externalEvents.on(e,r),this.picker.addEventListener(e,r)}removeEventListener(e,r){this.externalEvents.off(e,r),this.picker.removeEventListener(e,r)}handleKeydown(e){var r;e.key==="Escape"&&(this.close(),(r=this.triggerElement)==null||r.focus())}async destroy(){this.isOpen&&await this.close(),document.removeEventListener("click",this.onDocumentClick),this.picker.destroy(),this.externalEvents.removeAll()}toggle(e){return this.isOpen?this.close():this.open(e)}async open({triggerElement:e,referenceElement:r}={}){this.isOpen||(e&&(this.triggerElement=e),r&&(this.referenceElement=r),await this.initiateOpenStateChange(!0),this.popupEl.style.opacity="0",this.options.rootElement.appendChild(this.popupEl),await this.setPosition(),this.picker.reset(!1),await this.animatePopup(!0),await this.animateCloseButton(!0),this.picker.setInitialFocus(),this.externalEvents.emit("picker:open"))}async close(){var e;!this.isOpen||(await this.initiateOpenStateChange(!1),await this.animateCloseButton(!1),await this.animatePopup(!1),this.popupEl.remove(),this.picker.reset(),(e=this.positionCleanup)==null||e.call(this),this.focusTrap.deactivate(),this.externalEvents.emit("picker:close"))}getRunningAnimations(){return this.picker.el.getAnimations().filter(e=>e.playState==="running")}async setPosition(){var e;(e=this.positionCleanup)==null||e.call(this),this.positionCleanup=await yle(this,this.popupEl,this.referenceElement,this.options.position)}awaitPendingAnimations(){return Promise.all(this.getRunningAnimations().map(e=>e.finished))}onDocumentClick(e){var r;let i=e.target,n=(r=this.triggerElement)==null?void 0:r.contains(i);this.isOpen&&!this.picker.isPickerClick(e)&&!n&&this.close()}animatePopup(e){return kl(this.popupEl,{opacity:[0,1],transform:["scale(0.9)","scale(1)"]},{duration:150,id:e?"show-picker":"hide-picker",easing:"ease-in-out",direction:e?"normal":"reverse",fill:"both"},this.options)}animateCloseButton(e){if(this.closeButton)return kl(this.closeButton,{opacity:[0,1]},{duration:25,id:e?"show-close":"hide-close",easing:"ease-in-out",direction:e?"normal":"reverse",fill:"both"},this.options)}async initiateOpenStateChange(e){this.isOpen=e,await this.awaitPendingAnimations()}},Ele=`.picmo__popupContainer{display:flex;flex-direction:column;position:absolute}.picmo__popupContainer .picmo__closeButton{position:absolute;opacity:0;background:transparent;border:none;z-index:1;right:0;top:0;cursor:pointer;padding:4px;align-self:flex-end;transform:translate(50%,-50%);background:#999999;width:1.5rem;height:1.5rem;display:flex;align-items:center;justify-content:center;border-radius:50%}.picmo__popupContainer .picmo__closeButton:hover{background:var(--accent-color)}.picmo__popupContainer .picmo__closeButton svg{fill:#fff;width:1.25rem;height:1.25rem} `,Cle=Ow();function aL(t,e){return Cle(Ele),new yw(oe({autoFocus:"auto"},t),e)}var Ple={mounted(){let t=this.el.querySelector("[data-emoji-button]"),e=this.el.querySelector("[data-emoji-preview]"),r=this.el.querySelector("[data-emoji-input]"),i=aL({showPreview:!1},{triggerElement:t,referenceElement:t,position:"bottom"});i.addEventListener("emoji:select",({emoji:n})=>{e.innerHTML=n,r.value=n}),t.addEventListener("click",n=>{i.toggle()})}},sL=Ple;var _le={mounted(){this.focus()},updated(){this.el!==document.activeElement&&this.focus()},focus(){cs(document.activeElement)||(this.el.focus(),this.el.selectionStart=this.el.selectionEnd=this.el.value.length,this.el.scrollLeft=this.el.scrollWidth)}},lL=_le;var Ale={mounted(){this.props=this.getProps(),this.isFocused=!1,this.insertMode=!1,this.initializeHeadingEl(),this.navigationSubscription=_r.subscribe("navigation",this.handleNavigationEvent.bind(this))},updated(){this.props=this.getProps(),this.initializeHeadingEl()},destroyed(){this.navigationSubscription.destroy()},getProps(){return $t(this.el,["id","on-value-change","metadata"])},initializeHeadingEl(){let t=this.el.querySelector("[data-el-heading]");t!==this.headingEl&&(this.headingEl=t,this.headingEl.addEventListener("paste",e=>{e.preventDefault();let r=e.clipboardData.getData("text/plain").replace(` -`," ");document.execCommand("insertText",!1,r)}),this.headingEl.addEventListener("keydown",e=>{e.key==="Enter"&&e.preventDefault()}),this.headingEl.addEventListener("blur",e=>{setTimeout(()=>{this.isFocused&&this.insertMode&&(this.headingEl.focus(),cL(this.headingEl))},0)}))},handleNavigationEvent(t){t.type==="element_focused"?this.handleElementFocused(t.focusableId,t.scroll):t.type==="insert_mode_changed"&&this.handleInsertModeChanged(t.enabled)},handleElementFocused(t,e){this.props.id===t?(this.isFocused=!0,this.el.setAttribute("data-js-focused",""),e&&pl(this.el)):this.isFocused&&(this.isFocused=!1,this.el.removeAttribute("data-js-focused"))},handleInsertModeChanged(t){this.isFocused&&!this.insertMode&&t?(this.insertMode=t,this.el.setAttribute("phx-update","ignore"),this.headingEl.setAttribute("contenteditable",""),this.headingEl.focus(),cL(this.headingEl)):this.insertMode&&!t&&(this.insertMode=t,this.headingEl.removeAttribute("contenteditable"),this.el.removeAttribute("phx-update"),this.pushEvent(this.props.onValueChange,{value:this.headingEl.textContent.trim(),metadata:this.props.metadata}))}};function cL(t){let e=document.createRange();e.selectNodeContents(t),e.collapse(!1);let r=window.getSelection();r.removeAllRanges(),r.addRange(e)}var uL=Ale;var Qle={mounted(){this.props=this.getProps(),this.sourceEl=na(this.el,"[data-source]"),this.targetEl=na(this.el,"[data-target]"),this.updateDOM()},updated(){this.props=this.getProps(),this.updateDOM()},getProps(){return $t(this.el,["language"])},updateDOM(){let t=this.sourceEl.innerText,e=XO(t,this.props.language);this.targetEl.innerHTML=e,this.el.setAttribute("data-highlighted","")}},fL=Qle;var xw=["bg-yellow-100","border-yellow-300"],$le={mounted(){this.props=this.getProps(),this.inputEl=this.el.querySelector("[data-input]"),this.previewEl=this.el.querySelector("[data-preview]"),this.initialPreviewContentEl=this.previewEl.firstElementChild,this.cameraPreviewEl=this.el.querySelector("[data-camera-preview]"),this.cameraListEl=this.el.querySelector("[data-camera-list]"),this.cameraItemTemplateEl=this.cameraListEl.firstElementChild,this.cameraItemTemplateEl.remove(),this.uploadButton=this.el.querySelector("[data-btn-upload]"),this.openCameraButton=this.el.querySelector("[data-btn-open-camera]"),this.captureCameraButton=this.el.querySelector("[data-btn-capture-camera]"),this.cancelButton=this.el.querySelector("[data-btn-cancel]"),this.cameraListPopulated=!1,this.cameraVideoEl=null,this.cameraStream=null,this.updateImagePreview(),this.uploadButton.addEventListener("click",t=>{this.inputEl.click()}),this.inputEl.addEventListener("change",t=>{let[e]=t.target.files;e&&this.loadFile(e)}),this.el.addEventListener("dragover",t=>{t.stopPropagation(),t.preventDefault(),t.dataTransfer.dropEffect="copy"}),this.el.addEventListener("drop",t=>{t.stopPropagation(),t.preventDefault();let[e]=t.dataTransfer.files;e&&this.loadFile(e),this.closeCameraView()}),this.el.addEventListener("dragenter",t=>{this.el.classList.add(...xw)}),this.el.addEventListener("dragleave",t=>{this.el.contains(t.relatedTarget)||this.el.classList.remove(...xw)}),this.el.addEventListener("drop",t=>{this.el.classList.remove(...xw)}),this.openCameraButton.addEventListener("click",t=>{this.cameraListPopulated||(this.renderCameraList(),this.cameraListPopulated=!0)}),this.cameraListEl.addEventListener("click",t=>{let e=t.target.closest("[data-camera-id]");if(e){let r=e.dataset.cameraId;this.openCameraView(r)}}),this.captureCameraButton.addEventListener("click",t=>{let e=this.toCanvas(this.cameraVideoEl,this.cameraVideoEl.videoWidth,this.cameraVideoEl.videoHeight);this.pushImage(e),this.closeCameraView()}),this.cancelButton.addEventListener("click",t=>{this.closeCameraView()})},updated(){this.props=this.getProps(),this.updateImagePreview()},getProps(){return $t(this.el,["id","phx-target","height","width","format","fit","image-url","value-height","value-width"])},updateImagePreview(){this.props.imageUrl?Ile(this.props.imageUrl,this.props.valueHeight,this.props.valueWidth,this.props.format).then(t=>{this.setPreview(t)}):this.setPreview(this.initialPreviewContentEl)},loadFile(t){let e=new FileReader;e.onload=r=>{let i=document.createElement("img");i.addEventListener("load",n=>{let o=this.toCanvas(i,i.width,i.height);this.pushImage(o)}),i.src=r.target.result},e.readAsDataURL(t)},openCameraView(t){this.cameraPreviewEl.classList.remove("hidden"),this.cancelButton.classList.remove("hidden"),this.captureCameraButton.classList.remove("hidden"),this.previewEl.classList.add("hidden"),this.openCameraButton.classList.add("hidden"),this.uploadButton.classList.add("hidden"),navigator.mediaDevices.getUserMedia(this.cameraConstraints(t)).then(e=>{this.cameraStream=e,this.cameraVideoEl=document.createElement("video"),this.cameraVideoEl.autoplay=!0,this.cameraVideoEl.playsinline=!0,this.cameraVideoEl.muted=!0,this.cameraVideoEl.srcObject=e,this.setCameraPreview(this.cameraVideoEl)}).catch(()=>{})},cameraConstraints(t){return t==="system_default"?{audio:!1,video:!0}:{audio:!1,video:{deviceId:t}}},renderCameraList(){navigator.mediaDevices.getUserMedia({audio:!1,video:!0}).then(t=>navigator.mediaDevices.enumerateDevices().then(e=>(this.stopMediaStream(t),e))).then(t=>{let e=t.filter(r=>r.kind==="videoinput").map(r=>({deviceId:r.deviceId,label:r.label}));[{deviceId:"system_default",label:"System Default"},...e].forEach(({deviceId:r,label:i})=>{let n=this.cameraItemTemplateEl.cloneNode(!0);n.querySelector("[data-camera-id]").setAttribute("data-camera-id",r),n.querySelector("[data-label]").innerHTML=i,this.cameraListEl.appendChild(n)})}).catch(t=>{console.error(t),this.openCameraButton.disabled=!0})},closeCameraView(){return this.cameraStream!==null&&(this.stopMediaStream(this.cameraStream),this.cameraStream=null),this.cameraVideoEl!==null&&(this.cameraVideoEl.remove(),this.cameraVideoEl=null),this.cameraPreviewEl.classList.add("hidden"),this.cancelButton.classList.add("hidden"),this.captureCameraButton.classList.add("hidden"),this.previewEl.classList.remove("hidden"),this.openCameraButton.classList.remove("hidden"),this.uploadButton.classList.remove("hidden"),!0},stopMediaStream(t){t.getTracks().forEach(e=>{e.stop()})},pushImage(t){Xle(t,this.props.format).then(e=>{let r={height:t.height,width:t.width},i=new Blob([e]);i.meta=()=>r,this.uploadTo(this.props.phxTarget,"file",[i])})},toCanvas(t,e,r){let{width:i,height:n}=this.props,o=document.createElement("canvas"),a=o.getContext("2d");if(i===null&&n===null||i===e&&n===r)o.width=e,o.height=r,o.getContext("2d").drawImage(t,0,0,e,r,0,0,e,r);else if(this.props.fit==="contain"){let s=i/e,l=n/r,c=Math.min(s,l),u=Math.round(e*c),f=Math.round(r*c);o.width=u,o.height=f,a.drawImage(t,0,0,e,r,0,0,u,f)}else if(this.props.fit==="crop"){let s=i/e,l=n/r,c=Math.max(s,l),u=Math.round(e*c),f=Math.round(r*c);o.width=i,o.height=n,a.drawImage(t,Math.round((u-i)/c/2),Math.round((f-n)/c/2),e-Math.round((u-i)/c),r-Math.round((f-n)/c),0,0,i,n)}else if(this.props.fit==="pad"){let s=i/e,l=n/r,c=Math.min(s,l),u=Math.round(e*c),f=Math.round(r*c);o.width=i,o.height=n,a.fillStyle="black",a.fillRect(0,0,o.width,o.height),a.drawImage(t,0,0,e,r,Math.round((i-u)/2),Math.round((n-f)/2),u,f)}else o.width=i,o.height=n,a.drawImage(t,0,0,e,r,0,0,i,n);return o},setPreview(t){t.style.maxHeight="300px",t.style.maxWidth="100%",this.previewEl.replaceChildren(t)},setCameraPreview(t){t.style.maxHeight="300px",t.style.maxWidth="100%",this.cameraPreviewEl.replaceChildren(t)}};function Xle(t,e){if(e==="png"||e==="jpeg")return new Promise((r,i)=>{t.toBlob(n=>{n.arrayBuffer().then(o=>{r(o)})},`image/${e}`)});if(e==="rgb"){let r=t.getContext("2d").getImageData(0,0,t.width,t.height),i=Rle(r);return Promise.resolve(i)}throw new Error(`Unexpected format: ${e}`)}function Rle(t){let e=t.width*t.height,r=new Uint8ClampedArray(e*3);for(let i=0;in.arrayBuffer()).then(n=>{let o=document.createElement("canvas");o.height=e,o.width=r;let a=Lle(n,r,e);return o.getContext("2d").putImageData(a,0,0),o});throw new Error(`Unexpected format: ${i}`)}function Lle(t,e,r){let i=e*r,n=new Uint8Array(t),o=new Uint8ClampedArray(i*4);for(let a=0;a{t.sandbox="allow-scripts allow-same-origin allow-downloads allow-forms allow-modals allow-popups allow-top-navigation",t.allow="accelerometer; ambient-light-sensor; camera; display-capture; encrypted-media; fullscreen; geolocation; gyroscope; microphone; midi; usb; xr-spatial-tracking; clipboard-read; clipboard-write; bluetooth; serial",t.src=i})}function Nle(t,e){let r=window.location.protocol;return e?e.replace(/^https?:/,r):r==="https:"?"https://livebookusercontent.com/iframe/v5.html":`http://${window.location.hostname}:${t}/iframe/v5.html`}var Sw=null;function Ule(t){return Sw||(Sw=fetch(t).then(e=>e.text()).then(e=>{if(uX(e)!==gL)throw new Error(`The iframe loaded from ${t} doesn't have the expected checksum ${gL}`)})),Sw}var qle={mounted(){this.props=this.getProps(),this.id=sX(),this.childToken=lX(),this.childReadyPromise=null,this.childReady=!1,this.initReceived=!1,this.syncCallbackQueue=[],this.pongCallbackQueue=[],this.initTimeout=setTimeout(()=>this.handleInitTimeout(),2e3),this.channel=pL(this.props.sessionToken),this.iframeActions=this.createIframe(),this.childReadyPromise=new Promise((n,o)=>{this._handleWindowMessage=a=>{a.source===this.iframe.contentWindow&&this.handleChildMessage(a.data,n)},window.addEventListener("message",this._handleWindowMessage)}),this.hiddenInput=document.createElement("input"),this.hiddenInput.style.display="none",this.el.appendChild(this.hiddenInput),this.iframeActions.visibilityPromise.then(()=>{this.loadIframe()});let t=this.channel.on(`init:${this.props.ref}:${this.id}`,n=>{let[,o]=kw(n);this.handleServerInit(o)}),e=this.channel.on(`event:${this.props.ref}`,n=>{let[[o],a]=kw(n);this.handleServerEvent(o,a)}),r=this.channel.on(`error:${this.props.ref}`,({message:n,init:o})=>{this.handleServerError(n,o)}),i=this.channel.on(`pong:${this.props.ref}`,()=>{this.handleServerPong()});this.unsubscribeFromChannelEvents=()=>{this.channel.off(`init:${this.props.ref}:${this.id}`,t),this.channel.off(`event:${this.props.ref}`,e),this.channel.off(`error:${this.props.ref}`,r),this.channel.off(`pong:${this.props.ref}`,i)},this.subscriptions=[_r.subscribe(`js_views:${this.props.ref}`,this.handleJSViewEvent.bind(this)),_r.subscribe("navigation",this.handleNavigationEvent.bind(this))],this.channel.push("connect",{connect_token:this.props.connectToken,ref:this.props.ref,id:this.id},3e4)},updated(){this.props=this.getProps(this)},disconnected(){this.el.removeAttribute("id")},destroyed(){window.removeEventListener("message",this._handleWindowMessage),this.iframeActions.remove(),this.unsubscribeFromChannelEvents(),this.channel.push("disconnect",{ref:this.props.ref}),this.subscriptions.forEach(t=>t.destroy())},getProps(){return $t(this.el,["ref","assets-base-path","assets-cdn-url","js-path","session-token","connect-token","iframe-port","iframe-url","timeout-message"])},createIframe(){this.iframePlaceholder=document.createElement("div"),this.el.appendChild(this.iframePlaceholder),this.iframe=document.createElement("iframe"),this.iframe.className="w-full h-0 absolute z-[1]";let t=document.querySelector("[data-el-notebook]"),e=t.querySelector("[data-el-notebook-content]"),r=new ResizeObserver(l=>{this.repositionIframe()});r.observe(e),r.observe(t);let i=po(this.iframePlaceholder),n=new ResizeObserver(l=>{let c=po(this.iframePlaceholder);i!==c&&(i=c,this.repositionIframe())});n.observe(this.iframePlaceholder);let o=_r.subscribe("js_views",l=>{l.type==="reposition"&&this.repositionIframe()});this.iframe.addEventListener("mouseenter",l=>{this.iframePlaceholder.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0}))}),this.iframe.addEventListener("mouseleave",l=>{this.iframePlaceholder.dispatchEvent(new MouseEvent("mouseleave",{bubbles:!0}))});let a=PO(this.iframePlaceholder,{root:t,proximity:2e3});this.iframe.toggleAttribute("data-js-focused",!!this.el.closest("[data-js-focused]"));let s=()=>{r.disconnect(),n.disconnect(),o.destroy(),a.cancel(),this.iframe.remove(),this.iframePlaceholder.remove()};return{visibilityPromise:a.promise,remove:s}},repositionIframe(){let{iframe:t,iframePlaceholder:e}=this,r=document.querySelector("[data-el-notebook]");if(po(e))t.classList.add("hidden");else{t.classList.remove("hidden");let i=r.getBoundingClientRect(),n=e.getBoundingClientRect(),o=n.top-i.top+r.scrollTop;t.style.top=`${o}px`;let a=n.left-i.left+r.scrollLeft;t.style.left=`${a}px`,t.style.height=`${n.height}px`,t.style.width=`${n.width}px`}},loadIframe(){let t=document.querySelector("[data-el-js-view-iframes]");bL(this.iframe,this.props.iframePort,this.props.iframeUrl).then(()=>{t.appendChild(this.iframe)})},handleChildMessage(t,e){if(t.type==="ready"&&!this.childReady)this.getAssetsBaseUrl().then(r=>{this.postMessage({type:"readyReply",token:this.childToken,baseUrl:r,jsPath:this.props.jsPath}),this.childReady=!0,e()});else{if(t.token!==this.childToken)throw new Error("Token mismatch");if(t.type==="resize")this.iframePlaceholder.style.height=`${t.height}px`,this.iframe.style.height=`${t.height}px`;else if(t.type==="domEvent"){let r=this.replicateDomEvent(t.event);t.isTargetEditable?this.hiddenInput.dispatchEvent(r):this.el.dispatchEvent(r)}else if(t.type==="event"){let{event:r,payload:i}=t,n=OL([r,this.props.ref],i);this.channel.push("event",n)}else t.type==="syncReply"?(this.pongCallbackQueue.push(this.syncCallbackQueue.shift()),this.channel.push("ping",{ref:this.props.ref})):t.type==="selectSecret"&&this.pushEvent("select_secret",{js_view_ref:this.props.ref,preselect_name:t.preselectName,options:t.options})}},getAssetsBaseUrl(){return Ug().then(t=>!t&&this.props.assetsCdnUrl?this.props.assetsCdnUrl:window.location.origin+this.props.assetsBasePath)},postMessage(t){this.iframe.contentWindow.postMessage(t,"*")},replicateDomEvent(t){if(t.type==="focus")return new FocusEvent("focus");if(t.type==="mousedown")return new MouseEvent("mousedown",{bubbles:!0});if(t.type==="keydown")return new KeyboardEvent(t.type,t.props)},handleInitTimeout(){this.initTimeoutContainer=document.createElement("div"),this.initTimeoutContainer.classList.add("info-box"),this.el.prepend(this.initTimeoutContainer),this.initTimeoutContainer.textContent=this.props.timeoutMessage},clearInitTimeout(){clearTimeout(this.initTimeout),this.initTimeoutContainer&&this.initTimeoutContainer.remove()},handleServerInit(t){this.clearInitTimeout(),this.initReceived=!0,this.childReadyPromise.then(()=>{this.postMessage({type:"init",data:t})})},handleServerEvent(t,e){this.initReceived&&this.childReadyPromise.then(()=>{this.postMessage({type:"event",event:t,payload:e})})},handleServerError(t,e){e&&this.clearInitTimeout(),this.errorContainer||(this.errorContainer=document.createElement("div"),this.errorContainer.classList.add("error-box","mb-4"),this.el.prepend(this.errorContainer)),this.errorContainer.textContent=t},handleServerPong(){this.pongCallbackQueue.shift()()},handleJSViewEvent(t){t.type==="sync"?(this.syncCallbackQueue.push(t.callback),this.postMessage({type:"sync"})):t.type=="secretSelected"&&this.postMessage({type:"secretSelected",secretName:t.secretName})},handleNavigationEvent(t){if(t.type==="element_focused"){let e=this.el.closest("[data-focusable-id]"),r=e?e.dataset.focusableId:null;this.iframe.toggleAttribute("data-js-focused",r===t.focusableId)}}};function Ug(){return Ug.promise=Ug.promise||fetch("/public/health").then(t=>t.status===200).catch(t=>!1),Ug.promise}var yL=qle;var Ble={mounted(){this.props=this.getProps(),this._handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this._handleDocumentKeyUp=this.handleDocumentKeyUp.bind(this),this._handleDocumentFocus=this.handleDocumentFocus.bind(this),window.addEventListener("keydown",this._handleDocumentKeyDown,!0),window.addEventListener("keyup",this._handleDocumentKeyUp,!0),window.addEventListener("focus",this._handleDocumentFocus,!0)},updated(){this.props=this.getProps()},destroyed(){window.removeEventListener("keydown",this._handleDocumentKeyDown,!0),window.removeEventListener("keyup",this._handleDocumentKeyUp,!0),window.removeEventListener("focus",this._handleDocumentFocus,!0)},getProps(){return $t(this.el,["cell-id","default-handlers","keydown-enabled","keyup-enabled","target"])},handleDocumentKeyDown(t){if(this.isKeyboardToggle(t)&&!cs(document.activeElement)){mo(t),this.keyboardEnabled()?this.disableKeyboard():this.enableKeyboard();return}if(this.keyboardEnabled()){if(this.props.defaultHandlers!=="on"&&mo(t),t.repeat)return;if(this.props.keydownEnabled){let{key:e}=t;this.pushEventTo(this.props.target,"keydown",{key:e})}}},handleDocumentKeyUp(t){if(this.keyboardEnabled()&&(this.props.defaultHandlers!=="on"&&mo(t),this.props.keyupEnabled)){let{key:e}=t;this.pushEventTo(this.props.target,"keyup",{key:e})}},handleDocumentFocus(t){this.props.keydownEnabled&&cs(t.target)&&this.disableKeyboard()},enableKeyboard(){this.keyboardEnabled()||this.pushEventTo(this.props.target,"enable_keyboard",{})},disableKeyboard(){this.keyboardEnabled()&&this.pushEventTo(this.props.target,"disable_keyboard",{})},keyboardEnabled(){return this.props.keydownEnabled||this.props.keyupEnabled},isKeyboardToggle(t){if(t.repeat)return!1;let{metaKey:e,ctrlKey:r,key:i}=t;return(CO()?e:r)&&i==="k"&&this.isCellFocused()?!this.keyboardEnabled()||["on","disable_only"].includes(this.props.defaultHandlers):!1},isCellFocused(){let t=this.el.closest("[data-el-session]");return t&&t.getAttribute("data-js-focused-id")===this.props.cellId}},vL=Ble;var jle={mounted(){this.props=this.getProps(),this.templateEl=na(this.el,"[data-template]"),this.contentEl=na(this.el,"[data-content]"),this.markdown=new ml(this.contentEl,this.templateEl.textContent,{baseUrl:this.props.basePath,allowedUriSchemes:this.props.allowedUriSchemes})},updated(){this.props=this.getProps(),this.markdown.setContent(this.templateEl.textContent)},getProps(){return $t(this.el,["base-path","allowed-uri-schemes"])}},xL=jle;var Wle={mounted(){this.scroll()},updated(){this.scroll()},scroll(){_h(this.el)}},wL=Wle;var bd=class{constructor(e=2e3){this.resetTimeout=e,this.buffer=[],this.resetTimeoutId=null}push(e){this.buffer.push(e),this.resetTimeoutId&&clearTimeout(this.resetTimeoutId),this.resetTimeoutId=setTimeout(()=>{this.reset()},this.resetTimeout)}reset(){this.resetTimeoutId&&clearTimeout(this.resetTimeoutId),this.resetTimeoutId=null,this.buffer=[]}tryMatch(e){if(e.length>this.buffer.length)return!1;let r=this.buffer.slice(-e.length),i=e.every((n,o)=>n===r[o]);return i&&this.reset(),i}};var Vle={mounted(){this.props=this.getProps(),this.focusedId=null,this.insertMode=!1,this.view=null,this.viewOptions=null,this.keyBuffer=new bd,this.lastLocationReportByClientId={},this.followedClientId=null,this.store=ru.create("session"),AO(this.faviconForEvaluationStatus(this.props.globalStatus)),this.updateSectionListHighlight(),this._handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this._handleEditorEscape=this.handleEditorEscape.bind(this),this._handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this._handleDocumentFocus=this.handleDocumentFocus.bind(this),this._handleDocumentClick=this.handleDocumentClick.bind(this),document.addEventListener("keydown",this._handleDocumentKeyDown,!0),document.addEventListener("lb:editor_escape",this._handleEditorEscape),document.addEventListener("mousedown",this._handleDocumentMouseDown),document.addEventListener("focus",this._handleDocumentFocus,!0),document.addEventListener("click",this._handleDocumentClick),this.getElement("sections-list").addEventListener("click",t=>{this.handleSectionsListClick(t),this.handleCellIndicatorsClick(t)}),this.getElement("clients-list").addEventListener("click",t=>this.handleClientsListClick(t)),this.getElement("sections-list-toggle").addEventListener("click",t=>this.toggleSectionsList()),this.getElement("clients-list-toggle").addEventListener("click",t=>this.toggleClientsList()),this.getElement("secrets-list-toggle").addEventListener("click",t=>this.toggleSecretsList()),this.getElement("runtime-info-toggle").addEventListener("click",t=>this.toggleRuntimeInfo()),this.getElement("app-info-toggle").addEventListener("click",t=>this.toggleAppInfo()),this.getElement("files-list-toggle").addEventListener("click",t=>this.toggleFilesList()),this.getElement("notebook").addEventListener("scroll",t=>this.updateSectionListHighlight()),this.getElement("notebook-indicators").addEventListener("click",t=>this.handleCellIndicatorsClick(t)),this.getElement("views").addEventListener("click",t=>{this.handleViewsClick(t)}),this.getElement("section-toggle-collapse-all-button").addEventListener("click",t=>this.toggleCollapseAllSections()),this.initializeDragAndDrop(),window.addEventListener("phx:page-loading-stop",()=>{this.initializeFocus()},{once:!0}),this.handleEvent("session_init",({clients:t,client_id:e})=>{let r={};for(let i of t)r[i.id]=i;this.store.set("clients",r),this.store.set("clientId",e)}),this.handleEvent("cell_inserted",({cell_id:t})=>{this.handleCellInserted(t)}),this.handleEvent("cell_deleted",({cell_id:t,sibling_cell_id:e})=>{this.handleCellDeleted(t,e)}),this.handleEvent("cell_restored",({cell_id:t})=>{this.handleCellRestored(t)}),this.handleEvent("cell_moved",({cell_id:t})=>{this.handleCellMoved(t)}),this.handleEvent("section_inserted",({section_id:t})=>{this.handleSectionInserted(t)}),this.handleEvent("section_deleted",({section_id:t})=>{this.handleSectionDeleted(t)}),this.handleEvent("section_moved",({section_id:t})=>{this.handleSectionMoved(t)}),this.handleEvent("client_joined",({client:t})=>{this.handleClientJoined(t)}),this.handleEvent("client_left",({client_id:t})=>{this.handleClientLeft(t)}),this.handleEvent("clients_updated",({clients:t})=>{this.handleClientsUpdated(t)}),this.handleEvent("secret_selected",({select_secret_ref:t,secret_name:e})=>{this.handleSecretSelected(t,e)}),this.handleEvent("location_report",({client_id:t,focusable_id:e})=>{let r={focusableId:e};this.handleLocationReport(t,r)})},updated(){let t=this.props;this.props=this.getProps(),this.props.globalStatus!==t.globalStatus&&AO(this.faviconForEvaluationStatus(this.props.globalStatus))},disconnected(){this.el.removeAttribute("id"),this.keepChannel=!0},destroyed(){document.removeEventListener("keydown",this._handleDocumentKeyDown,!0),document.removeEventListener("lb:editor_scape",this._handleEditorEscape),document.removeEventListener("mousedown",this._handleDocumentMouseDown),document.removeEventListener("focus",this._handleDocumentFocus,!0),document.removeEventListener("click",this._handleDocumentClick),AO("favicon"),this.keepChannel||mL(),this.store.destroy()},getProps(){return $t(this.el,["autofocus-cell-id","global-status"])},faviconForEvaluationStatus(t){return t==="evaluating"?"favicon-evaluating":t==="stale"?"favicon-stale":t==="errored"?"favicon-errored":"favicon"},handleDocumentKeyDown(t){if(t.repeat)return;let e=CO()?t.metaKey:t.ctrlKey,r=t.altKey,i=t.shiftKey,n=t.key,o=this.keyBuffer;if(!(cs(t.target)&&t.target.closest("[data-el-outputs-container]"))){if(e&&i&&!r&&n==="Enter"){mo(t),this.queueFullCellsEvaluation(!0);return}else if(!e&&i&&!r&&n==="Enter"){mo(t),Ol(this.focusedCellType())&&this.queueFocusedCellEvaluation(),this.moveFocus(1);return}else if(e&&!r&&n==="Enter"){mo(t),Ol(this.focusedCellType())&&this.queueFocusedCellEvaluation();return}else if(e&&n==="s"){mo(t),this.saveNotebook();return}else if(e||r)return}this.insertMode?(o.reset(),!t.target.closest("[data-el-editor-container]")&&n==="Escape"&&this.escapeInsertMode()):cs(t.target)?(o.reset(),n==="Escape"&&t.target.blur()):(o.push(t.key),o.tryMatch(["d","d"])?this.deleteFocusedCell():o.tryMatch(["e","a"])?this.queueFullCellsEvaluation(!1):o.tryMatch(["e","e"])?Ol(this.focusedCellType())&&this.queueFocusedCellEvaluation():o.tryMatch(["e","s"])?this.queueFocusedSectionEvaluation():o.tryMatch(["s","s"])?this.toggleSectionsList():o.tryMatch(["s","e"])?this.toggleSecretsList():o.tryMatch(["s","a"])?this.toggleAppInfo():o.tryMatch(["s","u"])?this.toggleClientsList():o.tryMatch(["s","f"])?this.toggleFilesList():o.tryMatch(["s","r"])?this.toggleRuntimeInfo():o.tryMatch(["s","b"])?this.showBin():o.tryMatch(["s","p"])?this.showPackageSearch():o.tryMatch(["e","x"])?this.cancelFocusedCellEvaluation():o.tryMatch(["0","0"])?this.reconnectRuntime():o.tryMatch(["Escape","Escape"])?this.setFocusedEl(null):o.tryMatch(["?"])?this.showShortcuts():o.tryMatch(["i"])||t.target.matches("body, [data-el-cell-body], [data-el-heading], [data-focusable-id]")&&this.focusedId&&n==="Enter"?(mo(t),this.isInsertModeAvailable()&&this.enterInsertMode()):o.tryMatch(["j"])?this.moveFocus(1):o.tryMatch(["k"])?this.moveFocus(-1):o.tryMatch(["J"])?this.moveFocusedCell(1):o.tryMatch(["K"])?this.moveFocusedCell(-1):o.tryMatch(["n"])?this.insertCellBelowFocused("code"):o.tryMatch(["N"])?this.insertCellAboveFocused("code"):o.tryMatch(["m"])?(!this.view||this.viewOptions.showMarkdown)&&this.insertCellBelowFocused("markdown"):o.tryMatch(["M"])?(!this.view||this.viewOptions.showMarkdown)&&this.insertCellAboveFocused("markdown"):o.tryMatch(["v","z"])?this.toggleView("code-zen"):o.tryMatch(["v","p"])?this.toggleView("presentation"):o.tryMatch(["v","c"])?this.toggleView("custom"):o.tryMatch(["c"])?(!this.view||this.viewOptions.showSection)&&this.toggleCollapseSection():o.tryMatch(["C"])&&(!this.view||this.viewOptions.showSection)&&this.toggleCollapseAllSections())},handleEditorEscape(){this.insertMode&&(this.keyBuffer.reset(),this.escapeInsertMode())},handleDocumentMouseDown(t){if(!t.target.closest("[data-el-notebook]")){this.insertMode&&this.setInsertMode(!1);return}if(t.target.closest(".cm-tooltip")){this.insertMode&&this.setInsertMode(!1);return}if(t.target.closest("[data-el-insert-buttons] button"))return;let e=t.target.closest("[data-focusable-id]"),r=e?e.dataset.focusableId:null,i=this.editableElementClicked(t,e);r!==this.focusedId&&this.setFocusedEl(r,{scroll:!1,focusElement:!1}),!t.target.closest("[data-el-actions]")&&this.insertMode!==i&&this.setInsertMode(i)},editableElementClicked(t,e){if(e){let r=t.target.closest("[data-el-editor-container], [data-el-heading]");return r&&e.contains(r)}return!1},handleDocumentFocus(t){let e=t.target.closest&&t.target.closest("[data-focusable-id]");if(e){let r=e.dataset.focusableId;r!==this.focusedId&&this.setFocusedEl(r,{scroll:!1,focusElement:!1})}},handleDocumentClick(t){t.target.closest("[data-el-enable-insert-mode-button]")&&this.setInsertMode(!0),t.target.closest("[data-btn-package-search]")&&this.insertMode&&this.setInsertMode(!1);let e=t.target.closest("[data-el-queue-cell-evaluation-button]");if(e){let i=e.getAttribute("data-cell-id"),n=e.hasAttribute("data-disable-dependencies-cache");this.queueCellEvaluation(i,n)}let r=window.location.hash;if(r){let i=r.replace(/^#/,"");!document.getElementById(i).contains(t.target)&&!t.target.closest("a")&&history.pushState(null,document.title,window.location.pathname+window.location.search)}},handleSectionsListClick(t){let e=t.target.closest("[data-el-sections-list-item]");if(e){let r=e.getAttribute("data-section-id");this.getSectionById(r).scrollIntoView({behavior:"smooth",block:"start"})}},handleClientsListClick(t){let e=t.target.closest("[data-el-clients-list-item]");if(e){let r=e.getAttribute("data-client-id");t.target.closest("[data-el-client-link]")&&this.handleClientLinkClick(r),t.target.closest("[data-el-client-follow-toggle]")&&this.handleClientFollowToggleClick(r,e)}},handleClientLinkClick(t){this.mirrorClientFocus(t)},handleClientFollowToggleClick(t,e){let r=this.el.querySelector("[data-el-clients-list-item][data-js-followed]");r&&r.removeAttribute("data-js-followed"),t===this.followedClientId?this.followedClientId=null:(e.setAttribute("data-js-followed",""),this.followedClientId=t,this.mirrorClientFocus(t))},mirrorClientFocus(t){let e=this.lastLocationReportByClientId[t];e&&e.focusableId&&this.setFocusedEl(e.focusableId)},handleCellIndicatorsClick(t){let e=t.target.closest("[data-el-focus-cell-button]");if(e){let r=e.getAttribute("data-target");this.setFocusedEl(r)}},initializeFocus(){let t=window.location.hash;if(t){let e=t.replace(/^#/,""),r=document.getElementById(e);if(r){let i=r.closest("[data-focusable-id]");i?this.setFocusedEl(i.dataset.focusableId):r.scrollIntoView()}}else this.props.autofocusCellId&&(this.setFocusedEl(this.props.autofocusCellId,{scroll:!1}),this.setInsertMode(!0))},updateSectionListHighlight(){let t=this.el.querySelector("[data-el-sections-list-item][data-js-is-viewed]");t&&t.removeAttribute("data-js-is-viewed");let e=this.getSections().reverse().find(r=>{let{top:i}=r.getBoundingClientRect(),n=document.documentElement.scrollTop;return i<=n+window.innerHeight*.35});if(e){let r=e.getAttribute("data-section-id");this.el.querySelector(`[data-el-sections-list-item][data-section-id="${r}"]`).setAttribute("data-js-is-viewed","")}},initializeDragAndDrop(){let t=!1,e=null,r=null,i=(o=null)=>{if(!t){t=!0,e=o;let a=o?"internal":"external";this.el.setAttribute("data-js-dragging",a),a==="external"&&this.toggleFilesList(!0)}},n=()=>{t&&(t=!1,this.el.removeAttribute("data-js-dragging"))};this.el.addEventListener("dragstart",o=>{i(o.target)}),this.el.addEventListener("dragenter",o=>{i()}),this.el.addEventListener("dragleave",o=>{this.el.contains(o.relatedTarget)||n()}),this.el.addEventListener("dragover",o=>{o.stopPropagation(),o.preventDefault()}),this.el.addEventListener("drop",o=>{o.stopPropagation(),o.preventDefault();let a=o.target.closest("[data-el-insert-drop-area]"),s=o.target.closest("[data-el-files-drop-area]");if(a){let l=a.getAttribute("data-section-id")||null,c=a.getAttribute("data-cell-id")||null;if(o.dataTransfer.files.length>0)r=o.dataTransfer.files,this.pushEvent("handle_file_drop",{section_id:l,cell_id:c});else if(e&&e.matches("[data-el-file-entry]")){let u=e.getAttribute("data-name");this.pushEvent("insert_file",{file_entry_name:u,section_id:l,cell_id:c})}}else s&&o.dataTransfer.files.length>0&&(r=o.dataTransfer.files,this.pushEvent("handle_file_drop",{}));n()}),this.handleEvent("finish_file_drop",o=>{let a=document.querySelector('#add-file-entry-modal input[type="file"]');a&&(a.files=r,a.dispatchEvent(new Event("change",{bubbles:!0})))})},toggleSectionsList(t=null){this.toggleSidePanelContent("sections-list",t)},toggleClientsList(t=null){this.toggleSidePanelContent("clients-list",t)},toggleSecretsList(t=null){this.toggleSidePanelContent("secrets-list",t)},toggleAppInfo(t=null){this.toggleSidePanelContent("app-info",t)},toggleFilesList(t=null){this.toggleSidePanelContent("files-list",t)},toggleRuntimeInfo(t=null){this.toggleSidePanelContent("runtime-info",t)},toggleSidePanelContent(t,e=null){(e===null?this.el.getAttribute("data-js-side-panel-content")!==t:e)?this.el.setAttribute("data-js-side-panel-content",t):this.el.removeAttribute("data-js-side-panel-content")},showBin(){let t=this.el.querySelector("[data-btn-show-bin]");t&&t.click()},showPackageSearch(){this.setFocusedEl("setup");let t=this.el.querySelector("[data-btn-package-search]");t&&t.click()},saveNotebook(){this.pushEvent("save",{})},deleteFocusedCell(){this.focusedId&&this.isCell(this.focusedId)&&this.pushEvent("delete_cell",{cell_id:this.focusedId})},queueCellEvaluation(t,e){this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_cell_evaluation",{cell_id:t,disable_dependencies_cache:e})})},queueFocusedCellEvaluation(){this.focusedId&&this.isCell(this.focusedId)&&this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_cell_evaluation",{cell_id:this.focusedId})})},queueFullCellsEvaluation(t){let e=t&&this.focusedId&&this.isCell(this.focusedId)?[this.focusedId]:[];this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_full_evaluation",{forced_cell_ids:e})})},queueFocusedSectionEvaluation(){if(this.focusedId){let t=this.getSectionIdByFocusableId(this.focusedId);t&&this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_section_evaluation",{section_id:t})})}},dispatchQueueEvaluation(t){Ol(this.focusedCellType())?_r.broadcast(`cells:${this.focusedId}`,{type:"dispatch_queue_evaluation",dispatch:t}):t()},cancelFocusedCellEvaluation(){this.focusedId&&this.isCell(this.focusedId)&&this.pushEvent("cancel_cell_evaluation",{cell_id:this.focusedId})},reconnectRuntime(){this.pushEvent("reconnect_runtime",{})},showShortcuts(){let t=this.el.querySelector("[data-btn-show-shortcuts]");t&&t.click()},isInsertModeAvailable(){if(!this.focusedId)return!1;let t=this.getFocusableEl(this.focusedId);return!this.isCell(this.focusedId)||!t.hasAttribute("data-js-insert-mode-disabled")},enterInsertMode(){this.focusedId&&this.setInsertMode(!0)},escapeInsertMode(){this.setInsertMode(!1)},moveFocus(t){let e=this.nearbyFocusableId(this.focusedId,t);this.setFocusedEl(e)},moveFocusedCell(t){this.focusedId&&this.isCell(this.focusedId)&&this.pushEvent("move_cell",{cell_id:this.focusedId,offset:t})},insertCellBelowFocused(t){if(this.focusedId)this.insertCellBelowFocusableId(this.focusedId,t);else{let e=this.getFocusableIds();e.length>0&&this.insertCellBelowFocusableId(e[e.length-1],t)}},insertCellAboveFocused(t){if(this.focusedId){let e=this.nearbyFocusableId(this.focusedId,-1);this.insertCellBelowFocusableId(e,t)}else{let e=this.getFocusableIds();e.length>0&&this.insertCellBelowFocusableId(e[0],t)}},insertCellBelowFocusableId(t,e){if(this.isCell(t))this.pushEvent("insert_cell_below",{type:e,cell_id:t});else if(this.isSection(t))this.pushEvent("insert_cell_below",{type:e,section_id:t});else if(this.isNotebook(t)){let r=this.getSectionIds();r.length>0&&this.pushEvent("insert_cell_below",{type:e,section_id:r[0]})}},setFocusedEl(t,{scroll:e=!0,focusElement:r=!0}={}){if(this.focusedId=t,t?this.el.setAttribute("data-js-focused-id",t):this.el.removeAttribute("data-js-focused-id"),t){if(!this.isSection(t)){let n=this.getSectionIdByFocusableId(t);n&&this.getSectionById(n).removeAttribute("data-js-collapsed")}let i=this.getFocusableEl(t);r&&(i.querySelector("[data-el-cell-body]")||i.querySelector("[data-el-heading]")||i).focus({preventScroll:!0})}_r.broadcast("navigation",{type:"element_focused",focusableId:t,scroll:e}),this.setInsertMode(!1),this.sendLocationReport({focusableId:t})},setInsertMode(t){this.insertMode=t,t?this.el.setAttribute("data-js-insert-mode",""):this.el.removeAttribute("data-js-insert-mode"),_r.broadcast("navigation",{type:"insert_mode_changed",enabled:t})},handleViewsClick(t){let e=t.target.closest("[data-el-view-toggle]");if(e){let r=e.getAttribute("data-el-view-toggle");this.toggleView(r)}},toggleView(t){t===this.view?(this.unsetView(),t==="custom"&&this.customViewSettingsSubscription.destroy()):t==="code-zen"?this.setView(t,{showSection:!1,showMarkdown:!1,showOutput:!0,spotlight:!1}):t==="presentation"?this.setView(t,{showSection:!0,showMarkdown:!0,showOutput:!0,spotlight:!0}):t==="custom"&&(this.customViewSettingsSubscription=er.getAndSubscribe(r=>{this.setView(t,{showSection:r.custom_view_show_section,showMarkdown:r.custom_view_show_markdown,showOutput:r.custom_view_show_output,spotlight:r.custom_view_spotlight})}),this.pushEvent("open_custom_view_settings"));let e=this.focusedId||this.nearbyFocusableId(null,0);if(e){let r=this.ensureVisibleFocusableEl(e);r!==this.focused&&this.setFocusedEl(r,{scroll:!1}),r&&this.getFocusableEl(r).scrollIntoView({block:"center"})}},setView(t,e){this.view=t,this.viewOptions=e,this.el.setAttribute("data-js-view",t),this.el.toggleAttribute("data-js-hide-section",!e.showSection),this.el.toggleAttribute("data-js-hide-markdown",!e.showMarkdown),this.el.toggleAttribute("data-js-hide-output",!e.showOutput),this.el.toggleAttribute("data-js-spotlight",e.spotlight)},unsetView(){this.view=null,this.viewOptions=null,this.el.removeAttribute("data-js-view"),this.el.removeAttribute("data-js-hide-section"),this.el.removeAttribute("data-js-hide-markdown"),this.el.removeAttribute("data-js-hide-output"),this.el.removeAttribute("data-js-spotlight")},toggleCollapseSection(){if(this.focusedId){let t=this.getSectionIdByFocusableId(this.focusedId);if(t){let e=this.getSectionById(t);e.hasAttribute("data-js-collapsed")?e.removeAttribute("data-js-collapsed"):(e.setAttribute("data-js-collapsed",""),this.setFocusedEl(t,{scroll:!0}))}}},toggleCollapseAllSections(){let t=this.getSections().every(e=>e.hasAttribute("data-js-collapsed"));if(this.getSections().forEach(e=>{e.toggleAttribute("data-js-collapsed",!t)}),this.focusedId){let e=this.getSectionIdByFocusableId(this.focusedId);e&&this.setFocusedEl(e,{scroll:!0})}},handleCellInserted(t){this.setFocusedEl(t),vX(this.focusedCellType())&&this.setInsertMode(!0)},handleCellDeleted(t,e){if(this.focusedId===t)if(this.view){let r=this.ensureVisibleFocusableEl(e);this.setFocusedEl(r)}else this.setFocusedEl(e)},handleCellRestored(t){this.setFocusedEl(t)},handleCellMoved(t){this.repositionJSViews(),this.focusedId===t&&_r.broadcast("cells",{type:"cell_moved",cellId:t})},handleSectionInserted(t){let r=this.getSectionById(t).querySelector("[data-el-section-headline]"),{focusableId:i}=r.dataset;this.setFocusedEl(i),this.setInsertMode(!0),iX(document.activeElement)},handleSectionDeleted(t){this.focusedId&&!this.getFocusableEl(this.focusedId)&&this.setFocusedEl(null)},handleSectionMoved(t){this.repositionJSViews();let e=this.getSectionById(t);pl(e)},handleClientJoined(t){let e=this.store.get("clients");this.store.set("clients",Be(oe({},e),{[t.id]:t}))},handleClientLeft(t){let e=this.store.get("clients"),r=e[t];if(r){let[,i]=$O(e,t);this.store.set("clients",i),r.id===this.followedClientId&&(this.followedClientId=null)}},handleClientsUpdated(t){let e=this.store.get("clients"),r=oe({},e);for(let i of t)r[i.id]=i;this.store.set("clients",r)},handleSecretSelected(t,e){_r.broadcast(`js_views:${t}`,{type:"secretSelected",secretName:e})},handleLocationReport(t,e){let r=this.store.get("clients")[t];this.lastLocationReportByClientId[t]=e,r&&r.id===this.followedClientId&&e.focusableId!==this.focusedId&&this.setFocusedEl(e.focusableId)},repositionJSViews(){_r.broadcast("js_views",{type:"reposition"})},sendLocationReport(t){Object.keys(this.store.get("clients")).length>1&&this.pushEvent("location_report",{focusable_id:t.focusableId})},focusedCellType(){return this.focusedId&&this.isCell(this.focusedId)?this.getFocusableEl(this.focusedId).getAttribute("data-type"):null},nearbyFocusableId(t,e){let r=this.getFocusableIds();if(r.length===0)return null;let i=r.indexOf(t);if(i===-1){let n=this.getFocusableEls().find(Tx);return n?n.getAttribute("data-focusable-id"):r[0]}else{let n=tX(i+e,0,r.length-1);return r[n]}},ensureVisibleFocusableEl(t){let e=this.getFocusableEl(t),r=Array.from(this.el.querySelectorAll("[data-focusable-id]")),i=r.indexOf(e),n=[...r.slice(i,-1),...r.slice(0,i).reverse()].find(o=>!po(o));return n&&n.getAttribute("data-focusable-id")},isCell(t){return this.getFocusableEl(t).hasAttribute("data-el-cell")},isSection(t){return this.getFocusableEl(t).hasAttribute("data-el-section-headline")},isNotebook(t){return this.getFocusableEl(t).hasAttribute("data-el-notebook-headline")},getFocusableEl(t){return this.el.querySelector(`[data-focusable-id="${t}"]`)},getFocusableEls(){return Array.from(this.el.querySelectorAll("[data-focusable-id]")).filter(t=>!po(t))},getFocusableIds(){return this.getFocusableEls().map(t=>t.getAttribute("data-focusable-id"))},getSectionIdByFocusableId(t){let r=this.getFocusableEl(t).closest("[data-el-section]");return r&&r.getAttribute("data-section-id")},getSectionIds(){return this.getSections().map(e=>e.getAttribute("data-section-id"))},getSections(){return Array.from(this.el.querySelectorAll("[data-el-section]"))},getSectionById(t){return this.el.querySelector(`[data-el-section][data-section-id="${t}"]`)},getElement(t){return this.el.querySelector(`[data-el-${t}]`)}},kL=Vle;var Fle={mounted(){this.autosize(),this.el.addEventListener("input",t=>{this.autosize()})},updated(){this.autosize()},autosize(){this.el.style.height="0px",this.el.style.height=`${this.el.scrollHeight+2}px`}},SL=Fle;var Zle=100,Yle={mounted(){this.props=this.getProps(),this.interval=setInterval(()=>this.updateDOM(),Zle)},updated(){this.props=this.getProps(),this.updateDOM()},destroyed(){clearInterval(this.interval)},getProps(){return $t(this.el,["start"])},updateDOM(){let e=(Date.now()-new Date(this.props.start))/1e3;this.el.innerHTML=`${e.toFixed(1)}s`}},TL=Yle;var EL="lb:user_data";function CL(t){let e=JSON.stringify(t),r=oX(e);Gle(EL,r,15768e4)}function PL(){let t=Hle(EL);if(t){let e=aX(t);return JSON.parse(e)}else return null}function Hle(t){let e=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`));return e?e.replace(`${t}=`,""):null}function Gle(t,e,r){let i=`${t}=${e};max-age=${r};path=/${QO()}`;document.cookie=i}var Kle={mounted(){this.el.addEventListener("submit",t=>{let e=this.el.user_form_name.value,r=this.el.user_form_hex_color.value;CL({name:e,hex_color:r})})}},_L=Kle;var Jle={mounted(){this.props=this.getProps(),this.updateAttrs(),this.el.addEventListener("blur",t=>{let e=this.datetimeLocalToUtc(this.el.value);this.pushEventTo(this.props.phxTarget,"change",{html_value:e})})},updated(){this.props=this.getProps(),this.updateAttrs()},getProps(){return $t(this.el,["utc-value","utc-min","utc-max","phx-target"])},updateAttrs(){this.el.value=this.datetimeUtcToLocal(this.props.utcValue),this.el.min=this.datetimeUtcToLocal(this.props.utcMin),this.el.max=this.datetimeUtcToLocal(this.props.utcMax)},datetimeUtcToLocal(t){if(!t)return null;let e=new Date(t+"Z"),r=e.getFullYear().toString(),i=(e.getMonth()+1).toString().padStart(2,"0"),n=e.getDate().toString().padStart(2,"0"),o=e.getHours().toString().padStart(2,"0"),a=e.getMinutes().toString().padStart(2,"0"),s=e.getSeconds().toString().padStart(2,"0");return`${r}-${i}-${n}T${o}:${a}:${s}`},datetimeLocalToUtc(t){if(!t)return null;let e=new Date(t),r=e.getUTCFullYear().toString(),i=(e.getUTCMonth()+1).toString().padStart(2,"0"),n=e.getUTCDate().toString().padStart(2,"0"),o=e.getUTCHours().toString().padStart(2,"0"),a=e.getUTCMinutes().toString().padStart(2,"0"),s=e.getUTCSeconds().toString().padStart(2,"0");return`${r}-${i}-${n}T${o}:${a}:${s}`}},AL=Jle;var ece={mounted(){this.props=this.getProps(),this.updateAttrs(),this.el.addEventListener("blur",t=>{let e=this.timeLocalToUtc(this.el.value);this.pushEventTo(this.props.phxTarget,"change",{html_value:e})})},updated(){this.props=this.getProps(),this.updateAttrs()},getProps(){return $t(this.el,["utc-value","utc-min","utc-max","phx-target"])},updateAttrs(){this.el.value=this.timeUtcToLocal(this.props.utcValue),this.el.min=this.timeUtcToLocal(this.props.utcMin),this.el.max=this.timeUtcToLocal(this.props.utcMax)},timeUtcToLocal(t){if(!t)return null;let e=new Date;e.setUTCHours(...t.split(":"));let r=e.getHours().toString().padStart(2,"0"),i=e.getMinutes().toString().padStart(2,"0"),n=e.getSeconds().toString().padStart(2,"0");return`${r}:${i}:${n}`},timeLocalToUtc(t){if(!t)return null;let e=new Date;e.setHours(...t.split(":"));let r=e.getUTCHours().toString().padStart(2,"0"),i=e.getUTCMinutes().toString().padStart(2,"0"),n=e.getUTCSeconds().toString().padStart(2,"0");return`${r}:${i}:${n}`}},QL=ece;var RL=Al(XL());var tce={mounted(){this.props=this.getProps(),this.lineHeight=rX(this.el),this.templateEl=na(this.el,"[data-template]"),this.contentEl=na(this.el,"[data-content]"),this.capLines();let t=this.hyperListConfig();this.virtualizedList=new RL.default(this.contentEl,t),this.props.follow&&_h(this.contentEl)},updated(){this.props=this.getProps(),this.capLines();let t=this.props.follow&&nX(this.contentEl),e=this.hyperListConfig();this.virtualizedList.refresh(this.contentEl,e),t&&_h(this.contentEl)},getProps(){return $t(this.el,["max-height","follow","max-lines","ignore-trailing-empty-line"])},hyperListConfig(){let t=this.getLineElements(),e=t.length,r=Math.min(this.props.maxHeight,this.lineHeight*e);return{height:r,total:e,itemHeight:this.lineHeight,generate:i=>{let n=t[i].cloneNode(!0);return n.removeAttribute("id"),n},afterRender:()=>{this.contentEl.scrollWidth>this.contentEl.clientWidth?this.contentEl.style.height=`${r+12}px`:this.contentEl.style.height=`${r}px`}}},getLineElements(){let t=Array.from(this.templateEl.querySelectorAll("[data-line]"));if(t.length===0)return[];let e=t[t.length-1];return this.props.ignoreTrailingEmptyLine&&e.innerText===""?t.slice(0,-1):t},capLines(){if(this.props.maxLines){let e=Array.from(this.templateEl.querySelectorAll("[data-line]")).slice(0,-this.props.maxLines),[r,...i]=e;i.forEach(n=>n.remove()),r&&(r.innerHTML="...")}}},IL=tce;var rce={mounted(){let t=er.get(),e=this.el.querySelector('[name="show_section"][value="true"]'),r=this.el.querySelector('[name="show_markdown"][value="true"]'),i=this.el.querySelector('[name="show_output"][value="true"]'),n=this.el.querySelector('[name="spotlight"][value="true"]');e.checked=t.custom_view_show_section,r.checked=t.custom_view_show_markdown,i.checked=t.custom_view_show_output,n.checked=t.custom_view_spotlight,e.addEventListener("change",o=>{er.update({custom_view_show_section:o.target.checked})}),r.addEventListener("change",o=>{er.update({custom_view_show_markdown:o.target.checked})}),i.addEventListener("change",o=>{er.update({custom_view_show_output:o.target.checked})}),n.addEventListener("change",o=>{er.update({custom_view_spotlight:o.target.checked})})}},LL=rce;var ML={AppAuth:Wk,AudioInput:Yk,Cell:xX,CellEditor:vI,Dropzone:xI,EditorSettings:wI,EmojiPicker:sL,FocusOnUpdate:lL,Headline:uL,Highlight:fL,ImageInput:hL,ImageOutput:dL,JSView:yL,KeyboardControl:vL,MarkdownRenderer:xL,ScrollOnUpdate:wL,Session:kL,TextareaAutosize:SL,Timer:TL,UserForm:_L,UtcDateTimeInput:AL,UtcTimeInput:QL,VirtualizedLines:IL,CustomViewSettings:LL};var zL={onBeforeElUpdated(t,e){for(let r of t.attributes)r.name.startsWith("data-js-")&&e.setAttribute(r.name,r.value),r.name==="data-keep-attribute"&&(t.hasAttribute(r.value)?e.setAttribute(r.value,t.getAttribute(r.value)):e.removeAttribute(r.value))},onNodeAdded(t){if(t.nodeType===Node.ELEMENT_NODE&&t.hasAttribute("autofocus")&&(t.focus(),t.setSelectionRange&&t.value)){let e=t.value.length;t.setSelectionRange(e,e)}}};var Bg=Al(NL());function UL(){Bg.default.config({barColors:{0:"#b2c1ff"},shadowColor:"rgba(0, 0, 0, .3)"}),window.addEventListener("phx:page-loading-start",()=>{Bg.default.show(500)}),window.addEventListener("phx:page-loading-stop",()=>{Bg.default.hide()})}function qL(){window.addEventListener("lb:focus",t=>{requestAnimationFrame(()=>{t.target.focus()})}),window.addEventListener("lb:set_value",t=>{t.target.value=t.detail.value}),window.addEventListener("lb:check",t=>{t.target.checked=!0}),window.addEventListener("lb:uncheck",t=>{t.target.checked=!1}),window.addEventListener("lb:set_text",t=>{t.target.textContent=t.detail.value}),window.addEventListener("lb:clipcopy",t=>{"clipboard"in navigator?t.detail.content?navigator.clipboard.writeText(t.detail.content):t.target.tagName==="INPUT"?navigator.clipboard.writeText(t.target.value):navigator.clipboard.writeText(t.target.textContent):alert(`Sorry, your browser does not support clipboard copy. +`," ");document.execCommand("insertText",!1,r)}),this.headingEl.addEventListener("keydown",e=>{e.key==="Enter"&&e.preventDefault()}),this.headingEl.addEventListener("blur",e=>{setTimeout(()=>{this.isFocused&&this.insertMode&&(this.headingEl.focus(),cL(this.headingEl))},0)}))},handleNavigationEvent(t){t.type==="element_focused"?this.handleElementFocused(t.focusableId,t.scroll):t.type==="insert_mode_changed"&&this.handleInsertModeChanged(t.enabled)},handleElementFocused(t,e){this.props.id===t?(this.isFocused=!0,this.el.setAttribute("data-js-focused",""),e&&pl(this.el)):this.isFocused&&(this.isFocused=!1,this.el.removeAttribute("data-js-focused"))},handleInsertModeChanged(t){this.isFocused&&!this.insertMode&&t?(this.insertMode=t,this.el.setAttribute("phx-update","ignore"),this.headingEl.setAttribute("contenteditable",""),this.headingEl.focus(),cL(this.headingEl)):this.insertMode&&!t&&(this.insertMode=t,this.headingEl.removeAttribute("contenteditable"),this.el.removeAttribute("phx-update"),this.pushEvent(this.props.onValueChange,{value:this.headingEl.textContent.trim(),metadata:this.props.metadata}))}};function cL(t){let e=document.createRange();e.selectNodeContents(t),e.collapse(!1);let r=window.getSelection();r.removeAllRanges(),r.addRange(e)}var uL=Ale;var Qle={mounted(){this.props=this.getProps(),this.sourceEl=na(this.el,"[data-source]"),this.targetEl=na(this.el,"[data-target]"),this.updateDOM()},updated(){this.props=this.getProps(),this.updateDOM()},getProps(){return $t(this.el,["language"])},updateDOM(){let t=this.sourceEl.innerText,e=XO(t,this.props.language);this.targetEl.innerHTML=e,this.el.setAttribute("data-highlighted","")}},fL=Qle;var xw=["bg-yellow-100","border-yellow-300"],$le={mounted(){this.props=this.getProps(),this.inputEl=this.el.querySelector("[data-input]"),this.previewEl=this.el.querySelector("[data-preview]"),this.initialPreviewContentEl=this.previewEl.firstElementChild,this.cameraPreviewEl=this.el.querySelector("[data-camera-preview]"),this.cameraListEl=this.el.querySelector("[data-camera-list]"),this.cameraItemTemplateEl=this.cameraListEl.firstElementChild,this.cameraItemTemplateEl.remove(),this.uploadButton=this.el.querySelector("[data-btn-upload]"),this.openCameraButton=this.el.querySelector("[data-btn-open-camera]"),this.captureCameraButton=this.el.querySelector("[data-btn-capture-camera]"),this.cancelButton=this.el.querySelector("[data-btn-cancel]"),this.cameraListPopulated=!1,this.cameraVideoEl=null,this.cameraStream=null,this.updateImagePreview(),this.uploadButton.addEventListener("click",t=>{this.inputEl.click()}),this.inputEl.addEventListener("change",t=>{let[e]=t.target.files;e&&this.loadFile(e)}),this.el.addEventListener("dragover",t=>{t.stopPropagation(),t.preventDefault(),t.dataTransfer.dropEffect="copy"}),this.el.addEventListener("drop",t=>{t.stopPropagation(),t.preventDefault();let[e]=t.dataTransfer.files;e&&this.loadFile(e),this.closeCameraView()}),this.el.addEventListener("dragenter",t=>{this.el.classList.add(...xw)}),this.el.addEventListener("dragleave",t=>{this.el.contains(t.relatedTarget)||this.el.classList.remove(...xw)}),this.el.addEventListener("drop",t=>{this.el.classList.remove(...xw)}),this.openCameraButton.addEventListener("click",t=>{this.cameraListPopulated||(this.renderCameraList(),this.cameraListPopulated=!0)}),this.cameraListEl.addEventListener("click",t=>{let e=t.target.closest("[data-camera-id]");if(e){let r=e.dataset.cameraId;this.openCameraView(r)}}),this.captureCameraButton.addEventListener("click",t=>{let e=this.toCanvas(this.cameraVideoEl,this.cameraVideoEl.videoWidth,this.cameraVideoEl.videoHeight);this.pushImage(e),this.closeCameraView()}),this.cancelButton.addEventListener("click",t=>{this.closeCameraView()})},updated(){this.props=this.getProps(),this.updateImagePreview()},getProps(){return $t(this.el,["id","phx-target","height","width","format","fit","image-url","value-height","value-width"])},updateImagePreview(){this.props.imageUrl?Ile(this.props.imageUrl,this.props.valueHeight,this.props.valueWidth,this.props.format).then(t=>{this.setPreview(t)}):this.setPreview(this.initialPreviewContentEl)},loadFile(t){let e=new FileReader;e.onload=r=>{let i=document.createElement("img");i.addEventListener("load",n=>{let o=this.toCanvas(i,i.width,i.height);this.pushImage(o)}),i.src=r.target.result},e.readAsDataURL(t)},openCameraView(t){this.cameraPreviewEl.classList.remove("hidden"),this.cancelButton.classList.remove("hidden"),this.captureCameraButton.classList.remove("hidden"),this.previewEl.classList.add("hidden"),this.openCameraButton.classList.add("hidden"),this.uploadButton.classList.add("hidden"),navigator.mediaDevices.getUserMedia(this.cameraConstraints(t)).then(e=>{this.cameraStream=e,this.cameraVideoEl=document.createElement("video"),this.cameraVideoEl.autoplay=!0,this.cameraVideoEl.playsinline=!0,this.cameraVideoEl.muted=!0,this.cameraVideoEl.srcObject=e,this.setCameraPreview(this.cameraVideoEl)}).catch(()=>{})},cameraConstraints(t){return t==="system_default"?{audio:!1,video:!0}:{audio:!1,video:{deviceId:t}}},renderCameraList(){navigator.mediaDevices.getUserMedia({audio:!1,video:!0}).then(t=>navigator.mediaDevices.enumerateDevices().then(e=>(this.stopMediaStream(t),e))).then(t=>{let e=t.filter(r=>r.kind==="videoinput").map(r=>({deviceId:r.deviceId,label:r.label}));[{deviceId:"system_default",label:"System Default"},...e].forEach(({deviceId:r,label:i})=>{let n=this.cameraItemTemplateEl.cloneNode(!0);n.querySelector("[data-camera-id]").setAttribute("data-camera-id",r),n.querySelector("[data-label]").innerHTML=i,this.cameraListEl.appendChild(n)})}).catch(t=>{console.error(t),this.openCameraButton.disabled=!0})},closeCameraView(){return this.cameraStream!==null&&(this.stopMediaStream(this.cameraStream),this.cameraStream=null),this.cameraVideoEl!==null&&(this.cameraVideoEl.remove(),this.cameraVideoEl=null),this.cameraPreviewEl.classList.add("hidden"),this.cancelButton.classList.add("hidden"),this.captureCameraButton.classList.add("hidden"),this.previewEl.classList.remove("hidden"),this.openCameraButton.classList.remove("hidden"),this.uploadButton.classList.remove("hidden"),!0},stopMediaStream(t){t.getTracks().forEach(e=>{e.stop()})},pushImage(t){Xle(t,this.props.format).then(e=>{let r={height:t.height,width:t.width},i=new Blob([e]);i.meta=()=>r,this.uploadTo(this.props.phxTarget,"file",[i])})},toCanvas(t,e,r){let{width:i,height:n}=this.props,o=document.createElement("canvas"),a=o.getContext("2d");if(i===null&&n===null||i===e&&n===r)o.width=e,o.height=r,o.getContext("2d").drawImage(t,0,0,e,r,0,0,e,r);else if(this.props.fit==="contain"){let s=i/e,l=n/r,c=Math.min(s,l),u=Math.round(e*c),f=Math.round(r*c);o.width=u,o.height=f,a.drawImage(t,0,0,e,r,0,0,u,f)}else if(this.props.fit==="crop"){let s=i/e,l=n/r,c=Math.max(s,l),u=Math.round(e*c),f=Math.round(r*c);o.width=i,o.height=n,a.drawImage(t,Math.round((u-i)/c/2),Math.round((f-n)/c/2),e-Math.round((u-i)/c),r-Math.round((f-n)/c),0,0,i,n)}else if(this.props.fit==="pad"){let s=i/e,l=n/r,c=Math.min(s,l),u=Math.round(e*c),f=Math.round(r*c);o.width=i,o.height=n,a.fillStyle="black",a.fillRect(0,0,o.width,o.height),a.drawImage(t,0,0,e,r,Math.round((i-u)/2),Math.round((n-f)/2),u,f)}else o.width=i,o.height=n,a.drawImage(t,0,0,e,r,0,0,i,n);return o},setPreview(t){t.style.maxHeight="300px",t.style.maxWidth="100%",this.previewEl.replaceChildren(t)},setCameraPreview(t){t.style.maxHeight="300px",t.style.maxWidth="100%",this.cameraPreviewEl.replaceChildren(t)}};function Xle(t,e){if(e==="png"||e==="jpeg")return new Promise((r,i)=>{t.toBlob(n=>{n.arrayBuffer().then(o=>{r(o)})},`image/${e}`)});if(e==="rgb"){let r=t.getContext("2d").getImageData(0,0,t.width,t.height),i=Rle(r);return Promise.resolve(i)}throw new Error(`Unexpected format: ${e}`)}function Rle(t){let e=t.width*t.height,r=new Uint8ClampedArray(e*3);for(let i=0;in.arrayBuffer()).then(n=>{let o=document.createElement("canvas");o.height=e,o.width=r;let a=Lle(n,r,e);return o.getContext("2d").putImageData(a,0,0),o});throw new Error(`Unexpected format: ${i}`)}function Lle(t,e,r){let i=e*r,n=new Uint8Array(t),o=new Uint8ClampedArray(i*4);for(let a=0;a{t.sandbox="allow-scripts allow-same-origin allow-downloads allow-forms allow-modals allow-popups allow-top-navigation",t.allow="accelerometer; ambient-light-sensor; camera; display-capture; encrypted-media; fullscreen; geolocation; gyroscope; microphone; midi; usb; xr-spatial-tracking; clipboard-read; clipboard-write; bluetooth; serial",t.src=i})}function Nle(t,e){let r=window.location.protocol;return e?e.replace(/^https?:/,r):r==="https:"?"https://livebookusercontent.com/iframe/v5.html":`http://${window.location.hostname}:${t}/iframe/v5.html`}var Sw=null;function Ule(t){return Sw||(Sw=fetch(t).then(e=>e.text()).then(e=>{if(uX(e)!==gL)throw new Error(`The iframe loaded from ${t} doesn't have the expected checksum ${gL}`)})),Sw}var qle={mounted(){this.props=this.getProps(),this.id=sX(),this.childToken=lX(),this.childReadyPromise=null,this.childReady=!1,this.initReceived=!1,this.syncCallbackQueue=[],this.pongCallbackQueue=[],this.initTimeout=setTimeout(()=>this.handleInitTimeout(),2e3),this.channel=pL(this.props.sessionToken),this.iframeActions=this.createIframe(),this.childReadyPromise=new Promise((n,o)=>{this._handleWindowMessage=a=>{a.source===this.iframe.contentWindow&&this.handleChildMessage(a.data,n)},window.addEventListener("message",this._handleWindowMessage)}),this.hiddenInput=document.createElement("input"),this.hiddenInput.style.display="none",this.el.appendChild(this.hiddenInput),this.iframeActions.visibilityPromise.then(()=>{this.loadIframe()});let t=this.channel.on(`init:${this.props.ref}:${this.id}`,n=>{let[,o]=kw(n);this.handleServerInit(o)}),e=this.channel.on(`event:${this.props.ref}`,n=>{let[[o],a]=kw(n);this.handleServerEvent(o,a)}),r=this.channel.on(`error:${this.props.ref}`,({message:n,init:o})=>{this.handleServerError(n,o)}),i=this.channel.on(`pong:${this.props.ref}`,()=>{this.handleServerPong()});this.unsubscribeFromChannelEvents=()=>{this.channel.off(`init:${this.props.ref}:${this.id}`,t),this.channel.off(`event:${this.props.ref}`,e),this.channel.off(`error:${this.props.ref}`,r),this.channel.off(`pong:${this.props.ref}`,i)},this.subscriptions=[_r.subscribe(`js_views:${this.props.ref}`,this.handleJSViewEvent.bind(this)),_r.subscribe("navigation",this.handleNavigationEvent.bind(this))],this.channel.push("connect",{connect_token:this.props.connectToken,ref:this.props.ref,id:this.id},3e4)},updated(){this.props=this.getProps(this)},disconnected(){this.el.removeAttribute("id")},destroyed(){window.removeEventListener("message",this._handleWindowMessage),this.iframeActions.remove(),this.unsubscribeFromChannelEvents(),this.channel.push("disconnect",{ref:this.props.ref}),this.subscriptions.forEach(t=>t.destroy())},getProps(){return $t(this.el,["ref","assets-base-path","assets-cdn-url","js-path","session-token","connect-token","iframe-port","iframe-url","timeout-message"])},createIframe(){this.iframePlaceholder=document.createElement("div"),this.el.appendChild(this.iframePlaceholder),this.iframe=document.createElement("iframe"),this.iframe.className="w-full h-0 absolute z-[1]";let t=document.querySelector("[data-el-notebook]"),e=t.querySelector("[data-el-notebook-content]"),r=new ResizeObserver(l=>{this.repositionIframe()});r.observe(e),r.observe(t);let i=po(this.iframePlaceholder),n=new ResizeObserver(l=>{let c=po(this.iframePlaceholder);i!==c&&(i=c,this.repositionIframe())});n.observe(this.iframePlaceholder);let o=_r.subscribe("js_views",l=>{l.type==="reposition"&&this.repositionIframe()});this.iframe.addEventListener("mouseenter",l=>{this.iframePlaceholder.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0}))}),this.iframe.addEventListener("mouseleave",l=>{this.iframePlaceholder.dispatchEvent(new MouseEvent("mouseleave",{bubbles:!0}))});let a=PO(this.iframePlaceholder,{root:t,proximity:2e3});this.iframe.toggleAttribute("data-js-focused",!!this.el.closest("[data-js-focused]"));let s=()=>{r.disconnect(),n.disconnect(),o.destroy(),a.cancel(),this.iframe.remove(),this.iframePlaceholder.remove()};return{visibilityPromise:a.promise,remove:s}},repositionIframe(){let{iframe:t,iframePlaceholder:e}=this,r=document.querySelector("[data-el-notebook]");if(po(e))t.classList.add("hidden");else{t.classList.remove("hidden");let i=r.getBoundingClientRect(),n=e.getBoundingClientRect(),o=n.top-i.top+r.scrollTop;t.style.top=`${o}px`;let a=n.left-i.left+r.scrollLeft;t.style.left=`${a}px`,t.style.height=`${n.height}px`,t.style.width=`${n.width}px`}},loadIframe(){let t=document.querySelector("[data-el-js-view-iframes]");bL(this.iframe,this.props.iframePort,this.props.iframeUrl).then(()=>{t.appendChild(this.iframe)})},handleChildMessage(t,e){if(t.type==="ready"&&!this.childReady)this.getAssetsBaseUrl().then(r=>{this.postMessage({type:"readyReply",token:this.childToken,baseUrl:r,jsPath:this.props.jsPath}),this.childReady=!0,e()});else{if(t.token!==this.childToken)throw new Error("Token mismatch");if(t.type==="resize")this.iframePlaceholder.style.height=`${t.height}px`,this.iframe.style.height=`${t.height}px`;else if(t.type==="domEvent"){let r=this.replicateDomEvent(t.event);t.isTargetEditable?this.hiddenInput.dispatchEvent(r):this.el.dispatchEvent(r)}else if(t.type==="event"){let{event:r,payload:i}=t,n=OL([r,this.props.ref],i);this.channel.push("event",n)}else t.type==="syncReply"?(this.pongCallbackQueue.push(this.syncCallbackQueue.shift()),this.channel.push("ping",{ref:this.props.ref})):t.type==="selectSecret"&&this.pushEvent("select_secret",{js_view_ref:this.props.ref,preselect_name:t.preselectName,options:t.options})}},getAssetsBaseUrl(){return Ug().then(t=>!t&&this.props.assetsCdnUrl?this.props.assetsCdnUrl:window.location.origin+this.props.assetsBasePath)},postMessage(t){this.iframe.contentWindow.postMessage(t,"*")},replicateDomEvent(t){if(t.type==="focus")return new FocusEvent("focus");if(t.type==="mousedown")return new MouseEvent("mousedown",{bubbles:!0});if(t.type==="keydown")return new KeyboardEvent(t.type,t.props)},handleInitTimeout(){this.initTimeoutContainer=document.createElement("div"),this.initTimeoutContainer.classList.add("info-box"),this.el.prepend(this.initTimeoutContainer),this.initTimeoutContainer.textContent=this.props.timeoutMessage},clearInitTimeout(){clearTimeout(this.initTimeout),this.initTimeoutContainer&&this.initTimeoutContainer.remove()},handleServerInit(t){this.clearInitTimeout(),this.initReceived=!0,this.childReadyPromise.then(()=>{this.postMessage({type:"init",data:t})})},handleServerEvent(t,e){this.initReceived&&this.childReadyPromise.then(()=>{this.postMessage({type:"event",event:t,payload:e})})},handleServerError(t,e){e&&this.clearInitTimeout(),this.errorContainer||(this.errorContainer=document.createElement("div"),this.errorContainer.classList.add("error-box","mb-4"),this.el.prepend(this.errorContainer)),this.errorContainer.textContent=t},handleServerPong(){this.pongCallbackQueue.shift()()},handleJSViewEvent(t){t.type==="sync"?(this.syncCallbackQueue.push(t.callback),this.postMessage({type:"sync"})):t.type=="secretSelected"&&this.postMessage({type:"secretSelected",secretName:t.secretName})},handleNavigationEvent(t){if(t.type==="element_focused"){let e=this.el.closest("[data-focusable-id]"),r=e?e.dataset.focusableId:null;this.iframe.toggleAttribute("data-js-focused",r===t.focusableId)}}};function Ug(){return Ug.promise=Ug.promise||fetch("/public/health").then(t=>t.status===200).catch(t=>!1),Ug.promise}var yL=qle;var Ble={mounted(){this.props=this.getProps(),this._handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this._handleDocumentKeyUp=this.handleDocumentKeyUp.bind(this),this._handleDocumentFocus=this.handleDocumentFocus.bind(this),window.addEventListener("keydown",this._handleDocumentKeyDown,!0),window.addEventListener("keyup",this._handleDocumentKeyUp,!0),window.addEventListener("focus",this._handleDocumentFocus,!0)},updated(){this.props=this.getProps()},destroyed(){window.removeEventListener("keydown",this._handleDocumentKeyDown,!0),window.removeEventListener("keyup",this._handleDocumentKeyUp,!0),window.removeEventListener("focus",this._handleDocumentFocus,!0)},getProps(){return $t(this.el,["cell-id","default-handlers","keydown-enabled","keyup-enabled","target"])},handleDocumentKeyDown(t){if(this.isKeyboardToggle(t)&&!cs(document.activeElement)){mo(t),this.keyboardEnabled()?this.disableKeyboard():this.enableKeyboard();return}if(this.keyboardEnabled()){if(this.props.defaultHandlers!=="on"&&mo(t),t.repeat)return;if(this.props.keydownEnabled){let{key:e}=t;this.pushEventTo(this.props.target,"keydown",{key:e})}}},handleDocumentKeyUp(t){if(this.keyboardEnabled()&&(this.props.defaultHandlers!=="on"&&mo(t),this.props.keyupEnabled)){let{key:e}=t;this.pushEventTo(this.props.target,"keyup",{key:e})}},handleDocumentFocus(t){this.props.keydownEnabled&&cs(t.target)&&this.disableKeyboard()},enableKeyboard(){this.keyboardEnabled()||this.pushEventTo(this.props.target,"enable_keyboard",{})},disableKeyboard(){this.keyboardEnabled()&&this.pushEventTo(this.props.target,"disable_keyboard",{})},keyboardEnabled(){return this.props.keydownEnabled||this.props.keyupEnabled},isKeyboardToggle(t){if(t.repeat)return!1;let{metaKey:e,ctrlKey:r,key:i}=t;return(CO()?e:r)&&i==="k"&&this.isCellFocused()?!this.keyboardEnabled()||["on","disable_only"].includes(this.props.defaultHandlers):!1},isCellFocused(){let t=this.el.closest("[data-el-session]");return t&&t.getAttribute("data-js-focused-id")===this.props.cellId}},vL=Ble;var jle={mounted(){this.props=this.getProps(),this.templateEl=na(this.el,"[data-template]"),this.contentEl=na(this.el,"[data-content]"),this.markdown=new ml(this.contentEl,this.templateEl.textContent,{baseUrl:this.props.basePath,allowedUriSchemes:this.props.allowedUriSchemes})},updated(){this.props=this.getProps(),this.markdown.setContent(this.templateEl.textContent)},getProps(){return $t(this.el,["base-path","allowed-uri-schemes"])}},xL=jle;var Wle={mounted(){this.scroll()},updated(){this.scroll()},scroll(){_h(this.el)}},wL=Wle;var bd=class{constructor(e=2e3){this.resetTimeout=e,this.buffer=[],this.resetTimeoutId=null}push(e){this.buffer.push(e),this.resetTimeoutId&&clearTimeout(this.resetTimeoutId),this.resetTimeoutId=setTimeout(()=>{this.reset()},this.resetTimeout)}reset(){this.resetTimeoutId&&clearTimeout(this.resetTimeoutId),this.resetTimeoutId=null,this.buffer=[]}tryMatch(e){if(e.length>this.buffer.length)return!1;let r=this.buffer.slice(-e.length),i=e.every((n,o)=>n===r[o]);return i&&this.reset(),i}};var Vle={mounted(){this.props=this.getProps(),this.focusedId=null,this.insertMode=!1,this.view=null,this.viewOptions=null,this.keyBuffer=new bd,this.lastLocationReportByClientId={},this.followedClientId=null,this.store=ru.create("session"),AO(this.faviconForEvaluationStatus(this.props.globalStatus)),this.updateSectionListHighlight(),this._handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this._handleEditorEscape=this.handleEditorEscape.bind(this),this._handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this._handleDocumentFocus=this.handleDocumentFocus.bind(this),this._handleDocumentClick=this.handleDocumentClick.bind(this),document.addEventListener("keydown",this._handleDocumentKeyDown,!0),document.addEventListener("lb:editor_escape",this._handleEditorEscape),document.addEventListener("mousedown",this._handleDocumentMouseDown),document.addEventListener("focus",this._handleDocumentFocus,!0),document.addEventListener("click",this._handleDocumentClick),this.getElement("sections-list").addEventListener("click",t=>{this.handleSectionsListClick(t),this.handleCellIndicatorsClick(t)}),this.getElement("clients-list").addEventListener("click",t=>this.handleClientsListClick(t)),this.getElement("sections-list-toggle").addEventListener("click",t=>this.toggleSectionsList()),this.getElement("clients-list-toggle").addEventListener("click",t=>this.toggleClientsList()),this.getElement("secrets-list-toggle").addEventListener("click",t=>this.toggleSecretsList()),this.getElement("runtime-info-toggle").addEventListener("click",t=>this.toggleRuntimeInfo()),this.getElement("app-info-toggle").addEventListener("click",t=>this.toggleAppInfo()),this.getElement("files-list-toggle").addEventListener("click",t=>this.toggleFilesList()),this.getElement("notebook").addEventListener("scroll",t=>this.updateSectionListHighlight()),this.getElement("notebook-indicators").addEventListener("click",t=>this.handleCellIndicatorsClick(t)),this.getElement("views").addEventListener("click",t=>{this.handleViewsClick(t)}),this.getElement("section-toggle-collapse-all-button").addEventListener("click",t=>this.toggleCollapseAllSections()),this.initializeDragAndDrop(),window.addEventListener("phx:page-loading-stop",()=>{this.initializeFocus()},{once:!0}),this.handleEvent("session_init",({clients:t,client_id:e})=>{let r={};for(let i of t)r[i.id]=i;this.store.set("clients",r),this.store.set("clientId",e)}),this.handleEvent("cell_inserted",({cell_id:t})=>{this.handleCellInserted(t)}),this.handleEvent("cell_deleted",({cell_id:t,sibling_cell_id:e})=>{this.handleCellDeleted(t,e)}),this.handleEvent("cell_restored",({cell_id:t})=>{this.handleCellRestored(t)}),this.handleEvent("cell_moved",({cell_id:t})=>{this.handleCellMoved(t)}),this.handleEvent("section_inserted",({section_id:t})=>{this.handleSectionInserted(t)}),this.handleEvent("section_deleted",({section_id:t})=>{this.handleSectionDeleted(t)}),this.handleEvent("section_moved",({section_id:t})=>{this.handleSectionMoved(t)}),this.handleEvent("client_joined",({client:t})=>{this.handleClientJoined(t)}),this.handleEvent("client_left",({client_id:t})=>{this.handleClientLeft(t)}),this.handleEvent("clients_updated",({clients:t})=>{this.handleClientsUpdated(t)}),this.handleEvent("secret_selected",({select_secret_ref:t,secret_name:e})=>{this.handleSecretSelected(t,e)}),this.handleEvent("location_report",({client_id:t,focusable_id:e})=>{let r={focusableId:e};this.handleLocationReport(t,r)})},updated(){let t=this.props;this.props=this.getProps(),this.props.globalStatus!==t.globalStatus&&AO(this.faviconForEvaluationStatus(this.props.globalStatus))},disconnected(){this.el.removeAttribute("id"),this.keepChannel=!0},destroyed(){document.removeEventListener("keydown",this._handleDocumentKeyDown,!0),document.removeEventListener("lb:editor_scape",this._handleEditorEscape),document.removeEventListener("mousedown",this._handleDocumentMouseDown),document.removeEventListener("focus",this._handleDocumentFocus,!0),document.removeEventListener("click",this._handleDocumentClick),AO("favicon"),this.keepChannel||mL(),this.store.destroy()},getProps(){return $t(this.el,["autofocus-cell-id","global-status"])},faviconForEvaluationStatus(t){return t==="evaluating"?"favicon-evaluating":t==="stale"?"favicon-stale":t==="errored"?"favicon-errored":"favicon"},handleDocumentKeyDown(t){if(t.repeat)return;let e=CO()?t.metaKey:t.ctrlKey,r=t.altKey,i=t.shiftKey,n=t.key,o=this.keyBuffer;if(!(cs(t.target)&&t.target.closest("[data-el-outputs-container]"))){if(e&&i&&!r&&n==="Enter"){mo(t),this.queueFullCellsEvaluation(!0);return}else if(!e&&i&&!r&&n==="Enter"){mo(t),Ol(this.focusedCellType())&&this.queueFocusedCellEvaluation(),this.moveFocus(1);return}else if(e&&!r&&n==="Enter"){mo(t),Ol(this.focusedCellType())&&this.queueFocusedCellEvaluation();return}else if(e&&n==="s"){mo(t),this.saveNotebook();return}else if(e||r)return}this.insertMode?(o.reset(),!t.target.closest("[data-el-editor-container]")&&n==="Escape"&&this.escapeInsertMode()):cs(t.target)?(o.reset(),n==="Escape"&&t.target.blur()):(o.push(t.key),o.tryMatch(["d","d"])?this.deleteFocusedCell():o.tryMatch(["e","a"])?this.queueFullCellsEvaluation(!1):o.tryMatch(["e","e"])?Ol(this.focusedCellType())&&this.queueFocusedCellEvaluation():o.tryMatch(["e","s"])?this.queueFocusedSectionEvaluation():o.tryMatch(["s","s"])?this.toggleSectionsList():o.tryMatch(["s","e"])?this.toggleSecretsList():o.tryMatch(["s","a"])?this.toggleAppInfo():o.tryMatch(["s","u"])?this.toggleClientsList():o.tryMatch(["s","f"])?this.toggleFilesList():o.tryMatch(["s","r"])?this.toggleRuntimeInfo():o.tryMatch(["s","b"])?this.showBin():o.tryMatch(["s","p"])?this.showPackageSearch():o.tryMatch(["e","x"])?this.cancelFocusedCellEvaluation():o.tryMatch(["0","0"])?this.reconnectRuntime():o.tryMatch(["Escape","Escape"])?this.setFocusedEl(null):o.tryMatch(["?"])?this.showShortcuts():o.tryMatch(["i"])||t.target.matches("body, [data-el-cell-body], [data-el-heading], [data-focusable-id]")&&this.focusedId&&n==="Enter"?(mo(t),this.isInsertModeAvailable()&&this.enterInsertMode()):o.tryMatch(["j"])?this.moveFocus(1):o.tryMatch(["k"])?this.moveFocus(-1):o.tryMatch(["J"])?this.moveFocusedCell(1):o.tryMatch(["K"])?this.moveFocusedCell(-1):o.tryMatch(["n"])?this.insertCellBelowFocused("code"):o.tryMatch(["N"])?this.insertCellAboveFocused("code"):o.tryMatch(["m"])?(!this.view||this.viewOptions.showMarkdown)&&this.insertCellBelowFocused("markdown"):o.tryMatch(["M"])?(!this.view||this.viewOptions.showMarkdown)&&this.insertCellAboveFocused("markdown"):o.tryMatch(["v","z"])?this.toggleView("code-zen"):o.tryMatch(["v","p"])?this.toggleView("presentation"):o.tryMatch(["v","c"])?this.toggleView("custom"):o.tryMatch(["c"])?(!this.view||this.viewOptions.showSection)&&this.toggleCollapseSection():o.tryMatch(["C"])&&(!this.view||this.viewOptions.showSection)&&this.toggleCollapseAllSections())},handleEditorEscape(){this.insertMode&&(this.keyBuffer.reset(),this.escapeInsertMode())},handleDocumentMouseDown(t){if(!t.target.closest("[data-el-notebook]")){this.insertMode&&this.setInsertMode(!1);return}if(t.target.closest(".cm-tooltip")){this.insertMode&&this.setInsertMode(!1);return}if(t.target.closest("[data-el-insert-buttons] button"))return;let e=t.target.closest("[data-focusable-id]"),r=e?e.dataset.focusableId:null,i=this.editableElementClicked(t,e);r!==this.focusedId&&this.setFocusedEl(r,{scroll:!1,focusElement:!1}),!t.target.closest("[data-el-actions]")&&this.insertMode!==i&&this.setInsertMode(i)},editableElementClicked(t,e){if(e){let r=t.target.closest("[data-el-editor-container], [data-el-heading]");return r&&e.contains(r)}return!1},handleDocumentFocus(t){let e=t.target.closest&&t.target.closest("[data-focusable-id]");if(e){let r=e.dataset.focusableId;r!==this.focusedId&&this.setFocusedEl(r,{scroll:!1,focusElement:!1})}},handleDocumentClick(t){t.target.closest("[data-el-enable-insert-mode-button]")&&this.setInsertMode(!0),t.target.closest("[data-btn-package-search]")&&this.insertMode&&this.setInsertMode(!1);let e=t.target.closest("[data-el-queue-cell-evaluation-button]");if(e){let i=e.getAttribute("data-cell-id"),n=e.hasAttribute("data-disable-dependencies-cache");this.queueCellEvaluation(i,n)}let r=window.location.hash;if(r){let i=r.replace(/^#/,"");!document.getElementById(i).contains(t.target)&&!t.target.closest("a")&&history.pushState(null,document.title,window.location.pathname+window.location.search)}},handleSectionsListClick(t){let e=t.target.closest("[data-el-sections-list-item]");if(e){let r=e.getAttribute("data-section-id");this.getSectionById(r).scrollIntoView({behavior:"smooth",block:"start"})}},handleClientsListClick(t){let e=t.target.closest("[data-el-clients-list-item]");if(e){let r=e.getAttribute("data-client-id");t.target.closest("[data-el-client-link]")&&this.handleClientLinkClick(r),t.target.closest("[data-el-client-follow-toggle]")&&this.handleClientFollowToggleClick(r,e)}},handleClientLinkClick(t){this.mirrorClientFocus(t)},handleClientFollowToggleClick(t,e){let r=this.el.querySelector("[data-el-clients-list-item][data-js-followed]");r&&r.removeAttribute("data-js-followed"),t===this.followedClientId?this.followedClientId=null:(e.setAttribute("data-js-followed",""),this.followedClientId=t,this.mirrorClientFocus(t))},mirrorClientFocus(t){let e=this.lastLocationReportByClientId[t];e&&e.focusableId&&this.setFocusedEl(e.focusableId)},handleCellIndicatorsClick(t){let e=t.target.closest("[data-el-focus-cell-button]");if(e){let r=e.getAttribute("data-target");this.setFocusedEl(r)}},initializeFocus(){let t=window.location.hash;if(t){let e=t.replace(/^#/,""),r=document.getElementById(e);if(r){let i=r.closest("[data-focusable-id]");i?this.setFocusedEl(i.dataset.focusableId):r.scrollIntoView()}}else this.props.autofocusCellId&&(this.setFocusedEl(this.props.autofocusCellId,{scroll:!1}),this.setInsertMode(!0))},updateSectionListHighlight(){let t=this.el.querySelector("[data-el-sections-list-item][data-js-is-viewed]");t&&t.removeAttribute("data-js-is-viewed");let e=this.getSections().reverse().find(r=>{let{top:i}=r.getBoundingClientRect(),n=document.documentElement.scrollTop;return i<=n+window.innerHeight*.35});if(e){let r=e.getAttribute("data-section-id");this.el.querySelector(`[data-el-sections-list-item][data-section-id="${r}"]`).setAttribute("data-js-is-viewed","")}},initializeDragAndDrop(){let t=!1,e=null,r=null,i=(o=null)=>{if(!t){t=!0,e=o;let a=o?"internal":"external";this.el.setAttribute("data-js-dragging",a),a==="external"&&this.toggleFilesList(!0)}},n=()=>{t&&(t=!1,this.el.removeAttribute("data-js-dragging"))};this.el.addEventListener("dragstart",o=>{i(o.target)}),this.el.addEventListener("dragenter",o=>{i()}),this.el.addEventListener("dragleave",o=>{this.el.contains(o.relatedTarget)||n()}),this.el.addEventListener("dragover",o=>{o.stopPropagation(),o.preventDefault()}),this.el.addEventListener("drop",o=>{o.stopPropagation(),o.preventDefault();let a=o.target.closest("[data-el-insert-drop-area]"),s=o.target.closest("[data-el-files-drop-area]");if(a){let l=a.getAttribute("data-section-id")||null,c=a.getAttribute("data-cell-id")||null;if(o.dataTransfer.files.length>0)r=o.dataTransfer.files,this.pushEvent("handle_file_drop",{section_id:l,cell_id:c});else if(e&&e.matches("[data-el-file-entry]")){let u=e.getAttribute("data-name");this.pushEvent("insert_file",{file_entry_name:u,section_id:l,cell_id:c})}}else s&&o.dataTransfer.files.length>0&&(r=o.dataTransfer.files,this.pushEvent("handle_file_drop",{}));n()}),this.handleEvent("finish_file_drop",o=>{let a=document.querySelector('#add-file-entry-modal input[type="file"]');a&&(a.files=r,a.dispatchEvent(new Event("change",{bubbles:!0})))})},toggleSectionsList(t=null){this.toggleSidePanelContent("sections-list",t)},toggleClientsList(t=null){this.toggleSidePanelContent("clients-list",t)},toggleSecretsList(t=null){this.toggleSidePanelContent("secrets-list",t)},toggleAppInfo(t=null){this.toggleSidePanelContent("app-info",t)},toggleFilesList(t=null){this.toggleSidePanelContent("files-list",t)},toggleRuntimeInfo(t=null){this.toggleSidePanelContent("runtime-info",t)},toggleSidePanelContent(t,e=null){(e===null?this.el.getAttribute("data-js-side-panel-content")!==t:e)?this.el.setAttribute("data-js-side-panel-content",t):this.el.removeAttribute("data-js-side-panel-content")},showBin(){let t=this.el.querySelector("[data-btn-show-bin]");t&&t.click()},showPackageSearch(){this.setFocusedEl("setup");let t=this.el.querySelector("[data-btn-package-search]");t&&t.click()},saveNotebook(){this.pushEvent("save",{})},deleteFocusedCell(){this.focusedId&&this.isCell(this.focusedId)&&this.pushEvent("delete_cell",{cell_id:this.focusedId})},queueCellEvaluation(t,e){this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_cell_evaluation",{cell_id:t,disable_dependencies_cache:e})})},queueFocusedCellEvaluation(){this.focusedId&&this.isCell(this.focusedId)&&this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_cell_evaluation",{cell_id:this.focusedId})})},queueFullCellsEvaluation(t){let e=t&&this.focusedId&&this.isCell(this.focusedId)?[this.focusedId]:[];this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_full_evaluation",{forced_cell_ids:e})})},queueFocusedSectionEvaluation(){if(this.focusedId){let t=this.getSectionIdByFocusableId(this.focusedId);t&&this.dispatchQueueEvaluation(()=>{this.pushEvent("queue_section_evaluation",{section_id:t})})}},dispatchQueueEvaluation(t){Ol(this.focusedCellType())?_r.broadcast(`cells:${this.focusedId}`,{type:"dispatch_queue_evaluation",dispatch:t}):t()},cancelFocusedCellEvaluation(){this.focusedId&&this.isCell(this.focusedId)&&this.pushEvent("cancel_cell_evaluation",{cell_id:this.focusedId})},reconnectRuntime(){this.pushEvent("reconnect_runtime",{})},showShortcuts(){let t=this.el.querySelector("[data-btn-show-shortcuts]");t&&t.click()},isInsertModeAvailable(){if(!this.focusedId)return!1;let t=this.getFocusableEl(this.focusedId);return!this.isCell(this.focusedId)||!t.hasAttribute("data-js-insert-mode-disabled")},enterInsertMode(){this.focusedId&&this.setInsertMode(!0)},escapeInsertMode(){this.setInsertMode(!1)},moveFocus(t){let e=this.nearbyFocusableId(this.focusedId,t);this.setFocusedEl(e)},moveFocusedCell(t){this.focusedId&&this.isCell(this.focusedId)&&this.pushEvent("move_cell",{cell_id:this.focusedId,offset:t})},insertCellBelowFocused(t){if(this.focusedId)this.insertCellBelowFocusableId(this.focusedId,t);else{let e=this.getFocusableIds();e.length>0&&this.insertCellBelowFocusableId(e[e.length-1],t)}},insertCellAboveFocused(t){if(this.focusedId){let e=this.nearbyFocusableId(this.focusedId,-1);this.insertCellBelowFocusableId(e,t)}else{let e=this.getFocusableIds();e.length>0&&this.insertCellBelowFocusableId(e[0],t)}},insertCellBelowFocusableId(t,e){if(this.isCell(t))this.pushEvent("insert_cell_below",{type:e,cell_id:t});else if(this.isSection(t))this.pushEvent("insert_cell_below",{type:e,section_id:t});else if(this.isNotebook(t)){let r=this.getSectionIds();r.length>0&&this.pushEvent("insert_cell_below",{type:e,section_id:r[0]})}},setFocusedEl(t,{scroll:e=!0,focusElement:r=!0}={}){if(this.focusedId=t,t?this.el.setAttribute("data-js-focused-id",t):this.el.removeAttribute("data-js-focused-id"),t){if(!this.isSection(t)){let n=this.getSectionIdByFocusableId(t);n&&this.getSectionById(n).removeAttribute("data-js-collapsed")}let i=this.getFocusableEl(t);r&&(i.querySelector("[data-el-cell-body]")||i.querySelector("[data-el-heading]")||i).focus({preventScroll:!0})}_r.broadcast("navigation",{type:"element_focused",focusableId:t,scroll:e}),this.setInsertMode(!1),this.sendLocationReport({focusableId:t})},setInsertMode(t){this.insertMode=t,t?this.el.setAttribute("data-js-insert-mode",""):this.el.removeAttribute("data-js-insert-mode"),_r.broadcast("navigation",{type:"insert_mode_changed",enabled:t})},handleViewsClick(t){let e=t.target.closest("[data-el-view-toggle]");if(e){let r=e.getAttribute("data-el-view-toggle");this.toggleView(r)}},toggleView(t){t===this.view?(this.unsetView(),t==="custom"&&this.customViewSettingsSubscription.destroy()):t==="code-zen"?this.setView(t,{showSection:!1,showMarkdown:!1,showOutput:!0,spotlight:!1}):t==="presentation"?this.setView(t,{showSection:!0,showMarkdown:!0,showOutput:!0,spotlight:!0}):t==="custom"&&(this.customViewSettingsSubscription=er.getAndSubscribe(r=>{this.setView(t,{showSection:r.custom_view_show_section,showMarkdown:r.custom_view_show_markdown,showOutput:r.custom_view_show_output,spotlight:r.custom_view_spotlight})}),this.pushEvent("open_custom_view_settings"));let e=this.focusedId||this.nearbyFocusableId(null,0);if(e){let r=this.ensureVisibleFocusableEl(e);r!==this.focused&&this.setFocusedEl(r,{scroll:!1}),r&&this.getFocusableEl(r).scrollIntoView({block:"center"})}},setView(t,e){this.view=t,this.viewOptions=e,this.el.setAttribute("data-js-view",t),this.el.toggleAttribute("data-js-hide-section",!e.showSection),this.el.toggleAttribute("data-js-hide-markdown",!e.showMarkdown),this.el.toggleAttribute("data-js-hide-output",!e.showOutput),this.el.toggleAttribute("data-js-spotlight",e.spotlight)},unsetView(){this.view=null,this.viewOptions=null,this.el.removeAttribute("data-js-view"),this.el.removeAttribute("data-js-hide-section"),this.el.removeAttribute("data-js-hide-markdown"),this.el.removeAttribute("data-js-hide-output"),this.el.removeAttribute("data-js-spotlight")},toggleCollapseSection(){if(this.focusedId){let t=this.getSectionIdByFocusableId(this.focusedId);if(t){let e=this.getSectionById(t);e.hasAttribute("data-js-collapsed")?e.removeAttribute("data-js-collapsed"):(e.setAttribute("data-js-collapsed",""),this.setFocusedEl(t,{scroll:!0}))}}},toggleCollapseAllSections(){let t=this.getSections().every(e=>e.hasAttribute("data-js-collapsed"));if(this.getSections().forEach(e=>{e.toggleAttribute("data-js-collapsed",!t)}),this.focusedId){let e=this.getSectionIdByFocusableId(this.focusedId);e&&this.setFocusedEl(e,{scroll:!0})}},handleCellInserted(t){this.setFocusedEl(t),vX(this.focusedCellType())&&this.setInsertMode(!0)},handleCellDeleted(t,e){if(this.focusedId===t)if(this.view){let r=this.ensureVisibleFocusableEl(e);this.setFocusedEl(r)}else this.setFocusedEl(e)},handleCellRestored(t){this.setFocusedEl(t)},handleCellMoved(t){this.repositionJSViews(),this.focusedId===t&&_r.broadcast("cells",{type:"cell_moved",cellId:t})},handleSectionInserted(t){let r=this.getSectionById(t).querySelector("[data-el-section-headline]"),{focusableId:i}=r.dataset;this.setFocusedEl(i),this.setInsertMode(!0),iX(document.activeElement)},handleSectionDeleted(t){this.focusedId&&!this.getFocusableEl(this.focusedId)&&this.setFocusedEl(null)},handleSectionMoved(t){this.repositionJSViews();let e=this.getSectionById(t);pl(e)},handleClientJoined(t){let e=this.store.get("clients");this.store.set("clients",Be(oe({},e),{[t.id]:t}))},handleClientLeft(t){let e=this.store.get("clients"),r=e[t];if(r){let[,i]=$O(e,t);this.store.set("clients",i),r.id===this.followedClientId&&(this.followedClientId=null)}},handleClientsUpdated(t){let e=this.store.get("clients"),r=oe({},e);for(let i of t)r[i.id]=i;this.store.set("clients",r)},handleSecretSelected(t,e){_r.broadcast(`js_views:${t}`,{type:"secretSelected",secretName:e})},handleLocationReport(t,e){let r=this.store.get("clients")[t];this.lastLocationReportByClientId[t]=e,r&&r.id===this.followedClientId&&e.focusableId!==this.focusedId&&this.setFocusedEl(e.focusableId)},repositionJSViews(){_r.broadcast("js_views",{type:"reposition"})},sendLocationReport(t){Object.keys(this.store.get("clients")).length>1&&this.pushEvent("location_report",{focusable_id:t.focusableId})},focusedCellType(){return this.focusedId&&this.isCell(this.focusedId)?this.getFocusableEl(this.focusedId).getAttribute("data-type"):null},nearbyFocusableId(t,e){let r=this.getFocusableIds();if(r.length===0)return null;let i=r.indexOf(t);if(i===-1){let n=this.getFocusableEls().find(Tx);return n?n.getAttribute("data-focusable-id"):r[0]}else{let n=tX(i+e,0,r.length-1);return r[n]}},ensureVisibleFocusableEl(t){let e=this.getFocusableEl(t),r=Array.from(this.el.querySelectorAll("[data-focusable-id]")),i=r.indexOf(e),n=[...r.slice(i,-1),...r.slice(0,i).reverse()].find(o=>!po(o));return n&&n.getAttribute("data-focusable-id")},isCell(t){return this.getFocusableEl(t).hasAttribute("data-el-cell")},isSection(t){return this.getFocusableEl(t).hasAttribute("data-el-section-headline")},isNotebook(t){return this.getFocusableEl(t).hasAttribute("data-el-notebook-headline")},getFocusableEl(t){return this.el.querySelector(`[data-focusable-id="${t}"]`)},getFocusableEls(){return Array.from(this.el.querySelectorAll("[data-focusable-id]")).filter(t=>!po(t))},getFocusableIds(){return this.getFocusableEls().map(t=>t.getAttribute("data-focusable-id"))},getSectionIdByFocusableId(t){let r=this.getFocusableEl(t).closest("[data-el-section]");return r&&r.getAttribute("data-section-id")},getSectionIds(){return this.getSections().map(e=>e.getAttribute("data-section-id"))},getSections(){return Array.from(this.el.querySelectorAll("[data-el-section]"))},getSectionById(t){return this.el.querySelector(`[data-el-section][data-section-id="${t}"]`)},getElement(t){return this.el.querySelector(`[data-el-${t}]`)}},kL=Vle;var Fle={mounted(){this.autosize(),this.el.addEventListener("input",t=>{this.autosize()})},updated(){this.autosize()},autosize(){this.el.style.height="0px",this.el.style.height=`${this.el.scrollHeight+2}px`}},SL=Fle;var Zle=100,Yle={mounted(){this.props=this.getProps(),this.interval=setInterval(()=>this.updateDOM(),Zle)},updated(){this.props=this.getProps(),this.updateDOM()},destroyed(){clearInterval(this.interval)},getProps(){return $t(this.el,["start"])},updateDOM(){let e=(Date.now()-new Date(this.props.start))/1e3;this.el.innerHTML=`${e.toFixed(1)}s`}},TL=Yle;var EL="lb_user_data";function CL(t){let e=JSON.stringify(t),r=oX(e);Gle(EL,r,15768e4)}function PL(){let t=Hle(EL);if(t){let e=aX(t);return JSON.parse(e)}else return null}function Hle(t){let e=document.cookie.split("; ").find(r=>r.startsWith(`${t}=`));return e?e.replace(`${t}=`,""):null}function Gle(t,e,r){let i=`${t}=${e};max-age=${r};path=/${QO()}`;document.cookie=i}var Kle={mounted(){this.el.addEventListener("submit",t=>{let e=this.el.user_form_name.value,r=this.el.user_form_hex_color.value;CL({name:e,hex_color:r})})}},_L=Kle;var Jle={mounted(){this.props=this.getProps(),this.updateAttrs(),this.el.addEventListener("blur",t=>{let e=this.datetimeLocalToUtc(this.el.value);this.pushEventTo(this.props.phxTarget,"change",{html_value:e})})},updated(){this.props=this.getProps(),this.updateAttrs()},getProps(){return $t(this.el,["utc-value","utc-min","utc-max","phx-target"])},updateAttrs(){this.el.value=this.datetimeUtcToLocal(this.props.utcValue),this.el.min=this.datetimeUtcToLocal(this.props.utcMin),this.el.max=this.datetimeUtcToLocal(this.props.utcMax)},datetimeUtcToLocal(t){if(!t)return null;let e=new Date(t+"Z"),r=e.getFullYear().toString(),i=(e.getMonth()+1).toString().padStart(2,"0"),n=e.getDate().toString().padStart(2,"0"),o=e.getHours().toString().padStart(2,"0"),a=e.getMinutes().toString().padStart(2,"0"),s=e.getSeconds().toString().padStart(2,"0");return`${r}-${i}-${n}T${o}:${a}:${s}`},datetimeLocalToUtc(t){if(!t)return null;let e=new Date(t),r=e.getUTCFullYear().toString(),i=(e.getUTCMonth()+1).toString().padStart(2,"0"),n=e.getUTCDate().toString().padStart(2,"0"),o=e.getUTCHours().toString().padStart(2,"0"),a=e.getUTCMinutes().toString().padStart(2,"0"),s=e.getUTCSeconds().toString().padStart(2,"0");return`${r}-${i}-${n}T${o}:${a}:${s}`}},AL=Jle;var ece={mounted(){this.props=this.getProps(),this.updateAttrs(),this.el.addEventListener("blur",t=>{let e=this.timeLocalToUtc(this.el.value);this.pushEventTo(this.props.phxTarget,"change",{html_value:e})})},updated(){this.props=this.getProps(),this.updateAttrs()},getProps(){return $t(this.el,["utc-value","utc-min","utc-max","phx-target"])},updateAttrs(){this.el.value=this.timeUtcToLocal(this.props.utcValue),this.el.min=this.timeUtcToLocal(this.props.utcMin),this.el.max=this.timeUtcToLocal(this.props.utcMax)},timeUtcToLocal(t){if(!t)return null;let e=new Date;e.setUTCHours(...t.split(":"));let r=e.getHours().toString().padStart(2,"0"),i=e.getMinutes().toString().padStart(2,"0"),n=e.getSeconds().toString().padStart(2,"0");return`${r}:${i}:${n}`},timeLocalToUtc(t){if(!t)return null;let e=new Date;e.setHours(...t.split(":"));let r=e.getUTCHours().toString().padStart(2,"0"),i=e.getUTCMinutes().toString().padStart(2,"0"),n=e.getUTCSeconds().toString().padStart(2,"0");return`${r}:${i}:${n}`}},QL=ece;var RL=Al(XL());var tce={mounted(){this.props=this.getProps(),this.lineHeight=rX(this.el),this.templateEl=na(this.el,"[data-template]"),this.contentEl=na(this.el,"[data-content]"),this.capLines();let t=this.hyperListConfig();this.virtualizedList=new RL.default(this.contentEl,t),this.props.follow&&_h(this.contentEl)},updated(){this.props=this.getProps(),this.capLines();let t=this.props.follow&&nX(this.contentEl),e=this.hyperListConfig();this.virtualizedList.refresh(this.contentEl,e),t&&_h(this.contentEl)},getProps(){return $t(this.el,["max-height","follow","max-lines","ignore-trailing-empty-line"])},hyperListConfig(){let t=this.getLineElements(),e=t.length,r=Math.min(this.props.maxHeight,this.lineHeight*e);return{height:r,total:e,itemHeight:this.lineHeight,generate:i=>{let n=t[i].cloneNode(!0);return n.removeAttribute("id"),n},afterRender:()=>{this.contentEl.scrollWidth>this.contentEl.clientWidth?this.contentEl.style.height=`${r+12}px`:this.contentEl.style.height=`${r}px`}}},getLineElements(){let t=Array.from(this.templateEl.querySelectorAll("[data-line]"));if(t.length===0)return[];let e=t[t.length-1];return this.props.ignoreTrailingEmptyLine&&e.innerText===""?t.slice(0,-1):t},capLines(){if(this.props.maxLines){let e=Array.from(this.templateEl.querySelectorAll("[data-line]")).slice(0,-this.props.maxLines),[r,...i]=e;i.forEach(n=>n.remove()),r&&(r.innerHTML="...")}}},IL=tce;var rce={mounted(){let t=er.get(),e=this.el.querySelector('[name="show_section"][value="true"]'),r=this.el.querySelector('[name="show_markdown"][value="true"]'),i=this.el.querySelector('[name="show_output"][value="true"]'),n=this.el.querySelector('[name="spotlight"][value="true"]');e.checked=t.custom_view_show_section,r.checked=t.custom_view_show_markdown,i.checked=t.custom_view_show_output,n.checked=t.custom_view_spotlight,e.addEventListener("change",o=>{er.update({custom_view_show_section:o.target.checked})}),r.addEventListener("change",o=>{er.update({custom_view_show_markdown:o.target.checked})}),i.addEventListener("change",o=>{er.update({custom_view_show_output:o.target.checked})}),n.addEventListener("change",o=>{er.update({custom_view_spotlight:o.target.checked})})}},LL=rce;var ML={AppAuth:Wk,AudioInput:Yk,Cell:xX,CellEditor:vI,Dropzone:xI,EditorSettings:wI,EmojiPicker:sL,FocusOnUpdate:lL,Headline:uL,Highlight:fL,ImageInput:hL,ImageOutput:dL,JSView:yL,KeyboardControl:vL,MarkdownRenderer:xL,ScrollOnUpdate:wL,Session:kL,TextareaAutosize:SL,Timer:TL,UserForm:_L,UtcDateTimeInput:AL,UtcTimeInput:QL,VirtualizedLines:IL,CustomViewSettings:LL};var zL={onBeforeElUpdated(t,e){for(let r of t.attributes)r.name.startsWith("data-js-")&&e.setAttribute(r.name,r.value),r.name==="data-keep-attribute"&&(t.hasAttribute(r.value)?e.setAttribute(r.value,t.getAttribute(r.value)):e.removeAttribute(r.value))},onNodeAdded(t){if(t.nodeType===Node.ELEMENT_NODE&&t.hasAttribute("autofocus")&&(t.focus(),t.setSelectionRange&&t.value)){let e=t.value.length;t.setSelectionRange(e,e)}}};var Bg=Al(NL());function UL(){Bg.default.config({barColors:{0:"#b2c1ff"},shadowColor:"rgba(0, 0, 0, .3)"}),window.addEventListener("phx:page-loading-start",()=>{Bg.default.show(500)}),window.addEventListener("phx:page-loading-stop",()=>{Bg.default.hide()})}function qL(){window.addEventListener("lb:focus",t=>{requestAnimationFrame(()=>{t.target.focus()})}),window.addEventListener("lb:set_value",t=>{t.target.value=t.detail.value}),window.addEventListener("lb:check",t=>{t.target.checked=!0}),window.addEventListener("lb:uncheck",t=>{t.target.checked=!1}),window.addEventListener("lb:set_text",t=>{t.target.textContent=t.detail.value}),window.addEventListener("lb:clipcopy",t=>{"clipboard"in navigator?t.detail.content?navigator.clipboard.writeText(t.detail.content):t.target.tagName==="INPUT"?navigator.clipboard.writeText(t.target.value):navigator.clipboard.writeText(t.target.textContent):alert(`Sorry, your browser does not support clipboard copy. This generally requires a secure origin \u2014 either HTTPS or localhost.`)}),window.addEventListener("lb:scroll_into_view",t=>{eX(t.target).then(()=>{IO(t.target,{scrollMode:"if-needed",behavior:"smooth",block:"nearest",inline:"nearest"})})}),window.addEventListener("phx:lb:exec_js",t=>{let e=t.detail.to||"body";document.querySelectorAll(e).forEach(r=>{window.liveSocket.execJS(r,t.detail.js)})}),window.addEventListener("lb:session_list:on_selection_change",()=>{let t=!!document.querySelector("[name='session_ids[]']:checked"),e=document.querySelector("#edit-sessions [name='disconnect']"),r=document.querySelector("#edit-sessions [name='close_all']");e.parentElement.classList.toggle("pointer-events-none",!t),e.parentElement.classList.toggle("opacity-50",!t),r.parentElement.classList.toggle("pointer-events-none",!t),r.parentElement.classList.toggle("opacity-50",!t)}),window.addEventListener("contextmenu",t=>{let e=t.target.closest("[data-contextmenu-trigger-click]");e&&(t.preventDefault(),e.dispatchEvent(new Event("mousedown",{bubbles:!0})),e.dispatchEvent(new Event("click",{bubbles:!0})))}),window.addEventListener("submit",t=>{t.target.hasAttribute("phx-nosubmit")&&(t.preventDefault(),t.stopPropagation())},{capture:!0})}function BL(){let t=/AppleWebKit/.test(navigator.userAgent),e="ontouchstart"in window||navigator.maxTouchPoints>0;if(t&&e){let r=document.querySelector("meta[name='viewport']");r&&(r.content+=", maximum-scale=1.0")}}var Ew="confirm-opted-out-ids";function jL(){return ks(Ew)||[]}function WL(){window.addEventListener("phx:add_confirm_opt_out_id",t=>{let e=ks(Ew)||[],r=t.detail.opt_out_id;e.push(r),zl(Ew,e)})}function ice(){let t=document.querySelector("meta[name='csrf-token']").getAttribute("content"),e=new Nk(window.LIVEBOOK_BASE_URL_PATH+"/live",Ed,{params:r=>({_csrf_token:t,user_data:PL(),app_auth_token:jk(),confirm_opt_out_ids:jL()}),hooks:ML,dom:zL});UL(),qL(),WL(),BL(),er.getAndSubscribe(r=>{document.body.setAttribute("data-editor-theme",r.editor_theme)}),e.connect(),window.liveSocket=e}if(nce())ice();else{let t=document.createElement("div");t.innerHTML=`
@@ -583,7 +583,7 @@ This generally requires a secure origin \u2014 either HTTPS or localhost.`)}),wi
- `,t.querySelector("#open-app").href=window.location,document.body.appendChild(t)}function nce(){return document.cookie=`lb:probe_cookie=;path=/${QO()}`,document.cookie.split("; ").some(t=>t.startsWith("lb:probe_cookie="))} + `,t.querySelector("#open-app").href=window.location,document.body.appendChild(t)}function nce(){return document.cookie=`lb_probe_cookie=;path=/${QO()}`,document.cookie.split("; ").some(t=>t.startsWith("lb_probe_cookie="))} /*! Bundled license information: topbar/topbar.min.js: