PageSourceSearch

https://www.postnord.com/dist/client/pn-ocr-search.entry-20261001.js

js postnord.com collected 2026-10-02 02:20:16 UTC 4,177 bytes, 4 lines download raw bytes

1var i=Object.defineProperty;var o=(e,r,a)=>r in e?i(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a;var t=(e,r,a)=>o(e,typeof r!="symbol"?r+"":r,a);import{r as c,g as l,h as n,H as h,t as s}from"./client-20261001.js";import{b as d,s as u}from"./index-202610013.js";import"./preload-helper-20261001.js";import"./helpers-20261001.js";import"./index-20261001.js";import"./index-202610012.js";/*!
2 * Built with Stencil
3 * By PostNord.
4 */const m={SEARCH_BUTTON:{da:"Search",en:"Search",fi:"Search",no:"Search",sv:"Sök"},SEARCH_SUCCESS:{da:"Your OCR number is",en:"Your OCR number is",fi:"Your OCR number is",no:"Your OCR number is",sv:"Ditt OCR-nummer är"},ERROR_INVALID_LICENSE_NUMBER:{da:"Invalid license number",en:"Invalid license number",fi:"Invalid license number",no:"Invalid license number",sv:"Ogiltligt licensnummer"},ERROR_NO_RESULTS:{da:"The search did not generate any results",en:"The search did not generate any results",fi:"The search did not generate any results",no:"The search did not generate any results",sv:"Sökningen genererade inga träffar"},ERROR_REASON_HEADER:{da:"It may be due to:",en:"It may be due to:",fi:"It may be due to:",no:"It may be due to:",sv:"Det kan bero på:"},ERROR_REASON_ONE:{da:"We could not find that license number",en:"We could not find that license number",fi:"We could not find that license number",no:"We could not find that license number",sv:"Vi hittar inget sådant licensnummer"},ERROR_REASON_TWO:{da:"Check the information and try again.",en:"Check the information and try again.",fi:"Check the information and try again.",no:"Check the information and try again.",sv:"Kontrollera uppgifterna och försök igen."},PLACEHOLDER_TEXT:{da:"License number 6 digits",en:"License number 6 digits",fi:"License number 6 digits",no:"License number 6 digits",sv:"Licensnummer 6 tecken"}},R=()=>`${s("pn-ocr-search")} .bold{font-weight:700}${s("pn-ocr-search")} .search-results,${s("pn-ocr-search")} .error-text-container{padding:1em 0.5em}${s("pn-ocr-search")} .invalid-text-container{padding:0.5em 1em}${s("pn-ocr-search")} .invalid-text-container .invalid-ocr{color:#a70707}`,g=class{constructor(e){t(this,"loading",!1);t(this,"error",!1);t(this,"ocrNumber");t(this,"searchSuccess",!1);t(this,"invalidOcrNumber",!1);t(this,"language",null);c(this,e)}get hostElement(){return l(this)}async componentWillLoad(){this.language===null&&await d(this.hostElement)}getTranslation(e){return m[e][this.language||u]}handleSearch(e){this.invalidOcrNumber=!1,this.searchSuccess=!1,this.error=!1;const r=this.validateOcrNumber(e.detail);if(r.error){this.invalidOcrNumber=!0;return}this.ocrNumberSearch(r.value)}async ocrNumberSearch(e){this.loading=!0,await fetch(`https://portal.postnord.com/public-service/api/ocr?key=${e}`).then(r=>r.json()).then(r=>{this.ocrNumber=r.newOcr,this.searchSuccess=!0}).catch(()=>{this.error=!0,this.searchSuccess=!1}).finally(()=>{this.loading=!1})}validateOcrNumber(e){const r=e?e.replace(/[ -]/gi,""):"";return{error:new RegExp(/\D+/).test(r)||r.length!==6,value:r}}renderSearchResult(){if(!this.loading&&!this.error&&this.searchSuccess)return n("div",{class:"search-results"},this.getTranslation("SEARCH_SUCCESS"),": ",n("b",null,this.ocrNumber))}renderErrorMessage(){if(this.invalidOcrNumber&&!this.loading)return n("div",{class:"invalid-text-container"},n("p",{class:"invalid-ocr"},this.getTranslation("ERROR_INVALID_LICENSE_NUMBER")));if(this.error&&!this.loading)return n("div",{class:"error-text-container"},n("p",{class:"bold"},this.getTranslation("ERROR_NO_RESULTS")),n("p",{class:"bold"},this.getTranslation("ERROR_REASON_HEADER")),n("p",null,this.getTranslation("ERROR_REASON_ONE")),n("p",null,this.getTranslation("ERROR_REASON_TWO")))}render(){return n(h,{key:"c6f418483d78065a3a95f94f18613f76088ae279"},n("pn-search-field",{key:"c28bff48bc802958b6c8c05f54ad9093c3b1708e",loading:this.loading,label:this.getTranslation("SEARCH_BUTTON"),button:"icon",buttonLabel:this.getTranslation("SEARCH_BUTTON"),placeholder:this.getTranslation("PLACEHOLDER_TEXT"),onSearch:e=>this.handleSearch(e)}),this.renderSearchResult(),this.renderErrorMessage())}};g.style=R();export{g as pn_ocr_search};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.