diff --git a/themes/intotheeast/js/post/post-form.js b/themes/intotheeast/js/post/post-form.js index 737f6d3..bb153ba 100644 --- a/themes/intotheeast/js/post/post-form.js +++ b/themes/intotheeast/js/post/post-form.js @@ -92,7 +92,7 @@ Please report this to https://github.com/markedjs/marked.`,o){var f="

An error ----- `]},_p={link:"URL for the link:",image:"URL of the image:"},Bp={locale:"en-US",format:{hour:"2-digit",minute:"2-digit"}},Np={bold:"**",code:"```",italic:"*"},Op={sbInit:"Attach files by drag and dropping or pasting from clipboard.",sbOnDragEnter:"Drop image to upload it.",sbOnDrop:"Uploading image #images_names#...",sbProgress:"Uploading #file_name#: #progress#%",sbOnUploaded:"Uploaded #image_name#",sizeUnits:" B, KB, MB"},Ip={noFileGiven:"You must select a file.",typeNotAllowed:"This image type is not allowed.",fileTooLarge:`Image #image_name# is too big (#image_size#). -Maximum file size is #image_max_size#.`,importError:"Something went wrong when uploading the image #image_name#."};function V(o){o=o||{},o.parent=this;var l=!0;if(o.autoDownloadFontAwesome===!1&&(l=!1),o.autoDownloadFontAwesome!==!0)for(var s=document.styleSheets,a=0;a-1&&(l=!1);if(l){var f=document.createElement("link");f.rel="stylesheet",f.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(f)}if(o.element)this.element=o.element;else if(o.element===null){console.log("EasyMDE: Error. No element was found.");return}if(o.toolbar===void 0){o.toolbar=[];for(var p in Ur)Object.prototype.hasOwnProperty.call(Ur,p)&&(p.indexOf("separator-")!=-1&&o.toolbar.push("|"),(Ur[p].default===!0||o.showIcons&&o.showIcons.constructor===Array&&o.showIcons.indexOf(p)!=-1)&&o.toolbar.push(p))}if(Object.prototype.hasOwnProperty.call(o,"previewClass")||(o.previewClass="editor-preview"),Object.prototype.hasOwnProperty.call(o,"status")||(o.status=["autosave","lines","words","cursor"],o.uploadImage&&o.status.unshift("upload-image")),o.previewRender||(o.previewRender=function(h){return this.parent.markdown(h)}),o.parsingConfig=sr({highlightFormatting:!0},o.parsingConfig||{}),o.insertTexts=sr({},Mp,o.insertTexts||{}),o.promptTexts=sr({},_p,o.promptTexts||{}),o.blockStyles=sr({},Np,o.blockStyles||{}),o.autosave!=null&&(o.autosave.timeFormat=sr({},Bp,o.autosave.timeFormat||{})),o.iconClassMap=sr({},Me,o.iconClassMap||{}),o.shortcuts=sr({},Cp,o.shortcuts||{}),o.maxHeight=o.maxHeight||void 0,o.direction=o.direction||"ltr",typeof o.maxHeight<"u"?o.minHeight=o.maxHeight:o.minHeight=o.minHeight||"300px",o.errorCallback=o.errorCallback||function(h){alert(h)},o.uploadImage=o.uploadImage||!1,o.imageMaxSize=o.imageMaxSize||2097152,o.imageAccept=o.imageAccept||"image/png, image/jpeg, image/gif, image/avif",o.imageTexts=sr({},Op,o.imageTexts||{}),o.errorMessages=sr({},Ip,o.errorMessages||{}),o.imagePathAbsolute=o.imagePathAbsolute||!1,o.imageCSRFName=o.imageCSRFName||"csrfmiddlewaretoken",o.imageCSRFHeader=o.imageCSRFHeader||!1,o.imageInputName=o.imageInputName||"image",o.autosave!=null&&o.autosave.unique_id!=null&&o.autosave.unique_id!=""&&(o.autosave.uniqueId=o.autosave.unique_id),o.overlayMode&&o.overlayMode.combine===void 0&&(o.overlayMode.combine=!0),this.options=o,this.render(),o.initialValue&&(!this.options.autosave||this.options.autosave.foundSavedValue!==!0)&&this.value(o.initialValue),o.uploadImage){var c=this;this.codemirror.on("dragenter",function(h,b){c.updateStatusBar("upload-image",c.options.imageTexts.sbOnDragEnter),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("dragend",function(h,b){c.updateStatusBar("upload-image",c.options.imageTexts.sbInit),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("dragleave",function(h,b){c.updateStatusBar("upload-image",c.options.imageTexts.sbInit),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("dragover",function(h,b){c.updateStatusBar("upload-image",c.options.imageTexts.sbOnDragEnter),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("drop",function(h,b){b.stopPropagation(),b.preventDefault(),o.imageUploadFunction?c.uploadImagesUsingCustomFunction(o.imageUploadFunction,b.dataTransfer.files):c.uploadImages(b.dataTransfer.files)}),this.codemirror.on("paste",function(h,b){o.imageUploadFunction?c.uploadImagesUsingCustomFunction(o.imageUploadFunction,b.clipboardData.files):c.uploadImages(b.clipboardData.files)})}}V.prototype.uploadImages=function(o,l,s){if(o.length!==0){for(var a=[],f=0;f=2){var P=N[1];if(l.imagesPreviewHandler){var I=l.imagesPreviewHandler(N[1]);typeof I=="string"&&(P=I)}if(window.EMDEimagesCache[P])F(O,window.EMDEimagesCache[P]);else{window.EMDEimagesCache[P]={};var W=document.createElement("img");W.onload=function(){window.EMDEimagesCache[P]={naturalWidth:W.naturalWidth,naturalHeight:W.naturalHeight,url:P},F(O,window.EMDEimagesCache[P])},W.src=P}}}})}this.codemirror.on("update",function(){_()}),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element,(l.autofocus===!0||o.autofocus)&&this.codemirror.focus();var L=this.codemirror;setTimeout(function(){L.refresh()}.bind(L),0)};V.prototype.cleanup=function(){document.removeEventListener("keydown",this.documentOnKeyDown)};function Vf(){if(typeof localStorage=="object")try{localStorage.setItem("smde_localStorage",1),localStorage.removeItem("smde_localStorage")}catch{return!1}else return!1;return!0}V.prototype.autosave=function(){if(Vf()){var o=this;if(this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to use the autosave feature");return}this.options.autosave.binded!==!0&&(o.element.form!=null&&o.element.form!=null&&o.element.form.addEventListener("submit",function(){clearTimeout(o.autosaveTimeoutId),o.autosaveTimeoutId=void 0,localStorage.removeItem("smde_"+o.options.autosave.uniqueId)}),this.options.autosave.binded=!0),this.options.autosave.loaded!==!0&&(typeof localStorage.getItem("smde_"+this.options.autosave.uniqueId)=="string"&&localStorage.getItem("smde_"+this.options.autosave.uniqueId)!=""&&(this.codemirror.setValue(localStorage.getItem("smde_"+this.options.autosave.uniqueId)),this.options.autosave.foundSavedValue=!0),this.options.autosave.loaded=!0);var l=o.value();l!==""?localStorage.setItem("smde_"+this.options.autosave.uniqueId,l):localStorage.removeItem("smde_"+this.options.autosave.uniqueId);var s=document.getElementById("autosaved");if(s!=null&&s!=null&&s!=""){var a=new Date,f=new Intl.DateTimeFormat([this.options.autosave.timeFormat.locale,"en-US"],this.options.autosave.timeFormat.format).format(a),p=this.options.autosave.text==null?"Autosaved: ":this.options.autosave.text;s.innerHTML=p+f}}else console.log("EasyMDE: localStorage not available, cannot autosave")};V.prototype.clearAutosavedValue=function(){if(Vf()){if(this.options.autosave==null||this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to clear the autosave value");return}localStorage.removeItem("smde_"+this.options.autosave.uniqueId)}else console.log("EasyMDE: localStorage not available, cannot autosave")};V.prototype.openBrowseFileWindow=function(o,l){var s=this,a=this.gui.toolbar.getElementsByClassName("imageInput")[0];a.click();function f(p){s.options.imageUploadFunction?s.uploadImagesUsingCustomFunction(s.options.imageUploadFunction,p.target.files):s.uploadImages(p.target.files,o,l),a.removeEventListener("change",f)}a.addEventListener("change",f)};V.prototype.uploadImage=function(o,l,s){var a=this;l=l||function(y){Qf(a,y)};function f(b){a.updateStatusBar("upload-image",b),setTimeout(function(){a.updateStatusBar("upload-image",a.options.imageTexts.sbInit)},1e4),s&&typeof s=="function"&&s(b),a.options.errorCallback(b)}function p(b){var y=a.options.imageTexts.sizeUnits.split(",");return b.replace("#image_name#",o.name).replace("#image_size#",uo(o.size,y)).replace("#image_max_size#",uo(a.options.imageMaxSize,y))}if(o.size>this.options.imageMaxSize){f(p(this.options.errorMessages.fileTooLarge));return}var c=new FormData;c.append("image",o),a.options.imageCSRFToken&&!a.options.imageCSRFHeader&&c.append(a.options.imageCSRFName,a.options.imageCSRFToken);var h=new XMLHttpRequest;h.upload.onprogress=function(b){if(b.lengthComputable){var y=""+Math.round(b.loaded*100/b.total);a.updateStatusBar("upload-image",a.options.imageTexts.sbProgress.replace("#file_name#",o.name).replace("#progress#",y))}},h.open("POST",this.options.imageUploadEndpoint),a.options.imageCSRFToken&&a.options.imageCSRFHeader&&h.setRequestHeader(a.options.imageCSRFName,a.options.imageCSRFToken),h.onload=function(){try{var b=JSON.parse(this.responseText)}catch{console.error("EasyMDE: The server did not return a valid json."),f(p(a.options.errorMessages.importError));return}this.status===200&&b&&!b.error&&b.data&&b.data.filePath?l((a.options.imagePathAbsolute?"":window.location.origin+"/")+b.data.filePath):b.error&&b.error in a.options.errorMessages?f(p(a.options.errorMessages[b.error])):b.error?f(p(b.error)):(console.error("EasyMDE: Received an unexpected response after uploading the image."+this.status+" ("+this.statusText+")"),f(p(a.options.errorMessages.importError)))},h.onerror=function(b){console.error("EasyMDE: An unexpected error occurred when trying to upload the image."+b.target.status+" ("+b.target.statusText+")"),f(a.options.errorMessages.importError)},h.send(c)};V.prototype.uploadImageUsingCustomFunction=function(o,l){var s=this;function a(c){Qf(s,c)}function f(c){var h=p(c);s.updateStatusBar("upload-image",h),setTimeout(function(){s.updateStatusBar("upload-image",s.options.imageTexts.sbInit)},1e4),s.options.errorCallback(h)}function p(c){var h=s.options.imageTexts.sizeUnits.split(",");return c.replace("#image_name#",l.name).replace("#image_size#",uo(l.size,h)).replace("#image_max_size#",uo(s.options.imageMaxSize,h))}o.apply(this,[l,a,f])};V.prototype.setPreviewMaxHeight=function(){var o=this.codemirror,l=o.getWrapperElement(),s=l.nextSibling,a=parseInt(window.getComputedStyle(l).paddingTop),f=parseInt(window.getComputedStyle(l).borderTopWidth),p=parseInt(this.options.maxHeight),c=p+a*2+f*2,h=c.toString()+"px";s.style.height=h};V.prototype.createSideBySide=function(){var o=this.codemirror,l=o.getWrapperElement(),s=l.nextSibling;if(!s||!s.classList.contains("editor-preview-side")){if(s=document.createElement("div"),s.className="editor-preview-side",this.options.previewClass)if(Array.isArray(this.options.previewClass))for(var a=0;a"&&(l=l.substring(1)),o)try{if(o.matches)return o.matches(l);if(o.msMatchesSelector)return o.msMatchesSelector(l);if(o.webkitMatchesSelector)return o.webkitMatchesSelector(l)}catch{return!1}return!1}}function hc(o){return o.host&&o!==document&&o.host.nodeType&&o.host!==o?o.host:o.parentNode}function Gt(o,l,s,a){if(o){s=s||document;do{if(l!=null&&(l[0]===">"?o.parentNode===s&&Ro(o,l):Ro(o,l))||a&&o===s)return o;if(o===s)break}while(o=hc(o))}return null}var ic=/\s+/g;function Bt(o,l,s){if(o&&l)if(o.classList)o.classList[s?"add":"remove"](l);else{var a=(" "+o.className+" ").replace(ic," ").replace(" "+l+" "," ");o.className=(a+(s?" "+l:"")).replace(ic," ")}}function pe(o,l,s){var a=o&&o.style;if(a){if(s===void 0)return document.defaultView&&document.defaultView.getComputedStyle?s=document.defaultView.getComputedStyle(o,""):o.currentStyle&&(s=o.currentStyle),l===void 0?s:s[l];!(l in a)&&l.indexOf("webkit")===-1&&(l="-webkit-"+l),a[l]=s+(typeof s=="string"?"":"px")}}function An(o,l){var s="";if(typeof o=="string")s=o;else do{var a=pe(o,"transform");a&&a!=="none"&&(s=a+" "+s)}while(!l&&(o=o.parentNode));var f=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return f&&new f(s)}function pc(o,l,s){if(o){var a=o.getElementsByTagName(l),f=0,p=a.length;if(s)for(;f=p:c=f<=p,!c)return a;if(a===Vt())break;a=Tr(a,!1)}return!1}function Fn(o,l,s,a){for(var f=0,p=0,c=o.children;p2&&arguments[2]!==void 0?arguments[2]:{},f=a.evt,p=zp(a,Qp);xi.pluginEvent.bind(ge)(l,s,er({dragEl:J,parentEl:qe,ghostEl:ye,rootEl:Pe,nextEl:Yr,lastDownEl:Io,cloneEl:Re,cloneHidden:Fr,dragStarted:ci,putSortable:ft,activeSortable:ge.active,originalEvent:f,oldIndex:En,oldDraggableIndex:vi,newIndex:Nt,newDraggableIndex:Ar,hideGhostForTarget:wc,unhideGhostForTarget:Cc,cloneNowHidden:function(){Fr=!0},cloneNowShown:function(){Fr=!1},dispatchSortableEvent:function(h){Ct({sortable:s,name:h,originalEvent:f})}},p))};function Ct(o){Zp(er({putSortable:ft,cloneEl:Re,targetEl:J,rootEl:Pe,oldIndex:En,oldDraggableIndex:vi,newIndex:Nt,newDraggableIndex:Ar},o))}var J,qe,ye,Pe,Yr,Io,Re,Fr,En,Nt,vi,Ar,_o,ft,Sn=!1,Wo=!1,qo=[],Xr,jt,Dl,wl,lc,sc,ci,kn,mi,bi=!1,Bo=!1,Po,gt,Cl=[],Tl=!1,Uo=[],Go=typeof document<"u",No=Bl,uc=yi||cr?"cssFloat":"float",Jp=Go&&!cc&&!Bl&&"draggable"in document.createElement("div"),yc=function(){if(Go){if(cr)return!1;var o=document.createElement("x");return o.style.cssText="pointer-events:auto",o.style.pointerEvents==="auto"}}(),xc=function(l,s){var a=pe(l),f=parseInt(a.width)-parseInt(a.paddingLeft)-parseInt(a.paddingRight)-parseInt(a.borderLeftWidth)-parseInt(a.borderRightWidth),p=Fn(l,0,s),c=Fn(l,1,s),h=p&&pe(p),b=c&&pe(c),y=h&&parseInt(h.marginLeft)+parseInt(h.marginRight)+Je(p).width,x=b&&parseInt(b.marginLeft)+parseInt(b.marginRight)+Je(c).width;if(a.display==="flex")return a.flexDirection==="column"||a.flexDirection==="column-reverse"?"vertical":"horizontal";if(a.display==="grid")return a.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(p&&h.float&&h.float!=="none"){var C=h.float==="left"?"left":"right";return c&&(b.clear==="both"||b.clear===C)?"vertical":"horizontal"}return p&&(h.display==="block"||h.display==="flex"||h.display==="table"||h.display==="grid"||y>=f&&a[uc]==="none"||c&&a[uc]==="none"&&y+x>f)?"vertical":"horizontal"},$p=function(l,s,a){var f=a?l.left:l.top,p=a?l.right:l.bottom,c=a?l.width:l.height,h=a?s.left:s.top,b=a?s.right:s.bottom,y=a?s.width:s.height;return f===h||p===b||f+c/2===h+y/2},Vp=function(l,s){var a;return qo.some(function(f){var p=f[Ft].options.emptyInsertThreshold;if(!(!p||Nl(f))){var c=Je(f),h=l>=c.left-p&&l<=c.right+p,b=s>=c.top-p&&s<=c.bottom+p;if(h&&b)return a=f}}),a},Dc=function(l){function s(p,c){return function(h,b,y,x){var C=h.options.group.name&&b.options.group.name&&h.options.group.name===b.options.group.name;if(p==null&&(c||C))return!0;if(p==null||p===!1)return!1;if(c&&p==="clone")return p;if(typeof p=="function")return s(p(h,b,y,x),c)(h,b,y,x);var E=(c?h:b).options.group.name;return p===!0||typeof p=="string"&&p===E||p.join&&p.indexOf(E)>-1}}var a={},f=l.group;(!f||Fl(f)!="object")&&(f={name:f}),a.name=f.name,a.checkPull=s(f.pull,!0),a.checkPut=s(f.put),a.revertClone=f.revertClone,l.group=a},wc=function(){!yc&&ye&&pe(ye,"display","none")},Cc=function(){!yc&&ye&&pe(ye,"display","")};Go&&!cc&&document.addEventListener("click",function(o){if(Wo)return o.preventDefault(),o.stopPropagation&&o.stopPropagation(),o.stopImmediatePropagation&&o.stopImmediatePropagation(),Wo=!1,!1},!0);var Kr=function(l){if(J){l=l.touches?l.touches[0]:l;var s=Vp(l.clientX,l.clientY);if(s){var a={};for(var f in l)l.hasOwnProperty(f)&&(a[f]=l[f]);a.target=a.rootEl=s,a.preventDefault=void 0,a.stopPropagation=void 0,s[Ft]._onDragOver(a)}}},eg=function(l){J&&J.parentNode[Ft]._isOutsideThisEl(l.target)};function ge(o,l){if(!(o&&o.nodeType&&o.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(o));this.el=o,this.options=l=fr({},l),o[Ft]=this;var s={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(o.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return xc(o,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(c,h){c.setData("Text",h.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:ge.supportPointer!==!1&&"PointerEvent"in window&&(!pi||Bl),emptyInsertThreshold:5};xi.initializePlugins(this,o,s);for(var a in s)!(a in l)&&(l[a]=s[a]);Dc(l);for(var f in this)f.charAt(0)==="_"&&typeof this[f]=="function"&&(this[f]=this[f].bind(this));this.nativeDraggable=l.forceFallback?!1:Jp,this.nativeDraggable&&(this.options.touchStartThreshold=1),l.supportPointer?Se(o,"pointerdown",this._onTapStart):(Se(o,"mousedown",this._onTapStart),Se(o,"touchstart",this._onTapStart)),this.nativeDraggable&&(Se(o,"dragover",this),Se(o,"dragenter",this)),qo.push(this.el),l.store&&l.store.get&&this.sort(l.store.get(this)||[]),fr(this,Xp())}ge.prototype={constructor:ge,_isOutsideThisEl:function(l){!this.el.contains(l)&&l!==this.el&&(kn=null)},_getDirection:function(l,s){return typeof this.options.direction=="function"?this.options.direction.call(this,l,s,J):this.options.direction},_onTapStart:function(l){if(l.cancelable){var s=this,a=this.el,f=this.options,p=f.preventOnFilter,c=l.type,h=l.touches&&l.touches[0]||l.pointerType&&l.pointerType==="touch"&&l,b=(h||l).target,y=l.target.shadowRoot&&(l.path&&l.path[0]||l.composedPath&&l.composedPath()[0])||b,x=f.filter;if(sg(a),!J&&!(/mousedown|pointerdown/.test(c)&&l.button!==0||f.disabled)&&!y.isContentEditable&&!(!this.nativeDraggable&&pi&&b&&b.tagName.toUpperCase()==="SELECT")&&(b=Gt(b,f.draggable,a,!1),!(b&&b.animated)&&Io!==b)){if(En=Pt(b),vi=Pt(b,f.draggable),typeof x=="function"){if(x.call(this,l,b,this)){Ct({sortable:s,rootEl:y,name:"filter",targetEl:b,toEl:a,fromEl:a}),At("filter",s,{evt:l}),p&&l.preventDefault();return}}else if(x&&(x=x.split(",").some(function(C){if(C=Gt(y,C.trim(),a,!1),C)return Ct({sortable:s,rootEl:C,name:"filter",targetEl:b,fromEl:a,toEl:a}),At("filter",s,{evt:l}),!0}),x)){p&&l.preventDefault();return}f.handle&&!Gt(y,f.handle,a,!1)||this._prepareDragStart(l,h,b)}}},_prepareDragStart:function(l,s,a){var f=this,p=f.el,c=f.options,h=p.ownerDocument,b;if(a&&!J&&a.parentNode===p){var y=Je(a);if(Pe=p,J=a,qe=J.parentNode,Yr=J.nextSibling,Io=a,_o=c.group,ge.dragged=J,Xr={target:J,clientX:(s||l).clientX,clientY:(s||l).clientY},lc=Xr.clientX-y.left,sc=Xr.clientY-y.top,this._lastX=(s||l).clientX,this._lastY=(s||l).clientY,J.style["will-change"]="all",b=function(){if(At("delayEnded",f,{evt:l}),ge.eventCanceled){f._onDrop();return}f._disableDelayedDragEvents(),!nc&&f.nativeDraggable&&(J.draggable=!0),f._triggerDragStart(l,s),Ct({sortable:f,name:"choose",originalEvent:l}),Bt(J,c.chosenClass,!0)},c.ignore.split(",").forEach(function(x){pc(J,x.trim(),kl)}),Se(h,"dragover",Kr),Se(h,"mousemove",Kr),Se(h,"touchmove",Kr),c.supportPointer?(Se(h,"pointerup",f._onDrop),!this.nativeDraggable&&Se(h,"pointercancel",f._onDrop)):(Se(h,"mouseup",f._onDrop),Se(h,"touchend",f._onDrop),Se(h,"touchcancel",f._onDrop)),nc&&this.nativeDraggable&&(this.options.touchStartThreshold=4,J.draggable=!0),At("delayStart",this,{evt:l}),c.delay&&(!c.delayOnTouchOnly||s)&&(!this.nativeDraggable||!(yi||cr))){if(ge.eventCanceled){this._onDrop();return}c.supportPointer?(Se(h,"pointerup",f._disableDelayedDrag),Se(h,"pointercancel",f._disableDelayedDrag)):(Se(h,"mouseup",f._disableDelayedDrag),Se(h,"touchend",f._disableDelayedDrag),Se(h,"touchcancel",f._disableDelayedDrag)),Se(h,"mousemove",f._delayedDragTouchMoveHandler),Se(h,"touchmove",f._delayedDragTouchMoveHandler),c.supportPointer&&Se(h,"pointermove",f._delayedDragTouchMoveHandler),f._dragStartTimer=setTimeout(b,c.delay)}else b()}},_delayedDragTouchMoveHandler:function(l){var s=l.touches?l.touches[0]:l;Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){J&&kl(J),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var l=this.el.ownerDocument;ke(l,"mouseup",this._disableDelayedDrag),ke(l,"touchend",this._disableDelayedDrag),ke(l,"touchcancel",this._disableDelayedDrag),ke(l,"pointerup",this._disableDelayedDrag),ke(l,"pointercancel",this._disableDelayedDrag),ke(l,"mousemove",this._delayedDragTouchMoveHandler),ke(l,"touchmove",this._delayedDragTouchMoveHandler),ke(l,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(l,s){s=s||l.pointerType=="touch"&&l,!this.nativeDraggable||s?this.options.supportPointer?Se(document,"pointermove",this._onTouchMove):s?Se(document,"touchmove",this._onTouchMove):Se(document,"mousemove",this._onTouchMove):(Se(J,"dragend",this),Se(Pe,"dragstart",this._onDragStart));try{document.selection?zo(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(l,s){if(Sn=!1,Pe&&J){At("dragStarted",this,{evt:s}),this.nativeDraggable&&Se(document,"dragover",eg);var a=this.options;!l&&Bt(J,a.dragClass,!1),Bt(J,a.ghostClass,!0),ge.active=this,l&&this._appendGhost(),Ct({sortable:this,name:"start",originalEvent:s})}else this._nulling()},_emulateDragOver:function(){if(jt){this._lastX=jt.clientX,this._lastY=jt.clientY,wc();for(var l=document.elementFromPoint(jt.clientX,jt.clientY),s=l;l&&l.shadowRoot&&(l=l.shadowRoot.elementFromPoint(jt.clientX,jt.clientY),l!==s);)s=l;if(J.parentNode[Ft]._isOutsideThisEl(l),s)do{if(s[Ft]){var a=void 0;if(a=s[Ft]._onDragOver({clientX:jt.clientX,clientY:jt.clientY,target:l,rootEl:s}),a&&!this.options.dragoverBubble)break}l=s}while(s=hc(s));Cc()}},_onTouchMove:function(l){if(Xr){var s=this.options,a=s.fallbackTolerance,f=s.fallbackOffset,p=l.touches?l.touches[0]:l,c=ye&&An(ye,!0),h=ye&&c&&c.a,b=ye&&c&&c.d,y=No&>&&ac(gt),x=(p.clientX-Xr.clientX+f.x)/(h||1)+(y?y[0]-Cl[0]:0)/(h||1),C=(p.clientY-Xr.clientY+f.y)/(b||1)+(y?y[1]-Cl[1]:0)/(b||1);if(!ge.active&&!Sn){if(a&&Math.max(Math.abs(p.clientX-this._lastX),Math.abs(p.clientY-this._lastY))=0&&(Ct({rootEl:qe,name:"add",toEl:qe,fromEl:Pe,originalEvent:l}),Ct({sortable:this,name:"remove",toEl:qe,originalEvent:l}),Ct({rootEl:qe,name:"sort",toEl:qe,fromEl:Pe,originalEvent:l}),Ct({sortable:this,name:"sort",toEl:qe,originalEvent:l})),ft&&ft.save()):Nt!==En&&Nt>=0&&(Ct({sortable:this,name:"update",toEl:qe,originalEvent:l}),Ct({sortable:this,name:"sort",toEl:qe,originalEvent:l})),ge.active&&((Nt==null||Nt===-1)&&(Nt=En,Ar=vi),Ct({sortable:this,name:"end",toEl:qe,originalEvent:l}),this.save()))),this._nulling()},_nulling:function(){At("nulling",this),Pe=J=qe=ye=Yr=Re=Io=Fr=Xr=jt=ci=Nt=Ar=En=vi=kn=mi=ft=_o=ge.dragged=ge.ghost=ge.clone=ge.active=null;var l=this.el;Uo.forEach(function(s){l.contains(s)&&(s.checked=!0)}),Uo.length=Dl=wl=0},handleEvent:function(l){switch(l.type){case"drop":case"dragend":this._onDrop(l);break;case"dragenter":case"dragover":J&&(this._onDragOver(l),tg(l));break;case"selectstart":l.preventDefault();break}},toArray:function(){for(var l=[],s,a=this.el.children,f=0,p=a.length,c=this.options;ff.right+p||o.clientY>a.bottom&&o.clientX>a.left:o.clientY>f.bottom+p||o.clientX>a.right&&o.clientY>a.top}function og(o,l,s,a,f,p,c,h){var b=a?o.clientY:o.clientX,y=a?s.height:s.width,x=a?s.top:s.left,C=a?s.bottom:s.right,E=!1;if(!c){if(h&&Pox+y*p/2:bC-Po)return-mi}else if(b>x+y*(1-f)/2&&bC-y*p/2)?b>x+y/2?1:-1:0}function ag(o){return Pt(J)0||C>0&&E0?"Converting "+l+" photo"+(l>1?"s":"")+"\u2026":"Uploading "+C+" photo"+(C>1?"s":"")+"\u2026",s.details.open=!0):C>0?(s.summary.textContent="\u2713 "+C+" photo"+(C>1?"s":"")+" ready \u2014 tap to review",s.details.open=!1):(s.summary.textContent="Photos (1\u20136)",s.details.open=!0)}}function c(){p(),setTimeout(p,150),setTimeout(p,500)}function h(){var x=o.querySelector('button[type="submit"], input[type="submit"]');if(x&&(x.disabled=l>0),l>0)f("Converting "+l+" photo"+(l>1?"s":"")+"\u2026");else{var C=Ec();C&&/Converting/.test(C.textContent)&&f("")}p()}o.addEventListener("submit",function(x){l>0&&(x.preventDefault(),f("Hang on \u2014 a photo is still converting.","err"))},!0);function b(x){return function(C){var E=C&&C.file;return E?_c(E).then(function(F){return F?(l++,h(),import("./heic-to-CN7JBE7H.js").then(function(_){var L=_.heicTo||_.default&&_.default.heicTo;return L({blob:E,type:"image/jpeg",quality:.85})}).then(function(_){var L=new File([_],dg(E.name),{type:"image/jpeg"});x.addFile(L)}).catch(function(){f("A photo couldn\u2019t be converted and was skipped \u2014 the others are fine.","err")}).then(function(){l--,h()}),!1):!0}):!0}}var y=0;(function x(){var C=window.GravFilePond&&window.GravFilePond.getInstances?window.GravFilePond.getInstances():[];if(!C.length){y++<120&&setTimeout(x,50);return}C.forEach(function(E){E&&!E._heicHooked&&(E._heicHooked=!0,E.setOptions({beforeAddFile:b(E),allowReorder:!0,itemInsertLocation:"after"}),a=E,["addfile","processfile","processfiles","removefile","error"].forEach(function(F){try{E.on(F,c)}catch{}}),p())})})()}function Ot(o){return document.querySelector('[name="data['+o+']"]')}function gg(){var o=Array.prototype.slice.call(document.querySelectorAll(".advanced-field"));if(o.length){var l=[];if(o.forEach(function(p){var c=p.closest(".form-field");c&&l.indexOf(c)===-1&&l.push(c)}),!!l.length){var s=document.createElement("details");s.className="more-options";var a=document.createElement("summary");a.className="more-options__summary",a.textContent="More options",s.appendChild(a),l[0].parentNode.insertBefore(s,l[0]),l.forEach(function(p){s.appendChild(p)});var f=l.some(function(p){var c=p.querySelector('input[type="text"]');if(c&&c.value.trim())return!0;var h=p.querySelector('input[type="radio"]:checked');return!!(h&&h.value&&h.value!=="0")});f&&(s.open=!0)}}}var vg={0:"Sunny",1:"Partly cloudy",2:"Partly cloudy",3:"Cloudy",45:"Foggy",48:"Foggy",51:"Drizzle",53:"Drizzle",55:"Drizzle",56:"Drizzle",57:"Drizzle",61:"Rain",63:"Rain",65:"Rain",66:"Rain",67:"Rain",80:"Rain",81:"Rain",82:"Rain",71:"Snow",73:"Snow",75:"Snow",77:"Snow",85:"Snow",86:"Snow",95:"Thunderstorm",96:"Thunderstorm",99:"Thunderstorm"};function dr(o,l,s){o&&(o.className="form-status"+(s?" form-status--"+s:""),o.textContent=l||"")}function mg(){var o=document.getElementById("get-location"),l=document.getElementById("get-weather");if(!o&&!l)return;var s=document.getElementById("location-status"),a=document.getElementById("weather-status");function f(){var h=Ot("lat"),b=Ot("lng"),y=h?h.value.trim():"",x=b?b.value.trim():"";return y&&x?{lat:y,lng:x}:null}function p(){if(l){var h=!!f();l.disabled=!h,l.title=h?"":"Get location first"}}p();function c(h,b){var y=Ot("location_city"),x=Ot("location_country");if(!((!y||y.value.trim())&&(!x||x.value.trim()))){var C="https://api.bigdatacloud.net/data/reverse-geocode-client?latitude="+encodeURIComponent(h)+"&longitude="+encodeURIComponent(b)+"&localityLanguage=en";fetch(C).then(function(E){return E.json()}).then(function(E){var F=(E.city||E.locality||"").trim(),_=(E.countryName||"").trim();y&&!y.value.trim()&&F&&(y.value=F),x&&!x.value.trim()&&_&&(x.value=_);var L=[F,_].filter(Boolean).join(", ");L&&dr(s,"\u2713 Location captured \xB7 "+L,"ok")}).catch(function(){})}}o&&o.addEventListener("click",function(){if(!navigator.geolocation){dr(s,"Geolocation is not supported on this device.","err");return}o.classList.add("is-loading"),o.disabled=!0,dr(s,"Getting location\u2026"),navigator.geolocation.getCurrentPosition(function(h){var b=h.coords.latitude.toFixed(6),y=h.coords.longitude.toFixed(6),x=Ot("lat"),C=Ot("lng");x&&(x.value=b),C&&(C.value=y),o.classList.remove("is-loading"),o.disabled=!1,dr(s,"\u2713 Location captured \xB7 "+b+", "+y,"ok"),p(),c(b,y)},function(h){o.classList.remove("is-loading"),o.disabled=!1,dr(s,"\u2717 "+(h&&h.message?h.message:"Could not get location")+" \u2014 enter coordinates manually if needed.","err")},{enableHighAccuracy:!0,timeout:15e3})}),l&&l.addEventListener("click",function(){var h=f();if(!h){dr(a,"Get location first, then fetch weather.","err");return}l.classList.add("is-loading"),l.disabled=!0,dr(a,"Fetching weather\u2026");var b="https://api.open-meteo.com/v1/forecast?latitude="+h.lat+"&longitude="+h.lng+"¤t=temperature_2m,weather_code&temperature_unit=celsius";fetch(b).then(function(y){return y.json()}).then(function(y){var x=Math.round(y.current.temperature_2m),C=vg[y.current.weather_code]||"Cloudy",E=Ot("weather_temp_c"),F=Ot("weather_desc");E&&(E.value=x),F&&(F.value=C),l.classList.remove("is-loading"),p(),dr(a,"\u2713 Weather set \xB7 "+C+" \xB7 "+x+"\xB0C (edit above if needed)","ok")}).catch(function(){l.classList.remove("is-loading"),p(),dr(a,"\u2717 Could not fetch weather \u2014 set it manually above.","err")})})}function bg(){var o=new Date;return o.setSeconds(0,0),o.setMinutes(o.getMinutes()-o.getTimezoneOffset()),o.toISOString().slice(0,16)}function yg(){var o={title:"Title",date:"Date & time",content:"Content"},l=document.querySelector('form[name="new-entry"]');if(!l)return;var s=Ot("date");s&&!String(s.value).trim()&&(s.value=bg());function a(){l.querySelectorAll(".field-error").forEach(function(c){c.remove()}),l.querySelectorAll(".field-invalid").forEach(function(c){c.classList.remove("field-invalid")})}function f(c,h){c.classList.add("field-invalid");var b=document.createElement("span");b.className="field-error",b.textContent=h,c.parentNode.insertBefore(b,c.nextSibling)}function p(c){var h=l.querySelector(".photos-collapse"),b,y;if(h?(h.open=!0,y=h.querySelector(".photos-collapse__summary"),b=h):(b=document.querySelector(".filepond-root, .form-input-file"),y=b),!y)return b||null;var x=document.createElement("span");return x.className="field-error",x.textContent=c,y.insertAdjacentElement("afterend",x),b||y}l.addEventListener("submit",function(c){a();var h=null;!Xo&&document.querySelectorAll(".filepond--item").length<1&&(h=p("Add at least one photo.")),Object.keys(o).forEach(function(b){var y=Ot(b);y&&!String(y.value).trim()&&(f(y,o[b]+" is required."),h||(h=y))}),h&&(c.preventDefault(),typeof h.focus=="function"&&h.focus(),h.scrollIntoView({behavior:"smooth",block:"center"}))})}var Pl="intotheeast:new-entry-draft";function xg(o){return Array.prototype.slice.call(o.querySelectorAll('[name^="data["]')).filter(function(l){if(l.type==="file")return!1;var s=l.name;return s.indexOf("data[_json")!==0&&s.indexOf("data[photos")!==0})}function Dg(){var o=document.querySelector(".filepond-root, .form-input-file");if(!(!o||!o.parentNode)&&!o.parentNode.querySelector(".photo-reauth-hint")){var l=document.createElement("p");l.className="photo-reauth-hint is-shown",l.textContent="Your text was restored \u2014 photos need re-selecting (they can\u2019t be saved in a draft).",o.parentNode.insertBefore(l,o.nextSibling)}}function wg(){var o=document.querySelector('form[name="new-entry"]');if(!o||Xo)return;if(document.querySelector(".notices.success")){try{localStorage.removeItem(Pl)}catch{}return}function l(){var p={};xg(o).forEach(function(c){c.type==="radio"?c.checked&&(p[c.name]=c.value):p[c.name]=c.value});try{localStorage.setItem(Pl,JSON.stringify(p))}catch{}}var s=null;try{s=localStorage.getItem(Pl)}catch{s=null}if(s){var a=null;try{a=JSON.parse(s)}catch{a=null}if(a){var f=!1;Object.keys(a).forEach(function(p){var c=a[p];if(c!=null&&String(c).trim()&&(f=!0),p!=="data[content]"){var h=o.querySelectorAll('input[type="radio"][name="'+p+'"]');if(h.length){h.forEach(function(y){y.checked=y.value===c});return}var b=o.querySelector('[name="'+p+'"]');b&&b.type!=="file"&&(b.value=c)}}),window.postFormEditor&&a["data[content]"]!=null&&window.postFormEditor.value(a["data[content]"]),f&&Dg()}}o.addEventListener("input",l),o.addEventListener("change",l),window.postFormEditor&&window.postFormEditor.codemirror.on("change",l)}function Cg(){var o=document.querySelector(".post-form-wrap"),l=document.querySelector(".post-form-wrap .notices.success, .post-form-wrap .notices.green");if(!(!o||!l)){var s=document.createElement("div");s.className="post-success";var a=document.createElement("p");a.className="post-success__title",a.textContent="\u2713 Saved to your journal.",s.appendChild(a);var f=document.createElement("div");f.className="post-success__actions";var p=o.getAttribute("data-trip-url");if(p){var c=document.createElement("a");c.className="post-success__view",c.href=p,c.textContent="View your journal \u2192",f.appendChild(c)}var h=document.createElement("a");h.className="post-success__again",h.href=window.location.pathname,h.textContent="Post another",f.appendChild(h),s.appendChild(f),l.parentNode.insertBefore(s,l.nextSibling),["form",".form-action-row","#location-status","#weather-status"].forEach(function(b){var y=o.querySelector(b);y&&(y.style.display="none")}),l.scrollIntoView({behavior:"smooth",block:"start"})}}var Xo=!1;function Ac(o){return new URLSearchParams(window.location.search).get(o)}function hr(o,l){var s=Ot(o);s&&(s.value=l==null?"":String(l))}function zl(o,l){var s=l?"1":"0",a=document.querySelectorAll('[name="data['+o+']"]');Array.prototype.forEach.call(a,function(f){f.checked=String(f.value)===s})}function kg(o){var l=o==null?"":String(o);if(window.postFormEditor&&typeof window.postFormEditor.value=="function")window.postFormEditor.value(l);else{var s=Ot("content");s&&(s.value=l)}}function Fc(o,l){var s=o.querySelectorAll("input, textarea, select, button");Array.prototype.forEach.call(s,function(a){a.type==="file"||a.name&&a.name.indexOf("data[photos")===0||(a.disabled=l)}),window.postFormEditor&&window.postFormEditor.codemirror&&window.postFormEditor.codemirror.setOption("readOnly",l?"nocursor":!1)}function Hl(o,l){o&&(o.tagName==="INPUT"?o.value=l:o.textContent=l)}function Sg(o,l){var s=o.querySelector(".post-edit-error");if(s){s.textContent=l;return}var a=document.createElement("div");a.className="post-edit-error",a.setAttribute("role","alert"),a.textContent=l;var f=o.querySelector("h1");f?f.insertAdjacentElement("afterend",a):o.insertBefore(a,o.firstChild)}var Eg=/\.(jpe?g|png|webp|heic|heif|gif)$/i;function Tc(o){var l=/(?:^|\/)photo-0*(\d+)\./i.exec(o);return l?parseInt(l[1],10):Number.MAX_SAFE_INTEGER}function Ag(o,l){var s=Tc(o),a=Tc(l);return s!==a?s-a:ol?1:0}function Lc(o,l){var s=String(o||"photo"),a=s.lastIndexOf("."),f=(a>0?s.slice(0,a):s).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"photo",p=l?".jpg":a>0?s.slice(a).toLowerCase():".jpg",c=Date.now().toString(36)+Math.random().toString(36).slice(2,6);return f+"-"+c+p}function Fg(o){var l=document.querySelector('form[name="new-entry"]');if(!l||!o)return;var s=o.split("/").filter(Boolean).pop();if(!s)return;var a=document.querySelector(".filepond-root, .form-input-file"),f=a?a.closest(".form-field"):null;f&&(f.style.display="none");var p=l.querySelector(".photos-collapse");p&&(p.style.display="none");var c=document.createElement("div");c.className="photo-editor",c.innerHTML='

