1(function(g,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(g=typeof globalThis<"u"?globalThis:g||self,O(g["payment-widget"]={}))})(this,function(g){"use strict";function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var R={exports:{}};R.exports=D,R.exports.isMobile=D,R.exports.default=D;const ue=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,pe=/CrOS/,he=/android|ipad|playbook|silk/i;function D(e){e||(e={});let t=e.ua;if(!t&&typeof navigator<"u"&&(t=navigator.userAgent),t&&t.headers&&typeof t.headers["user-agent"]=="string"&&(t=t.headers["user-agent"]),typeof t!="string")return!1;let n=ue.test(t)&&!pe.test(t)||!!e.tablet&&he.test(t);return!n&&e.tablet&&e.featureDetect&&navigator&&navigator.maxTouchPoints>1&&t.indexOf("Macintosh")!==-1&&t.indexOf("Safari")!==-1&&(n=!0),n}var me=R.exports;const U=O(me),j={SUCCESS:"success",FAIL:"fail"},C={SUCCESS:{type:j.SUCCESS},FAIL:{type:j.FAIL}},ge=()=>({initiator:e=>{const t=new MessageChannel;return parent.postMessage("Send port to target",e,[t.port2]),n=>new Promise(o=>{t.port1.postMessage(n),t.port1.onmessage=({data:s})=>{typeof n=="object"&&n!==null&&"type"in n&&(s==null?void 0:s.type)===n.type&&o(s==null?void 0:s.payload)}})},target:async e=>new Promise(t=>{const n=o=>{if(o.ports.length){const s=o.ports[0];s.onmessage=i=>{e(i,s)},t({port:s,cleanup:()=>window.removeEventListener("message",n)})}};window.addEventListener("message",n)})}),ye=ge();function T(){}function H(e){return e()}function q(){return Object.create(null)}function M(e){e.forEach(H)}function K(e){return typeof e=="function"}function be(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}let P;function J(e,t){return P||(P=document.createElement("a")),P.href=t,e===P.href}function _e(e){return Object.keys(e).length===0}function z(e,t){e.appendChild(t)}function we(e,t,n){const o=Ee(e);if(!o.getElementById(t)){const s=N("style");s.id=t,s.textContent=n,Ie(o,s)}}function Ee(e){if(!e)return document;const t=e.getRootNode?e.getRootNode():e.ownerDocument;return t&&t.host?t:e.ownerDocument}function Ie(e,t){return z(e.head||e,t),t.sheet}function Q(e,t,n){e.insertBefore(t,n||null)}function v(e){e.parentNode&&e.parentNode.removeChild(e)}function N(e){return document.createElement(e)}function Se(e){return document.createTextNode(e)}function Oe(){return Se("")}function p(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function Te(e){return Array.from(e.childNodes)}function X(e,t,n){e.classList[n?"add":"remove"](t)}let A;function k(e){A=e}const _=[],Y=[];let w=[];const Z=[],ke=Promise.resolve();let B=!1;function Re(){B||(B=!0,ke.then(I))}function L(e){w.push(e)}const F=new Set;let E=0;function I(){if(E!==0)return;const e=A;do{try{for(;E<_.length;){const t=_[E];E++,k(t),Ce(t.$$)}}catch(t){throw _.length=0,E=0,t}for(k(null),_.length=0,E=0;Y.length;)Y.pop()();for(let t=0;t<w.length;t+=1){const n=w[t];F.has(n)||(F.add(n),n())}w.length=0}while(_.length);for(;Z.length;)Z.pop()();B=!1,F.clear(),k(e)}function Ce(e){if(e.fragment!==null){e.update(),M(e.before_update);const t=e.dirty;e.dirty=[-1],e.fragment&&e.fragment.p(e.ctx,t),e.after_update.forEach(L)}}function Me(e){const t=[],n=[];w.forEach(o=>e.indexOf(o)===-1?t.push(o):n.push(o)),n.forEach(o=>o()),w=t}const Pe=new Set;function $e(e,t){e&&e.i&&(Pe.delete(e),e.i(t))}function xe(e,t,n,o){const{fragment:s,after_update:i}=e.$$;s&&s.m(t,n),o||L(()=>{const l=e.$$.on_mount.map(H).filter(K);e.$$.on_destroy?e.$$.on_destroy.push(...l):M(l),e.$$.on_mount=[]}),i.forEach(L)}function De(e,t){const n=e.$$;n.fragment!==null&&(Me(n.after_update),M(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}function Ue(e,t){e.$$.dirty[0]===-1&&(_.push(e),Re(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<<t%31}function ve(e,t,n,o,s,i,l,a=[-1]){const f=A;k(e);
1const r=e.$$={fragment:null,ctx:[],props:i,update:T,not_equal:s,bound:q(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(t.context||(f?f.$$.context:[])),callbacks:q(),dirty:a,skip_bound:!1,root:t.target||f.$$.root};l&&l(r.root);let h=!1;if(r.ctx=n?n(e,t.props||{},(c,u,...m)=>{const b=m.length?m[0]:u;return r.ctx&&s(r.ctx[c],r.ctx[c]=b)&&(!r.skip_bound&&r.bound[c]&&r.bound[c](b),h&&Ue(e,c)),u}):[],r.update(),h=!0,M(r.before_update),r.fragment=o?o(r.ctx):!1,t.target){if(t.hydrate){const c=Te(t.target);r.fragment&&r.fragment.l(c),c.forEach(v)}else r.fragment&&r.fragment.c();t.intro&&$e(e.$$.fragment),xe(e,t.target,t.anchor,t.customElement),I()}k(f)}class Ne{$destroy(){De(this,1),this.$destroy=T}$on(t,n){if(!K(n))return T;const o=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return o.push(n),()=>{const s=o.indexOf(n);s!==-1&&o.splice(s,1)}}$set(t){this.$$set&&!_e(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function Ae(e){we(e,"svelte-1s6dmb5",".root.svelte-1s6dmb5{position:fixed;z-index:1000;left:0;top:0;width:100%;height:100%;background-color:transparent}.not-visible.svelte-1s6dmb5{visibility:hidden}")}function ee(e){let t,n,o;return{c(){t=N("div"),n=N("iframe"),p(n,"id",e[3]),p(n,"sandbox","allow-same-origin allow-scripts allow-popups allow-forms allow-modals allow-popups-to-escape-sandbox allow-storage-access-by-user-activation"),p(n,"allowtransparency",!0),p(n,"title",Le),p(n,"width","100%"),p(n,"height","100%"),J(n.src,o=e[0])||p(n,"src",o),p(n,"frameborder","no"),p(t,"class","root svelte-1s6dmb5"),X(t,"not-visible",!e[2])},m(s,i){Q(s,t,i),z(t,n)},p(s,i){i&8&&p(n,"id",s[3]),i&1&&!J(n.src,o=s[0])&&p(n,"src",o),i&4&&X(t,"not-visible",!s[2])},d(s){s&&v(t)}}}function Be(e){let t,n=e[1]&&ee(e);return{c(){n&&n.c(),t=Oe()},m(o,s){n&&n.m(o,s),Q(o,t,s)},p(o,[s]){o[1]?n?n.p(o,s):(n=ee(o),n.c(),n.m(t.parentNode,t)):n&&(n.d(1),n=null)},i:T,o:T,d(o){n&&n.d(o),o&&v(t)}}}let Le="web widget";function Fe(e,t,n){let{url:o}=t,{isOpen:s}=t,{isVisible:i=!1}=t,{iframeId:l}=t;return e.$$set=a=>{"url"in a&&n(0,o=a.url),"isOpen"in a&&n(1,s=a.isOpen),"isVisible"in a&&n(2,i=a.isVisible),"iframeId"in a&&n(3,l=a.iframeId)},[o,s,i,l]}class te extends Ne{constructor(t){super(),ve(this,t,Fe,Be,be,{url:0,isOpen:1,isVisible:2,iframeId:3},Ae)}get url(){return this.$$.ctx[0]}set url(t){this.$$set({url:t}),I()}get isOpen(){return this.$$.ctx[1]}set isOpen(t){this.$$set({isOpen:t}),I()}get isVisible(){return this.$$.ctx[2]}set isVisible(t){this.$$set({isVisible:t}),I()}get iframeId(){return this.$$.ctx[3]}set iframeId(t){this.$$set({iframeId:t}),I()}}const ne=(e,t,n)=>{const o=new URL(e);return o.searchParams.set("state",n),o.searchParams.set("bankInvoiceId",t),o},Ve=e=>e.backUrl?ne(e.backUrl,e.orderId,"success"):e.successUrl,Ge=e=>e.backUrl?ne(e.backUrl,e.orderId,"return"):e.failUrl,We=(e,t,{closeModal:n,resolve:o,params:s,onAppInitialize:i,internalParams:l})=>{var a,f,r,h,c,u,m,b;if(((a=e.data)==null?void 0:a.type)===C.SUCCESS.type&&(n(),o(C.SUCCESS.type),window.location.replace(Ve(s))),((f=e.data)==null?void 0:f.type)===C.FAIL.type&&(n(),o(C.FAIL.type),window.location.replace(Ge(s))),((r=e.data)==null?void 0:r.type)==="CLOSE_WIDGET"&&(n(),document.body.style.overflow="",document.body.style.position="",o("closed")),((h=e.data)==null?void 0:h.type)==="GET_PARAMETERS"&&(i==null||i(),t.postMessage({type:"GET_PARAMETERS",payload:s})),((c=e.data)==null?void 0:c.type)==="GET_VERSION"&&t.postMessage({type:"GET_VERSION",payload:VERSION}),((u=e.data)==null?void 0:u.type)==="OPEN_LINK"&&((m=e.data)!=null&&m.payload)&&window.location.assign(e.data.payload),((b=e.data)==null?void 0:b.type)==="GET_ORDERID"){const d=l.get("orderId");if(!d)return;t.postMessage({type:"GET_ORDERID",payload:d})}},je=2e4,oe={localhostHttps:"https://localhost:3000",localhost:"http://localhost:3000",IFT:"https://ift.safepayonline.ru",UAT:"https://psi.safepayonline.ru",PRODUCTION:"https://safepayonline.ru"},se={localhostHttps:"https://localhost:3000",localhost:"http://localhost:3000",IFT:"https://ift.platiecom.ru",UAT:"https://psi.platiecom.ru",PRODUCTION:"https://platiecom.ru"}
1,He="width=450,height=500,top=200,left=200",V=(e,t=!1)=>t?oe[e]||oe.PRODUCTION:se[e]||se.PRODUCTION,re=(e,t,n)=>{const o=new URL(e);return U()||o.searchParams.append("platform","desktop"),t&&o.searchParams.append("orderId",t),n&&o.searchParams.append("params",n),o.toString()},ie=((e,t)=>!!e&&!(e.includes("Chrome")||e.includes("Chromium"))&&e.includes("Safari")&&!t)(navigator.userAgent,U()),ae=()=>({host:window.location.host,href:window.location.href}),qe=(e,t)=>{const n=setTimeout(()=>e("fail"),je);return()=>{clearTimeout(n),t()}},ce=()=>Math.random().toString(36).substring(2,15),le=()=>{const e=document.getElementById("payment-widget-container");if(!e){const t=document.createElement("div");return t.setAttribute("id","payment-widget-container"),document.body.appendChild(t),t}return e},Ke=(e,t,n)=>new te({target:e,props:{url:t,isOpen:!1,iframeId:n}}),Je=(e,t)=>{const n=new Map,o=ce(),s=le(),i=V(e,t),l=Ke(s,i,o),a=d=>l.$set({isOpen:d}),f=()=>l.$set({isVisible:!0}),r=()=>a(!1),h=()=>a(!0),c=d=>l.$set({url:d});let u=null;const m=d=>{var y;((y=d.data)==null?void 0:y.target)==="tab"&&(u==null||u.postMessage(d.data,"*"))},b=d=>{var y,$;if(((y=d.data)==null?void 0:y.target)==="iframe"){const S=document.getElementById(o);($=S==null?void 0:S.contentWindow)==null||$.window.postMessage(d.data,"*")}};return{open:d=>{const y={...d,orderId:d.bankInvoiceId,isSafariDesktop:ie};return new Promise(async($,S)=>{try{c(re(i,y.orderId)),ie&&(u=window.open(i+"/access-cookie","_blank",He)),h(),document.body.style.overflow="hidden",document.body.style.position="sticky",window.onmessage=x=>{b(x),m(x)};const{href:W,host:et}=ae(),tt={...y,href:W,host:et},nt=qe(S,f);ye.target((x,ot)=>We(x,ot,{closeModal:r,resolve:$,params:tt,onAppInitialize:nt,internalParams:n}))}catch(W){console.error(W),r(),S("fail")}})},setOrderId:d=>{n.set("orderId",d)},close:()=>{document.body.style.overflow="",document.body.style.position="",r()}}},ze=(e,t)=>{const n=V(e,t);return{open:o=>{const s={...o,orderId:o.bankInvoiceId};return new Promise(async(i,l)=>{try{const{href:a,host:f}=ae(),r={...s,href:a,host:f},h=btoa(JSON.stringify(r));window.location.assign(re(n,s.orderId,h))}catch{l("fail")}})}}},Qe=1e4,de=(e,t)=>new te({target:e,props:{iframeId:ce(),url:t,isOpen:!1}}),G={GET_SBERID_RESPONSE:"GET_SBERID_RESPONSE",SBERID_RESPONSE:"SBERID_RESPONSE",CLOSE_SBERID_TAB:"CLOSE_SBERID_TAB"},Xe=()=>setTimeout(()=>window.close(),Qe),Ye=e=>{const t=le(),n=V(e),o=de(t,`${n}/framed-sberid`),s=f=>o.$set({isOpen:f}),i=()=>o.$set({isVisible:!0}),l=()=>s(!1),a=()=>s(!0);return{open:f=>new Promise(async(r,h)=>{try{Xe(),window.addEventListener("message",c=>{var u,m;((u=c.data)==null?void 0:u.type)===G.GET_SBERID_RESPONSE&&c.source.postMessage({type:G.SBERID_RESPONSE,payload:f},c.origin),((m=c.data)==null?void 0:m.type)===G.CLOSE_SBERID_TAB&&window.close()}),a(),i()}catch(c){console.error(c),l(),h("fail")}})}},fe=(e,t)=>U()?ze(e,t):Je(e,t),Ze=(...e)=>fe(...e);g.createModal=de,g.createSberIdIFrame=Ye,g.createWidget=Ze,g.createWidgetInternal=fe,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
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.