{"version":3,"file":"lost-luggage-QR-generator.min.js","names":["sInputKeyValidationHelper","widgetControlls","widget","widgetSteps","currentWidgetStep","totalWidgetSteps","widgetBanner","banner","progressBar","totalStep","currentStep","title","progressBarStepLength","init","this","Array","from","querySelectorAll","getWidgetBannerNodes","setTotalWidgetSteps","setBackButtonEListeners","showNewWidgetState","length","forEach","step","index","toggleVisibility","updateProgressBar","setWidgetBanner","button","addEventListener","e","decrementWidgetStep","restartWidget","preventDefault","incrementWidgetStep","numberOfWidgetSteps","innerText","querySelector","document","getElementById","style","width","setBannerTitle","getAttribute","element","show","classList","remove","add","setFieldErrorState","field","removeErrorFromInput","lostLuggageQRGenerator","qrCodeElement","qrCode","undefined","vCardText","tagInputValue","cardTextFallback","luggage","phone","key","qrCodeData","name","email","note","forms","tagTypeForm","contactDetailsForm","noteForm","infoTipCard","qrGenerator","getWidgetNodes","addFormSubmitListeners","initiateInputValidation","attachDownloadPDFHandler","handleWidgetRestart","downloadQRCodeButton","lostLuggagePDFBuilder","generatePDF","restartWidgetButton","allFields","setInputValidation","contactDetailFields","addTagFormListener","addContactFormListener","addNoteFormListener","tagTypeInput","processTagTypeSubmission","processUserDataSubmission","noteInput","noteInputCharCount","handleNoteInputCharCount","processNoteSubmission","input","displayNode","totalCount","currentCharCount","value","charCountLeft","createVCard","resetQRCode","generateQRCode","fields","inputWithValidation","inputValidationType","tagTypeSelect","validInputTypes","parseSelectOptionInputs","toggleContactFormInputs","formattedNote","replace","filter","line","trim","join","height","QRCode","text","firstChild","removeChild","inputsFailed","validateContactFormInputValues","invalidFields","dataInputType","contains","push","test","trimmedValue","includes","validateField","inputType","handleTagSelection","selectedOption","inputValue","dataset","qrInfoTipText","qrCodeInfoTip","setCardText","options","selectedIndex","contactInputs","JSON","parse","isFallback","listTextFallback","listText","customStyles","containerStyles","gap","paddingTop","paddingRight","paddingBottom","paddingLeft","bannerStyles","fontSize","borderBottom","qrStyles","listStyles","listItemStyles","marginBottom","wordSpacing","flexDirection","alignItems","marginLeft","listStylePosition","listItem","createPDFLayout","pdfContent","createContainer","qrCodeContainer","createQRCode","createBanner","list","createPDFList","appendChild","styles","container","createElement","id","setCustomStyles","bannerText","listItemText","textContent","Object","entries","property","pixelAsNumber","parseInt","isNaN","pixelAsMM","convertPixelsToMillimeters","pixelValue","pdfLayout","console","error","margin","filename","image","type","quality","html2canvas","scale","jsPDF","unit","format","orientation","html2pdf","set","save","err","widgetContainer"],"sources":["lost-luggage-QR-generator/lost-luggage-QR-generator.js"],"mappings":"OAASA,8BAAiC,sBAG1C,MAAMC,gBAAkB,CACvBC,OAAQ,KACRC,YAAa,GACbC,kBAAmB,EACnBC,iBAAkB,EAElBC,aAAc,CACbC,OAAQ,KACRC,YAAa,KACbC,UAAW,KACXC,YAAa,KACbC,MAAO,KACPC,sBAAuB,GAGxB,IAAAC,CAAKX,GACCA,IAELY,KAAKZ,OAASA,EACdY,KAAKX,YAAcY,MAAMC,KAAKF,KAAKZ,OAAOe,iBAAiB,kBAG3DH,KAAKI,uBACLJ,KAAKK,sBACLL,KAAKM,0BACN,EAGA,kBAAAC,GAEMP,KAAKX,aAA2C,IAA5BW,KAAKX,YAAYmB,SAG1CR,KAAKX,YAAYoB,SAAQ,CAACC,EAAMC,IAAUX,KAAKY,iBAAiBF,EAAMC,EAAQ,IAAMX,KAAKV,qBACzFU,KAAKa,oBACN,EAEA,mBAAAR,GACML,KAAKX,cAEVW,KAAKT,iBAAmBS,KAAKX,YAAYmB,OACzCR,KAAKc,gBAAgBd,KAAKT,kBAC3B,EAEA,uBAAAe,GACqBnB,gBAAgBC,OAAOe,iBAAiB,qBAChDM,SAAQM,GAAUA,EAAOC,iBAAiB,SAASC,GAAK9B,gBAAgB+B,oBAAoBD,MACzG,EAEA,aAAAE,CAAcF,GACbA,EAAEG,iBACFpB,KAAKV,kBAAoB,EACzBU,KAAKO,oBACN,EAEA,mBAAAW,CAAoBD,GACnBA,GAAGG,iBAC4B,IAA3BpB,KAAKV,oBACRU,KAAKV,m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IACtC,GAAI2F,MAAMF,GAET/I,EAAQJ,MAAMkJ,GAAYxF,MACpB,CAEN,MAAM4F,EAAYjL,KAAKkL,2BAA2BJ,GAClD/I,EAAQJ,MAAMkJ,GAAY,GAAGI,KAC9B,KAGMlJ,CACR,EAEAmJ,2BAA2BC,GAGFA,EAFZ,IACO,KAKpB,WAAAjH,CAAYjD,GACXA,EAAEG,iBAEF,MAAMgK,EAAYpL,KAAK0J,kBAEvB,IAAK0B,EAEJ,YADAC,QAAQC,MAAM,mCAKf,MAAMxD,EAAU,CACfyD,OAAQ,EACRC,SAAU,mBACVC,MAAO,CAAEC,KAAM,OAAQC,QAAS,KAChCC,YAAa,CACZC,MAAO,KAERC,MAAO,CACNC,KAAM,KACNC,OAAQ,KACRC,YAAa,aAIf,IACCC,WAAWhM,KAAKkL,GAAWe,IAAIrE,GAASsE,MACzC,CAAE,MAAOC,GACRhB,QAAQC,MAAM,sCAAuCe,EACtD,CACD,GAGD5K,SAAST,iBAAiB,oBAAoB,WAC7C,MAAMsL,EAAkB7K,SAASC,eAAe,2BAE5C4K,IACHnN,gBAAgBY,KAAKuM,GACrB/J,uBAAuBxC,KAAKuM,GAC5BrI,sBAAsBlE,OAExB","ignoreList":[],"sourcesContent":["import { sInputKeyValidationHelper } from '../../shared.min.js';\r\n\r\n//GENERIC WIDGET CONTROLS & HELPER FUNCTIONS\r\nconst widgetControlls = {\r\n\twidget: null,\r\n\twidgetSteps: [],\r\n\tcurrentWidgetStep: 1,\r\n\ttotalWidgetSteps: 0,\r\n\r\n\twidgetBanner: {\r\n\t\tbanner: null,\r\n\t\tprogressBar: null,\r\n\t\ttotalStep: null,\r\n\t\tcurrentStep: null,\r\n\t\ttitle: null,\r\n\t\tprogressBarStepLength: 0,\r\n\t},\r\n\r\n\tinit(widget) {\r\n\t\tif (!widget) return;\r\n\r\n\t\tthis.widget = widget;\r\n\t\tthis.widgetSteps = Array.from(this.widget.querySelectorAll('.widget__step'));\r\n\r\n\t\t//GET NODES FOR BANNER\r\n\t\tthis.getWidgetBannerNodes();\r\n\t\tthis.setTotalWidgetSteps();\r\n\t\tthis.setBackButtonEListeners();\r\n\t},\r\n\r\n\t//WIDGET NAVIGATION\r\n\tshowNewWidgetState() {\r\n\t\t//INCREMENT APP AND HIDE/SHOW NEW/PREV APP STEP\r\n\t\tif (!this.widgetSteps || this.widgetSteps.length === 0) return;\r\n\r\n\t\t//IF WIDGET STEPS IS EQUAL TO CURRENT WIDGET STEPS, SHOW STEP, ELSE HIDE\r\n\t\tthis.widgetSteps.forEach((step, index) => this.toggleVisibility(step, index + 1 === this.currentWidgetStep));\r\n\t\tthis.updateProgressBar();\r\n\t},\r\n\r\n\tsetTotalWidgetSteps() {\r\n\t\tif (!this.widgetSteps) return;\r\n\r\n\t\tthis.totalWidgetSteps = this.widgetSteps.length;\r\n\t\tthis.setWidgetBanner(this.totalWidgetSteps);\r\n\t},\r\n\r\n\tsetBackButtonEListeners() {\r\n\t\tconst backButtons = widgetControlls.widget.querySelectorAll('.arrow-link--back');\r\n\t\tbackButtons.forEach(button => button.addEventListener('click', e => widgetControlls.decrementWidgetStep(e)));\r\n\t},\r\n\r\n\trestartWidget(e) {\r\n\t\te.preventDefault();\r\n\t\tthis.currentWidgetStep = 1;\r\n\t\tthis.showNewWidgetState();\r\n\t},\r\n\r\n\tdecrementWidgetStep(e) {\r\n\t\te?.preventDefault();\r\n\t\tif (this.currentWidgetStep !== 1) {\r\n\t\t\tthis.currentWidgetStep -= 1;\r\n\t\t\tthis.showNewWidgetState();\r\n\t\t}\r\n\t},\r\n\r\n\tincrementWidgetStep() {\r\n\t\t//RESET APP IF REACHES END ELSE\r\n\t\tif (this.currentWidgetStep < this.totalWidgetSteps) {\r\n\t\t\tthis.currentWidgetStep += 1;\r\n\t\t} else {\r\n\t\t\tthis.currentWidgetStep = 1;\r\n\t\t}\r\n\t\tthis.showNewWidgetState();\r\n\t},\r\n\r\n\t//BANNER FUNCTIONALITY\r\n\tsetWidgetBanner(numberOfWidgetSteps) {\r\n\t\tconst { widgetBanner } = this;\r\n\r\n\t\twidgetBanner.progressBarStepLength = 100 / numberOfWidgetSteps;\r\n\t\tif (widgetBanner.totalStep) widgetBanner.totalStep.innerText = numberOfWidgetSteps;\r\n\r\n\t\tthis.updateProgressBar();\r\n\t},\r\n\r\n\tgetWidgetBannerNodes() {\r\n\t\tconst { widget, widgetBanner } = this;\r\n\r\n\t\tif (!widget) return;\r\n\r\n\t\twidgetBanner.banner = widget.querySelectorAll('.widget__banner');\r\n\t\twidgetBanner.progressBar = widget.querySelector('.widget__banner__progress-bar__step');\r\n\t\twidgetBanner.currentStep = document.getElementById('banner-step-current');\r\n\t\twidgetBanner.totalStep = document.getElementById('banner-step-total');\r\n\t\twidgetBanner.title = document.querySelector('.widget__banner__header__title');\r\n\t},\r\n\r\n\tupdateProgressBar() {\r\n\t\tconst { widgetBanner, currentWidgetStep } = this;\r\n\r\n\t\twidgetBanner.progressBar.style.width = `${widgetBanner.progressBarStepLength * currentWidgetStep}%`;\r\n\t\twidgetBanner.currentStep.innerText = currentWidgetStep;\r\n\r\n\t\tthis.setBannerTitle();\r\n\t},\r\n\r\n\tsetBannerTitle() {\r\n\t\tconst { widgetSteps, widgetBanner, currentWidgetStep } = this;\r\n\r\n\t\tconst currentStep = widgetSteps[currentWidgetStep - 1];\r\n\t\twidgetBanner.title.innerText = currentStep.getAttribute('data-step-name');\r\n\t},\r\n\r\n\t//VISIBILITY CONTROLLS\r\n\r\n\ttoggleVisibility(element, show) {\r\n\t\tif (show) {\r\n\t\t\telement.classList.remove('display-none');\r\n\t\t} else {\r\n\t\t\telement.classList.add('display-none');\r\n\t\t}\r\n\t},\r\n\r\n\t//ERROR STATES\r\n\r\n\tsetFieldErrorState(field) {\r\n\t\tfield.classList.add('field-group--error');\r\n\t},\r\n\r\n\tremoveErrorFromInput(field) {\r\n\t\tfield.classList.remove('field-group--error');\r\n\t},\r\n};\r\n\r\n//HANDLES FUNCTIONALITY FOR QR GERNERATION\r\n\r\nconst lostLuggageQRGenerator = {\r\n\tqrCodeElement: null,\r\n\tqrCode: undefined,\r\n\tvCardText: '',\r\n\ttagInputValue: null,\r\n\r\n\tcardTextFallback: {\r\n\t\tluggage: 'Consider placing it in the address holder that many cases come with.',\r\n\t\tphone: 'Consider placing the tag in the back of your phone case or card holder.',\r\n\t\tkey: 'Consider placing the tag in a key ring holder.',\r\n\t},\r\n\r\n\tqrCodeData: {\r\n\t\tname: '',\r\n\t\tphone: '',\r\n\t\temail: '',\r\n\t\tnote: '',\r\n\t},\r\n\r\n\tforms: {\r\n\t\ttagTypeForm: null,\r\n\t\tcontactDetailsForm: null,\r\n\t\tnoteForm: null,\r\n\t},\r\n\r\n\tinfoTipCard: null,\r\n\r\n\tinit(qrGenerator) {\r\n\t\t//GET ELEMENTS\r\n\t\tthis.getWidgetNodes();\r\n\r\n\t\t//SET UP E-LISTENERS\r\n\t\tthis.addFormSubmitListeners();\r\n\r\n\t\t//INPUT VALIDATION\r\n\t\tthis.initiateInputValidation(qrGenerator);\r\n\r\n\t\t//DOWNLOAD PDF\r\n\t\tthis.attachDownloadPDFHandler();\r\n\r\n\t\t//RESTARD WIDGET\r\n\t\tthis.handleWidgetRestart();\r\n\t},\r\n\r\n\tgetWidgetNodes() {\r\n\t\tconst { forms } = this;\r\n\r\n\t\t//GET FORMS\r\n\t\tforms.tagTypeForm = document.getElementById('cnfsd-wdgt-lost-luggage-tag-form');\r\n\t\tforms.contactDetailsForm = document.getElementById('cnfsd-wdgt-lost-luggage-details-form');\r\n\t\tforms.noteForm = document.getElementById('cnfsd-wdgt-lost-luggage-note-form');\r\n\r\n\t\t//GET QR CODE CONTAINER\r\n\t\tthis.qrCodeElement = document.querySelector('.widget__step > .widget__qr-container');\r\n\r\n\t\t//GET CARD\r\n\t\tthis.infoTipCard = document.getElementById('cnfsd-wdgt-lost-luggage-qr-code-info-tip');\r\n\t},\r\n\r\n\tattachDownloadPDFHandler() {\r\n\t\t//DOWNLOAD QR CODE BUTTON\r\n\t\tconst downloadQRCodeButton = document.getElementById('cnfsd-wdgt-lost-luggage-download-code');\r\n\t\tdownloadQRCodeButton?.addEventListener('click', e => lostLuggagePDFBuilder.generatePDF(e));\r\n\t},\r\n\r\n\thandleWidgetRestart() {\r\n\t\tconst restartWidgetButton = document.querySelector('.widget__restart');\r\n\t\trestartWidgetButton?.addEventListener('click', e => widgetControlls.restartWidget(e));\r\n\t},\r\n\r\n\tinitiateInputValidation(qrGenerator) {\r\n\t\t//SET UP USER INPUT VALIDATION\r\n\t\tconst allFields = qrGenerator.querySelectorAll('.field-group');\r\n\t\tthis.setInputValidation(allFields);\r\n\t},\r\n\r\n\taddFormSubmitListeners() {\r\n\t\tconst { forms } = this;\r\n\r\n\t\tconst contactDetailFields = forms.contactDetailsForm?.querySelectorAll('.field-group') || [];\r\n\t\tthis.addTagFormListener(contactDetailFields);\r\n\t\tthis.addContactFormListener(contactDetailFields);\r\n\t\tthis.addNoteFormListener();\r\n\t},\r\n\r\n\taddTagFormListener(contactDetailFields) {\r\n\t\tconst { forms } = this;\r\n\r\n\t\tconst tagTypeInput = document.getElementById('cnfsd-wdgt-lost-luggage-tag-type');\r\n\t\tforms.tagTypeForm?.addEventListener('submit', e => {\r\n\t\t\te.preventDefault();\r\n\t\t\tthis.processTagTypeSubmission(tagTypeInput, contactDetailFields);\r\n\t\t});\r\n\t},\r\n\r\n\taddContactFormListener(contactDetailFields) {\r\n\t\tconst { forms } = this;\r\n\r\n\t\tforms.contactDetailsForm?.addEventListener('submit', e => {\r\n\t\t\te.preventDefault();\r\n\t\t\tthis.processUserDataSubmission(contactDetailFields);\r\n\t\t});\r\n\t},\r\n\r\n\taddNoteFormListener() {\r\n\t\tconst { forms } = this;\r\n\r\n\t\tconst noteInput = document.getElementById('cnfsd-wdgt-lost-luggage-note');\r\n\t\tconst noteInputCharCount = document.getElementById('cnfsd-wdgt-lost-luggage-note-charcount');\r\n\r\n\t\tnoteInput.addEventListener('input', () => this.handleNoteInputCharCount(noteInput, noteInputCharCount, 200));\r\n\r\n\t\tforms.noteForm?.addEventListener('submit', e => {\r\n\t\t\te.preventDefault();\r\n\t\t\tthis.processNoteSubmission(noteInput);\r\n\t\t});\r\n\t},\r\n\r\n\thandleNoteInputCharCount(input, displayNode, totalCount) {\r\n\t\tconst currentCharCount = input.value.length;\r\n\t\tconst charCountLeft = totalCount - currentCharCount;\r\n\r\n\t\t//IF DOESN'T EXCEED TOTAL COUNT\r\n\t\tif (currentCharCount !== totalCount + 1) displayNode.innerText = `${charCountLeft} characters remaining`;\r\n\t},\r\n\r\n\tprocessNoteSubmission(noteInput) {\r\n\t\tconst { qrCodeData, qrCodeElement } = this;\r\n\r\n\t\t//SET NOTE IN QR DATA TO NOTE INPUT VALUE\r\n\t\tqrCodeData.note = noteInput.value;\r\n\r\n\t\t//CREATE V CARD\r\n\t\tthis.vCardText = this.createVCard();\r\n\r\n\t\t//RESET QR CODE IF ONE ALREADY EXISTS\r\n\t\tif (this.qrCode !== undefined) this.resetQRCode();\r\n\r\n\t\tthis.qrCode = this.generateQRCode(qrCodeElement);\r\n\t\t//INCREMENT NAV STEP\r\n\t\twidgetControlls.incrementWidgetStep();\r\n\t},\r\n\r\n\tsetInputValidation(fields) {\r\n\t\tfields.forEach(field => {\r\n\t\t\tconst inputWithValidation = field.querySelector('input[data-input-validation]');\r\n\t\t\tif (inputWithValidation) {\r\n\t\t\t\tconst inputValidationType = inputWithValidation.getAttribute('data-input-validation');\r\n\t\t\t\tsInputKeyValidationHelper(inputWithValidation, inputValidationType, field);\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n\r\n\tprocessTagTypeSubmission(tagTypeSelect, contactDetailFields) {\r\n\t\tconst validInputTypes = this.parseSelectOptionInputs(tagTypeSelect);\r\n\t\tthis.toggleContactFormInputs(contactDetailFields, validInputTypes);\r\n\t\twidgetControlls.incrementWidgetStep();\r\n\t},\r\n\r\n\tcreateVCard() {\r\n\t\tconst { name, email, phone, note } = this.qrCodeData;\r\n\r\n\t\tconst formattedNote = note.replace(/\\n/g, '\\\\n');\r\n\r\n\t\tconst vCardLines = [\r\n\t\t\t'BEGIN:VCARD',\r\n\t\t\t'VERSION:3.0',\r\n\t\t\t`FN:${name}`,\r\n\t\t\tphone ? `TEL;TYPE=CELL,VOICE:${phone}` : '',\r\n\t\t\temail ? `EMAIL:${email}` : '',\r\n\t\t\tnote ? `NOTE:${formattedNote}` : '',\r\n\t\t\t'END:VCARD',\r\n\t\t];\r\n\r\n\t\t//FILTER ANY EMPTY LINES AND THEN JOIN THE REST\r\n\t\treturn vCardLines.filter(line => line.trim() !== '').join('\\n');\r\n\t},\r\n\r\n\tgenerateQRCode(element, width = 142, height = 142) {\r\n\t\tconst { vCardText } = this;\r\n\r\n\t\treturn new QRCode(element, {\r\n\t\t\ttext: vCardText,\r\n\t\t\twidth: width,\r\n\t\t\theight: height,\r\n\t\t});\r\n\t},\r\n\r\n\tresetQRCode() {\r\n\t\tconst { qrCodeElement } = this;\r\n\t\t//REMOVE CURRENT QR BEFORE GENERATING A NEW ONE\r\n\t\twhile (qrCodeElement.firstChild) {\r\n\t\t\tqrCodeElement.removeChild(qrCodeElement.firstChild);\r\n\t\t}\r\n\t},\r\n\r\n\tprocessUserDataSubmission(fields) {\r\n\t\t//CHECK INPUTS PASS VALIDATION\r\n\t\tconst inputsFailed = this.validateContactFormInputValues(fields);\r\n\r\n\t\t//IF THERE ARE INPUTS WITH ERRORS, SHOW ERROR MESSAGE OF INPUT\r\n\t\tif (inputsFailed.length) {\r\n\t\t\tinputsFailed.forEach(field => {\r\n\t\t\t\twidgetControlls.setFieldErrorState(field);\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\t//GENERATE QR HERE\r\n\t\t\twidgetControlls.incrementWidgetStep();\r\n\t\t}\r\n\t},\r\n\r\n\tvalidateContactFormInputValues(fields) {\r\n\t\t//CONTACT FORM USER INPUT VALIDATION\r\n\t\tconst { qrCodeData } = this;\r\n\r\n\t\tconst invalidFields = [];\r\n\t\tconst validateField = field => {\r\n\t\t\t//IF FIELD IS HIDDEN (NOT USED IN VCARD), SET DATA BACK TO EMPTY STRING\r\n\r\n\t\t\tconst input = field.querySelector('input');\r\n\t\t\tconst value = input?.value.trim();\r\n\t\t\tconst dataInputType = input?.getAttribute('data-input-type');\r\n\r\n\t\t\tif (field.classList.contains('display-none')) return (qrCodeData[dataInputType] = '');\r\n\r\n\t\t\t//CHECK EACH FIELD TYPE\r\n\t\t\tswitch (dataInputType) {\r\n\t\t\t\tcase 'name':\r\n\t\t\t\t\tif (!value) invalidFields.push(field);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'email':\r\n\t\t\t\t\tconst regex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\r\n\t\t\t\t\tif (!value || !regex.test(value)) invalidFields.push(field);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'phone':\r\n\t\t\t\t\tconst trimmedValue = value.replace(/\\s+/g, '');\r\n\t\t\t\t\tif (!value || (trimmedValue.length !== 10 && trimmedValue.length !== 11)) invalidFields.push(field);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tif (!value) invalidFields.push(field);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\t// SET THE VALUE TO THE QR DATA IF VALID INPUT\r\n\t\t\tif (!invalidFields.includes(field)) qrCodeData[dataInputType] = value;\r\n\t\t};\r\n\r\n\t\tfields.forEach(field => validateField(field));\r\n\r\n\t\treturn invalidFields;\r\n\t},\r\n\r\n\ttoggleContactFormInputs(contactDetailFields, validInputTypes) {\r\n\t\tcontactDetailFields.forEach(field => {\r\n\t\t\tconst input = field.querySelector('input');\r\n\t\t\tconst inputType = input.getAttribute('data-input-type');\r\n\r\n\t\t\tif (validInputTypes.includes(inputType)) {\r\n\t\t\t\twidgetControlls.toggleVisibility(field, true);\r\n\t\t\t} else {\r\n\t\t\t\twidgetControlls.toggleVisibility(field, false);\r\n\t\t\t}\r\n\t\t});\r\n\t},\r\n\r\n\thandleTagSelection(selectedOption) {\r\n\t\tconst inputValue = selectedOption.dataset.inputValue;\r\n\t\tconst qrInfoTipText = selectedOption.dataset.qrCodeInfoTip;\r\n\t\t//SET THE TAG TYPE FOR USE IN PDF GENERATOR\r\n\t\tlostLuggagePDFBuilder.tagInputValue = inputValue;\r\n\r\n\t\t//CHECKS IF INFO CARD TEXT HAS BEEN SET FROM CMS\r\n\t\tqrInfoTipText ? this.setCardText(qrInfoTipText, false) : this.setCardText(inputValue, true);\r\n\t},\r\n\r\n\tparseSelectOptionInputs(tagTypeSelect) {\r\n\t\t//GET DATA ATTRIBUTE FROM OPTION SELECTED TO GENERATE INPUTS\r\n\t\tconst selectedOption = tagTypeSelect.options[tagTypeSelect.selectedIndex];\r\n\t\tconst contactInputs = JSON.parse(selectedOption.dataset.contactInputs);\r\n\r\n\t\tthis.handleTagSelection(selectedOption);\r\n\r\n\t\treturn contactInputs;\r\n\t},\r\n\r\n\tsetCardText(value, isFallback) {\r\n\t\tconst { infoTipCard, cardTextFallback } = this;\r\n\r\n\t\t//IF INFO CARD TEXT SET FROM CMS, USE THAT, ELSE USE STATIC\r\n\t\tconst qrInfoTipText = isFallback ? cardTextFallback[value] : value;\r\n\t\tinfoTipCard.innerText = qrInfoTipText;\r\n\t},\r\n};\r\n\r\n//HANDLES FUNCTIONALITY FOR PDF GERNERATION\r\n\r\nconst lostLuggagePDFBuilder = {\r\n\tlistTextFallback: [\"Scan QR code to view owner's details\", 'safely return the item to its owner'],\r\n\tlistText: [],\r\n\ttagInputValue: null,\r\n\r\n\tcustomStyles: {\r\n\t\tluggage: {\r\n\t\t\tcontainerStyles: {\r\n\t\t\t\tgap: 67,\r\n\t\t\t\tpaddingTop: 185,\r\n\t\t\t\tpaddingRight: 54,\r\n\t\t\t\tpaddingBottom: 60,\r\n\t\t\t\tpaddingLeft: 54,\r\n\t\t\t\twidth: 1181,\r\n\t\t\t\theight: 591,\r\n\t\t\t},\r\n\t\t\tbannerStyles: {\r\n\t\t\t\tfontSize: 50,\r\n\t\t\t\tpaddingTop: 25,\r\n\t\t\t\tpaddingRight: 60,\r\n\t\t\t\tpaddingBottom: 25,\r\n\t\t\t\tpaddingLeft: 60,\r\n\t\t\t\theight: 125,\r\n\t\t\t\tborderBottom: 1,\r\n\t\t\t},\r\n\t\t\tqrStyles: { width: 358, height: 358 },\r\n\t\t\tlistStyles: {},\r\n\t\t\tlistItemStyles: { fontSize: 42, marginBottom: 34, wordSpacing: 3 },\r\n\t\t},\r\n\t\tphone: {\r\n\t\t\tcontainerStyles: {\r\n\t\t\t\tgap: 67,\r\n\t\t\t\tpaddingTop: 185,\r\n\t\t\t\tpaddingRight: 54,\r\n\t\t\t\tpaddingBottom: 60,\r\n\t\t\t\tpaddingLeft: 54,\r\n\t\t\t\twidth: 1063,\r\n\t\t\t\theight: 591,\r\n\t\t\t},\r\n\t\t\tbannerStyles: {\r\n\t\t\t\tfontSize: 50,\r\n\t\t\t\tpaddingTop: 25,\r\n\t\t\t\tpaddingRight: 60,\r\n\t\t\t\tpaddingBottom: 25,\r\n\t\t\t\tpaddingLeft: 60,\r\n\t\t\t\theight: 125,\r\n\t\t\t\tborderBottom: 1,\r\n\t\t\t},\r\n\t\t\tqrStyles: { width: 358, height: 358 },\r\n\t\t\tlistStyles: {},\r\n\t\t\tlistItemStyles: { fontSize: 42, marginBottom: 34, wordSpacing: 3 },\r\n\t\t},\r\n\t\tkey: {\r\n\t\t\tcontainerStyles: {\r\n\t\t\t\tgap: 16,\r\n\t\t\t\tpaddingTop: 92,\r\n\t\t\t\tpaddingRight: 24,\r\n\t\t\t\tpaddingBottom: 28,\r\n\t\t\t\tpaddingLeft: 24,\r\n\t\t\t\twidth: 354,\r\n\t\t\t\theight: 472,\r\n\t\t\t\tflexDirection: 'column',\r\n\t\t\t\talignItems: 'flex-start',\r\n\t\t\t},\r\n\t\t\tbannerStyles: {\r\n\t\t\t\tfontSize: 26,\r\n\t\t\t\tpaddingTop: 17,\r\n\t\t\t\tpaddingRight: 24,\r\n\t\t\t\tpaddingBottom: 17,\r\n\t\t\t\tpaddingLeft: 24,\r\n\t\t\t\theight: 68,\r\n\t\t\t\tborderBottom: 1,\r\n\t\t\t},\r\n\t\t\tqrStyles: { width: 200, height: 200 },\r\n\t\t\tlistStyles: { width: 306, marginLeft: 0, listStylePosition: 'inside' },\r\n\t\t\tlistItemStyles: { fontSize: 22, marginBottom: 16, wordSpacing: 3 },\r\n\t\t},\r\n\t},\r\n\r\n\tinit() {\r\n\t\tconst { listText } = this;\r\n\r\n\t\tconst pdfGeneratorPDFTemplate = document.getElementById('cnsfg-wdgt-lost-luggage-pdf-info');\r\n\t\tconst listItems = pdfGeneratorPDFTemplate.querySelectorAll('li');\r\n\r\n\t\tlistItems.forEach(listItem => listText.push(listItem.innerText));\r\n\t},\r\n\r\n\tcreatePDFLayout() {\r\n\t\tconst { customStyles, tagInputValue } = this;\r\n\r\n\t\tconst styles = customStyles[tagInputValue];\r\n\t\tif (!styles) return null;\r\n\r\n\t\tconst { containerStyles, bannerStyles, qrStyles, listStyles, listItemStyles } = customStyles[tagInputValue];\r\n\r\n\t\tconst pdfContent = this.createContainer(containerStyles);\r\n\t\tif (!pdfContent) return null;\r\n\r\n\t\tconst qrCodeContainer = this.createQRCode(qrStyles);\r\n\t\tconst banner = this.createBanner(bannerStyles);\r\n\t\tconst list = this.createPDFList(listStyles, listItemStyles);\r\n\r\n\t\tpdfContent.appendChild(banner);\r\n\t\tpdfContent.appendChild(qrCodeContainer);\r\n\t\tpdfContent.appendChild(list);\r\n\r\n\t\treturn pdfContent;\r\n\t},\r\n\r\n\tcreateContainer(styles) {\r\n\t\tif (!styles) return null;\r\n\t\tconst container = document.createElement('div');\r\n\t\tcontainer.id = 'cnfsd-wdgt-lost-luggage-pdf';\r\n\t\tcontainer.classList.add('pdf-content');\r\n\r\n\t\t//\tRETURNS NEW CONTAINER ELEMENT WITH CUSTOM STYLES BASED ON SELECTED TAG\r\n\t\treturn this.setCustomStyles(container, styles);\r\n\t},\r\n\r\n\tcreateBanner(styles) {\r\n\t\tconst banner = document.createElement('div');\r\n\t\tbanner.classList.add('pdf-content__banner');\r\n\r\n\t\tconst bannerText = document.createElement('b');\r\n\t\tbannerText.innerText = 'Lost item';\r\n\r\n\t\tbanner.appendChild(bannerText);\r\n\r\n\t\treturn this.setCustomStyles(banner, styles);\r\n\t},\r\n\r\n\tcreatePDFList(listStyles, listItemStyles) {\r\n\t\tconst { listText, listTextFallback } = this;\r\n\r\n\t\t//IF LIST ITEM EXISTS IN CMS, USE THAT ELSE USE FALLBACK\r\n\t\tconst listItem = listText.length ? listText : listTextFallback;\r\n\r\n\t\tconst list = document.createElement('ul');\r\n\t\tlistItem.forEach(listItemText => {\r\n\t\t\tconst listItem = document.createElement('li');\r\n\t\t\tlistItem.textContent = listItemText;\r\n\t\t\tthis.setCustomStyles(listItem, listItemStyles);\r\n\t\t\tlist.appendChild(listItem);\r\n\t\t});\r\n\r\n\t\treturn this.setCustomStyles(list, listStyles);\r\n\t},\r\n\r\n\tcreateQRCode(styles) {\r\n\t\tconst { width, height } = styles;\r\n\r\n\t\tconst qrCodeContainer = document.createElement('div');\r\n\t\tqrCodeContainer.classList.add('pdf-content__qr-container');\r\n\r\n\t\t//CREATE QR CODE FOR PDF\r\n\t\tlostLuggageQRGenerator.generateQRCode(qrCodeContainer, width, height);\r\n\r\n\t\treturn this.setCustomStyles(qrCodeContainer, styles);\r\n\t},\r\n\r\n\tsetCustomStyles(element, styles) {\r\n\t\tObject.entries(styles).forEach(([property, value]) => {\r\n\t\t\tconst pixelAsNumber = parseInt(value, 10);\r\n\t\t\tif (isNaN(pixelAsNumber)) {\r\n\t\t\t\t//IF NOT A NUMBER, SET STYLE PROPERTY\r\n\t\t\t\telement.style[property] = value;\r\n\t\t\t} else {\r\n\t\t\t\t//CONVERT PIXEL VALUE INTO MM FOR PRINTING\r\n\t\t\t\tconst pixelAsMM = this.convertPixelsToMillimeters(pixelAsNumber);\r\n\t\t\t\telement.style[property] = `${pixelAsMM}mm`;\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn element;\r\n\t},\r\n\r\n\tconvertPixelsToMillimeters(pixelValue) {\r\n\t\tconst dpi = 300;\r\n\t\tconst inchesInMM = 25.4;\r\n\t\tconst pixelValueInMM = (pixelValue / dpi) * inchesInMM;\r\n\t\treturn pixelValueInMM;\r\n\t},\r\n\r\n\tgeneratePDF(e) {\r\n\t\te.preventDefault();\r\n\r\n\t\tconst pdfLayout = this.createPDFLayout();\r\n\r\n\t\tif (!pdfLayout) {\r\n\t\t\tconsole.error('PDF layout could not be created');\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// OPTIONS FOR PDF GENERATION\r\n\t\tconst options = {\r\n\t\t\tmargin: 5,\r\n\t\t\tfilename: 'Lost-QR-Code.pdf',\r\n\t\t\timage: { type: 'jpeg', quality: 0.98 },\r\n\t\t\thtml2canvas: {\r\n\t\t\t\tscale: 1.5,\r\n\t\t\t},\r\n\t\t\tjsPDF: {\r\n\t\t\t\tunit: 'mm',\r\n\t\t\t\tformat: 'a4',\r\n\t\t\t\torientation: 'portrait',\r\n\t\t\t},\r\n\t\t};\r\n\r\n\t\ttry {\r\n\t\t\thtml2pdf().from(pdfLayout).set(options).save();\r\n\t\t} catch (err) {\r\n\t\t\tconsole.error('Error generating or saving the PDF:', err);\r\n\t\t}\r\n\t},\r\n};\r\n\r\ndocument.addEventListener('DOMContentLoaded', function () {\r\n\tconst widgetContainer = document.getElementById('cnfsd-wdgt-lost-luggage');\r\n\r\n\tif (widgetContainer) {\r\n\t\twidgetControlls.init(widgetContainer);\r\n\t\tlostLuggageQRGenerator.init(widgetContainer);\r\n\t\tlostLuggagePDFBuilder.init();\r\n\t}\r\n});\r\n"]}