Photos

',f&&f.parentNode?f.parentNode.insertBefore(c,f):l.insertBefore(c,l.firstElementChild);var h=c.querySelector(".photo-editor__grid"),b=c.querySelector(".photo-editor__status"),y=c.querySelector(".photo-editor__add"),x=c.querySelector(".photo-editor__input"),C=[],E=null,F=!1,_=0;function L(S,R){b.textContent=S||"",b.className="photo-editor__status gpx-status"+(R?" error":"")}function T(S){F=S,y.disabled=S,Array.prototype.forEach.call(h.querySelectorAll(".photo-editor__del, .photo-editor__confirm-yes, .photo-editor__confirm-no"),function(R){R.disabled=S}),E&&E.option("disabled",S)}function O(S,R,z){return fetch(S,Object.assign({credentials:"include"},R)).then(function(K){if(K.ok||z&&z.indexOf(K.status)!==-1)return K;var ue=new Error("HTTP "+K.status);throw ue.status=K.status,ue})}function N(S,R){var z=S&&S.status;return z===401||z===403?"Your login session expired \u2014 sign in again, then retry.":R}function P(){return fetch("/api/v1/pages"+o+"/media",{credentials:"include",headers:{Accept:"application/json"}}).then(function(S){if(!S.ok)throw new Error("HTTP "+S.status);return S.json()}).then(function(S){return(S&&S.data||[]).filter(function(R){return R&&typeof R.filename=="string"&&Eg.test(R.filename)}).map(function(R){return R.filename}).sort(Ag)})}function I(S){return O("/api/v1/entry/"+encodeURIComponent(s)+"/photos/order",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({order:S})})}function W(S){if(C=(S||[]).slice(),E&&(E.destroy(),E=null),h.innerHTML="",!C.length){h.innerHTML='

