@opencitylabs/formio-custom-components 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,10 +64,10 @@ if(data.calendarId && data.api_url){
64
64
  data.overlaps_validation = -1; document.querySelector("input[name^='data[overlaps_validation]']").value = -1;
65
65
  }
66
66
  );
67
- }`,validateOn:`change`,validate:{customMessage:`Vi sono sovrapposizioni negli orari di apertura`,custom:`if (document.querySelector("input[name^='data[overlaps_validation]']").value === '0') {valid=true} else {valid = 'Sovrapposizione';}`},key:`overlaps_validation`,attributes:{readonly:`true`},required:!0,type:`number`,input:!0,weight:1},{label:`Precisione minima (minuti)`,defaultValue:1,required:!0,inputFormat:`plain`,key:`range_step`,type:`number`,input:!0,weight:1}];function Ge(...e){return i.Components.baseEditForm([{key:`display`,components:K}],...e)}function Ke({day:e,slot:t,i18next:n}){return(0,r.jsx)(`li`,{className:`it-list-item`,children:(0,r.jsx)(`div`,{className:`list-item`,children:(0,r.jsx)(`div`,{className:`it-right-zone`,children:(0,r.jsxs)(`span`,{className:`text pl-4`,children:[(0,r.jsx)(`b`,{children:e}),` `,n.t(`alle`),` `,n.t(`ore`),` `,(0,r.jsx)(`b`,{children:t})]})})})})}var q=t.Formio.Components.components.field,qe=({component:e,current:t,onChange:n,i18next:i})=>{let[f,p]=(0,a.useState)(),[m,h]=(0,a.useState)([]),[ee,g]=(0,a.useState)([]),[_,v]=(0,a.useState)(!1),[y,b]=(0,a.useState)(null),[x,S]=(0,a.useState)(null),[C,w]=(0,a.useState)(null),[T,E]=(0,a.useState)(null),[D,O]=(0,a.useState)({}),[k,A]=(0,a.useState)(null),[j,te]=(0,a.useState)(!1),[N,P]=(0,a.useState)([]),[F,I]=(0,a.useState)(!1),L=(0,a.useRef)(),R=e.calendarId;c.default.locale(i.language),d.default.locale(i.language);let ne=e=>{let t=(0,c.default)(e).format(`YYYY-MM-DD`);fetch(ae(t)).then(e=>e.json()).then(t=>{let n=ie(e||new Date),r=t.filter(e=>e.available==1);r.length===0&&he();let i=[];n.forEach(e=>{t.some(t=>t.date===e&&t.available==1)?i.push({available:!0,date:e}):i.push({available:!1,date:e})}),h(i.map(e=>{if(e.available===!1)return(0,c.default)(e.date,`YYYY-MM-DD`).toDate()})),re(r.length?r[0].date:e)}).catch(e=>console.error(e))},re=e=>{E(null),w(null),g([]);let t=(0,c.default)(e).format(`YYYY-MM-DD`);fetch(oe(t)).then(e=>e.json()).then(t=>{let n=t.filter(e=>e.availability==1);O(n[0]),n.length>0?(g(t),v(!1),w((0,c.default)(e).format(`L`)),p((0,c.default)(e,`YYYY-MM-DD`).toDate())):(t.length>0&&p((0,c.default)(t[0].date,`YYYY-MM-DD`).toDate()),g([]),he())})},z=()=>{if(R!==``&&R!=null)if(!t.dataValue)ne(new Date);else if(e.multiple&&Array.isArray(t.dataValue)){if(t.dataValue.length>0){A(t.dataValue);let e=[];t.dataValue.map(t=>{e.push({...t,date:(0,c.default)(t.date,`YYYY-MM-DD`).format(`DD-MM-YYYY`)})}),P(e)}}else if(!e.multiple&&typeof t.dataValue==`object`){let e={date:t.dataValue.date,slot:t.dataValue.slot};P([{...t.dataValue,date:(0,c.default)(t.dataValue.date,`YYYY-MM-DD`).format(`DD-MM-YYYY`)}]),A(e)}else{let r=t.dataValue.replace(`)`,``).replace(` (`,` @ `).replace(/\//g,`-`).split(` @ `),i=r[2].split(`#`),a={date:(0,c.default)(r[0],`DD-MM-YYYY`).format(`YYYY-MM-DD`),slot:r[1]};e.multiple?(n([{date:r[0],slot:r[1],calendar_id:i[0],meeting_id:i[1],opening_hour_id:i.length===3?i[2]:``}]),P([{date:r[0],slot:r[1],calendar_id:i[0],meeting_id:i[1],opening_hour_id:i.length===3?i[2]:``}])):(n({date:r[0],slot:r[1],calendar_id:i[0],meeting_id:i[1],opening_hour_id:i.length===3?i[2]:``}),P([{date:r[0],slot:r[1],calendar_id:i[0],meeting_id:i[1],opening_hour_id:i.length===3?i[2]:``}])),A(a)}};(0,a.useEffect)(()=>{window.FormioInstance?.formReady.then(()=>{setTimeout(()=>{z()},1e3)})},[]);let ie=e=>{let t=(0,c.default)(e,`YYYY-MM`).daysInMonth(),n=[];for(;t;){let r=(0,c.default)(e).date(t);n.push(r.format(`YYYY-MM-DD`)),t--}return n},ae=(t,n=!1)=>{let r=e.calendarId,i=e.select_opening_hours,a=e.select_opening_hours?e.opening_hours:[];window.location.pathname.split(`/`);let o=`${M()}/api/calendars/${r}/availabilities`,s=[`from_time=${(0,c.default)(t).startOf(`month`).format(`YYYY-MM-DD`)}`,`to_time=${(0,c.default)(t).endOf(`month`).format(`YYYY-MM-DD`)}`];return n&&s.push(`available=${n}`),i&&a&&s.push(`opening_hours=${a.join()}`),`${o}?${s.join(`&`)}`},oe=(t,n=!1)=>{let r=e.calendarId,i=e.select_opening_hours,a=e.select_opening_hours?e.opening_hours:[];window.location.pathname.split(`/`);let o=(0,c.default)(t).format(`YYYY-MM-DD`),s=`${M()}/api/calendars/${r}/availabilities/${o}`,l=[];return n&&l.push(`available=${n}`),i&&a&&l.push(`opening_hours=${a.join()}`),l&&(s=`${s}?${l.join(`&`)}`),s},se=e=>{ne(e)},ce=e=>{setTimeout(()=>{te(!j)},1e3),re(e)},le=e=>{E(null),setTimeout(()=>{e&&(S(e.target.dataset),E(e.target.id))},300)},ue=t=>{b(null);let n=`${M()}/it/meetings/new-draft`,r={date:x?.date?(0,c.default)(x?.date).format(`DD-MM-YYYY`):(0,c.default)(t.target.dataset.date).format(`DD-MM-YYYY`),slot:x?.value_start&&x?.value_end?x.value_start+`-`+x.value_end:t.target.dataset.slots,calendar:e.calendarId,opening_hour:x?.opening_hour?x?.opening_hour:t.target.dataset.opening_hour,meeting:y?y.id:``,first_available_date:D.date,first_available_start_time:D.start_time,first_available_end_time:D.end_time,first_availability_updated_at:(0,c.default)().format()};fetch(n,{method:`POST`,body:JSON.stringify(r),headers:{"Content-Type":`application/json; charset=utf-8`},strictErrors:!0}).then(e=>{if(!e.ok)throw Error(i.t(`Intervallo selezionato non disponibile!`));return e.json()}).then(e=>{b(e);let t={date:r.date,slot:r.slot,calendar_id:r.calendar[0],opening_hour_id:r.opening_hour||r.opening_hour_id,meeting_id:e.id};P([...N,t])}).catch(e=>{console.log(e),u.default.fire({title:``,html:`<p>`+e+`</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1})})},de=()=>{x&&(ue(),te(!j))},fe=()=>(0,r.jsx)(`span`,{children:i.t(`Tempo prenotazione scaduto!`)}),pe=({minutes:e,seconds:t,completed:n})=>n?(0,r.jsx)(fe,{}):(0,r.jsx)(`div`,{children:(0,r.jsxs)(`div`,{children:[` `,(0,r.jsxs)(`span`,{children:[` `,(0,r.jsxs)(`i`,{children:[i.t(`Per confermare la prenotazione che ti abbiamo riservato procedi con l’invio di questa pratica e con il pagamento (se richiesto) di quanto previsto entro`),`:`]}),` `,(0,r.jsxs)(`b`,{children:[e,` `,i.t(`minuti`),` `,t,` `,i.t(`secondi`)]})]})]})}),me=t=>{if(t===null||t===``)n(``);else if(Array.isArray(t)&&t.length>0){let t=[];N.map(e=>{t.push({date:(0,c.default)(e.date,`DD-MM-YYYY`).format(`YYYY-MM-DD`),slot:e.slot,calendar_id:e.calendar_id||e.calendar[0],meeting_id:e.meeting_id,opening_hour_id:e.opening_hour||e.opening_hour_id})}),e.multiple?n(t):n(t[0])}else n(``)},he=()=>{v(!0),b(null),w(null),me(null)},B=()=>{if(i.language===`it`)return Fe;if(i.language===`en`)return Ee;if(i.language===`de`)return be};(0,a.useEffect)(()=>{me(N)},[N]),(0,a.useEffect)(()=>{document.querySelector(`.formio-read-only`)&&F===!1?(I(!0),setTimeout(()=>{z()},1e3)):(I(!1),setTimeout(()=>{z()},1e3))},[]);let ge=(e,t)=>{let n=`${M()}/api/meetings/${t.meeting_id}`;fetch(n,{method:`DELETE`,headers:{"Content-Type":`application/json; charset=utf-8`,Authorization:`Bearer ${U(`auth-token`)}`},strictErrors:!0}).then(t=>{t&&t.status>400?u.default.fire({title:``,html:`<p>${i.t(`Ci sono stati degli errori durante la cancellazione dello slot`)}</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1}):(P([...N.slice(0,e),...N.slice(e+1)]),ne(new Date))})};return(0,r.jsxs)(r.Fragment,{children:[F&&k?(0,r.jsxs)(`div`,{className:`my-5 mx-2 d-print-block d-preview-calendar d-preview-calendar-none`,children:[(0,r.jsxs)(`b`,{children:[Array.isArray(k)&&k.length>1?i.t(`Giorni selezionati per la prenotazione`):i.t(`Giorno selezionato per la prenotazione`),`:`]}),(0,r.jsx)(`div`,{className:`mb-5`,children:(0,r.jsx)(`div`,{className:`it-list-wrapper`,children:(0,r.jsx)(`ul`,{className:`it-list`,children:Array.isArray(k)?k.map(e=>(0,r.jsx)(Ke,{day:(0,c.default)(e.date,`DD-MM-YYYY`).format(`DD/MM/YYYY`),i18next:i,slot:e.slot})):(0,r.jsx)(Ke,{day:(0,d.default)(k.date).format(`DD/MM/YYYY`),i18next:i,slot:k.slot})})})})]}):(0,r.jsx)(`div`,{className:`slot-calendar `,children:(0,r.jsxs)(`div`,{className:`row`,children:[e.multiple?(0,r.jsx)(`div`,{className:`col-12 d-print-none d-preview-calendar-none`,children:(0,r.jsxs)(`div`,{className:`m-2`,children:[(0,r.jsx)(`h6`,{children:i.t(e.label)}),(0,r.jsx)(o.DayPicker,{mode:`single`,selected:f,locale:B(),disabled:m,onMonthChange:se,onDayClick:ce})]})}):N.length===1?null:(0,r.jsx)(`div`,{className:`col-12 d-print-none d-preview-calendar-none`,children:(0,r.jsxs)(`div`,{className:`m-2`,children:[(0,r.jsx)(`h6`,{children:i.t(e.label)}),(0,r.jsx)(o.DayPicker,{mode:`single`,selected:f,locale:B(),disabled:m,onMonthChange:se,onDayClick:ce})]})}),(0,r.jsx)(`div`,{className:`col-12`,children:N.length?(0,r.jsx)(`div`,{className:`row m-2`,children:(0,r.jsxs)(`div`,{className:`col-12 mb-4`,children:[(0,r.jsxs)(`b`,{children:[N.length>1?i.t(`Giorni selezionati per la prenotazione`):i.t(`Giorno selezionato per la prenotazione`),`:`,` `]}),(0,r.jsx)(`div`,{className:`mb-5`,children:(0,r.jsx)(`div`,{className:`it-list-wrapper`,children:(0,r.jsx)(`ul`,{className:`it-list`,children:N.map((e,t)=>(0,r.jsx)(`li`,{children:(0,r.jsx)(`div`,{className:`list-item`,children:(0,r.jsxs)(`div`,{className:`it-right-zone`,children:[(0,r.jsxs)(`span`,{className:`text pl-4`,children:[e.date,` `,x||e.slot?`${i.t(`alle`)} ${e.slot}`:``]}),(0,r.jsx)(l.Icon,{icon:`it-delete`,onClick:()=>ge(t,e),role:`button`})]})})},`li`+t))})})}),y?(0,r.jsx)(l.Alert,{color:`info`,defaultValue:`string`,className:`d-print-none d-preview-calendar-none`,children:(0,r.jsx)(s.default,{date:y.expiration_time,renderer:pe})}):null]})}):null})]})}),(0,r.jsxs)(l.Modal,{isOpen:j,toggle:()=>te(!j),labelledBy:`daySelected`,size:`lg`,centered:!0,container:G(),children:[(0,r.jsx)(l.ModalHeader,{toggle:()=>te(!j),id:`daySelected`,children:i.t(`Seleziona una fascia oraria`)}),(0,r.jsx)(l.ModalBody,{children:(0,r.jsxs)(`div`,{className:`row`,children:[N.length>=1?(0,r.jsxs)(`div`,{children:[C&&!_?(0,r.jsxs)(`h6`,{children:[i.t(`Orari disponibili del`),` `,(0,d.default)(C).format(`DD/MM/YYYY`)]}):null,(0,r.jsxs)(`div`,{className:`calendar-last-selection col-12 pt-2 mb-5`,children:[(0,r.jsx)(`small`,{className:`pl-2 mb-2 d-flex px-2`,children:(0,r.jsxs)(`b`,{children:[(0,r.jsx)(l.Icon,{icon:`it-clock`,className:`mr-1`,size:`sm`}),` `,i.t(`Ultimo orario selezionato`)]})}),(0,r.jsx)(`div`,{className:`col-6 px-2`,children:(0,r.jsx)(`button`,{type:`button`,id:`slot-last-selection`,onClick:le,tabIndex:`1`,className:T===`slot-last-selection`?`active btn btn-slot p-0`:`btn btn-slot p-0`,"data-date":(0,c.default)(C,`DD/MM/YYYY`).format(`YYYY-MM-DD`),"data-slots":N[N.length-1].slot,"data-opening_hour":N[N.length-1].opening_hour_id,"data-start":N[N.length-1].slot.split(`-`)[0],"data-end":N[N.length-1].slot.split(`-`)[1],"data-value_start":N[N.length-1].slot.split(`-`)[0],"data-value_end":N[N.length-1].slot.split(`-`)[1],disabled:_,children:N[N.length-1].slot})})]})]}):null,(0,r.jsx)(`div`,{children:C&&N.length>=1?(0,r.jsx)(`h6`,{children:i.t(`Seleziona altri orari`)}):_?null:(0,r.jsxs)(`h6`,{children:[i.t(`Orari disponibili del`),` `,(0,d.default)(C).format(`DD/MM/YYYY`)]})}),ee.map((e,t)=>(0,r.jsx)(`div`,{className:`col-6`,children:(0,r.jsxs)(`button`,{type:`button`,id:`slot-`+t,onClick:le,ref:L,className:T===`slot-`+t?`active btn btn-slot p-0`:`btn btn-slot p-0`,tabIndex:`1`,"data-date":e.date,"data-start":e.start_time,"data-end":e.end_time,"data-value_start":e.start_time,"data-value_end":e.end_time,"data-slots":e.start_time+`-`+e.end_time,"data-opening_hour":e.opening_hour,"data-min_duration":e.min_duration,disabled:e.slots_available==0,children:[e.start_time,` - `,e.end_time]})},`slot-`+t)),_?(0,r.jsxs)(`div`,{className:`callout callout-highlight warning`,children:[(0,r.jsxs)(`div`,{className:`callout-title`,children:[(0,r.jsx)(l.Icon,{"aria-hidden":!0,icon:`it-help-circle`}),i.t(`Attenzione`)]}),(0,r.jsxs)(`p`,{children:[` `,i.t(`Non è possibile prenotare per la data selezionata`),`.`]})]}):null]})}),(0,r.jsx)(l.ModalFooter,{children:(0,r.jsx)(l.Button,{color:`primary`,onClick:()=>de(),disabled:!C||!x?.value_start,children:i.t(`Conferma`)})})]})]})},Je=class e extends q{constructor(e,t,n){super(e,t,n)}static get builderInfo(){return{title:`Calendar`,group:`basic`,icon:`bi bi-calendar-plus`,documentation:``,weight:70,schema:e.schema()}}static schema(){return q.schema({type:`calendar`})}static editForm=Ge;attach(e){return super.attach(e).then(()=>{this.loadRefs(this.element,{[`react-${this.id}`]:`single`});let e=this.refs[`react-${this.id}`];return e?(this.rootComponent=(0,n.createRoot)(e),this.rootComponent.render((0,r.jsx)(qe,{component:this.component,value:this.dataValue,onChange:e=>this.setValue(e),...this,current:this})),this):this})}detach(){return this.rootComponent&&=(this.rootComponent.unmount(),null),super.detach()}setValue(e){if(e)if(Array.isArray(e))this.selectedNextSlots=e,this.updateValue(e),this.shouldSetValue=!0;else if(typeof e==`object`)this.date=e.date,this.slot=e.slot,this.meeting=e.meeting_id,this.meeting_expiration_time=null,this.opening_hour=e.opening_hour_id,this.calendar_id=e.calendar_id,this.updateValue(e),this.shouldSetValue=!0;else{let t=e.replace(`)`,``).replace(` (`,` @ `).replace(/\//g,`-`).split(` @ `),n=t[2].split(`#`);this.date=t[0],this.slot=t[1],this.meeting=n[1],this.meeting_expiration_time=null,this.opening_hour=n.length===3?n[2]:``,this.updateValue({date:this.date,slot:this.slot,calendar_id:this.calendar_id,meeting_id:this.meeting,opening_hour_id:this.opening_hour})}}getValue(){if(!(this.date&&this.slot&&this.meeting&&this.opening_hour)&&!(this.selectedNextSlots&&this.selectedNextSlots.length>0))return null;let e=this.meeting?this.meeting:``,t=this.opening_hour?this.opening_hour:``;return this.component.multiple?this.selectedNextSlots:{date:this.date,slot:this.slot,calendar_id:this.calendar_id,meeting_id:e,opening_hour_id:t}}init(){super.init()}render(){return super.render(`<div ref="react-${this.id}"></div>`)}},Ye=[{key:`labelPosition`,ignore:!0},{key:`placeholder`,ignore:!0},{key:`description`,ignore:!0},{key:`hideLabel`,ignore:!0},{key:`autofocus`,ignore:!0},{key:`tooltip`,ignore:!0},{key:`tabindex`,ignore:!0},{key:`disabled`,ignore:!0},{label:`Base url`,calculateValue:`let url = '`+M()+`'; data.url = url; value=url;`,key:`url`,type:`hidden`,input:!0,weight:1},{label:`Tipo di visualizazzione`,widget:`choicesjs`,tableView:!0,data:{values:[{label:`calendar`,value:`calendar`},{label:`select`,value:`select`}]},validateWhenHidden:!1,defaultValue:`calendar`,key:`view`,type:`select`,input:!0}];function Xe(...e){return i.Components.baseEditForm([{key:`display`,components:Ye}],...e)}function Ze({day:e,slot:t,i18next:n}){return(0,r.jsx)(`li`,{className:`it-list-item`,children:(0,r.jsx)(`div`,{className:`list-item`,children:(0,r.jsx)(`div`,{className:`it-right-zone`,children:(0,r.jsxs)(`span`,{className:`text-paragraph pl-4`,children:[(0,r.jsx)(`b`,{children:e}),` `,n.t(`alle`),` `,n.t(`ore`),` `,(0,r.jsx)(`b`,{children:t})]})})})})}function Qe(e,t){if(!t||t.length===0)return;let n=t.map(e=>{let t=new Date(e.start);return(new Date(e.end)-t)/6e4}),r=Math.min(...n),i=n.reduce((e,t)=>e+t,0)/n.length,a=0;a=r<=30&&r>15?i*1:r<=15?i*24:i*4,e.setOption(`slotHeight`,a),document.documentElement.style.setProperty(`--slot-height`,`${a}px`)}var $e={AVAILABILITY:{key:`availability_data_cache_`,duration:10},SLOTS:{key:`availability_slots_cache_`,duration:10},SUBMISSION:{key:`submission_cache_`,duration:30}},et=(e,t,n)=>{let r={data:n,timestamp:(0,d.default)().toISOString()};localStorage.setItem(t,JSON.stringify(r))},tt=(e,t)=>{try{let n=localStorage.getItem(t);if(!n)return null;let r=JSON.parse(n),i=(0,d.default)().diff((0,d.default)(r.timestamp),`minutes`);return i>$e[e].duration?(localStorage.removeItem(t),console.log(`⏰ Cache scaduto: ${e}`),null):(console.log(`✅ Cache letto: ${e} (${i} minuti fa)`),r.data)}catch(t){return console.error(`Errore nel leggere il cache (${e}):`,t),null}},nt=(e,...t)=>$e[e].key+btoa(t),rt=`calendar_view_state`,it=`calendar_view_date`,at=(e,t)=>{try{localStorage.setItem(rt,e),localStorage.setItem(it,t||new Date().toISOString())}catch(e){console.error(`Errore nel salvare lo stato della view:`,e)}},ot=()=>{try{let e=localStorage.getItem(rt),t=localStorage.getItem(it);return{viewType:e||`timeGridWeek`,date:t?new Date(t):new Date}}catch(e){return console.error(`Errore nel leggere lo stato della view:`,e),{viewType:`timeGridWeek`,date:new Date}}},J=()=>{try{localStorage.removeItem(rt),localStorage.removeItem(it)}catch(e){console.error(`Errore nel pulire lo stato della view:`,e)}},st=t.Formio.Components.components.field,ct=({component:e,current:t,onChange:n,i18next:i})=>{let[o,s]=(0,a.useState)(null),[p,m]=(0,a.useState)(null),[h,ee]=(0,a.useState)([]),[g,_]=(0,a.useState)(!1),[v,y]=(0,a.useState)(!1),[b,x]=(0,a.useState)(null),[S,C]=(0,a.useState)([]),[w,T]=(0,a.useState)([]),[E,D]=(0,a.useState)([]),[O,k]=(0,a.useState)(null),[A,j]=(0,a.useState)(null),[te,N]=(0,a.useState)(null),P=(0,a.useRef)(null),F=(0,a.useRef)(null);i.language,c.default.locale(i.language),d.default.locale(i.language);function I(e){if(!e||e.length===0)return null;let t=e.map(e=>({start:e.start_time,end:e.end_time}));return{earliestStartTime:t.reduce((e,t)=>t.start<e?t.start:e,t[0].start),latestEndTime:t.reduce((e,t)=>t.end>e?t.end:e,t[0].end)}}function L(e){let t=e.map(e=>(0,c.default)(e.date).isoWeekday()),n=[1,2,3,4,5,6,7].filter(e=>!t.includes(e));n.length>0?F.current.setOption(`hiddenDays`,n):F.current.setOption(`hiddenDays`,[])}function R(e,t,n){let r=new URL(e),i=`${r.pathname.split(`/`).slice(0,4).join(`/`)}/${t}/${n}`;return`${r.origin}${i}${r.search}`}function ne(e,t,n){let r=new URL(e),i=`${r.pathname.split(`/`).slice(0,4).join(`/`)}`;return`${r.origin}${i}${r.search}&from_to=${t}&to_date=${n}`}function re(e,t,n){return`${M()}/api/availabilities/${e}/${t}?calendar_ids=${n}&available=true`}let z=e=>{D([]),T([]),n({}),e&&T(o.filter(t=>t.date.startsWith(e)))},ie=async(e,t)=>{let r=JSON.parse(e),a=nt(`SLOTS`,r.date,r.calendar_ids);if(t===`manual`)D([]),N(null),x(null),n({});else{let e=tt(`SLOTS`,a);if(e){D(e);return}}try{let e=await window.FormioHelper.anonymousCall(`availabilities/${r.date}?calendar_ids=${r.calendar_ids}`);et(`SLOTS`,a,e.data),D(e.data)}catch(e){console.error(`Errore nel caricamento degli slot:`,e),u.default.fire({icon:`error`,title:i.t(`Errore`),text:i.t(`Errore nel caricamento degli orari`)})}},ae=e=>{let r=JSON.parse(e),a={status:6,calendar:r.calendar_id,opening_hour:r.opening_hour_id,user:null,email:null,fiscal_code:null,name:` `,phone_number:null,from_time:(0,d.default)(`${r.date}T${r.start_time}`).toISOString(),to_time:(0,d.default)(`${r.date}T${r.end_time}`).toISOString(),user_message:null,reason:null,location:null,motivation_outcome:null,calendar_group_config_id:t?.data?.service_data?.id,calendar_group_office_id:t?.data?.user_group?.id,calendar_group_place_id:t?.data?.place?.id};window.FormioHelper.authenticatedRequest(t?.dataValue?.id?`PATCH`:`POST`,t?.dataValue?.id?`meetings/${t.dataValue.id}`:`meetings`,a).then(e=>{x({day:(0,d.default)(r.date).format(`dddd, DD MMMM YYYY`),startDate:r.start_time,endDate:r.end_time}),n(e?.id?e:e?{...e,id:t.dataValue.id}:t.dataValue.id?{...a,id:t.dataValue.id}:{...a})}).catch(e=>{console.error(e),e.status===400&&e?.response?.data?.type===`validation_error`?u.default.fire({title:``,html:`<p>`+i.t(`Lo slot orario selezionato non è disponibile perché già prenotato Seleziona un altro orario o una data diversa`)+`</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1}):u.default.fire({title:``,html:`<p>`+e+`</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1})})},oe=e=>{let t=new Set,n=[];return e.forEach(e=>{let r=(0,d.default)(e.date),i=r.format(`YYYY-MM`);t.has(i)||(t.add(i),n.push({value:i,label:r.format(`MMMM YYYY`).replace(/^\w/,e=>e.toUpperCase())}))}),n},se=async()=>{let e=t?.root?.data?.place?.merge_availabilities?t?.root?.data?.place?.merged_availabilities_link:null,r=(0,c.default)().format(`YYYY-MM-DD`),a=(0,c.default)().add(1,`month`).format(`YYYY-MM-DD`),o=t?.root?.data?.place?.calendars[0]?.id||null,l=e?ne(e,r,a):re(r,a,o),d=nt(`AVAILABILITY`,l),f=tt(`AVAILABILITY`,d);if(f){s(f),C(oe(f));return}else n({});_(!0);try{let e=await window.FormioHelper.fetchAPIUrlLimit(l);if(_(!1),!e?.length){u.default.fire({icon:`warning`,title:i.t(`warning`),html:i.t(`no_meetings`)});return}et(`AVAILABILITY`,d,e),s(e),C(oe(e))}catch(e){_(!1),console.error(`Errore nel caricamento disponibilità:`,e)}};(0,a.useEffect)(()=>{if(o?.length){let e=t?.dataValue??t?.getValue();if(e?.from_time&&e?.to_time&&!(0,d.default)().isAfter(e?.draft_expiration)){let t=(0,d.default)(e.from_time).format(`YYYY-MM`);k(t),t&&T&&(T(o.filter(e=>e.date.startsWith(t))),j((0,d.default)(e.from_time).format(`YYYY-MM-DD`)))}else e?.draft_expiration&&(0,d.default)().isAfter(e?.draft_expiration)&&u.default.fire({icon:`warning`,title:i.t(`warning`),html:i.t(`expired_meeting`)})}},[o]),(0,a.useEffect)(()=>{let e=t?.dataValue??t?.getValue();if(!S.length||O||e?.from_time||e?.to_time)return;let n=S[0];n&&(k(n.value),z(n.value))},[S,O,t?.dataValue]),(0,a.useEffect)(()=>{if(A&&v===!1){let e=t?.dataValue??t?.getValue();ie(JSON.stringify({date:A,calendar_ids:e.calendar.id}))}},[A]);let ce=()=>window.innerWidth>768?`timeGridWeek`:`timeGridDay`;(0,a.useEffect)(()=>{let e=()=>{let e=F.current;if(!e)return;let t=ce();t!==e.getView().type&&e.setOption(`view`,t)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,a.useEffect)(()=>{let e=t?.dataValue??t?.getValue();E?.length&&e?.from_time&&(N((0,d.default)(e.from_time).format(`HH:mm`)+` - `+(0,d.default)(e.to_time).format(`HH:mm`)),x({day:(0,d.default)(e.from_time).format(`dddd D MMM YYYY`),startDate:(0,d.default)(e.from_time).format(`HH:mm`),endDate:(0,d.default)(e.to_time).format(`HH:mm`)}))},[E]);let le=()=>{let e=ot();F.current=(0,f.createCalendar)(P.current,[f.TimeGrid],{events:[],buttonText:{today:i.t(`Oggi`)},allDaySlot:!1,firstDay:1,date:e.date,slotEventOverlap:!1,view:ce(),height:`400px`,views:{timeGridWeek:{allDaySlot:!1,firstDay:1,slotHeight:48},timeGridDay:{allDaySlot:!1,firstDay:1,slotHeight:48}},datesSet:e=>{at(e.view.type,e.start)},eventClick({event:e,el:r}){document.querySelectorAll(`.ec-event`).forEach(e=>{e.classList.remove(`highlighted-event`)}),r.classList.add(`highlighted-event`);let a=new Date(e.start),o=new Date(e.end),s=a.toLocaleDateString(`it-IT`,{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),c=a.toLocaleTimeString(`it-IT`,{hour:`2-digit`,minute:`2-digit`}),l=o.toLocaleTimeString(`it-IT`,{hour:`2-digit`,minute:`2-digit`}),d={status:6,calendar:e.extendedProps.calendar_id,opening_hour:e.extendedProps.opening_hour_id,user:null,email:null,fiscal_code:null,name:` `,phone_number:null,from_time:a,to_time:o,user_message:null,reason:null,location:null,motivation_outcome:null,calendar_group_config_id:t?.data?.service_data?.id,calendar_group_office_id:t?.data?.user_group?.id,calendar_group_place_id:t?.data?.place?.id};window.FormioHelper.authenticatedRequest(t?.dataValue?.id?`PATCH`:`POST`,t?.dataValue?.id?`meetings/${t.dataValue.id}`:`meetings`,d).then(e=>{let r;!e||e===``?r={...d,code:null,id:t?.dataValue?.id}:typeof e==`object`&&(r=e),x({day:s,startDate:c,endDate:l}),n(r)}).catch(e=>{console.error(e),e.status===400&&e?.response?.data?.type===`validation_error`?u.default.fire({title:``,html:`<p>`+i.t(`Lo slot orario selezionato non è disponibile perché già prenotato Seleziona un altro orario o una data diversa`)+`</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1}):u.default.fire({title:``,html:`<p>`+e+`</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1})})},viewDidMount:ue,eventDidMount:e=>{let{event:t,el:n}=e,r=t.extendedProps;n.setAttribute(`data-event-id`,t.id+`-`+r.date+`-`+r.start_time)},loading:e=>{_(e)}})},ue=e=>{t?.root?.data?.place&&F.current.setOption(`eventSources`,[{events:de}])};async function de(e,n,r){try{F.current.setOption(`events`,[]);let r=(0,c.default)(e.start).format(`YYYY-MM-DD`),a=new Date(e.end);a.setDate(a.getDate()-1);let o=(0,c.default)(a).format(`YYYY-MM-DD`),s=t?.root?.data?.place?.merge_availabilities?t?.root?.data?.place?.merged_availabilities_link:null,l=s?R(s,r,o):re(r,o,null),d=nt(`AVAILABILITY`,l),f=tt(`AVAILABILITY`,d),p;if(f?(p=f,_(!1)):(p=await window.FormioHelper.fetchAPIUrlLimit(l),et(`AVAILABILITY`,d,p)),!p?.length){n([]),u.default.fire({icon:`warning`,title:i.t(`warning`),html:i.t(`no_meetings`)});return}let m=p.map(e=>({id:e.opening_hour_id,allDay:!1,start:`${e.date}T${e.start_time}:00`,end:`${e.date}T${e.end_time}:00`,title:`${e.start_time} - ${e.end_time}`,editable:!1,display:`auto`,color:`#ebeef0`,textColor:`#000`,className:`event-slot`,extendedProps:{...e}})),h=I(p);F.current.setOption(`slotMinTime`,h.earliestStartTime),F.current.setOption(`slotMaxTime`,h.latestEndTime),L(p),Qe(F.current,m),n(m),setTimeout(()=>{fe(m)},500)}catch(e){console.error(`Errore nel caricamento disponibilità:`,e),r?.(e)}}(0,a.useEffect)(()=>{let r,a=!1;async function o(){try{if(await window.FormioInstance?.formReady,a)return;if(!P.current){console.warn(`Elemento calendario non trovato`);return}let r=t?.dataValue??t?.getValue();r&&r?.draft_expiration&&(0,d.default)().isAfter(r.draft_expiration)&&(n({}),J()),t?.data?.service_data?.view_type===`calendar`||e.view===`calendar`?F?.current||le():t?.data?.service_data?.view_type===`select`||e.view===`select`?se():alert(i.t(`Il componente non è configurato per la visualizzazione a calendario`))}catch(e){console.error(`Errore durante l'inizializzazione del calendario:`,e)}}return r=setTimeout(o,500),()=>{a=!0,r&&clearTimeout(r),F.current&&=(P.current?.destroy?.(),null)}},[t?.root?.data?.place]);function fe(e){let n=t?.dataValue;if(!n?.from_time)return;let r=(0,d.default)(n.from_time).format(`DD-MM-YYYY HH:mm`),i=(0,d.default)(n.to_time).format(`DD-MM-YYYY HH:mm`),a=e.find(e=>(0,d.default)(e.start).format(`DD-MM-YYYY HH:mm`)===r&&(0,d.default)(e.end).format(`DD-MM-YYYY HH:mm`)===i);if(!a)return;let o=document.querySelector(`.ec-event[data-event-id="${a.id}-${(0,d.default)(n?.from_time).format(`YYYY-MM-DD`)}-${(0,d.default)(n?.from_time).format(`HH:mm`)}"]`);o&&(o.classList.add(`highlighted-event`),o.scrollIntoView({behavior:`smooth`,block:`center`}),x({day:(0,d.default)(n?.from_time).format(`dddd, DD MMMM YYYY`),startDate:(0,d.default)(n?.from_time).format(`HH:mm`),endDate:(0,d.default)(n?.to_time).format(`HH:mm`)}))}return(0,a.useEffect)(()=>{document.querySelector(`.formio-read-only`)&&v===!1?y(!0):(t?.data?.service_data?.view_type===`select`?se():t?.data?.service_data?.view_type===`calendar`&&le(),y(!1))},[]),(0,a.useEffect)(()=>{v&&setTimeout(()=>{let e=t?.dataValue??t?.getValue();console.log(`savedValue`,e,v),e&&m(e)},500)},[v]),(0,r.jsx)(r.Fragment,{children:v&&p?(0,r.jsxs)(`div`,{className:`mx-2`,children:[(0,r.jsxs)(`p`,{className:`text-paragraph`,children:[i.t(`Giorno selezionato per la prenotazione`),`:`]}),(0,r.jsx)(`div`,{className:``,children:(0,r.jsx)(`div`,{className:`it-list-wrapper`,children:(0,r.jsx)(`ul`,{className:`it-list`,children:(0,r.jsx)(Ze,{day:(0,d.default)(p.from_time).format(`dddd D MMM YYYY`),i18next:i,slot:`${(0,d.default)(p.from_time).format(`HH:mm`)} - ${(0,d.default)(p.to_time).format(`HH:mm`)}`})})})})]}):(0,r.jsxs)(`div`,{className:``,children:[(0,r.jsx)(`div`,{ref:P}),S.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(l.Select,{label:`Mese`,id:`selectMonthYear`,onChange:z,children:[(0,r.jsx)(`option`,{value:``,children:i.t(`Scegli un'opzione`)}),S.map(e=>(0,r.jsx)(`option`,{value:e.value,selected:e.value===O,children:e.label},e.value))]}),(0,r.jsxs)(l.Select,{label:`Giorno`,id:`selectDay`,onChange:e=>ie(e,`manual`),disabled:w.length===0,children:[(0,r.jsx)(`option`,{value:``,children:i.t(`Scegli un'opzione`)}),w.map(e=>(0,r.jsx)(`option`,{value:JSON.stringify(e),selected:e.date===A,children:(0,d.default)(e.date).format(`dddd,DD MMMM YYYY`)},e.date))]}),(0,r.jsxs)(l.Select,{label:`Orario`,id:`selectSlot`,onChange:ae,disabled:E.length===0,children:[(0,r.jsx)(`option`,{value:``,children:i.t(`Scegli un'opzione`)}),E.map(e=>(0,r.jsx)(`option`,{value:JSON.stringify(e),selected:e.start_time+` - `+e.end_time===te,children:e.start_time+` - `+e.end_time},e.start_time+` - `+e.end_time))]})]}):null,b?(({day:e,startDate:t,endDate:n})=>(0,r.jsx)(`div`,{className:`mt-3`,children:(0,r.jsxs)(`div`,{className:`row align-items-center gy-3`,children:[(0,r.jsxs)(`div`,{className:`col-12 col-md border-light mx-md-3`,children:[(0,r.jsx)(`div`,{className:`text-paragraph-small`,children:i.t(`Data`)}),(0,r.jsx)(`p`,{className:`data-text`,children:(0,r.jsx)(`strong`,{children:e})})]}),(0,r.jsxs)(`div`,{className:`col-12 col-md border-light mx-md-3`,children:[(0,r.jsx)(`div`,{className:`text-paragraph-small`,children:i.t(`Ora`)}),(0,r.jsx)(`p`,{className:`data-text`,children:(0,r.jsxs)(`strong`,{children:[t,` - `,n]})})]})]})}))({day:b.day,startDate:b.startDate,endDate:b.endDate}):null,g?(0,r.jsx)(`div`,{className:`d-flex align-items-center justify-content-center position-absolute-center`,children:(0,r.jsx)(l.Spinner,{active:!0})}):null]})})},lt=class e extends st{constructor(e,t,n){super(e,t,n)}static get builderInfo(){return{title:`Calendar Advanced`,group:`basic`,icon:`bi bi-calendar-plus`,documentation:``,weight:70,schema:e.schema()}}static schema(){return st.schema({type:`calendar-advanced`})}static editForm=Xe;attach(e,t){return super.attach(e).then(()=>{this.loadRefs(this.element,{[`react-${this.id}`]:`single`});let e=this.refs[`react-${this.id}`];return e?(this.rootComponent&&=(this.rootComponent.unmount(),null),this.rootComponent=(0,n.createRoot)(e),this.builderMode?(this.rootComponent.render((0,r.jsx)(`div`,{className:`my-1 border border-2 border-light rounded p-3 text-secondary`,children:(0,r.jsx)(`div`,{className:`h6 mb-0`,children:this.component?.label||`Calendar Advanced`})})),this):(this.rootComponent.render((0,r.jsx)(ct,{ref:t,component:this.component,value:this.dataValue,onChange:e=>this.setValue(e),...this,current:this})),this)):this})}detach(){return this.rootComponent&&=(this.rootComponent.unmount(),null),super.detach()}setValue(e){e&&(this.updateValue(e),this.shouldSetValue=!0)}getValue(){return this.dataValue}init(){super.init()}render(){return super.render(`<div ref="react-${this.id}"></div>`)}},ut=[{key:`defaultValue`,ignore:!0}],dt=[{key:`placeholder`,ignore:!0},{type:`checkbox`,label:`Files Synchronization feature`,tooltip:`Enable ability to control files synchronization. Files will be auto synced before submit.`,key:`autoSync`,input:!0,conditional:{json:{in:[{var:`data.storage`},[`s3`,`azure`,`googledrive`]]}}}],ft=[{type:`select`,input:!0,key:`storage`,label:`Storage`,placeholder:`Select your file storage provider`,weight:0,tooltip:`Which storage to save the files in.`,valueProperty:`value`,dataSrc:`custom`,hidden:!0,data:{custom:function(){return[{label:`url`,value:`url`}]}}},{type:`checkbox`,input:!0,defaultValue:!0,key:`protocol_required`,label:`Richiede protocollazione?`,tooltip:``,weight:10},{type:`checkbox`,input:!0,defaultValue:!1,key:`check_signature`,label:`Effettuare il controllo della firma?`,tooltip:``,weight:15},{type:`checkbox`,input:!0,key:`useMultipartUpload`,label:`Use the S3 Multipart Upload API`,tooltip:`The <a href='https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html'>S3 Multipart Upload API</a> is designed to improve the upload experience for larger objects (> 5GB).`,conditional:{json:{"===":[{var:`data.storage`},`s3`]}}},{label:`Multipart Upload`,tableView:!1,key:`multipart`,type:`container`,input:!0,components:[{label:`Part Size (MB)`,applyMaskOn:`change`,mask:!1,tableView:!1,delimiter:!1,requireDecimal:!1,inputFormat:`plain`,truncateMultipleSpaces:!1,validate:{min:5,max:5e3},key:`partSize`,type:`number`,input:!0,defaultValue:500}],conditional:{json:{"===":[{var:`data.useMultipartUpload`},!0]}}},{type:`textfield`,input:!0,key:`options.indexeddb`,label:`Database`,weight:10,placeholder:`Enter the indexeddb database name`,conditional:{json:{in:[{var:`data.storage`},[`indexeddb`]]}}},{type:`textfield`,input:!0,label:`Table`,key:`options.indexeddbTable`,weight:10,placeholder:`Enter the name for indexeddb table`,conditional:{json:{in:[{var:`data.storage`},[`indexeddb`]]}}},{type:`textarea`,key:`options`,label:`Custom request options`,tooltip:`Pass your custom xhr options(optional)`,rows:5,editor:`ace`,input:!0,weight:15,placeholder:`{
67
+ }`,validateOn:`change`,validate:{customMessage:`Vi sono sovrapposizioni negli orari di apertura`,custom:`if (document.querySelector("input[name^='data[overlaps_validation]']").value === '0') {valid=true} else {valid = 'Sovrapposizione';}`},key:`overlaps_validation`,attributes:{readonly:`true`},required:!0,type:`number`,input:!0,weight:1},{label:`Precisione minima (minuti)`,defaultValue:1,required:!0,inputFormat:`plain`,key:`range_step`,type:`number`,input:!0,weight:1}];function Ge(...e){return i.Components.baseEditForm([{key:`display`,components:K}],...e)}function Ke({day:e,slot:t,i18next:n}){return(0,r.jsx)(`li`,{className:`it-list-item`,children:(0,r.jsx)(`div`,{className:`list-item`,children:(0,r.jsx)(`div`,{className:`it-right-zone`,children:(0,r.jsxs)(`span`,{className:`text pl-4`,children:[(0,r.jsx)(`b`,{children:e}),` `,n.t(`alle`),` `,n.t(`ore`),` `,(0,r.jsx)(`b`,{children:t})]})})})})}var q=t.Formio.Components.components.field,qe=({component:e,current:t,onChange:n,i18next:i})=>{let[f,p]=(0,a.useState)(),[m,h]=(0,a.useState)([]),[ee,g]=(0,a.useState)([]),[_,v]=(0,a.useState)(!1),[y,b]=(0,a.useState)(null),[x,S]=(0,a.useState)(null),[C,w]=(0,a.useState)(null),[T,E]=(0,a.useState)(null),[D,O]=(0,a.useState)({}),[k,A]=(0,a.useState)(null),[j,te]=(0,a.useState)(!1),[N,P]=(0,a.useState)([]),[F,I]=(0,a.useState)(!1),L=(0,a.useRef)(),R=e.calendarId;c.default.locale(i.language),d.default.locale(i.language);let ne=e=>{let t=(0,c.default)(e).format(`YYYY-MM-DD`);fetch(ae(t)).then(e=>e.json()).then(t=>{let n=ie(e||new Date),r=t.filter(e=>e.available==1);r.length===0&&he();let i=[];n.forEach(e=>{t.some(t=>t.date===e&&t.available==1)?i.push({available:!0,date:e}):i.push({available:!1,date:e})}),h(i.map(e=>{if(e.available===!1)return(0,c.default)(e.date,`YYYY-MM-DD`).toDate()})),re(r.length?r[0].date:e)}).catch(e=>console.error(e))},re=e=>{E(null),w(null),g([]);let t=(0,c.default)(e).format(`YYYY-MM-DD`);fetch(oe(t)).then(e=>e.json()).then(t=>{let n=t.filter(e=>e.availability==1);O(n[0]),n.length>0?(g(t),v(!1),w((0,c.default)(e).format(`L`)),p((0,c.default)(e,`YYYY-MM-DD`).toDate())):(t.length>0&&p((0,c.default)(t[0].date,`YYYY-MM-DD`).toDate()),g([]),he())})},z=()=>{if(R!==``&&R!=null)if(!t.dataValue)ne(new Date);else if(e.multiple&&Array.isArray(t.dataValue)){if(t.dataValue.length>0){A(t.dataValue);let e=[];t.dataValue.map(t=>{e.push({...t,date:(0,c.default)(t.date,`YYYY-MM-DD`).format(`DD-MM-YYYY`)})}),P(e)}}else if(!e.multiple&&typeof t.dataValue==`object`){let e={date:t.dataValue.date,slot:t.dataValue.slot};P([{...t.dataValue,date:(0,c.default)(t.dataValue.date,`YYYY-MM-DD`).format(`DD-MM-YYYY`)}]),A(e)}else{let r=t.dataValue.replace(`)`,``).replace(` (`,` @ `).replace(/\//g,`-`).split(` @ `),i=r[2].split(`#`),a={date:(0,c.default)(r[0],`DD-MM-YYYY`).format(`YYYY-MM-DD`),slot:r[1]};e.multiple?(n([{date:r[0],slot:r[1],calendar_id:i[0],meeting_id:i[1],opening_hour_id:i.length===3?i[2]:``}]),P([{date:r[0],slot:r[1],calendar_id:i[0],meeting_id:i[1],opening_hour_id:i.length===3?i[2]:``}])):(n({date:r[0],slot:r[1],calendar_id:i[0],meeting_id:i[1],opening_hour_id:i.length===3?i[2]:``}),P([{date:r[0],slot:r[1],calendar_id:i[0],meeting_id:i[1],opening_hour_id:i.length===3?i[2]:``}])),A(a)}};(0,a.useEffect)(()=>{window.FormioInstance?.formReady.then(()=>{setTimeout(()=>{z()},1e3)})},[]);let ie=e=>{let t=(0,c.default)(e,`YYYY-MM`).daysInMonth(),n=[];for(;t;){let r=(0,c.default)(e).date(t);n.push(r.format(`YYYY-MM-DD`)),t--}return n},ae=(t,n=!1)=>{let r=e.calendarId,i=e.select_opening_hours,a=e.select_opening_hours?e.opening_hours:[];window.location.pathname.split(`/`);let o=`${M()}/api/calendars/${r}/availabilities`,s=[`from_time=${(0,c.default)(t).startOf(`month`).format(`YYYY-MM-DD`)}`,`to_time=${(0,c.default)(t).endOf(`month`).format(`YYYY-MM-DD`)}`];return n&&s.push(`available=${n}`),i&&a&&s.push(`opening_hours=${a.join()}`),`${o}?${s.join(`&`)}`},oe=(t,n=!1)=>{let r=e.calendarId,i=e.select_opening_hours,a=e.select_opening_hours?e.opening_hours:[];window.location.pathname.split(`/`);let o=(0,c.default)(t).format(`YYYY-MM-DD`),s=`${M()}/api/calendars/${r}/availabilities/${o}`,l=[];return n&&l.push(`available=${n}`),i&&a&&l.push(`opening_hours=${a.join()}`),l&&(s=`${s}?${l.join(`&`)}`),s},se=e=>{ne(e)},ce=e=>{setTimeout(()=>{te(!j)},1e3),re(e)},le=e=>{E(null),setTimeout(()=>{e&&(S(e.target.dataset),E(e.target.id))},300)},ue=t=>{b(null);let n=`${M()}/it/meetings/new-draft`,r={date:x?.date?(0,c.default)(x?.date).format(`DD-MM-YYYY`):(0,c.default)(t.target.dataset.date).format(`DD-MM-YYYY`),slot:x?.value_start&&x?.value_end?x.value_start+`-`+x.value_end:t.target.dataset.slots,calendar:e.calendarId,opening_hour:x?.opening_hour?x?.opening_hour:t.target.dataset.opening_hour,meeting:y?y.id:``,first_available_date:D.date,first_available_start_time:D.start_time,first_available_end_time:D.end_time,first_availability_updated_at:(0,c.default)().format()};fetch(n,{method:`POST`,body:JSON.stringify(r),headers:{"Content-Type":`application/json; charset=utf-8`},strictErrors:!0}).then(e=>{if(!e.ok)throw Error(i.t(`Intervallo selezionato non disponibile!`));return e.json()}).then(e=>{b(e);let t={date:r.date,slot:r.slot,calendar_id:r.calendar[0],opening_hour_id:r.opening_hour||r.opening_hour_id,meeting_id:e.id};P([...N,t])}).catch(e=>{console.log(e),u.default.fire({title:``,html:`<p>`+e+`</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1})})},de=()=>{x&&(ue(),te(!j))},fe=()=>(0,r.jsx)(`span`,{children:i.t(`Tempo prenotazione scaduto!`)}),pe=({minutes:e,seconds:t,completed:n})=>n?(0,r.jsx)(fe,{}):(0,r.jsx)(`div`,{children:(0,r.jsxs)(`div`,{children:[` `,(0,r.jsxs)(`span`,{children:[` `,(0,r.jsxs)(`i`,{children:[i.t(`Per confermare la prenotazione che ti abbiamo riservato procedi con l’invio di questa pratica e con il pagamento (se richiesto) di quanto previsto entro`),`:`]}),` `,(0,r.jsxs)(`b`,{children:[e,` `,i.t(`minuti`),` `,t,` `,i.t(`secondi`)]})]})]})}),me=t=>{if(t===null||t===``)n(``);else if(Array.isArray(t)&&t.length>0){let t=[];N.map(e=>{t.push({date:(0,c.default)(e.date,`DD-MM-YYYY`).format(`YYYY-MM-DD`),slot:e.slot,calendar_id:e.calendar_id||e.calendar[0],meeting_id:e.meeting_id,opening_hour_id:e.opening_hour||e.opening_hour_id})}),e.multiple?n(t):n(t[0])}else n(``)},he=()=>{v(!0),b(null),w(null),me(null)},B=()=>{if(i.language===`it`)return Fe;if(i.language===`en`)return Ee;if(i.language===`de`)return be};(0,a.useEffect)(()=>{me(N)},[N]),(0,a.useEffect)(()=>{document.querySelector(`.formio-read-only`)&&F===!1?(I(!0),setTimeout(()=>{z()},1e3)):(I(!1),setTimeout(()=>{z()},1e3))},[]);let ge=(e,t)=>{let n=`${M()}/api/meetings/${t.meeting_id}`;fetch(n,{method:`DELETE`,headers:{"Content-Type":`application/json; charset=utf-8`,Authorization:`Bearer ${U(`auth-token`)}`},strictErrors:!0}).then(t=>{t&&t.status>400?u.default.fire({title:``,html:`<p>${i.t(`Ci sono stati degli errori durante la cancellazione dello slot`)}</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1}):(P([...N.slice(0,e),...N.slice(e+1)]),ne(new Date))})};return(0,r.jsxs)(r.Fragment,{children:[F&&k?(0,r.jsxs)(`div`,{className:`my-5 mx-2 d-print-block d-preview-calendar d-preview-calendar-none`,children:[(0,r.jsxs)(`b`,{children:[Array.isArray(k)&&k.length>1?i.t(`Giorni selezionati per la prenotazione`):i.t(`Giorno selezionato per la prenotazione`),`:`]}),(0,r.jsx)(`div`,{className:`mb-5`,children:(0,r.jsx)(`div`,{className:`it-list-wrapper`,children:(0,r.jsx)(`ul`,{className:`it-list`,children:Array.isArray(k)?k.map(e=>(0,r.jsx)(Ke,{day:(0,c.default)(e.date,`DD-MM-YYYY`).format(`DD/MM/YYYY`),i18next:i,slot:e.slot})):(0,r.jsx)(Ke,{day:(0,d.default)(k.date).format(`DD/MM/YYYY`),i18next:i,slot:k.slot})})})})]}):(0,r.jsx)(`div`,{className:`slot-calendar `,children:(0,r.jsxs)(`div`,{className:`row`,children:[e.multiple?(0,r.jsx)(`div`,{className:`col-12 d-print-none d-preview-calendar-none`,children:(0,r.jsxs)(`div`,{className:`m-2`,children:[(0,r.jsx)(`h6`,{children:i.t(e.label)}),(0,r.jsx)(o.DayPicker,{mode:`single`,selected:f,locale:B(),disabled:m,onMonthChange:se,onDayClick:ce})]})}):N.length===1?null:(0,r.jsx)(`div`,{className:`col-12 d-print-none d-preview-calendar-none`,children:(0,r.jsxs)(`div`,{className:`m-2`,children:[(0,r.jsx)(`h6`,{children:i.t(e.label)}),(0,r.jsx)(o.DayPicker,{mode:`single`,selected:f,locale:B(),disabled:m,onMonthChange:se,onDayClick:ce})]})}),(0,r.jsx)(`div`,{className:`col-12`,children:N.length?(0,r.jsx)(`div`,{className:`row m-2`,children:(0,r.jsxs)(`div`,{className:`col-12 mb-4`,children:[(0,r.jsxs)(`b`,{children:[N.length>1?i.t(`Giorni selezionati per la prenotazione`):i.t(`Giorno selezionato per la prenotazione`),`:`,` `]}),(0,r.jsx)(`div`,{className:`mb-5`,children:(0,r.jsx)(`div`,{className:`it-list-wrapper`,children:(0,r.jsx)(`ul`,{className:`it-list`,children:N.map((e,t)=>(0,r.jsx)(`li`,{children:(0,r.jsx)(`div`,{className:`list-item`,children:(0,r.jsxs)(`div`,{className:`it-right-zone`,children:[(0,r.jsxs)(`span`,{className:`text pl-4`,children:[e.date,` `,x||e.slot?`${i.t(`alle`)} ${e.slot}`:``]}),(0,r.jsx)(l.Icon,{icon:`it-delete`,onClick:()=>ge(t,e),role:`button`})]})})},`li`+t))})})}),y?(0,r.jsx)(l.Alert,{color:`info`,defaultValue:`string`,className:`d-print-none d-preview-calendar-none`,children:(0,r.jsx)(s.default,{date:y.expiration_time,renderer:pe})}):null]})}):null})]})}),(0,r.jsxs)(l.Modal,{isOpen:j,toggle:()=>te(!j),labelledBy:`daySelected`,size:`lg`,centered:!0,container:G(),children:[(0,r.jsx)(l.ModalHeader,{toggle:()=>te(!j),id:`daySelected`,children:i.t(`Seleziona una fascia oraria`)}),(0,r.jsx)(l.ModalBody,{children:(0,r.jsxs)(`div`,{className:`row`,children:[N.length>=1?(0,r.jsxs)(`div`,{children:[C&&!_?(0,r.jsxs)(`h6`,{children:[i.t(`Orari disponibili del`),` `,(0,d.default)(C).format(`DD/MM/YYYY`)]}):null,(0,r.jsxs)(`div`,{className:`calendar-last-selection col-12 pt-2 mb-5`,children:[(0,r.jsx)(`small`,{className:`pl-2 mb-2 d-flex px-2`,children:(0,r.jsxs)(`b`,{children:[(0,r.jsx)(l.Icon,{icon:`it-clock`,className:`mr-1`,size:`sm`}),` `,i.t(`Ultimo orario selezionato`)]})}),(0,r.jsx)(`div`,{className:`col-6 px-2`,children:(0,r.jsx)(`button`,{type:`button`,id:`slot-last-selection`,onClick:le,tabIndex:`1`,className:T===`slot-last-selection`?`active btn btn-slot p-0`:`btn btn-slot p-0`,"data-date":(0,c.default)(C,`DD/MM/YYYY`).format(`YYYY-MM-DD`),"data-slots":N[N.length-1].slot,"data-opening_hour":N[N.length-1].opening_hour_id,"data-start":N[N.length-1].slot.split(`-`)[0],"data-end":N[N.length-1].slot.split(`-`)[1],"data-value_start":N[N.length-1].slot.split(`-`)[0],"data-value_end":N[N.length-1].slot.split(`-`)[1],disabled:_,children:N[N.length-1].slot})})]})]}):null,(0,r.jsx)(`div`,{children:C&&N.length>=1?(0,r.jsx)(`h6`,{children:i.t(`Seleziona altri orari`)}):_?null:(0,r.jsxs)(`h6`,{children:[i.t(`Orari disponibili del`),` `,(0,d.default)(C).format(`DD/MM/YYYY`)]})}),ee.map((e,t)=>(0,r.jsx)(`div`,{className:`col-6`,children:(0,r.jsxs)(`button`,{type:`button`,id:`slot-`+t,onClick:le,ref:L,className:T===`slot-`+t?`active btn btn-slot p-0`:`btn btn-slot p-0`,tabIndex:`1`,"data-date":e.date,"data-start":e.start_time,"data-end":e.end_time,"data-value_start":e.start_time,"data-value_end":e.end_time,"data-slots":e.start_time+`-`+e.end_time,"data-opening_hour":e.opening_hour,"data-min_duration":e.min_duration,disabled:e.slots_available==0,children:[e.start_time,` - `,e.end_time]})},`slot-`+t)),_?(0,r.jsxs)(`div`,{className:`callout callout-highlight warning`,children:[(0,r.jsxs)(`div`,{className:`callout-title`,children:[(0,r.jsx)(l.Icon,{"aria-hidden":!0,icon:`it-help-circle`}),i.t(`Attenzione`)]}),(0,r.jsxs)(`p`,{children:[` `,i.t(`Non è possibile prenotare per la data selezionata`),`.`]})]}):null]})}),(0,r.jsx)(l.ModalFooter,{children:(0,r.jsx)(l.Button,{color:`primary`,onClick:()=>de(),disabled:!C||!x?.value_start,children:i.t(`Conferma`)})})]})]})},Je=class e extends q{constructor(e,t,n){super(e,t,n)}static get builderInfo(){return{title:`Calendar`,group:`basic`,icon:`bi bi-calendar-plus`,documentation:``,weight:70,schema:e.schema()}}static schema(){return q.schema({type:`calendar`})}static editForm=Ge;attach(e){return super.attach(e).then(()=>{this.loadRefs(this.element,{[`react-${this.id}`]:`single`});let e=this.refs[`react-${this.id}`];return e?(this.rootComponent=(0,n.createRoot)(e),this.rootComponent.render((0,r.jsx)(qe,{component:this.component,value:this.dataValue,onChange:e=>this.setValue(e),...this,current:this})),this):this})}detach(){return this.rootComponent&&=(this.rootComponent.unmount(),null),super.detach()}setValue(e){if(e)if(Array.isArray(e))this.selectedNextSlots=e,this.updateValue(e),this.shouldSetValue=!0;else if(typeof e==`object`)this.date=e.date,this.slot=e.slot,this.meeting=e.meeting_id,this.meeting_expiration_time=null,this.opening_hour=e.opening_hour_id,this.calendar_id=e.calendar_id,this.updateValue(e),this.shouldSetValue=!0;else{let t=e.replace(`)`,``).replace(` (`,` @ `).replace(/\//g,`-`).split(` @ `),n=t[2].split(`#`);this.date=t[0],this.slot=t[1],this.meeting=n[1],this.meeting_expiration_time=null,this.opening_hour=n.length===3?n[2]:``,this.updateValue({date:this.date,slot:this.slot,calendar_id:this.calendar_id,meeting_id:this.meeting,opening_hour_id:this.opening_hour})}}getValue(){if(!(this.date&&this.slot&&this.meeting&&this.opening_hour)&&!(this.selectedNextSlots&&this.selectedNextSlots.length>0))return null;let e=this.meeting?this.meeting:``,t=this.opening_hour?this.opening_hour:``;return this.component.multiple?this.selectedNextSlots:{date:this.date,slot:this.slot,calendar_id:this.calendar_id,meeting_id:e,opening_hour_id:t}}init(){super.init()}render(){return super.render(`<div ref="react-${this.id}"></div>`)}},Ye=[{key:`labelPosition`,ignore:!0},{key:`placeholder`,ignore:!0},{key:`description`,ignore:!0},{key:`hideLabel`,ignore:!0},{key:`autofocus`,ignore:!0},{key:`tooltip`,ignore:!0},{key:`tabindex`,ignore:!0},{key:`disabled`,ignore:!0},{label:`Base url`,calculateValue:`let url = '`+M()+`'; data.url = url; value=url;`,key:`url`,type:`hidden`,input:!0,weight:1},{label:`Tipo di visualizazzione`,widget:`choicesjs`,tableView:!0,data:{values:[{label:`calendar`,value:`calendar`},{label:`select`,value:`select`}]},validateWhenHidden:!1,defaultValue:`calendar`,key:`view`,type:`select`,input:!0}];function Xe(...e){return i.Components.baseEditForm([{key:`display`,components:Ye}],...e)}function Ze({day:e,slot:t,i18next:n}){return(0,r.jsx)(`li`,{className:`it-list-item`,children:(0,r.jsx)(`div`,{className:`list-item`,children:(0,r.jsx)(`div`,{className:`it-right-zone`,children:(0,r.jsxs)(`span`,{className:`text-paragraph pl-4`,children:[(0,r.jsx)(`b`,{children:e}),` `,n.t(`alle`),` `,n.t(`ore`),` `,(0,r.jsx)(`b`,{children:t})]})})})})}function Qe(e,t){if(!t||t.length===0)return;let n=t.map(e=>{let t=new Date(e.start);return(new Date(e.end)-t)/6e4}),r=Math.min(...n),i=n.reduce((e,t)=>e+t,0)/n.length,a=0;a=r<=30&&r>15?i*1:r<=15?i*24:i*4,e.setOption(`slotHeight`,a),document.documentElement.style.setProperty(`--slot-height`,`${a}px`)}var $e={AVAILABILITY:{key:`availability_data_cache_`,duration:10},SLOTS:{key:`availability_slots_cache_`,duration:10},SUBMISSION:{key:`submission_cache_`,duration:30}},et=(e,t,n)=>{let r={data:n,timestamp:(0,d.default)().toISOString()};localStorage.setItem(t,JSON.stringify(r))},tt=(e,t)=>{try{let n=localStorage.getItem(t);if(!n)return null;let r=JSON.parse(n),i=(0,d.default)().diff((0,d.default)(r.timestamp),`minutes`);return i>$e[e].duration?(localStorage.removeItem(t),console.log(`⏰ Cache scaduto: ${e}`),null):(console.log(`✅ Cache letto: ${e} (${i} minuti fa)`),r.data)}catch(t){return console.error(`Errore nel leggere il cache (${e}):`,t),null}},nt=(e,...t)=>$e[e].key+btoa(t),rt=`calendar_view_state`,it=`calendar_view_date`,at=(e,t)=>{try{localStorage.setItem(rt,e),localStorage.setItem(it,t||new Date().toISOString())}catch(e){console.error(`Errore nel salvare lo stato della view:`,e)}},ot=()=>{try{let e=localStorage.getItem(rt),t=localStorage.getItem(it);return{viewType:e||`timeGridWeek`,date:t?new Date(t):new Date}}catch(e){return console.error(`Errore nel leggere lo stato della view:`,e),{viewType:`timeGridWeek`,date:new Date}}},J=()=>{try{localStorage.removeItem(rt),localStorage.removeItem(it)}catch(e){console.error(`Errore nel pulire lo stato della view:`,e)}},st=t.Formio.Components.components.field,ct=({component:e,current:t,onChange:n,i18next:i})=>{let[o,s]=(0,a.useState)(null),[p,m]=(0,a.useState)(null),[h,ee]=(0,a.useState)([]),[g,_]=(0,a.useState)(!1),[v,y]=(0,a.useState)(!1),[b,x]=(0,a.useState)(null),[S,C]=(0,a.useState)([]),[w,T]=(0,a.useState)([]),[E,D]=(0,a.useState)([]),[O,k]=(0,a.useState)(null),[A,j]=(0,a.useState)(null),[te,N]=(0,a.useState)(null),P=(0,a.useRef)(null),F=(0,a.useRef)(null);i.language,c.default.locale(i.language),d.default.locale(i.language);function I(e){if(!e||e.length===0)return null;let t=e.map(e=>({start:e.start_time,end:e.end_time}));return{earliestStartTime:t.reduce((e,t)=>t.start<e?t.start:e,t[0].start),latestEndTime:t.reduce((e,t)=>t.end>e?t.end:e,t[0].end)}}function L(e){let t=e.map(e=>(0,c.default)(e.date).isoWeekday()),n=[1,2,3,4,5,6,7].filter(e=>!t.includes(e));n.length>0?F.current.setOption(`hiddenDays`,n):F.current.setOption(`hiddenDays`,[])}function R(e,t,n){let r=new URL(e),i=`${r.pathname.split(`/`).slice(0,4).join(`/`)}/${t}/${n}`;return`${r.origin}${i}${r.search}`}function ne(e,t,n){let r=new URL(e),i=`${r.pathname.split(`/`).slice(0,4).join(`/`)}`;return`${r.origin}${i}${r.search}&from_to=${t}&to_date=${n}`}function re(e,t,n){return`${M()}/api/availabilities/${e}/${t}?calendar_ids=${n}&available=true`}let z=e=>{D([]),T([]),n({}),e&&T((o??[]).filter(t=>t.date.startsWith(e)))},ie=async(e,t)=>{let r=JSON.parse(e),a=nt(`SLOTS`,r.date,r.calendar_ids);if(t===`manual`)D([]),N(null),x(null),n({});else{let e=tt(`SLOTS`,a);if(e){D(e);return}}try{let e=await window.FormioHelper.anonymousCall(`availabilities/${r.date}?calendar_ids=${r.calendar_ids}`),t=Array.isArray(e)?e:e?.data??[];et(`SLOTS`,a,t),D(t)}catch(e){console.error(`Errore nel caricamento degli slot:`,e),u.default.fire({icon:`error`,title:i.t(`Errore`),text:i.t(`Errore nel caricamento degli orari`)})}},ae=e=>{let r=JSON.parse(e),a={status:6,calendar:r.calendar_id,opening_hour:r.opening_hour_id,user:null,email:null,fiscal_code:null,name:` `,phone_number:null,from_time:(0,d.default)(`${r.date}T${r.start_time}`).toISOString(),to_time:(0,d.default)(`${r.date}T${r.end_time}`).toISOString(),user_message:null,reason:null,location:null,motivation_outcome:null,calendar_group_config_id:t?.data?.service_data?.id,calendar_group_office_id:t?.data?.user_group?.id,calendar_group_place_id:t?.data?.place?.id};window.FormioHelper.authenticatedRequest(t?.dataValue?.id?`PATCH`:`POST`,t?.dataValue?.id?`meetings/${t.dataValue.id}`:`meetings`,a).then(e=>{x({day:(0,d.default)(r.date).format(`dddd, DD MMMM YYYY`),startDate:r.start_time,endDate:r.end_time}),n(e?.id?e:e?{...e,id:t.dataValue.id}:t.dataValue.id?{...a,id:t.dataValue.id}:{...a})}).catch(e=>{console.error(e),e.status===400&&e?.response?.data?.type===`validation_error`?u.default.fire({title:``,html:`<p>`+i.t(`Lo slot orario selezionato non è disponibile perché già prenotato Seleziona un altro orario o una data diversa`)+`</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1}):u.default.fire({title:``,html:`<p>`+e+`</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1})})},oe=e=>{let t=new Set,n=[];return e.forEach(e=>{let r=(0,d.default)(e.date),i=r.format(`YYYY-MM`);t.has(i)||(t.add(i),n.push({value:i,label:r.format(`MMMM YYYY`).replace(/^\w/,e=>e.toUpperCase())}))}),n},se=async()=>{let e=t?.root?.data?.place?.merge_availabilities?t?.root?.data?.place?.merged_availabilities_link:null,r=(0,c.default)().format(`YYYY-MM-DD`),a=(0,c.default)().add(1,`month`).format(`YYYY-MM-DD`),o=t?.root?.data?.place?.calendars[0]?.id||null,l=e?ne(e,r,a):re(r,a,o),d=nt(`AVAILABILITY`,l),f=tt(`AVAILABILITY`,d);if(f){s(f),C(oe(f));return}else n({});_(!0);try{let e=await window.FormioHelper.fetchAPIUrlLimit(l);if(_(!1),!e?.length){u.default.fire({icon:`warning`,title:i.t(`warning`),html:i.t(`no_meetings`)});return}et(`AVAILABILITY`,d,e),s(e),C(oe(e))}catch(e){_(!1),console.error(`Errore nel caricamento disponibilità:`,e)}};(0,a.useEffect)(()=>{if(o?.length){let e=t?.dataValue??t?.getValue();if(e?.from_time&&e?.to_time&&!(0,d.default)().isAfter(e?.draft_expiration)){let t=(0,d.default)(e.from_time).format(`YYYY-MM`);k(t),t&&T&&(T(o.filter(e=>e.date.startsWith(t))),j((0,d.default)(e.from_time).format(`YYYY-MM-DD`)))}else e?.draft_expiration&&(0,d.default)().isAfter(e?.draft_expiration)&&u.default.fire({icon:`warning`,title:i.t(`warning`),html:i.t(`expired_meeting`)})}},[o]),(0,a.useEffect)(()=>{let e=t?.dataValue??t?.getValue();if(!S.length||O||e?.from_time||e?.to_time)return;let n=S[0];n&&(k(n.value),z(n.value))},[S,O,t?.dataValue]),(0,a.useEffect)(()=>{if(A&&v===!1){let e=t?.dataValue??t?.getValue();ie(JSON.stringify({date:A,calendar_ids:e.calendar.id}))}},[A]);let ce=()=>window.innerWidth>768?`timeGridWeek`:`timeGridDay`;(0,a.useEffect)(()=>{let e=()=>{let e=F.current;if(!e)return;let t=ce();t!==e.getView().type&&e.setOption(`view`,t)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,a.useEffect)(()=>{let e=t?.dataValue??t?.getValue();E?.length&&e?.from_time&&(N((0,d.default)(e.from_time).format(`HH:mm`)+` - `+(0,d.default)(e.to_time).format(`HH:mm`)),x({day:(0,d.default)(e.from_time).format(`dddd D MMM YYYY`),startDate:(0,d.default)(e.from_time).format(`HH:mm`),endDate:(0,d.default)(e.to_time).format(`HH:mm`)}))},[E]);let le=()=>{let e=ot();F.current=(0,f.createCalendar)(P.current,[f.TimeGrid],{events:[],buttonText:{today:i.t(`Oggi`)},allDaySlot:!1,firstDay:1,date:e.date,slotEventOverlap:!1,view:ce(),height:`400px`,views:{timeGridWeek:{allDaySlot:!1,firstDay:1,slotHeight:48},timeGridDay:{allDaySlot:!1,firstDay:1,slotHeight:48}},datesSet:e=>{at(e.view.type,e.start)},eventClick({event:e,el:r}){document.querySelectorAll(`.ec-event`).forEach(e=>{e.classList.remove(`highlighted-event`)}),r.classList.add(`highlighted-event`);let a=new Date(e.start),o=new Date(e.end),s=a.toLocaleDateString(`it-IT`,{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),c=a.toLocaleTimeString(`it-IT`,{hour:`2-digit`,minute:`2-digit`}),l=o.toLocaleTimeString(`it-IT`,{hour:`2-digit`,minute:`2-digit`}),d={status:6,calendar:e.extendedProps.calendar_id,opening_hour:e.extendedProps.opening_hour_id,user:null,email:null,fiscal_code:null,name:` `,phone_number:null,from_time:a,to_time:o,user_message:null,reason:null,location:null,motivation_outcome:null,calendar_group_config_id:t?.data?.service_data?.id,calendar_group_office_id:t?.data?.user_group?.id,calendar_group_place_id:t?.data?.place?.id};window.FormioHelper.authenticatedRequest(t?.dataValue?.id?`PATCH`:`POST`,t?.dataValue?.id?`meetings/${t.dataValue.id}`:`meetings`,d).then(e=>{let r;!e||e===``?r={...d,code:null,id:t?.dataValue?.id}:typeof e==`object`&&(r=e),x({day:s,startDate:c,endDate:l}),n(r)}).catch(e=>{console.error(e),e.status===400&&e?.response?.data?.type===`validation_error`?u.default.fire({title:``,html:`<p>`+i.t(`Lo slot orario selezionato non è disponibile perché già prenotato Seleziona un altro orario o una data diversa`)+`</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1}):u.default.fire({title:``,html:`<p>`+e+`</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1})})},viewDidMount:ue,eventDidMount:e=>{let{event:t,el:n}=e,r=t.extendedProps;n.setAttribute(`data-event-id`,t.id+`-`+r.date+`-`+r.start_time)},loading:e=>{_(e)}})},ue=e=>{t?.root?.data?.place&&F.current.setOption(`eventSources`,[{events:de}])};async function de(e,n,r){try{F.current.setOption(`events`,[]);let r=(0,c.default)(e.start).format(`YYYY-MM-DD`),a=new Date(e.end);a.setDate(a.getDate()-1);let o=(0,c.default)(a).format(`YYYY-MM-DD`),s=t?.root?.data?.place?.merge_availabilities?t?.root?.data?.place?.merged_availabilities_link:null,l=s?R(s,r,o):re(r,o,null),d=nt(`AVAILABILITY`,l),f=tt(`AVAILABILITY`,d),p;if(f?(p=f,_(!1)):(p=await window.FormioHelper.fetchAPIUrlLimit(l),et(`AVAILABILITY`,d,p)),!p?.length){n([]),u.default.fire({icon:`warning`,title:i.t(`warning`),html:i.t(`no_meetings`)});return}let m=p.map(e=>({id:e.opening_hour_id,allDay:!1,start:`${e.date}T${e.start_time}:00`,end:`${e.date}T${e.end_time}:00`,title:`${e.start_time} - ${e.end_time}`,editable:!1,display:`auto`,color:`#ebeef0`,textColor:`#000`,className:`event-slot`,extendedProps:{...e}})),h=I(p);F.current.setOption(`slotMinTime`,h.earliestStartTime),F.current.setOption(`slotMaxTime`,h.latestEndTime),L(p),Qe(F.current,m),n(m),setTimeout(()=>{fe(m)},500)}catch(e){console.error(`Errore nel caricamento disponibilità:`,e),r?.(e)}}(0,a.useEffect)(()=>{let r,a=!1;async function o(){try{if(await window.FormioInstance?.formReady,a)return;if(!P.current){console.warn(`Elemento calendario non trovato`);return}let r=t?.dataValue??t?.getValue();r&&r?.draft_expiration&&(0,d.default)().isAfter(r.draft_expiration)&&(n({}),J()),t?.data?.service_data?.view_type===`calendar`||e.view===`calendar`?F?.current||le():t?.data?.service_data?.view_type===`select`||e.view===`select`?se():alert(i.t(`Il componente non è configurato per la visualizzazione a calendario`))}catch(e){console.error(`Errore durante l'inizializzazione del calendario:`,e)}}return r=setTimeout(o,500),()=>{a=!0,r&&clearTimeout(r),F.current&&=(P.current?.destroy?.(),null)}},[t?.root?.data?.place]);function fe(e){let n=t?.dataValue;if(!n?.from_time)return;let r=(0,d.default)(n.from_time).format(`DD-MM-YYYY HH:mm`),i=(0,d.default)(n.to_time).format(`DD-MM-YYYY HH:mm`),a=e.find(e=>(0,d.default)(e.start).format(`DD-MM-YYYY HH:mm`)===r&&(0,d.default)(e.end).format(`DD-MM-YYYY HH:mm`)===i);if(!a)return;let o=document.querySelector(`.ec-event[data-event-id="${a.id}-${(0,d.default)(n?.from_time).format(`YYYY-MM-DD`)}-${(0,d.default)(n?.from_time).format(`HH:mm`)}"]`);o&&(o.classList.add(`highlighted-event`),o.scrollIntoView({behavior:`smooth`,block:`center`}),x({day:(0,d.default)(n?.from_time).format(`dddd, DD MMMM YYYY`),startDate:(0,d.default)(n?.from_time).format(`HH:mm`),endDate:(0,d.default)(n?.to_time).format(`HH:mm`)}))}return(0,a.useEffect)(()=>{document.querySelector(`.formio-read-only`)&&v===!1?y(!0):(t?.data?.service_data?.view_type===`select`?se():t?.data?.service_data?.view_type===`calendar`&&le(),y(!1))},[]),(0,a.useEffect)(()=>{v&&setTimeout(()=>{let e=t?.dataValue??t?.getValue();e&&m(e)},500)},[v]),(0,r.jsx)(r.Fragment,{children:v&&p?(0,r.jsxs)(`div`,{className:`mx-2`,children:[(0,r.jsxs)(`p`,{className:`text-paragraph`,children:[i.t(`Giorno selezionato per la prenotazione`),`:`]}),(0,r.jsx)(`div`,{className:``,children:(0,r.jsx)(`div`,{className:`it-list-wrapper`,children:(0,r.jsx)(`ul`,{className:`it-list`,children:(0,r.jsx)(Ze,{day:(0,d.default)(p.from_time).format(`dddd D MMM YYYY`),i18next:i,slot:`${(0,d.default)(p.from_time).format(`HH:mm`)} - ${(0,d.default)(p.to_time).format(`HH:mm`)}`})})})})]}):(0,r.jsxs)(`div`,{className:``,children:[(0,r.jsx)(`div`,{ref:P}),S.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(l.Select,{label:`Mese`,id:`selectMonthYear`,onChange:z,children:[(0,r.jsx)(`option`,{value:``,children:i.t(`Scegli un'opzione`)}),S.map(e=>(0,r.jsx)(`option`,{value:e.value,selected:e.value===O,children:e.label},e.value))]}),(0,r.jsxs)(l.Select,{label:`Giorno`,id:`selectDay`,onChange:e=>ie(e,`manual`),disabled:w.length===0,children:[(0,r.jsx)(`option`,{value:``,children:i.t(`Scegli un'opzione`)}),w.map(e=>(0,r.jsx)(`option`,{value:JSON.stringify(e),selected:e.date===A,children:(0,d.default)(e.date).format(`dddd,DD MMMM YYYY`)},e.date))]}),(0,r.jsxs)(l.Select,{label:`Orario`,id:`selectSlot`,onChange:ae,disabled:E.length===0,children:[(0,r.jsx)(`option`,{value:``,children:i.t(`Scegli un'opzione`)}),E.map(e=>(0,r.jsx)(`option`,{value:JSON.stringify(e),selected:e.start_time+` - `+e.end_time===te,children:e.start_time+` - `+e.end_time},e.start_time+` - `+e.end_time))]})]}):null,b?(({day:e,startDate:t,endDate:n})=>(0,r.jsx)(`div`,{className:`mt-3`,children:(0,r.jsxs)(`div`,{className:`row align-items-center gy-3`,children:[(0,r.jsxs)(`div`,{className:`col-12 col-md border-light mx-md-3`,children:[(0,r.jsx)(`div`,{className:`text-paragraph-small`,children:i.t(`Data`)}),(0,r.jsx)(`p`,{className:`data-text`,children:(0,r.jsx)(`strong`,{children:e})})]}),(0,r.jsxs)(`div`,{className:`col-12 col-md border-light mx-md-3`,children:[(0,r.jsx)(`div`,{className:`text-paragraph-small`,children:i.t(`Ora`)}),(0,r.jsx)(`p`,{className:`data-text`,children:(0,r.jsxs)(`strong`,{children:[t,` - `,n]})})]})]})}))({day:b.day,startDate:b.startDate,endDate:b.endDate}):null,g?(0,r.jsx)(`div`,{className:`d-flex align-items-center justify-content-center position-absolute-center`,children:(0,r.jsx)(l.Spinner,{active:!0})}):null]})})},lt=class e extends st{constructor(e,t,n){super(e,t,n)}static get builderInfo(){return{title:`Calendar Advanced`,group:`basic`,icon:`bi bi-calendar-plus`,documentation:``,weight:70,schema:e.schema()}}static schema(){return st.schema({type:`calendar-advanced`})}static editForm=Xe;attach(e,t){return super.attach(e).then(()=>{this.loadRefs(this.element,{[`react-${this.id}`]:`single`});let e=this.refs[`react-${this.id}`];return e?(this.rootComponent&&=(this.rootComponent.unmount(),null),this.rootComponent=(0,n.createRoot)(e),this.builderMode?(this.rootComponent.render((0,r.jsx)(`div`,{className:`my-1 border border-2 border-light rounded p-3 text-secondary`,children:(0,r.jsx)(`div`,{className:`h6 mb-0`,children:this.component?.label||`Calendar Advanced`})})),this):(this.rootComponent.render((0,r.jsx)(ct,{ref:t,component:this.component,value:this.dataValue,onChange:e=>this.setValue(e),...this,current:this})),this)):this})}detach(){return this.rootComponent&&=(this.rootComponent.unmount(),null),super.detach()}setValue(e){e&&(this.updateValue(e),this.shouldSetValue=!0)}getValue(){return this.dataValue}init(){super.init()}render(){return super.render(`<div ref="react-${this.id}"></div>`)}},ut=[{key:`defaultValue`,ignore:!0}],dt=[{key:`placeholder`,ignore:!0},{type:`checkbox`,label:`Files Synchronization feature`,tooltip:`Enable ability to control files synchronization. Files will be auto synced before submit.`,key:`autoSync`,input:!0,conditional:{json:{in:[{var:`data.storage`},[`s3`,`azure`,`googledrive`]]}}}],ft=[{type:`select`,input:!0,key:`storage`,label:`Storage`,placeholder:`Select your file storage provider`,weight:0,tooltip:`Which storage to save the files in.`,valueProperty:`value`,dataSrc:`custom`,hidden:!0,data:{custom:function(){return[{label:`url`,value:`url`}]}}},{type:`checkbox`,input:!0,defaultValue:!0,key:`protocol_required`,label:`Richiede protocollazione?`,tooltip:``,weight:10},{type:`checkbox`,input:!0,defaultValue:!1,key:`check_signature`,label:`Effettuare il controllo della firma?`,tooltip:``,weight:15},{type:`checkbox`,input:!0,key:`useMultipartUpload`,label:`Use the S3 Multipart Upload API`,tooltip:`The <a href='https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html'>S3 Multipart Upload API</a> is designed to improve the upload experience for larger objects (> 5GB).`,conditional:{json:{"===":[{var:`data.storage`},`s3`]}}},{label:`Multipart Upload`,tableView:!1,key:`multipart`,type:`container`,input:!0,components:[{label:`Part Size (MB)`,applyMaskOn:`change`,mask:!1,tableView:!1,delimiter:!1,requireDecimal:!1,inputFormat:`plain`,truncateMultipleSpaces:!1,validate:{min:5,max:5e3},key:`partSize`,type:`number`,input:!0,defaultValue:500}],conditional:{json:{"===":[{var:`data.useMultipartUpload`},!0]}}},{type:`textfield`,input:!0,key:`options.indexeddb`,label:`Database`,weight:10,placeholder:`Enter the indexeddb database name`,conditional:{json:{in:[{var:`data.storage`},[`indexeddb`]]}}},{type:`textfield`,input:!0,label:`Table`,key:`options.indexeddbTable`,weight:10,placeholder:`Enter the name for indexeddb table`,conditional:{json:{in:[{var:`data.storage`},[`indexeddb`]]}}},{type:`textarea`,key:`options`,label:`Custom request options`,tooltip:`Pass your custom xhr options(optional)`,rows:5,editor:`ace`,input:!0,weight:15,placeholder:`{
68
68
  "withCredentials": true,
69
69
  "headers": {
70
70
  "Authorization": "Basic <key>"
71
71
  }
72
- }`,conditional:{json:{"===":[{var:`data.storage`},`url`]}}},{type:`textfield`,input:!0,key:`fileKey`,label:`File form-data key`,weight:17,placeholder:`Enter the key name of a file for form data.`,tooltip:`Key name that you would like to modify for the file while calling API request.`,conditional:{json:{"===":[{var:`data.storage`},`url`]}}},{type:`textfield`,input:!0,key:`dir`,label:`Directory`,placeholder:`(optional) Enter a directory for the files`,tooltip:`This will place all the files uploaded in this field in the directory`,weight:20,conditional:{json:{"!==":[{var:`data.storage`},`googledrive`]}}},{type:`textfield`,input:!0,key:`dir`,label:`Folder ID`,placeholder:`(optional) Enter an ID of the folder for the files`,tooltip:`This will place all the files uploaded in this field in the folder`,weight:20,conditional:{json:{"===":[{var:`data.storage`},`googledrive`]}}},{type:`textfield`,input:!0,key:`fileNameTemplate`,label:`File Name Template`,placeholder:`(optional) { {name} }-{ {guid} }"`,tooltip:"Specify template for name of uploaded file(s). Regular template variables are available (`data`, `component`, `user`, `value`, `moment` etc.), also `fileName`, `guid` variables are available. `guid` part must be present, if not found in template, will be added at the end.",weight:25},{type:`checkbox`,input:!0,key:`image`,label:`Display as image(s)`,tooltip:`Instead of a list of linked files, images will be rendered in the view.`,weight:30},{type:`checkbox`,input:!0,key:`uploadOnly`,label:`Upload Only`,tooltip:`When this is checked, will only allow you to upload file(s) and consequently the download, in this component, will be unavailable.`,weight:33},{type:`checkbox`,input:!0,key:`privateDownload`,label:`Private Download`,tooltip:`When this is checked, the file download will send a POST request to the download URL with the x-jwt-token header. This will allow your endpoint to create a Private download system.`,weight:31,conditional:{json:{"===":[{var:`data.storage`},`url`]}}},{type:`textfield`,input:!0,key:`imageSize`,label:`Image Size`,placeholder:`100`,tooltip:`The image size for previewing images.`,weight:40,conditional:{json:{"==":[{var:`data.image`},!0]}}},{type:`textfield`,input:!0,key:`maxFiles`,label:`Numero massimo di file`,placeholder:`100`,tooltip:`Numero massimo di file caricabilii, default è 100.`,weight:40},{type:`checkbox`,input:!0,key:`webcam`,label:`Enable web camera`,tooltip:`This will allow using an attached camera to directly take a picture instead of uploading an existing file.`,weight:32},{type:`textfield`,input:!0,key:`webcamSize`,label:`Webcam Width`,placeholder:`320`,tooltip:`The webcam size for taking pictures.`,weight:38,conditional:{json:{"==":[{var:`data.webcam`},!0]}}},{type:`datagrid`,input:!0,label:`File Types`,key:`fileTypes`,tooltip:`Specify file types to classify the uploads. This is useful if you allow multiple types of uploads but want to allow the user to specify which type of file each is.`,weight:11,components:[{label:`Label`,key:`label`,input:!0,type:`textfield`},{label:`Value`,key:`value`,input:!0,type:`textfield`}]},{type:`textfield`,input:!0,key:`filePattern`,label:`File Pattern`,placeholder:`.jpg,video/*,application/pdf`,tooltip:`See <a href='https://github.com/danialfarid/ng-file-upload#full-reference' target='_blank'>https://github.com/danialfarid/ng-file-upload#full-reference</a> for how to specify file patterns.`,weight:50},{type:`textfield`,input:!0,key:`fileMinSize`,label:`File Minimum Size`,placeholder:`1MB`,tooltip:`See <a href='https://github.com/danialfarid/ng-file-upload#full-reference' target='_blank'>https://github.com/danialfarid/ng-file-upload#full-reference</a> for how to specify file sizes.`,weight:60},{type:`textfield`,input:!0,key:`fileMaxSize`,label:`File Maximum Size`,placeholder:`10MB`,tooltip:`See <a href='https://github.com/danialfarid/ng-file-upload#full-reference' target='_blank'>https://github.com/danialfarid/ng-file-upload#full-reference</a> for how to specify file sizes.`,weight:70},{type:`textfield`,input:!0,key:`maxFiles`,label:`Numero massimo di file`,placeholder:`100`,tooltip:`Numero massimo di file caricabilii, default è 100.`,weight:40}],pt=[{key:`unique`,ignore:!0},{key:`validateOn`,ignore:!0}];function mt(...e){return i.Components.baseEditForm([{key:`display`,components:dt},{key:`data`,components:ut},{label:`File`,key:`file`,weight:5,components:ft},{key:`validation`,components:pt}],...e)}var ht=E(((e,t)=>{t.exports=Array.isArray})),gt=E(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),_t=E(((e,t)=>{var n=gt(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),vt=E(((e,t)=>{t.exports=_t().Symbol})),yt=E(((e,t)=>{var n=vt(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),bt=E(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),xt=E(((e,t)=>{var n=vt(),r=yt(),i=bt(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),St=E(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),Ct=E(((e,t)=>{var n=xt(),r=St(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),wt=E(((e,t)=>{var n=ht(),r=Ct(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;function o(e,t){if(n(e))return!1;var o=typeof e;return o==`number`||o==`symbol`||o==`boolean`||e==null||r(e)?!0:a.test(e)||!i.test(e)||t!=null&&e in Object(t)}t.exports=o})),Tt=E(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),Et=E(((e,t)=>{var n=xt(),r=Tt(),i=`[object AsyncFunction]`,a=`[object Function]`,o=`[object GeneratorFunction]`,s=`[object Proxy]`;function c(e){if(!r(e))return!1;var t=n(e);return t==a||t==o||t==i||t==s}t.exports=c})),Dt=E(((e,t)=>{t.exports=_t()[`__core-js_shared__`]})),Ot=E(((e,t)=>{var n=Dt(),r=function(){var e=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function i(e){return!!r&&r in e}t.exports=i})),kt=E(((e,t)=>{var n=Function.prototype.toString;function r(e){if(e!=null){try{return n.call(e)}catch{}try{return e+``}catch{}}return``}t.exports=r})),At=E(((e,t)=>{var n=Et(),r=Ot(),i=Tt(),a=kt(),o=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,u=c.toString,d=l.hasOwnProperty,f=RegExp(`^`+u.call(d).replace(o,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function p(e){return!i(e)||r(e)?!1:(n(e)?f:s).test(a(e))}t.exports=p})),jt=E(((e,t)=>{function n(e,t){return e?.[t]}t.exports=n})),Mt=E(((e,t)=>{var n=At(),r=jt();function i(e,t){var i=r(e,t);return n(i)?i:void 0}t.exports=i})),Nt=E(((e,t)=>{t.exports=Mt()(Object,`create`)})),Pt=E(((e,t)=>{var n=Nt();function r(){this.__data__=n?n(null):{},this.size=0}t.exports=r})),Ft=E(((e,t)=>{function n(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}t.exports=n})),It=E(((e,t)=>{var n=Nt(),r=`__lodash_hash_undefined__`,i=Object.prototype.hasOwnProperty;function a(e){var t=this.__data__;if(n){var a=t[e];return a===r?void 0:a}return i.call(t,e)?t[e]:void 0}t.exports=a})),Lt=E(((e,t)=>{var n=Nt(),r=Object.prototype.hasOwnProperty;function i(e){var t=this.__data__;return n?t[e]!==void 0:r.call(t,e)}t.exports=i})),Rt=E(((e,t)=>{var n=Nt(),r=`__lodash_hash_undefined__`;function i(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=n&&t===void 0?r:t,this}t.exports=i})),zt=E(((e,t)=>{var n=Pt(),r=Ft(),i=It(),a=Lt(),o=Rt();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),Bt=E(((e,t)=>{function n(){this.__data__=[],this.size=0}t.exports=n})),Vt=E(((e,t)=>{function n(e,t){return e===t||e!==e&&t!==t}t.exports=n})),Ht=E(((e,t)=>{var n=Vt();function r(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}t.exports=r})),Ut=E(((e,t)=>{var n=Ht(),r=Array.prototype.splice;function i(e){var t=this.__data__,i=n(t,e);return i<0?!1:(i==t.length-1?t.pop():r.call(t,i,1),--this.size,!0)}t.exports=i})),Wt=E(((e,t)=>{var n=Ht();function r(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}t.exports=r})),Gt=E(((e,t)=>{var n=Ht();function r(e){return n(this.__data__,e)>-1}t.exports=r})),Kt=E(((e,t)=>{var n=Ht();function r(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}t.exports=r})),qt=E(((e,t)=>{var n=Bt(),r=Ut(),i=Wt(),a=Gt(),o=Kt();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),Jt=E(((e,t)=>{t.exports=Mt()(_t(),`Map`)})),Yt=E(((e,t)=>{var n=zt(),r=qt(),i=Jt();function a(){this.size=0,this.__data__={hash:new n,map:new(i||r),string:new n}}t.exports=a})),Xt=E(((e,t)=>{function n(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}t.exports=n})),Zt=E(((e,t)=>{var n=Xt();function r(e,t){var r=e.__data__;return n(t)?r[typeof t==`string`?`string`:`hash`]:r.map}t.exports=r})),Qt=E(((e,t)=>{var n=Zt();function r(e){var t=n(this,e).delete(e);return this.size-=t?1:0,t}t.exports=r})),$t=E(((e,t)=>{var n=Zt();function r(e){return n(this,e).get(e)}t.exports=r})),en=E(((e,t)=>{var n=Zt();function r(e){return n(this,e).has(e)}t.exports=r})),tn=E(((e,t)=>{var n=Zt();function r(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}t.exports=r})),nn=E(((e,t)=>{var n=Yt(),r=Qt(),i=$t(),a=en(),o=tn();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),rn=E(((e,t)=>{var n=nn(),r=`Expected a function`;function i(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(r);var a=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=a.cache;if(i.has(r))return i.get(r);var o=e.apply(this,n);return a.cache=i.set(r,o)||i,o};return a.cache=new(i.Cache||n),a}i.Cache=n,t.exports=i})),an=E(((e,t)=>{var n=rn(),r=500;function i(e){var t=n(e,function(e){return i.size===r&&i.clear(),e}),i=t.cache;return t}t.exports=i})),on=E(((e,t)=>{var n=an(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g;t.exports=n(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(r,function(e,n,r,a){t.push(r?a.replace(i,`$1`):n||e)}),t})})),sn=E(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}t.exports=n})),cn=E(((e,t)=>{var n=vt(),r=sn(),i=ht(),a=Ct(),o=1/0,s=n?n.prototype:void 0,c=s?s.toString:void 0;function l(e){if(typeof e==`string`)return e;if(i(e))return r(e,l)+``;if(a(e))return c?c.call(e):``;var t=e+``;return t==`0`&&1/e==-o?`-0`:t}t.exports=l})),ln=E(((e,t)=>{var n=cn();function r(e){return e==null?``:n(e)}t.exports=r})),un=E(((e,t)=>{var n=ht(),r=wt(),i=on(),a=ln();function o(e,t){return n(e)?e:r(e,t)?[e]:i(a(e))}t.exports=o})),dn=E(((e,t)=>{var n=Ct(),r=1/0;function i(e){if(typeof e==`string`||n(e))return e;var t=e+``;return t==`0`&&1/e==-r?`-0`:t}t.exports=i})),Y=E(((e,t)=>{var n=un(),r=dn();function i(e,t){t=n(t,e);for(var i=0,a=t.length;e!=null&&i<a;)e=e[r(t[i++])];return i&&i==a?e:void 0}t.exports=i})),fn=E(((e,t)=>{var n=Y();function r(e,t,r){var i=e==null?void 0:n(e,t);return i===void 0?r:i}t.exports=r})),pn=E(((e,t)=>{var n=Mt();t.exports=function(){try{var e=n(Object,`defineProperty`);return e({},``,{}),e}catch{}}()})),mn=E(((e,t)=>{var n=pn();function r(e,t,r){t==`__proto__`&&n?n(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}t.exports=r})),hn=E(((e,t)=>{var n=mn(),r=Vt(),i=Object.prototype.hasOwnProperty;function a(e,t,a){var o=e[t];(!(i.call(e,t)&&r(o,a))||a===void 0&&!(t in e))&&n(e,t,a)}t.exports=a})),gn=E(((e,t)=>{var n=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function i(e,t){var i=typeof e;return t??=n,!!t&&(i==`number`||i!=`symbol`&&r.test(e))&&e>-1&&e%1==0&&e<t}t.exports=i})),_n=E(((e,t)=>{var n=hn(),r=un(),i=gn(),a=Tt(),o=dn();function s(e,t,s,c){if(!a(e))return e;t=r(t,e);for(var l=-1,u=t.length,d=u-1,f=e;f!=null&&++l<u;){var p=o(t[l]),m=s;if(p===`__proto__`||p===`constructor`||p===`prototype`)return e;if(l!=d){var h=f[p];m=c?c(h,p,f):void 0,m===void 0&&(m=a(h)?h:i(t[l+1])?[]:{})}n(f,p,m),f=f[p]}return e}t.exports=s})),vn=O(E(((e,t)=>{var n=_n();function r(e,t,r){return e==null?e:n(e,t,r)}t.exports=r}))(),1),yn=O(fn(),1);document.documentElement.lang.toString();var bn=class{constructor(){this.token=null,this.basePath=null,this.init()}init(){this.token=null,this.basePath=M()}async getSessionAuthToken(){let e=this;await m.default.get(e.basePath+`/api/session-auth`).then(t=>{e.token=t.data.token}).catch(e=>{u.default.fire(`'error_message_detail`,`'auth_error'`,`error`)})}getSessionAuthTokenPromise(){let e=this;return new Promise(async(t,n)=>{U(`auth-token`)?t({token:U(`auth-token`)}):await m.default.get(e.basePath+`/api/session-auth?with-cookie=true`,{withCredentials:!0,headers:{"Content-Type":`application/json; charset=utf-8`}}).then(e=>{let t=(0,g.jwtDecode)(e.data.token);t.exp&&W(`auth-token`,e.data.token,t.exp)}).catch(e=>{console.log(e)})})}getToken(){return this.token}execAuthenticatedCall(e){this.token?e(this.token):this.getSessionAuthTokenPromise().then(t=>{this.token=t.token,e(this.token)})}},xn=t.Formio.Components.components.file,Sn=null;document.querySelector(`widget-formio`)!==null&&(Sn=document.querySelector(`widget-formio`).getAttribute(`signature-check-ws-url`));var Cn=({component:e,current:t,onChange:n,i18next:i})=>{let[o,s]=(0,a.useState)([]),[c,d]=(0,a.useState)(new Map),[f,g]=(0,a.useState)(!1),_=new bn;(0,a.useEffect)(()=>{_.getSessionAuthTokenPromise()},[]);let v=(e,t)=>{d(n=>{let r=new Map(n);return r.set(e,{...t,progress:Number(t?.progress)||0}),r})};function y(t){return t.size>(A(e.fileMaxSize)||A(`1GB`))?{code:`size-files`,message:`${i.t(`I file non possono superare le dimensioni di`)} ${e.fileMaxSize?e.fileMaxSize:`1GB`}`}:o.length>=(e.maxFiles?parseInt(e.maxFiles):e.multiple?100:1)?{code:`too-many-files`,message:`${i.t(`Puoi caricare massimo `)} ${e.maxFiles||100} ${i.t(`file`)}`}:t.size<A(e.fileMinSize)?{code:`file-too-small`,message:`${i.t(`I file devono avare una dimensione superiore a `)} ${e.fileMinSize}`}:null}function b(){if(e.filePattern){let t=e.filePattern.split(`,`).map(e=>e.trim()).filter(Boolean).reduce((e,t)=>{let n=t.startsWith(`.`)?t:`.${t}`,r=h.default.getType(n);return r?(e[r]||(e[r]=[]),e[r].push(n),e):e},{});return Object.keys(t).length?t:void 0}else return!0}let x=e=>{let t={};return t.originalName=e.originalName?e.originalName:e.name,t.name=e.name,t.url=e.url,t.data=e.data,t.signature_validation=e.signature_validation,t.mime_type=e.mime_type,t.storage=`url`,t.size=e.size,t},{getRootProps:S,getInputProps:C,fileRejections:w,isDragActive:T,open:E}=(0,p.useDropzone)({onDrop:e=>{e.map(e=>{k(e).then(e=>{})})},maxFiles:e.maxFiles?parseInt(e.maxFiles)-o.length:e.multiple?100:1,validator:y,accept:b()}),D=e=>{let t=M()+`/api/attachments/`+e.data.id;fetch(t,{method:`DELETE`,headers:{"Content-Type":`application/json; charset=utf-8`,Authorization:`Bearer ${U(`auth-token`)}`},strictErrors:!0}).then(()=>{s(t=>{let r=t.filter(t=>t.data.id!==e.data.id);return n(r),r})}).catch(e=>{u.default.fire({title:``,html:`<p>${i.t(`Ci sono stati degli errori durante l'eliminazione del file`)}</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1}),console.error(e)})},O=()=>{let e=typeof t?.getCurrentValue==`function`?t.getCurrentValue():t?.dataValue;e?.length>0&&(s(e),setTimeout(()=>{n(e)},100))};(0,a.useEffect)(()=>{document.querySelector(`.formio-read-only`)&&f===!1?(g(!0),setTimeout(()=>{O()},1e3)):(g(!1),setTimeout(()=>{O()},1e3))},[]);async function k(r){let a,o=M()+`/it/upload`,c={mime_type:r.type,name:r.name,original_filename:r.name,protocol_required:e.protocol_required,size:r.size};return await m.default.post(o,c,{maxContentLength:1/0,maxBodyLength:1/0}).then(async o=>(a=o.data.id,r.url=M()+`/it/allegati/`+a,r.storage=`url`,r.mime_type=r.type,r.protocol_required=e.protocol_required,r.data={...o.data,baseUrl:M()+`/it/allegati/`+a},v(a,r),await m.default.put(o.data.uri,r,{onUploadProgress:e=>{let t=Math.round(e.loaded*100/e.total);d(e=>{let n=new Map(e),i=r;return i.progress=parseInt(t),n.has(a)&&n.set(a,i),n})},maxContentLength:1/0,maxBodyLength:1/0,headers:{"Content-Type":`multipart/form-data`}}).then(async o=>{let c=o.headers.etag.replace(/\\|"/gi,``)||null;return await m.default.put(M()+`/it/upload/`+a,{file_hash:c,check_signature:e.check_signature}).then(async i=>{d(e=>{let t=new Map(e);return t.delete(a),t});let o=t.dataValue||[],c=null;if(s(e=>{let t=[...e,x(r)];return c=t.length-1,n(t),t}),e.check_signature&&i.data.url&&Sn)return await m.default.post(Sn,{url:i.data.url,content:null},{headers:{"Content-Type":`application/json`}}).then(e=>{r.signature_validation=e.data.sign,o[c].signature_validation=e.data.sign}).catch(e=>{o[c].signature_validation=`File validation error: `+e});d(e=>{let t=new Map(e);return t.delete(a),t})}).catch(e=>{d(e=>{let t=new Map(e);return t.delete(a),t}),console.log(e),u.default.fire({title:``,html:`<p>${i.t(`Ci sono stati degli errori dutante il caricamento dei file, riprova più tardi!`)}</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1})})}).catch(e=>{d(e=>{let t=new Map(e);return t.delete(a),t}),console.log(e),u.default.fire({title:``,html:`<p>${i.t(`Ci sono stati degli errori dutante il caricamento dei file, riprova più tardi!`)}</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1})}))).catch(e=>{console.log(e),u.default.fire({title:``,html:`<p>${i.t(`Ci sono stati degli errori dutante il caricamento dei file, riprova più tardi!`)}</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1}),d(e=>{let t=new Map(e);return t.delete(a),t})})}function A(e){if(typeof e==`string`){if(e.search(/kb/i)===e.length-2)return parseFloat(e.substring(0,e.length-2)*1024);if(e.search(/mb/i)===e.length-2)return parseFloat(e.substring(0,e.length-2)*1024*1024);if(e.search(/gb/i)===e.length-2)return parseFloat(e.substring(0,e.length-2)*1024*1024*1024);if(e.search(/b/i)===e.length-1||e.search(/s/i)===e.length-1)return parseFloat(e.substring(0,e.length-1));if(e.search(/m/i)===e.length-1)return parseFloat(e.substring(0,e.length-1)*60);if(e.search(/h/i)===e.length-1)return parseFloat(e.substring(0,e.length-1)*3600)}return e}function j(e,t=2){if(!+e)return`0 Bytes`;let n=1024,r=t<0?0:t,i=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],a=Math.floor(Math.log(e)/Math.log(n));return`${parseFloat((e/n**+a).toFixed(r))} ${i[a]}`}return t.conditionallyHidden()||t.visible===!1?null:(0,r.jsx)(r.Fragment,{children:f?(0,r.jsxs)(`div`,{children:[(0,r.jsxs)(`label`,{className:`col-form-label floating-label`,htmlFor:`${e.id}-${e.key}`,children:[e.label,e.validate.required&&(0,r.jsx)(`span`,{className:`text-danger`})]}),(0,r.jsxs)(`ul`,{className:`upload-file-list`,children:[o.map((e,t)=>(0,r.jsxs)(`li`,{className:`upload-file success mw-100`,children:[(0,r.jsx)(l.Icon,{"aria-hidden":`true`,color:`primary`,icon:`it-file`,title:`Icona file`,size:`sm`}),(0,r.jsxs)(`p`,{children:[(0,r.jsx)(`span`,{className:`visually-hidden`,children:i.t(`File caricato:`)}),e.name,(0,r.jsx)(`span`,{className:`upload-file-weight`,children:j(e.size)})]})]},e.size+t)),o.length<1&&(0,r.jsxs)(`li`,{className:`upload-file text-secondary mw-100`,children:[(0,r.jsx)(l.Icon,{"aria-hidden":`true`,color:`light`,icon:`it-files`,title:`Icona file`,size:`sm`}),(0,r.jsx)(`p`,{children:i.t(`Nessun elemento`)})]})]})]}):(0,r.jsxs)(r.Fragment,{children:[e.hideLabel||e.hidden?``:(0,r.jsxs)(`label`,{className:`col-form-label floating-label`,htmlFor:`${e.id}-${e.key}`,title:e.tooltip||void 0,children:[e.label,e.validate.required&&(0,r.jsx)(`span`,{className:`text-danger`}),e.tooltip&&(0,r.jsx)(`i`,{tabIndex:0,className:`bi bi-question-circle text-muted ms-1`,"data-tooltip":e.tooltip,"aria-expanded":`false`})]}),(0,r.jsxs)(`div`,{className:`my-1 border-2 border-light file-uploader-box rounded p-3 text-secondary${T?` dragover`:``}`,style:{border:`dashed`},...S({onClick:e=>e.stopPropagation()}),children:[(0,r.jsx)(`input`,{id:`${e.id}-${e.key}`,"aria-describedby":`file-uploader-description-${e.id}-${e.key}`,...C()}),(0,r.jsxs)(`div`,{className:`upload-dragdrop${T?` dragover`:``}`,children:[(0,r.jsx)(`div`,{className:`ms-1 me-3`,children:(0,r.jsx)(l.Icon,{color:`secondary`,icon:`it-upload`,title:i.t(`Carica file`),size:`_sm`})}),(0,r.jsxs)(`div`,{className:`upload-dragdrop-text`,children:[(0,r.jsx)(`div`,{className:`h5`,id:`file-uploader-description-${e.id}-${e.key}`,children:i.t(`Trascina il file per caricarlo`)}),(0,r.jsxs)(`p`,{className:`d-inline-flex`,children:[i.t(`oppure`),(0,r.jsx)(l.Button,{tag:`input`,type:`button`,value:i.t(`selezionalo dal dispositivo`),onClick:E,className:`px-1 py-0 text-decoration-underline primary-color`,size:`xs`})]})]})]})]}),(0,r.jsx)(`div`,{dangerouslySetInnerHTML:{__html:ee.default.sanitize(e.description||``)}}),(0,r.jsxs)(`ul`,{className:`upload-file-list my-0`,children:[o.map((e,t)=>(0,r.jsxs)(`li`,{className:`upload-file success`,children:[(0,r.jsx)(l.Icon,{"aria-hidden":`true`,color:`primary`,icon:`it-file`,title:`Icona file`,size:`sm`}),(0,r.jsxs)(`p`,{children:[(0,r.jsx)(`span`,{className:`visually-hidden`,children:i.t(`File caricato:`)}),e.name,(0,r.jsx)(`span`,{className:`upload-file-weight`,children:j(e.size)})]}),(0,r.jsx)(l.Button,{className:`px-1`,onClick:()=>D(e),children:(0,r.jsx)(l.Icon,{title:`${i.t(`Elimina file caricato`)} ${e.name}`,color:`secondary`,icon:`it-delete`,className:`ms-auto pointer`,size:`sm`})})]},e.size+t)),Array.from(c.entries()).map(([e,t])=>(0,r.jsxs)(`li`,{className:`upload-file success`,children:[(0,r.jsx)(l.Icon,{"aria-hidden":`true`,color:`primary`,icon:`it-file`,title:`Icona file`,size:`sm`}),(0,r.jsxs)(`p`,{children:[(0,r.jsx)(`span`,{className:`visually-hidden`,children:i.t(`Caricamento file:`)}),t.name,(0,r.jsx)(`span`,{className:`upload-file-weight`,children:j(t.size)})]}),(0,r.jsx)(l.Progress,{value:Number(t?.progress)||0})]},e))]}),!!(w&&w.length)&&(0,r.jsx)(`div`,{className:`formio-error-wrapper`,children:(0,r.jsx)(`ul`,{className:`formio-errors upload-file-list my-0 `,children:w.map(({file:t,errors:n},a)=>(0,r.jsxs)(`li`,{className:`upload-file error`,children:[(0,r.jsxs)(`div`,{className:`upload-file-name-error-wrapper`,children:[(0,r.jsx)(l.Icon,{"aria-hidden":`true`,color:`error`,icon:`it-error`,title:`Icona file`,size:`sm`}),(0,r.jsxs)(`p`,{className:`text-wrap error`,children:[(0,r.jsx)(`span`,{className:`visually-hidden`,children:i.t(`Errore caricamento file:`)}),t.name,(0,r.jsx)(`span`,{className:`upload-file-weight`,children:j(t.size)})]})]}),(0,r.jsx)(`div`,{children:n.map(t=>t.code===`file-invalid-type`?(0,r.jsxs)(`p`,{className:`text-wrap ms-0`,children:[i.t(`I file possono essere di tipo `),e.filePattern]}):t.code===`too-many-files`?(0,r.jsxs)(`p`,{className:`text-wrap ms-0`,children:[i.t(`Puoi caricare massimo `),` `,e.maxFiles?e.maxFiles:e.multiple?100:1,` `,i.t(`file`)]}):(0,r.jsx)(`p`,{className:`text-wrap ms-0`,children:t.message}))})]},t.size+a))})})]})})},wn=class e extends xn{constructor(e,t,n){super({...e,clearOnHide:!1},t,n),this.reactRef=null,this.lastRenderedVisible=void 0,this.rootComponent=null,this.mountNode=null}static get builderInfo(){return{title:`File Sdc`,group:`basic`,icon:`bi bi-file-earmark-text`,documentation:``,weight:70,schema:e.schema()}}get emptyValue(){return[]}init(){if(super.init(),this.component?.multiple&&!Array.isArray(this.getCurrentValue())){this.dataValue=[];let e=this.path||this.component?.key;e&&this.rootValue&&(0,vn.default)(this.rootValue,e,[])}}static schema(){return xn.schema({type:`sdcfile`,modelType:`array`})}static editForm=mt;getI18next(){return this.i18next&&typeof this.i18next.t==`function`?this.i18next:{language:this.options?.language||document?.documentElement?.lang||`it`,t:(e,t)=>this.t(e,t)}}hideFileProcessingLoader(){this.refs?.fileProcessingLoader&&(this.refs.fileProcessingLoader.style.display=`none`)}renderReact(){if(this.rootComponent){if(this.builderMode){this.rootComponent.render((0,r.jsx)(`div`,{className:`my-1 border border-2 border-light file-uploader-box rounded p-3 text-secondary`,children:(0,r.jsx)(`div`,{className:`upload-dragdrop`,children:(0,r.jsx)(`div`,{className:`upload-dragdrop-text`,children:(0,r.jsx)(`div`,{className:`h6 mb-0`,children:this.component?.label||`File Sdc`})})})}));return}this.rootComponent.render((0,r.jsx)(Cn,{component:this.component,current:this,i18next:this.getI18next(),onChange:e=>this.updateValueFromReact(e)}))}}attach(e){let t=super.attach(e);this.hideFileProcessingLoader();let r=`react-${this.id}`;this.loadRefs(e,{[r]:`single`});let i=this.refs[r];return i?(this.rootComponent&&this.mountNode!==i&&(this.rootComponent.unmount(),this.rootComponent=null),this.rootComponent||=(0,n.createRoot)(i),this.mountNode=i,this.lastRenderedVisible=this.visible,this.renderReact(),t):t}updateValueFromReact(e,t={modified:!0}){let n=this.normalizeValue(e,t),r=this.updateValue(n,t),i=this.path||this.component?.key;if(i&&this.rootValue){let e=(0,yn.default)(this.rootValue,i);this.isEqual(e,n)||(0,vn.default)(this.rootValue,i,n)}return r}setValue(e,t={}){let n=this.normalizeValue(e,t),r=super.setValue(n,t),i=this.path||this.component?.key;if(i&&this.rootValue){let e=(0,yn.default)(this.rootValue,i);this.isEqual(e,n)||(0,vn.default)(this.rootValue,i,n)}return r}normalizeValue(e,t={}){let n=super.normalizeValue(e,t);return!this.component?.multiple||Array.isArray(n)?n:n==null||n===``?[]:[n]}detach(){return this.hideFileProcessingLoader(),this.rootComponent&&=(this.rootComponent.unmount(),null),this.mountNode=null,super.detach()}getValue(){return this.getCurrentValue()}get validationValue(){return this.getCurrentValue()}getCurrentValue(){let e=super.getValue(),t=this.path||this.component?.key,n=t&&this.rootValue?(0,yn.default)(this.rootValue,t):void 0;return this.component?.multiple?Array.isArray(e)&&e.length>0?e:Array.isArray(n)?n:[]:e??n??null}isEmpty(e=this.validationValue){return this.component?.multiple?!Array.isArray(e)||e.length===0:e==null||e===``}checkCondition(e,t){let n=super.checkCondition(e,t),r=this.visible;return this.lastRenderedVisible!==r&&(this.lastRenderedVisible=r,this.renderReact()),n}render(){let e=`<div ref="react-${this.id}"></div>`;return Object.getPrototypeOf(Object.getPrototypeOf(xn.prototype)).render.call(this,e)}},Tn=[{key:`labelPosition`,ignore:!0},{key:`labelPosition`,ignore:!0},{key:`placeholder`,ignore:!0},{key:`description`,ignore:!0},{key:`hideLabel`,ignore:!0},{key:`autofocus`,ignore:!0},{key:`tooltip`,ignore:!0},{key:`tabindex`,ignore:!0},{key:`disabled`,ignore:!0}];function En(...e){return i.Components.baseEditForm([{key:`display`,components:Tn}],...e)}var Dn=({value:e,defaultValue:t=``,onConfirm:n,source:i,disabled:o,onClear:s,tClearInput:c=()=>`Clear input`,...u})=>{let d=(0,a.useRef)(null),f=e=>{setTimeout(()=>{d.current&&(d.current.elementReferences[-1].value=e)},0)};(0,a.useEffect)(()=>{e!==void 0&&f(e)},[e]),(0,a.useEffect)(()=>{o?d.current&&(d.current.elementReferences[-1].disabled=!0):d.current&&(d.current.elementReferences[-1].disabled=!1)},[o]);let p=()=>{s&&s()},m=(e,t)=>{d.current.elementReferences[-1].classList.contains(`autocomplete__input--focused`)&&i(e,t)},h=t=>{t?n(t):f(e)};return(0,r.jsxs)(`div`,{style:{position:`relative`,width:`100%`},children:[(0,r.jsx)(_.default,{ref:d,...u,defaultValue:t,onConfirm:h,source:m}),!!(e&&e.length>0&&!o)&&(0,r.jsx)(`button`,{onClick:p,style:{position:`absolute`,right:`0px`,top:`50%`,transform:`translateY(-50%)`,background:`transparent`,border:`none`,cursor:`pointer`,padding:0},"aria-label":c(),children:(0,r.jsx)(l.Icon,{icon:`it-close`,size:`sm`,title:c()})})]})},On=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABSCAMAAAAhFXfZAAAC91BMVEVMaXEzeak2f7I4g7g3g7cua5gzeKg8hJo3grY4g7c3grU0gLI2frE0daAubJc2gbQwd6QzeKk2gLMtd5sxdKIua5g1frA2f7IydaM0e6w2fq41fK01eqo3grgubJgta5cxdKI1f7AydaQydaMxc6EubJgvbJkwcZ4ubZkwcJwubZgubJcydqUydKIxapgubJctbJcubZcubJcvbJYubJcvbZkubJctbJctbZcubJg2f7AubJcrbZcubJcubJcua5g3grY0fq8ubJcubJdEkdEwhsw6i88vhswuhcsuhMtBjMgthMsrg8srgss6is8qgcs8i9A9iMYtg8spgcoogMo7hcMngMonf8olfso4gr8kfck5iM8jfMk4iM8he8k1fro7itAgesk2hs8eecgzfLcofssdeMg0hc4cd8g2hcsxeLQbdsgZdcgxeLImfcszhM0vda4xgckzhM4xg84wf8Yxgs4udKsvfcQucqhUndROmdM1fK0wcZ8vb5w0eqpQm9MzeKhXoNVcpdYydKNWn9VZotVKltJFjsIwcJ1Rms9OlslLmtH///8+kc9epdYzd6dbo9VHkMM2f7FHmNBClM8ydqVcpNY9hro3gLM9hLczealQmcw3fa46f7A8gLMxc6I3eagyc6FIldJMl9JSnNRSntNNl9JPnNJFi75UnM9ZodVKksg8kM45jc09e6ZHltFBk883gbRBh7pDk9EwcaBzn784g7dKkcY2i81Om9M7j85Llc81is09g7Q4grY/j9A0eqxKmdFFltBEjcXf6fFImdBCiLxJl9FGlNFBi78yiMxVndEvbpo6js74+vx+psPP3+o/ks5HkcpGmNCjwdZCkNDM3ehYoNJEls+lxNkxh8xHks0+jdC1zd5Lg6r+/v/H2ufz9/o3jM3t8/edvdM/k89Th61OiLBSjbZklbaTt9BfptdjmL1AicBHj8hGk9FAgK1dkLNTjLRekrdClc/k7fM0icy0y9tgp9c4jc2NtM9Dlc8zicxeXZn3AAAAQ3RSTlMAHDdTb4yPA+LtnEQmC4L2EmHqB7XA0d0sr478x4/Yd5i1zOfyPkf1sLVq4Nh3FvjxopQ2/STNuFzUwFIwxKaejILpIBEV9wAABhVJREFUeF6s1NdyFEcYBeBeoQIhRAkLlRDGrhIgY3BJL8CVeKzuyXFzzjkn5ZxzzuScg3PO8cKzu70JkO0LfxdTU//pM9vTu7Xgf6KqOVTb9X7toRrVEfBf1HTVjZccrT/2by1VV928Yty9ZbVuucdz90frG8DBjl9pVApbOstvmMuvVgaNXSfAAd6pGxpy6yxf5ph43pS/4f3uoaGm2rdu72S9xzOvMymkZFq/ptDrk90mhW7e4zl7HLzhxGWPR20xmSxJ/VqldG5m9XhaVOA1DadsNh3Pu5L2N6QtPO/32JpqQBVVk20oy/Pi2s23WEvyfHbe1thadVQttvm7Llf65gGmXK67XtupyoM7HQhmXdLS8oGWJNeOJ3C5fG5XCEJnkez3/oFdsvgJ4l2ANZwhrJKk/7OSXa+3Vw2WJMlKnGkobouYk6T0TyX30klOUnTD9HJ5qpckL3EW/w4XF3Xd0FGywXUrstrclVsqz5Pd/sXFYyDnPdrLcQODmGOK47IZb4CmibmMn+MYRzFZ5jg33ZL/EJrWcszHmANy3ARBK/IXtciJy8VsitPSdE3uuHxzougojcUdr8/32atnz/ev3f/K5wtpxUTpcaI45zusVDpYtZi+jg0oU9b3x74h7+n9ABvYEZeKaVq0sh0AtLKsFtqNBdeT0MrSzwwlq9+x6xAO4tgOtSzbCjrNQQiNvQUbUEubvzBUeGw26yDCsRHCoLkTHDa7IdOLIThs/gHvChszh2CimE8peRs47cxANI0lYNB5y1DljpOF0IhzBDPOZnDOqYYbeGKECbPzWnXludPphw5c2YBq5zlwXphIbO4VDCZ0gnPfUO1TwZoYwAs2ExPCedAu9DAjfQUjzITQb3jNj0KG2Sgt6BHaQUdYzWz+XmBktOHwanXjaSTcwwziBcuMOtwBmqPrTOxFQR/DRKKPqyur0aiW6cULYsx6tBm0jXpR/AUWR6HRq9WVW6MRhIq5jLyjbaCTDCijyYJNpCajdyobP/eTw0iexBAKkJ3gA5KcQb2zBXsIBckn+xVv8jkZSaEFHE+jFEleAEfayRU0MouNoBmB/L50Ai/HSLIHxcrpCvnhSQAuakKp2C/YbCylJjXRVy/z3+Kv/RrNcCo+WUzlVEhzKffnTQnxeN9fWF88fiNCUdSTsaufaChKWInHeysygfpIqagoakW+vV20J8uyl6TyNKEZWV4oRSPyCkWpgOLSbkCObT8o2r6tlG58HQquf6O0v50tB7JM7F4EORd2dx/K0w/KHsVkLPaoYrwgP/y7krr3SSMA4zj+OBgmjYkxcdIJQyQRKgg2viX9Hddi9UBb29LrKR7CVVEEEXWojUkXNyfTNDE14W9gbHJNuhjDettN3ZvbOvdOqCD3Jp/9l+/wJE+9PkYGjx/fqkys3S2rMozM/o2106rfMUINo6hVqz+eu/hd1c4xTg0TAfy5kV+4UG6+IthHTU9woWmxuKNbTfuCSfovBCxq7EtHqvYL4Sm6F8GVxsSXHMQ07TOi1DKtZxjWaaIyi4CXWjxPccUw8WVbMYY5wxC1mzEyXMJWkllpRloi+Kkoq69sxBTlElF6aAxYUbjXNlhlDZilDnM4U5SlN5biRsRHnbx3mbeWjEh4mEyiuJDl5XcWVmX5GvNkFgLWZM5qwsop4/AWfLhU1cR7k1VVvcYCWRkOI6Xy5gmnphCYIkvzuNYzHzosq2oNk2RtSs8khfUOfHIDgR6ysYBaMpl4uEgk2U/oJTs9AaTSwma7dT69geAE2ZpEjUsn2ieJNHeKfrI3EcAGJ2ZaNgVuC8EBctCLc57P5u5led6IOBkIYkuQMrmmjChs4VkfOerHqSBkPzZlhe06RslZ3zMjk2sscqKwY0RcjKK+LWbzd7KiHhkncs/siFJ+V5eXxD34B8nVuJEpGJNmxN2gH3vSvp7J70tF+D1Ej8qUJD1TkErAND2GZwTFg/LubvmgiBG3SOvdlsqFQrkEzJCL1rstlnVFROixZoDDSuXQFHESwVGlcuQcMb/b42NgjLowh5MTDFE3vNB5qStRIErdCQEh6pLPR92anSUb/wAIhldAaDMpGgAAAABJRU5ErkJggg==`,kn=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=`,An=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC`,jn=({position:e,areasLayer:t,bounds:n,onMarkedMoved:i})=>{let o=(0,a.useRef)(null),s=null,[c,l]=(0,a.useState)([]),u=(0,v.tileLayer)(`https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`,{attribution:`&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>`}),d=[41.9,12.5],f=()=>{let r=v.default.map(o.current,{keyboard:!1,minZoom:6,maxZoom:18}).setView(d,10);u.addTo(r),t&&t.map(e=>{e.addTo(r)});let a=e?[`${e.lat}`,`${e.lon}`]:n?n.getCenter():d;if(delete v.default.Icon.Default.prototype._getIconUrl,v.default.Icon.Default.mergeOptions({iconRetinaUrl:On,iconUrl:kn,shadowUrl:An}),s=v.default.marker(a,{draggable:!0}).addTo(r),s.on(`moveend`,function(e){i(e.target.getLatLng(),s)}),r.on(`click`,function(e){let t=e.latlng;s&&s.setLatLng(t).update(),i(t,s)}),!e&&n)r.fitBounds(n);else{let t=e?[e.lat,e.lon]:d;s&&(s.setLatLng(t).update(),r.setView(t,15))}};return(0,a.useEffect)(()=>{o.current&&f()},[o]),(0,r.jsx)(`div`,{className:`d-block`,style:{height:`60vh`,width:`100%`,display:`block`},children:(0,r.jsx)(`div`,{ref:o,style:{height:`100%`,width:`100%`},"aria-hidden":!0})})},Mn=t.Formio.Components.components.field,Nn=({component:e,value:t,current:n,onChange:i,i18next:o})=>{let[s,c]=(0,a.useState)(null),[d,f]=(0,a.useState)([]),[p,m]=(0,a.useState)(),[h,ee]=(0,a.useState)(),[g,_]=(0,a.useState)(!1),[b,x]=(0,a.useState)(),[S,C]=(0,a.useState)(!1),[w,T]=(0,a.useState)(),[E,D]=(0,a.useState)(),[O,k]=(0,a.useState)(!1),[A,j]=(0,a.useState)(``),[te,N]=(0,a.useState)(``),[P,F]=(0,a.useState)(!1),[I,L]=(0,a.useState)(!1),R=new URLSearchParams(window.location.search).get(`area`),{geographic_areas_id:ne}=window.OC_SERVICE_DETAILS,re=(0,a.useRef)(),z=o.language,ie=v.default.latLngBounds(),ae=R||(ne&&ne.length>0?ne:void 0),oe=(e,t)=>{re.current=e;let n=`https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(e)}&countrycodes=it&viewbox=${p}&bounded=1&addressdetails=1&limit=14&format=jsonv2&accept-language=${z}`,r=[],i=[];C(!0),fetch(n).then(e=>e.json()).then(n=>{if(n.length&&re.current===e){C(!0);let e=n.map((e,t)=>{let{lat:n,lon:r}=e,i=`${M()}/api/geographic-areas/contains?lat=${n}&lon=${r}&geographic_areas_ids=${b.join(`,`)}`;return fetch(i).then(e=>e.json()).then(t=>t.result?(e.label=Be(e),e):null)});return Promise.all(e)}else re.current===e&&(t([]),C(!1))}).then(n=>{n=n?n.filter(e=>e!==null):[],n.length>0?(n.forEach((e,t)=>{n[t].label=Be(e)}),n=y.default.uniqWith(n,(e,t)=>e.label===t.label),n.forEach((e,t)=>{i.push(e.label),r.push(e)}),re.current===e&&(t(i),f(r),C(!1))):re.current===e&&(t([]),C(!1))}).catch(e=>{console.error(`Error fetching locations:`,e),C(!1)})},se=(e,t)=>{oe(e,t)},ce=(e,t)=>{let{lat:n,lng:r}=e,i=`https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=${n}&lon=${r}&accept-language=${z}`;fetch(i).then(e=>e.json()).then(e=>{if(e&&e.display_name)if(e.label=Be(e),e.lat=n,e.lon=r,t)t.bindPopup(`${e.label}`,{className:`address-map-popup`}).openPopup(),D(e);else{D(e);return}}).catch(e=>console.error(`Error with reverse geocoding:`,e))};function le(){navigator.geolocation.getCurrentPosition(e=>{let t=e.coords.latitude,n=e.coords.longitude;if((b||[]).length>0){let e=`${M()}/api/geographic-areas/contains?lat=${t}&lon=${n}&geographic_areas_ids=${b.join(`,`)}`;fetch(e).then(e=>e.json()).then(e=>{e.result?(c({lat:t,lon:n}),ce({lat:t,lng:n}),L(!I)):L(!I)})}else c({lat:t,lon:n}),ce({lat:t,lng:n}),L(!I)},e=>{e?.code===1?(F(!P),N(o.t(`error_message_code_1`))):e?.code===2?(F(!P),N(o.t(`error_message_code_2`))):e?.code===3?(F(!P),N(o.t(`error_message_code_3`))):(F(!P),N(o.t(`error_message_generic`)))})}(0,a.useEffect)(()=>{t&&c(t),n.valuePosition&&c(n.valuePosition)},[t,n]);let ue=()=>{t&&c(t),n.valuePosition&&c(n.valuePosition)};(0,a.useEffect)(()=>{window?.Formio?.formioReady.then(()=>{setTimeout(()=>{ue(),de()},1)})},[]);let de=()=>{let e=`${M()}/api/geographic-areas`,t=[],n=[],r=[];fetch(e).then(e=>e.json()).then(e=>{if(Array.isArray(e)&&e.length>0){e.filter(e=>ae?Array.isArray(ae)?ae.includes(e.id):e.id===ae:!0).forEach(e=>{t.push(e.id);let i=JSON.parse(e.geofence);n.push(i);let a=v.default.geoJSON(i,{style:{color:`#3478bd`,fillColor:`#87CEEB`,fillOpacity:.2,weight:1.5},filter:function(e){return e.geometry.type===`Polygon`||e.geometry.type===`MultiPolygon`}});ie.extend(a.getBounds()),r.push(a)}),ee(r),x(t),T(ie);let i=ie.getNorthEast(),a=ie.getSouthWest();m([i.lng,i.lat,a.lng,a.lat])}else console.log(`No geographic_areas_ids found.`)}).catch(e=>{console.error(`Error with reverse geocoding:`,e)})},fe=()=>{j(s?.label?s.label:``)};(0,a.useEffect)(()=>{fe(),i(s)},[s]),(0,a.useEffect)(()=>{document.querySelector(`.formio-read-only`)&&O===!1?k(!0):k(!1)},[]);let pe=()=>{if(E){let e=`${M()}/api/geographic-areas/contains?lat=${E.lat}&lon=${E.lon}&geographic_areas_ids=${b.join(`,`)}`;_(!0),fetch(e).then(e=>e.json()).then(e=>{_(!1),e?e.result===!1?u.default.fire({title:``,html:`<p>`+o.t(`Attenzione: Il luogo selezionato si trova al di fuori dell’area coperta dal servizio. Per favore, scegli un luogo all'interno dell'area evidenziata nella mappa.`)+`</p>`,icon:`error`,cancelButtonText:o.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1}):e.result===!0&&(L(!I),c(E)):(_(!1),console.log(`No geographic-areas/contains .`))}).catch(e=>{console.error(`Error with geographic-areas/contains:`,e),u.default.fire({title:``,html:`<p>`+e+`</p>`,icon:`error`,cancelButtonText:o.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1})})}};return(0,r.jsx)(`div`,{children:(0,r.jsxs)(`div`,{id:`address-map-container-${e.key}`,className:`address-map-container`,children:[(0,r.jsx)(`div`,{children:(0,r.jsxs)(l.Modal,{wrapClassName:`formio-component-address_map`,isOpen:I,size:`lg`,scrollable:!0,toggle:()=>L(!I),labelledBy:`maps-evo`,container:G(),children:[(0,r.jsx)(l.ModalHeader,{toggle:()=>L(!I),id:`maps-evo`,children:o.t(`Individua il luogo sulla mappa`)}),(0,r.jsxs)(l.ModalBody,{children:[(0,r.jsx)(`p`,{children:(0,r.jsx)(`small`,{children:o.t(`Trascina l’icona nel punto preciso in cui si verifica l’evento che vuoi segnalare e fai click su Salva indirizzo`)})}),(0,r.jsx)(jn,{position:s,areasLayer:h,bounds:w,onMarkedMoved:(e,t)=>{ce(e,t)}})]}),(0,r.jsxs)(l.ModalFooter,{children:[(0,r.jsx)(l.Button,{color:`secondary`,onClick:()=>L(!I),children:o.t(`Chiudi`)}),(0,r.jsx)(l.Button,{color:`primary`,onClick:()=>{pe()},disabled:!E||g,children:o.t(`Salva indirizzo`)})]})]})}),(0,r.jsx)(`div`,{children:(0,r.jsxs)(l.Modal,{isOpen:P,toggle:()=>F(!P),withIcon:!0,labelledBy:`error-modal-message`,container:G(),children:[(0,r.jsx)(l.ModalHeader,{icon:`it-info-circle`,id:`error-modal-message`,children:o.t(`warning`)}),(0,r.jsx)(l.ModalBody,{children:(0,r.jsx)(`p`,{children:te})}),(0,r.jsx)(l.ModalFooter,{children:(0,r.jsx)(l.Button,{color:`primary`,onClick:()=>F(!P),children:o.t(`close`)})})]})}),(0,r.jsxs)(`div`,{className:`position-relative`,children:[(0,r.jsx)(Dn,{id:`${e.id}-${e.key}`,inputClasses:`form-control`,source:(0,y.debounce)(se,520),onConfirm:e=>{C(!1),re.current=``,e&&(e===``&&c(null),c(d.find(t=>t.label===e)))},onClear:()=>{C(!1),re.current=``,c(null)},dropdownArrow:()=>null,minLength:3,disabled:O,confirmOnBlur:!0,showNoOptionsFound:!S,defaultValue:s?.label,value:A,tNoResults:()=>o.t(`Nessun risultato trovato, prova a inserire l'indirizzo completo`),tClearInput:()=>o.t(`Clear input`)}),S&&(0,r.jsx)(`div`,{className:`position-absolute`,style:{width:`100%`,bottom:`0px`},children:(0,r.jsx)(l.Progress,{indeterminate:!0,label:`In elaborazione...`})})]}),!O&&(0,r.jsxs)(l.Button,{type:`button`,value:o.t(`Individua con precisione sulla mappa`),onClick:()=>{/Mobi|Android/i.test(navigator.userAgent)?le():(L(!0),D(!1))},icon:!0,className:`px-0 primary-color`,children:[(0,r.jsx)(l.Icon,{color:`primary`,icon:`it-map-marker-circle`,role:`presentation`}),(0,r.jsx)(`span`,{children:o.t(`Individua con precisione sulla mappa`)})]})]})})},Pn=class e extends Mn{constructor(e,t,n){super(e,t,n)}static get builderInfo(){return{title:`Address Map`,group:`basic`,icon:`bi bi-map`,documentation:``,weight:70,schema:e.schema()}}static schema(){return Mn.schema({type:`address_map`})}static editForm=En;attach(e){return super.attach(e).then(()=>{this.loadRefs(this.element,{[`react-${this.id}`]:`single`});let e=this.refs[`react-${this.id}`];return e?(this.rootComponent=(0,n.createRoot)(e),this.rootComponent.render((0,r.jsx)(Nn,{component:this.component,value:this.dataValue,onChange:e=>this.setValue(e),...this,current:this},this.dataValue)),this):this})}detach(){return this.rootComponent&&=(this.rootComponent.unmount(),null),super.detach()}setValue(e){this.valuePosition=e,this.updateValue(e)}getValue(){return this.valuePosition}init(){super.init()}render(){return super.render(`<div ref="react-${this.id}"></div>`)}},Fn=[{key:`labelPosition`,ignore:!0},{key:`placeholder`,ignore:!0},{key:`description`,ignore:!0},{key:`hideLabel`,ignore:!0},{key:`autofocus`,ignore:!0},{key:`tooltip`,ignore:!0},{key:`tabindex`,ignore:!0},{key:`disabled`,ignore:!0},{label:`Base url`,calculateValue:`let url = '`+M()+`'; data.url = url; value=url;`,key:`url`,type:`hidden`,input:!0,weight:1}];function In(...e){return i.Components.baseEditForm([{key:`display`,components:Fn}],...e)}var Ln=t.Formio.Components.components.field,Rn=({component:e,current:t,onChange:n,i18next:i})=>{let o=`list-services`,s=`selected-category`,[c,u]=(0,a.useState)([]),[d,f]=(0,a.useState)([]),[p,m]=(0,a.useState)(null),[h,g]=(0,a.useState)(null),[_,v]=(0,a.useState)(``),[y,b]=(0,a.useState)(!1),[x,S]=(0,a.useState)(!1),C=(0,a.useRef)(!1),w=(0,a.useRef)(),T=(0,a.useMemo)(()=>p&&(d.find(e=>e.name===p)||c.find(e=>e.name===p))||null,[p,d,c]),E=(0,a.useMemo)(()=>T?.services||[],[T]),D=async()=>{S(!0);let e=sessionStorage.getItem(o),t=sessionStorage.getItem(s);if(e)try{let n=JSON.parse(e);if(Array.isArray(n)&&n.length>0)return u(n),f(n),m((n.find(e=>e.name===t)||n[0])?.name||null),S(!1),n}catch{console.warn(`⚠️ Cache corrotta, rigenerazione...`)}let n=await window.FormioHelper.getBookingConfig(),r={};n.forEach(e=>{(e.categories??[]).forEach(t=>{r[t]||(r[t]={name:t,services:[]}),r[t].services.push(e)})});let i=Object.fromEntries(Object.entries(r).sort(([e],[t])=>e.localeCompare(t,`it`,{sensitivity:`base`}))),a=Object.values(i).filter(e=>(e.name??``).trim()!==``);return u(a),f(a),m(a[0]?.name||null),sessionStorage.setItem(o,JSON.stringify(a)),sessionStorage.setItem(s,a[0]?.name||``),S(!1),a};(0,a.useEffect)(()=>{p&&sessionStorage.setItem(s,p)},[p]),(0,a.useEffect)(()=>{C.current||(C.current=!0,D())},[]);let O=e=>{let t=(e=``)=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=(e=``)=>e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/\s+/g,` `).trim(),r=(e=``)=>e.replace(/<[^>]*>/g,` `),i=(e,n)=>RegExp(`\\b${t(n)}`,`i`).test(e),a=(e,t)=>{let a=n(e.name),o=n((e.categories??[]).join(` `)),s=n(r(e.abstract??``));if(!t.every(e=>i(a,e)||i(o,e)||i(s,e)))return-1;let c=0;for(let e of t)i(a,e)?c+=3:i(o,e)?c+=2:i(s,e)&&(c+=1);return c},o=e.target.value;v(o);let s=n(o);if(!s){f(c),m(e=>e??c[0]?.name??null);return}let l=s.split(` `).filter(Boolean),u=c.map(e=>{let t=e.services.map(e=>({service:e,score:a(e,l)})).filter(e=>e.score>=0).sort((e,t)=>t.score-e.score).map(e=>e.service);return t.length?{...e,services:t}:null}).filter(Boolean);f(u),m(u.some(e=>e.name===p)?p:u[0]?.name??null)},k=e=>{g(e);let r=c.find(t=>t.services.some(t=>t.id===e.id));r&&m(r.name),n({id:e.id,link:e.link,name:e.name,show_howto_in_motivation:e.show_howto_in_motivation,categories:e.categories,offices:e.offices,abstract:e.abstract,view_type:e.view_type}),t.data.user_group=null,J()},A=e=>{m(e.name),g(null),v(``),f(c),n({})};return(0,a.useEffect)(()=>{b(!!document.querySelector(`.formio-read-only`))},[]),(0,a.useEffect)(()=>{let e=setTimeout(()=>{let e=t?.dataValue??t?.getValue();if(e?.id&&(g(e),c.length>0)){let t=c.find(t=>t.services.some(t=>t.id===e.id));t&&m(t.name)}},500);return()=>clearTimeout(e)},[t?.dataValue,t?.data,c]),(0,a.useEffect)(()=>{let e=window.FormioInstance;if(!e)return;let n=()=>{let n=e.submission?.data?.[t?.component?.key];if(n?.id&&(g(n),c.length>0)){let e=c.find(e=>e.services.some(e=>e.id===n.id));e&&m(e.name)}};return e.on(`change`,n),()=>e.off(`change`,n)},[c,t?.component?.key]),x?(0,r.jsx)(`div`,{className:`services-booking`,ref:w,children:(0,r.jsxs)(`div`,{children:[i.t(`Caricamento in corso`),`...`]})}):(0,r.jsx)(`div`,{className:`services-booking`,ref:w,children:c&&!y?(0,r.jsxs)(l.Container,{children:[(0,r.jsx)(l.Row,{className:`mb-3`,children:(0,r.jsx)(l.Col,{children:(0,r.jsx)(`h3`,{className:`h6 fw-bold text-uppercase mb-3`,children:i.t(`Seleziona il servizio per cui stai richiedendo un appuntamento`)})})}),(0,r.jsx)(l.Row,{className:`mb-3`,children:(0,r.jsx)(l.Col,{children:(0,r.jsx)(`div`,{className:`search-container`,children:(0,r.jsx)(l.Input,{id:`search`,label:i.t(`Cerca`),type:`text`,value:_,onChange:O,onInput:O,infoText:i.t(`Cerca per categoria, servizio o descrizione`)})})})}),(0,r.jsxs)(l.Row,{className:`mb-3`,children:[T?(0,r.jsx)(l.Col,{lg:3,md:4,className:`mb-4 mb-lg-0`,children:(0,r.jsxs)(`div`,{className:`categories-list`,children:[(0,r.jsx)(`h3`,{className:`h6 fw-bold text-uppercase mb-3`,children:i.t(`Categorie`)}),d.length>0&&d.map(e=>{let t=p===e.name;return(0,r.jsxs)(`button`,{onClick:()=>A(e),className:`category-item w-100 text-start p-3 mb-2 border-0 rounded ${t?`category-active bg-primary text-white`:`bg-light text-dark`}`,children:[(0,r.jsx)(`span`,{className:`fw-500 d-block`,children:e.name}),(0,r.jsxs)(`small`,{className:`d-block mt-1 ${t?`text-white`:`text-muted`}`,children:[e.services.length,` `,e.services.length>1?i.t(`servizi`):i.t(`servizio`)]})]},e.name)})]})}):null,(0,r.jsx)(l.Col,{lg:T?9:12,md:T?8:12,children:(0,r.jsxs)(`div`,{className:`services-container`,children:[E.length>0?(0,r.jsxs)(`div`,{className:`services-header mb-4`,children:[(0,r.jsx)(`h3`,{className:`h5 fw-bold text-primary mb-0`,children:T?.name}),(0,r.jsx)(`div`,{className:`border-bottom border-primary mt-3 mb-4`})]}):null,E.length>0?(0,r.jsx)(`div`,{className:`services-list`,children:E.map(e=>{let t=h?.id===e.id,n=ee.default.sanitize(e?.abstract);return(0,r.jsx)(`button`,{onClick:()=>k(e),className:`service-card mb-4 p-4 rounded border cursor-pointer transition text-start w-100 ${t?`border-primary border-2 bg-light`:`border-light border-1 bg-white`}`,style:{cursor:`pointer`},tabIndex:`0`,role:`button`,"aria-label":`${e.name}`,"aria-pressed":t,children:(0,r.jsx)(`div`,{className:`d-flex justify-content-between align-items-start`,children:(0,r.jsxs)(`div`,{className:`flex-grow-1`,children:[(0,r.jsx)(`h5`,{className:`h6 fw-bold mb-2 text-dark`,children:e.name}),e?.abstract&&(0,r.jsx)(`p`,{className:`text-muted small mb-0`,dangerouslySetInnerHTML:{__html:n}})]})})},e.id)})}):(0,r.jsx)(`div`,{className:`alert alert-info text-italic`,children:i.t(`Il servizio che stai cercando non è disponibile per la prenotazione appuntamento`)})]})})]})]}):y?(0,r.jsx)(`fieldset`,{className:`it-page-section`,children:(0,r.jsx)(`div`,{className:`cmp-card mt-2`,children:(0,r.jsxs)(`div`,{className:`card has-bkg-grey shadow-sm p-big`,children:[(0,r.jsx)(`div`,{className:`card-header border-0 p-0 mb-lg-30`,children:(0,r.jsx)(`div`,{className:`d-flex`,children:(0,r.jsx)(`h2`,{className:`title-xxlarge mb-1`,children:T?.name})})}),(0,r.jsx)(`div`,{className:`card p-3 p-lg-4 fieldset-body`,children:t?.dataValue?.id?(0,r.jsx)(`div`,{className:`services-list`,children:(0,r.jsx)(`div`,{className:`service-card p-4 rounded border transition border-light border-1 bg-white`,children:(0,r.jsx)(`div`,{className:`d-flex justify-content-between align-items-start`,children:(0,r.jsx)(`div`,{className:`flex-grow-1`,children:(0,r.jsx)(`p`,{className:`mb-2 text-dark text-paragraph`,children:t.dataValue.name})})})},t.dataValue.id)}):null})]})})}):null})},zn=class e extends Ln{constructor(e,t,n){super(e,t,n)}static get builderInfo(){return{title:`Lista Servizi`,group:`basic`,icon:`bi bi-list`,documentation:``,weight:70,schema:e.schema()}}static schema(){return Ln.schema({type:`list-services`})}static editForm=In;attach(e,t){return super.attach(e).then(()=>{this.loadRefs(this.element,{[`react-${this.id}`]:`single`});let e=this.refs[`react-${this.id}`];return e?(this.rootComponent&&=(this.rootComponent.unmount(),null),this.rootComponent=(0,n.createRoot)(e),this.builderMode?(this.rootComponent.render((0,r.jsx)(`div`,{className:`my-1 border border-2 border-light rounded p-3 text-secondary`,children:(0,r.jsx)(`div`,{className:`h6 mb-0`,children:this.component?.label||`Lista Servizi`})})),this):(this.rootComponent.render((0,r.jsx)(Rn,{ref:t,component:this.component,onChange:e=>this.setValue(e),...this,current:this})),this)):this})}detach(){return this.rootComponent&&=(this.rootComponent.unmount(),null),super.detach()}setValue(e){e&&(this.shouldSetValue=!0,this.updateValue(e))}getValue(){return this.dataValue}init(){super.init()}render(){return super.render(`<div ref="react-${this.id}"></div>`)}},Bn=t.Components.components.select,Vn=class extends Bn{attach(e){let t=super.attach(e);return(Array.isArray(this.refs.autocompleteInput)?this.refs.autocompleteInput:[this.refs.autocompleteInput]).forEach(e=>{e?.parentNode&&e.parentNode.removeChild(e)}),t}},Hn={pagebreak:j,dynamic_calendar:We,calendar:Je,"calendar-advanced":lt,sdcfile:wn,address_map:Pn,"list-services":zn,select:Vn};function Un(e){if(!e||typeof e.addComponent!=`function`)throw Error(`registerFormioComponents requires Formio Components with addComponent(name, component)`);return Object.entries(Hn).forEach(([t,n])=>{e.addComponent(t,n)}),Hn}return e.Calendar=Je,e.CalendarAdvanced=lt,e.FormioAddressMap=Pn,e.FormioDynamicCalendar=We,e.FormioListServices=zn,e.FormioPageBreak=j,e.SdcFile=wn,e.Select=Vn,e.formioCustomComponents=Hn,e.registerFormioComponents=Un,e})({},_formio_js,react_dom_client,react_jsx_runtime,_formio_react,react,react_day_picker,react_countdown,moment,design_react_kit,sweetalert2,dayjs,_event_calendar_core,react_dropzone,axios,mime,dompurify,jwt_decode,accessible_autocomplete_react,leaflet,lodash);
72
+ }`,conditional:{json:{"===":[{var:`data.storage`},`url`]}}},{type:`textfield`,input:!0,key:`fileKey`,label:`File form-data key`,weight:17,placeholder:`Enter the key name of a file for form data.`,tooltip:`Key name that you would like to modify for the file while calling API request.`,conditional:{json:{"===":[{var:`data.storage`},`url`]}}},{type:`textfield`,input:!0,key:`dir`,label:`Directory`,placeholder:`(optional) Enter a directory for the files`,tooltip:`This will place all the files uploaded in this field in the directory`,weight:20,conditional:{json:{"!==":[{var:`data.storage`},`googledrive`]}}},{type:`textfield`,input:!0,key:`dir`,label:`Folder ID`,placeholder:`(optional) Enter an ID of the folder for the files`,tooltip:`This will place all the files uploaded in this field in the folder`,weight:20,conditional:{json:{"===":[{var:`data.storage`},`googledrive`]}}},{type:`textfield`,input:!0,key:`fileNameTemplate`,label:`File Name Template`,placeholder:`(optional) { {name} }-{ {guid} }"`,tooltip:"Specify template for name of uploaded file(s). Regular template variables are available (`data`, `component`, `user`, `value`, `moment` etc.), also `fileName`, `guid` variables are available. `guid` part must be present, if not found in template, will be added at the end.",weight:25},{type:`checkbox`,input:!0,key:`image`,label:`Display as image(s)`,tooltip:`Instead of a list of linked files, images will be rendered in the view.`,weight:30},{type:`checkbox`,input:!0,key:`uploadOnly`,label:`Upload Only`,tooltip:`When this is checked, will only allow you to upload file(s) and consequently the download, in this component, will be unavailable.`,weight:33},{type:`checkbox`,input:!0,key:`privateDownload`,label:`Private Download`,tooltip:`When this is checked, the file download will send a POST request to the download URL with the x-jwt-token header. This will allow your endpoint to create a Private download system.`,weight:31,conditional:{json:{"===":[{var:`data.storage`},`url`]}}},{type:`textfield`,input:!0,key:`imageSize`,label:`Image Size`,placeholder:`100`,tooltip:`The image size for previewing images.`,weight:40,conditional:{json:{"==":[{var:`data.image`},!0]}}},{type:`textfield`,input:!0,key:`maxFiles`,label:`Numero massimo di file`,placeholder:`100`,tooltip:`Numero massimo di file caricabilii, default è 100.`,weight:40},{type:`checkbox`,input:!0,key:`webcam`,label:`Enable web camera`,tooltip:`This will allow using an attached camera to directly take a picture instead of uploading an existing file.`,weight:32},{type:`textfield`,input:!0,key:`webcamSize`,label:`Webcam Width`,placeholder:`320`,tooltip:`The webcam size for taking pictures.`,weight:38,conditional:{json:{"==":[{var:`data.webcam`},!0]}}},{type:`datagrid`,input:!0,label:`File Types`,key:`fileTypes`,tooltip:`Specify file types to classify the uploads. This is useful if you allow multiple types of uploads but want to allow the user to specify which type of file each is.`,weight:11,components:[{label:`Label`,key:`label`,input:!0,type:`textfield`},{label:`Value`,key:`value`,input:!0,type:`textfield`}]},{type:`textfield`,input:!0,key:`filePattern`,label:`File Pattern`,placeholder:`.jpg,video/*,application/pdf`,tooltip:`See <a href='https://github.com/danialfarid/ng-file-upload#full-reference' target='_blank'>https://github.com/danialfarid/ng-file-upload#full-reference</a> for how to specify file patterns.`,weight:50},{type:`textfield`,input:!0,key:`fileMinSize`,label:`File Minimum Size`,placeholder:`1MB`,tooltip:`See <a href='https://github.com/danialfarid/ng-file-upload#full-reference' target='_blank'>https://github.com/danialfarid/ng-file-upload#full-reference</a> for how to specify file sizes.`,weight:60},{type:`textfield`,input:!0,key:`fileMaxSize`,label:`File Maximum Size`,placeholder:`10MB`,tooltip:`See <a href='https://github.com/danialfarid/ng-file-upload#full-reference' target='_blank'>https://github.com/danialfarid/ng-file-upload#full-reference</a> for how to specify file sizes.`,weight:70},{type:`textfield`,input:!0,key:`maxFiles`,label:`Numero massimo di file`,placeholder:`100`,tooltip:`Numero massimo di file caricabilii, default è 100.`,weight:40}],pt=[{key:`unique`,ignore:!0},{key:`validateOn`,ignore:!0}];function mt(...e){return i.Components.baseEditForm([{key:`display`,components:dt},{key:`data`,components:ut},{label:`File`,key:`file`,weight:5,components:ft},{key:`validation`,components:pt}],...e)}var ht=E(((e,t)=>{t.exports=Array.isArray})),gt=E(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),_t=E(((e,t)=>{var n=gt(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),vt=E(((e,t)=>{t.exports=_t().Symbol})),yt=E(((e,t)=>{var n=vt(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),bt=E(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),xt=E(((e,t)=>{var n=vt(),r=yt(),i=bt(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),St=E(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),Ct=E(((e,t)=>{var n=xt(),r=St(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),wt=E(((e,t)=>{var n=ht(),r=Ct(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;function o(e,t){if(n(e))return!1;var o=typeof e;return o==`number`||o==`symbol`||o==`boolean`||e==null||r(e)?!0:a.test(e)||!i.test(e)||t!=null&&e in Object(t)}t.exports=o})),Tt=E(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),Et=E(((e,t)=>{var n=xt(),r=Tt(),i=`[object AsyncFunction]`,a=`[object Function]`,o=`[object GeneratorFunction]`,s=`[object Proxy]`;function c(e){if(!r(e))return!1;var t=n(e);return t==a||t==o||t==i||t==s}t.exports=c})),Dt=E(((e,t)=>{t.exports=_t()[`__core-js_shared__`]})),Ot=E(((e,t)=>{var n=Dt(),r=function(){var e=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function i(e){return!!r&&r in e}t.exports=i})),kt=E(((e,t)=>{var n=Function.prototype.toString;function r(e){if(e!=null){try{return n.call(e)}catch{}try{return e+``}catch{}}return``}t.exports=r})),At=E(((e,t)=>{var n=Et(),r=Ot(),i=Tt(),a=kt(),o=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,u=c.toString,d=l.hasOwnProperty,f=RegExp(`^`+u.call(d).replace(o,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function p(e){return!i(e)||r(e)?!1:(n(e)?f:s).test(a(e))}t.exports=p})),jt=E(((e,t)=>{function n(e,t){return e?.[t]}t.exports=n})),Mt=E(((e,t)=>{var n=At(),r=jt();function i(e,t){var i=r(e,t);return n(i)?i:void 0}t.exports=i})),Nt=E(((e,t)=>{t.exports=Mt()(Object,`create`)})),Pt=E(((e,t)=>{var n=Nt();function r(){this.__data__=n?n(null):{},this.size=0}t.exports=r})),Ft=E(((e,t)=>{function n(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}t.exports=n})),It=E(((e,t)=>{var n=Nt(),r=`__lodash_hash_undefined__`,i=Object.prototype.hasOwnProperty;function a(e){var t=this.__data__;if(n){var a=t[e];return a===r?void 0:a}return i.call(t,e)?t[e]:void 0}t.exports=a})),Lt=E(((e,t)=>{var n=Nt(),r=Object.prototype.hasOwnProperty;function i(e){var t=this.__data__;return n?t[e]!==void 0:r.call(t,e)}t.exports=i})),Rt=E(((e,t)=>{var n=Nt(),r=`__lodash_hash_undefined__`;function i(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=n&&t===void 0?r:t,this}t.exports=i})),zt=E(((e,t)=>{var n=Pt(),r=Ft(),i=It(),a=Lt(),o=Rt();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),Bt=E(((e,t)=>{function n(){this.__data__=[],this.size=0}t.exports=n})),Vt=E(((e,t)=>{function n(e,t){return e===t||e!==e&&t!==t}t.exports=n})),Ht=E(((e,t)=>{var n=Vt();function r(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}t.exports=r})),Ut=E(((e,t)=>{var n=Ht(),r=Array.prototype.splice;function i(e){var t=this.__data__,i=n(t,e);return i<0?!1:(i==t.length-1?t.pop():r.call(t,i,1),--this.size,!0)}t.exports=i})),Wt=E(((e,t)=>{var n=Ht();function r(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}t.exports=r})),Gt=E(((e,t)=>{var n=Ht();function r(e){return n(this.__data__,e)>-1}t.exports=r})),Kt=E(((e,t)=>{var n=Ht();function r(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}t.exports=r})),qt=E(((e,t)=>{var n=Bt(),r=Ut(),i=Wt(),a=Gt(),o=Kt();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),Jt=E(((e,t)=>{t.exports=Mt()(_t(),`Map`)})),Yt=E(((e,t)=>{var n=zt(),r=qt(),i=Jt();function a(){this.size=0,this.__data__={hash:new n,map:new(i||r),string:new n}}t.exports=a})),Xt=E(((e,t)=>{function n(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}t.exports=n})),Zt=E(((e,t)=>{var n=Xt();function r(e,t){var r=e.__data__;return n(t)?r[typeof t==`string`?`string`:`hash`]:r.map}t.exports=r})),Qt=E(((e,t)=>{var n=Zt();function r(e){var t=n(this,e).delete(e);return this.size-=t?1:0,t}t.exports=r})),$t=E(((e,t)=>{var n=Zt();function r(e){return n(this,e).get(e)}t.exports=r})),en=E(((e,t)=>{var n=Zt();function r(e){return n(this,e).has(e)}t.exports=r})),tn=E(((e,t)=>{var n=Zt();function r(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}t.exports=r})),nn=E(((e,t)=>{var n=Yt(),r=Qt(),i=$t(),a=en(),o=tn();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),rn=E(((e,t)=>{var n=nn(),r=`Expected a function`;function i(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(r);var a=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=a.cache;if(i.has(r))return i.get(r);var o=e.apply(this,n);return a.cache=i.set(r,o)||i,o};return a.cache=new(i.Cache||n),a}i.Cache=n,t.exports=i})),an=E(((e,t)=>{var n=rn(),r=500;function i(e){var t=n(e,function(e){return i.size===r&&i.clear(),e}),i=t.cache;return t}t.exports=i})),on=E(((e,t)=>{var n=an(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g;t.exports=n(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(r,function(e,n,r,a){t.push(r?a.replace(i,`$1`):n||e)}),t})})),sn=E(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}t.exports=n})),cn=E(((e,t)=>{var n=vt(),r=sn(),i=ht(),a=Ct(),o=1/0,s=n?n.prototype:void 0,c=s?s.toString:void 0;function l(e){if(typeof e==`string`)return e;if(i(e))return r(e,l)+``;if(a(e))return c?c.call(e):``;var t=e+``;return t==`0`&&1/e==-o?`-0`:t}t.exports=l})),ln=E(((e,t)=>{var n=cn();function r(e){return e==null?``:n(e)}t.exports=r})),un=E(((e,t)=>{var n=ht(),r=wt(),i=on(),a=ln();function o(e,t){return n(e)?e:r(e,t)?[e]:i(a(e))}t.exports=o})),dn=E(((e,t)=>{var n=Ct(),r=1/0;function i(e){if(typeof e==`string`||n(e))return e;var t=e+``;return t==`0`&&1/e==-r?`-0`:t}t.exports=i})),Y=E(((e,t)=>{var n=un(),r=dn();function i(e,t){t=n(t,e);for(var i=0,a=t.length;e!=null&&i<a;)e=e[r(t[i++])];return i&&i==a?e:void 0}t.exports=i})),fn=E(((e,t)=>{var n=Y();function r(e,t,r){var i=e==null?void 0:n(e,t);return i===void 0?r:i}t.exports=r})),pn=E(((e,t)=>{var n=Mt();t.exports=function(){try{var e=n(Object,`defineProperty`);return e({},``,{}),e}catch{}}()})),mn=E(((e,t)=>{var n=pn();function r(e,t,r){t==`__proto__`&&n?n(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}t.exports=r})),hn=E(((e,t)=>{var n=mn(),r=Vt(),i=Object.prototype.hasOwnProperty;function a(e,t,a){var o=e[t];(!(i.call(e,t)&&r(o,a))||a===void 0&&!(t in e))&&n(e,t,a)}t.exports=a})),gn=E(((e,t)=>{var n=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function i(e,t){var i=typeof e;return t??=n,!!t&&(i==`number`||i!=`symbol`&&r.test(e))&&e>-1&&e%1==0&&e<t}t.exports=i})),_n=E(((e,t)=>{var n=hn(),r=un(),i=gn(),a=Tt(),o=dn();function s(e,t,s,c){if(!a(e))return e;t=r(t,e);for(var l=-1,u=t.length,d=u-1,f=e;f!=null&&++l<u;){var p=o(t[l]),m=s;if(p===`__proto__`||p===`constructor`||p===`prototype`)return e;if(l!=d){var h=f[p];m=c?c(h,p,f):void 0,m===void 0&&(m=a(h)?h:i(t[l+1])?[]:{})}n(f,p,m),f=f[p]}return e}t.exports=s})),vn=O(E(((e,t)=>{var n=_n();function r(e,t,r){return e==null?e:n(e,t,r)}t.exports=r}))(),1),yn=O(fn(),1);document.documentElement.lang.toString();var bn=class{constructor(){this.token=null,this.basePath=null,this.init()}init(){this.token=null,this.basePath=M()}async getSessionAuthToken(){let e=this;await m.default.get(e.basePath+`/api/session-auth`).then(t=>{e.token=t.data.token}).catch(e=>{u.default.fire(`'error_message_detail`,`'auth_error'`,`error`)})}getSessionAuthTokenPromise(){let e=this;return new Promise(async(t,n)=>{U(`auth-token`)?t({token:U(`auth-token`)}):await m.default.get(e.basePath+`/api/session-auth?with-cookie=true`,{withCredentials:!0,headers:{"Content-Type":`application/json; charset=utf-8`}}).then(e=>{let t=(0,g.jwtDecode)(e.data.token);t.exp&&W(`auth-token`,e.data.token,t.exp)}).catch(e=>{console.log(e)})})}getToken(){return this.token}execAuthenticatedCall(e){this.token?e(this.token):this.getSessionAuthTokenPromise().then(t=>{this.token=t.token,e(this.token)})}},xn=t.Formio.Components.components.file,Sn=null;document.querySelector(`widget-formio`)!==null&&(Sn=document.querySelector(`widget-formio`).getAttribute(`signature-check-ws-url`));var Cn=({component:e,current:t,onChange:n,i18next:i})=>{let[o,s]=(0,a.useState)([]),[c,d]=(0,a.useState)(new Map),[f,g]=(0,a.useState)(!1),_=new bn;(0,a.useEffect)(()=>{_.getSessionAuthTokenPromise()},[]);let v=(e,t)=>{d(n=>{let r=new Map(n);return r.set(e,{...t,progress:Number(t?.progress)||0}),r})};function y(t){return t.size>(A(e.fileMaxSize)||A(`1GB`))?{code:`size-files`,message:`${i.t(`I file non possono superare le dimensioni di`)} ${e.fileMaxSize?e.fileMaxSize:`1GB`}`}:o.length>=(e.maxFiles?parseInt(e.maxFiles):e.multiple?100:1)?{code:`too-many-files`,message:`${i.t(`Puoi caricare massimo `)} ${e.maxFiles||100} ${i.t(`file`)}`}:t.size<A(e.fileMinSize)?{code:`file-too-small`,message:`${i.t(`I file devono avare una dimensione superiore a `)} ${e.fileMinSize}`}:null}function b(){if(e.filePattern){let t=e.filePattern.split(`,`).map(e=>e.trim()).filter(Boolean).reduce((e,t)=>{let n=t.startsWith(`.`)?t:`.${t}`,r=h.default.getType(n);return r?(e[r]||(e[r]=[]),e[r].push(n),e):e},{});return Object.keys(t).length?t:void 0}else return!0}let x=e=>{let t={};return t.originalName=e.originalName?e.originalName:e.name,t.name=e.name,t.url=e.url,t.data=e.data,t.signature_validation=e.signature_validation,t.mime_type=e.mime_type,t.storage=`url`,t.size=e.size,t},{getRootProps:S,getInputProps:C,fileRejections:w,isDragActive:T,open:E}=(0,p.useDropzone)({onDrop:e=>{e.map(e=>{k(e).then(e=>{})})},maxFiles:e.maxFiles?parseInt(e.maxFiles)-o.length:e.multiple?100:1,validator:y,accept:b()}),D=e=>{let t=M()+`/api/attachments/`+e.data.id;fetch(t,{method:`DELETE`,headers:{"Content-Type":`application/json; charset=utf-8`,Authorization:`Bearer ${U(`auth-token`)}`},strictErrors:!0}).then(()=>{s(t=>{let r=t.filter(t=>t.data.id!==e.data.id);return n(r),r})}).catch(e=>{u.default.fire({title:``,html:`<p>${i.t(`Ci sono stati degli errori durante l'eliminazione del file`)}</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1}),console.error(e)})},O=()=>{let e=typeof t?.getCurrentValue==`function`?t.getCurrentValue():t?.dataValue;e?.length>0&&(s(e),setTimeout(()=>{n(e)},100))};(0,a.useEffect)(()=>{document.querySelector(`.formio-read-only`)&&f===!1?(g(!0),setTimeout(()=>{O()},1e3)):(g(!1),setTimeout(()=>{O()},1e3))},[]);async function k(r){let a,o=M()+`/it/upload`,c={mime_type:r.type,name:r.name,original_filename:r.name,protocol_required:e.protocol_required,size:r.size};return await m.default.post(o,c,{maxContentLength:1/0,maxBodyLength:1/0}).then(async o=>(a=o.data.id,r.url=M()+`/it/allegati/`+a,r.storage=`url`,r.mime_type=r.type,r.protocol_required=e.protocol_required,r.data={...o.data,baseUrl:M()+`/it/allegati/`+a},v(a,r),await m.default.put(o.data.uri,r,{onUploadProgress:e=>{let t=Math.round(e.loaded*100/e.total);d(e=>{let n=new Map(e),i=r;return i.progress=parseInt(t),n.has(a)&&n.set(a,i),n})},maxContentLength:1/0,maxBodyLength:1/0,headers:{"Content-Type":`multipart/form-data`}}).then(async o=>{let c=o.headers.etag.replace(/\\|"/gi,``)||null;return await m.default.put(M()+`/it/upload/`+a,{file_hash:c,check_signature:e.check_signature}).then(async i=>{d(e=>{let t=new Map(e);return t.delete(a),t});let o=t.dataValue||[],c=null;if(s(e=>{let t=[...e,x(r)];return c=t.length-1,n(t),t}),e.check_signature&&i.data.url&&Sn)return await m.default.post(Sn,{url:i.data.url,content:null},{headers:{"Content-Type":`application/json`}}).then(e=>{r.signature_validation=e.data.sign,o[c].signature_validation=e.data.sign}).catch(e=>{o[c].signature_validation=`File validation error: `+e});d(e=>{let t=new Map(e);return t.delete(a),t})}).catch(e=>{d(e=>{let t=new Map(e);return t.delete(a),t}),console.log(e),u.default.fire({title:``,html:`<p>${i.t(`Ci sono stati degli errori dutante il caricamento dei file, riprova più tardi!`)}</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1})})}).catch(e=>{d(e=>{let t=new Map(e);return t.delete(a),t}),console.log(e),u.default.fire({title:``,html:`<p>${i.t(`Ci sono stati degli errori dutante il caricamento dei file, riprova più tardi!`)}</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1})}))).catch(e=>{console.log(e),u.default.fire({title:``,html:`<p>${i.t(`Ci sono stati degli errori dutante il caricamento dei file, riprova più tardi!`)}</p>`,icon:`error`,cancelButtonText:i.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1}),d(e=>{let t=new Map(e);return t.delete(a),t})})}function A(e){if(typeof e==`string`){if(e.search(/kb/i)===e.length-2)return parseFloat(e.substring(0,e.length-2)*1024);if(e.search(/mb/i)===e.length-2)return parseFloat(e.substring(0,e.length-2)*1024*1024);if(e.search(/gb/i)===e.length-2)return parseFloat(e.substring(0,e.length-2)*1024*1024*1024);if(e.search(/b/i)===e.length-1||e.search(/s/i)===e.length-1)return parseFloat(e.substring(0,e.length-1));if(e.search(/m/i)===e.length-1)return parseFloat(e.substring(0,e.length-1)*60);if(e.search(/h/i)===e.length-1)return parseFloat(e.substring(0,e.length-1)*3600)}return e}function j(e,t=2){if(!+e)return`0 Bytes`;let n=1024,r=t<0?0:t,i=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`,`EB`,`ZB`,`YB`],a=Math.floor(Math.log(e)/Math.log(n));return`${parseFloat((e/n**+a).toFixed(r))} ${i[a]}`}return t.conditionallyHidden()||t.visible===!1?null:(0,r.jsx)(r.Fragment,{children:f?(0,r.jsxs)(`div`,{children:[(0,r.jsxs)(`label`,{className:`col-form-label floating-label`,htmlFor:`${e.id}-${e.key}`,children:[e.label,e.validate.required&&(0,r.jsx)(`span`,{className:`text-danger`})]}),(0,r.jsxs)(`ul`,{className:`upload-file-list`,children:[o.map((e,t)=>(0,r.jsxs)(`li`,{className:`upload-file success mw-100`,children:[(0,r.jsx)(l.Icon,{"aria-hidden":`true`,color:`primary`,icon:`it-file`,title:`Icona file`,size:`sm`}),(0,r.jsxs)(`p`,{children:[(0,r.jsx)(`span`,{className:`visually-hidden`,children:i.t(`File caricato:`)}),e.name,(0,r.jsx)(`span`,{className:`upload-file-weight`,children:j(e.size)})]})]},e.size+t)),o.length<1&&(0,r.jsxs)(`li`,{className:`upload-file text-secondary mw-100`,children:[(0,r.jsx)(l.Icon,{"aria-hidden":`true`,color:`light`,icon:`it-files`,title:`Icona file`,size:`sm`}),(0,r.jsx)(`p`,{children:i.t(`Nessun elemento`)})]})]})]}):(0,r.jsxs)(r.Fragment,{children:[e.hideLabel||e.hidden?``:(0,r.jsxs)(`label`,{className:`col-form-label floating-label`,htmlFor:`${e.id}-${e.key}`,title:e.tooltip||void 0,children:[e.label,e.validate.required&&(0,r.jsx)(`span`,{className:`text-danger`}),e.tooltip&&(0,r.jsx)(`i`,{tabIndex:0,className:`bi bi-question-circle text-muted ms-1`,"data-tooltip":e.tooltip,"aria-expanded":`false`})]}),(0,r.jsxs)(`div`,{className:`my-1 border-2 border-light file-uploader-box rounded p-3 text-secondary${T?` dragover`:``}`,style:{border:`dashed`},...S({onClick:e=>e.stopPropagation()}),children:[(0,r.jsx)(`input`,{id:`${e.id}-${e.key}`,"aria-describedby":`file-uploader-description-${e.id}-${e.key}`,...C()}),(0,r.jsxs)(`div`,{className:`upload-dragdrop${T?` dragover`:``}`,children:[(0,r.jsx)(`div`,{className:`ms-1 me-3`,children:(0,r.jsx)(l.Icon,{color:`secondary`,icon:`it-upload`,title:i.t(`Carica file`),size:`_sm`})}),(0,r.jsxs)(`div`,{className:`upload-dragdrop-text`,children:[(0,r.jsx)(`div`,{className:`h5`,id:`file-uploader-description-${e.id}-${e.key}`,children:i.t(`Trascina il file per caricarlo`)}),(0,r.jsxs)(`p`,{className:`d-inline-flex`,children:[i.t(`oppure`),(0,r.jsx)(l.Button,{tag:`input`,type:`button`,value:i.t(`selezionalo dal dispositivo`),onClick:E,className:`px-1 py-0 text-decoration-underline primary-color`,size:`xs`})]})]})]})]}),(0,r.jsx)(`div`,{dangerouslySetInnerHTML:{__html:ee.default.sanitize(e.description||``)}}),(0,r.jsxs)(`ul`,{className:`upload-file-list my-0`,children:[o.map((e,t)=>(0,r.jsxs)(`li`,{className:`upload-file success`,children:[(0,r.jsx)(l.Icon,{"aria-hidden":`true`,color:`primary`,icon:`it-file`,title:`Icona file`,size:`sm`}),(0,r.jsxs)(`p`,{children:[(0,r.jsx)(`span`,{className:`visually-hidden`,children:i.t(`File caricato:`)}),e.name,(0,r.jsx)(`span`,{className:`upload-file-weight`,children:j(e.size)})]}),(0,r.jsx)(l.Button,{className:`px-1`,onClick:()=>D(e),children:(0,r.jsx)(l.Icon,{title:`${i.t(`Elimina file caricato`)} ${e.name}`,color:`secondary`,icon:`it-delete`,className:`ms-auto pointer`,size:`sm`})})]},e.size+t)),Array.from(c.entries()).map(([e,t])=>(0,r.jsxs)(`li`,{className:`upload-file success`,children:[(0,r.jsx)(l.Icon,{"aria-hidden":`true`,color:`primary`,icon:`it-file`,title:`Icona file`,size:`sm`}),(0,r.jsxs)(`p`,{children:[(0,r.jsx)(`span`,{className:`visually-hidden`,children:i.t(`Caricamento file:`)}),t.name,(0,r.jsx)(`span`,{className:`upload-file-weight`,children:j(t.size)})]}),(0,r.jsx)(l.Progress,{value:Number(t?.progress)||0})]},e))]}),!!(w&&w.length)&&(0,r.jsx)(`div`,{className:`formio-error-wrapper`,children:(0,r.jsx)(`ul`,{className:`formio-errors upload-file-list my-0 `,children:w.map(({file:t,errors:n},a)=>(0,r.jsxs)(`li`,{className:`upload-file error`,children:[(0,r.jsxs)(`div`,{className:`upload-file-name-error-wrapper`,children:[(0,r.jsx)(l.Icon,{"aria-hidden":`true`,color:`error`,icon:`it-error`,title:`Icona file`,size:`sm`}),(0,r.jsxs)(`p`,{className:`text-wrap error`,children:[(0,r.jsx)(`span`,{className:`visually-hidden`,children:i.t(`Errore caricamento file:`)}),t.name,(0,r.jsx)(`span`,{className:`upload-file-weight`,children:j(t.size)})]})]}),(0,r.jsx)(`div`,{children:n.map(t=>t.code===`file-invalid-type`?(0,r.jsxs)(`p`,{className:`text-wrap ms-0`,children:[i.t(`I file possono essere di tipo `),e.filePattern]}):t.code===`too-many-files`?(0,r.jsxs)(`p`,{className:`text-wrap ms-0`,children:[i.t(`Puoi caricare massimo `),` `,e.maxFiles?e.maxFiles:e.multiple?100:1,` `,i.t(`file`)]}):(0,r.jsx)(`p`,{className:`text-wrap ms-0`,children:t.message}))})]},t.size+a))})})]})})},wn=class e extends xn{constructor(e,t,n){super({...e,clearOnHide:!1},t,n),this.reactRef=null,this.lastRenderedVisible=void 0,this.rootComponent=null,this.mountNode=null}static get builderInfo(){return{title:`File Sdc`,group:`basic`,icon:`bi bi-file-earmark-text`,documentation:``,weight:70,schema:e.schema()}}get emptyValue(){return[]}init(){if(super.init(),this.component?.multiple&&!Array.isArray(this.getCurrentValue())){this.dataValue=[];let e=this.path||this.component?.key;e&&this.rootValue&&(0,vn.default)(this.rootValue,e,[])}}static schema(){return xn.schema({type:`sdcfile`,modelType:`array`})}static editForm=mt;getI18next(){return this.i18next&&typeof this.i18next.t==`function`?this.i18next:{language:this.options?.language||document?.documentElement?.lang||`it`,t:(e,t)=>this.t(e,t)}}hideFileProcessingLoader(){this.refs?.fileProcessingLoader&&(this.refs.fileProcessingLoader.style.display=`none`)}renderReact(){if(this.rootComponent){if(this.builderMode){this.rootComponent.render((0,r.jsx)(`div`,{className:`my-1 border border-2 border-light file-uploader-box rounded p-3 text-secondary`,children:(0,r.jsx)(`div`,{className:`upload-dragdrop`,children:(0,r.jsx)(`div`,{className:`upload-dragdrop-text`,children:(0,r.jsx)(`div`,{className:`h6 mb-0`,children:this.component?.label||`File Sdc`})})})}));return}this.rootComponent.render((0,r.jsx)(Cn,{component:this.component,current:this,i18next:this.getI18next(),onChange:e=>this.updateValueFromReact(e)}))}}attach(e){let t=super.attach(e);this.hideFileProcessingLoader();let r=`react-${this.id}`;this.loadRefs(e,{[r]:`single`});let i=this.refs[r];return i?(this.rootComponent&&this.mountNode!==i&&(this.rootComponent.unmount(),this.rootComponent=null),this.rootComponent||=(0,n.createRoot)(i),this.mountNode=i,this.lastRenderedVisible=this.visible,this.renderReact(),t):t}updateValueFromReact(e,t={modified:!0}){let n=this.normalizeValue(e,t),r=this.updateValue(n,t),i=this.path||this.component?.key;if(i&&this.rootValue){let e=(0,yn.default)(this.rootValue,i);this.isEqual(e,n)||(0,vn.default)(this.rootValue,i,n)}return r}setValue(e,t={}){let n=this.normalizeValue(e,t),r=super.setValue(n,t),i=this.path||this.component?.key;if(i&&this.rootValue){let e=(0,yn.default)(this.rootValue,i);this.isEqual(e,n)||(0,vn.default)(this.rootValue,i,n)}return r}normalizeValue(e,t={}){let n=super.normalizeValue(e,t);return!this.component?.multiple||Array.isArray(n)?n:n==null||n===``?[]:[n]}detach(){return this.hideFileProcessingLoader(),this.rootComponent&&=(this.rootComponent.unmount(),null),this.mountNode=null,super.detach()}getValue(){return this.getCurrentValue()}get validationValue(){return this.getCurrentValue()}getCurrentValue(){let e=super.getValue(),t=this.path||this.component?.key,n=t&&this.rootValue?(0,yn.default)(this.rootValue,t):void 0;return this.component?.multiple?Array.isArray(e)&&e.length>0?e:Array.isArray(n)?n:[]:e??n??null}isEmpty(e=this.validationValue){return this.component?.multiple?!Array.isArray(e)||e.length===0:e==null||e===``}checkCondition(e,t){let n=super.checkCondition(e,t),r=this.visible;return this.lastRenderedVisible!==r&&(this.lastRenderedVisible=r,this.renderReact()),n}render(){let e=`<div ref="react-${this.id}"></div>`;return Object.getPrototypeOf(Object.getPrototypeOf(xn.prototype)).render.call(this,e)}},Tn=[{key:`labelPosition`,ignore:!0},{key:`labelPosition`,ignore:!0},{key:`placeholder`,ignore:!0},{key:`description`,ignore:!0},{key:`hideLabel`,ignore:!0},{key:`autofocus`,ignore:!0},{key:`tooltip`,ignore:!0},{key:`tabindex`,ignore:!0},{key:`disabled`,ignore:!0}];function En(...e){return i.Components.baseEditForm([{key:`display`,components:Tn}],...e)}var Dn=_.default?.default??_.default,On=({value:e,defaultValue:t=``,onConfirm:n,source:i,disabled:o,onClear:s,tClearInput:c=()=>`Clear input`,...u})=>{let d=(0,a.useRef)(null),f=e=>{setTimeout(()=>{d.current&&(d.current.elementReferences[-1].value=e)},0)};(0,a.useEffect)(()=>{e!==void 0&&f(e)},[e]),(0,a.useEffect)(()=>{o?d.current&&(d.current.elementReferences[-1].disabled=!0):d.current&&(d.current.elementReferences[-1].disabled=!1)},[o]);let p=()=>{s&&s()},m=(e,t)=>{d.current.elementReferences[-1].classList.contains(`autocomplete__input--focused`)&&i(e,t)},h=t=>{t?n(t):f(e)};return(0,r.jsxs)(`div`,{style:{position:`relative`,width:`100%`},children:[(0,r.jsx)(Dn,{ref:d,...u,defaultValue:t,onConfirm:h,source:m}),!!(e&&e.length>0&&!o)&&(0,r.jsx)(`button`,{onClick:p,style:{position:`absolute`,right:`0px`,top:`50%`,transform:`translateY(-50%)`,background:`transparent`,border:`none`,cursor:`pointer`,padding:0},"aria-label":c(),children:(0,r.jsx)(l.Icon,{icon:`it-close`,size:`sm`,title:c()})})]})},kn=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABSCAMAAAAhFXfZAAAC91BMVEVMaXEzeak2f7I4g7g3g7cua5gzeKg8hJo3grY4g7c3grU0gLI2frE0daAubJc2gbQwd6QzeKk2gLMtd5sxdKIua5g1frA2f7IydaM0e6w2fq41fK01eqo3grgubJgta5cxdKI1f7AydaQydaMxc6EubJgvbJkwcZ4ubZkwcJwubZgubJcydqUydKIxapgubJctbJcubZcubJcvbJYubJcvbZkubJctbJctbZcubJg2f7AubJcrbZcubJcubJcua5g3grY0fq8ubJcubJdEkdEwhsw6i88vhswuhcsuhMtBjMgthMsrg8srgss6is8qgcs8i9A9iMYtg8spgcoogMo7hcMngMonf8olfso4gr8kfck5iM8jfMk4iM8he8k1fro7itAgesk2hs8eecgzfLcofssdeMg0hc4cd8g2hcsxeLQbdsgZdcgxeLImfcszhM0vda4xgckzhM4xg84wf8Yxgs4udKsvfcQucqhUndROmdM1fK0wcZ8vb5w0eqpQm9MzeKhXoNVcpdYydKNWn9VZotVKltJFjsIwcJ1Rms9OlslLmtH///8+kc9epdYzd6dbo9VHkMM2f7FHmNBClM8ydqVcpNY9hro3gLM9hLczealQmcw3fa46f7A8gLMxc6I3eagyc6FIldJMl9JSnNRSntNNl9JPnNJFi75UnM9ZodVKksg8kM45jc09e6ZHltFBk883gbRBh7pDk9EwcaBzn784g7dKkcY2i81Om9M7j85Llc81is09g7Q4grY/j9A0eqxKmdFFltBEjcXf6fFImdBCiLxJl9FGlNFBi78yiMxVndEvbpo6js74+vx+psPP3+o/ks5HkcpGmNCjwdZCkNDM3ehYoNJEls+lxNkxh8xHks0+jdC1zd5Lg6r+/v/H2ufz9/o3jM3t8/edvdM/k89Th61OiLBSjbZklbaTt9BfptdjmL1AicBHj8hGk9FAgK1dkLNTjLRekrdClc/k7fM0icy0y9tgp9c4jc2NtM9Dlc8zicxeXZn3AAAAQ3RSTlMAHDdTb4yPA+LtnEQmC4L2EmHqB7XA0d0sr478x4/Yd5i1zOfyPkf1sLVq4Nh3FvjxopQ2/STNuFzUwFIwxKaejILpIBEV9wAABhVJREFUeF6s1NdyFEcYBeBeoQIhRAkLlRDGrhIgY3BJL8CVeKzuyXFzzjkn5ZxzzuScg3PO8cKzu70JkO0LfxdTU//pM9vTu7Xgf6KqOVTb9X7toRrVEfBf1HTVjZccrT/2by1VV928Yty9ZbVuucdz90frG8DBjl9pVApbOstvmMuvVgaNXSfAAd6pGxpy6yxf5ph43pS/4f3uoaGm2rdu72S9xzOvMymkZFq/ptDrk90mhW7e4zl7HLzhxGWPR20xmSxJ/VqldG5m9XhaVOA1DadsNh3Pu5L2N6QtPO/32JpqQBVVk20oy/Pi2s23WEvyfHbe1thadVQttvm7Llf65gGmXK67XtupyoM7HQhmXdLS8oGWJNeOJ3C5fG5XCEJnkez3/oFdsvgJ4l2ANZwhrJKk/7OSXa+3Vw2WJMlKnGkobouYk6T0TyX30klOUnTD9HJ5qpckL3EW/w4XF3Xd0FGywXUrstrclVsqz5Pd/sXFYyDnPdrLcQODmGOK47IZb4CmibmMn+MYRzFZ5jg33ZL/EJrWcszHmANy3ARBK/IXtciJy8VsitPSdE3uuHxzougojcUdr8/32atnz/ev3f/K5wtpxUTpcaI45zusVDpYtZi+jg0oU9b3x74h7+n9ABvYEZeKaVq0sh0AtLKsFtqNBdeT0MrSzwwlq9+x6xAO4tgOtSzbCjrNQQiNvQUbUEubvzBUeGw26yDCsRHCoLkTHDa7IdOLIThs/gHvChszh2CimE8peRs47cxANI0lYNB5y1DljpOF0IhzBDPOZnDOqYYbeGKECbPzWnXludPphw5c2YBq5zlwXphIbO4VDCZ0gnPfUO1TwZoYwAs2ExPCedAu9DAjfQUjzITQb3jNj0KG2Sgt6BHaQUdYzWz+XmBktOHwanXjaSTcwwziBcuMOtwBmqPrTOxFQR/DRKKPqyur0aiW6cULYsx6tBm0jXpR/AUWR6HRq9WVW6MRhIq5jLyjbaCTDCijyYJNpCajdyobP/eTw0iexBAKkJ3gA5KcQb2zBXsIBckn+xVv8jkZSaEFHE+jFEleAEfayRU0MouNoBmB/L50Ai/HSLIHxcrpCvnhSQAuakKp2C/YbCylJjXRVy/z3+Kv/RrNcCo+WUzlVEhzKffnTQnxeN9fWF88fiNCUdSTsaufaChKWInHeysygfpIqagoakW+vV20J8uyl6TyNKEZWV4oRSPyCkWpgOLSbkCObT8o2r6tlG58HQquf6O0v50tB7JM7F4EORd2dx/K0w/KHsVkLPaoYrwgP/y7krr3SSMA4zj+OBgmjYkxcdIJQyQRKgg2viX9Hddi9UBb29LrKR7CVVEEEXWojUkXNyfTNDE14W9gbHJNuhjDettN3ZvbOvdOqCD3Jp/9l+/wJE+9PkYGjx/fqkys3S2rMozM/o2106rfMUINo6hVqz+eu/hd1c4xTg0TAfy5kV+4UG6+IthHTU9woWmxuKNbTfuCSfovBCxq7EtHqvYL4Sm6F8GVxsSXHMQ07TOi1DKtZxjWaaIyi4CXWjxPccUw8WVbMYY5wxC1mzEyXMJWkllpRloi+Kkoq69sxBTlElF6aAxYUbjXNlhlDZilDnM4U5SlN5biRsRHnbx3mbeWjEh4mEyiuJDl5XcWVmX5GvNkFgLWZM5qwsop4/AWfLhU1cR7k1VVvcYCWRkOI6Xy5gmnphCYIkvzuNYzHzosq2oNk2RtSs8khfUOfHIDgR6ysYBaMpl4uEgk2U/oJTs9AaTSwma7dT69geAE2ZpEjUsn2ieJNHeKfrI3EcAGJ2ZaNgVuC8EBctCLc57P5u5led6IOBkIYkuQMrmmjChs4VkfOerHqSBkPzZlhe06RslZ3zMjk2sscqKwY0RcjKK+LWbzd7KiHhkncs/siFJ+V5eXxD34B8nVuJEpGJNmxN2gH3vSvp7J70tF+D1Ej8qUJD1TkErAND2GZwTFg/LubvmgiBG3SOvdlsqFQrkEzJCL1rstlnVFROixZoDDSuXQFHESwVGlcuQcMb/b42NgjLowh5MTDFE3vNB5qStRIErdCQEh6pLPR92anSUb/wAIhldAaDMpGgAAAABJRU5ErkJggg==`,An=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=`,jn=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC`,Mn=({position:e,areasLayer:t,bounds:n,onMarkedMoved:i})=>{let o=(0,a.useRef)(null),s=null,[c,l]=(0,a.useState)([]),u=(0,v.tileLayer)(`https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png`,{attribution:`&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>`}),d=[41.9,12.5],f=()=>{let r=v.default.map(o.current,{keyboard:!1,minZoom:6,maxZoom:18}).setView(d,10);u.addTo(r),t&&t.map(e=>{e.addTo(r)});let a=e?[`${e.lat}`,`${e.lon}`]:n?n.getCenter():d;if(delete v.default.Icon.Default.prototype._getIconUrl,v.default.Icon.Default.mergeOptions({iconRetinaUrl:kn,iconUrl:An,shadowUrl:jn}),s=v.default.marker(a,{draggable:!0}).addTo(r),s.on(`moveend`,function(e){i(e.target.getLatLng(),s)}),r.on(`click`,function(e){let t=e.latlng;s&&s.setLatLng(t).update(),i(t,s)}),!e&&n)r.fitBounds(n);else{let t=e?[e.lat,e.lon]:d;s&&(s.setLatLng(t).update(),r.setView(t,15))}};return(0,a.useEffect)(()=>{o.current&&f()},[o]),(0,r.jsx)(`div`,{className:`d-block`,style:{height:`60vh`,width:`100%`,display:`block`},children:(0,r.jsx)(`div`,{ref:o,style:{height:`100%`,width:`100%`},"aria-hidden":!0})})},Nn=t.Formio.Components.components.field,Pn=({component:e,value:t,current:n,onChange:i,i18next:o})=>{let[s,c]=(0,a.useState)(null),[d,f]=(0,a.useState)([]),[p,m]=(0,a.useState)(),[h,ee]=(0,a.useState)(),[g,_]=(0,a.useState)(!1),[b,x]=(0,a.useState)(),[S,C]=(0,a.useState)(!1),[w,T]=(0,a.useState)(),[E,D]=(0,a.useState)(),[O,k]=(0,a.useState)(!1),[A,j]=(0,a.useState)(``),[te,N]=(0,a.useState)(``),[P,F]=(0,a.useState)(!1),[I,L]=(0,a.useState)(!1),R=new URLSearchParams(window.location.search).get(`area`),{geographic_areas_id:ne}=window.OC_SERVICE_DETAILS,re=(0,a.useRef)(),z=o.language,ie=v.default.latLngBounds(),ae=R||(ne&&ne.length>0?ne:void 0),oe=(e,t)=>{re.current=e;let n=`https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(e)}&countrycodes=it&viewbox=${p}&bounded=1&addressdetails=1&limit=14&format=jsonv2&accept-language=${z}`,r=[],i=[];C(!0),fetch(n).then(e=>e.json()).then(n=>{if(n.length&&re.current===e){C(!0);let e=n.map((e,t)=>{let{lat:n,lon:r}=e,i=`${M()}/api/geographic-areas/contains?lat=${n}&lon=${r}&geographic_areas_ids=${b.join(`,`)}`;return fetch(i).then(e=>e.json()).then(t=>t.result?(e.label=Be(e),e):null)});return Promise.all(e)}else re.current===e&&(t([]),C(!1))}).then(n=>{n=n?n.filter(e=>e!==null):[],n.length>0?(n.forEach((e,t)=>{n[t].label=Be(e)}),n=y.default.uniqWith(n,(e,t)=>e.label===t.label),n.forEach((e,t)=>{i.push(e.label),r.push(e)}),re.current===e&&(t(i),f(r),C(!1))):re.current===e&&(t([]),C(!1))}).catch(e=>{console.error(`Error fetching locations:`,e),C(!1)})},se=(e,t)=>{oe(e,t)},ce=(e,t)=>{let{lat:n,lng:r}=e,i=`https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=${n}&lon=${r}&accept-language=${z}`;fetch(i).then(e=>e.json()).then(e=>{if(e&&e.display_name)if(e.label=Be(e),e.lat=n,e.lon=r,t)t.bindPopup(`${e.label}`,{className:`address-map-popup`}).openPopup(),D(e);else{D(e);return}}).catch(e=>console.error(`Error with reverse geocoding:`,e))};function le(){navigator.geolocation.getCurrentPosition(e=>{let t=e.coords.latitude,n=e.coords.longitude;if((b||[]).length>0){let e=`${M()}/api/geographic-areas/contains?lat=${t}&lon=${n}&geographic_areas_ids=${b.join(`,`)}`;fetch(e).then(e=>e.json()).then(e=>{e.result?(c({lat:t,lon:n}),ce({lat:t,lng:n}),L(!I)):L(!I)})}else c({lat:t,lon:n}),ce({lat:t,lng:n}),L(!I)},e=>{e?.code===1?(F(!P),N(o.t(`error_message_code_1`))):e?.code===2?(F(!P),N(o.t(`error_message_code_2`))):e?.code===3?(F(!P),N(o.t(`error_message_code_3`))):(F(!P),N(o.t(`error_message_generic`)))})}(0,a.useEffect)(()=>{t&&c(t),n.valuePosition&&c(n.valuePosition)},[t,n]);let ue=()=>{t&&c(t),n.valuePosition&&c(n.valuePosition)};(0,a.useEffect)(()=>{window?.Formio?.formioReady.then(()=>{setTimeout(()=>{ue(),de()},1)})},[]);let de=()=>{let e=`${M()}/api/geographic-areas`,t=[],n=[],r=[];fetch(e).then(e=>e.json()).then(e=>{if(Array.isArray(e)&&e.length>0){e.filter(e=>ae?Array.isArray(ae)?ae.includes(e.id):e.id===ae:!0).forEach(e=>{t.push(e.id);let i=JSON.parse(e.geofence);n.push(i);let a=v.default.geoJSON(i,{style:{color:`#3478bd`,fillColor:`#87CEEB`,fillOpacity:.2,weight:1.5},filter:function(e){return e.geometry.type===`Polygon`||e.geometry.type===`MultiPolygon`}});ie.extend(a.getBounds()),r.push(a)}),ee(r),x(t),T(ie);let i=ie.getNorthEast(),a=ie.getSouthWest();m([i.lng,i.lat,a.lng,a.lat])}else console.log(`No geographic_areas_ids found.`)}).catch(e=>{console.error(`Error with reverse geocoding:`,e)})},fe=()=>{j(s?.label?s.label:``)};(0,a.useEffect)(()=>{fe(),i(s)},[s]),(0,a.useEffect)(()=>{document.querySelector(`.formio-read-only`)&&O===!1?k(!0):k(!1)},[]);let pe=()=>{if(E){let e=`${M()}/api/geographic-areas/contains?lat=${E.lat}&lon=${E.lon}&geographic_areas_ids=${b.join(`,`)}`;_(!0),fetch(e).then(e=>e.json()).then(e=>{_(!1),e?e.result===!1?u.default.fire({title:``,html:`<p>`+o.t(`Attenzione: Il luogo selezionato si trova al di fuori dell’area coperta dal servizio. Per favore, scegli un luogo all'interno dell'area evidenziata nella mappa.`)+`</p>`,icon:`error`,cancelButtonText:o.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1}):e.result===!0&&(L(!I),c(E)):(_(!1),console.log(`No geographic-areas/contains .`))}).catch(e=>{console.error(`Error with geographic-areas/contains:`,e),u.default.fire({title:``,html:`<p>`+e+`</p>`,icon:`error`,cancelButtonText:o.t(`Chiudi`),showCancelButton:!0,showConfirmButton:!1})})}};return(0,r.jsx)(`div`,{children:(0,r.jsxs)(`div`,{id:`address-map-container-${e.key}`,className:`address-map-container`,children:[(0,r.jsx)(`div`,{children:(0,r.jsxs)(l.Modal,{wrapClassName:`formio-component-address_map`,isOpen:I,size:`lg`,scrollable:!0,toggle:()=>L(!I),labelledBy:`maps-evo`,container:G(),children:[(0,r.jsx)(l.ModalHeader,{toggle:()=>L(!I),id:`maps-evo`,children:o.t(`Individua il luogo sulla mappa`)}),(0,r.jsxs)(l.ModalBody,{children:[(0,r.jsx)(`p`,{children:(0,r.jsx)(`small`,{children:o.t(`Trascina l’icona nel punto preciso in cui si verifica l’evento che vuoi segnalare e fai click su Salva indirizzo`)})}),(0,r.jsx)(Mn,{position:s,areasLayer:h,bounds:w,onMarkedMoved:(e,t)=>{ce(e,t)}})]}),(0,r.jsxs)(l.ModalFooter,{children:[(0,r.jsx)(l.Button,{color:`secondary`,onClick:()=>L(!I),children:o.t(`Chiudi`)}),(0,r.jsx)(l.Button,{color:`primary`,onClick:()=>{pe()},disabled:!E||g,children:o.t(`Salva indirizzo`)})]})]})}),(0,r.jsx)(`div`,{children:(0,r.jsxs)(l.Modal,{isOpen:P,toggle:()=>F(!P),withIcon:!0,labelledBy:`error-modal-message`,container:G(),children:[(0,r.jsx)(l.ModalHeader,{icon:`it-info-circle`,id:`error-modal-message`,children:o.t(`warning`)}),(0,r.jsx)(l.ModalBody,{children:(0,r.jsx)(`p`,{children:te})}),(0,r.jsx)(l.ModalFooter,{children:(0,r.jsx)(l.Button,{color:`primary`,onClick:()=>F(!P),children:o.t(`close`)})})]})}),(0,r.jsxs)(`div`,{className:`position-relative`,children:[(0,r.jsx)(On,{id:`${e.id}-${e.key}`,inputClasses:`form-control`,source:(0,y.debounce)(se,520),onConfirm:e=>{C(!1),re.current=``,e&&(e===``&&c(null),c(d.find(t=>t.label===e)))},onClear:()=>{C(!1),re.current=``,c(null)},dropdownArrow:()=>null,minLength:3,disabled:O,confirmOnBlur:!0,showNoOptionsFound:!S,defaultValue:s?.label,value:A,tNoResults:()=>o.t(`Nessun risultato trovato, prova a inserire l'indirizzo completo`),tClearInput:()=>o.t(`Clear input`)}),S&&(0,r.jsx)(`div`,{className:`position-absolute`,style:{width:`100%`,bottom:`0px`},children:(0,r.jsx)(l.Progress,{indeterminate:!0,label:`In elaborazione...`})})]}),!O&&(0,r.jsxs)(l.Button,{type:`button`,value:o.t(`Individua con precisione sulla mappa`),onClick:()=>{/Mobi|Android/i.test(navigator.userAgent)?le():(L(!0),D(!1))},icon:!0,className:`px-0 primary-color`,children:[(0,r.jsx)(l.Icon,{color:`primary`,icon:`it-map-marker-circle`,role:`presentation`}),(0,r.jsx)(`span`,{children:o.t(`Individua con precisione sulla mappa`)})]})]})})},Fn=class e extends Nn{constructor(e,t,n){super(e,t,n)}static get builderInfo(){return{title:`Address Map`,group:`basic`,icon:`bi bi-map`,documentation:``,weight:70,schema:e.schema()}}static schema(){return Nn.schema({type:`address_map`})}static editForm=En;attach(e){return super.attach(e).then(()=>{this.loadRefs(this.element,{[`react-${this.id}`]:`single`});let e=this.refs[`react-${this.id}`];return e?(this.rootComponent=(0,n.createRoot)(e),this.rootComponent.render((0,r.jsx)(Pn,{component:this.component,value:this.dataValue,onChange:e=>this.setValue(e),...this,current:this},this.dataValue)),this):this})}detach(){return this.rootComponent&&=(this.rootComponent.unmount(),null),super.detach()}setValue(e){this.valuePosition=e,this.updateValue(e)}getValue(){return this.valuePosition}init(){super.init()}render(){return super.render(`<div ref="react-${this.id}"></div>`)}},In=[{key:`labelPosition`,ignore:!0},{key:`placeholder`,ignore:!0},{key:`description`,ignore:!0},{key:`hideLabel`,ignore:!0},{key:`autofocus`,ignore:!0},{key:`tooltip`,ignore:!0},{key:`tabindex`,ignore:!0},{key:`disabled`,ignore:!0},{label:`Base url`,calculateValue:`let url = '`+M()+`'; data.url = url; value=url;`,key:`url`,type:`hidden`,input:!0,weight:1}];function Ln(...e){return i.Components.baseEditForm([{key:`display`,components:In}],...e)}var Rn=t.Formio.Components.components.field,zn=({component:e,current:t,onChange:n,i18next:i})=>{let o=`list-services`,s=`selected-category`,[c,u]=(0,a.useState)([]),[d,f]=(0,a.useState)([]),[p,m]=(0,a.useState)(null),[h,g]=(0,a.useState)(null),[_,v]=(0,a.useState)(``),[y,b]=(0,a.useState)(!1),[x,S]=(0,a.useState)(!1),C=(0,a.useRef)(!1),w=(0,a.useRef)(),T=(0,a.useMemo)(()=>p&&(d.find(e=>e.name===p)||c.find(e=>e.name===p))||null,[p,d,c]),E=(0,a.useMemo)(()=>T?.services||[],[T]),D=async()=>{S(!0);let e=sessionStorage.getItem(o),t=sessionStorage.getItem(s);if(e)try{let n=JSON.parse(e);if(Array.isArray(n)&&n.length>0)return u(n),f(n),m((n.find(e=>e.name===t)||n[0])?.name||null),S(!1),n}catch{console.warn(`⚠️ Cache corrotta, rigenerazione...`)}let n=await window.FormioHelper.getBookingConfig(),r={};n.forEach(e=>{(e.categories??[]).forEach(t=>{r[t]||(r[t]={name:t,services:[]}),r[t].services.push(e)})});let i=Object.fromEntries(Object.entries(r).sort(([e],[t])=>e.localeCompare(t,`it`,{sensitivity:`base`}))),a=Object.values(i).filter(e=>(e.name??``).trim()!==``);return u(a),f(a),m(a[0]?.name||null),sessionStorage.setItem(o,JSON.stringify(a)),sessionStorage.setItem(s,a[0]?.name||``),S(!1),a};(0,a.useEffect)(()=>{p&&sessionStorage.setItem(s,p)},[p]),(0,a.useEffect)(()=>{C.current||(C.current=!0,D())},[]);let O=e=>{let t=(e=``)=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=(e=``)=>e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/\s+/g,` `).trim(),r=(e=``)=>e.replace(/<[^>]*>/g,` `),i=(e,n)=>RegExp(`\\b${t(n)}`,`i`).test(e),a=(e,t)=>{let a=n(e.name),o=n((e.categories??[]).join(` `)),s=n(r(e.abstract??``));if(!t.every(e=>i(a,e)||i(o,e)||i(s,e)))return-1;let c=0;for(let e of t)i(a,e)?c+=3:i(o,e)?c+=2:i(s,e)&&(c+=1);return c},o=e.target.value;v(o);let s=n(o);if(!s){f(c),m(e=>e??c[0]?.name??null);return}let l=s.split(` `).filter(Boolean),u=c.map(e=>{let t=e.services.map(e=>({service:e,score:a(e,l)})).filter(e=>e.score>=0).sort((e,t)=>t.score-e.score).map(e=>e.service);return t.length?{...e,services:t}:null}).filter(Boolean);f(u),m(u.some(e=>e.name===p)?p:u[0]?.name??null)},k=e=>{g(e);let r=c.find(t=>t.services.some(t=>t.id===e.id));r&&m(r.name),n({id:e.id,link:e.link,name:e.name,show_howto_in_motivation:e.show_howto_in_motivation,categories:e.categories,offices:e.offices,abstract:e.abstract,view_type:e.view_type}),t.data.user_group=null,J()},A=e=>{m(e.name),g(null),v(``),f(c),n({})};return(0,a.useEffect)(()=>{b(!!document.querySelector(`.formio-read-only`))},[]),(0,a.useEffect)(()=>{let e=setTimeout(()=>{let e=t?.dataValue??t?.getValue();if(e?.id&&(g(e),c.length>0)){let t=c.find(t=>t.services.some(t=>t.id===e.id));t&&m(t.name)}},500);return()=>clearTimeout(e)},[t?.dataValue,t?.data,c]),(0,a.useEffect)(()=>{let e=window.FormioInstance;if(!e)return;let n=()=>{let n=e.submission?.data?.[t?.component?.key];if(n?.id&&(g(n),c.length>0)){let e=c.find(e=>e.services.some(e=>e.id===n.id));e&&m(e.name)}};return e.on(`change`,n),()=>e.off(`change`,n)},[c,t?.component?.key]),x?(0,r.jsx)(`div`,{className:`services-booking`,ref:w,children:(0,r.jsxs)(`div`,{children:[i.t(`Caricamento in corso`),`...`]})}):(0,r.jsx)(`div`,{className:`services-booking`,ref:w,children:c&&!y?(0,r.jsxs)(l.Container,{children:[(0,r.jsx)(l.Row,{className:`mb-3`,children:(0,r.jsx)(l.Col,{children:(0,r.jsx)(`h3`,{className:`h6 fw-bold text-uppercase mb-3`,children:i.t(`Seleziona il servizio per cui stai richiedendo un appuntamento`)})})}),(0,r.jsx)(l.Row,{className:`mb-3`,children:(0,r.jsx)(l.Col,{children:(0,r.jsx)(`div`,{className:`search-container`,children:(0,r.jsx)(l.Input,{id:`search`,label:i.t(`Cerca`),type:`text`,value:_,onChange:O,onInput:O,infoText:i.t(`Cerca per categoria, servizio o descrizione`)})})})}),(0,r.jsxs)(l.Row,{className:`mb-3`,children:[T?(0,r.jsx)(l.Col,{lg:3,md:4,className:`mb-4 mb-lg-0`,children:(0,r.jsxs)(`div`,{className:`categories-list`,children:[(0,r.jsx)(`h3`,{className:`h6 fw-bold text-uppercase mb-3`,children:i.t(`Categorie`)}),d.length>0&&d.map(e=>{let t=p===e.name;return(0,r.jsxs)(`button`,{onClick:()=>A(e),className:`category-item w-100 text-start p-3 mb-2 border-0 rounded ${t?`category-active bg-primary text-white`:`bg-light text-dark`}`,children:[(0,r.jsx)(`span`,{className:`fw-500 d-block`,children:e.name}),(0,r.jsxs)(`small`,{className:`d-block mt-1 ${t?`text-white`:`text-muted`}`,children:[e.services.length,` `,e.services.length>1?i.t(`servizi`):i.t(`servizio`)]})]},e.name)})]})}):null,(0,r.jsx)(l.Col,{lg:T?9:12,md:T?8:12,children:(0,r.jsxs)(`div`,{className:`services-container`,children:[E.length>0?(0,r.jsxs)(`div`,{className:`services-header mb-4`,children:[(0,r.jsx)(`h3`,{className:`h5 fw-bold text-primary mb-0`,children:T?.name}),(0,r.jsx)(`div`,{className:`border-bottom border-primary mt-3 mb-4`})]}):null,E.length>0?(0,r.jsx)(`div`,{className:`services-list`,children:E.map(e=>{let t=h?.id===e.id,n=ee.default.sanitize(e?.abstract);return(0,r.jsx)(`button`,{onClick:()=>k(e),className:`service-card mb-4 p-4 rounded border cursor-pointer transition text-start w-100 ${t?`border-primary border-2 bg-light`:`border-light border-1 bg-white`}`,style:{cursor:`pointer`},tabIndex:`0`,role:`button`,"aria-label":`${e.name}`,"aria-pressed":t,children:(0,r.jsx)(`div`,{className:`d-flex justify-content-between align-items-start`,children:(0,r.jsxs)(`div`,{className:`flex-grow-1`,children:[(0,r.jsx)(`h5`,{className:`h6 fw-bold mb-2 text-dark`,children:e.name}),e?.abstract&&(0,r.jsx)(`p`,{className:`text-muted small mb-0`,dangerouslySetInnerHTML:{__html:n}})]})})},e.id)})}):(0,r.jsx)(`div`,{className:`alert alert-info text-italic`,children:i.t(`Il servizio che stai cercando non è disponibile per la prenotazione appuntamento`)})]})})]})]}):y?(0,r.jsx)(`fieldset`,{className:`it-page-section`,children:(0,r.jsx)(`div`,{className:`cmp-card mt-2`,children:(0,r.jsxs)(`div`,{className:`card has-bkg-grey shadow-sm p-big`,children:[(0,r.jsx)(`div`,{className:`card-header border-0 p-0 mb-lg-30`,children:(0,r.jsx)(`div`,{className:`d-flex`,children:(0,r.jsx)(`h2`,{className:`title-xxlarge mb-1`,children:T?.name})})}),(0,r.jsx)(`div`,{className:`card p-3 p-lg-4 fieldset-body`,children:t?.dataValue?.id?(0,r.jsx)(`div`,{className:`services-list`,children:(0,r.jsx)(`div`,{className:`service-card p-4 rounded border transition border-light border-1 bg-white`,children:(0,r.jsx)(`div`,{className:`d-flex justify-content-between align-items-start`,children:(0,r.jsx)(`div`,{className:`flex-grow-1`,children:(0,r.jsx)(`p`,{className:`mb-2 text-dark text-paragraph`,children:t.dataValue.name})})})},t.dataValue.id)}):null})]})})}):null})},Bn=class e extends Rn{constructor(e,t,n){super(e,t,n)}static get builderInfo(){return{title:`Lista Servizi`,group:`basic`,icon:`bi bi-list`,documentation:``,weight:70,schema:e.schema()}}static schema(){return Rn.schema({type:`list-services`})}static editForm=Ln;attach(e,t){return super.attach(e).then(()=>{this.loadRefs(this.element,{[`react-${this.id}`]:`single`});let e=this.refs[`react-${this.id}`];return e?(this.rootComponent&&=(this.rootComponent.unmount(),null),this.rootComponent=(0,n.createRoot)(e),this.builderMode?(this.rootComponent.render((0,r.jsx)(`div`,{className:`my-1 border border-2 border-light rounded p-3 text-secondary`,children:(0,r.jsx)(`div`,{className:`h6 mb-0`,children:this.component?.label||`Lista Servizi`})})),this):(this.rootComponent.render((0,r.jsx)(zn,{ref:t,component:this.component,onChange:e=>this.setValue(e),...this,current:this})),this)):this})}detach(){return this.rootComponent&&=(this.rootComponent.unmount(),null),super.detach()}setValue(e){e&&(this.shouldSetValue=!0,this.updateValue(e))}getValue(){return this.dataValue}init(){super.init()}render(){return super.render(`<div ref="react-${this.id}"></div>`)}},Vn=t.Components.components.select,Hn=class extends Vn{attach(e){let t=super.attach(e);return(Array.isArray(this.refs.autocompleteInput)?this.refs.autocompleteInput:[this.refs.autocompleteInput]).forEach(e=>{e?.parentNode&&e.parentNode.removeChild(e)}),t}},Un={pagebreak:j,dynamic_calendar:We,calendar:Je,"calendar-advanced":lt,sdcfile:wn,address_map:Fn,"list-services":Bn,select:Hn};function Wn(e){if(!e||typeof e.addComponent!=`function`)throw Error(`registerFormioComponents requires Formio Components with addComponent(name, component)`);return Object.entries(Un).forEach(([t,n])=>{e.addComponent(t,n)}),Un}return e.Calendar=Je,e.CalendarAdvanced=lt,e.FormioAddressMap=Fn,e.FormioDynamicCalendar=We,e.FormioListServices=Bn,e.FormioPageBreak=j,e.SdcFile=wn,e.Select=Hn,e.formioCustomComponents=Un,e.registerFormioComponents=Wn,e})({},_formio_js,react_dom_client,react_jsx_runtime,_formio_react,react,react_day_picker,react_countdown,moment,design_react_kit,sweetalert2,dayjs,_event_calendar_core,react_dropzone,axios,mime,dompurify,jwt_decode,accessible_autocomplete_react,leaflet,lodash);
73
73
  //# sourceMappingURL=index.iife.js.map