/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@com.xcodeclazz/bridge@0.0.3/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
const BridgeUtils={extend:function(e,t){var n,i=t||{};for(n in e)e.hasOwnProperty(n)&&(i[n]=e[n]);return i}},bridgeLocalStorage=function(){var e,t={},n=-1,i=!1,a=!0,o={iframeId:"cross-domain-iframe",iframeUrl:void 0,initCallback:function(){}};function r(e){var n;try{n=JSON.parse(e.data)}catch(e){}n&&("iframe-ready"===n.id?(a=!0,o.initCallback()):t[n.id]&&(t[n.id](n),delete t[n.id]))}function c(i,a,o,r){n++,t[n]=r;var c={id:n,action:i,key:a,value:o};e.contentWindow.postMessage(JSON.stringify(c),"*")}function l(t){o=BridgeUtils.extend(t,o);var n=document.createElement("div");window.addEventListener?window.addEventListener("message",r,!1):window.attachEvent("onmessage",r),n.innerHTML='<iframe id="'+o.iframeId+'" src="'+o.iframeUrl+'" style="display: none;"></iframe>',document.body.appendChild(n),e=document.getElementById(o.iframeId)}function d(){return"complete"===document.readyState}function s(){return i?!!a||(console.log("You must wait for iframe ready message before using the api."),!1):(console.log("You must call bridgeLocalStorage.init() before using it."),!1)}return{init:function(e){if(!e.iframeUrl)throw"You must specify iframeUrl";i?console.log("bridgeLocalStorage was already initialized!"):(i=!0,d()?l(e):document.addEventListener?document.addEventListener("readystatechange",(function(){d()&&l(e)})):document.attachEvent("readystatechange",(function(){d()&&l(e)})))},setItem:function(e,t,n){s()&&c("set",e,t,n)},getItem:function(e,t){s()&&c("get",e,null,t)},removeItem:function(e,t){s()&&c("remove",e,null,t)},key:function(e,t){s()&&c("key",e,null,t)},getSize:function(e){s()&&c("size",null,null,e)},getLength:function(e){s()&&c("length",null,null,e)},clear:function(e){s()&&c("clear",null,null,e)},wasInit:function(){return i}}}();!function(){var e={};function t(t,n){var i=BridgeUtils.extend({...n,id:t},e);parent.postMessage(JSON.stringify(i),"*")}function n(e){var n,i,a,o;try{n=JSON.parse(e.data)}catch{}n&&("set"===n.action?(i=n.id,a=n.key,o=n.value,localStorage.setItem(a,o),t(i,{success:localStorage.getItem(a)===o})):"get"===n.action?function(e,n){t(e,{key:n,value:localStorage.getItem(n)})}(n.id,n.key):"remove"===n.action?function(e,n){localStorage.removeItem(n),t(e,{})}(n.id,n.key):"key"===n.action?function(e,n){t(e,{key:localStorage.key(n)})}(n.id,n.key):"size"===n.action?function(e){t(e,{size:JSON.stringify(localStorage).length})}(n.id):"length"===n.action?function(e){t(e,{length:localStorage.length})}(n.id):"clear"===n.action&&function(e){localStorage.clear(),t(e,{})}(n.id))}window.addEventListener?window.addEventListener("message",n,!1):window.attachEvent("onmessage",n),parent.postMessage(JSON.stringify({id:"iframe-ready"}),"*")}();
//# sourceMappingURL=/sm/349db8d0e688c0c17534b975cb4216ac2743fc80bb328d7b89e557ed370fd4eb.map