No photos yet \u2014 add some.

';return}var R=++_;C.forEach(function(z){var K=document.createElement("div");K.className="photo-editor__cell",K.setAttribute("data-filename",z);var ue=document.createElement("img");ue.className="photo-editor__img",ue.loading="lazy",ue.alt=z,ue.src=o+"/"+encodeURIComponent(z)+"?v="+R;var De=document.createElement("button");De.type="button",De.className="photo-editor__del",De.setAttribute("aria-label","Delete "+z),De.textContent="\u2715",De.addEventListener("click",function(){U(K,z)}),K.appendChild(ue),K.appendChild(De),h.appendChild(K)}),C.length>1&&(E=new Sc(h,{animation:150,draggable:".photo-editor__cell",filter:".photo-editor__confirm",onEnd:be}))}function j(){return Array.prototype.map.call(h.querySelectorAll(".photo-editor__cell"),function(S){return S.getAttribute("data-filename")})}function X(S,R){if(S.length!==R.length)return!1;for(var z=0;zDelete?',S.appendChild(z),S.classList.add("is-confirming"),z.querySelector(".photo-editor__confirm-no").addEventListener("click",function(){S.classList.remove("is-confirming"),z.remove()}),z.querySelector(".photo-editor__confirm-yes").addEventListener("click",function(){z.querySelector(".photo-editor__confirm-yes").disabled=!0,z.querySelector(".photo-editor__confirm-no").disabled=!0,ae(R)})}}function ae(S){var R=C.slice(),z=C.filter(function(K){return K!==S});T(!0),L("Deleting\u2026"),O("/api/v1/pages"+o+"/media/"+encodeURIComponent(S),{method:"DELETE"},[204,404]).then(function(){return(z.length?I(z):Promise.resolve()).then(P).then(function(K){L(""),W(K)},function(){L("Photo deleted, but refreshing the list failed \u2014 reload if it looks off.",!0),W(z)})},function(K){L(N(K,"Couldn\u2019t delete that photo. Try again."),!0),W(R)}).then(function(){T(!1)})}function ne(S){return _c(S).then(function(R){return R?import("./heic-to-CN7JBE7H.js").then(function(z){var K=z.heicTo||z.default&&z.default.heicTo;return K({blob:S,type:"image/jpeg",quality:.85})}).then(function(z){return{blob:z,name:Lc(S.name,!0)}}):{blob:S,name:Lc(S.name,!1)}})}y.addEventListener("click",function(){F||x.click()}),x.addEventListener("change",function(){var S=Array.prototype.slice.call(x.files||[]);x.value="",S.length&&se(S)});function se(S){T(!0);var R=S.length,z=0,K=0,ue=!1,De=C.slice(),ot=Promise.resolve();S.forEach(function(A){ot=ot.then(function(){return z++,L("Uploading "+z+" of "+R+"\u2026"),ne(A).then(function(D){var ee=new FormData;return ee.append("file",D.blob,D.name),O("/api/v1/pages"+o+"/media",{method:"POST",body:ee})}).then(null,function(D){K++,D&&(D.status===401||D.status===403)&&(ue=!0)})})}),ot.then(function(){return L("Finishing\u2026"),P()}).then(function(A){var D=De.filter(function(he){return A.indexOf(he)!==-1}),ee=A.filter(function(he){return De.indexOf(he)===-1}),we=D.concat(ee);return we.length?I(we).catch(function(){return I(we)}).catch(function(){return Promise.all(ee.map(function(he){return O("/api/v1/pages"+o+"/media/"+encodeURIComponent(he),{method:"DELETE"},[204,404]).then(function(){return!0},function(){return!1})})).then(function(he){var $e=new Error("reorder failed");throw $e.rolledBack=!0,$e.rollbackIncomplete=he.indexOf(!1)!==-1,$e})}).then(P):(W([]),null)}).then(function(A){A&&W(A),K?L(ue?"Couldn\u2019t add photos \u2014 your login session expired. Sign in again, then retry.":K+" photo"+(K>1?"s":"")+" couldn\u2019t be added.",!0):L("")}).catch(function(A){var D;return A&&A.rolledBack?D=A.rollbackIncomplete?"Couldn\u2019t finish adding photos and cleanup was incomplete \u2014 reload the page and check your photos.":"Couldn\u2019t finish adding photos \u2014 changes were rolled back. Try again.":D="Couldn\u2019t add photos. Please try again.",L(D,!0),P().then(W,function(){W(De)})}).then(function(){T(!1)})}h.innerHTML='

