1function parseAs(t,e){switch(e){case"number":return Number(t);case"date":return Date.parse(t);default:return t}}function defaultComparitor(t,e){return t<e?-1:t>e?1:0}function comparatorFor(t){return t&&"number"!==t?(new Intl.Collator).compare:defaultComparitor}import{Controller}from"@hotwired/stimulus";import AnimateLayout from"utilities/animate_layout";export default class extends Controller{static targets=["item"];static values={by:{type:String,default:"order"},byType:{type:String,default:"number"},fallback:{type:String,default:"createdAt"},fallbackType:{type:String,default:"date"},moveItemParent:{type:Boolean,default:!1},animate:{type:Boolean,default:!0},limit:{type:Number,default:0}};initialize(){this.byComparator=comparatorFor(this.byTypeValue),this.fallbackComparator=comparatorFor(this.fallbackTypeValue),this.animateValue&&(this.layoutAnimator=new AnimateLayout(this.element,{zPositionProperty:"animationZLayer",instantFirstRun:!0})),this.observer=new MutationObserver((t=>{t.forEach((t=>{t.oldValue!==t.target.getAttribute(t.attributeName)&&this._reorderItem(t.target)}))}))}connect(){this.observer.observe(this.element,{subtree:!0,attributeFilter:[`data-${this.byValue}`,`data-${this.fallbackValue}`],attributeOldValue:!0})}disconnect(){this.observer.disconnect()}itemTargetConnected(t){this._reorderItem(t)}limitValueChanged(){this._applyLimit()}_applyLimit(){if(!this.limitValue)return;let t=!1;this.itemTargets.forEach(((e,a)=>{const i=this._movableFor(e),r=a>=this.limitValue;i.classList.contains("hidden")!==r&&(i.classList.toggle("hidden",r),t=!0)})),t&&this.dispatch("limit")}_movableFor(t){return this.moveItemParentValue?t.closest("[data-ordered-list-move-item-parent]"):t}_reorderItem(t){this.layoutAnimator?.queue();const e=parseAs(t.dataset[this.byValue],this.byTypeValue),a=parseAs(t.dataset[this.fallbackValue],this.fallbackTypeValue);let i=this.itemTargets.find((i=>{if(t===i)return!1;const r=parseAs(i.dataset[this.byValue],this.byTypeValue),l=this.byComparator(e,r);if(1===l)return i;if(0===l){const t=parseAs(i.dataset[this.fallbackValue],this.fallbackTypeValue);if(1===this.fallbackComparator(a,t))return i}return!1}));this.moveItemParentValue&&(t=this._movableFor(t),i=i&&this._movableFor(i)),i?t.nextElementSibling!==i&&this.element.insertBefore(t,i):(t.parentElement!==this.element||t.nextElementSibling)&&this.element.appendChild(t),this._applyLimit()}}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.