1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jspdf.es.min-C5xPL-AM.js","assets/index-BUI1Sc0V.js","assets/index-B8rU0zE_.css"])))=>i.map(i=>d[i]); 2import{q as Q,A as G,C as Ii,N as Ri,v as ua,l as o,w as t,B as wi,O as Ti,F as _i,J as Ei,G as Ai,H as Di,x as ir,P as Pi,Q as Li,z as E,y as or,M as Oi,I as T,_ as Fi}from"./index-BUI1Sc0V.js";import{U as Mi,r as ln}from"./UserMenu-Dfn60PMe.js";import{n as ma,B as Ki,t as lr,x as Gs,o as Ui,g as Ce,T as zi,A as qi,a as Bi,b as $i,e as Gi,c as Wi,p as Vi,q as Yi,F as pn,w as Ws,N as fn,P as Hi,v as Qi,m as Zi,C as Ji,D as Xi,E as eo,G as to}from"./addressApi-CiYEzu4j.js";import{g as q,a as no}from"./apiMode-S8LIAw05.js";import{a as Me,p as hr,i as ro,g as Vs,e as cr,b as so,c as ao,d as io}from"./projectCreditApi-D2g_0ksw.js";/* empty css */import{c as Ke,b as mn,f as dr,a as oo}from"./formatUtcTimestamp-BTLbyeO9.js";import{h as lo}from"./nativeDocumentBridge-D6udmHhj.js";import{r as Ys,s as cn,u as co}from"./Spacetime-Ci26XPxE.js";import"./propaneOrderContract-0EUUdmZu.js";import"./_commonjsHelpers-Cpj98o6Y.js";function Ie(e){return String(e??"").trim().replace(/\s+/g," ")}function gn(e){return Ie(e).toLocaleLowerCase("nb-NO")}const uo=/^(\d{4})\s+(.+)$/;function pa(e){const r=Ie(e);if(!r)return{deliveryAddress:"",postalCode:"",city:""};const a=r.split(",").map(Ie).filter(Boolean);let c="",i="";const d=[];return a.forEach(f=>{const m=f.match(uo);if(m){c||(c=m[1],i=Ie(m[2]));return}d.some(j=>gn(j)===gn(f))||d.push(f)}),{deliveryAddress:d.join(", ")||r,postalCode:c,city:i}}function mo(e){return pa(e).deliveryAddress}function po(e){const r=Ie((e==null?void 0:e.city)??(e==null?void 0:e.poststed)),a=Ie([e==null?void 0:e.postalCode,r].filter(Boolean).join(" ")),c=Ie(e==null?void 0:e.municipalityName),i=c&&gn(c)!==gn(r)?c:"";return[a,i].filter(Boolean).join(" · ")}function yr(e){return String(e??"").trim().toLocaleLowerCase("nb-NO")}function Hs(e){const r=new Set;return(Array.isArray(e)?e:[]).filter(a=>{const c=[a==null?void 0:a.id,a==null?void 0:a.displayText,a==null?void 0:a.postalCode,(a==null?void 0:a.city)||(a==null?void 0:a.poststed)].map(yr).join("|");return!c||r.has(c)?!1:(r.add(c),!0)})}async function fo(e,r,a,c={}){const i=String(r??"").trim(),d=String(a??"").trim(),f=await e(i,c);if(f.length>0||!d||yr(d)===yr(i))return Hs(f);const m=await e(d,c);return Hs(m)}const go={getAll:()=>Q(`${G}/customer/stations`)},ur={getAll:()=>Q(`${G}/customer/delivery-organizations`),getPrimary:()=>Q(`${G}/customer/primary-delivery-organization`),setPrimary:e=>Q(`${G}/customer/primary-delivery-organization`,{method:"PUT",body:JSON.stringify({organizationNumber:e})})};function ho(e){return`${G}/customer/sales-ledger/stories/${encodeURIComponent(e)}/receipt.pdf`}const dn={getStories:()=>Q(`${G}/customer/sales-ledger/stories`),getReceiptText:e=>Ri(`${G}/customer/sales-ledger/stories/${encodeURIComponent(e)}/receipt-text`),getReceiptPdf:e=>Ii(ho(e))},ct={startSession:(e,r)=>Q(`${G}/customer/stations/${encodeURIComponent(e)}/dispenser-sessions`,{method:"POST",body:JSON.stringify(r)}),cancelSession:(e,r)=>Q(`${G}/customer/stations/${encodeURIComponent(e)}/dispenser-sessions/${encodeURIComponent(r)}/cancel`,{method:"POST"}),createNativeWalletAuthorization:(e,r)=>Q(`${G}/customer/stations/${encodeURIComponent(e)}/dispenser-sessions/native-wallet`,{method:"POST",body:JSON.stringify(r)}),verifyNativeWalletAuthorization:(e,r,a)=>Q(`${G}/customer/stations/${encodeURIComponent(e)}/dispenser-sessions/${encodeURIComponent(r)}/native-wallet/verify`,{method:"POST",body:JSON.stringify({paymentIntentId:a})}),connect:(e,r)=>Q(`${G}/customer/dispenser/connect`,{method:"POST",body:JSON.stringify({stationId:e,paymentMethod:r})}),disconnect:()=>Q(`${G}/customer/dispenser/disconnect`,{method:"POST"})},yo=new Set(["propane_order_address_verification_required","address_validation_required","delivery_address_validation_required"]),vo=new Set(["propane_order_address_verification_invalid","address_validation_invalid","address_validation_expired","delivery_address_validation_invali
2d","delivery_address_validation_expired"]);function bo(e){var r,a,c;return String(((r=e==null?void 0:e.data)==null?void 0:r.code)??((c=(a=e==null?void 0:e.data)==null?void 0:a.extensions)==null?void 0:c.code)??(e==null?void 0:e.code)??"").trim().toLowerCase()}function No(e){const r=bo(e);return yo.has(r)?"selection_required":vo.has(r)?"selection_invalid":null}function xo(e,r){if(!r)return!1;const a=[r.streetName,`${r.houseNumber??""}${r.houseLetter??""}`.trim()].filter(Boolean).join(" ").trim()||r.displayText||"",c=r.city||r.poststed||"";return e.leveringsadresse===a&&e.postnummer===(r.postalCode||"")&&e.sted===c}function jo(){return{selectedAddressSuggestion:null,addressSuggestions:[],addressSearchStatus:"idle",addressSuggestionsOpen:!0,activeAddressSuggestionIndex:-1,approvedAddressMismatchContext:null,approvedAddressMismatchChallenge:null,addressMismatchReview:null}}function ko(){const{t:e}=ua("common"),[r,a]=o.useState(""),[c,i]=o.useState(null),[d,f]=o.useState(!1),[m,j]=o.useState(""),y=async P=>{P.preventDefault(),f(!0),i(null),j("");try{const _=r.trim();if(!_){j("Skriv inn et kupongnavn.");return}const F=await hr.validateVoucher(_);i(F)}catch{j(e("contentUpdateFailed"))}finally{f(!1)}},k=(c==null?void 0:c.valid)===!0,A=String((c==null?void 0:c.status)??"").toLowerCase(),Z=!k&&A==="access_required";return t.jsxs("div",{className:"cp-card project-credit-section cp-project-voucher",children:[t.jsx("h2",{children:"Prosjektkupong"}),t.jsx("p",{children:"Kontroller at en prosjektkupong er gyldig før den brukes ved stasjonen."}),t.jsxs("form",{className:"project-credit-form",onSubmit:y,children:[t.jsxs("label",{children:["Kupongnavn",t.jsx("input",{required:!0,value:r,onChange:P=>a(P.target.value),placeholder:"OSLO RIGG",autoComplete:"off"})]}),t.jsx("button",{type:"submit",className:"ui-button ui-button--primary project-credit-button",disabled:d,children:d?"Sjekker...":"Sjekk kupong"})]}),m&&t.jsx("div",{className:"project-credit-message is-error",role:"alert",children:m}),c&&t.jsxs("div",{className:"project-credit-panel",children:[t.jsx("span",{className:`project-credit-badge project-credit-badge--${k?"valid":"invalid"}`,children:k?"Gyldig":"Ikke gyldig"}),t.jsx("h3",{children:k?c.projectName:Z?"Prosjekttilgang mangler":"Kupongen kan ikke brukes"}),k?t.jsx("div",{className:"project-credit-stack",children:t.jsxs("div",{className:"project-credit-meta",children:[t.jsx("span",{children:c.companyName}),t.jsx("span",{children:c.projectName}),t.jsxs("span",{children:["Gjenstår: ",Me(c.projectRemainingAmountOre)]})]})}):Z?t.jsx("p",{children:"Kupongen finnes, men brukeren er ikke tildelt aktiv tilgang til prosjektet."}):t.jsxs("p",{children:["Status: ",A||"ukjent"]})]})]})}const So="/google-pay-button-dark.png";function Co({wallet:e,disabled:r,onClick:a,ariaLabel:c}){return e==="applePay"?t.jsx("button",{type:"button",className:"native-wallet-button native-wallet-button--apple-pay",disabled:r,onClick:a,"aria-label":c}):e==="googlePay"?t.jsx("button",{type:"button",className:"native-wallet-button native-wallet-button--google-pay",disabled:r,onClick:a,"aria-label":c,children:t.jsx("img",{src:So,alt:"","aria-hidden":"true"})}):null}const Qs={available:!1,platform:null,wallet:null,reason:"NATIVE_BRIDGE_UNAVAILABLE"};function fa(e){const r=e??(typeof window>"u"?void 0:window),a=r==null?void 0:r.MinLpgNativePayments;return typeof(a==null?void 0:a.isAvailable)!="function"||typeof(a==null?void 0:a.confirmPayment)!="function"?null:a}async function Zs(e){const r=fa(e);if(!r)return Qs;try{const a=await r.isAvailable(),c=(a==null?void 0:a.platform)==="ios"||(a==null?void 0:a.platform)==="android",i=(a==null?void 0:a.platform)==="ios"&&(a==null?void 0:a.wallet)==="applePay"||(a==null?void 0:a.platform)==="android"&&(a==null?void 0:a.wallet)==="googlePay";return(a==null?void 0:a.available)===!0&&c&&i?{available:!0,platform:a.platform==="ios"?"ios":"android",wallet:a.wallet==="applePay"?"applePay":"googlePay",reason:a.reason}:{available:!1,platform:c?a.platform:null,wallet:null,reason:(a==null?void 0:a.reason)??"WALLET_NOT_AVAILABLE"}}catch{return Qs}}async function Io(e,r){const a=fa(r);if(!a)throw{code:"WALLET_NOT_AVAILABLE",message:"Native wallet payments are not available."};return a.confirmPayment(e)}const Ro=new Set(["NOK","SEK","EUR","DKK"]);function yn(e,r){return{code:e,message:r}}function ga(e){return e&&typeof e=="object"?{code:typeof e.code=="string"?e.code:"PAYMENT_FAILED",message:typeof e.message=="string"?e.message:"Payment failed.",declineCode:typeof e.declineCode=="string"?e.declineCode:void 0,stripeErrorCode:typeof e.stripeErrorCode=="string"?e.stripeErrorCode:void 0}:yn("PAYMENT_FAILED","Payment failed.")}function wo(e){return ga(e).code==="PAYMENT_CANCELED"}function To(e){const r=String((e==null?void 0:e.dispensingSessionId)??"").trim(),a=String((e==null?void 0:e.clientSecret)??"").trim(),c=typeof(e==null?void 0:e.currency)=="string"?e.currency:"",i=e==null?void 0:e.amountMinor;if(!r||!a||!Number.isSafeInteger(i)||i<=0||!Ro.has(c.toUpperCase()))throw yn("INVALID_AUTHORIZATION_SESSION","The backend returned an invali
2d authorization session.");return{dispensingSessionId:r,clientSecret:a,amountMinor:i,currency:c}}function _o(e){if(!(e!=null&&e.paymentIntentId)||e.status!=="RequiresCapture"||e.captureMethod!=="Manual"||e.authorized!==!0)throw yn("AUTHORIZATION_INCOMPLETE","The wallet authorization was not completed.");return e}function Eo(e,r,a){if((e==null?void 0:e.verified)!==!0||String((e==null?void 0:e.dispensingSessionId)??"")!==r.dispensingSessionId||String((e==null?void 0:e.paymentIntentId)??"")!==a)throw yn("BACKEND_VERIFICATION_REQUIRED","The backend did not verify the wallet authorization.");return e}async function Ao({requestAuthorization:e,confirmPayment:r,verifyAuthorization:a,cancelAuthorization:c,onAuthorizationCreated:i,paymentRequest:d,label:f}){let m=null,j=null;try{const y=await e(d);j=String((y==null?void 0:y.dispensingSessionId)??"").trim()||null,m=To(y),await(i==null?void 0:i(m));const k=_o(await r({clientSecret:m.clientSecret,amountMinor:m.amountMinor,currency:m.currency,label:f})),A=await a({dispensingSessionId:m.dispensingSessionId,paymentIntentId:k.paymentIntentId});return{session:m,nativeResult:k,verification:Eo(A,m,k.paymentIntentId)}}catch(y){if(j)try{await c(j)}catch{}throw ga(y)}}const Js="minlpg:native-platform-ready",Do={available:!1,platform:null,wallet:null,reason:"CHECKING"};function Po(){const[e,r]=o.useState(Do),a=o.useCallback(async()=>{const c=await Zs();return r(c),c},[]);return o.useEffect(()=>{let c=!0;const i=async()=>{const d=await Zs();c&&r(d)};return i(),window.addEventListener(Js,i),()=>{c=!1,window.removeEventListener(Js,i)}},[]),{...e,refreshAvailability:a}}const Lo=[{value:"BOTTLE",label:"Propanflasker"},{value:"BULK_LPG",label:"Bulk LPG / tank"}];function Oo({user:e,portalData:r}={}){var m;const a=wi(e==null?void 0:e.role),c=Ti(a),i=a==="project_manager",d=(e==null?void 0:e.customerDemoType)==="orders_only"||c,f=a==="organization_customer"||(e==null?void 0:e.customerDemoType)==="company_admin"||(e==null?void 0:e.customerDemoType)==="company"||String((m=r==null?void 0:r.customer)==null?void 0:m.customerType).includes("ORGANIZATION");return{isPropaneOrderingCustomer:c,isOrdersOnlyCustomer:d,canUseDispenserFlows:!d,canUseReceipts:!d,canUseClipFlows:!d,canUseProjectCouponFlows:!d,canUseCreditFlows:!d,canUseProjectManagementLink:i,canUseOrganizationFlows:f&&!d}}function Fo(e,r){return r!=null&&r.isOrdersOnlyCustomer&&(e==="/portal"||e==="/portal/"||e.startsWith("/portal/dispenser")||e.startsWith("/portal/kvitteringer")||e.startsWith("/portal/klippekort")||e.startsWith("/portal/prosjektkupong")||e.startsWith("/portal/kreditt")||e.startsWith("/portal/organisasjon"))?"/portal/bestillinger":null}function Mo(){return Lo}const ha={id:"S002",name:"Demo Station 1",company:"Demo Energi AS",orgNr:"999888777",deliveryOrganizationNumber:"999888777",deliveryOrganizationName:"Demo Energi AS",address:"Demoveien 10, 0123 Oslo",active:!0,latitude:59.93,longitude:10.83},Ko=[ha,{id:"S001",name:"Demo Station 2",company:"Demo Energi AS",orgNr:"999888777",deliveryOrganizationNumber:"999888777",deliveryOrganizationName:"Demo Energi AS",address:"Eksempelgata 22, 0456 Oslo",active:!0,latitude:59.94,longitude:10.78},{id:"S003",name:"Demo Station 3",company:"Demo Energi AS",orgNr:"999888777",deliveryOrganizationNumber:"999888777",deliveryOrganizationName:"Demo Energi AS",address:"Testveien 7, 1383 Asker",active:!0,latitude:59.83,longitude:10.5}];function Uo(e,r,a,c){const d=(a-e)*Math.PI/180,f=(c-r)*Math.PI/180,m=Math.sin(d/2)**2+Math.cos(e*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.sin(f/2)**2;return 6371*(2*Math.atan2(Math.sqrt(m),Math.sqrt(1-m)))}function ya(e,r,a){return r!=null&&a!=null&&e.some(c=>c.latitude!=null&&c.longitude!=null)?[...e].map(c=>({...c,_distanceKm:Uo(r,a,c.latitude,c.longitude)})).sort((c,i)=>(c._distanceKm??1/0)-(i._distanceKm??1/0)):[...e].sort((c,i)=>(c.name??"").localeCompare(i.name??""))}function zo(){return ha}function qo(e=null,r=null){return ya(Ko,e,r)}async function Bo({useMocks:e,fetchStations:r,lat:a=null,lon:c=null}){if(e)return{source:"demo",stations:qo(a,c)};const i=await r(),d=Array.isArray(i)?i:(i==null?void 0:i.content)??(i==null?void 0:i.stations)??[];return{source:"api",stations:ya(d,a,c)}}const va=9e4,$o=3e3,Go=6e4;function Wo(e){return(e==null?void 0:e.defaultDispenseWithRoadTax)!==!1}
2function ba(e){return String(e??"terminal_card").trim().toLowerCase()==="credit"?"credit":"terminal_card"}function Vo({stationIdentifier:e,posEcrId:r,dispenseWithRoadTax:a,paymentMethod:c="terminal_card",creditId:i}){const d=ba(c);return String(e??"").trim()!==""&&String(r??"").trim()!==""&&typeof a=="boolean"&&(d!=="credit"||String(i??"").trim()!=="")}function Xs({posEcrId:e,dispenseWithRoadTax:r,paymentMethod:a="terminal_card",creditId:c}){if(String(e??"").trim()==="")throw new Error("posEcrId is required");if(typeof r!="boolean")throw new Error("Road tax choice is required");const i=ba(a),d={posEcrId:String(e).trim(),dispenseWithRoadTax:r,paymentMethod:i};if(i==="credit"){const f=String(c??"").trim();if(!f)throw new Error("creditId is required for credit payment");d.creditId=f}return d}function vr(e){return(Array.isArray(e)?e:(e==null?void 0:e.content)??(e==null?void 0:e.stories)??(e==null?void 0:e.items)??[]).map(a=>{const c=String(a.storyRecordId??a.recordId??a.id??a.storyId??"").trim(),i=String(a.storyId??a.dispenserStoryId??a.storyRecordId??"").trim(),d=a.completedAtUtc??a.completedAt??a.endedAt??a.timestamp??a.startedAt??a.dateTime,f=a.amountOre??a.amountMinor,m=Number(a.amountKr??a.amountNok??(f!=null?f/100:0));return ma({...a,storyRecordId:c,storyId:i,transactionId:c||i,timestamp:d,amountKr:Number.isFinite(m)?m:0,paymentType:a.paymentType??a.paymentMethod??a.flow??"terminal_card"})})}function ea(e,r){const a=String(r??"").trim();return a?vr(e).find(c=>c.storyId===a||c.storyRecordId===a||c.transactionId===a)??null:null}function Yo(e){return e==null?null:typeof e!="object"?e:"some"in e?e.some:"Some"in e?e.Some:"value"in e?e.value:e}function Ho(e){const r=(e==null?void 0:e.raw)??e,a=Yo((r==null?void 0:r.active_story_id)??(r==null?void 0:r.activeStoryId));return String(a??"").trim()}function ta({session:e,snapshot:r,now:a=Date.now(),stallMs:c=va}){if(!(e!=null&&e.storyId))return"idle";if(e.status==="cancelling")return"cancelling";if(e.status==="completed")return"completed";if(e.status==="failed"||e.status==="cancelled")return"failed";const i=Number(e.lastProgressAt??e.startedAt??a);if(a-i>=c)return"stalled";const d=String((r==null?void 0:r.state)??e.state??"").toUpperCase(),f=String((r==null?void 0:r.sessionFsm)??"").toUpperCase(),m=String((r==null?void 0:r.pumpFsm)??"").toUpperCase(),j=String((r==null?void 0:r.stationFsm)??"").toUpperCase(),y=Number((r==null?void 0:r.volumeLitres)??0),k=Number((r==null?void 0:r.amountKr)??0);return d.includes("FAILED")||d.includes("CANCEL")||d.includes("REVERS")||f==="FAILED"||j.includes("FAILED")?"failed":y>0||k>0||m.includes("DELIVERY")||d.includes("PUMPING")||d.includes("IN_USE")?"dispensing":r!=null&&r.nozzleLifted||m.includes("UNLOCK")||d.includes("READY_TO_PUMP")?"ready_to_dispense":f==="RESERVED"||d.includes("AUTHORIZED")?"payment_authorized":"waiting_for_terminal"}function Qo({session:e,snapshot:r}){if(!(e!=null&&e.storyId)||!r)return!1;const a=Ho(r);if(!a||a!==String(e.storyId).trim())return!0;const c=String(r.state??"").toUpperCase(),i=String(r.sessionFsm??"").toUpperCase(),d=String(r.pumpFsm??"").toUpperCase(),f=String(r.stationFsm??"").toUpperCase(),m=String(r.terminalFsm??"").toUpperCase(),j=`${c} ${i} ${d} ${f} ${m}`;return!["AUTHENTICATED","AUTHORIZ","PAYMENT","TERMINAL","NETS","RESERVED","READY_TO_PUMP","PUMPING","DELIVERY","IN_USE","UNLOCK"].some(y=>j.includes(y))}const Zo=[{id:1,minutesAgo:75,amountKr:450,liters:25.01,paymentType:"CREDIT",station:"LPG Demo Stasjon"},{id:2,daysAgo:2,hour:9,minute:15,amountKr:380.2,liters:21.14,paymentType:"BANK_TERMINAL",station:"LPG Demo Stasjon"},{id:3,daysAgo:5,hour:16,minute:45,amountKr:520,liters:28.89,paymentType:"CREDIT",station:"LPG Demo Stasjon"}];function mr(e){return Number(Number(e).toFixed(2))}function Jo(e=new Date){return Zo.map(({daysAgo:r=0,minutesAgo:a,hour:c,minute:i,...d})=>{const f=new Date(e);return a!=null?f.setMinutes(f.getMinutes()-a,0,0):(f.setDate(f.getDate()-r),f.setHours(c,i,0,0)),{...d,timestamp:f.toISOString()}})}function Xo({liters:e,pricePerLitre:r,withRoadTax:a,station:c,completedAt:i=new Date,transactionId:d}){const f=i instanceof Date?i:new Date(i),m=mr(e);return{transactionId:d??`customer-demo-fill-${f.getTime()}`,timestamp:f.toISOString(),amountKr:mr(m*Number(r)),liters:m,pricePerLitre:mr(r),withRoadTax:a===!0,paymentType:"BANK_TERMINAL",station:c||"LPG Demo Stasjon",isDemoDispensingReceipt:!0}}function el(e){return[...e].sort((r,a)=>new Date(a.timestamp).getTime()-new Date(r.timestamp).getTime())}function tl(e,r,a){const c=new Date(`${r}T00:00:00`).getTime(),i=new Date(`${a}T23:59:59.999`).getTime();return el(e).filter(d=>{const f=new Date(d.timestamp).getTime();return f>=c&&f<=i})}function na(e,r){return r||(e==null?void 0:e.isDemoDispensingReceipt)===!0}const nl=Object.freeze({clip_granted:"clipEventGranted",clip_req_granted:"clipEventRequestGranted",reward_redeemed_from_request:"clipEventRewardRedeemed"});function rl(e){return Number.isFinite(e)?e>0?`+${e}`:String(e):""}function sl(e,r){const a=nl[e==null?void 0:e.eventType]??"clipEventUnknown";return{date:Ke(e==null?void 0:e.createdAtUtc),type:r(a),amount:rl(e==null?void 0:e.clipDelta)}}function al(e){const r=String((e==null?void 0:e.organizationNumber)??"").trim();return r?{organizationNumber:r,organizationName:String((e==null?void 0:e.organizationName)??r).trim(),activeStationCount:Number((e==null?void 0:e.activeStationCount)??0)}:null}function ra(e){const r=Array.isArray(e)?e:(e==null?void 0:e.organizations)??[],a=new Map;return r.forEach(c=>{const i=al(c);if(!i)return;const d=a.get(i.organizationNumber);a.set(i.organizationNumber,d?{...d,organizationName:d.organizationName||i.organizationName,activeStationCount:Math.max(d.activeStationCount,i.activeStationCount)}:i)}),[...a.values()].sort((c,i)=>c.organizationName.localeCompare(i.organizationName,"nb"))}function il(e){return String((e==null?void 0:e.deliveryOrganizationNumber)??"").trim()}
2function sa(e){const r=(e==null?void 0:e.latitude)??(e==null?void 0:e.lat),a=(e==null?void 0:e.longitude)??(e==null?void 0:e.lon)??(e==null?void 0:e.lng);if(r==null||r===""||a==null||a==="")return null;const c=Number(r),i=Number(a);return!Number.isFinite(c)||!Number.isFinite(i)||c<-90||c>90||i<-180||i>180?null:{latitude:c,longitude:i}}function ol(e,r){const c=(r.latitude-e.latitude)*Math.PI/180,i=(r.longitude-e.longitude)*Math.PI/180,d=e.latitude*Math.PI/180,f=r.latitude*Math.PI/180,m=Math.sin(c/2)**2+Math.cos(d)*Math.cos(f)*Math.sin(i/2)**2;return 6371*2*Math.atan2(Math.sqrt(m),Math.sqrt(1-m))}function ll(e,r,a){const c=sa(a);if(!c)return e;const i=new Map;return r.forEach(d=>{const f=il(d),m=sa(d);if(!f||!m)return;const j=ol(c,m),y=i.get(f);(y==null||j<y)&&i.set(f,j)}),[...e].sort((d,f)=>{const m=i.get(d.organizationNumber)??1/0,j=i.get(f.organizationNumber)??1/0;return m!==j?m-j:d.organizationName.localeCompare(f.organizationName,"nb")})}function dt(e){const r=String((e==null?void 0:e.primaryDeliveryOrganizationNumber)??"").trim();return r?{organizationNumber:r,organizationName:String((e==null?void 0:e.primaryDeliveryOrganizationName)??r).trim(),setAtUtc:(e==null?void 0:e.primaryDeliveryOrganizationSetAtUtc)??null}:null}function cl(e){return!(e!=null&&e.isSet)||!(e!=null&&e.organizationNumber)?null:{organizationNumber:String(e.organizationNumber).trim(),organizationName:String(e.organizationName??e.organizationNumber).trim(),setAtUtc:e.setAtUtc??null}}const dl="kunde",ul=123,ml=2e3,pl=12300,fl=100,aa=12.4,gl=350,br="order-address-suggestions";function S(...e){return e.map(r=>r==null?"":String(r).trim()).find(r=>r!=="")??""}function ia(...e){const r=S(...e.map(i=>i==null?void 0:i.firstName)),a=S(...e.map(i=>i==null?void 0:i.lastName));return[r,a].filter(Boolean).join(" ").trim()||S(...e.map(i=>i==null?void 0:i.fullName),...e.map(i=>i==null?void 0:i.name))}function Na(e){return pa(S(e))}function xa(...e){const r=S(...e);return r.includes("@")?r:""}function hn(e){return e===!0||e==="true"}function hl({user:e,portalData:r}={}){var P,_,F;const a=(r==null?void 0:r.customer)??{},c=hn(S(e==null?void 0:e.rememberDeliveryAddress,a.rememberDeliveryAddress)),i=c?S(e==null?void 0:e.deliveryAddress,a.deliveryAddress,e==null?void 0:e.address,a.address):"",d=Na(S(i)),f=c?(e==null?void 0:e.addressValidation)??a.addressValidation:null,m=(f==null?void 0:f.isValidated)===!0?Nr(f.address):"",j=c?S((P=f==null?void 0:f.address)==null?void 0:P.postalCode,e==null?void 0:e.postalCode,a.postalCode,a.postnummer,d.postalCode):"",y=c?S((_=f==null?void 0:f.address)==null?void 0:_.city,(F=f==null?void 0:f.address)==null?void 0:F.poststed,e==null?void 0:e.city,a.city,a.sted,d.city):"",k=S(a.organizationName,e==null?void 0:e.organizationName,a.companyName,e==null?void 0:e.companyName,ia(a,e)),A=S(a.contactName,e==null?void 0:e.contactName,ia(a,e)),Z=S(m,d.deliveryAddress);return{firmanavnKundenavn:k,kontaktperson:A,telefon:S(a.phone,e==null?void 0:e.phone),epost:xa(a.email,e==null?void 0:e.email),leveringsadresse:Z,postnummer:j,sted:y}}function yl({user:e,portalData:r}={}){const a=(r==null?void 0:r.customer)??{},c=hn(S(e==null?void 0:e.rememberDeliveryAddress,a.rememberDeliveryAddress)),i=(e==null?void 0:e.addressValidation)??a.addressValidation;return!c||(i==null?void 0:i.isValidated)!==!0||!(i!=null&&i.address)?null:i.address}function Nr(e){return[e==null?void 0:e.streetName,`${(e==null?void 0:e.houseNumber)??""}${(e==null?void 0:e.houseLetter)??""}`.trim()].filter(Boolean).join(" ").trim()}function oa(e){return`${br}-option-${e}`}function pr(e){return e?{isValidated:!0,address:{id:e.id,adresseId:e.adresseId??null,displayText:e.displayText,streetName:e.streetName,houseNumber:e.houseNumber,houseLetter:e.houseLetter,postalCode:e.postalCode,city:e.city,poststed:e.poststed,municipalityName:e.municipalityName,municipalityNumber:e.municipalityNumber,latitude:e.latitude??null,longitude:e.longitude??null,rawSource:e.rawSource}}:{isValidated:!1,address:null}}function xr(e){return String((e==null?void 0:e.stationCode)??(e==null?void 0:e.stationId)??(e==null?void 0:e.id)??"").trim()}function vl(e){return S(e==null?void 0:e.name,e==null?void 0:e.legalName,e==null?void 0:e.stationCode,e==null?void 0:e.stationId,e==null?void 0:e.id)}function bl(e){const r=vl(e),a=S(e==null?void 0:e.address);return a?`${r} â ${a}`:r}function Nl(e){return(e==null?void 0:e.active)!==!1&&String((e==null?void 0:e.status)??"").toUpperCase()!=="INACTIVE"&&xr(e)!==""}function xl(e,r){const a=String(r??"").trim();if(!a)return!0;const c=[e==null?void 0:e.stationCode,e==null?void 0:e.stationId].map(i=>
2String(i??"").trim()).filter(Boolean);return c.length===0||c.includes(a)}function fr(e){const r=String((e==null?void 0:e.creditKind)??"").toLowerCase();return r==="private"?"Privat":r==="company"?"Firma":"Kreditt"}function jl(e){const r=String(e??"").toLowerCase();return r==="pending"?"Venter":r==="approved"?"Godkjent":r==="rejected"?"Avvist":e||"Ukjent"}function ja(e,r){return{...e,firmanavnKundenavn:e.firmanavnKundenavn||r.firmanavnKundenavn||"",kontaktperson:e.kontaktperson||r.kontaktperson||"",telefon:e.telefon||r.telefon||"",epost:e.epost||r.epost||"",leveringsadresse:e.leveringsadresse||r.leveringsadresse||"",postnummer:e.postnummer||r.postnummer||"",sted:e.sted||r.sted||"",bulk:{...e.bulk}}}function la(e){return e.reduce((r,a)=>({...r,[a.key]:0}),{})}function jr(e={}){return ja({firmanavnKundenavn:"",kontaktperson:"",telefon:"",epost:"",leveringsadresse:"",postnummer:"",sted:"",kommentar:"",orderType:"BOTTLE",fylling:la(pn),nyFlaske:la(fn),bulk:{tanknummerReferanse:"",onsketVolum:"",onsketLeveringsdato:""}},e)}function kl(e){return S(e==null?void 0:e.productCode,e==null?void 0:e.productType)}const Sl=Object.freeze({FILL_2KG:"refill_2kg",FILL_5KG:"refill_5kg",FILL_10KG:"refill_10kg",FILL_11KG:"refill_11kg",FILL_17KG:"refill_17kg",FILL_33KG:"refill_33kg",FILL_TRUCK_14_5KG:"refill_truck_14_5kg",FILL_TRUCK_16_5KG:"refill_truck_16_5kg",NEW_2KG:"new_2kg",NEW_5KG:"new_5kg",NEW_10KG:"new_10kg",NEW_11KG:"new_11kg",NEW_17KG:"new_17kg",NEW_33KG:"new_33kg",NEW_TRUCK_14_5KG:"new_truck_14_5kg",NEW_TRUCK_16_5KG:"new_truck_16_5kg",CYLINDER_2KG:"new_2kg",CYLINDER_5KG:"new_5kg",CYLINDER_10KG:"new_10kg",CYLINDER_11KG:"new_11kg",CYLINDER_17KG:"new_17kg",CYLINDER_33KG:"new_33kg"});function Cl(e){const r=S(e);return Sl[r]??r}function Il(e,r){const a={...e.fylling},c={...e.nyFlaske};return(Array.isArray(r)?r:[]).forEach(i=>{const d=Cl(kl(i)),f=Math.max(0,Number.parseInt(i==null?void 0:i.quantity,10)||0);if(f<=0)return;const m=pn.find(y=>y.productCode===d);if(m){a[m.key]=f;return}const j=fn.find(y=>y.productCode===d);j&&(c[j.key]=f)}),{...e,fylling:a,nyFlaske:c}}function gr(e){const r=S(e);return r?r.length>=10?r.slice(0,10):r:""}function Rl(e,r={}){const a=(e==null?void 0:e.orderType)==="bulk_lpg"||(e==null?void 0:e.orderType)==="BULK_LPG"||(e==null?void 0:e.isBulkLpg)===!0,c=Na(e==null?void 0:e.deliveryAddress),i=(e==null?void 0:e.customerInfo)??{},d=(e==null?void 0:e.bulkDetails)??{},f={...jr(r),firmanavnKundenavn:S(e==null?void 0:e.customerName,i.firmanavnKundenavn,r.firmanavnKundenavn),kontaktperson:S(e==null?void 0:e.contactPerson,i.kontaktperson,i.contactName,r.kontaktperson),telefon:S(e==null?void 0:e.phone,i.telefon,i.phone,r.telefon),epost:xa(e==null?void 0:e.email,i.epost,i.email,r.epost),leveringsadresse:S(e==null?void 0:e.deliveryStreetAddress,i.leveringsadresse,c.deliveryAddress,r.leveringsadresse),postnummer:S(e==null?void 0:e.postalCode,i.postnummer,i.postalCode,c.postalCode,r.postnummer),sted:S(e==null?void 0:e.city,i.sted,i.city,c.city,r.sted),kommentar:S(e==null?void 0:e.notes,e==null?void 0:e.comment,i.kommentar,i.comment),orderType:a?"BULK_LPG":"BOTTLE",bulk:{tanknummerReferanse:S(d.tanknummerReferanse,d.tankReference,d.tankAddress),onsketVolum:S(d.onsketVolum,d.desiredVolume),onsketLeveringsdato:S(gr(e==null?void 0:e.desiredDeliveryDate),gr(d.onsketLeveringsdato),gr(d.desiredDeliveryDate))}};return a?f:Il(f,e==null?void 0:e.lines)}const wl={refill_2kg:"productTypeFill2kg",refill_5kg:"productTypeFill5kg",refill_10kg:"productTypeFill10kg",refill_11kg:"productTypeFill11kg",refill_17kg:"productTypeFill17kg",refill_33kg:"productTypeFill33kg",refill_truck_14_5kg:"productTypeFillTruck145kg",refill_truck_16_5kg:"productTypeFillTruck165kg",new_2kg:"productTypeNew2kg",new_5kg:"productTypeNew5kg",new_10kg:"productTypeNew10kg",new_11kg:"productTypeNew11kg",new_17kg:"productTypeNew17kg",new_33kg:"productTypeNew33kg",new_truck_14_5kg:"productTypeNewTruck145kg",new_truck_16_5kg:"productTypeNewTruck165kg",FILL_2KG:"productTypeFill2kg",FILL_5KG:"productTypeFill5kg",FILL_10KG:"productTypeFill10kg",FILL_11KG:"productTypeFill11kg",FILL_17KG:"productTypeFill17kg",FILL_33KG:"productTypeFill33kg",FILL_TRUCK_14_5KG:"productTypeFillTruck145kg",FILL_TRUCK_16_5KG:"productTypeFillTruck165kg",NEW_2KG:"productTypeNew2kg",NEW_5KG:"productTypeNew5kg",NEW_10KG:"productTypeNew10kg",NEW_11KG:"productTypeNew11kg",NEW_17KG:"productTypeNew17kg",NEW_33KG:"productTypeNew33kg",NEW_TRUCK_14_5KG:"productTypeNewTruck145kg",NEW_TRUCK_16_5KG:"productTypeNewTruck165kg",CYLINDER_10KG:"productTypeCylinder10kg",CYLINDER_15KG:"productTypeCylinder15kg",CYLINDER_20KG:"productTypeCylinder20kg"};function Tl(e,r){const a=wl[e];return a?r(a):e??r("productTypeUnknown")}function _l(e,r){switch(String(e??"").toUpperCase()){case"NEW":return r("orderStatusNew");case"SUBMITTED":return r("orderStatusSubmitted","Innsendt");case"ASSIGNED":return r("orderStatusAssigned");case"ACCEPTED":return r("orderStatusAccepted");case"IN_PROGRESS":return r("orderStatusInProgress");case"COMPLETED":return r("orderStatusCompleted");case"DELIVERED":return r("orderStatusDelivered");case"CANCELLED":return r("orderStatusCancelled");default:return e||"-"}}function El(e){switch(String(e??"").toUpperCase()){case"NEW":case"SUBMITTED":return"new";case"ASSIGNED":case"ACCEPTED":case"IN_PROGRESS":return"assigned";case"COMPLETED":case"DELIVERED":return"done";default:return"done"}}function Al(e){const r=El(e);return{padding:"4px 8px",borderRadius:"12px",fontSize:"0.85rem",fontWeight:600,display:"inline-block",backgroundColor:r==="new"?"#e3f2fd":r==="assigned"?"#fff3e0":"#e8f5e9",color:r==="new"?"#1976d2":r==="assigned"?"#f57c00":"#388e3c"}}function Dl(e,r){var a;if(e.orderType==="bulk_lpg"||e.orderType==="BULK_LPG"||e.isBulkLpg){const c=r("productTypeBulkLpg");return e.deliveryAddress?`${c} â ${e.deliveryAddress}`:c}return(a=e.lines)!=null&&a.length?e.lines.map(c=>`${c.quantity}
2x ${Tl(c.productCode??c.productType,r)}`).join(", "):"â"}function Pl(e,r,a,c){const d=(a-e)*Math.PI/180,f=(c-r)*Math.PI/180,m=Math.sin(d/2)**2+Math.cos(e*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.sin(f/2)**2;return 6371*(2*Math.atan2(Math.sqrt(m),Math.sqrt(1-m)))}function un(e){return e==null||Number.isNaN(e)?null:e<1?`${(e*1e3).toFixed(0)} m`:`${e.toFixed(1).replace(".",",")} km`}function Ll(e){const r=e.replace(/\/+$/,"")||"/portal";return r.endsWith("/kvitteringer")?"receipts":r.endsWith("/bestillinger/ny")?"new-order":r.endsWith("/bestillinger")?"orders":r.endsWith("/organisasjon/ansatte")?"org-employees":r.endsWith("/kreditt")||r.endsWith("/organisasjon")?"org-credit":r.endsWith("/klippekort")?"klippekort":r.endsWith("/prosjektkupong")?"project-voucher":(r==="/portal"||r.endsWith("/dispenser"),"dashboard")}function ca(e){return(e==null?void 0:e.posEcrId)!=null&&String(e.posEcrId).trim()!==""?`ecr:${String(e.posEcrId).trim()}`:(e==null?void 0:e.posTerminalId)!=null&&String(e.posTerminalId).trim()!==""?`term:${String(e.posTerminalId).trim()}`:null}function Ol(e,r){const a=ca(e),c=ca(r),d=a!=null&&a===c?e:null;return{...r,volumeLitres:r.volumeLitres??(d==null?void 0:d.volumeLitres)??0,amountKr:r.amountKr??(d==null?void 0:d.amountKr)??0,volumeMilliliters:r.volumeMilliliters??(d==null?void 0:d.volumeMilliliters),amountOre:r.amountOre??(d==null?void 0:d.amountOre)}}function da(e){const r=e==null?void 0:e.raw;if(r==null)return"";const a=co(r.active_story_id??r.activeStoryId);return String(a??"").trim()}function ka(e){const r=Number(e.amountKr??0),a=Number(e.liters??0),c=Number(e.pricePerLitre??(a>0?r/a:0)),i=d=>new Intl.NumberFormat("nb-NO",{minimumFractionDigits:2,maximumFractionDigits:2}).format(d);return["SIMULERT KVITTERING",e.station||"LPG Demo Stasjon",`${Ke(e.timestamp,"nb-NO")} ${mn(e.timestamp,"nb-NO")}`,"",`Mengde: ${i(a)} L`,`Literpris: ${i(c)} kr`,e.withRoadTax?"Med veibruksavgift":"Uten veibruksavgift","Betaling: Bankterminal","",`TOTALT ${i(r)} kr`,`Referanse: ${e.transactionId}`,"","Denne kvitteringen er laget i demo-modus."].join(` 3`)}async function Fl(e){const{jsPDF:r}=await Fi(async()=>{const{jsPDF:i}=await import("./jspdf.es.min-C5xPL-AM.js").then(d=>d.j);return{jsPDF:i}},__vite__mapDeps([0,1,2])),a=new r({unit:"pt",format:[260,420]}),c=ka(e).split(` 4`);return a.setFont("helvetica","normal"),a.setFontSize(9),c.forEach((i,d)=>{d===0?(a.setFont("helvetica","bold"),a.setFontSize(15)):d===1?a.setFontSize(12):i.startsWith("TOTALT")?(a.setFont("helvetica","bold"),a.setFontSize(13)):(a.setFont("helvetica","normal"),a.setFontSize(9)),a.text(i||" ",130,38+d*20,{align:"center"})}),a.output("blob")}function Ml(e,r){if(e==null||typeof e!="object")return null;const a=e,c=a.threshold??a.clipRewardThreshold??a.rewardThreshold??a.requiredClips,i=a.balance??a.currentClipCount??a.clipCount,d=Number(c),f=Number(i),m=Number.isFinite(d)&&d>0?d:0,j=Number.isFinite(f)&&f>=0?f:0,y=a.programId??a.clipProgramId??null,k=String(a.programName??a.clipProgramName??r("sectionKlippekort")).trim(),A=a.exists===!0||a.customerClipAccountId!=null||j>0,Z=a.rewardAvailable===!0||m>0&&j>=m;return{exists:A,programId:y,programName:k,threshold:m,balance:j,rewardAvailable:Z}}function Jl(){var xs,js,ks,Ss,Cs,Is,Rs,ws;const{t:e,i18n:r}=ua("customer"),{showPrimaryNavigation:a}=_i(),c=Po(),{user:i,setUser:d}=Ei(),f=Ai(),m=Di(),j=f.pathname,y=o.useMemo(()=>Ll(j),[j]),[k,A]=o.useState(null),[Z,P]=o.useState(!1),[_,F]=o.use
4State(!1),[ut,J]=o.useState(null),[kr,B]=o.useState(null),[Sr,se]=o.useState("idle"),[mt,Ue]=o.useState(null),[vn,pt]=o.useState(null),[h,ze]=o.useState(null),[ft,qe]=o.useState(!1),[Sa,gt]=o.useState(null),[Ca,ht]=o.useState(!1),[Cr,bn]=o.useState(null),[Ia,yt]=o.useState(()=>Date.now()),ee=o.useRef({sessionId:null,stationId:null,type:null}),Ir=o.useRef(null),Be=o.useRef(null),$e=o.useRef(null),[vt,bt]=o.useState("idle"),[Nt,Ge]=o.useState(0),[xt,We]=o.useState(0),[jt,kt]=o.useState(null),[I]=o.useState(null),Re=o.useMemo(()=>hl({user:i,portalData:I}),[i,I]),Rr=o.useMemo(()=>yl({user:i,portalData:I}),[i,I]),Ve=hn(i==null?void 0:i.rememberDeliveryAddress),[wr,Tr]=o.useState([]),[Ra,St]=o.useState(!1),[v,D]=o.useState(()=>jr(Re)),[Nn,_r]=o.useState(!1),[xn,jn]=o.useState(Ve),[ae,me]=o.useState([]),[kn,pe]=o.useState("idle"),[R,ie]=o.useState(null),[fe,we]=o.useState(null),[Sn,te]=o.useState(null),[wa,Cn]=o.useState(null),[Ye,z]=o.useState(!1),[Te,$]=o.useState(-1),ge=o.useRef(null),In=o.useRef(null),Er=o.useRef(null),Ct=o.useRef(null),It=o.useRef(null),Ar=o.useRef(null),He=o.useRef(null),Dr=o.useRef(null),Rn=o.useRef(!1),[he,Ta]=o.useState([]),[X,Rt]=o.useState(null),[_e,Pr]=o.useState([]),[wt,Lr]=o.useState(""),[Or,Tt]=o.useState(()=>dt(i)),[_a,_t]=o.useState(!1),[Fr,Mr]=o.useState(!1),[wn,ye]=o.useState(null),[Qe,Et]=o.useState(null),[Ea,Kr]=o.useState(!0),[Aa,Ur]=o.useState(null),[Ee,Da]=o.useState(null),At=o.useRef(!1),oe=o.useMemo(()=>{const n=he;return Ee!=null&&n.some(s=>s.latitude!=null&&s.longitude!=null)?[...n].map(s=>({...s,_distanceKm:Pl(Ee.lat,Ee.lon,s.latitude,s.longitude)})).sort((s,l)=>(s._distanceKm??1/0)-(l._distanceKm??1/0)):[...n].sort((s,l)=>(s.name??"").localeCompare(l.name??""))},[he,Ee]),Dt=Ea,zr=Aa,[Pt,ve]=o.useState(null),[qr,Pa]=o.useState(null),le=o.useRef(!1),Tn=o.useMemo(()=>Oo({user:i,portalData:I}),[I,i]),{isOrdersOnlyCustomer:La,canUseDispenserFlows:Ze,canUseReceipts:Br,canUseClipFlows:ce,canUseProjectCouponFlows:_n,canUseOrganizationFlows:Oa,canUseCreditFlows:Je,canUseProjectManagementLink:$r}=Tn,[M,Lt]=o.useState({method:"terminal_card",creditId:""}),[Ot,Gr]=o.useState([]),[En,Wr]=o.useState(!1),[Vr,Yr]=o.useState(!1),[Ft,be]=o.useState({text:"",isError:!1}),[L,de]=o.useState({stationId:"",requestedAmountKr:"",requestNote:"",creditKind:"private",companyName:"",organizationNumber:""}),[Ne,An]=o.useState(null),[Dn,Pn]=o.useState(null),[K,Hr]=o.useState(null),Mt=o.useRef(null),Kt=o.useRef(null),Qr=o.useRef(!1),Zr=o.useRef(null),Ut=o.useRef(!1),[ne,Ln]=o.useState(null),[zt,Fa]=o.useState(()=>{const n=new Date;return n.setDate(1),n.toISOString().slice(0,10)}),[qt,Ma]=o.useState(()=>new Date().toISOString().slice(0,10)),[Bt,On]=o.useState([]),[Jr,Ka]=o.useState(()=>Jo()),[Fn,Xr]=o.useState(!1),[Mn,xe]=o.useState(null),[Kn,Ua]=o.useState("all"),[W,es]=o.useState(null),[ts,za]=o.useState([]),[qa,ns]=o.useState(!1),[Xe,$t]=o.useState(!1),[Un,Gt]=o.useState(!1),[Wt,zn]=o.useState([]),[rs,qn]=o.useState([]),[Ba,ss]=o.useState(!1),[$a,Bn]=o.useState(null),[Ga,$n]=o.useState(!1),[U,Vt]=o.useState({status:"idle"}),et=o.useRef(0),tt=o.useRef(0),je=o.useRef(null),Gn=o.useRef(null),Ae=o.useRef(null),Wn=o.useRef(!1),[Wa,Vn]=o.useState(null),[Va,Yn]=o.useState(null),as=q(),Hn=zo(),N=as.useMocks?X??(I==null?void 0:I.station)??Hn:X??(I==null?void 0:I.station)??null,Yt=(N==null?void 0:N.id)??(N==null?void 0:N.stationId),V=!!(i!=null&&i.isDemoUser&&(i==null?void 0:i.role)==="customer"&&(i==null?void 0:i.customerDemoType)==="private"&&String((i==null?void 0:i.email)??"").trim().toLowerCase()===dl),Y=xr(N),nt=Ki({deploymentEnabled:or,policy:$a,isLegacyHybrid:ir()}),Qn=o.useMemo(()=>oe.filter(Nl),[oe]),De=o.useMemo(()=>Ot.filter(ro).filter(n=>xl(n,Y)),[Ot,Y]),Ht=o.useMemo(()=>De.find(n=>n.id===M.creditId)??null,[De,M.creditId]),Zn=o.useMemo(()=>Wo(N),[N]),Jn=Ys(N,Yt).posEcrId??Y,Ya=da(K),Ha=!!(h!=null&&h.storyId&&Ya===h.storyId),Xn=h!=null&&h.storyId?Ha?K:null:K,is=k??!0?Va:Wa,Qa=_&&(K==null?void 0:K.selectedPriceKr)!=null?K.selectedPriceKr:is,os=V&&jt!=null?jt:Qa,Za=V&&xt>0?xt.toFixed(2).replace(".",","):Number(((xs=h!=null&&h.storyId?Xn:K)==null?void 0:xs.amountKr)??0).toFixed(2).replace(".",","),Ja=V&&Nt>0?Nt.toFixed(2).replace(".",","):Number(((js=h!=null&&h.storyId?Xn:K)==null?void 0:js.volumeLitres)??0).toFixed(2).replace(".",","),Pe=ta({session:h,snapshot:Xn,now:Ia,stallMs:va}),Xa=h!=null&&h.storyId?e(`appDispenserProgress.${Pe}`):"",er=Vo({stationIdentifier:Y,posEcrId:Jn,dispenseWithRoadTax:k,paymentMethod:M.method,creditId:M.creditId}),Qt=Sa??(h!=null&&h.storyId?ea(Bt,h.storyId):null),ls=V&&vt==="awaiting_card",Zt=V&&vt==="pumping",tr=_&&!Zt&&!(h!=null&&h.storyId),ei=c.available&&!as.useMocks&&!V,cs=["creating","authorizing","verifying"].includes(Sr),ds=vn?new Intl.NumberFormat(r.resolvedLanguage==="en"?"en-GB":"nb-NO",{style:"currency",currency:vn.currency}).format(vn.amountMinor/100):null;o.useEffect(()=>{Kt.current=h},[h]),o.useEffect(()=>{Qr.current=_},[_]),o.useEffect(()=>{Ut.current||(pt(null),Ue(null),se("idle"))},[Y,k]);const ke=o.useCallback(()=>{Be.current&&(clearTimeout(Be.current),Be.current=null),$e.current&&(clearInterval($e.current),$e.current=null)},[]),us=o.useCallback((n=!0)=>{ke(),bt("idle"),n&&(Ge(0),We(0),kt(null))},[ke]),ti=o.useCallback(({pricePerLitre:n,dispenseWithRoadTax:s,stationName:l})=>{ke(),bt("pumping"),F(!0),P(!1),J(null),kt(n),Ge(0),We(0);const u=Date.now(),p=setInterval(()=>{const g=Math.min(1,(Date.now()-u)/pl),b=Number((ul*g).toFixed(2)),x=Number((b*n).toFixed(2));if(Ge(b),We(x),g>=1){clearInterval(p),$e.current=null;const C=Xo({liters:b,pricePerLitre:n,withRoadTax:s,station:l});Ka(H=>[C,...H]),gt(C),bt("idle"),A(null),F(!1),P(!1),J(null),ee.current={sessionId:null,
4stationId:null,type:null}}},fl);$e.current=p},[ke]);o.useEffect(()=>{const{useMocks:n}=q();if(n){const s=no();Vn(aa),Yn(aa+s)}},[]),o.useEffect(()=>{if(!Ze||!Yt||q().useMocks){An(null),Pn(null),Hr(null);return}let n=!1;const s=Ys(N,Yt);return!s.posTerminalId&&!s.posEcrId?()=>{n=!0}:(Mt.current=cn.dispenser.subscribeToRealtimeDispenser({...s,onSnapshot:l=>{var u;n||(Hr(p=>Ol(p,l)),Pn(l.state??"OFFLINE"),An(l.isOnline?"ONLINE":"OFFLINE"),l.priceWithTaxKr!=null&&Yn(l.priceWithTaxKr),l.priceWithoutTaxKr!=null&&Vn(l.priceWithoutTaxKr),l.dispenseWithRoadTax!=null&&((u=Kt.current)!=null&&u.storyId||Qr.current)&&["READY_TO_PUMP","PUMPING","PAYMENT_PENDING","IN_USE"].includes(l.state)&&A(l.dispenseWithRoadTax))},onConnectionStateChange:l=>{n||l==="closed"&&(An("OFFLINE"),Pn("OFFLINE"))}}),()=>{var l;n=!0,(l=Mt.current)!=null&&l.close&&(Mt.current.close(),Mt.current=null)})},[Ze,N,Yt]),o.useEffect(()=>{if(!(h!=null&&h.storyId)||["completed","failed","cancelled"].includes(h.status))return;const n=setInterval(()=>{yt(Date.now())},5e3);return()=>clearInterval(n)},[h]),o.useEffect(()=>{if(!(h!=null&&h.storyId)||!K)return;const n=h,s=da(K),l=s===n.storyId,u=Qo({session:n,snapshot:K});
4u&&(ee.current={sessionId:null,stationId:null,type:null},F(!1),J(null),qe(!1)),ze(p=>{if(!(p!=null&&p.storyId)||["completed","failed","cancelled"].includes(p.status)||p.storyId!==n.storyId)return p;if(u)return p.sawRealtimeProgress&&!K.hasOpenDispenserStory&&!s&&["dispensing","ready_to_dispense","payment_authorized"].includes(p.lastPhase)?{...p,status:"completed",completedAt:Date.now(),lastProgressAt:Date.now(),lastPhase:"completed"}:null;if(!l)return p;const g=ta({session:p,snapshot:K});return{...p,status:g==="failed"?"failed":p.status,sawRealtimeProgress:!0,lastProgressAt:Date.now(),lastPhase:g}})},[h,K]);const rt=o.useCallback(async(n,s,l=!1)=>{At.current=l,Da(n!=null&&s!=null?{lat:n,lon:s}:null),Kr(!0),Ur(null);const{useMocks:u}=q();try{const{stations:p}=await Bo({useMocks:u,fetchStations:go.getAll,lat:n,lon:s});le.current||(Ta(p),Rt(g=>{const b=p[0]??(u?Hn:null);if(!b)return null;const x=n!=null&&s!=null;if(l&&x||!g)return b;const C=g!=null&&(g.id!=null||g.stationId!=null)?String(g.id??g.stationId):null;return C&&p.some(lt=>String(lt.id??lt.stationId)===C)?g:b}))}catch{le.current||Ur(!0)}finally{le.current||Kr(!1)}},[Hn]),Le=o.useCallback((n=!1)=>{if(ve(null),!window.isSecureContext||!navigator.geolocation){ve("unavailable"),rt(null,null,n);return}if(qr==="denied"){ve("denied"),rt(null,null,n);return}navigator.geolocation.getCurrentPosition(s=>{le.current||rt(s.coords.latitude,s.coords.longitude,n)},s=>{le.current||(s.code===1?ve("denied"):s.code===3?ve("timeout"):ve("unavailable"),rt(null,null,n))},{enableHighAccuracy:!1,timeout:1e4,maximumAge:3e5})},[rt,qr]),Jt=o.useCallback(async()=>{if(!Je||q().useMocks){Gr([]);return}Wr(!0);try{const n=await hr.getMyCredits();Gr(Array.isArray(n)?n:[])}catch{be({text:e("common:contentUpdateFailed"),isError:!0})}finally{Wr(!1)}},[Je,e]);o.useEffect(()=>{Jt()},[Jt]),o.useEffect(()=>{M.method==="credit"&&(Ht||Lt({method:"terminal_card",creditId:""}))},[M.method,Ht]),o.useEffect(()=>{var u;if(!((u=navigator.permissions)!=null&&u.query))return;let n=!1,s=null;const l=p=>{n||(Pa(p),p==="denied"&&ve("denied"))};return navigator.permissions.query({name:"geolocation"}).then(p=>{n||(s=p,l(p.state),p.onchange=()=>l(p.state))}).catch(()=>{}),()=>{n=!0,s&&(s.onchange=null)}},[]);const Xt=o.useMemo(()=>Pt==="denied"?e("locationDenied"):Pt==="timeout"||Pt==="unavailable"?e("locationUnavailable"):null,[Pt,e]);o.useEffect(()=>{if(le.current)return;const n=oe;if(n.length===0){Rt(null);return}const s=Ee!=null&&n.some(l=>l.latitude!=null&&l.longitude!=null);Rt(l=>{const u=n[0];if(At.current&&s)return At.current=!1,u;if(At.current=!1,!l)return u;const p=l!=null&&(l.id!=null||l.stationId!=null)?String(l.id??l.stationId):null;return p&&n.some(b=>String(b.id??b.stationId)===p)?l:u})},[oe,Ee]),o.useEffect(()=>{const n=Y??"";if(Zr.current!==n){Zr.current=n,q().useMocks||(Yn(null),Vn(null)),A(Zn);return}!_&&!(h!=null&&h.storyId)&&A(s=>typeof s=="boolean"?s:Zn)},[h==null?void 0:h.storyId,_,Zn,Y]),o.useEffect(()=>(le.current=!1,Le(),()=>{le.current=!0}),[Le]);const Se=o.useCallback(()=>{!V||_||vt!=="idle"||Nt<=0&&xt<=0&&jt==null||(Ge(0),We(0),kt(null))},[V,_,vt,Nt,xt,jt]),ms=o.useCallback(n=>{if(n===""||n==null)return;const s=String(n),l=oe.find(u=>String(u.id??u.stationId)===s);l&&(Se(),Rt(l))},[oe,Se]);o.useEffect(()=>{if(_&&ut>0){const n=setInterval(()=>{J(s=>
4s<=1?(ee.current={sessionId:null,stationId:null,type:null},F(!1),P(!1),A(null),null):s-1)},1e3);return()=>clearInterval(n)}},[_,ut]);const en=o.useRef(Dn);o.useEffect(()=>{const n=Dn;(en.current==="PUMPING"||en.current==="IN_USE"||en.current==="READY_TO_PUMP")&&(n==="IDLE"||n==="PAYMENT_PENDING"||n==="AUTHORIZED_WAITING"||n==="OFFLINE")&&A(null),en.current=n},[Dn]),o.useEffect(()=>()=>{ke()},[ke]);const ni=async()=>{const n=Y,s=Jn;if(!n){B(e("dispenserErrorStationRequired"));return}if(k==null){B(e("dispenserErrorTaxChoiceRequired"));return}if(!s){B(e("dispenserErrorNoDispenser"));return}if(B(null),gt(null),ht(!1),qe(!1),P(!0),V){const l=Number(is??0);ke(),Ge(0),We(0),kt(l),bt("awaiting_card"),F(!0),P(!1),J(120),ee.current={sessionId:null,stationId:n,type:"demo"},Be.current=setTimeout(()=>{Be.current=null,ti({pricePerLitre:l,dispenseWithRoadTax:k,stationName:(N==null?void 0:N.name)??(N==null?void 0:N.legalName)??"LPG Demo Stasjon"})},ml);return}if(q().useMocks){setTimeout(()=>{F(!0),J(120),P(!1)},1500);return}try{const l=Xs({posEcrId:s,dispenseWithRoadTax:k,paymentMethod:M.method,creditId:M.creditId}),u=await ct.startSession(n,l),p=String((u==null?void 0:u.storyId)??"").trim();if(!p){B(e("dispenserErrorNoSession")),P(!1);return}ee.current={sessionId:p,stationId:n,type:"customer-app"},ze({storyId:p,stationCode:(u==null?void 0:u.stationCode)??n,posEcrId:(u==null?void 0:u.posEcrId)??s,dispenseWithRoadTax:(u==null?void 0:u.dispenseWithRoadTax)??k,flow:(u==null?void 0:u.flow)??(M.method==="credit"?"user_credit":"user_card"),paymentMethod:l.paymentMethod,creditId:l.creditId??null,state:(u==null?void 0:u.state)??"AUTHORIZING_AUTHENTICATED_USER",status:"active",startedAt:Date.now(),lastProgressAt:Date.now(),lastPhase:"waiting_for_terminal",sawRealtimeProgress:!1}),yt(Date.now()),F(!0),J(null)}catch(l){const u=(l==null?void 0:l.message)||String(l);let p="dispenserErrorGeneric";/offline|503|502/i.test(u)?p="dispenserErrorStationOffline":/ledig|available|busy|409/i.test(u)?p="dispenserErrorNoDispenser":/reserve|beløp|kort|card|402|payment/i.test(u)&&(p="dispenserErrorReserveFailed"),B(e(p))}finally{P(!1)}},ri=async()=>{if(Ut.current||!c.available)return;const n=Y,s=Jn;if(!n){B(e("dispenserErrorStationRequired"));return}if(k==null){B(e("dispenserErrorTaxChoiceRequired"));return}if(!s){B(e("dispenserErrorNoDispenser"));return}Ut.current=!0,B(null),Ue(null),pt(null),se("creating");try{const l={...Xs({posEcrId:s,dispenseWithRoadTax:k,paymentMethod:"terminal_card"}),paymentMethod:"native_wallet",wallet:c.wallet},u=await Ao({paymentRequest:l,label:e("nativeWalletReservationLabel"),requestAuthorization:x=>ct.createNativeWalletAuthorization(n,x),onAuthorizationCreated:async x=>{ee.current={sessionId:x.dispensingSessionId,stationId:n,type:"native-wallet"},pt(x),se("authorizing"),await new Promise(C=>requestAnimationFrame(()=>requestAnimationFrame(C)))},confirmPayment:Io,verifyAuthorization:({dispensingSessionId:x,paymentIntentId:C})=>(se("verifying"),ct.verifyNativeWalletAuthorization(n,x,C)),cancelAuthorization:x=>ct.cancelSession(n,x)}),{session:p,verification:g}=u,b=String(g.storyId??p.dispensingSessionId).trim();ee.current={sessionId:b,stationId:n,type:"native-wallet"},ze({storyId:b,dispensingSessionId:p.dispensingSessionId,paymentIntentId:u.nativeResult.paymentIntentId,stationCode:g.stationCode??n,posEcrId:g.posEcrId??s,dispenseWithRoadTax:g.dispenseWithRoadTax??k,flow:g.flow??"user_native_wallet",paymentMethod:"native_wallet",creditId:null,state:g.state??"PAYMENT_AUTHORIZED",status:"active",startedAt:Date.now(),lastProgressAt:Date.now(),lastPhase:"payment_authorized",sawRealtimeProgress:!1}),yt(Date.now()),se("verified"),F(!0),J(null)}
4catch(l){ee.current={sessionId:null,stationId:null,type:null},wo(l)?(se("canceled"),Ue({kind:"status",text:e("nativeWalletCanceled")})):(se("failed"),Ue({kind:"error",text:e("nativeWalletAuthorizationFailed")}))}finally{Ut.current=!1}},st=o.useCallback(async()=>{V&&us(!0),ee.current={sessionId:null,stationId:null,type:null},F(!1),P(!1),J(null),B(null),ze(null),qe(!1),gt(null),pt(null),Ue(null),se("idle"),A(null)},[V,us]),si=o.useCallback(async()=>{var l,u;const n=(l=Kt.current)==null?void 0:l.storyId,s=((u=Kt.current)==null?void 0:u.stationCode)??Y;if(!(!n||!s||ft)){B(null),qe(!0);try{const p=await ct.cancelSession(s,n);ze(g=>!(g!=null&&g.storyId)||g.storyId!==n?g:{...g,state:(p==null?void 0:p.state)??"CANCEL_REQUESTED",status:"cancelling",lastProgressAt:Date.now(),lastPhase:"cancelling"}),yt(Date.now())}catch{B(e("dispenserCancelFailed"))}finally{qe(!1)}}},[ft,Y,e]);o.useEffect(()=>{var l;if(!tr)return;const n=document.body.style.overflow;document.body.style.overflow="hidden",(l=Ir.current)==null||l.focus();const s=u=>{u.key==="Escape"&&st()};return window.addEventListener("keydown",s),()=>{document.body.style.overflow=n,window.removeEventListener("keydown",s)}},[st,tr]);const ai=n=>{if(n==null)return"00:00";const s=String(Math.floor(n/60)).padStart(2,"0"),l=String(n%60).padStart(2,"0");return`${s}:${l}`},ii=async()=>{var n;St(!0),m("/portal/bestillinger");try{const s=await lr.getOrdersByCustomer(((n=I==null?void 0:I.customer)==null?void 0:n.id)||"current-user");Tr(s)}catch(s){console.error(s)}finally{St(!1)}};o.useEffect(()=>{if(!i)return;const n=Fo(j,Tn);n&&m(n,{replace:!0})},[Tn,i,j,m]),o.useEffect(()=>{var s;if(y!=="orders")return;let n=!1;return St(!0),lr.getOrdersByCustomer(((s=I==null?void 0:I.customer)==null?void 0:s.id)||"current-user").then(l=>{n||Tr(l)}).catch(l=>{n||console.error(l)}).finally(()=>{n||St(!1)}),()=>{n=!0}},[y,(ks=I==null?void 0:I.customer)==null?void 0:ks.id]),o.useEffect(()=>{D(n=>ja(n,Re)),jn(Ve),ie(Rr)},[Re,Ve,Rr]);const re=xo(v,R),Oe=v.leveringsadresse.trim(),ps=[Oe,(Ss=v.postnummer)==null?void 0:Ss.trim(),(Cs=v.sted)==null?void 0:Cs.trim()].filter(Boolean).join(", "),ue=[v.firmanavnKundenavn,R==null?void 0:R.id,R==null?void 0:R.displayText,R==null?void 0:R.postalCode,(R==null?void 0:R.city)||(R==null?void 0:R.poststed),R==null?void 0:R.rawSource,Oe,v.postnummer,v.sted].map(n=>String(n||"").trim().toLowerCase()).join("|");Dr.current=ue;const oi=Ye&&Te>=0?oa(Te):void 0,at=Or!=null,li=o.useMemo(()=>ll(_e,he,re?R:null),[_e,he,re,R]),ci=o.useCallback(n=>{if(!n)return;const s=Rl(n,Re);D(s),ie(null),me([]),z(!1),$(-1),pe("idle"),jn((n==null?void 0:n.rememberDeliveryAddress)==null?Ve:hn(n.rememberDeliveryAddress)),m("/portal/bestillinger/ny")},[m,Re,Ve]),it=o.useCallback(async()=>{const n=await Pi(),s=Li(n);return s&&(d(s),Tt(dt(s))),s},[d]);o.useEffect(()=>{Tt(dt(i))},[i]),o.useEffect(()=>{if(y!=="new-order")return;let n=!1;if(_t(!0),ye(null),q().useMocks){const s=ra(he.map(l=>({organizationNumber:l.deliveryOrganizationNumber??l.orgNumber??l.orgNr,organizationName:l.deliveryOrganizationName??l.company??l.legalName??l.name,activeStationCount:1})));Pr(s),_t(!1);return}if(!(i!=null&&i.isRestAuth)){_t(!1);return}return Promise.all([ur.getAll(),ur.getPrimary()]).then(async([s,l])=>{if(n)return;const u=ra(s);Pr(u);const p=cl(l);p&&(p.organizationNumber!==i.primaryDeliveryOrganizationNumber||p.organizationName!==i.primaryDeliveryOrganizationName)&&await it()}).catch(s=>{n||(s==null?void 0:s.status)!==403&&(console.error("Delivery organization lookup failed:",s),ye("Kunne ikke laste leveringsorganisasjoner. Prøv igjen."))}).finally(()=>{n||_t(!1)}),()=>{n=!0}},[y,he,it,i==null?void 0:i.isRestAuth,i==null?void 0:i.primaryDeliveryOrganizationName,i==null?void 0:i.primaryDeliveryOrganizationNumber]);const di=o.useCallback(async()=>{if(at)return;if(!wt){Et("Velg en leveringsorganisasjon.");return}const n=_e.find(l=>l.organizationNumber===wt);if(!n){Et("Valgt organisasjon er ikke lenger tilgjengelig. Velg en annen.");return}if(Et(null),!!window.confirm(`Bekreft ${n.organizationName} som fast leveringsorganisasjon. Valget kan ikke endres senere.`)){Mr(!0),ye(null);try{if(q().useMocks){Tt(n),d(p=>({...p,primaryDeliveryOrganizationNumber:n.organizationNumber,primaryDeliveryOrganizationName:n.organizationName,primaryDeliveryOrganizationSetAtUtc:new Date().toISOString()})),E.success("Leveringsorganisasjonen er lagret.");return}await ur.setPrimary(n.organizationNumber);const l=await it(),u=dt(l);Tt(u),E.success("Leveringsorganisasjonen er lagret.")}catch(l){if((l==null?void 0:l.status)===409){try{const u=await it();if(dt(u)){E.success("Leveringsorganisasjonen var allerede satt.");return}}catch(u){console.error("Could not refresh primary delivery organization after conflict:",u)}ye("Leveringsorganisasjonen er allerede satt. Last inn siden på nytt hvis den ikke vises.");return}if((l==null?void 0:l.status)===404){ye("Valgt organisasjon er ikke lenger tilgjengelig. Velg en annen."),Lr("");return}if((l==null?void 0:l.status)===403){ye("Kun kundekontoer kan velge fast leveringsorganisasjon.");return}console.error("Failed to set primary delivery organization:",l),ye("Kunne ikke lagre leveringsorganisasjonen. Prøv igjen.")}finally{Mr(!1)}}},[_e,at,it,wt,d]);o.useEffect(()=>{if(y!=="new-order"||re||Oe.length<3){me([]),pe("idle"),z(!1),$(-1);return}const n=new AbortController,s=window.setTimeout(async()=>{pe("loading");try{const l=await fo(Gs.searchAddresses,ps,Oe,{signal:n.signal});me(l),pe("success"),z(l.length>0),$(-1)}catch(l){if((l==null?void 0:l.name)==="AbortError")return;console.error("Address search failed:",l),me([]),pe("error"),z(!1),$(-1)}},gl);return()=>{window.clearTimeout(s),n.abort()}},[y,Oe,ps,re]);const ui=n=>{ie(null),te(null),$(-1),D(s=>({...s,leveringsadresse:n}))},mi=()=>{ge.current!=null&&(window.clearTimeout(ge.current),ge.current=null),ae.length>0&&(z(!0),$(n=>n>=0?n:-1))},pi=()=>{ge.current=window.setTimeout(()=>{z(!1),$(-1),ge.current=null},120)},fi=o.useCallback(n=>{te(null),z(!0),$(-1),E.error(n),window.setTimeout(()=>{var s;return(s=In.current)==null?void 0:s.focus()},0)},[]),fs=o.useCallback(n=>{const s=jo();ie(s.selectedAddressSuggestion),me(s.addressSuggestions),pe(s.addressSearchStatus),z(s.addressSuggestionsOpen),$(s.activeAddressSuggestionIndex),te(s.approvedAddressMismatchContext),Cn(s.approvedAddressMismatchChallenge),we(s.addressMismatchReview),E.error(n),window.setTimeout(()=>{var l;return(l=In.current)==null?void 0:l.focus()},0)},[]),gs=n=>{const s=Nr(n)||n.displayText||"",l=n.city||n.poststed||"";ie(n),te(null),me([]),z(!1),$(-1),pe("idle"),D(u=>({...u,leveringsadresse:s,postnummer:n.postalCode||u.postnummer,sted:l||u.sted}))},gi=n=>{if(ae.length===0){n.key==="Escape"&&z(!1);return}if(n.key==="ArrowDown"){n.preventDefault(),z(!0),$(s=>(s+1)%ae.length);return}if(n.key==="ArrowUp"){n.preventDefault(),z(!0),$(s=>s<=0?ae.length-1:s-1);return}if(n.key==="Enter"&&Ye&&Te>=0){n.preventDefault(),gs(ae[Te]);return}n.key==="Escape"&&(n.preventDefault(),z(!1),$(-1))};o.useEffect(()=>()=>{ge.current!=null&&window.clearTimeout(ge.current)},[]),o.useEffect(()=>{var n;(n=He.current)==null||n.abort(),He.current=null,te(s=>s===ue?s:null),Cn(null)},[ue]),o.useEffect(()=>{if(!fe)return;const n=window.setTimeout(()=>{var s;return(s=It.current)==null?void 0:s.focus()},0);return()=>window.clearTimeout(n)},[fe]);const hi=async n=>{var g,b,x,C,H,lt,Ts,_s,Es,As,Ds,Ps,Ls,Os,Fs,Ms,Ks,Us,zs,qs,Bs,$s;if(n.preventDefault(),Nn||Rn.current)return;Ct.current=((g=n.nativeEvent)==null?void 0:g.submitter)||document.activeElement;const{orderType:s}=v,l=[...pn.filter(w=>(v.fylling[w.key]??0)>0).map(w=>
4({productCode:w.productCode,quantity:v.fylling[w.key]})),...fn.filter(w=>(v.nyFlaske[w.key]??0)>0).map(w=>({productCode:w.productCode,quantity:v.nyFlaske[w.key]}))];if(!((b=v.firmanavnKundenavn)!=null&&b.trim())){E.error("Firmanavn / Kundenavn er pÃ¥krevd.");return}if(!at||!(i!=null&&i.primaryDeliveryOrganizationNumber)){E.error("Bekreft fast leveringsorganisasjon før du sender bestillingen.");return}if(!((x=v.leveringsadresse)!=null&&x.trim())){E.error("Leveringsadresse er pÃ¥krevd.");return}if(!re){fi(e("deliveryAddressOfficialSelectionRequired"));return}let u=null;if(re){const w=pr(R);let O;const sr=ue,ar=new AbortController;He.current=ar,Rn.current=!0;try{O=await Gs.verifyCompanyAddress({companyName:v.firmanavnKundenavn.trim(),addressValidation:w,confirmMismatch:Sn===ue,verificationChallenge:Sn===ue?wa:null},{signal:ar.signal})}catch(on){if((on==null?void 0:on.name)==="AbortError")return;console.warn("Company address verification unavailable:",on),E.error(e("companyAddressCheckRequestFailed"));return}finally{He.current===ar&&(He.current=null),Rn.current=!1}if(Dr.current!==sr)return;if((O==null?void 0:O.status)==="unavailable"){if(!O.verificationProof){E.error(e("companyAddressCheckRequestFailed"));return}E(e("companyAddressCheckUnavailable"))}if((O==null?void 0:O.status)==="mismatch"){if(Sn!==ue){we({placeSummary:O.placeSummary||"",context:ue,challenge:O.verificationChallenge||null});return}u=O.verificationProof||null}else u=(O==null?void 0:O.verificationProof)||null}const p=Qi(v.bulk.onsketLeveringsdato);if(p){E.error(p===Zi?e("requestedDeliveryDatePast","Ãnsket leveringsdato kan ikke være i fortiden."):e("requestedDeliveryDateRequired","Ãnsket leveringsdato er pÃ¥krevd."));return}if(s==="BOTTLE"&&l.length===0){E.error(e("errorNoProducts","Velg minst ett produkt (antall > 0)."));return}_r(!0);try{const w=mo(v.leveringsadresse);await lr.createOrder({deliveryOrganizationNumber:i.primaryDeliveryOrganizationNumber,deliveryOrganizationName:i.primaryDeliveryOrganizationName,customerId:((C=I==null?void 0:I.customer)==null?void 0:C.id)||"current-user",customerName:v.firmanavnKundenavn.trim(),contactPerson:((H=v.kontaktperson)==null?void 0:H.trim())||null,phone:((lt=v.telefon)==null?void 0:lt.trim())||null,email:((Ts=v.epost)==null?void 0:Ts.trim())||null,postalCode:((_s=v.postnummer)==null?void 0:_s.trim())||null,city:((Es=v.sted)==null?void 0:Es.trim())||null,comment:((As=v.kommentar)==null?void 0:As.trim())||"",deliveryAddress:w,rememberDeliveryAddress:xn,addressValidation:pr(re?R:null),companyAddressVerificationProof:u,orderType:s,desiredDeliveryDate:v.bulk.onsketLeveringsdato.trim(),isBulkLpg:s==="BULK_LPG",customerInfo:{firmanavnKundenavn:v.firmanavnKundenavn.trim(),kontaktperson:((Ds=v.kontaktperson)==null?void 0:Ds.trim())||null,telefon:((Ps=v.telefon)==null?void 0:Ps.trim())||null,epost:((Ls=v.epost)==null?void 0:Ls.trim())||null,leveringsadresse:((Os=v.leveringsadresse)==null?void 0:Os.trim())||null,postnummer:((Fs=v.postnummer)==null?void 0:Fs.trim())||null,sted:((Ms=v.sted)==null?void 0:Ms.trim())||null,rememberDeliveryAddress:xn,addressValidation:pr(re?R:null),kommentar:((Ks=v.kommentar)==null?void 0:Ks.trim())||null},lines:s==="BOTTLE"?l:[],bulkDetails:s==="BULK_LPG"?{tanknummerReferanse:((Us=v.bulk.tanknummerReferanse)==null?void 0:Us.trim())||null,onsketVolum:((zs=v.bulk.onsketVolum)==null?void 0:zs.trim())||null,onsketLeveringsdato:((qs=v.bulk.onsketLeveringsdato)==null?void 0:qs.trim())||null}:null}),E.success(e("orderSuccess","Bestilling sendt!")),ie(null),me([]),z(!1),D(jr(Re)),m("/portal/bestillinger"),ii()}catch(w){const O=No(w);if(O==="selection_required")fs(e("deliveryAddressOfficialSelectionRequired"));else if(O==="selection_invalid")fs(e("deliveryAddressOfficialSelectionInvalid"));else{const sr=((Bs=w==null?void 0:w.data)==null?void 0:Bs.detail)||(($s=w==null?void 0:w.data)==null?void 0:$s.message)||(w==null?void 0:w.message);E.error(e("orderError","Kunne ikke opprette bestilling: ")+sr)}}finally{_r(!1)}},yi=async n=>{n.preventDefault(),be({text:"",isError:!1});const s=io(L.requestedAmountKr);if(!L.stationId){be({text:"Velg stasjon for kredittforespørselen.",isError:!0});return}if(s==null){be({text:"Skriv inn et gyldig kredittbeløp.",isError:!0});return}const l=L.creditKind==="company";
4if(l&&(!L.companyName.trim()||!L.organizationNumber.trim())){be({text:"Firmanavn og organisasjonsnummer mÃ¥ fylles ut for firmakreditt.",isError:!0});return}Yr(!0);try{await hr.requestDirectCredit({stationId:L.stationId,requestedAmountOre:s,requestNote:L.requestNote.trim()||void 0,companyName:l?L.companyName:void 0,organizationNumber:l?L.organizationNumber:void 0}),de(u=>({...u,requestedAmountKr:"",requestNote:""})),await Jt(),be({text:"Kredittforespørsel sendt.",isError:!1})}catch{be({text:e("common:contentUpdateFailed"),isError:!0})}finally{Yr(!1)}},ot=o.useCallback(n=>{var l;switch(((l=n==null?void 0:n.toUpperCase)==null?void 0:l.call(n))??n){case"CARD":case"BANK_TERMINAL":case"TERMINAL_CARD":return e("bankTerminal");case"CREDIT":case"USER_CREDIT":return e("creditAgreement");case"VIPPS":return"Vipps";default:return n||"â"}},[e]),nr=o.useMemo(()=>tl(Jr,zt,qt).map(n=>({...n,date:Ke(n.timestamp,"nb-NO"),time:mn(n.timestamp,"nb-NO",{hour:"2-digit",minute:"2-digit"}),paymentTypeRaw:n.paymentType,paymentType:ot(n.paymentType)})),[Jr,zt,qt,ot]),hs=o.useMemo(()=>(q().useMocks?nr:Bt).map(s=>ma(s)).filter(s=>Ui(s,Kn)),[nr,Kn,Bt]),vi=async()=>{m("/portal/kvitteringer");const{useMocks:n}=q();if(xe(null),!n){Xr(!0);try{const s=await dn.getStories(),l=new Date(`${zt}T00:00:00`).getTime(),u=new Date(`${qt}T23:59:59`).getTime(),p=vr(s).filter(g=>{if(!g.timestamp)return!0;const b=new Date(g.timestamp).getTime();return Number.isNaN(b)||b>=l&&b<=u}).map(g=>{const b=g.transactionId,x=g.timestamp??g.dateTime??g.endedAt;return{...g,transactionId:b,storyRecordId:g.storyRecordId,storyId:g.storyId,date:Ke(x,"nb-NO"),time:mn(x,"nb-NO",{hour:"2-digit",minute:"2-digit"}),amountKr:Number(g.effectiveAmountKr),paymentType:ot(g.paymentType??g.paymentMethod),paymentTypeRaw:g.paymentType??g.paymentMethod}});On(p)}catch{xe(e("common:contentUpdateFailed")),On([])}finally{Xr(!1)}}},ys=async(n,s)=>{n.preventDefault();const l=s.storyRecordId??s.transactionId??s.id;if(!l)return;xe(null);const u=window.innerWidth<=768,p=lo(),g=!u&&!p?window.open("","_blank"):null;try{const b=na(s,q().useMocks)?await Fl(s):await dn.getReceiptPdf(l);if(p){Ln({blob:b,filename:`${l}.pdf`});return}const x=URL.createObjectURL(b);u||!g?Ln({url:x,blob:b,filename:`${l}.pdf`}):(g.opener=null,g.location.replace(x),setTimeout(()=>URL.revokeObjectURL(x),1e4))}catch{g==null||g.close(),xe(e("common:contentUpdateFailed"))}},bi=async(n,s)=>{n.preventDefault();const l=s.storyRecordId??s.transactionId??s.id;if(l){xe(null);try{const u=na(s,q().useMocks)?ka(s):await dn.getReceiptText(l);bn(typeof u=="string"?u:(u==null?void 0:u.receiptText)??(u==null?void 0:u.text)??JSON.stringify(u,null,2))}catch{xe(e("common:contentUpdateFailed"))}}};o.useEffect(()=>{if((h==null?void 0:h.status)!=="completed"||!h.storyId)return;let n=!1,s=null;const l=Date.now()+Go;F(!1),P(!1),J(null),ht(!1);const u=b=>{gt(b),On(x=>{if(x.some(H=>(H.storyRecordId??H.transactionId)===(b.storyRecordId??b.transactionId)))return x;const C=b.timestamp;return[{...b,transactionId:b.transactionId,storyRecordId:b.storyRecordId,storyId:b.storyId,date:Ke(C,"nb-NO"),time:mn(C,"nb-NO",{hour:"2-digit",minute:"2-digit"}),amountKr:Number(b.effectiveAmountKr),paymentType:ot(b.paymentType),paymentTypeRaw:b.paymentType},...x]})},p=()=>{if(Date.now()>=l){ht(!0);return}s=setTimeout(g,$o)},g=async()=>{try{const b=await dn.getStories();if(n)return;const x=vr(b),C=ea(x,h.storyId);if(C){u(C);return}p()}catch{if(n)return;if(Date.now()>=l){ht(!0),xe(e("common:contentUpdateFailed"));return}p()}};return g(),()=>{n=!0,s!=null&&clearTimeout(s)}},[h==null?void 0:h.status,h==null?void 0:h.storyId,ot,e]);const Ni=()=>{var n;(n=ne==null?void 0:ne.url)!=null&&n.startsWith("blob:")&&URL.revokeObjectURL(ne.url),Ln(null)},vs=o.useCallback(()=>{ss(!0),Ae.current&&clearTimeout(Ae.current),Ae.current=setTimeout(()=>{ss(!1),Ae.current=null},3e3)},[]);o.useEffect(()=>{if(!or||!ce||!(i!=null&&i.id)||ir()){Bn(null),$n(!1);return}let n=!1;return $n(!0),Ce.getB024Capability().then(s=>{n||Bn(s)}).catch(()=>{n||Bn(null)}).finally(()=>{n||$n(!1)}),()=>{n=!0}},[ce,i==null?void 0:i.id]);const tn=o.useCallback(async()=>{var s,l,u,p;const n=N==null?void 0:N.stationCode;if(!(!n||!(i!=null&&i.id))){ns(!0);try{const[g,b]=await Promise.all([Ce.getMyStationClipStatus(n),Ce.getMyClipEvents()]),x=Ml(g,e),C=Gn.current;es(x),Gn.current={stationCode:n,status:x},(C==null?void 0:C.stationCode)===n&&((s=C.status)!=null&&s.rewardAvailable)&&!(x!=null&&x.rewardAvailable)&&Number(((l=C.status)==null?void 0:l.balance)??0)>=Number(((u=C.status)==null?void 0:u.threshold)??0)&&vs(),za(b.filter(H=>H.stationCode===n||H.stationId===(N==null?void 0:N.id)))}catch(g){(p=g.message)!=null&&p.includes("not assigned to any clip program")?(es(null),Gn.current={stationCode:n,status:null}):console.error("Failed to fetch clips:",g)}finally{ns(!1)}}},[N,e,vs,i==null?void 0:i.id]);o.useEffect(()=>{je.current=tn},[tn]);const rr=async n=>{if(!Wn.current){Wn.current=!0,Vt({status:"locating",requestType:n}),n==="grant"?$t(!0):Gt(!0);try{const s=await Ji(),l=Xi(he,s);Vt({status:"submitting",requestType:n});const u=eo(l.stationId,s),p=n==="grant"?await Ce.createClipRequest(u):await Ce.createRedeemRequest(u);Vt({status:"success",requestType:n,response:p}),E.success(e(n==="grant"?"requestClipSuccess":"redeemRewardRequestSuccess"))}catch(s){const l=to(s);Vt({status:"error",requestType:n,...l})}finally{Wn.current=!1,n==="grant"?$t(!1):Gt(!1)}}},bs=async()=>
4{if(nt){await rr("grant");return}const n=String((N==null?void 0:N.stationCode)??(N==null?void 0:N.id)??(N==null?void 0:N.stationId)??"").trim();if(!n){E.error(e("requestClipError"));return}$t(!0);try{await Ce.createClipRequest({stationId:n}),E.success(e("requestClipSuccess"))}catch(s){console.error("Failed to request clip:",s),E.error(e("requestClipError"))}finally{$t(!1)}},xi=async()=>{if(nt){await rr("redeem");return}const n=N==null?void 0:N.stationCode;if(!(!n||!(i!=null&&i.id))){Gt(!0);try{await Ce.createRedeemRequest({stationId:n}),E.success(e("redeemRewardRequestSuccess","Forespørsel om belønning er sendt til stasjonseier."))}catch(s){console.error("Failed to redeem reward:",s),E.error(e("redeemRewardError","Kunne ikke sende forespørsel om belønning."))}finally{Gt(!1)}}};o.useEffect(()=>()=>{Ae.current&&clearTimeout(Ae.current)},[]),o.useEffect(()=>{ce&&y==="klippekort"&&tn()},[y,ce,tn]),o.useEffect(()=>{var u;if(!ce){et.current=0,tt.current=0,zn([]),qn([]);return}const n=((u=N==null?void 0:N.spacetimeId)==null?void 0:u.toString())||(N==null?void 0:N.id)||(N==null?void 0:N.stationId);if(!n||!cn.isConfigured()||q().useMocks){et.current=0,tt.current=0,zn([]),qn([]);return}et.current=0,tt.current=0;const s=cn.clips.subscribeToClipRequests({stationId:n,onRows:p=>{var x;const g=p.filter(C=>C.status==="pending"),b=et.current;et.current=g.length,zn(g),b>0&&g.length===0&&((x=je.current)==null||x.call(je))}}),l=cn.clips.subscribeToClipRedeemRequests({stationId:n,onRows:p=>{var x;const g=p.filter(C=>C.status==="pending"),b=tt.current;tt.current=g.length,qn(g),b>0&&g.length===0&&((x=je.current)==null||x.call(je))}});return()=>{s.close(),l.close()}},[ce,N]);const Fe=y==="dashboard",nn=y==="receipts",rn=y==="project-voucher",sn=y==="orders"||y==="new-order",an=y==="org-credit"||y==="org-employees",Ns=Mo(),ji="Bestilling av fylling av propanflasker, kjøp av nye flasker eller LPG til tank.",ki="Bestillingsskjema â Propan / LPG",Si=o.useMemo(()=>{switch(y){case"dashboard":return e("sectionDispenser");case"receipts":return e("sectionReceipts");case"klippekort":return e("sectionKlippekort");case"project-voucher":return"Prosjektkupong";case"orders":return"Mine bestillinger";case"new-order":return"Ny bestilling";case"org-credit":return"Kreditt";case"org-employees":return"Behandle ansatte";default:return e("sectionDispenser")}},[y,e]),Ci=n=>t.jsxs("div",{className:"cp-order-station-block",children:[t.jsx("p",{style:{marginBottom:"0.5rem",fontWeight:600},children:n}),_a?t.jsx("span",{className:"cp-header-station-loading","aria-busy":"true",children:"Laster fast leveringsorganisasjon..."}):at?t.jsxs("div",{className:"cp-primary-station-card",children:[t.jsx("span",{className:"cp-primary-station-label",children:"Fast leveringsorganisasjon"}),t.jsx("strong",{children:Or.organizationName}),t.jsx("span",{children:"Organisasjonen er lÃ¥st for alle fremtidige leveringsbestillinger."})]}):t.jsxs("div",{className:"cp-primary-station-card",children:[t.jsx("span",{className:"cp-primary-station-label",children:"Velg fast leveringsorganisasjon"}),t.jsx("p",{children:"Velg organisasjonen som skal hÃ¥ndtere leveringene dine. Valget lagres én gang og kan ikke endres senere."}),t.jsx("div",{className:"cp-dispenser-station-widget",children:wn&&_e.length===0?t.jsx("button",{type:"button",className:"cp-header-station-retry",onClick:()=>window.location.reload(),"aria-label":e("retry"),children:e("retry")}):t.jsxs(t.Fragment,{children:[t.jsxs("select",{id:"cp-order-primary-delivery-organization-select",className:"cp-header-station-select",value:wt,onChange:s=>{Lr(s.target.value),Et(null)},"aria-label":"Velg fast leveringsorganisasjon","aria-describedby":`cp-order-primary-delivery-organization-help${Qe?" cp-order-primary-delivery-organization-error":""}`,"aria-errormessage":Qe?"cp-order-primary-delivery-organization-error":void 0,"aria-invalid":Qe?"true":void 0,required:!0,children:[t.jsx("option",{value:"",children:"Velg organisasjon"}),li.map(s=>t.jsx("option",{value:s.organizationNumber,children:s.organizationName},s.organizationNumber))]}),t.jsx("button",{type:"button",className:"ui-button ui-button--secondary cp-btn-outline cp-primary-station-confirm",onClick:di,disabled:_e.length===0||Fr,children:Fr?"Lagrer...":"Bekreft organisasjon"})]})}),t.jsx("span",{id:"cp-order-primary-delivery-organization-help",className:"cp-sr-only",children:"Organisasjonene sorteres etter avstand til valgt leveringsadresse nÃ¥r stasjonskoordinater er tilgjengelige."}),Qe&&t.jsx("p",{id:"cp-order-primary-delivery-organization-error",className:"cp-location-hint cp-station-info-error",role:"alert",children:Qe}),wn&&t.jsx("p",{className:"cp-location-hint cp-station-info-error",role:"alert",children:wn})]})]});return t.jsxs("main",{className:"cp-page","data-testid":"customer-portal-page",children:[t.jsx(Oi,{desktopSidebar:!0,brandSubtitle:e("customerPortal"),mobileCenterTitle:Si,leftContent:t.jsx("div",{className:"cp-header-left-content",children:t.jsx("nav",{className:"cp-header-nav","aria-label":e("customerPortal"),children:t.jsxs("div",{className:"cp-header-nav-inner",children:[Ze&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:`cp-header-nav-tab ${Fe?"active":""}`,onClick:()=>m("/portal/dispenser"),"aria-current":Fe?"page":void 0,"data-testid":"customer-nav-dispenser",children:[t.jsx(T,{name:"local_gas_station"}),t.jsx("span",{children:e("sectionDispenser")})]}),t.jsxs("button",{type:"button",className:`cp-header-nav-tab ${nn?"active":""}`,onClick:()=>m("/portal/kvitteringer"),"aria-current":nn?"page":void 0,"data-testid":"customer-nav-receipts",children:[t.jsx(T,{name:"receipt"}),t.jsx("span",{children:e("sectionReceipts")})]}),t.jsxs("button",{type:"button",className:`cp-header-nav-tab ${y==="klippekort"?"active":""}`,onClick:()=>m("/portal/klippekort"),"aria-current":y==="klippekort"?"page":void 0,"data-testid":"customer-nav-klippekort",children:[t.jsx(T,{name:"confirmation_number"}),t.jsx("span",{children:e("sectionKlippekort")})]}),_n&&t.jsxs("button",{type:"button",className:`cp-header-nav-tab ${rn?"active":""}`,onClick:()=>m("/portal/prosjektkupong"),"aria-current":rn?"page":void 0,children:[t.jsx(T,{name:"confirmation_number"}),t.jsx("span",{children:"Prosjektkupong"})]})]}),t.jsxs("button",{type:"button",className:`cp-header-nav-tab ${sn?"active":""}`,onClick:()=>m("/portal/bestillinger"),"aria-current":sn?"page":void 0,children:[t.jsx(T,{name:"inventory_2"}),t.jsx("span",{children:e("sectionOrders")})]}),Je&&t.jsxs("button",{type:"button",className:`cp-header-nav-tab ${an?"active":""}`,onClick:()=>m("/portal/kreditt"),"aria-current":an?"page":void 0,children:[t.jsx(T,{name:"credit_score"}),t.jsx("span",{children:"Kreditt"})]}),$r&&t.jsxs("button",{type:"button",className:"cp-header-nav-tab",onClick:()=>m("/projects"),children:[t.jsx(T,{name:"folder_open"}),t.jsx("span",{children:"Prosjekter"})]})]})})}),rightContent:t.jsx(Mi,{redirectTo:"/"})}),Fe&&Ze&&t.jsx("div",{className:"cp-main-grid cp-main-grid--single",children:t.jsx("div",{className:"cp-dispenser-col",children:y==="dashboard"&&t.jsxs("div",{className:"cp-card cp-dispenser-card",children:[t.jsxs("div",{className:"cp-card-header-row",children:[t.jsx("div",{className:"cp-card-badge",children:e("sectionDispenser")}),t.jsx("div",{className:"cp-dispenser-station-widget",children:Dt?t.jsx("span",{className:"cp-header-station-loading","aria-busy":"true",children:e("loadingStations")}):zr?t.jsx("button",{type:"button",className:"cp-header-station-retry",onClick:()=>Le(),"aria-label":e("retry"),children:e("retry")}):t.jsxs(t.Fragment,{children:[t.jsxs("select",{id:"cp-station-select",className:"cp-header-station-select",value:X?String(X.id??X.stationId??X):"",onCh
4ange:n=>ms(n.target.value),"aria-label":e("selectStation"),children:[t.jsx("option",{value:"",children:e("selectStation")}),oe.map(n=>{const s=n.id??n.stationId,l=n.name??n.legalName??n.stationCode??"",u=n.address??"",p=u?`${l} â ${u}`:l,g=n._distanceKm!=null?un(n._distanceKm):n.distanceKm!=null?un(n.distanceKm):null;return t.jsxs("option",{value:s,children:[p,g?` (${g})`:""]},s)})]}),t.jsx("button",{type:"button",className:"cp-header-station-closest",onClick:()=>{Se(),Le(!0)},disabled:Dt,"aria-label":e("chooseClosestStation"),title:e("chooseClosestStation"),children:t.jsx(T,{name:"my_location"})})]})}),Xt&&t.jsx("p",{className:"cp-location-hint",role:"status","aria-live":"polite",children:Xt}),t.jsx("div",{className:"cp-status-row",children:t.jsx("span",{className:`cp-status-badge ${Ne==="ONLINE"?"online":Ne==="OFFLINE"?"offline":""}`,"aria-live":"polite",children:e(Ne==="ONLINE"?"statusOnline":Ne==="OFFLINE"?"statusOffline":"statusUnknown")})})]}),t.jsxs("div",{className:"cp-prisvisning",children:[t.jsxs("div",{className:"cp-tax-options",children:[t.jsxs("label",{className:"cp-tax-radio",children:[t.jsx("input",{type:"radio",name:"custTaxOption",checked:k===!0,onChange:()=>{Se(),A(!0)},disabled:_}),t.jsx("span",{children:e("withRoadTax")})]}),t.jsxs("label",{className:"cp-tax-radio",children:[t.jsx("input",{type:"radio",name:"custTaxOption",checked:k===!1,onChange:()=>{Se(),A(!1)},disabled:_}),t.jsx("span",{children:e("withoutTax")})]})]}),t.jsx("button",{type:"button",className:`cp-tax-btn ${k?"with-tax":"without-tax"}`,onClick:()=>{_||(Se(),A(n=>n==null?!0:!n))},disabled:_,"aria-pressed":k===!1,"aria-label":k==null?e("chooseRoadTax"):e(k?"withRoadTaxCaps":"withoutRoadTaxCaps"),children:k==null?e("chooseRoadTax"):e(k?"withRoadTaxCaps":"withoutRoadTaxCaps")}),k===!1&&t.jsx(zi,{className:"cp-tax-warning"})]}),t.jsxs("div",{className:"cp-display-row",children:[t.jsxs("div",{className:"cp-display-field",children:[t.jsx("div",{className:"cp-display-label",children:e("amountToPay")}),t.jsx("div",{className:"cp-display-box",children:Za})]}),t.jsxs("div",{className:"cp-display-field",children:[t.jsx("div",{className:"cp-display-label",children:e("volumeLitres")}),t.jsx("div",{className:"cp-display-box",children:Ja})]}),t.jsxs("div",{className:"cp-display-field",children:[t.jsx("div",{className:"cp-display-label",children:e("pricePerLitre")}),t.jsx("div",{className:"cp-display-box price",children:os!=null?Number(os).toFixed(2).replace(".",","):"â"})]})]}),t.jsxs("div",{className:"cp-payment-section",children:[t.jsx("div",{className:"cp-payment-label",children:e("selectPayment")}),t.jsxs("div",{className:"cp-payment-options",role:"radiogroup","aria-label":e("selectPayment"),children:[t.jsxs("label",{className:"cp-payment-option",children:[t.jsx("input",{type:"radio",name:"customer-payment-tender",value:"terminal_card",checked:M.method==="terminal_card",onChange:()=>Lt({method:"terminal_card",creditId:""})}),t.jsxs("span",{className:"cp-payment-option-label",children:[t.jsx(T,{name:"credit_card"}),t.jsx("span",{children:e("bankTerminal")})]})]}),t.jsxs("label",{className:"cp-payment-option",children:[t.jsx("input",{type:"radio",name:"customer-payment-tender",value:"credit",checked:M.method==="credit",disabled:De.length===0,onChange:()=>{var n;return Lt({method:"credit",creditId:((n=De[0])==null?void 0:n.id)??""})}}),t.jsxs("span",{className:"cp-payment-option-label",children:[t.jsx(T,{name:"account_balance_wallet"}),t.jsx("span",{children:e("creditAgreement")})]})]})]}),M.method==="credit"&&t.jsxs("label",{className:"cp-payment-credit-select",children:["Kredittlinje",t.jsx("select",{value:M.creditId,onChange:n=>Lt({method:"credit",creditId:n.target.value}),children:De.map(n=>{const s=Vs(n);return t.jsxs("option",{value:n.id,children:[fr(n)," - ",Me(cr(n)),s?` - ${s}`:""]},n.id)})})]}),M.method==="terminal_card"&&De.length===0&&t.jsx("div",{className:"cp-payment-hint",children:"Ingen godkjent kredittlinje for valgt stasjon."}),Ht&&t.jsxs("div",{className:"cp-payment-hint",children:["Tilgjengelig: ",Me(cr(Ht))]})]}),kr&&t.jsx("p",{className:"cp-dispenser-error",role:"alert",children:kr}),(h==null?void 0:h.storyId)&&t.jsxs("div",{className:`cp-app-dispenser-progress cp-app-dispenser-progress--${Pe}`,role:"status","aria-live":"polite",children:[t.jsxs("div",{children:[t.jsx("span",{className:"cp-app-dispenser-progress-label",children:Xa}),t.jsxs("span",{className:"cp-app-dispenser-story",children:[e("storyId"),": ",h.storyId]})]}),["waiting_for_terminal","payment_authorized","ready_to_dispense","cancelling"].includes(Pe)&&t.jsx("div",{className:"cp-app-dispenser-actions",children:t.jsx("button",{type:"button",className:"ui-button ui-button--secondary cp-btn-outline",onClick:si,disabled:ft||h.status==="cancelling",children:ft||h.status==="cancelling"?e("cancellingDispenserSession"):e("cancelDispenserSession")})}),["stalled","failed"].includes(Pe)&&t.jsxs("div",{className:"cp-app-dispenser-actions",children:[t.jsx("button",{type:"button",className:"ui-button ui-button--secondary cp-btn-outline",onClick:st,children:e("retry")}),t.jsx("span",{children:e("contactSupport")})]}),Qt&&Pe==="completed"&&t.jsxs("div",{className:"cp-app-dispenser-actions",children:[t.jsx("button",{type:"button",className:"ui-button ui-button--secondary cp-btn-outline",onClick:n=>bi(n,Qt),children:e("openReceiptText")}),t.jsx("button",{type:"button",className:"ui-button ui-button--secondary cp-btn-outline",onClick:n=>ys(n,Qt),children:e("downloadPdf")})]}),!Qt&&Pe==="completed"&&t.jsx("div",{className:"cp-app-dispenser-actions",children:t.jsx("span",{children:e(Ca?"receiptPendingTimedOut":"receiptPending")})})]}),ei&&M.method==="terminal_card"&&t.jsxs("section",{className:"cp-native-wallet","aria-labelledby":"
4cp-native-wallet-heading",children:[t.jsx("h3",{id:"cp-native-wallet-heading",children:e("nativeWalletHeading",{wallet:c.wallet==="applePay"?"Apple Pay":"Google Pay"})}),t.jsx("p",{className:"cp-native-wallet-reservation",children:ds?e("nativeWalletReservation",{amount:ds}):e("nativeWalletReservationPending")}),cs&&t.jsxs("p",{className:"cp-native-wallet-status",role:"status","aria-live":"polite",children:[t.jsx(T,{name:"progress_activity",className:"icon-spin"}),e(`nativeWalletProgress.${Sr}`)]}),mt&&t.jsx("p",{className:`cp-native-wallet-message cp-native-wallet-message--${mt.kind}`,role:mt.kind==="error"?"alert":"status","aria-live":"polite",children:mt.text}),t.jsx(Co,{wallet:c.wallet,disabled:!er||cs||_||Ne==="OFFLINE",onClick:ri,ariaLabel:e("nativeWalletButtonLabel",{wallet:c.wallet==="applePay"?"Apple Pay":"Google Pay"})})]}),t.jsx("button",{className:`cp-connect-btn ${!er||Z||Ne==="OFFLINE"?"disabled":""}`,onClick:ni,disabled:!er||Z||_||Ne==="OFFLINE",children:Z&&!_?t.jsxs(t.Fragment,{children:[t.jsx(T,{name:"progress_activity",className:"icon-spin"})," ",e("connecting")]}):e("connectDispenser")})]})})}),(!Fe||La)&&t.jsxs("div",{className:"cp-section-content",children:[y==="receipts"&&Br&&t.jsxs("div",{className:"cp-card",children:[t.jsx("div",{className:"cp-card-badge",children:e("receipts")}),t.jsxs("div",{className:"cp-receipts-filter",children:[t.jsxs("div",{className:"cp-date-row",children:[t.jsxs("div",{className:"cp-date-field",children:[t.jsx("label",{children:e("fromDate")}),t.jsx("input",{type:"date",value:zt,onChange:n=>Fa(n.target.value)})]}),t.jsxs("div",{className:"cp-date-field",children:[t.jsx("label",{children:e("toDate")}),t.jsx("input",{type:"date",value:qt,onChange:n=>Ma(n.target.value)})]})]}),t.jsx("button",{className:"ui-button ui-button--primary cp-btn-orange",type:"button",onClick:vi,disabled:Fn,children:Fn?e("loadingReceipts","Laster kvitteringer..."):e("getReceipts")})]}),Mn&&t.jsx("p",{className:"cp-receipts-error",style:{color:"var(--color-error, #c00)",marginTop:"0.5rem"},children:Mn}),t.jsx("div",{className:"accounting-quality-filters",role:"group","aria-label":e("accountingQuality.filterLabel"),children:qi.map(n=>t.jsx("button",{type:"button",className:"accounting-quality-filter","aria-pressed":Kn===n,onClick:()=>Ua(n),children:e(`accountingQuality.filters.${n}`)},n))}),t.jsxs("div",{className:"ui-data-grid cp-receipts-table cp-receipts-table--transactions",children:[t.jsxs("div",{className:"ui-data-grid__header cp-receipts-header",children:[t.jsx("span",{className:"cp-receipts-col-date",children:e("date")}),t.jsx("span",{className:"cp-receipts-col-time",children:e("time")}),t.jsx("span",{className:"cp-receipts-col-quality",children:e("accountingQuality.quality")}),t.jsx("span",{className:"cp-receipts-col-amount",children:e("amount")}),t.jsx("span",{className:"cp-receipts-col-payment",children:e("payment")}),t.jsx("span",{className:"cp-receipts-col-receipt",children:e("receipt")})]}),hs.length===0&&!Fn&&t.jsx("div",{className:"ui-data-grid__empty cp-receipts-row",style:{gridColumn:"1 / -1",color:"var(--text-secondary)"},children:Mn?null:Bt.length>0||nr.length>0?e("accountingQuality.noMatchingFilter"):e("receiptsNote","Ingen kvitteringer i den valgte perioden")}),hs.map(n=>t.jsxs("div",{className:`ui-data-grid__row cp-receipts-row${n.isDemoDispensingReceipt?" cp-receipts-row--demo-fill":""}`,children:[t.jsx("span",{className:"cp-receipts-col-date",children:n.date}),t.jsx("span",{className:"cp-receipts-col-time",children:n.time}),t.jsxs("div",{className:"cp-receipts-col-quality",children:[t.jsx(Bi,{row:n,t:e}),t.jsx($i,{row:n,t:e})]}),t.jsx("span",{className:"cp-receipts-col-amount",children:Gi(n)?t.jsxs("span",{className:"accounting-quality-values",children:[t.jsx("span",{className:"accounting-quality-values__label",children:e("accountingQuality.reported")}),t.jsxs("span",{children:[Number(n.reportedAmountKr).toFixed(2)," kr"]}),t.jsx("span",{className:"accounting-quality-values__label",children:e("accountingQuality.accountingValue")}),t.jsxs("span",{children:[Number(n.effectiveAmountKr).toFixed(2)," kr"]})]}):`${Number(n.effectiveAmountKr).toFixed(2)} kr`}),t.jsxs("span",{className:"cp-receipts-col-payment",children:[n.paymentType,n.isDemoDispensingReceipt?t.jsx("span",{className:"cp-receipt-demo-fill-label",children:e("simulatedDispensingReceipt")}):null]}),t.jsx("span",{className:"cp-receipts-col-receipt",children:n.transactionId?t.jsx("span",{className:"cp-receipt-actions",children:t.jsx("a",{href:"#",className:"cp-pdf-link cp-pdf-link--icon",onClick:s=>ys(s,n),"aria-label":e("downloadPdf"),children:t.jsx(T,{name:"receipt"})})}):t.jsx("span",{className:"cp-pdf-link cp-pdf-link--icon",style:{opacity:.7},"aria-hidden":"true",children:t.jsx(T,{name:"receipt"})})}),t.jsx(Wi,{row:n,t:e,formatTimestamp:s=>dr(s,"nb-NO")})]},n.transactionId??n.id))]})]}),y==="klippekort"&&ce&&t.jsxs("div",{className:"cp-card",children:[t.jsxs("div",{className:"cp-card-header-row",children:[t.jsx("div",{className:"cp-card-badge",children:e("sectionKlippekort")}),t.jsx("div",{className:"cp-dispenser-station-widget",children:Ga&&or&&!ir()?t.jsx("span",{className:"cp-header-station-loading","aria-busy":"true",children:e("b024PolicyLoading")}):nt?t.jsxs("div",{className:"cp-b024-location-station",role:"status",children:[t.jsx(T,{name:"my_location"}),t.jsx("span",{children:e("b024StationChosenFromFreshLocation")})]}):Dt?t.jsx("span",{className:"cp-header-station-loading","aria-busy":"true",children:e("loadingStations")}):zr?t.jsx("button",{type:"button",className:"cp-header-station-retry",onClick:()=>Le(),"aria-label":e("retry"),children:e("retry")}):t.jsxs(t.Fragment,{children:[t.jsxs("select",{id:"cp-station-select-clips",className:"cp-header-station-select",value:X?String(X.id??X.stationId??X):"",onCh
4ange:n=>ms(n.target.value),"aria-label":e("selectStation"),children:[t.jsx("option",{value:"",children:e("selectStation")}),oe.map(n=>{const s=n.id??n.stationId,l=n.name??n.legalName??n.stationCode??"",u=n.address??"",p=u?`${l} â ${u}`:l,g=n._distanceKm!=null?un(n._distanceKm):n.distanceKm!=null?un(n.distanceKm):null;return t.jsxs("option",{value:s,children:[p,g?` (${g})`:""]},s)})]}),t.jsx("button",{type:"button",className:"cp-header-station-closest",onClick:()=>{Se(),Le(!0)},disabled:Dt,"aria-label":e("chooseClosestStation"),title:e("chooseClosestStation"),children:t.jsx(T,{name:"my_location"})})]})}),!nt&&Xt&&t.jsx("p",{className:"cp-location-hint",role:"status","aria-live":"polite",children:Xt})]}),nt&&U.status!=="idle"?t.jsxs("div",{className:`cp-b024-request-state cp-b024-request-state--${U.status}`,role:U.status==="error"?"alert":"status","aria-live":"polite",children:[U.status==="locating"?t.jsx("p",{children:e("b024Locating")}):null,U.status==="submitting"?t.jsx("p",{children:e("b024CreatingRequest")}):null,U.status==="success"?t.jsxs(t.Fragment,{children:[t.jsx("strong",{children:e(U.requestType==="redeem"?"b024RedeemRequestCreated":"b024GrantRequestCreated")}),t.jsx("p",{children:e("b024ResolvedStation",{station:((Is=U.response)==null?void 0:Is.stationName)||((Rs=U.response)==null?void 0:Rs.stationCode)})}),t.jsx("p",{children:e("b024RequestExpires",{expiry:dr((ws=U.response)==null?void 0:ws.expiresAtUtc)})})]}):null,U.status==="error"?t.jsxs(t.Fragment,{children:[t.jsx("strong",{children:e(`b024Error_${U.code}`)}),t.jsx("p",{children:e(`b024Recovery_${U.code}`)}),U.retryable?t.jsx("button",{type:"button",className:"ui-button ui-button--secondary cp-b024-retry",onClick:()=>rr(U.requestType),disabled:Xe||Un,children:e("retry")}):null]}):null]}):null,qa?t.jsx("p",{children:e("loadingClips","Laster klipp...")}):!W||!W.exists?t.jsxs("div",{className:"cp-clips-empty",children:[t.jsx("p",{children:e("noClips")}),t.jsx("button",{className:"ui-button ui-button--primary cp-btn-orange",onClick:bs,disabled:Xe||Wt.length>0,children:Xe?e("sending","Sender..."):Wt.length>0?e("clipRequested"):e("requestClip")})]}):t.jsxs("div",{className:"cp-clips-container",children:[Ba?t.jsx("div",{className:"cp-reward-confetti","aria-hidden":"true",children:Array.from({length:36}).map((n,s)=>t.jsx("span",{style:{"--x":`${s*71%300-150}px`,"--r":`${s*53%520-260}deg`,"--d":`${s%12*.085}s`,"--f":`${s*29%100/100+.78}`,"--c":["#f39c12","#1fb46a","#3498db","#e74c3c","#f1c40f","#22c1c3"][s%6]}},s))}):null,t.jsxs("div",{className:"cp-clips-status",children:[t.jsx("h3",{children:W.programName}),t.jsx("p",{children:e("klippekortNote",{count:W.threshold})}),t.jsxs("div",{className:"cp-clips-progress",children:[t.jsx("div",{className:"cp-clips-grid",children:Array.from({length:W.threshold}).map((n,s)=>t.jsx("div",{className:`cp-clip-slot ${s<W.balance?"filled":""}`,children:s<W.balance&&t.jsx(T,{name:"check"})},s))}),t.jsx("p",{className:"cp-clips-count",children:e("clipsCount",{count:W.balance,total:W.threshold})})]}),W.balance>=W.threshold&&t.jsxs("div",{className:"cp-reward-banner",children:[t.jsx("p",{children:e("rewardReady")}),t.jsx("button",{className:"ui-button ui-button--primary cp-btn-orange",onClick:xi,disabled:Un||rs.length>0,children:Un?e("sending","Sender..."):rs.length>0?e("rewardRequested","Belønning forespurt"):e("redeemReward")})]}),t.jsx("button",{className:"ui-button ui-button--primary cp-btn-orange",onClick:bs,disabled:Xe||Wt.length>0,style:{marginTop:"1rem"},children:Xe?e("sending","Sender..."):Wt.length>0?e("clipRequested"):e("requestClip")})]}),ts.length>0&&t.jsxs("div",{className:"cp-clips-history",children:[t.jsx("h4",{style:{marginTop:"2rem",marginBottom:"1rem"},children:e("clipHistory")}),t.jsxs("div",{className:"ui-data-grid cp-receipts-table cp-clips-history-table",role:"table","aria-label":e("clipHistory"),children:[t.jsxs("div",{className:"ui-data-grid__header cp-receipts-header",role:"row",children:[t.jsx("span",{role:"columnheader",children:e("date")}),t.jsx("span",{role:"columnheader",children:e("type")}),t.jsx("span",{className:"cp-clips-history-amount",role:"columnheader",children:e("amount")})]}),ts.map(n=>{const s=sl(n,e);return t.jsxs("div",{className:"ui-data-grid__row cp-receipts-row",role:"row",children:[t.jsx("span",{className:"cp-clips-history-date",role:"cell",children:s.date}),t.jsx("span",{className:"cp-clips-history-type",role:"cell",children:s.type}),t.jsx("span",{className:"cp-clips-history-amount",role:"cell",children:s.amount})]},n.id)})]})]})]})]}),y==="project-voucher"&&_n&&t.jsx(ko,{}),(y==="orders"||y==="new-order")&&t.jsxs(t.Fragment,{children:[y==="orders"&&t.jsxs("div",{className:"cp-card",children:[t.jsxs("div",{className:"cp-card-header-row",children:[t.jsx("div",{className:"cp-card-badge",children:"Mine bestillinger"}),t.jsx("button",{className:"ui-button ui-button--primary cp-btn-orange",onClick:()=>m("/portal/bestillinger/ny"),children:"Ny bestilling"})]}),Ra?t.jsx("p",{children:"Laster bestillinger..."}):wr.length===0?t.jsx("p",{children:"Du har ingen bestillinger enda."}):t.jsxs("div",{className:"ui-data-grid cp-receipts-table cp-orders-table",style:{marginTop:"1rem"},role:"table","aria-label":"Mine bestillinger",children:[t.jsxs("div",{className:"ui-data-grid__header cp-receipts-header",role:"row",children:[t.jsx("span",{role:"columnheader",children:"Dato og tid"}),t.jsx("span",{role:"columnheader",children:e("requestedDeliveryDate","Ãnsket leveringsdato")}),t.jsx("span",{role:"columnheader",children:"Status"}),t.jsx("span",{role:"columnheader",children:"Produkter"}),t.jsx("span",{role:"columnheader",children:"Leveringsadresse"}),t.jsx("span",{role:"columnheader",children:"Notater"}),t.jsx("span",{role:"columnheader",children:"Handling"})]}),wr.map(n=>t.jsxs("div",{className:"ui-data-grid__row cp-receipts-row",role:"row",children:[t.jsx("span",{className:"cp-order-cell","data-label":"Dato og tid",role:"cell",children:t.jsx("span",{children:dr(n.createdAt,"nb-NO")})}),t.jsx("span",{className:"cp-order-cell","data-label":e("requestedDeliveryDate","Ãnsket leveringsdato"),role:"cell",children:t.jsx("span",{children:oo(Vi(n),"nb-NO")||"â"})}),t.jsx("span",{className:"cp-order-cell status-cell","data-label":"Status",role:"cell",children:t.jsx("span",{style:Al(n.status),children:_l(n.status,e)})}),t.jsx("span",{className:"cp-order-cell","data-label":"Produkter",style:{fontSize:"0.9rem"},role:"cell",children:t.jsx("span",{children:Dl(n,e)})}),t.jsx("span",{className:"cp-order-cell","data-label":"Leveringsadresse",style:{fontSize:"0.9rem"},role:"cell",children:t.jsx("span",{children:n.deliveryAddress})}),t.jsx("span",{className:"cp-order-cell","data-label":"Notater",style:{fontSize:"0.9rem"},role:"cell",children:t.jsx("span",{children:n.notes||"â"})}),t.jsx("span",{className:"cp-order-cell cp-order-cell--actions","data-label":"Handling",role:"cell",children:t.jsx("button",{type:"button",className:"ui-button ui-button--secondary cp-btn-outline cp-btn-small cp-repeat-order-button",onClick:()=>ci(n),children:"Gjenta bestilling"})})]},n.id))]})]}),y==="new-order"&&t.jsxs("div",{className:"cp-card",children:[t.jsx("h2",{children:ki}),t.jsx("p",{style:{marginBottom:"1rem",color:"var(--text-secondary)"},children:ji}),t.jsxs("form",{ref:Er,onSubmit:hi,className:"cp-order-form",children:[t.jsxs("section",{className:"cp-order-section","aria-labelledby":"
4customer-info-heading",children:[t.jsx("h3",{id:"customer-info-heading",children:"Kundeinformasjon"}),t.jsxs("div",{className:"cp-order-fields",children:[t.jsxs("div",{className:"cp-order-field",children:[t.jsx("label",{htmlFor:"order-firmanavn",children:"Firmanavn / Kundenavn"}),t.jsx("input",{id:"order-firmanavn",type:"text",value:v.firmanavnKundenavn,onChange:n=>{te(null),D(s=>({...s,firmanavnKundenavn:n.target.value}))},placeholder:"Firma eller navn"})]}),t.jsxs("div",{className:"cp-order-field",children:[t.jsx("label",{htmlFor:"order-kontaktperson",children:"Kontaktperson"}),t.jsx("input",{id:"order-kontaktperson",type:"text",value:v.kontaktperson,onChange:n=>D(s=>({...s,kontaktperson:n.target.value})),placeholder:"Navn"})]}),t.jsxs("div",{className:"cp-order-field",children:[t.jsx("label",{htmlFor:"order-telefon",children:"Telefon"}),t.jsx("input",{id:"order-telefon",type:"text",value:v.telefon,onChange:n=>D(s=>({...s,telefon:n.target.value})),placeholder:"+47 â¦"})]}),t.jsxs("div",{className:"cp-order-field",children:[t.jsx("label",{htmlFor:"order-epost",children:"E-post"}),t.jsx("input",{id:"order-epost",type:"email",value:v.epost,onChange:n=>D(s=>({...s,epost:n.target.value})),placeholder:"[email protected]"})]}),t.jsxs("div",{className:"cp-order-field cp-address-autocomplete",children:[t.jsx("label",{htmlFor:"order-leveringsadresse",children:"Leveringsadresse"}),t.jsxs("div",{className:"cp-address-combobox",children:[t.jsx("input",{ref:In,id:"order-leveringsadresse",className:Ye?"cp-address-input--open":void 0,type:"text",value:v.leveringsadresse,onChange:n=>ui(n.target.value),onFocus:mi,onBlur:pi,onKeyDown:gi,placeholder:"Gateadresse",role:"combobox","aria-autocomplete":"list","aria-expanded":Ye,"aria-controls":br,"aria-activedescendant":oi,"aria-describedby":"order-address-status"}),Ye&&ae.length>0&&t.jsx("div",{id:br,className:"cp-address-suggestions",role:"listbox",children:ae.map((n,s)=>t.jsxs("button",{id:oa(s),type:"button",className:`cp-address-suggestion${s===Te?" active":""}`,onMouseDown:l=>l.preventDefault(),onClick:()=>gs(n),role:"option","aria-selected":s===Te,children:[t.jsx("span",{children:Nr(n)||n.displayText}),t.jsx("small",{children:po(n)})]},n.id))})]}),t.jsx("p",{id:"order-address-status",className:"cp-address-status",role:"status","aria-live":"polite",children:re?e("officialAddressSelected"):kn==="loading"?e("addressSearchLoading"):kn==="error"?e("addressSuggestionsUnavailable"):kn==="success"&&Oe.length>=3&&ae.length===0?e("addressSuggestionNoMatch"):""}),t.jsxs("label",{className:"cp-address-remember",children:[t.jsx("input",{type:"checkbox",checked:xn,onChange:n=>jn(n.target.checked)}),t.jsx("span",{children:"Husk leveringsadressen til neste gang"})]})]}),t.jsxs("div",{className:"cp-order-field cp-order-field--short",children:[t.jsx("label",{htmlFor:"order-postnummer",children:"Postnummer"}),t.jsx("input",{id:"order-postnummer",type:"text",value:v.postnummer,onChange:n=>{ie(null),te(null),D(s=>({...s,postnummer:n.target.value}))},placeholder:"0000"})]}),t.jsxs("div",{className:"cp-order-field",children:[t.jsx("label",{htmlFor:"order-sted",children:"Sted"}),t.jsx("input",{id:"order-sted",type:"text",value:v.sted,onChange:n=>{ie(null),te(null),D(s=>({...s,sted:n.target.value}))},placeholder:"Poststed"})]}),t.jsx("div",{className:"cp-order-field cp-order-field--full",children:Ci("Leveringsorganisasjon")}),t.jsxs("div",{className:"cp-order-field cp-order-field--full",children:[t.jsx("label",{htmlFor:"order-kommentar",children:"Kommentar"}),t.jsx("textarea",{id:"order-kommentar",rows:3,value:v.kommentar,onChange:n=>D(s=>({...s,kommentar:n.target.value})),placeholder:"Valgfri kommentar til bestillingen"})]})]})]}),Ns.length>1&&t.jsxs("section",{className:"cp-order-section","aria-labelledby":"order-type-heading",children:[t.jsx("h3",{id:"order-type-heading",children:"Valg av bestillingstype"}),t.jsx("div",{className:"cp-order-type-radios",role:"radiogroup","aria-label":"Bestillingstype",children:Ns.map(({value:n,label:s})=>t.jsxs("label",{className:"cp-order-type-radio",children:[t.jsx("input",{type:"radio",name:"orderType",value:n,checked:v.orderType===n,onChange:()=>D(l=>({...l,orderType:n}))}),t.jsx("span",{children:s})]},n))})]}),t.jsxs("section",{className:"cp-order-section","aria-labelledby":"requested-delivery-date-heading",children:[t.jsx("h3",{id:"requested-delivery-date-heading",children:e("requestedDeliveryDate","Ãnsket leveringsdato")}),t.jsx("div",{className:"cp-order-fields",children:t.jsxs("div",{className:"cp-order-field",children:[t.jsx("label",{htmlFor:"order-leveringsdato",children:e("requestedDeliveryDate","Ãnsket leveringsdato")}),t.jsx("input",{id:"order-leveringsdato",type:"date",value:v.bulk.onsketLeveringsdato,min:Yi(),onChange:n=>D(s=>({...s,bulk:{...s.bulk,onsketLeveringsdato:n.target.value}})),required:!0,"aria-describedby":"order-leveringsdato-help"}),t.jsx("small",{id:"order-leveringsdato-help",children:e("requestedDeliveryDateHelp","Datoen gjelder lokal kalenderdag i Norge.")})]})})]}),v.orderType==="BOTTLE"&&t.jsxs("section",{className:"cp-order-section","aria-labelledby":"fylling-heading",children:[t.jsx("h3",{id:"fylling-heading",children:"Fylling propan (flaske)"}),t.jsx("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Velg antall for hver type. Bruk 0 for Ã¥ ikke bestille."}),t.jsx("div",{className:"cp-order-product-rows",children:pn.map(({key:n,label:s})=>t.jsxs("div",{className:"cp-order-product-row",children:[t.jsx("label",{htmlFor:`order-fill-${n}`,children:s}),t.jsx(Ws,{id:`order-fill-${n}`,label:s,value:v.fylling[n]??0,onChange:l=>D(u=>({...u,fylling:{...u.fylling,[n]:l}}))}),t.jsx("span",{className:"cp-order-unit",children:"Stk"})]},n))})]}),v.orderType==="BOTTLE"&&t.jsxs("section",{className:"cp-order-section","aria-labelledby":"ny-flaske-heading",children:[t.jsx("h3",{id:"ny-flaske-heading",children:"Ny propanflaske"}),t.jsx("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Velg antall for hver type. Bruk 0 for Ã¥ ikke bestille."}),t.jsx("div",{className:"cp-order-product-rows",children:fn.map(({key:n,label:s})=>t.jsxs("div",{className:"cp-order-product-row",children:[t.jsx("label",{htmlFor:`order-ny-${n}`,children:s}),t.jsx(Ws,{id:`order-ny-${n}`,label:s,value:v.nyFlaske[n]??0,onChange:l=>D(u=>({...u,nyFlaske:{...u.nyFlaske,[n]:l}}))}),t.jsx("span",{className:"cp-order-unit",children:"Stk"})]},n))})]}),v.orderType==="BULK_LPG"&&t.jsxs("section",{className:"cp-order-section","aria-labelledby":"bulk-heading",children:[t.jsx("h3",{id:"bulk-heading",children:"Bulk LPG / tank"}),t.jsx("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem",color:"var(--text-secondary)"},children:"Bestillingen sendes til din faste leveringsorganisasjon."}),t.jsxs("div",{className:"cp-order-fields",children:[t.jsxs("div",{className:"cp-order-field",children:[t.jsx("label",{htmlFor:"order-tanknummer",children:"Tanknummer / referanse"}),t.jsx("input",{id:"order-tanknummer",type:"text",value:v.bulk.tanknummerReferanse,onChange:n=>D(s=>({...s,bulk:{...s.bulk,tanknummerReferanse:n.target.value}})),placeholder:"Tank-ID eller referanse"})]}),t.jsxs("div",{className:"cp-order-field",children:[t.jsx("label",{htmlFor:"order-volum",children:"Ãnsket volum / mengde"}),t.jsx("input",{id:"order-volum",type:"text",value:v.bulk.onsketVolum,onChange:n=>D(s=>({...s,bulk:{...s.bulk,onsketVolum:n.target.value}})),placeholder:"F.eks. liter eller kg"})]})]})]}),t.jsxs("div",{className:"cp-order-actions",children:[t.jsx("button",{type:"submit",className:"ui-button ui-button--primary cp-btn-orange",disabled:Nn||!at,children:Nn?"Sender...":"Send bestilling"}),t.jsx("button",{type:"button",className:"ui-button ui-button--secondary cp-btn-outline",onClick:()=>m("/portal/bestillinger"),children:"Avbryt"})]})]})]})]}),y==="org-credit"&&Je&&t.jsxs("div",{className:"cp-card cp-credit-card",children:[t.jsxs("div",{className:"cp-card-header-row",children:[t.jsxs("div",{children:[t.jsx("div",{className:"cp-card-badge",children:"Kreditt"}),t.jsx("h2",{children:"Søk om kreditt"})]}),t.jsx("button",{type:"button",className:"ui-button ui-button--secondary cp-btn-outline",onClick:Jt,disabled:En,children:En?"Laster...":"Oppdater"})]}),Ft.text&&t.jsx("div",{className:`cp-credit-message ${Ft.isError?"is-error":""}`,role:Ft.isError?"alert":"status",children:Ft.text}),t.jsxs("form",{onSubmit:yi,className:"cp-credit-form",children:[t.jsxs("label",{children:["Stasjon",t.jsxs("select",{required:!0,value:L.stationId,onChange:n=>de(s=>({...s,stationId:n.target.value})),children:[t.jsx("option",{value:"",children:"Velg stasjon"}),Qn.map(n=>{const s=xr(n);return t.jsx("option",{value:s,children:bl(n)},s)})]})]}),t.jsxs("div",{className:"cp-credit-kind-group",role:"radiogroup","aria-label":"Kredittype",children:[t.jsxs("label",{children:[t.jsx("input",{type:"radio",name:"customer-credit-kind",value:"private",checked:L.creditKind==="private",onCh
4ange:()=>de(n=>({...n,creditKind:"private"}))}),"Privat kreditt"]}),t.jsxs("label",{children:[t.jsx("input",{type:"radio",name:"customer-credit-kind",value:"company",checked:L.creditKind==="company",onChange:()=>de(n=>({...n,creditKind:"company"}))}),"Firmakreditt"]})]}),L.creditKind==="company"&&t.jsxs("div",{className:"cp-credit-company-fields",children:[t.jsxs("label",{children:["Firmanavn",t.jsx("input",{required:!0,value:L.companyName,onChange:n=>de(s=>({...s,companyName:n.target.value})),autoComplete:"organization"})]}),t.jsxs("label",{children:["Organisasjonsnummer",t.jsx("input",{required:!0,value:L.organizationNumber,onChange:n=>de(s=>({...s,organizationNumber:n.target.value})),inputMode:"numeric",autoComplete:"off"})]})]}),t.jsxs("label",{children:["Ãnsket kredittgrense (kr)",t.jsx("input",{type:"number",min:"1",step:"0.01",required:!0,value:L.requestedAmountKr,onChange:n=>de(s=>({...s,requestedAmountKr:n.target.value})),placeholder:"50000"})]}),t.jsxs("label",{children:["Notat",t.jsx("textarea",{value:L.requestNote,onChange:n=>de(s=>({...s,requestNote:n.target.value})),rows:3})]}),t.jsxs("div",{className:"cp-credit-actions",children:[t.jsx("button",{type:"submit",className:"ui-button ui-button--primary cp-btn-orange",disabled:Vr||Qn.length===0,children:Vr?"Sender...":"Send forespørsel"}),t.jsx("button",{type:"button",className:"ui-button ui-button--secondary cp-btn-outline",onClick:()=>m("/portal/dispenser"),children:"Avbryt"})]}),Qn.length===0&&t.jsx("p",{className:"cp-credit-empty",children:"Ingen aktive stasjoner tilgjengelig for kredittforespørsel."})]}),t.jsx("h3",{children:"Mine kredittlinjer"}),En?t.jsx("p",{children:"Laster kredittlinjer..."}):Ot.length===0?t.jsx("p",{children:"Ingen kredittforespørsler enda."}):t.jsx("div",{className:"cp-credit-list",children:Ot.map(n=>{const s=String(n.status??"").toLowerCase();return t.jsxs("div",{className:"cp-credit-row",children:[t.jsxs("div",{children:[t.jsx("strong",{children:n.companyName||fr(n)}),t.jsx("span",{children:fr(n)}),t.jsx("span",{children:Vs(n)||"-"})]}),t.jsxs("div",{children:[t.jsxs("span",{children:["Forespurt: ",Me(so(n))]}),s==="approved"&&t.jsxs(t.Fragment,{children:[t.jsxs("span",{children:["Godkjent: ",Me(ao(n))]}),t.jsxs("span",{children:["GjenstÃ¥r: ",Me(cr(n))]})]})]}),t.jsxs("div",{children:[t.jsx("span",{children:Ke(n.requestedAtUtc??n.requestedAt)}),t.jsx("span",{className:`cp-credit-status cp-credit-status--${s||"unknown"}`,children:jl(n.status)})]})]},n.id)})})]}),y==="org-employees"&&Oa&&t.jsxs("div",{className:"cp-card",children:[t.jsx("h2",{children:"Behandle ansatte"}),t.jsx("p",{children:"Ansatte som har registrert seg og venter pÃ¥ godkjenning for Ã¥ bli med i organisasjonen og fÃ¥ tilgang til kreditt."}),t.jsx("p",{style:{marginTop:"1rem"},children:"Ansattgodkjenning er midlertidig utilgjengelig mens ny MinLPG API-støtte implementeres."}),t.jsx("button",{className:"ui-button ui-button--secondary cp-btn-outline",style:{marginTop:"1.5rem"},onClick:()=>m("/portal/dispenser"),children:"â Tilbake"})]})]}),a&&ln.createPortal(t.jsxs("nav",{className:"cp-bottom-nav","aria-label":e("customerPortal"),children:[Ze&&t.jsxs("button",{type:"button",className:`cp-bottom-nav__item ${Fe?"active":""}`,onClick:()=>m("/portal/dispenser"),"aria-current":Fe?"page":void 0,"aria-label":e("sectionDispenser"),children:[t.jsx(T,{name:"local_gas_station"}),t.jsx("span",{children:e("sectionDispenser")})]}),Br&&t.jsxs("button",{type:"button",className:`cp-bottom-nav__item ${nn?"active":""}`,onClick:()=>m("/portal/kvitteringer"),"aria-current":nn?"page":void 0,"aria-label":e("sectionReceipts"),children:[t.jsx(T,{name:"receipt"}),t.jsx("span",{children:e("sectionReceipts")})]}),ce&&t.jsxs("button",{type:"button",className:`cp-bottom-nav__item ${y==="klippekort"?"active":""}`,onClick:()=>m("/portal/klippekort"),"aria-current":y==="klippekort"?"page":void 0,"aria-label":e("sectionKlippekort"),children:[t.jsx(T,{name:"loyalty"}),t.jsx("span",{children:e("sectionKlippekort")})]}),_n&&t.jsxs("button",{type:"button",className:`cp-bottom-nav__item ${rn?"active":""}`,onClick:()=>m("/portal/prosjektkupong"),"aria-current":rn?"page":void 0,"aria-label":"Prosjektkupong",children:[t.jsx(T,{name:"confirmation_number"}),t.jsx("span",{children:"Prosjektkupong"})]}),t.jsxs("button",{type:"button",className:`cp-bottom-nav__item ${sn?"active":""}`,onClick:()=>m("/portal/bestillinger"),"aria-current":sn?"page":void 0,"aria-label":e("sectionOrders"),children:[t.jsx(T,{name:"inventory_2"}),t.jsx("span",{children:e("sectionOrders")})]}),Je&&t.jsxs("button",{type:"button",className:`cp-bottom-nav__item ${an?"active":""}`,onClick:()=>m("/portal/kreditt"),"aria-current":an?"page":void 0,"aria-label":"Kreditt",children:[t.jsx(T,{name:"business"}),t.jsx("span",{children:"Kreditt"})]}),$r&&t.jsxs("button",{type:"button",className:"cp-bottom-nav__item",onClick:()=>m("/projects"),"aria-label":"Prosjekter",children:[t.jsx(T,{name:"folder_managed"}),t.jsx("span",{children:"Prosjekter"})]})]}),document.body),fe&&ln.createPortal(t.jsx("div",{className:"cp-dispenser-modal-overlay",role:"presentation",onClick:()=>{we(null),window.setTimeout(()=>{var n,s;return(s=(n=Ct.current)==null?void 0:n.focus)==null?void 0:s.call(n)},0)},children:t.jsxs("section",{className:"cp-dispenser-modal",role:"dialog","aria-modal":"true","aria-labelledby":"address-mismatch-review-title",onClick:n=>n.stopPropagation(),onKeyDown:n=>{if(n.key==="Escape"&&(n.preventDefault(),we(null),window.setTimeout(()=>{var s,l;return(l=(s=Ct.current)==null?void 0:s.focus)==null?void 0:l.call(s)},0)),n.key==="Tab"){n.preventDefault();const s=document.activeElement===It.current?Ar.current:It.current;s==null||s.focus()}},children:[t.jsx("h2",{id:"address-mismatch-review-title",children:e("companyAddressReviewTitle")}),t.jsx("p",{children:e("companyAddressReviewBody")}),fe.placeSummary&&t.jsxs("p",{children:[t.jsx("strong",{children:e("companyAddressReviewFound")})," ",fe.placeSummary]}),t.jsx("p",{children:e("companyAddressReviewAlternative")}
4),t.jsxs("div",{className:"modal-buttons",children:[t.jsx("button",{ref:It,type:"button",className:"ui-button ui-button--secondary",onClick:()=>{we(null),window.setTimeout(()=>{var n,s;return(s=(n=Ct.current)==null?void 0:n.focus)==null?void 0:s.call(n)},0)},children:e("companyAddressReviewBack")}),t.jsx("button",{ref:Ar,type:"button",className:"ui-button ui-button--primary",onClick:()=>{te(fe.context),Cn(fe.challenge),we(null),window.setTimeout(()=>{var n;return(n=Er.current)==null?void 0:n.requestSubmit()},0)},children:e("companyAddressReviewConfirm")})]})]})}),document.body),tr&&ln.createPortal(t.jsx("div",{className:"cp-dispenser-modal-overlay",onClick:st,children:t.jsx("div",{className:"cp-dispenser-modal",role:"dialog","aria-modal":"true","aria-labelledby":"customer-dispenser-modal-title",onClick:n=>n.stopPropagation(),children:t.jsxs("div",{className:"cp-dispenser-active",children:[t.jsx("div",{id:"customer-dispenser-modal-title",className:"cp-dispenser-active-header",children:e("terminalActivated")}),t.jsx("div",{className:"cp-dispenser-divider"}),t.jsx("div",{className:"cp-dispenser-spinner-container",children:t.jsx("div",{className:"cp-dispenser-spinner"})}),t.jsx("p",{className:"cp-dispenser-ready-text",children:e(ls?"tapCardPrompt":Zt?"pumpingInProgress":"dispenserReady")}),t.jsx("p",{className:"cp-dispenser-instruction",children:e(ls?"tapCardInstruction":Zt?"dispensingInstruction":"holdStartInstruction")}),ut!=null&&!Zt&&t.jsxs("p",{className:"cp-dispenser-countdown",children:[e("validFor")," ",ai(ut)]}),t.jsx("button",{ref:Ir,className:"cp-dispenser-close-btn",onClick:st,children:e("close")})]})})}),document.body),Cr&&ln.createPortal(t.jsx("div",{className:"cp-dispenser-modal-overlay",onClick:()=>bn(null),children:t.jsxs("div",{className:"cp-receipt-text-modal",role:"dialog","aria-modal":"true","aria-labelledby":"customer-receipt-text-title",onClick:n=>n.stopPropagation(),children:[t.jsx("div",{className:"cp-card-badge",id:"customer-receipt-text-title",children:e("receipt")}),t.jsx("pre",{children:Cr}),t.jsx("button",{type:"button",className:"cp-dispenser-close-btn",onClick:()=>bn(null),children:e("close")})]})}),document.body),ne&&t.jsx(Hi,{url:ne.url,blob:ne.blob,base64:ne.base64,filename:ne.filename,onClose:Ni})]})}export{Jl as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.