Loading photos\u2026

',P().then(W).catch(function(){L("Couldn\u2019t load photos.",!0),W([])})}function Tg(){var o=document.querySelector('form[name="new-entry"]'),l=document.querySelector(".post-form-wrap");if(!(!o||!l)){var s=Ac("edit");if(s){Xo=!0;var a=l.querySelector("h1");a&&(a.textContent="Edit entry");var f=o.querySelector('button[type="submit"], input[type="submit"]'),p=f?f.tagName==="INPUT"?f.value:f.textContent:"Save changes";Fc(o,!0),Hl(f,"Loading entry\u2026");var c=Ac("return")||l.getAttribute("data-trip-url")||"";o.setAttribute("action","/post?edit="+encodeURIComponent(s)+(c?"&return="+encodeURIComponent(c):"")),fetch("/api/v1/pages"+s,{credentials:"include",headers:{Accept:"application/json"}}).then(function(h){if(!h.ok){var b=new Error("HTTP "+h.status);throw b.status=h.status,b}return h.json()}).then(function(h){var b=h&&h.data||{},y=b.header||{};hr("title",y.title!=null?y.title:b.title),hr("date",y.date?String(y.date).replace(" ","T"):""),kg(b.content),hr("lat",y.lat),hr("lng",y.lng),hr("location_city",y.location_city),hr("location_country",y.location_country),hr("weather_desc",y.weather_desc),hr("weather_temp_c",y.weather_temp_c),hr("transport_mode",y.transport_mode),zl("featured",y.featured),zl("force_connect",y.force_connect),zl("published",y.published!==void 0?y.published:b.published);var x=Ot("edit_path");x&&(x.value=s+"/entry.md"),Fc(o,!1),Hl(f,"Save changes");var C=o.querySelector(".more-options");C&&(C.open=!0),Fg(s)}).catch(function(h){var b=h&&h.status===404?"This entry no longer exists \u2014 it may have been deleted. Head back to the journal.":"Sorry \u2014 this entry couldn\u2019t be loaded for editing. Check your connection and try again.";Sg(l,b),Hl(f,p)})}}}function Mc(){window.postFormEditor=fg(),Cg(),Tg(),wg(),pg(),gg(),mg(),yg()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Mc):Mc(); +Maximum file size is #image_max_size#.`,importError:"Something went wrong when uploading the image #image_name#."};function V(o){o=o||{},o.parent=this;var l=!0;if(o.autoDownloadFontAwesome===!1&&(l=!1),o.autoDownloadFontAwesome!==!0)for(var s=document.styleSheets,a=0;a-1&&(l=!1);if(l){var f=document.createElement("link");f.rel="stylesheet",f.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(f)}if(o.element)this.element=o.element;else if(o.element===null){console.log("EasyMDE: Error. No element was found.");return}if(o.toolbar===void 0){o.toolbar=[];for(var p in Ur)Object.prototype.hasOwnProperty.call(Ur,p)&&(p.indexOf("separator-")!=-1&&o.toolbar.push("|"),(Ur[p].default===!0||o.showIcons&&o.showIcons.constructor===Array&&o.showIcons.indexOf(p)!=-1)&&o.toolbar.push(p))}if(Object.prototype.hasOwnProperty.call(o,"previewClass")||(o.previewClass="editor-preview"),Object.prototype.hasOwnProperty.call(o,"status")||(o.status=["autosave","lines","words","cursor"],o.uploadImage&&o.status.unshift("upload-image")),o.previewRender||(o.previewRender=function(h){return this.parent.markdown(h)}),o.parsingConfig=sr({highlightFormatting:!0},o.parsingConfig||{}),o.insertTexts=sr({},Mp,o.insertTexts||{}),o.promptTexts=sr({},_p,o.promptTexts||{}),o.blockStyles=sr({},Np,o.blockStyles||{}),o.autosave!=null&&(o.autosave.timeFormat=sr({},Bp,o.autosave.timeFormat||{})),o.iconClassMap=sr({},Me,o.iconClassMap||{}),o.shortcuts=sr({},Cp,o.shortcuts||{}),o.maxHeight=o.maxHeight||void 0,o.direction=o.direction||"ltr",typeof o.maxHeight<"u"?o.minHeight=o.maxHeight:o.minHeight=o.minHeight||"300px",o.errorCallback=o.errorCallback||function(h){alert(h)},o.uploadImage=o.uploadImage||!1,o.imageMaxSize=o.imageMaxSize||2097152,o.imageAccept=o.imageAccept||"image/png, image/jpeg, image/gif, image/avif",o.imageTexts=sr({},Op,o.imageTexts||{}),o.errorMessages=sr({},Ip,o.errorMessages||{}),o.imagePathAbsolute=o.imagePathAbsolute||!1,o.imageCSRFName=o.imageCSRFName||"csrfmiddlewaretoken",o.imageCSRFHeader=o.imageCSRFHeader||!1,o.imageInputName=o.imageInputName||"image",o.autosave!=null&&o.autosave.unique_id!=null&&o.autosave.unique_id!=""&&(o.autosave.uniqueId=o.autosave.unique_id),o.overlayMode&&o.overlayMode.combine===void 0&&(o.overlayMode.combine=!0),this.options=o,this.render(),o.initialValue&&(!this.options.autosave||this.options.autosave.foundSavedValue!==!0)&&this.value(o.initialValue),o.uploadImage){var c=this;this.codemirror.on("dragenter",function(h,b){c.updateStatusBar("upload-image",c.options.imageTexts.sbOnDragEnter),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("dragend",function(h,b){c.updateStatusBar("upload-image",c.options.imageTexts.sbInit),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("dragleave",function(h,b){c.updateStatusBar("upload-image",c.options.imageTexts.sbInit),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("dragover",function(h,b){c.updateStatusBar("upload-image",c.options.imageTexts.sbOnDragEnter),b.stopPropagation(),b.preventDefault()}),this.codemirror.on("drop",function(h,b){b.stopPropagation(),b.preventDefault(),o.imageUploadFunction?c.uploadImagesUsingCustomFunction(o.imageUploadFunction,b.dataTransfer.files):c.uploadImages(b.dataTransfer.files)}),this.codemirror.on("paste",function(h,b){o.imageUploadFunction?c.uploadImagesUsingCustomFunction(o.imageUploadFunction,b.clipboardData.files):c.uploadImages(b.clipboardData.files)})}}V.prototype.uploadImages=function(o,l,s){if(o.length!==0){for(var a=[],f=0;f=2){var P=N[1];if(l.imagesPreviewHandler){var I=l.imagesPreviewHandler(N[1]);typeof I=="string"&&(P=I)}if(window.EMDEimagesCache[P])F(O,window.EMDEimagesCache[P]);else{window.EMDEimagesCache[P]={};var W=document.createElement("img");W.onload=function(){window.EMDEimagesCache[P]={naturalWidth:W.naturalWidth,naturalHeight:W.naturalHeight,url:P},F(O,window.EMDEimagesCache[P])},W.src=P}}}})}this.codemirror.on("update",function(){_()}),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element,(l.autofocus===!0||o.autofocus)&&this.codemirror.focus();var L=this.codemirror;setTimeout(function(){L.refresh()}.bind(L),0)};V.prototype.cleanup=function(){document.removeEventListener("keydown",this.documentOnKeyDown)};function Vf(){if(typeof localStorage=="object")try{localStorage.setItem("smde_localStorage",1),localStorage.removeItem("smde_localStorage")}catch{return!1}else return!1;return!0}V.prototype.autosave=function(){if(Vf()){var o=this;if(this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to use the autosave feature");return}this.options.autosave.binded!==!0&&(o.element.form!=null&&o.element.form!=null&&o.element.form.addEventListener("submit",function(){clearTimeout(o.autosaveTimeoutId),o.autosaveTimeoutId=void 0,localStorage.removeItem("smde_"+o.options.autosave.uniqueId)}),this.options.autosave.binded=!0),this.options.autosave.loaded!==!0&&(typeof localStorage.getItem("smde_"+this.options.autosave.uniqueId)=="string"&&localStorage.getItem("smde_"+this.options.autosave.uniqueId)!=""&&(this.codemirror.setValue(localStorage.getItem("smde_"+this.options.autosave.uniqueId)),this.options.autosave.foundSavedValue=!0),this.options.autosave.loaded=!0);var l=o.value();l!==""?localStorage.setItem("smde_"+this.options.autosave.uniqueId,l):localStorage.removeItem("smde_"+this.options.autosave.uniqueId);var s=document.getElementById("autosaved");if(s!=null&&s!=null&&s!=""){var a=new Date,f=new Intl.DateTimeFormat([this.options.autosave.timeFormat.locale,"en-US"],this.options.autosave.timeFormat.format).format(a),p=this.options.autosave.text==null?"Autosaved: ":this.options.autosave.text;s.innerHTML=p+f}}else console.log("EasyMDE: localStorage not available, cannot autosave")};V.prototype.clearAutosavedValue=function(){if(Vf()){if(this.options.autosave==null||this.options.autosave.uniqueId==null||this.options.autosave.uniqueId==""){console.log("EasyMDE: You must set a uniqueId to clear the autosave value");return}localStorage.removeItem("smde_"+this.options.autosave.uniqueId)}else console.log("EasyMDE: localStorage not available, cannot autosave")};V.prototype.openBrowseFileWindow=function(o,l){var s=this,a=this.gui.toolbar.getElementsByClassName("imageInput")[0];a.click();function f(p){s.options.imageUploadFunction?s.uploadImagesUsingCustomFunction(s.options.imageUploadFunction,p.target.files):s.uploadImages(p.target.files,o,l),a.removeEventListener("change",f)}a.addEventListener("change",f)};V.prototype.uploadImage=function(o,l,s){var a=this;l=l||function(y){Qf(a,y)};function f(b){a.updateStatusBar("upload-image",b),setTimeout(function(){a.updateStatusBar("upload-image",a.options.imageTexts.sbInit)},1e4),s&&typeof s=="function"&&s(b),a.options.errorCallback(b)}function p(b){var y=a.options.imageTexts.sizeUnits.split(",");return b.replace("#image_name#",o.name).replace("#image_size#",uo(o.size,y)).replace("#image_max_size#",uo(a.options.imageMaxSize,y))}if(o.size>this.options.imageMaxSize){f(p(this.options.errorMessages.fileTooLarge));return}var c=new FormData;c.append("image",o),a.options.imageCSRFToken&&!a.options.imageCSRFHeader&&c.append(a.options.imageCSRFName,a.options.imageCSRFToken);var h=new XMLHttpRequest;h.upload.onprogress=function(b){if(b.lengthComputable){var y=""+Math.round(b.loaded*100/b.total);a.updateStatusBar("upload-image",a.options.imageTexts.sbProgress.replace("#file_name#",o.name).replace("#progress#",y))}},h.open("POST",this.options.imageUploadEndpoint),a.options.imageCSRFToken&&a.options.imageCSRFHeader&&h.setRequestHeader(a.options.imageCSRFName,a.options.imageCSRFToken),h.onload=function(){try{var b=JSON.parse(this.responseText)}catch{console.error("EasyMDE: The server did not return a valid json."),f(p(a.options.errorMessages.importError));return}this.status===200&&b&&!b.error&&b.data&&b.data.filePath?l((a.options.imagePathAbsolute?"":window.location.origin+"/")+b.data.filePath):b.error&&b.error in a.options.errorMessages?f(p(a.options.errorMessages[b.error])):b.error?f(p(b.error)):(console.error("EasyMDE: Received an unexpected response after uploading the image."+this.status+" ("+this.statusText+")"),f(p(a.options.errorMessages.importError)))},h.onerror=function(b){console.error("EasyMDE: An unexpected error occurred when trying to upload the image."+b.target.status+" ("+b.target.statusText+")"),f(a.options.errorMessages.importError)},h.send(c)};V.prototype.uploadImageUsingCustomFunction=function(o,l){var s=this;function a(c){Qf(s,c)}function f(c){var h=p(c);s.updateStatusBar("upload-image",h),setTimeout(function(){s.updateStatusBar("upload-image",s.options.imageTexts.sbInit)},1e4),s.options.errorCallback(h)}function p(c){var h=s.options.imageTexts.sizeUnits.split(",");return c.replace("#image_name#",l.name).replace("#image_size#",uo(l.size,h)).replace("#image_max_size#",uo(s.options.imageMaxSize,h))}o.apply(this,[l,a,f])};V.prototype.setPreviewMaxHeight=function(){var o=this.codemirror,l=o.getWrapperElement(),s=l.nextSibling,a=parseInt(window.getComputedStyle(l).paddingTop),f=parseInt(window.getComputedStyle(l).borderTopWidth),p=parseInt(this.options.maxHeight),c=p+a*2+f*2,h=c.toString()+"px";s.style.height=h};V.prototype.createSideBySide=function(){var o=this.codemirror,l=o.getWrapperElement(),s=l.nextSibling;if(!s||!s.classList.contains("editor-preview-side")){if(s=document.createElement("div"),s.className="editor-preview-side",this.options.previewClass)if(Array.isArray(this.options.previewClass))for(var a=0;a"&&(l=l.substring(1)),o)try{if(o.matches)return o.matches(l);if(o.msMatchesSelector)return o.msMatchesSelector(l);if(o.webkitMatchesSelector)return o.webkitMatchesSelector(l)}catch{return!1}return!1}}function hc(o){return o.host&&o!==document&&o.host.nodeType&&o.host!==o?o.host:o.parentNode}function Gt(o,l,s,a){if(o){s=s||document;do{if(l!=null&&(l[0]===">"?o.parentNode===s&&Ro(o,l):Ro(o,l))||a&&o===s)return o;if(o===s)break}while(o=hc(o))}return null}var ic=/\s+/g;function Bt(o,l,s){if(o&&l)if(o.classList)o.classList[s?"add":"remove"](l);else{var a=(" "+o.className+" ").replace(ic," ").replace(" "+l+" "," ");o.className=(a+(s?" "+l:"")).replace(ic," ")}}function pe(o,l,s){var a=o&&o.style;if(a){if(s===void 0)return document.defaultView&&document.defaultView.getComputedStyle?s=document.defaultView.getComputedStyle(o,""):o.currentStyle&&(s=o.currentStyle),l===void 0?s:s[l];!(l in a)&&l.indexOf("webkit")===-1&&(l="-webkit-"+l),a[l]=s+(typeof s=="string"?"":"px")}}function An(o,l){var s="";if(typeof o=="string")s=o;else do{var a=pe(o,"transform");a&&a!=="none"&&(s=a+" "+s)}while(!l&&(o=o.parentNode));var f=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return f&&new f(s)}function pc(o,l,s){if(o){var a=o.getElementsByTagName(l),f=0,p=a.length;if(s)for(;f=p:c=f<=p,!c)return a;if(a===Vt())break;a=Tr(a,!1)}return!1}function Fn(o,l,s,a){for(var f=0,p=0,c=o.children;p2&&arguments[2]!==void 0?arguments[2]:{},f=a.evt,p=zp(a,Qp);xi.pluginEvent.bind(ge)(l,s,er({dragEl:J,parentEl:qe,ghostEl:ye,rootEl:Pe,nextEl:Yr,lastDownEl:Io,cloneEl:Re,cloneHidden:Fr,dragStarted:ci,putSortable:ft,activeSortable:ge.active,originalEvent:f,oldIndex:En,oldDraggableIndex:vi,newIndex:Nt,newDraggableIndex:Ar,hideGhostForTarget:wc,unhideGhostForTarget:Cc,cloneNowHidden:function(){Fr=!0},cloneNowShown:function(){Fr=!1},dispatchSortableEvent:function(h){Ct({sortable:s,name:h,originalEvent:f})}},p))};function Ct(o){Zp(er({putSortable:ft,cloneEl:Re,targetEl:J,rootEl:Pe,oldIndex:En,oldDraggableIndex:vi,newIndex:Nt,newDraggableIndex:Ar},o))}var J,qe,ye,Pe,Yr,Io,Re,Fr,En,Nt,vi,Ar,_o,ft,Sn=!1,Wo=!1,qo=[],Xr,jt,Dl,wl,lc,sc,ci,kn,mi,bi=!1,Bo=!1,Po,gt,Cl=[],Tl=!1,Uo=[],Go=typeof document<"u",No=Bl,uc=yi||cr?"cssFloat":"float",Jp=Go&&!cc&&!Bl&&"draggable"in document.createElement("div"),yc=function(){if(Go){if(cr)return!1;var o=document.createElement("x");return o.style.cssText="pointer-events:auto",o.style.pointerEvents==="auto"}}(),xc=function(l,s){var a=pe(l),f=parseInt(a.width)-parseInt(a.paddingLeft)-parseInt(a.paddingRight)-parseInt(a.borderLeftWidth)-parseInt(a.borderRightWidth),p=Fn(l,0,s),c=Fn(l,1,s),h=p&&pe(p),b=c&&pe(c),y=h&&parseInt(h.marginLeft)+parseInt(h.marginRight)+Je(p).width,x=b&&parseInt(b.marginLeft)+parseInt(b.marginRight)+Je(c).width;if(a.display==="flex")return a.flexDirection==="column"||a.flexDirection==="column-reverse"?"vertical":"horizontal";if(a.display==="grid")return a.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(p&&h.float&&h.float!=="none"){var C=h.float==="left"?"left":"right";return c&&(b.clear==="both"||b.clear===C)?"vertical":"horizontal"}return p&&(h.display==="block"||h.display==="flex"||h.display==="table"||h.display==="grid"||y>=f&&a[uc]==="none"||c&&a[uc]==="none"&&y+x>f)?"vertical":"horizontal"},$p=function(l,s,a){var f=a?l.left:l.top,p=a?l.right:l.bottom,c=a?l.width:l.height,h=a?s.left:s.top,b=a?s.right:s.bottom,y=a?s.width:s.height;return f===h||p===b||f+c/2===h+y/2},Vp=function(l,s){var a;return qo.some(function(f){var p=f[Ft].options.emptyInsertThreshold;if(!(!p||Nl(f))){var c=Je(f),h=l>=c.left-p&&l<=c.right+p,b=s>=c.top-p&&s<=c.bottom+p;if(h&&b)return a=f}}),a},Dc=function(l){function s(p,c){return function(h,b,y,x){var C=h.options.group.name&&b.options.group.name&&h.options.group.name===b.options.group.name;if(p==null&&(c||C))return!0;if(p==null||p===!1)return!1;if(c&&p==="clone")return p;if(typeof p=="function")return s(p(h,b,y,x),c)(h,b,y,x);var E=(c?h:b).options.group.name;return p===!0||typeof p=="string"&&p===E||p.join&&p.indexOf(E)>-1}}var a={},f=l.group;(!f||Fl(f)!="object")&&(f={name:f}),a.name=f.name,a.checkPull=s(f.pull,!0),a.checkPut=s(f.put),a.revertClone=f.revertClone,l.group=a},wc=function(){!yc&&ye&&pe(ye,"display","none")},Cc=function(){!yc&&ye&&pe(ye,"display","")};Go&&!cc&&document.addEventListener("click",function(o){if(Wo)return o.preventDefault(),o.stopPropagation&&o.stopPropagation(),o.stopImmediatePropagation&&o.stopImmediatePropagation(),Wo=!1,!1},!0);var Kr=function(l){if(J){l=l.touches?l.touches[0]:l;var s=Vp(l.clientX,l.clientY);if(s){var a={};for(var f in l)l.hasOwnProperty(f)&&(a[f]=l[f]);a.target=a.rootEl=s,a.preventDefault=void 0,a.stopPropagation=void 0,s[Ft]._onDragOver(a)}}},eg=function(l){J&&J.parentNode[Ft]._isOutsideThisEl(l.target)};function ge(o,l){if(!(o&&o.nodeType&&o.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(o));this.el=o,this.options=l=fr({},l),o[Ft]=this;var s={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(o.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return xc(o,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(c,h){c.setData("Text",h.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:ge.supportPointer!==!1&&"PointerEvent"in window&&(!pi||Bl),emptyInsertThreshold:5};xi.initializePlugins(this,o,s);for(var a in s)!(a in l)&&(l[a]=s[a]);Dc(l);for(var f in this)f.charAt(0)==="_"&&typeof this[f]=="function"&&(this[f]=this[f].bind(this));this.nativeDraggable=l.forceFallback?!1:Jp,this.nativeDraggable&&(this.options.touchStartThreshold=1),l.supportPointer?Se(o,"pointerdown",this._onTapStart):(Se(o,"mousedown",this._onTapStart),Se(o,"touchstart",this._onTapStart)),this.nativeDraggable&&(Se(o,"dragover",this),Se(o,"dragenter",this)),qo.push(this.el),l.store&&l.store.get&&this.sort(l.store.get(this)||[]),fr(this,Xp())}ge.prototype={constructor:ge,_isOutsideThisEl:function(l){!this.el.contains(l)&&l!==this.el&&(kn=null)},_getDirection:function(l,s){return typeof this.options.direction=="function"?this.options.direction.call(this,l,s,J):this.options.direction},_onTapStart:function(l){if(l.cancelable){var s=this,a=this.el,f=this.options,p=f.preventOnFilter,c=l.type,h=l.touches&&l.touches[0]||l.pointerType&&l.pointerType==="touch"&&l,b=(h||l).target,y=l.target.shadowRoot&&(l.path&&l.path[0]||l.composedPath&&l.composedPath()[0])||b,x=f.filter;if(sg(a),!J&&!(/mousedown|pointerdown/.test(c)&&l.button!==0||f.disabled)&&!y.isContentEditable&&!(!this.nativeDraggable&&pi&&b&&b.tagName.toUpperCase()==="SELECT")&&(b=Gt(b,f.draggable,a,!1),!(b&&b.animated)&&Io!==b)){if(En=Pt(b),vi=Pt(b,f.draggable),typeof x=="function"){if(x.call(this,l,b,this)){Ct({sortable:s,rootEl:y,name:"filter",targetEl:b,toEl:a,fromEl:a}),At("filter",s,{evt:l}),p&&l.preventDefault();return}}else if(x&&(x=x.split(",").some(function(C){if(C=Gt(y,C.trim(),a,!1),C)return Ct({sortable:s,rootEl:C,name:"filter",targetEl:b,fromEl:a,toEl:a}),At("filter",s,{evt:l}),!0}),x)){p&&l.preventDefault();return}f.handle&&!Gt(y,f.handle,a,!1)||this._prepareDragStart(l,h,b)}}},_prepareDragStart:function(l,s,a){var f=this,p=f.el,c=f.options,h=p.ownerDocument,b;if(a&&!J&&a.parentNode===p){var y=Je(a);if(Pe=p,J=a,qe=J.parentNode,Yr=J.nextSibling,Io=a,_o=c.group,ge.dragged=J,Xr={target:J,clientX:(s||l).clientX,clientY:(s||l).clientY},lc=Xr.clientX-y.left,sc=Xr.clientY-y.top,this._lastX=(s||l).clientX,this._lastY=(s||l).clientY,J.style["will-change"]="all",b=function(){if(At("delayEnded",f,{evt:l}),ge.eventCanceled){f._onDrop();return}f._disableDelayedDragEvents(),!nc&&f.nativeDraggable&&(J.draggable=!0),f._triggerDragStart(l,s),Ct({sortable:f,name:"choose",originalEvent:l}),Bt(J,c.chosenClass,!0)},c.ignore.split(",").forEach(function(x){pc(J,x.trim(),kl)}),Se(h,"dragover",Kr),Se(h,"mousemove",Kr),Se(h,"touchmove",Kr),c.supportPointer?(Se(h,"pointerup",f._onDrop),!this.nativeDraggable&&Se(h,"pointercancel",f._onDrop)):(Se(h,"mouseup",f._onDrop),Se(h,"touchend",f._onDrop),Se(h,"touchcancel",f._onDrop)),nc&&this.nativeDraggable&&(this.options.touchStartThreshold=4,J.draggable=!0),At("delayStart",this,{evt:l}),c.delay&&(!c.delayOnTouchOnly||s)&&(!this.nativeDraggable||!(yi||cr))){if(ge.eventCanceled){this._onDrop();return}c.supportPointer?(Se(h,"pointerup",f._disableDelayedDrag),Se(h,"pointercancel",f._disableDelayedDrag)):(Se(h,"mouseup",f._disableDelayedDrag),Se(h,"touchend",f._disableDelayedDrag),Se(h,"touchcancel",f._disableDelayedDrag)),Se(h,"mousemove",f._delayedDragTouchMoveHandler),Se(h,"touchmove",f._delayedDragTouchMoveHandler),c.supportPointer&&Se(h,"pointermove",f._delayedDragTouchMoveHandler),f._dragStartTimer=setTimeout(b,c.delay)}else b()}},_delayedDragTouchMoveHandler:function(l){var s=l.touches?l.touches[0]:l;Math.max(Math.abs(s.clientX-this._lastX),Math.abs(s.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){J&&kl(J),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var l=this.el.ownerDocument;ke(l,"mouseup",this._disableDelayedDrag),ke(l,"touchend",this._disableDelayedDrag),ke(l,"touchcancel",this._disableDelayedDrag),ke(l,"pointerup",this._disableDelayedDrag),ke(l,"pointercancel",this._disableDelayedDrag),ke(l,"mousemove",this._delayedDragTouchMoveHandler),ke(l,"touchmove",this._delayedDragTouchMoveHandler),ke(l,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(l,s){s=s||l.pointerType=="touch"&&l,!this.nativeDraggable||s?this.options.supportPointer?Se(document,"pointermove",this._onTouchMove):s?Se(document,"touchmove",this._onTouchMove):Se(document,"mousemove",this._onTouchMove):(Se(J,"dragend",this),Se(Pe,"dragstart",this._onDragStart));try{document.selection?zo(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(l,s){if(Sn=!1,Pe&&J){At("dragStarted",this,{evt:s}),this.nativeDraggable&&Se(document,"dragover",eg);var a=this.options;!l&&Bt(J,a.dragClass,!1),Bt(J,a.ghostClass,!0),ge.active=this,l&&this._appendGhost(),Ct({sortable:this,name:"start",originalEvent:s})}else this._nulling()},_emulateDragOver:function(){if(jt){this._lastX=jt.clientX,this._lastY=jt.clientY,wc();for(var l=document.elementFromPoint(jt.clientX,jt.clientY),s=l;l&&l.shadowRoot&&(l=l.shadowRoot.elementFromPoint(jt.clientX,jt.clientY),l!==s);)s=l;if(J.parentNode[Ft]._isOutsideThisEl(l),s)do{if(s[Ft]){var a=void 0;if(a=s[Ft]._onDragOver({clientX:jt.clientX,clientY:jt.clientY,target:l,rootEl:s}),a&&!this.options.dragoverBubble)break}l=s}while(s=hc(s));Cc()}},_onTouchMove:function(l){if(Xr){var s=this.options,a=s.fallbackTolerance,f=s.fallbackOffset,p=l.touches?l.touches[0]:l,c=ye&&An(ye,!0),h=ye&&c&&c.a,b=ye&&c&&c.d,y=No&>&&ac(gt),x=(p.clientX-Xr.clientX+f.x)/(h||1)+(y?y[0]-Cl[0]:0)/(h||1),C=(p.clientY-Xr.clientY+f.y)/(b||1)+(y?y[1]-Cl[1]:0)/(b||1);if(!ge.active&&!Sn){if(a&&Math.max(Math.abs(p.clientX-this._lastX),Math.abs(p.clientY-this._lastY))=0&&(Ct({rootEl:qe,name:"add",toEl:qe,fromEl:Pe,originalEvent:l}),Ct({sortable:this,name:"remove",toEl:qe,originalEvent:l}),Ct({rootEl:qe,name:"sort",toEl:qe,fromEl:Pe,originalEvent:l}),Ct({sortable:this,name:"sort",toEl:qe,originalEvent:l})),ft&&ft.save()):Nt!==En&&Nt>=0&&(Ct({sortable:this,name:"update",toEl:qe,originalEvent:l}),Ct({sortable:this,name:"sort",toEl:qe,originalEvent:l})),ge.active&&((Nt==null||Nt===-1)&&(Nt=En,Ar=vi),Ct({sortable:this,name:"end",toEl:qe,originalEvent:l}),this.save()))),this._nulling()},_nulling:function(){At("nulling",this),Pe=J=qe=ye=Yr=Re=Io=Fr=Xr=jt=ci=Nt=Ar=En=vi=kn=mi=ft=_o=ge.dragged=ge.ghost=ge.clone=ge.active=null;var l=this.el;Uo.forEach(function(s){l.contains(s)&&(s.checked=!0)}),Uo.length=Dl=wl=0},handleEvent:function(l){switch(l.type){case"drop":case"dragend":this._onDrop(l);break;case"dragenter":case"dragover":J&&(this._onDragOver(l),tg(l));break;case"selectstart":l.preventDefault();break}},toArray:function(){for(var l=[],s,a=this.el.children,f=0,p=a.length,c=this.options;ff.right+p||o.clientY>a.bottom&&o.clientX>a.left:o.clientY>f.bottom+p||o.clientX>a.right&&o.clientY>a.top}function og(o,l,s,a,f,p,c,h){var b=a?o.clientY:o.clientX,y=a?s.height:s.width,x=a?s.top:s.left,C=a?s.bottom:s.right,E=!1;if(!c){if(h&&Pox+y*p/2:bC-Po)return-mi}else if(b>x+y*(1-f)/2&&bC-y*p/2)?b>x+y/2?1:-1:0}function ag(o){return Pt(J)0||C>0&&E0?"Converting "+l+" photo"+(l>1?"s":"")+"\u2026":"Uploading "+C+" photo"+(C>1?"s":"")+"\u2026",s.details.open=!0):C>0?(s.summary.textContent="\u2713 "+C+" photo"+(C>1?"s":"")+" ready \u2014 tap to review",s.details.open=!1):(s.summary.textContent="Photos (1\u20136)",s.details.open=!0)}}function c(){p(),setTimeout(p,150),setTimeout(p,500)}function h(){var x=o.querySelector('button[type="submit"], input[type="submit"]');if(x&&(x.disabled=l>0),l>0)f("Converting "+l+" photo"+(l>1?"s":"")+"\u2026");else{var C=Ec();C&&/Converting/.test(C.textContent)&&f("")}p()}o.addEventListener("submit",function(x){l>0&&(x.preventDefault(),f("Hang on \u2014 a photo is still converting.","err"))},!0);function b(x){return function(C){var E=C&&C.file;return E?_c(E).then(function(F){return F?(l++,h(),import("./heic-to-CN7JBE7H.js").then(function(_){var L=_.heicTo||_.default&&_.default.heicTo;return L({blob:E,type:"image/jpeg",quality:.85})}).then(function(_){var L=new File([_],dg(E.name),{type:"image/jpeg"});x.addFile(L)}).catch(function(){f("A photo couldn\u2019t be converted and was skipped \u2014 the others are fine.","err")}).then(function(){l--,h()}),!1):!0}):!0}}var y=0;(function x(){var C=window.GravFilePond&&window.GravFilePond.getInstances?window.GravFilePond.getInstances():[];if(!C.length){y++<120&&setTimeout(x,50);return}C.forEach(function(E){E&&!E._heicHooked&&(E._heicHooked=!0,E.setOptions({beforeAddFile:b(E),allowReorder:!0,itemInsertLocation:"after"}),a=E,["addfile","processfile","processfiles","removefile","error"].forEach(function(F){try{E.on(F,c)}catch{}}),p())})})()}function Ot(o){return document.querySelector('[name="data['+o+']"]')}function gg(){var o=Array.prototype.slice.call(document.querySelectorAll(".advanced-field"));if(o.length){var l=[];if(o.forEach(function(p){var c=p.closest(".form-field");c&&l.indexOf(c)===-1&&l.push(c)}),!!l.length){var s=document.createElement("details");s.className="more-options";var a=document.createElement("summary");a.className="more-options__summary",a.textContent="More options",s.appendChild(a),l[0].parentNode.insertBefore(s,l[0]),l.forEach(function(p){s.appendChild(p)});var f=l.some(function(p){var c=p.querySelector('input[type="text"]');if(c&&c.value.trim())return!0;var h=p.querySelector('input[type="radio"]:checked');if(!h||!h.value)return!1;var b=/\[published\]$/.test(h.name||"");return b?h.value==="0":h.value!=="0"});f&&(s.open=!0)}}}var vg={0:"Sunny",1:"Partly cloudy",2:"Partly cloudy",3:"Cloudy",45:"Foggy",48:"Foggy",51:"Drizzle",53:"Drizzle",55:"Drizzle",56:"Drizzle",57:"Drizzle",61:"Rain",63:"Rain",65:"Rain",66:"Rain",67:"Rain",80:"Rain",81:"Rain",82:"Rain",71:"Snow",73:"Snow",75:"Snow",77:"Snow",85:"Snow",86:"Snow",95:"Thunderstorm",96:"Thunderstorm",99:"Thunderstorm"};function dr(o,l,s){o&&(o.className="form-status"+(s?" form-status--"+s:""),o.textContent=l||"")}function mg(){var o=document.getElementById("get-location"),l=document.getElementById("get-weather");if(!o&&!l)return;var s=document.getElementById("location-status"),a=document.getElementById("weather-status");function f(){var h=Ot("lat"),b=Ot("lng"),y=h?h.value.trim():"",x=b?b.value.trim():"";return y&&x?{lat:y,lng:x}:null}function p(){if(l){var h=!!f();l.disabled=!h,l.title=h?"":"Get location first"}}p();function c(h,b){var y=Ot("location_city"),x=Ot("location_country");if(!((!y||y.value.trim())&&(!x||x.value.trim()))){var C="https://api.bigdatacloud.net/data/reverse-geocode-client?latitude="+encodeURIComponent(h)+"&longitude="+encodeURIComponent(b)+"&localityLanguage=en";fetch(C).then(function(E){return E.json()}).then(function(E){var F=(E.city||E.locality||"").trim(),_=(E.countryName||"").trim();y&&!y.value.trim()&&F&&(y.value=F),x&&!x.value.trim()&&_&&(x.value=_);var L=[F,_].filter(Boolean).join(", ");L&&dr(s,"\u2713 Location captured \xB7 "+L,"ok")}).catch(function(){})}}o&&o.addEventListener("click",function(){if(!navigator.geolocation){dr(s,"Geolocation is not supported on this device.","err");return}o.classList.add("is-loading"),o.disabled=!0,dr(s,"Getting location\u2026"),navigator.geolocation.getCurrentPosition(function(h){var b=h.coords.latitude.toFixed(6),y=h.coords.longitude.toFixed(6),x=Ot("lat"),C=Ot("lng");x&&(x.value=b),C&&(C.value=y),o.classList.remove("is-loading"),o.disabled=!1,dr(s,"\u2713 Location captured \xB7 "+b+", "+y,"ok"),p(),c(b,y)},function(h){o.classList.remove("is-loading"),o.disabled=!1,dr(s,"\u2717 "+(h&&h.message?h.message:"Could not get location")+" \u2014 enter coordinates manually if needed.","err")},{enableHighAccuracy:!0,timeout:15e3})}),l&&l.addEventListener("click",function(){var h=f();if(!h){dr(a,"Get location first, then fetch weather.","err");return}l.classList.add("is-loading"),l.disabled=!0,dr(a,"Fetching weather\u2026");var b="https://api.open-meteo.com/v1/forecast?latitude="+h.lat+"&longitude="+h.lng+"¤t=temperature_2m,weather_code&temperature_unit=celsius";fetch(b).then(function(y){return y.json()}).then(function(y){var x=Math.round(y.current.temperature_2m),C=vg[y.current.weather_code]||"Cloudy",E=Ot("weather_temp_c"),F=Ot("weather_desc");E&&(E.value=x),F&&(F.value=C),l.classList.remove("is-loading"),p(),dr(a,"\u2713 Weather set \xB7 "+C+" \xB7 "+x+"\xB0C (edit above if needed)","ok")}).catch(function(){l.classList.remove("is-loading"),p(),dr(a,"\u2717 Could not fetch weather \u2014 set it manually above.","err")})})}function bg(){var o=new Date;return o.setSeconds(0,0),o.setMinutes(o.getMinutes()-o.getTimezoneOffset()),o.toISOString().slice(0,16)}function yg(){var o={title:"Title",date:"Date & time",content:"Content"},l=document.querySelector('form[name="new-entry"]');if(!l)return;var s=Ot("date");s&&!String(s.value).trim()&&(s.value=bg());function a(){l.querySelectorAll(".field-error").forEach(function(c){c.remove()}),l.querySelectorAll(".field-invalid").forEach(function(c){c.classList.remove("field-invalid")})}function f(c,h){c.classList.add("field-invalid");var b=document.createElement("span");b.className="field-error",b.textContent=h,c.parentNode.insertBefore(b,c.nextSibling)}function p(c){var h=l.querySelector(".photos-collapse"),b,y;if(h?(h.open=!0,y=h.querySelector(".photos-collapse__summary"),b=h):(b=document.querySelector(".filepond-root, .form-input-file"),y=b),!y)return b||null;var x=document.createElement("span");return x.className="field-error",x.textContent=c,y.insertAdjacentElement("afterend",x),b||y}l.addEventListener("submit",function(c){a();var h=null;!Xo&&document.querySelectorAll(".filepond--item").length<1&&(h=p("Add at least one photo.")),Object.keys(o).forEach(function(b){var y=Ot(b);y&&!String(y.value).trim()&&(f(y,o[b]+" is required."),h||(h=y))}),h&&(c.preventDefault(),typeof h.focus=="function"&&h.focus(),h.scrollIntoView({behavior:"smooth",block:"center"}))})}var Pl="intotheeast:new-entry-draft";function xg(o){return Array.prototype.slice.call(o.querySelectorAll('[name^="data["]')).filter(function(l){if(l.type==="file")return!1;var s=l.name;return s.indexOf("data[_json")!==0&&s.indexOf("data[photos")!==0})}function Dg(){var o=document.querySelector(".filepond-root, .form-input-file");if(!(!o||!o.parentNode)&&!o.parentNode.querySelector(".photo-reauth-hint")){var l=document.createElement("p");l.className="photo-reauth-hint is-shown",l.textContent="Your text was restored \u2014 photos need re-selecting (they can\u2019t be saved in a draft).",o.parentNode.insertBefore(l,o.nextSibling)}}function wg(){var o=document.querySelector('form[name="new-entry"]');if(!o||Xo)return;if(document.querySelector(".notices.success")){try{localStorage.removeItem(Pl)}catch{}return}function l(){var p={};xg(o).forEach(function(c){c.type==="radio"?c.checked&&(p[c.name]=c.value):p[c.name]=c.value});try{localStorage.setItem(Pl,JSON.stringify(p))}catch{}}var s=null;try{s=localStorage.getItem(Pl)}catch{s=null}if(s){var a=null;try{a=JSON.parse(s)}catch{a=null}if(a){var f=!1;Object.keys(a).forEach(function(p){var c=a[p];if(c!=null&&String(c).trim()&&(f=!0),p!=="data[content]"){var h=o.querySelectorAll('input[type="radio"][name="'+p+'"]');if(h.length){h.forEach(function(y){y.checked=y.value===c});return}var b=o.querySelector('[name="'+p+'"]');b&&b.type!=="file"&&(b.value=c)}}),window.postFormEditor&&a["data[content]"]!=null&&window.postFormEditor.value(a["data[content]"]),f&&Dg()}}o.addEventListener("input",l),o.addEventListener("change",l),window.postFormEditor&&window.postFormEditor.codemirror.on("change",l)}function Cg(){var o=document.querySelector(".post-form-wrap"),l=document.querySelector(".post-form-wrap .notices.success, .post-form-wrap .notices.green");if(!(!o||!l)){var s=document.createElement("div");s.className="post-success";var a=document.createElement("p");a.className="post-success__title",a.textContent="\u2713 Saved to your journal.",s.appendChild(a);var f=document.createElement("div");f.className="post-success__actions";var p=o.getAttribute("data-trip-url");if(p){var c=document.createElement("a");c.className="post-success__view",c.href=p,c.textContent="View your journal \u2192",f.appendChild(c)}var h=document.createElement("a");h.className="post-success__again",h.href=window.location.pathname,h.textContent="Post another",f.appendChild(h),s.appendChild(f),l.parentNode.insertBefore(s,l.nextSibling),["form",".form-action-row","#location-status","#weather-status"].forEach(function(b){var y=o.querySelector(b);y&&(y.style.display="none")}),l.scrollIntoView({behavior:"smooth",block:"start"})}}var Xo=!1;function Ac(o){return new URLSearchParams(window.location.search).get(o)}function hr(o,l){var s=Ot(o);s&&(s.value=l==null?"":String(l))}function zl(o,l){var s=l?"1":"0",a=document.querySelectorAll('[name="data['+o+']"]');Array.prototype.forEach.call(a,function(f){f.checked=String(f.value)===s})}function kg(o){var l=o==null?"":String(o);if(window.postFormEditor&&typeof window.postFormEditor.value=="function")window.postFormEditor.value(l);else{var s=Ot("content");s&&(s.value=l)}}function Fc(o,l){var s=o.querySelectorAll("input, textarea, select, button");Array.prototype.forEach.call(s,function(a){a.type==="file"||a.name&&a.name.indexOf("data[photos")===0||(a.disabled=l)}),window.postFormEditor&&window.postFormEditor.codemirror&&window.postFormEditor.codemirror.setOption("readOnly",l?"nocursor":!1)}function Hl(o,l){o&&(o.tagName==="INPUT"?o.value=l:o.textContent=l)}function Sg(o,l){var s=o.querySelector(".post-edit-error");if(s){s.textContent=l;return}var a=document.createElement("div");a.className="post-edit-error",a.setAttribute("role","alert"),a.textContent=l;var f=o.querySelector("h1");f?f.insertAdjacentElement("afterend",a):o.insertBefore(a,o.firstChild)}var Eg=/\.(jpe?g|png|webp|heic|heif|gif)$/i;function Tc(o){var l=/(?:^|\/)photo-0*(\d+)\./i.exec(o);return l?parseInt(l[1],10):Number.MAX_SAFE_INTEGER}function Ag(o,l){var s=Tc(o),a=Tc(l);return s!==a?s-a:ol?1:0}function Lc(o,l){var s=String(o||"photo"),a=s.lastIndexOf("."),f=(a>0?s.slice(0,a):s).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"photo",p=l?".jpg":a>0?s.slice(a).toLowerCase():".jpg",c=Date.now().toString(36)+Math.random().toString(36).slice(2,6);return f+"-"+c+p}function Fg(o){var l=document.querySelector('form[name="new-entry"]');if(!l||!o)return;var s=o.split("/").filter(Boolean).pop();if(!s)return;var a=document.querySelector(".filepond-root, .form-input-file"),f=a?a.closest(".form-field"):null;f&&(f.style.display="none");var p=l.querySelector(".photos-collapse");p&&(p.style.display="none");var c=document.createElement("div");c.className="photo-editor",c.innerHTML='
Photos

