Files
2026-11-25 21:50:39 +03:30

2 lines
5.1 KiB
JavaScript

(()=>{var m=()=>({isSticky:!1,width:0,resizeObserver:null,boundUpdateWidth:null,init(){let n=this.$el.parentElement;n&&(this.updateWidth(),this.resizeObserver=new ResizeObserver(()=>this.updateWidth()),this.resizeObserver.observe(n),this.boundUpdateWidth=this.updateWidth.bind(this),window.addEventListener("resize",this.boundUpdateWidth))},enableSticky(){this.isSticky=this.$el.getBoundingClientRect().top>0},disableSticky(){this.isSticky=!1},updateWidth(){let n=this.$el.parentElement;if(!n)return;let e=getComputedStyle(this.$root.querySelector(".fi-ac"));this.width=n.offsetWidth+parseInt(e.marginInlineStart,10)*-1+parseInt(e.marginInlineEnd,10)*-1},destroy(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.boundUpdateWidth&&(window.removeEventListener("resize",this.boundUpdateWidth),this.boundUpdateWidth=null)}});var f=function(n,e,r){let t=n;if(e.startsWith("/")&&(r=!0,e=e.slice(1)),r)return e;for(;e.startsWith("../");)t=t.includes(".")?t.slice(0,t.lastIndexOf(".")):null,e=e.slice(3);return["",null,void 0].includes(t)?e:["",null,void 0].includes(e)?t:`${t}.${e}`},p=new Set(["$el","$refs","$store","$watch","$dispatch","$nextTick","$root","$data","$id","$event","$focus","$persist","$tooltip","$js","$anchor","$queryString","$wire","$get","$set","$state","$statePath","$callSchemaComponentMethod","$schemaComponentMethods"]);function h({key:n,exposedMethods:e=[],path:r,containerPath:t}){let i=this.$wire,o=(s,a={},d={})=>Livewire.fireAction(i.__instance,"callSchemaComponentMethod",[n,s,a],d),l=Object.fromEntries(e.filter(s=>!p.has(`$${s}`)).map(s=>[`$${s}`,(a={})=>o(s,a)]));return{...l,$schemaComponentMethods:l,$callSchemaComponentMethod:o,$statePath:r,$get:(s,a)=>i.$get(f(t,s,a)),$set:(s,a,d,c=!1)=>i.$set(f(t,s,d),a,c),get $state(){return i.$get(r)}}}var $=n=>{let e=Alpine.findClosest(n,r=>r.__livewire);if(!e)throw"Could not find Livewire component in DOM tree.";return e.__livewire},u=!1;document.addEventListener("invalid",n=>{let e=n.target;if(!e.closest("[data-field-wrapper]")||e.offsetParent!==null&&getComputedStyle(e).visibility!=="hidden"||(n.preventDefault(),u)||Array.from(e.form?.elements??[]).some(t=>t.willValidate&&!t.validity.valid&&t.offsetParent!==null&&getComputedStyle(t).visibility!=="hidden"))return;u=!0;let r=e;for(;r;)r.dispatchEvent(new CustomEvent("expand")),r=r.parentNode;requestAnimationFrame(()=>requestAnimationFrame(()=>{e.form?.reportValidity(),setTimeout(()=>u=!1,100)}))},!0);document.addEventListener("alpine:init",()=>{window.Alpine.data("filamentSchema",({livewireId:n,schemaKey:e,isLazyLoaded:r=!1})=>({intersectionObserver:null,stopInterceptingSchemaRequest:null,isLoadingSchema:!1,hasSchemaLoadingFailed:!1,isDestroyed:!1,init(){r&&(this.intersectionObserver=new IntersectionObserver(async t=>{if(!(!t[0]?.isIntersecting||this.isLoadingSchema||this.isDestroyed)){this.isLoadingSchema=!0,this.intersectionObserver.disconnect(),this.stopInterceptingSchemaRequest=Livewire.interceptRequest(({request:i,onError:o})=>{let{components:l}=i.payload;l.some(s=>JSON.parse(s.snapshot).memo.id===n&&s.calls.some(a=>a.method==="loadLazySchema"&&a.params[0]===e))&&o(({response:s,preventDefault:a})=>{s.status!==419&&l.every(d=>!Object.keys(d.updates).length&&d.calls.length&&d.calls.every(c=>c.method==="loadLazySchema"))&&a()})});try{await this.$wire.loadLazySchema(e)}catch{this.isDestroyed||(this.hasSchemaLoadingFailed=!0)}finally{this.isDestroyed||(this.isLoadingSchema=!1),this.stopInterceptingSchemaRequest?.(),this.stopInterceptingSchemaRequest=null}}}),this.intersectionObserver.observe(this.$el))},handleFormValidationError(t){t.detail.livewireId===n&&this.$nextTick(()=>{let i=this.$el.querySelector("[data-validation-error]");if(!i)return;let o=i;for(;o;)o.dispatchEvent(new CustomEvent("expand")),o=o.parentNode;setTimeout(()=>{i.isConnected&&i.closest("[data-field-wrapper]")?.scrollIntoView({behavior:"smooth",block:"start",inline:"start"})},200)})},handleClientSideStateReset(t){t.detail.livewireId!==n||t.detail.schemaKey!==e||this.$nextTick(()=>{let i=this.$el.querySelectorAll("[autofocus]");for(let o of i)if(o.offsetParent!==null&&(o.focus(),document.activeElement===o))break})},isStateChanged(t,i){if(t===void 0)return!1;try{return JSON.stringify(t)!==JSON.stringify(i)}catch{return t!==i}},destroy(){this.isDestroyed=!0,this.intersectionObserver?.disconnect(),this.stopInterceptingSchemaRequest?.(),this.stopInterceptingSchemaRequest=null}})),window.Alpine.data("filamentSchemaComponent",h),window.Alpine.data("filamentActionsSchemaComponent",m),Livewire.interceptMessage(({message:n,onSuccess:e})=>{e(({payload:r})=>{let t=n.component;t.el.isConnected&&r.effects?.dispatches?.forEach(i=>{if(!i.params?.awaitSchemaComponent)return;let o=Array.from(n.component.el.querySelectorAll(`[wire\\:partial="schema-component::${i.params.awaitSchemaComponent}"]`)).filter(a=>$(a)===n.component);if(o.length===1)return;if(o.length>1)throw`Multiple schema components found with key [${i.params.awaitSchemaComponent}].`;let l=`schema-component-${t.id}-${i.params.awaitSchemaComponent}-loaded`,s=()=>{window.dispatchEvent(new CustomEvent(i.name,{detail:i.params}))};window.addEventListener(l,s,{once:!0}),t.addCleanup(()=>window.removeEventListener(l,s))})})})});})();