52 lines
10 KiB
JavaScript
52 lines
10 KiB
JavaScript
import"./modulepreload-polyfill-B5Qt9EMX.js";import{i as z,a as J,b as Q}from"./lit-element-BUNo9pnf.js";import{t as X}from"./custom-element-BhZVzxrc.js";import{n as K}from"./property-MreHcJY-.js";/*! Capacitor: https://capacitorjs.com/ - MIT License */var L;(function(r){r.Unimplemented="UNIMPLEMENTED",r.Unavailable="UNAVAILABLE"})(L||(L={}));class S extends Error{constructor(e,t,o){super(e),this.message=e,this.code=t,this.data=o}}const Y=r=>{var e,t;return r!=null&&r.androidBridge?"android":!((t=(e=r==null?void 0:r.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||t===void 0)&&t.bridge?"ios":"web"},Z=r=>{const e=r.CapacitorCustomPlatform||null,t=r.Capacitor||{},o=t.Plugins=t.Plugins||{},n=()=>e!==null?e.name:Y(r),s=()=>n()!=="web",a=i=>{const c=b.get(i);return!!(c!=null&&c.platforms.has(n())||l(i))},l=i=>{var c;return(c=t.PluginHeaders)===null||c===void 0?void 0:c.find(C=>C.name===i)},u=i=>r.console.error(i),b=new Map,E=(i,c={})=>{const C=b.get(i);if(C)return console.warn(`Capacitor plugin "${i}" already registered. Cannot register plugins twice.`),C.proxy;const w=n(),y=l(i);let p;const M=async()=>(!p&&w in c?p=typeof c[w]=="function"?p=await c[w]():p=c[w]:e!==null&&!p&&"web"in c&&(p=typeof c.web=="function"?p=await c.web():p=c.web),p),G=(d,f)=>{var g,m;if(y){const v=y==null?void 0:y.methods.find(h=>f===h.name);if(v)return v.rtype==="promise"?h=>t.nativePromise(i,f.toString(),h):(h,k)=>t.nativeCallback(i,f.toString(),h,k);if(d)return(g=d[f])===null||g===void 0?void 0:g.bind(d)}else{if(d)return(m=d[f])===null||m===void 0?void 0:m.bind(d);throw new S(`"${i}" plugin is not implemented on ${w}`,L.Unimplemented)}},$=d=>{let f;const g=(...m)=>{const v=M().then(h=>{const k=G(h,d);if(k){const O=k(...m);return f=O==null?void 0:O.remove,O}else throw new S(`"${i}.${d}()" is not implemented on ${w}`,L.Unimplemented)});return d==="addListener"&&(v.remove=async()=>f()),v};return g.toString=()=>`${d.toString()}() { [capacitor code] }`,Object.defineProperty(g,"name",{value:d,writable:!1,configurable:!1}),g},B=$("addListener"),T=$("removeListener"),V=(d,f)=>{const g=B({eventName:d},f),m=async()=>{const h=await g;T({eventName:d,callbackId:h},f)},v=new Promise(h=>g.then(()=>h({remove:m})));return v.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await m()},v},A=new Proxy({},{get(d,f){switch(f){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return y?V:B;case"removeListener":return T;default:return $(f)}}});return o[i]=A,b.set(i,{name:i,proxy:A,platforms:new Set([...Object.keys(c),...y?[w]:[]])}),A};return t.convertFileSrc||(t.convertFileSrc=i=>i),t.getPlatform=n,t.handleError=u,t.isNativePlatform=s,t.isPluginAvailable=a,t.registerPlugin=E,t.Exception=S,t.DEBUG=!!t.DEBUG,t.isLoggingEnabled=!!t.isLoggingEnabled,t},N=r=>r.Capacitor=Z(r),U=N(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),x=U.registerPlugin;class j{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,t){let o=!1;this.listeners[e]||(this.listeners[e]=[],o=!0),this.listeners[e].push(t);const s=this.windowListeners[e];s&&!s.registered&&this.addWindowListener(s),o&&this.sendRetainedArgumentsForEvent(e);const a=async()=>this.removeListener(e,t);return Promise.resolve({remove:a})}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,t,o){const n=this.listeners[e];if(!n){if(o){let s=this.retainedEventArguments[e];s||(s=[]),s.push(t),this.retainedEventArguments[e]=s}return}n.forEach(s=>s(t))}hasListeners(e){var t;return!!(!((t=this.listeners[e])===null||t===void 0)&&t.length)}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:o=>{this.notifyListeners(t,o)}}}unimplemented(e="not implemented"){return new U.Exception(e,L.Unimplemented)}unavailable(e="not available"){return new U.Exception(e,L.Unavailable)}async removeListener(e,t){const o=this.listeners[e];if(!o)return;const n=o.indexOf(t);this.listeners[e].splice(n,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){const t=this.retainedEventArguments[e];t&&(delete this.retainedEventArguments[e],t.forEach(o=>{this.notifyListeners(e,o)}))}}const H=r=>encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),F=r=>r.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class ee extends j{async getCookies(){const e=document.cookie,t={};return e.split(";").forEach(o=>{if(o.length<=0)return;let[n,s]=o.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");n=F(n).trim(),s=F(s).trim(),t[n]=s}),t}async setCookie(e){try{const t=H(e.key),o=H(e.value),n=e.expires?`; expires=${e.expires.replace("expires=","")}`:"",s=(e.path||"/").replace("path=",""),a=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${t}=${o||""}${n}; path=${s}; ${a};`}catch(t){return Promise.reject(t)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(t){return Promise.reject(t)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const t of e)document.cookie=t.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}x("CapacitorCookies",{web:()=>new ee});const te=async r=>new Promise((e,t)=>{const o=new FileReader;o.onload=()=>{const n=o.result;e(n.indexOf(",")>=0?n.split(",")[1]:n)},o.onerror=n=>t(n),o.readAsDataURL(r)}),re=(r={})=>{const e=Object.keys(r);return Object.keys(r).map(n=>n.toLocaleLowerCase()).reduce((n,s,a)=>(n[s]=r[e[a]],n),{})},ne=(r,e=!0)=>r?Object.entries(r).reduce((o,n)=>{const[s,a]=n;let l,u;return Array.isArray(a)?(u="",a.forEach(b=>{l=e?encodeURIComponent(b):b,u+=`${s}=${l}&`}),u.slice(0,-1)):(l=e?encodeURIComponent(a):a,u=`${s}=${l}`),`${o}&${u}`},"").substr(1):null,se=(r,e={})=>{const t=Object.assign({method:r.method||"GET",headers:r.headers},e),n=re(r.headers)["content-type"]||"";if(typeof r.data=="string")t.body=r.data;else if(n.includes("application/x-www-form-urlencoded")){const s=new URLSearchParams;for(const[a,l]of Object.entries(r.data||{}))s.set(a,l);t.body=s.toString()}else if(n.includes("multipart/form-data")||r.data instanceof FormData){const s=new FormData;if(r.data instanceof FormData)r.data.forEach((l,u)=>{s.append(u,l)});else for(const l of Object.keys(r.data))s.append(l,r.data[l]);t.body=s;const a=new Headers(t.headers);a.delete("content-type"),t.headers=a}else(n.includes("application/json")||typeof r.data=="object")&&(t.body=JSON.stringify(r.data));return t};class oe extends j{async request(e){const t=se(e,e.webFetchExtra),o=ne(e.params,e.shouldEncodeUrlParams),n=o?`${e.url}?${o}`:e.url,s=await fetch(n,t),a=s.headers.get("content-type")||"";let{responseType:l="text"}=s.ok?e:{};a.includes("application/json")&&(l="json");let u,b;switch(l){case"arraybuffer":case"blob":b=await s.blob(),u=await te(b);break;case"json":u=await s.json();break;case"document":case"text":default:u=await s.text()}const E={};return s.headers.forEach((i,c)=>{E[c]=i}),{data:u,headers:E,status:s.status,url:s.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}x("CapacitorHttp",{web:()=>new oe});var R;(function(r){r.Dark="DARK",r.Light="LIGHT",r.Default="DEFAULT"})(R||(R={}));var W;(function(r){r.StatusBar="StatusBar",r.NavigationBar="NavigationBar"})(W||(W={}));class ae extends j{async setStyle(){this.unavailable("not available for web")}async setAnimation(){this.unavailable("not available for web")}async show(){this.unavailable("not available for web")}async hide(){this.unavailable("not available for web")}}x("SystemBars",{web:()=>new ae});var D;(function(r){r.Dark="DARK",r.Light="LIGHT",r.Default="DEFAULT"})(D||(D={}));var I;(function(r){r.None="NONE",r.Slide="SLIDE",r.Fade="FADE"})(I||(I={}));const q=x("StatusBar");var ie=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,_=(r,e,t,o)=>{for(var n=o>1?void 0:o?ce(e,t):e,s=r.length-1,a;s>=0;s--)(a=r[s])&&(n=(o?a(e,t,n):a(n))||n);return o&&n&&ie(e,t,n),n};let P=class extends J{constructor(){super(...arguments),this.name="World",this.count=0}render(){return Q`
|
|
<main>
|
|
<header><span class="title"> Hello, ${this.name}! </span></header>
|
|
<section>
|
|
<button @click=${this._onClick} part="button">
|
|
Click Count: ${this.count}
|
|
</button>
|
|
<slot></slot>
|
|
</section>
|
|
</main>
|
|
`}_onClick(){this.count++}foo(){return"foo"}firstUpdated(){q.setOverlaysWebView({overlay:!0}),(async()=>{await q.setStyle({style:D.Dark})})()}};P.styles=z`
|
|
main {
|
|
--bg-color: #f0f0f0;
|
|
--fg-color: #000;
|
|
--app-bar-color: navy;
|
|
--app-bar-on-color: white;
|
|
display: flex;
|
|
flex-direction: column;
|
|
width: 100%;
|
|
/* Settings for the notch */
|
|
background-color: var(--app-bar-color);
|
|
padding-top: var(--inset-top);
|
|
height: calc(100% - var(--inset-top));
|
|
}
|
|
header {
|
|
background-color: var(--app-bar-color);
|
|
color: var(--app-bar-on-color);
|
|
padding: 1rem;
|
|
padding-left: var(--inset-left);
|
|
padding-right: var(--inset-right);
|
|
}
|
|
.title {
|
|
padding-left: 1rem;
|
|
}
|
|
section {
|
|
background-color: var(--bg-color);
|
|
color: var(--fg-color);
|
|
flex: 1;
|
|
/* Settings for the notch */
|
|
padding-bottom: calc(var(--inset-bottom) + 1rem);
|
|
padding-left: calc(var(--inset-left) + 1rem);
|
|
padding-right: calc(var(--inset-right) + 1rem);
|
|
padding-top: 1rem;
|
|
}
|
|
@media (prefers-color-scheme: dark) {
|
|
section {
|
|
color: var(--bg-color);
|
|
background-color: var(--fg-color);
|
|
}
|
|
}
|
|
`;_([K()],P.prototype,"name",2);_([K({type:Number})],P.prototype,"count",2);P=_([X("my-element")],P);
|