',f&&f.parentNode?f.parentNode.insertBefore(c,f):l.insertBefore(c,l.firstElementChild);var h=c.querySelector(".photo-editor__grid"),b=c.querySelector(".photo-editor__status"),y=c.querySelector(".photo-editor__add"),x=c.querySelector(".photo-editor__input"),C=[],E=null,F=!1,_=0;function L(S,R){b.textContent=S||"",b.className="photo-editor__status gpx-status"+(R?" error":"")}function T(S){F=S,y.disabled=S,Array.prototype.forEach.call(h.querySelectorAll(".photo-editor__del, .photo-editor__confirm-yes, .photo-editor__confirm-no"),function(R){R.disabled=S}),E&&E.option("disabled",S)}function O(S,R,z){return fetch(S,Object.assign({credentials:"include"},R)).then(function(K){if(K.ok||z&&z.indexOf(K.status)!==-1)return K;var ue=new Error("HTTP "+K.status);throw ue.status=K.status,ue})}function N(S,R){var z=S&&S.status;return z===401||z===403?"Your login session expired \u2014 sign in again, then retry.":R}function P(){return fetch("/api/v1/pages"+o+"/media",{credentials:"include",headers:{Accept:"application/json"}}).then(function(S){if(!S.ok)throw new Error("HTTP "+S.status);return S.json()}).then(function(S){return(S&&S.data||[]).filter(function(R){return R&&typeof R.filename=="string"&&Eg.test(R.filename)}).map(function(R){return R.filename}).sort(Ag)})}function I(S){return O("/api/v1/entry/"+encodeURIComponent(s)+"/photos/order",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({order:S})})}function W(S){if(C=(S||[]).slice(),E&&(E.destroy(),E=null),h.innerHTML="",!C.length){h.innerHTML='

