1import{a as f,C as u}from"./chunk-control_connector_constants.CepOMss.js";import{e as i,n as y}from"./chunk-vendor-lit.NvY0u02.js";import{ap as g,aE as _}from"./storefrontApp.CsApItsi.min.js";import{S as v}from"./chunk-storefront_base_lit_element.lX23Jvc.js";import{C as O}from"./chunk-context_consumer_controller.DQ84A7A.js";import{C as S}from"./chunk-context_provider_controller.CCbkLM7.js";class d extends g{}class T{static getFormControls({$controlConnector:e,formControlsSelectors:n}){const s=Object.entries(n);for(let l=0;l<s.length;++l){const[a,c]=s[l],m=[...e.querySelectorAll(c)];if(!m?.length)continue;const h=m.filter(C=>C.name&&C.id);if(!h.length)continue;const p=a===_.select&&h[0].multiple?_.multiSelect:a;if(!p)throw new d(`Form control type: ${p} is not defined`);return{$controls:h,type:p}}return{$controls:[],type:""}}}const b="form-controller",P="form-service",N={min:"min",max:"max",length:"length",required:"required",requiredInGroup:"requiredInGroup",email:"email",moreThan:"moreThan",lessThan:"lessThan",positive:"positive",streetWithNumber:"streetWithNumber"};var R=Object.defineProperty,A=Object.getOwnPropertyDescriptor,r=(t,e,n,s)=>{for(var l=s>1?void 0:s?A(e,n):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(l=(s?c(e,n,l):c(l))||l);return s&&l&&R(e,n,l),l};let o=class extends v{constructor(){super(...arguments),this.required=!1,this.validationMode=f.focusout,this._contextConsumer=new O(this),this._controlsPropertiesAccessors=[],this._context=new S(this),this._$controls=[],this.watchChildrenConnected=!0,this._isReinitializing=!1}_initializeConnector(){const{$controls:t,type:e}=T.getFormControls({$controlConnector:this,formControlsSelectors:this._formController.formService.getFormControlsSelectors()});if(this._controlType=e,this._$controls=t,!!t?.length){if(this._controlSelector=this._formController.formService.getFormControlsSelectors()[e],!this._controlSelector)throw new d(`Missing control selector for control ${e}`);this._initFormControls()}}async allChildrenConnected(){try{if(super.allChildrenConnected(),this._formController=await this._contextConsumer.consumeAsync(b),!this._formController)return;this._initializeConnector(),this._context.provide(u,this._$controls[0].name)}catch{}}_initFormControls(){this._cleanUp(),this._$controls.forEach(t=>{t.dataset.validationNameLabel=this._getValidationNameLabel(t.id),this._formController.htmlControlRegistrationService.registerControl(t,this._controlType);const e=this._formController.controlPropertiesManager.getPropertiesAccessorInstance({$control:t,controlSelector:this._controlSelector,validationMode:this.validationMode});if(!e)return;this._controlsPropertiesAccessors.push(e);const n=this._formController.controlValidatorsProcessor.getValidatorsRecordFormControlAttributes(this);n&&this._formController.controlValidatorsProcessor.registerValidators({controlSelector:this._controlSelector,$control:t,validators:n,message:this.errorMessage})})}_cleanUp(){this._controlsPropertiesAccessors.forEach(t=>{t.dispose()}),this._$controls.forEach(t=>{this._formController.formService.removeFormControl(t.id)})}_getValidationNameLabel(t){if(this.validationNameLabel)return this.validationNameLabel;const n=[...document.querySelectorAll(`label[for="${t}"]`)].filter(s=>s.textContent&&s.textContent.length>0)[0];return this._getTextWithOmissions(n)}_getTextWithOmissions(t){if(!t)return"";const e=t.cloneNode(!0);return e.querySelectorAll('[aria-hidden="true"]').forEach(s=>s.remove()),e.innerText||""}updated(t){Object.values(N).some(n=>t.has(n))&&this._formController&&!this._isReinitializing&&this._recollectAndReinit()}_recollectAndReinit(){if(!(!this._formController||this._isReinitializing)){this._isReinitializing=!0;try{this._initializeConnector()}finally{this._isReinitializing=!1}}}disconnectedCallback(){super.disconnectedCallback(),this._cleanUp()}};r([i({type:String})],o.prototype,"min",2);r([i({type:String})],o.prototype,"max",2);r([i({type:Number})],o.prototype,"length",2);r([i({type:Number})],o.prototype,"moreThan",2);r([i({type:Number})],o.prototype,"lessThan",2);r([i({type:Boolean})],o.prototype,"email",2);r([i({type:Boolean})],o.prototype,"required",2);r([i({type:Boolean})],o.prototype,"requiredInGroup",2);r([i({type:Boolean})],o.prototype,"streetWithNumber",2);r([i({type:Boolean})],o.prototype,"positive",2);r([i({type:String})],o.prototype,"errorMessage",2);r([i({type:String})],o.prototype,"validationMode",2);r([i({type:String,attribute:"validation-name-label"})],o.prototype,"validationNameLabel",2);o=r([y("control-connector")],o);export{o as C,P as F,d as a,b,N as c};
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.