PageSourceSearch

https://www.lookah.com/assets/order_change_address.Dc5BgHzu.js

js lookah.com collected 2026-09-24 20:10:14 UTC 3,038 bytes, 1 lines download raw bytes

1import{s as t,r as i,F as s}from"./validation.D7JpMsNh.js";import{S as r,E as e}from"./index.CNNIaLv5.js";import"./vendor-utils.D-niUx-H.js";import"./vendor.85qOW4G2.js";import"./vendor-alpine.C-A-yvFA.js";function a(a={}){const n="#lookah-change-address-form";class FormState{constructor(){this.isSubmitting=!1,this.cleanupFunctions=[]}addCleanup(t){this.cleanupFunctions.push(t)}cleanup(){this.cleanupFunctions.forEach((t=>t())),this.cleanupFunctions=[]}}return{state:r.IDLE,isFormVisible:!1,error:null,transitions:{enter:{enter:"transition ease-out duration-200",enterStart:"opacity-0 translate-y-1",enterEnd:"opacity-100 translate-y-0"},leave:{leave:"transition ease-in duration-150",leaveStart:"opacity-100 translate-y-0",leaveEnd:"opacity-0 translate-y-1"}},validator:null,form:null,get isLoading(){return this.state===r.LOADING},get hasError(){return this.state===r.ERROR},get formClasses(){return{"form-loading":this.isLoading,"form-error":this.hasError}},get isFormValid(){var t;return(null==(t=this.validator)?void 0:t.isFormValid().isValid)||!1},handlers:null,init(){this.form=document.querySelector(n),this.form&&(this._initForm(),this._setupEventHandlers())},_setupEventHandlers(){if(this.form)try{this.handlers=t(this.form,(t=>{this.state=t}))}catch(i){}},_cleanupEventHandlers(){var t;try{this.handlers&&(i(this.handlers),this.handlers=null),null==(t=this.formState)||t.cleanup()}catch(s){}},showForm(){this.isFormVisible=!0,this.state=r.IDLE,this.error=null,this._initValidation()},hideForm(){this._hideForm()},_initForm(){this.form&&(this.formState=new FormState,this.validator=new s(this.form),window.addEventListener(e.CHECKOUT.VALIDATION.FORM,(t=>{const{isValid:i,errors:s}=t.detail;!i&&(null==s?void 0:s.length)>0&&(this.error=s[0].message,this.state=r.ERROR)})))},_initValidation(){if(this.form)try{this.validator=new s(this.form),window.addEventListener(e.CHECKOUT.VALIDATION.FORM,(t=>{const{isValid:i,errors:s}=t.detail;!i&&(null==s?void 0:s.length)>0&&(this.error=s[0].message)}))}catch(t){this.validator=null}},_hideForm(){var t;this.isFormVisible=!1,this.state=r.IDLE,this.error=null,null==(t=this.validator)||t.reset()},destroy(){var t,i;null==(t=this._cleanup)||t.call(this),this._cleanupEventHandlers(),null==(i=this.validator)||i.destroy()},async handleSubmit(t){if(null==t||t.preventDefault(),!this.formState.isSubmitting)try{if(this.formState.isSubmitting=!0,this.state=r.LOADING,this.validator||this._initValidation(),!this.validator)throw new Error("验证器初始化失败");if(!(await this.validator.validateAll({focusOnError:!0,silent:!1})))return void(this.state=r.ERROR);this.form.submit(),this._hideForm(),window.dispatchEvent(new CustomEvent(e.ADDRESS.UPDATED,{detail:{type:"shipping"}}))}catch(i){this.state=r.ERROR}finally{this.formState.isSubmitting=!1,this.state=r.IDLE}},_bindFormEvents(){this.form&&(this.form.addEventListener("submit",(t=>this.handleSubmit(t))),this.formState.addCleanup((()=>{this.form.removeEventListener("submit",(t=>this.handleSubmit(t)))})))}}}export{a as default};

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.