No photos yet \u2014 add some.

';return}var R=++_;C.forEach(function(z){var K=document.createElement("div");K.className="photo-editor__cell",K.setAttribute("data-filename",z);var ue=document.createElement("img");ue.className="photo-editor__img",ue.loading="lazy",ue.alt=z,ue.src=o+"/"+encodeURIComponent(z)+"?v="+R;var De=document.createElement("button");De.type="button",De.className="photo-editor__del",De.setAttribute("aria-label","Delete "+z),De.textContent="\u2715",De.addEventListener("click",function(){U(K,z)}),K.appendChild(ue),K.appendChild(De),h.appendChild(K)}),C.length>1&&(E=new Sc(h,{animation:150,draggable:".photo-editor__cell",filter:".photo-editor__confirm",onEnd:be}))}function j(){return Array.prototype.map.call(h.querySelectorAll(".photo-editor__cell"),function(S){return S.getAttribute("data-filename")})}function X(S,R){if(S.length!==R.length)return!1;for(var z=0;zDelete?',S.appendChild(z),S.classList.add("is-confirming"),z.querySelector(".photo-editor__confirm-no").addEventListener("click",function(){S.classList.remove("is-confirming"),z.remove()}),z.querySelector(".photo-editor__confirm-yes").addEventListener("click",function(){z.querySelector(".photo-editor__confirm-yes").disabled=!0,z.querySelector(".photo-editor__confirm-no").disabled=!0,ae(R)})}}function ae(S){var R=C.slice(),z=C.filter(function(K){return K!==S});T(!0),L("Deleting\u2026"),O("/api/v1/pages"+o+"/media/"+encodeURIComponent(S),{method:"DELETE"},[204,404]).then(function(){return(z.length?I(z):Promise.resolve()).then(P).then(function(K){L(""),W(K)},function(){L("Photo deleted, but refreshing the list failed \u2014 reload if it looks off.",!0),W(z)})},function(K){L(N(K,"Couldn\u2019t delete that photo. Try again."),!0),W(R)}).then(function(){T(!1)})}function ne(S){return _c(S).then(function(R){return R?import("./heic-to-CN7JBE7H.js").then(function(z){var K=z.heicTo||z.default&&z.default.heicTo;return K({blob:S,type:"image/jpeg",quality:.85})}).then(function(z){return{blob:z,name:Lc(S.name,!0)}}):{blob:S,name:Lc(S.name,!1)}})}y.addEventListener("click",function(){F||x.click()}),x.addEventListener("change",function(){var S=Array.prototype.slice.call(x.files||[]);x.value="",S.length&&se(S)});function se(S){T(!0);var R=S.length,z=0,K=0,ue=!1,De=C.slice(),ot=Promise.resolve();S.forEach(function(A){ot=ot.then(function(){return z++,L("Uploading "+z+" of "+R+"\u2026"),ne(A).then(function(D){var ee=new FormData;return ee.append("file",D.blob,D.name),O("/api/v1/pages"+o+"/media",{method:"POST",body:ee})}).then(null,function(D){K++,D&&(D.status===401||D.status===403)&&(ue=!0)})})}),ot.then(function(){return L("Finishing\u2026"),P()}).then(function(A){var D=De.filter(function(he){return A.indexOf(he)!==-1}),ee=A.filter(function(he){return De.indexOf(he)===-1}),we=D.concat(ee);return we.length?I(we).catch(function(){return I(we)}).catch(function(){return Promise.all(ee.map(function(he){return O("/api/v1/pages"+o+"/media/"+encodeURIComponent(he),{method:"DELETE"},[204,404]).then(function(){return!0},function(){return!1})})).then(function(he){var $e=new Error("reorder failed");throw $e.rolledBack=!0,$e.rollbackIncomplete=he.indexOf(!1)!==-1,$e})}).then(P):(W([]),null)}).then(function(A){A&&W(A),K?L(ue?"Couldn\u2019t add photos \u2014 your login session expired. Sign in again, then retry.":K+" photo"+(K>1?"s":"")+" couldn\u2019t be added.",!0):L("")}).catch(function(A){var D;return A&&A.rolledBack?D=A.rollbackIncomplete?"Couldn\u2019t finish adding photos and cleanup was incomplete \u2014 reload the page and check your photos.":"Couldn\u2019t finish adding photos \u2014 changes were rolled back. Try again.":D="Couldn\u2019t add photos. Please try again.",L(D,!0),P().then(W,function(){W(De)})}).then(function(){T(!1)})}h.innerHTML='

Loading photos\u2026

',P().then(W).catch(function(){L("Couldn\u2019t load photos.",!0),W([])})}function Tg(){var o=document.querySelector('form[name="new-entry"]'),l=document.querySelector(".post-form-wrap");if(!(!o||!l)){var s=Ac("edit");if(s){Xo=!0;var a=l.querySelector("h1");a&&(a.textContent="Edit entry");var f=o.querySelector('button[type="submit"], input[type="submit"]'),p=f?f.tagName==="INPUT"?f.value:f.textContent:"Save changes";Fc(o,!0),Hl(f,"Loading entry\u2026");var c=Ac("return")||l.getAttribute("data-trip-url")||"";o.setAttribute("action","/post?edit="+encodeURIComponent(s)+(c?"&return="+encodeURIComponent(c):"")),fetch("/api/v1/pages"+s,{credentials:"include",headers:{Accept:"application/json"}}).then(function(h){if(!h.ok){var b=new Error("HTTP "+h.status);throw b.status=h.status,b}return h.json()}).then(function(h){var b=h&&h.data||{},y=b.header||{};hr("title",y.title!=null?y.title:b.title),hr("date",y.date?String(y.date).replace(" ","T"):""),kg(b.content),hr("lat",y.lat),hr("lng",y.lng),hr("location_city",y.location_city),hr("location_country",y.location_country),hr("weather_desc",y.weather_desc),hr("weather_temp_c",y.weather_temp_c),hr("transport_mode",y.transport_mode),zl("featured",y.featured),zl("force_connect",y.force_connect),zl("published",y.published!==void 0?y.published:b.published);var x=Ot("edit_path");x&&(x.value=s+"/entry.md"),Fc(o,!1),Hl(f,"Save changes");var C=o.querySelector(".more-options");C&&(C.open=!0),Fg(s)}).catch(function(h){var b=h&&h.status===404?"This entry no longer exists \u2014 it may have been deleted. Head back to the journal.":"Sorry \u2014 this entry couldn\u2019t be loaded for editing. Check your connection and try again.";Sg(l,b),Hl(f,p)})}}}function Mc(){window.postFormEditor=fg(),Cg(),Tg(),wg(),pg(),gg(),mg(),yg()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Mc):Mc(); /*! Bundled license information: sortablejs/modular/sortable.esm.js: diff --git a/themes/intotheeast/js/src/post-form.js b/themes/intotheeast/js/src/post-form.js index a3b2540..725b245 100644 --- a/themes/intotheeast/js/src/post-form.js +++ b/themes/intotheeast/js/src/post-form.js @@ -326,12 +326,20 @@ function initDisclosure() { wrappers[0].parentNode.insertBefore(details, wrappers[0]); wrappers.forEach(function (w) { details.appendChild(w); }); + // A toggle only counts as an "advanced value" worth auto-expanding for when + // it DEVIATES from its blueprint default. `published` defaults ON, so a plain + // create form would otherwise trip this on every load and render More options + // expanded. `published` is the sole default-ON toggle here, so its notable + // state is OFF (a deliberate draft); the others (force_connect/featured) + // default OFF, so theirs is ON. (Edit mode force-opens the panel elsewhere — + // see initEditMode — so this only governs the create / draft-restore case.) var hasValue = wrappers.some(function (w) { var text = w.querySelector('input[type="text"]'); if (text && text.value.trim()) return true; var toggle = w.querySelector('input[type="radio"]:checked'); - if (toggle && toggle.value && toggle.value !== '0') return true; - return false; + if (!toggle || !toggle.value) return false; + var isPublished = /\[published\]$/.test(toggle.name || ''); + return isPublished ? toggle.value === '0' : toggle.value !== '0'; }); if (hasValue) details.open = true; }