Comparing version 0.0.32 to 0.0.33
@@ -1,1 +0,1 @@ | ||
var q=Object.defineProperty,K=Object.defineProperties,Q=Object.getOwnPropertyDescriptor,Z=Object.getOwnPropertyDescriptors,ee=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var E=(e,t,o)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,w=(e,t)=>{for(var o in t||(t={}))A.call(t,o)&&E(e,o,t[o]);if(j)for(var o of j(t))te.call(t,o)&&E(e,o,t[o]);return e},y=(e,t)=>K(e,Z(t));var oe=(e,t)=>{for(var o in t)q(e,o,{get:t[o],enumerable:!0})},ne=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ee(t))!A.call(e,n)&&n!==o&&q(e,n,{get:()=>t[n],enumerable:!(r=Q(t,n))||r.enumerable});return e};var re=e=>ne(q({},"__esModule",{value:!0}),e);var qe={};oe(qe,{default:()=>J});module.exports=re(qe);function U(){let e=!1,t,o,r=(i,d)=>{e||(e=!0,i(d))},n=new Promise((i,d)=>{t=i,o=d});return n.resolve=i=>r(t,i),n.reject=i=>r(o,i),n}function ie(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof NodeList)&&!(e instanceof Node)&&!(e.el instanceof Node)}function ae(e){return!!e.forEach}function h(e,t,o,r){return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)}function g(e){return c("div",{innerHTML:e}).firstChild}function c(e,...t){let o=e.split("."),r=o[0],n=o.slice(1),i=r==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement(r||"div");r==="svg"&&i.setAttribute("xmlns","http://www.w3.org/2000/svg");let d=t[0],l=ie(d)&&d;return n.length&&(i.className=n.join(" ")),ce(l,i),se(l?t.slice(1):t,i),i}function ce(e,t){return t&&e&&Object.keys(e).forEach(o=>{let r=e[o];if(o==="class"||o==="className"){let n=r&&r.split(" ");n&&n.length&&t.classList.add(...n)}else o==="innerHTML"||o==="textContent"||typeof r=="function"||o.startsWith("$")?t[o]=r:r!==!1&&r!==void 0&&r!==null&&t.setAttribute(o,r)}),t}function se(e,t){return t.appendChild(z(e)),t}function z(e,t){return t||(t=document.createDocumentFragment()),e instanceof Node||typeof e=="string"?ue(e,t):(ae(e)&&Array.from(e).forEach(o=>o&&z(o,t)),t)}function ue(e,t){if(!e)return t;let o=typeof e=="string"?document.createTextNode(e):e;return t instanceof Range?(t.insertNode(o),t.collapse()):t instanceof Node&&t.appendChild(o),t}var M=()=>g('<svg fill="currentColor" viewBox="0 0 24 24"><path d="M5 4h-3v-1h3v1zm10.93 0l.812 1.219c.743 1.115 1.987 1.781 3.328 1.781h1.93v13h-20v-13h3.93c1.341 0 2.585-.666 3.328-1.781l.812-1.219h5.86zm1.07-2h-8l-1.406 2.109c-.371.557-.995.891-1.664.891h-5.93v17h24v-17h-3.93c-.669 0-1.293-.334-1.664-.891l-1.406-2.109zm-11 8c0-.552-.447-1-1-1s-1 .448-1 1 .447 1 1 1 1-.448 1-1zm7 0c1.654 0 3 1.346 3 3s-1.346 3-3 3-3-1.346-3-3 1.346-3 3-3zm0-2c-2.761 0-5 2.239-5 5s2.239 5 5 5 5-2.239 5-5-2.239-5-5-5z" /></svg>'),C=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>'),x=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z" /></svg>');(function(){if(window.ImageCapture)return;let t=document.createElement("script");t.src="https://unpkg.com/image-capture@0.4.0/lib/imagecapture.min.js",document.head.appendChild(t)})();function S(e){let t=!!window.MediaRecorder;return{filepicker:!0,takephoto:e.includes("takephoto")&&!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),takevideo:e.includes("takevideo")&&t,takeaudio:e.includes("takeaudio")&&t}}function I(e){let o=(e.video?["video/mp4","video/mpeg","video/webm"]:["audio/mpeg","audio/webm","audio/ogg","audio/wav","audio/mp3","audio/mp4"]).filter(r=>MediaRecorder.isTypeSupported(r))[0];if(!o)throw new Error("No supported mime type found.");return o}function O(e){return e.name=`your${e.type.replace("/",".")}`,e}function F(e){let t=[],o,r;function n(s){s.data.size>0?t.push(s.data):console.error("No data",s)}function i(){return o}function d(){let s=o.getVideoTracks()[0];return new ImageCapture(s).takePhoto().then(O)}function l(){t=[],r=new MediaRecorder(o,{mimeType:I(e)}),r.ondataavailable=n,r.start()}function f(){return new Promise((s,u)=>{r.onstop=()=>{e.isDisposed()&&u(new Error("Disposed."));try{let a=new Blob(t,{type:I(e)});s(O(a))}catch(a){u(a)}},r.stop()})}return setTimeout(function s(){if(e.isDisposed()){r&&r.state!=="inactive"&&r.stop();return}setTimeout(s,1e3)},1e3),navigator.mediaDevices.getUserMedia(e).then(s=>(o=s,{liveSrc:i,capturePhoto:d,beginMediaCapture:l,endMediaCapture:f}))}function N(){let e=navigator.userAgent.toLowerCase();return e.includes("safari/")&&/ip(ad|hone|od)/.test(e)}function R(e){let t=e.onPickFiles,o=e.accept,r=e.sources,n=e.beginCaptureMedia,i=S(r),d=N(),l=(u,a,p)=>i[u]&&c("button.quik-footer-btn.quik-main-footer-btn",{onclick(m){m.preventDefault(),n(u)}},a(),p),f=()=>{let u=i.takevideo,a=i.takephoto,p=u?"video/*;capture=camcorder":a?"image/*,":"";if(!!p)return c("label.quik-footer-btn.quik-main-footer-btn",C(),u?"Take photo or video":"Take photo",c("input.quik-file-input",{type:"file",accept:p,onchange(m){t(m.target.files)}}))},s=c("label.quik-drop-target.quik-content",{ondragover(u){u.preventDefault(),s.classList.add("quik-drop-target-active")},ondragleave(){s.classList.remove("quik-drop-target-active")},ondrop(u){u.preventDefault(),u.stopPropagation();let a=u.dataTransfer.files;!e.multiple&&a.length>1&&(a=[a[0]]),t(a)}},c("input.quik-file-input",{type:"file",accept:o,multiple:e.multiple,onchange(u){t(u.target.files)}}),g('<svg class="quik-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>'),c("h2.quik-header","Upload a file"),c(".quik-instructions",c("span.quik-text","Drag or paste a file here, or choose an option below."),c("footer.quik-footer",c("span.quik-footer-btn.quik-footer-btn-primary",g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>'),"Choose File"),!d&&l("takephoto",M,"Take Photo"),!d&&l("takevideo",C,"Record Video"),d&&f(),l("takeaudio",x,"Record Audio"))));return s}function W(e){let t=e.close;return c(".quikpik",{onmousedown:t,ontouchstart:t},c("div.quik-body",{onmousedown(r){r.stopPropagation()},ontouchstart(r){r.stopPropagation()}},R(e)))}function b(e,t){e.querySelector(".quik-body").firstChild.replaceWith(t)}function X(){return c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename","Uploading..."),c("span.quik-percent","0%")),c("span.quik-progress-bar-wrapper",c("span.quik-progress-bar",{style:"width: 0%"})))}function Y(e,t,o){let r=e.querySelector(".quik-progress-bar");e.querySelector(".quik-filename").textContent=`Uploading ${o}`,e.querySelector(".quik-percent").textContent=Math.round(t)+"%",r.style.width=t+"%",t>=100&&r.classList.add("quik-done-bar")}function $(e,t,o,r){let n=0,i=!1,d=new Image;function l(){let s=o.width;o.width=o.height,o.height=s}function f(s,u,a){if(!u||!i)return;let p=u.getContext("2d");p.translate(u.width/2,u.height/2),p.rotate(a*Math.PI/180),p.drawImage(s,-s.width/2,-s.height/2),p.rotate(-a*Math.PI/180),p.translate(-u.width/2,-u.height/2)}return d.addEventListener("load",()=>{i=!0,o.width=d.width,o.height=d.height,f(d,o,n),r()}),d.addEventListener("error",()=>alert("Failed to load image.")),d.src=e,{save(s="image/png",u=void 0){return n?new Promise(a=>o.toBlob(p=>{p.name=t&&t.name,a(p)},s,u)):Promise.resolve(t)},rotate(){n=(n+90)%360,l(),f(d,o,n)}}}var T=32,P=32;function de(e){let t=e.image,o=e.cropBounds,r=e.scale,n=c("canvas");return n.width=o.width*r,n.height=o.height*r,n.getContext("2d").drawImage(t,o.left*r,o.top*r,o.width*r,o.height*r,0,0,n.width,n.height),new Promise(d=>{n.toBlob(l=>{l.name=t.name,d(l)},"image/png")})}function le(e){let t=e.parentElement,o=c(".quik-crop");return t.appendChild(o),o}function L(e){let t=e.changedTouches&&e.changedTouches[0];return t&&(e.clientX=t.clientX,e.clientY=t.clientY),e}function V(e,t){e=L(e);let o=t.getBoundingClientRect(),r=Math.max(10,Math.floor(o.width/5)),n=Math.max(10,Math.floor(o.height/5)),i=e.clientX<o.left+n,d=e.clientX>o.right-r,l=e.clientY<o.top+n,f=e.clientY>o.bottom-n;return(l?"n":f?"s":"")+(d?"e":i?"w":"")||"move"}function pe(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=Math.max(o.left,t.left+e.deltaX);return r+t.height>o.bottom&&(r=o.bottom-t.height),n+t.width>o.right&&(n=o.right-t.width),{top:r,left:n}}function fe(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.right,t.left+t.width+e.deltaX),n=Math.max(P,r-t.left);if(!e.aspectRatio)return{width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio),{width:n,height:i}}function me(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.bottom,t.top+t.height+e.deltaY),n=Math.max(T,r-t.top);if(!e.aspectRatio)return{height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio),{width:i,height:n}}function B(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.left,t.left+e.deltaX),n=t.right-r;if(n<P&&(r-=P-n,n=P),!e.aspectRatio)return{left:r,width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio,r=t.right-n),{left:r,width:n,height:i}}function he(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=t.bottom-r;if(n<T&&(r-=T-n,n=T),!e.aspectRatio)return{top:r,height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio,r=t.bottom-n),{width:i,height:n,top:r}}function ge(e){let t={};return e.direction==="sw"&&e.aspectRatio?B(e):e.direction==="nw"&&e.aspectRatio?(t=B(e,"n"),t.top=e.bounds.bottom-t.height,t):(e.direction.includes("s")&&(Object.assign(t,me(e)),e.aspectRatio)||e.direction.includes("n")&&(Object.assign(t,he(e)),e.aspectRatio)||(e.direction.includes("w")&&Object.assign(t,B(e)),e.direction.includes("e")&&Object.assign(t,fe(e))),t)}function ke(e,t,o,r,n){let i=t.getBoundingClientRect(),d=e.clientX,l=e.clientY,f={direction:n,aspectRatio:o,parentBounds:i,bounds:r.getBoundingClientRect(),deltaY:0,deltaX:0,applyEvent(s){s=L(s),f.deltaX=s.clientX-d,f.deltaY=s.clientY-l},resize(s){s.top&&(s.top=s.top-i.top),s.left&&(s.left=s.left-i.left),Object.keys(s).forEach(u=>{r.style[u]=Math.round(s[u])+"px"})}};return f}function D(e,t){let o=le(e),r=!1;h(o,"mousedown",n),h(o,"touchstart",n),h(o,"mousemove",i=>{if(!i.buttons){let d=V(i,o);o.style.cursor=d==="move"?"grabbing":d+"-resize"}});function n(i){if(i.preventDefault(),i=L(i),r)return;r=!0;let d=V(i,o),l=ke(i,e,t,o,d),f=[];function s(a){l.applyEvent(a),l.resize(d==="move"?pe(l):ge(l))}function u(){r=!1,f.forEach(a=>a())}f=[h(document,"mousemove",s),h(document,"touchmove",s),h(document,"mouseup",u),h(document,"touchend",u),h(document,"touchcancel",u)]}return{el:o,dispose(){o.remove()},apply(i){return de({image:i,cropBounds:{top:o.offsetTop-e.offsetTop,left:o.offsetLeft-e.offsetLeft,width:o.offsetWidth,height:o.offsetHeight},scale:i.naturalWidth/e.offsetWidth})}}}function ve(e,t){let o=new Image;return new Promise(r=>{o.onload=()=>{r(t(o)),URL.revokeObjectURL(o.src)},o.src=URL.createObjectURL(e)})}function H(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,d=e.onConfirm,l=e.requireCrop,f=e.cropRatio,s,u=c(".quik-content-wrapper",c(".quik-text","Loading...")),a=c("canvas.quik-confirm-item"),p=c(".quik-content",a),m=$(t,o,a,()=>{s=l?D(a,f):void 0,u.appendChild(c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),!l&&c("button.quik-footer-btn",{onclick(){s?(s.dispose(),s=void 0):s=D(a,f)}},g('<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M24 18h-4v-14h-14v-4h-2v4h-4v2h4v14h14v4h2v-4h4v-2zm-18 0v-12h12v12h-12z"/></svg>'),"Crop"),c("button.quik-footer-btn",{onclick:m.rotate},g('<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c3.31 0 6.291 1.353 8.459 3.522l2.48-2.48 1.061 7.341-7.437-.966 2.489-2.489c-1.808-1.807-4.299-2.928-7.052-2.928-5.514 0-10 4.486-10 10s4.486 10 10 10c3.872 0 7.229-2.216 8.89-5.443l1.717 1.046c-2.012 3.803-6.005 6.397-10.607 6.397-6.627 0-12-5.373-12-12s5.373-12 12-12z" /></svg>')," Rotate"),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(k){k.target.disabled=!0,m.save().then(v=>s?ve(v,s.apply):v).then(v=>{v.name||(v.name=o.name),d(v)})}},n))),u.firstChild.replaceWith(p)});return u}function G(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,d=e.onConfirm,l=o.type.startsWith("video/")?c("video.quik-vid.quik-content",{src:t,controls:!0}):c("audio",{src:t,controls:!0});return c(".quik-content-wrapper",c(".quik-confirm-item",l),c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(f){f.target.disabled=!0,d(o)}},n)))}var be=10;function we(e){let t=c("video.quik-vid.quik-content");return t.srcObject=e.recorder.liveSrc(),t.muted=!0,t.controls=!1,t.play(),t}function Ce(e,t,o){let r=Date.now(),n=t*60,i=u=>`${Math.floor(u/60)}:${`00${u%60}`.slice(-2)} / ${t}:00`,d,l=c("span.quik-progress-bar",{style:"width: 0%"}),f=c("span.quik-duration",i(0)),s=c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename",e),f),c("span.quik-progress-bar-wrapper",l));return d=setTimeout(function u(){let a=Math.floor((Date.now()-r)/1e3);if(f.textContent=i(a),l.style.width=`${Math.floor(a*100/n)}%`,a>=n){o();return}s.isConnected&&setTimeout(u,1e3)},1e3),s}function _(e){let t=e.onPickFiles,o=e.maxDuration||be,r=e.onCancel,n=e.type,i,d=c("p.quik-info.quik-content",`Waiting for your ${n==="takeaudio"?"microphone":"camera"}...`),l=c("footer.quik-footer",c("button.quik-footer-btn.quik-footer-btn-secondary",{onclick:r},"Cancel")),f=c(".quik-media",d,l),s=()=>!f.isConnected,u=a=>d.replaceWith(c("p.quik-error",a.toString()));return F({video:n!=="takeaudio",audio:n!=="takephoto",isDisposed:s}).then(a=>{let p=()=>{d.textContent="Generating preview...",i&&i.remove(),(n==="takephoto"?a.capturePhoto():a.endMediaCapture()).then(k=>t([k])).catch(u)};d.textContent=n==="takephoto"?"":`Ready to record. You can record up to ${o} minutes of ${n==="takeaudio"?"audio":"video"}.`,n!=="takeaudio"&&f.insertBefore(we({recorder:a,onPickFiles:t,onError:u}),d),l.appendChild(c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(m){n==="takephoto"||i?(m.target.disabled=!0,p()):(a.beginMediaCapture(),i=Ce("Recording...",o,p),d.textContent="",f.insertBefore(i,l),m.target.innerHTML="",m.target.append(x(),c("span","Stop recording")))}},n==="takephoto"?M():n==="takeaudio"?x():C(),n==="takephoto"?"Take Photo":"Begin Recording"))}).catch(u),f}function xe(e){e=w({sources:["filepicker","takephoto"]},e);let t,o=U(),r=[h(window,"keydown",a=>{(a.key==="Escape"||a.code==="Escape")&&d()}),h(document.body,"paste",a=>{a.clipboardData&&a.clipboardData.files&&a.clipboardData.files.length&&(a.preventDefault(),l(a.clipboardData.files))})],n=y(w({},e),{close:d,uploadFiles:u,onPickFiles:l,beginCaptureMedia:s,promise:o,root:void 0,uploader:void 0});n.root=W(n);function i(){b(n.root,R({onPickFiles:l,beginCaptureMedia:s,accept:n.accept,sources:n.sources}))}function d(){o.resolve(t),n.root.remove(),r.forEach(a=>a()),n.uploader&&(n.uploader.cancel(),n.uploader=void 0)}function l(a){let p=a.length===1?a[0]:void 0;if(p&&p.type!=="image/gif"&&!p.type.startsWith("image/svg")&&p.type.startsWith("image/")){let m=URL.createObjectURL(p);r.push(()=>URL.revokeObjectURL(m)),b(n.root,H(y(w({},e),{url:m,file:p,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>u([k])})));return}u(a)}function f(a){let p=a[0],m=URL.createObjectURL(p);r.push(()=>URL.revokeObjectURL(m)),b(n.root,G(y(w({},e),{url:m,file:p,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>u([k])})))}function s(a){b(n.root,_({type:a,onPickFiles:a==="takephoto"?l:f,onCancel:i,maxDuration:n.maxDuration}))}function u(a){if(e.customProgress)n.root.remove(),n.uploader=e.upload({files:a,onProgress(){}}),n.uploader.promise.then(p=>o.resolve(p)).catch(o.reject);else{let p=X();b(n.root,p),n.uploader=e.upload({files:a,onProgress(m,k){Y(p,m,k)}}),n.uploader.promise.then(m=>{t=m,setTimeout(d,250)}).catch(o.reject)}return n.uploader}return o.cancel=d,n}function J(e={}){let t=xe(e);return document.body.appendChild(t.root),t.promise} | ||
var q=Object.defineProperty,Q=Object.defineProperties,Z=Object.getOwnPropertyDescriptor,ee=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var E=(e,t,o)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,w=(e,t)=>{for(var o in t||(t={}))A.call(t,o)&&E(e,o,t[o]);if(j)for(var o of j(t))oe.call(t,o)&&E(e,o,t[o]);return e},y=(e,t)=>Q(e,ee(t));var ne=(e,t)=>{for(var o in t)q(e,o,{get:t[o],enumerable:!0})},re=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of te(t))!A.call(e,n)&&n!==o&&q(e,n,{get:()=>t[n],enumerable:!(r=Z(t,n))||r.enumerable});return e};var ie=e=>re(q({},"__esModule",{value:!0}),e);var ye={};ne(ye,{default:()=>K});module.exports=ie(ye);function U(){let e=!1,t,o,r=(i,d)=>{e||(e=!0,i(d))},n=new Promise((i,d)=>{t=i,o=d});return n.resolve=i=>r(t,i),n.reject=i=>r(o,i),n}function ae(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof NodeList)&&!(e instanceof Node)&&!(e.el instanceof Node)}function ce(e){return!!e.forEach}function h(e,t,o,r){return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)}function g(e){return c("div",{innerHTML:e}).firstChild}function c(e,...t){let o=e.split("."),r=o[0],n=o.slice(1),i=r==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement(r||"div");r==="svg"&&i.setAttribute("xmlns","http://www.w3.org/2000/svg");let d=t[0],l=ae(d)&&d;return n.length&&(i.className=n.join(" ")),se(l,i),ue(l?t.slice(1):t,i),i}function se(e,t){return t&&e&&Object.keys(e).forEach(o=>{let r=e[o];if(o==="class"||o==="className"){let n=r&&r.split(" ");n&&n.length&&t.classList.add(...n)}else o==="innerHTML"||o==="textContent"||typeof r=="function"||o.startsWith("$")?t[o]=r:r!==!1&&r!==void 0&&r!==null&&t.setAttribute(o,r)}),t}function ue(e,t){return t.appendChild(z(e)),t}function z(e,t){return t||(t=document.createDocumentFragment()),e instanceof Node||typeof e=="string"?de(e,t):(ce(e)&&Array.from(e).forEach(o=>o&&z(o,t)),t)}function de(e,t){if(!e)return t;let o=typeof e=="string"?document.createTextNode(e):e;return t instanceof Range?(t.insertNode(o),t.collapse()):t instanceof Node&&t.appendChild(o),t}var M=()=>g('<svg fill="currentColor" viewBox="0 0 24 24"><path d="M5 4h-3v-1h3v1zm10.93 0l.812 1.219c.743 1.115 1.987 1.781 3.328 1.781h1.93v13h-20v-13h3.93c1.341 0 2.585-.666 3.328-1.781l.812-1.219h5.86zm1.07-2h-8l-1.406 2.109c-.371.557-.995.891-1.664.891h-5.93v17h24v-17h-3.93c-.669 0-1.293-.334-1.664-.891l-1.406-2.109zm-11 8c0-.552-.447-1-1-1s-1 .448-1 1 .447 1 1 1 1-.448 1-1zm7 0c1.654 0 3 1.346 3 3s-1.346 3-3 3-3-1.346-3-3 1.346-3 3-3zm0-2c-2.761 0-5 2.239-5 5s2.239 5 5 5 5-2.239 5-5-2.239-5-5-5z" /></svg>'),C=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>'),x=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z" /></svg>');(function(){if(window.ImageCapture)return;let t=document.createElement("script");t.src="https://unpkg.com/image-capture@0.4.0/lib/imagecapture.min.js",document.head.appendChild(t)})();function S(e){let t=!!window.MediaRecorder;return{filepicker:!0,takephoto:e.includes("takephoto")&&!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),takevideo:e.includes("takevideo")&&t,takeaudio:e.includes("takeaudio")&&t}}function I(e){let o=(e.video?["video/mp4","video/mpeg","video/webm"]:["audio/mpeg","audio/webm","audio/ogg","audio/wav","audio/mp3","audio/mp4"]).filter(r=>MediaRecorder.isTypeSupported(r))[0];if(!o)throw new Error("No supported mime type found.");return o}function O(e){return e.name=`your${e.type.replace("/",".")}`,e}function F(e){let t=[],o,r;function n(u){u.data.size>0?t.push(u.data):console.error("No data",u)}function i(){return o}function d(){let u=o.getVideoTracks()[0];return new ImageCapture(u).takePhoto().then(O)}function l(){t=[],r=new MediaRecorder(o,{mimeType:I(e)}),r.ondataavailable=n,r.start()}function p(){return new Promise((u,s)=>{r.onstop=()=>{e.isDisposed()&&s(new Error("Disposed."));try{let a=new Blob(t,{type:I(e)});u(O(a))}catch(a){s(a)}},r.stop()})}return setTimeout(function u(){if(e.isDisposed()){r&&r.state!=="inactive"&&r.stop();return}setTimeout(u,1e3)},1e3),navigator.mediaDevices.getUserMedia(e).then(u=>(o=u,{liveSrc:i,capturePhoto:d,beginMediaCapture:l,endMediaCapture:p}))}function N(){let e=navigator.userAgent.toLowerCase();return e.includes("safari/")&&/ip(ad|hone|od)/.test(e)}function R(e){let t=e.onPickFiles,o=e.accept,r=e.sources,n=e.beginCaptureMedia,i=S(r),d=N(),l=(s,a,f)=>i[s]&&c("button.quik-footer-btn.quik-main-footer-btn",{onclick(m){m.preventDefault(),n(s)}},a(),f),p=()=>{let s=i.takevideo,a=i.takephoto,f=s?"video/*;capture=camcorder":a?"image/*,":"";if(!!f)return c("label.quik-footer-btn.quik-main-footer-btn",C(),s?"Take photo or video":"Take photo",c("input.quik-file-input",{type:"file",accept:f,onchange(m){t(m.target.files)}}))},u=c("label.quik-drop-target.quik-content",{ondragover(s){s.preventDefault(),u.classList.add("quik-drop-target-active")},ondragleave(){u.classList.remove("quik-drop-target-active")},ondrop(s){s.preventDefault(),s.stopPropagation();let a=s.dataTransfer.files;!e.multiple&&a.length>1&&(a=[a[0]]),t(a)}},c("input.quik-file-input",{type:"file",accept:o,multiple:e.multiple,onchange(s){t(s.target.files)}}),g('<svg class="quik-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>'),c("h2.quik-header","Upload a file"),c(".quik-instructions",c("span.quik-text","Drag or paste a file here, or choose an option below."),c("footer.quik-footer",c("span.quik-footer-btn.quik-footer-btn-primary",g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>'),"Choose File"),!d&&l("takephoto",M,"Take Photo"),!d&&l("takevideo",C,"Record Video"),d&&p(),l("takeaudio",x,"Record Audio"))));return u}function W(e){let t=e.close;return c(".quikpik",{onmousedown:t,ontouchstart:t},c("div.quik-body",{onmousedown(r){r.stopPropagation()},ontouchstart(r){r.stopPropagation()}},R(e)))}function b(e,t){e.querySelector(".quik-body").firstChild.replaceWith(t)}function X(){return c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename","Uploading..."),c("span.quik-percent","0%")),c("span.quik-progress-bar-wrapper",c("span.quik-progress-bar",{style:"width: 0%"})))}function Y(e,t,o){let r=e.querySelector(".quik-progress-bar");e.querySelector(".quik-filename").textContent=`Uploading ${o}`,e.querySelector(".quik-percent").textContent=Math.round(t)+"%",r.style.width=t+"%",t>=100&&r.classList.add("quik-done-bar")}function $(e,t,o,r){let n=0,i=!1,d=new Image;function l(){let u=o.width;o.width=o.height,o.height=u}function p(u,s,a){if(!s||!i)return;let f=s.getContext("2d");f.translate(s.width/2,s.height/2),f.rotate(a*Math.PI/180),f.drawImage(u,-u.width/2,-u.height/2),f.rotate(-a*Math.PI/180),f.translate(-s.width/2,-s.height/2)}return d.addEventListener("load",()=>{i=!0,o.width=d.width,o.height=d.height,p(d,o,n),r()}),d.addEventListener("error",()=>alert("Failed to load image.")),d.src=e,{save(u="image/png",s=void 0){return n?new Promise(a=>o.toBlob(f=>{f.name=t&&t.name,a(f)},u,s)):Promise.resolve(t)},rotate(){n=(n+90)%360,l(),p(d,o,n)}}}var T=32,P=32;function le(e){let t=e.image,o=e.cropBounds,r=e.scale,n=c("canvas");return n.width=o.width*r,n.height=o.height*r,n.getContext("2d").drawImage(t,o.left*r,o.top*r,o.width*r,o.height*r,0,0,n.width,n.height),new Promise(d=>{n.toBlob(l=>{l.name=t.name,d(l)},"image/png")})}function fe(e){let t=e.parentElement,o=c(".quik-crop");return t.appendChild(o),o}function B(e){let t=e.changedTouches&&e.changedTouches[0];return t&&(e.clientX=t.clientX,e.clientY=t.clientY),e}function H(e,t){e=B(e);let o=t.getBoundingClientRect(),r=Math.max(10,Math.floor(o.width/5)),n=Math.max(10,Math.floor(o.height/5)),i=e.clientX<o.left+n,d=e.clientX>o.right-r,l=e.clientY<o.top+n,p=e.clientY>o.bottom-n;return(l?"n":p?"s":"")+(d?"e":i?"w":"")||"move"}function pe(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=Math.max(o.left,t.left+e.deltaX);return r+t.height>o.bottom&&(r=o.bottom-t.height),n+t.width>o.right&&(n=o.right-t.width),{top:r,left:n}}function me(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.right,t.left+t.width+e.deltaX),n=Math.max(P,r-t.left);if(!e.aspectRatio)return{width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio),{width:n,height:i}}function he(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.bottom,t.top+t.height+e.deltaY),n=Math.max(T,r-t.top);if(!e.aspectRatio)return{height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio),{width:i,height:n}}function L(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.left,t.left+e.deltaX),n=t.right-r;if(n<P&&(r-=P-n,n=P),!e.aspectRatio)return{left:r,width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio,r=t.right-n),t.bottom-i<o.top&&(i=t.bottom-o.top,n=i/e.aspectRatio,r=t.right-n),{left:r,width:n,height:i}}function ge(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=t.bottom-r;if(n<T&&(r-=T-n,n=T),!e.aspectRatio)return{top:r,height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio,r=t.bottom-n),{width:i,height:n,top:r}}function ke(e){let t={};return e.direction==="sw"&&e.aspectRatio?L(e):e.direction==="nw"&&e.aspectRatio?(t=L(e,"n"),t.top=e.bounds.bottom-t.height,t):(e.direction.includes("s")&&(Object.assign(t,he(e)),e.aspectRatio)||e.direction.includes("n")&&(Object.assign(t,ge(e)),e.aspectRatio)||(e.direction.includes("w")&&Object.assign(t,L(e)),e.direction.includes("e")&&Object.assign(t,me(e))),t)}function V(e){return{left:e.offsetLeft,top:e.offsetTop,height:e.offsetHeight,width:e.offsetWidth,bottom:e.offsetTop+e.offsetHeight,right:e.offsetLeft+e.offsetWidth}}function ve(e,t,o,r,n){let i=V(t),d=e.clientX,l=e.clientY,p={direction:n,aspectRatio:o,parentBounds:i,bounds:V(r),deltaY:0,deltaX:0,applyEvent(u){u=B(u),p.deltaX=u.clientX-d,p.deltaY=u.clientY-l},resize(u){Object.keys(u).forEach(s=>{r.style[s]=Math.round(u[s])+"px"})}};return p}function D(e,t){let o=fe(e),r=!1;h(o,"mousedown",n),h(o,"touchstart",n),h(o,"mousemove",i=>{if(!i.buttons){let d=H(i,o);o.style.cursor=d==="move"?"grabbing":d+"-resize"}});function n(i){if(i.preventDefault(),i=B(i),r)return;r=!0;let d=H(i,o),l=ve(i,e,t,o,d),p=[];function u(a){l.applyEvent(a),l.resize(d==="move"?pe(l):ke(l))}function s(){r=!1,p.forEach(a=>a())}p=[h(document,"mousemove",u),h(document,"touchmove",u),h(document,"mouseup",s),h(document,"touchend",s),h(document,"touchcancel",s)]}return{el:o,dispose(){o.remove()},apply(i){return le({image:i,cropBounds:{top:o.offsetTop-e.offsetTop,left:o.offsetLeft-e.offsetLeft,width:o.offsetWidth,height:o.offsetHeight},scale:i.naturalWidth/e.offsetWidth})}}}function be(e,t){let o=new Image;return new Promise(r=>{o.onload=()=>{r(t(o)),URL.revokeObjectURL(o.src)},o.src=URL.createObjectURL(e)})}function G(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,d=e.onConfirm,l=e.requireCrop,p=e.cropRatio,u,s=c(".quik-content-wrapper",c(".quik-text","Loading...")),a=c("canvas.quik-confirm-item"),f=c(".quik-content",a),m=$(t,o,a,()=>{u=l?D(a,p):void 0,s.appendChild(c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),!l&&c("button.quik-footer-btn",{onclick(){u?(u.dispose(),u=void 0):u=D(a,p)}},g('<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M24 18h-4v-14h-14v-4h-2v4h-4v2h4v14h14v4h2v-4h4v-2zm-18 0v-12h12v12h-12z"/></svg>'),"Crop"),c("button.quik-footer-btn",{onclick:m.rotate},g('<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c3.31 0 6.291 1.353 8.459 3.522l2.48-2.48 1.061 7.341-7.437-.966 2.489-2.489c-1.808-1.807-4.299-2.928-7.052-2.928-5.514 0-10 4.486-10 10s4.486 10 10 10c3.872 0 7.229-2.216 8.89-5.443l1.717 1.046c-2.012 3.803-6.005 6.397-10.607 6.397-6.627 0-12-5.373-12-12s5.373-12 12-12z" /></svg>')," Rotate"),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(k){k.target.disabled=!0,m.save().then(v=>u?be(v,u.apply):v).then(v=>{v.name||(v.name=o.name),d(v)})}},n))),s.firstChild.replaceWith(f)});return s}function _(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,d=e.onConfirm,l=o.type.startsWith("video/")?c("video.quik-vid.quik-content",{src:t,controls:!0}):c("audio",{src:t,controls:!0});return c(".quik-content-wrapper",c(".quik-confirm-item",l),c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(p){p.target.disabled=!0,d(o)}},n)))}var we=10;function Ce(e){let t=c("video.quik-vid.quik-content");return t.srcObject=e.recorder.liveSrc(),t.muted=!0,t.controls=!1,t.play(),t}function xe(e,t,o){let r=Date.now(),n=t*60,i=s=>`${Math.floor(s/60)}:${`00${s%60}`.slice(-2)} / ${t}:00`,d,l=c("span.quik-progress-bar",{style:"width: 0%"}),p=c("span.quik-duration",i(0)),u=c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename",e),p),c("span.quik-progress-bar-wrapper",l));return d=setTimeout(function s(){let a=Math.floor((Date.now()-r)/1e3);if(p.textContent=i(a),l.style.width=`${Math.floor(a*100/n)}%`,a>=n){o();return}u.isConnected&&setTimeout(s,1e3)},1e3),u}function J(e){let t=e.onPickFiles,o=e.maxDuration||we,r=e.onCancel,n=e.type,i,d=c("p.quik-info.quik-content",`Waiting for your ${n==="takeaudio"?"microphone":"camera"}...`),l=c("footer.quik-footer",c("button.quik-footer-btn.quik-footer-btn-secondary",{onclick:r},"Cancel")),p=c(".quik-media",d,l),u=()=>!p.isConnected,s=a=>d.replaceWith(c("p.quik-error",a.toString()));return F({video:n!=="takeaudio",audio:n!=="takephoto",isDisposed:u}).then(a=>{let f=()=>{d.textContent="Generating preview...",i&&i.remove(),(n==="takephoto"?a.capturePhoto():a.endMediaCapture()).then(k=>t([k])).catch(s)};d.textContent=n==="takephoto"?"":`Ready to record. You can record up to ${o} minutes of ${n==="takeaudio"?"audio":"video"}.`,n!=="takeaudio"&&p.insertBefore(Ce({recorder:a,onPickFiles:t,onError:s}),d),l.appendChild(c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(m){n==="takephoto"||i?(m.target.disabled=!0,f()):(a.beginMediaCapture(),i=xe("Recording...",o,f),d.textContent="",p.insertBefore(i,l),m.target.innerHTML="",m.target.append(x(),c("span","Stop recording")))}},n==="takephoto"?M():n==="takeaudio"?x():C(),n==="takephoto"?"Take Photo":"Begin Recording"))}).catch(s),p}function qe(e){e=w({sources:["filepicker","takephoto"]},e);let t,o=U(),r=[h(window,"keydown",a=>{(a.key==="Escape"||a.code==="Escape")&&d()}),h(document.body,"paste",a=>{a.clipboardData&&a.clipboardData.files&&a.clipboardData.files.length&&(a.preventDefault(),l(a.clipboardData.files))})],n=y(w({},e),{close:d,uploadFiles:s,onPickFiles:l,beginCaptureMedia:u,promise:o,root:void 0,uploader:void 0});n.root=W(n);function i(){b(n.root,R({onPickFiles:l,beginCaptureMedia:u,accept:n.accept,sources:n.sources}))}function d(){o.resolve(t),n.root.remove(),r.forEach(a=>a()),n.uploader&&(n.uploader.cancel(),n.uploader=void 0)}function l(a){let f=a.length===1?a[0]:void 0;if(f&&f.type!=="image/gif"&&!f.type.startsWith("image/svg")&&f.type.startsWith("image/")){let m=URL.createObjectURL(f);r.push(()=>URL.revokeObjectURL(m)),b(n.root,G(y(w({},e),{url:m,file:f,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>s([k])})));return}s(a)}function p(a){let f=a[0],m=URL.createObjectURL(f);r.push(()=>URL.revokeObjectURL(m)),b(n.root,_(y(w({},e),{url:m,file:f,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>s([k])})))}function u(a){b(n.root,J({type:a,onPickFiles:a==="takephoto"?l:p,onCancel:i,maxDuration:n.maxDuration}))}function s(a){if(e.customProgress)n.root.remove(),n.uploader=e.upload({files:a,onProgress(){}}),n.uploader.promise.then(f=>o.resolve(f)).catch(o.reject);else{let f=X();b(n.root,f),n.uploader=e.upload({files:a,onProgress(m,k){Y(f,m,k)}}),n.uploader.promise.then(m=>{t=m,setTimeout(d,250)}).catch(o.reject)}return n.uploader}return o.cancel=d,n}function K(e={}){let t=qe(e);return document.body.appendChild(t.root),t.promise} |
@@ -1,1 +0,1 @@ | ||
var quikpik=(()=>{var q=Object.defineProperty,K=Object.defineProperties,Q=Object.getOwnPropertyDescriptor,Z=Object.getOwnPropertyDescriptors,ee=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var E=(e,t,o)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,w=(e,t)=>{for(var o in t||(t={}))A.call(t,o)&&E(e,o,t[o]);if(j)for(var o of j(t))te.call(t,o)&&E(e,o,t[o]);return e},y=(e,t)=>K(e,Z(t));var oe=(e,t)=>{for(var o in t)q(e,o,{get:t[o],enumerable:!0})},ne=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ee(t))!A.call(e,n)&&n!==o&&q(e,n,{get:()=>t[n],enumerable:!(r=Q(t,n))||r.enumerable});return e};var re=e=>ne(q({},"__esModule",{value:!0}),e);var qe={};oe(qe,{default:()=>J});function U(){let e=!1,t,o,r=(i,d)=>{e||(e=!0,i(d))},n=new Promise((i,d)=>{t=i,o=d});return n.resolve=i=>r(t,i),n.reject=i=>r(o,i),n}function ie(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof NodeList)&&!(e instanceof Node)&&!(e.el instanceof Node)}function ae(e){return!!e.forEach}function h(e,t,o,r){return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)}function g(e){return c("div",{innerHTML:e}).firstChild}function c(e,...t){let o=e.split("."),r=o[0],n=o.slice(1),i=r==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement(r||"div");r==="svg"&&i.setAttribute("xmlns","http://www.w3.org/2000/svg");let d=t[0],l=ie(d)&&d;return n.length&&(i.className=n.join(" ")),ce(l,i),se(l?t.slice(1):t,i),i}function ce(e,t){return t&&e&&Object.keys(e).forEach(o=>{let r=e[o];if(o==="class"||o==="className"){let n=r&&r.split(" ");n&&n.length&&t.classList.add(...n)}else o==="innerHTML"||o==="textContent"||typeof r=="function"||o.startsWith("$")?t[o]=r:r!==!1&&r!==void 0&&r!==null&&t.setAttribute(o,r)}),t}function se(e,t){return t.appendChild(z(e)),t}function z(e,t){return t||(t=document.createDocumentFragment()),e instanceof Node||typeof e=="string"?ue(e,t):(ae(e)&&Array.from(e).forEach(o=>o&&z(o,t)),t)}function ue(e,t){if(!e)return t;let o=typeof e=="string"?document.createTextNode(e):e;return t instanceof Range?(t.insertNode(o),t.collapse()):t instanceof Node&&t.appendChild(o),t}var M=()=>g('<svg fill="currentColor" viewBox="0 0 24 24"><path d="M5 4h-3v-1h3v1zm10.93 0l.812 1.219c.743 1.115 1.987 1.781 3.328 1.781h1.93v13h-20v-13h3.93c1.341 0 2.585-.666 3.328-1.781l.812-1.219h5.86zm1.07-2h-8l-1.406 2.109c-.371.557-.995.891-1.664.891h-5.93v17h24v-17h-3.93c-.669 0-1.293-.334-1.664-.891l-1.406-2.109zm-11 8c0-.552-.447-1-1-1s-1 .448-1 1 .447 1 1 1 1-.448 1-1zm7 0c1.654 0 3 1.346 3 3s-1.346 3-3 3-3-1.346-3-3 1.346-3 3-3zm0-2c-2.761 0-5 2.239-5 5s2.239 5 5 5 5-2.239 5-5-2.239-5-5-5z" /></svg>'),C=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>'),x=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z" /></svg>');(function(){if(window.ImageCapture)return;let t=document.createElement("script");t.src="https://unpkg.com/image-capture@0.4.0/lib/imagecapture.min.js",document.head.appendChild(t)})();function S(e){let t=!!window.MediaRecorder;return{filepicker:!0,takephoto:e.includes("takephoto")&&!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),takevideo:e.includes("takevideo")&&t,takeaudio:e.includes("takeaudio")&&t}}function I(e){let o=(e.video?["video/mp4","video/mpeg","video/webm"]:["audio/mpeg","audio/webm","audio/ogg","audio/wav","audio/mp3","audio/mp4"]).filter(r=>MediaRecorder.isTypeSupported(r))[0];if(!o)throw new Error("No supported mime type found.");return o}function O(e){return e.name=`your${e.type.replace("/",".")}`,e}function F(e){let t=[],o,r;function n(s){s.data.size>0?t.push(s.data):console.error("No data",s)}function i(){return o}function d(){let s=o.getVideoTracks()[0];return new ImageCapture(s).takePhoto().then(O)}function l(){t=[],r=new MediaRecorder(o,{mimeType:I(e)}),r.ondataavailable=n,r.start()}function f(){return new Promise((s,u)=>{r.onstop=()=>{e.isDisposed()&&u(new Error("Disposed."));try{let a=new Blob(t,{type:I(e)});s(O(a))}catch(a){u(a)}},r.stop()})}return setTimeout(function s(){if(e.isDisposed()){r&&r.state!=="inactive"&&r.stop();return}setTimeout(s,1e3)},1e3),navigator.mediaDevices.getUserMedia(e).then(s=>(o=s,{liveSrc:i,capturePhoto:d,beginMediaCapture:l,endMediaCapture:f}))}function N(){let e=navigator.userAgent.toLowerCase();return e.includes("safari/")&&/ip(ad|hone|od)/.test(e)}function R(e){let t=e.onPickFiles,o=e.accept,r=e.sources,n=e.beginCaptureMedia,i=S(r),d=N(),l=(u,a,p)=>i[u]&&c("button.quik-footer-btn.quik-main-footer-btn",{onclick(m){m.preventDefault(),n(u)}},a(),p),f=()=>{let u=i.takevideo,a=i.takephoto,p=u?"video/*;capture=camcorder":a?"image/*,":"";if(!!p)return c("label.quik-footer-btn.quik-main-footer-btn",C(),u?"Take photo or video":"Take photo",c("input.quik-file-input",{type:"file",accept:p,onchange(m){t(m.target.files)}}))},s=c("label.quik-drop-target.quik-content",{ondragover(u){u.preventDefault(),s.classList.add("quik-drop-target-active")},ondragleave(){s.classList.remove("quik-drop-target-active")},ondrop(u){u.preventDefault(),u.stopPropagation();let a=u.dataTransfer.files;!e.multiple&&a.length>1&&(a=[a[0]]),t(a)}},c("input.quik-file-input",{type:"file",accept:o,multiple:e.multiple,onchange(u){t(u.target.files)}}),g('<svg class="quik-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>'),c("h2.quik-header","Upload a file"),c(".quik-instructions",c("span.quik-text","Drag or paste a file here, or choose an option below."),c("footer.quik-footer",c("span.quik-footer-btn.quik-footer-btn-primary",g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>'),"Choose File"),!d&&l("takephoto",M,"Take Photo"),!d&&l("takevideo",C,"Record Video"),d&&f(),l("takeaudio",x,"Record Audio"))));return s}function W(e){let t=e.close;return c(".quikpik",{onmousedown:t,ontouchstart:t},c("div.quik-body",{onmousedown(r){r.stopPropagation()},ontouchstart(r){r.stopPropagation()}},R(e)))}function b(e,t){e.querySelector(".quik-body").firstChild.replaceWith(t)}function X(){return c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename","Uploading..."),c("span.quik-percent","0%")),c("span.quik-progress-bar-wrapper",c("span.quik-progress-bar",{style:"width: 0%"})))}function Y(e,t,o){let r=e.querySelector(".quik-progress-bar");e.querySelector(".quik-filename").textContent=`Uploading ${o}`,e.querySelector(".quik-percent").textContent=Math.round(t)+"%",r.style.width=t+"%",t>=100&&r.classList.add("quik-done-bar")}function $(e,t,o,r){let n=0,i=!1,d=new Image;function l(){let s=o.width;o.width=o.height,o.height=s}function f(s,u,a){if(!u||!i)return;let p=u.getContext("2d");p.translate(u.width/2,u.height/2),p.rotate(a*Math.PI/180),p.drawImage(s,-s.width/2,-s.height/2),p.rotate(-a*Math.PI/180),p.translate(-u.width/2,-u.height/2)}return d.addEventListener("load",()=>{i=!0,o.width=d.width,o.height=d.height,f(d,o,n),r()}),d.addEventListener("error",()=>alert("Failed to load image.")),d.src=e,{save(s="image/png",u=void 0){return n?new Promise(a=>o.toBlob(p=>{p.name=t&&t.name,a(p)},s,u)):Promise.resolve(t)},rotate(){n=(n+90)%360,l(),f(d,o,n)}}}var T=32,P=32;function de(e){let t=e.image,o=e.cropBounds,r=e.scale,n=c("canvas");return n.width=o.width*r,n.height=o.height*r,n.getContext("2d").drawImage(t,o.left*r,o.top*r,o.width*r,o.height*r,0,0,n.width,n.height),new Promise(d=>{n.toBlob(l=>{l.name=t.name,d(l)},"image/png")})}function le(e){let t=e.parentElement,o=c(".quik-crop");return t.appendChild(o),o}function L(e){let t=e.changedTouches&&e.changedTouches[0];return t&&(e.clientX=t.clientX,e.clientY=t.clientY),e}function V(e,t){e=L(e);let o=t.getBoundingClientRect(),r=Math.max(10,Math.floor(o.width/5)),n=Math.max(10,Math.floor(o.height/5)),i=e.clientX<o.left+n,d=e.clientX>o.right-r,l=e.clientY<o.top+n,f=e.clientY>o.bottom-n;return(l?"n":f?"s":"")+(d?"e":i?"w":"")||"move"}function pe(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=Math.max(o.left,t.left+e.deltaX);return r+t.height>o.bottom&&(r=o.bottom-t.height),n+t.width>o.right&&(n=o.right-t.width),{top:r,left:n}}function fe(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.right,t.left+t.width+e.deltaX),n=Math.max(P,r-t.left);if(!e.aspectRatio)return{width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio),{width:n,height:i}}function me(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.bottom,t.top+t.height+e.deltaY),n=Math.max(T,r-t.top);if(!e.aspectRatio)return{height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio),{width:i,height:n}}function B(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.left,t.left+e.deltaX),n=t.right-r;if(n<P&&(r-=P-n,n=P),!e.aspectRatio)return{left:r,width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio,r=t.right-n),{left:r,width:n,height:i}}function he(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=t.bottom-r;if(n<T&&(r-=T-n,n=T),!e.aspectRatio)return{top:r,height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio,r=t.bottom-n),{width:i,height:n,top:r}}function ge(e){let t={};return e.direction==="sw"&&e.aspectRatio?B(e):e.direction==="nw"&&e.aspectRatio?(t=B(e,"n"),t.top=e.bounds.bottom-t.height,t):(e.direction.includes("s")&&(Object.assign(t,me(e)),e.aspectRatio)||e.direction.includes("n")&&(Object.assign(t,he(e)),e.aspectRatio)||(e.direction.includes("w")&&Object.assign(t,B(e)),e.direction.includes("e")&&Object.assign(t,fe(e))),t)}function ke(e,t,o,r,n){let i=t.getBoundingClientRect(),d=e.clientX,l=e.clientY,f={direction:n,aspectRatio:o,parentBounds:i,bounds:r.getBoundingClientRect(),deltaY:0,deltaX:0,applyEvent(s){s=L(s),f.deltaX=s.clientX-d,f.deltaY=s.clientY-l},resize(s){s.top&&(s.top=s.top-i.top),s.left&&(s.left=s.left-i.left),Object.keys(s).forEach(u=>{r.style[u]=Math.round(s[u])+"px"})}};return f}function D(e,t){let o=le(e),r=!1;h(o,"mousedown",n),h(o,"touchstart",n),h(o,"mousemove",i=>{if(!i.buttons){let d=V(i,o);o.style.cursor=d==="move"?"grabbing":d+"-resize"}});function n(i){if(i.preventDefault(),i=L(i),r)return;r=!0;let d=V(i,o),l=ke(i,e,t,o,d),f=[];function s(a){l.applyEvent(a),l.resize(d==="move"?pe(l):ge(l))}function u(){r=!1,f.forEach(a=>a())}f=[h(document,"mousemove",s),h(document,"touchmove",s),h(document,"mouseup",u),h(document,"touchend",u),h(document,"touchcancel",u)]}return{el:o,dispose(){o.remove()},apply(i){return de({image:i,cropBounds:{top:o.offsetTop-e.offsetTop,left:o.offsetLeft-e.offsetLeft,width:o.offsetWidth,height:o.offsetHeight},scale:i.naturalWidth/e.offsetWidth})}}}function ve(e,t){let o=new Image;return new Promise(r=>{o.onload=()=>{r(t(o)),URL.revokeObjectURL(o.src)},o.src=URL.createObjectURL(e)})}function H(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,d=e.onConfirm,l=e.requireCrop,f=e.cropRatio,s,u=c(".quik-content-wrapper",c(".quik-text","Loading...")),a=c("canvas.quik-confirm-item"),p=c(".quik-content",a),m=$(t,o,a,()=>{s=l?D(a,f):void 0,u.appendChild(c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),!l&&c("button.quik-footer-btn",{onclick(){s?(s.dispose(),s=void 0):s=D(a,f)}},g('<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M24 18h-4v-14h-14v-4h-2v4h-4v2h4v14h14v4h2v-4h4v-2zm-18 0v-12h12v12h-12z"/></svg>'),"Crop"),c("button.quik-footer-btn",{onclick:m.rotate},g('<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c3.31 0 6.291 1.353 8.459 3.522l2.48-2.48 1.061 7.341-7.437-.966 2.489-2.489c-1.808-1.807-4.299-2.928-7.052-2.928-5.514 0-10 4.486-10 10s4.486 10 10 10c3.872 0 7.229-2.216 8.89-5.443l1.717 1.046c-2.012 3.803-6.005 6.397-10.607 6.397-6.627 0-12-5.373-12-12s5.373-12 12-12z" /></svg>')," Rotate"),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(k){k.target.disabled=!0,m.save().then(v=>s?ve(v,s.apply):v).then(v=>{v.name||(v.name=o.name),d(v)})}},n))),u.firstChild.replaceWith(p)});return u}function G(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,d=e.onConfirm,l=o.type.startsWith("video/")?c("video.quik-vid.quik-content",{src:t,controls:!0}):c("audio",{src:t,controls:!0});return c(".quik-content-wrapper",c(".quik-confirm-item",l),c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(f){f.target.disabled=!0,d(o)}},n)))}var be=10;function we(e){let t=c("video.quik-vid.quik-content");return t.srcObject=e.recorder.liveSrc(),t.muted=!0,t.controls=!1,t.play(),t}function Ce(e,t,o){let r=Date.now(),n=t*60,i=u=>`${Math.floor(u/60)}:${`00${u%60}`.slice(-2)} / ${t}:00`,d,l=c("span.quik-progress-bar",{style:"width: 0%"}),f=c("span.quik-duration",i(0)),s=c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename",e),f),c("span.quik-progress-bar-wrapper",l));return d=setTimeout(function u(){let a=Math.floor((Date.now()-r)/1e3);if(f.textContent=i(a),l.style.width=`${Math.floor(a*100/n)}%`,a>=n){o();return}s.isConnected&&setTimeout(u,1e3)},1e3),s}function _(e){let t=e.onPickFiles,o=e.maxDuration||be,r=e.onCancel,n=e.type,i,d=c("p.quik-info.quik-content",`Waiting for your ${n==="takeaudio"?"microphone":"camera"}...`),l=c("footer.quik-footer",c("button.quik-footer-btn.quik-footer-btn-secondary",{onclick:r},"Cancel")),f=c(".quik-media",d,l),s=()=>!f.isConnected,u=a=>d.replaceWith(c("p.quik-error",a.toString()));return F({video:n!=="takeaudio",audio:n!=="takephoto",isDisposed:s}).then(a=>{let p=()=>{d.textContent="Generating preview...",i&&i.remove(),(n==="takephoto"?a.capturePhoto():a.endMediaCapture()).then(k=>t([k])).catch(u)};d.textContent=n==="takephoto"?"":`Ready to record. You can record up to ${o} minutes of ${n==="takeaudio"?"audio":"video"}.`,n!=="takeaudio"&&f.insertBefore(we({recorder:a,onPickFiles:t,onError:u}),d),l.appendChild(c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(m){n==="takephoto"||i?(m.target.disabled=!0,p()):(a.beginMediaCapture(),i=Ce("Recording...",o,p),d.textContent="",f.insertBefore(i,l),m.target.innerHTML="",m.target.append(x(),c("span","Stop recording")))}},n==="takephoto"?M():n==="takeaudio"?x():C(),n==="takephoto"?"Take Photo":"Begin Recording"))}).catch(u),f}function xe(e){e=w({sources:["filepicker","takephoto"]},e);let t,o=U(),r=[h(window,"keydown",a=>{(a.key==="Escape"||a.code==="Escape")&&d()}),h(document.body,"paste",a=>{a.clipboardData&&a.clipboardData.files&&a.clipboardData.files.length&&(a.preventDefault(),l(a.clipboardData.files))})],n=y(w({},e),{close:d,uploadFiles:u,onPickFiles:l,beginCaptureMedia:s,promise:o,root:void 0,uploader:void 0});n.root=W(n);function i(){b(n.root,R({onPickFiles:l,beginCaptureMedia:s,accept:n.accept,sources:n.sources}))}function d(){o.resolve(t),n.root.remove(),r.forEach(a=>a()),n.uploader&&(n.uploader.cancel(),n.uploader=void 0)}function l(a){let p=a.length===1?a[0]:void 0;if(p&&p.type!=="image/gif"&&!p.type.startsWith("image/svg")&&p.type.startsWith("image/")){let m=URL.createObjectURL(p);r.push(()=>URL.revokeObjectURL(m)),b(n.root,H(y(w({},e),{url:m,file:p,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>u([k])})));return}u(a)}function f(a){let p=a[0],m=URL.createObjectURL(p);r.push(()=>URL.revokeObjectURL(m)),b(n.root,G(y(w({},e),{url:m,file:p,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>u([k])})))}function s(a){b(n.root,_({type:a,onPickFiles:a==="takephoto"?l:f,onCancel:i,maxDuration:n.maxDuration}))}function u(a){if(e.customProgress)n.root.remove(),n.uploader=e.upload({files:a,onProgress(){}}),n.uploader.promise.then(p=>o.resolve(p)).catch(o.reject);else{let p=X();b(n.root,p),n.uploader=e.upload({files:a,onProgress(m,k){Y(p,m,k)}}),n.uploader.promise.then(m=>{t=m,setTimeout(d,250)}).catch(o.reject)}return n.uploader}return o.cancel=d,n}function J(e={}){let t=xe(e);return document.body.appendChild(t.root),t.promise}return re(qe);})(); | ||
var quikpik=(()=>{var q=Object.defineProperty,Q=Object.defineProperties,Z=Object.getOwnPropertyDescriptor,ee=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertyNames,j=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var E=(e,t,o)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,w=(e,t)=>{for(var o in t||(t={}))A.call(t,o)&&E(e,o,t[o]);if(j)for(var o of j(t))oe.call(t,o)&&E(e,o,t[o]);return e},y=(e,t)=>Q(e,ee(t));var ne=(e,t)=>{for(var o in t)q(e,o,{get:t[o],enumerable:!0})},re=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of te(t))!A.call(e,n)&&n!==o&&q(e,n,{get:()=>t[n],enumerable:!(r=Z(t,n))||r.enumerable});return e};var ie=e=>re(q({},"__esModule",{value:!0}),e);var ye={};ne(ye,{default:()=>K});function U(){let e=!1,t,o,r=(i,d)=>{e||(e=!0,i(d))},n=new Promise((i,d)=>{t=i,o=d});return n.resolve=i=>r(t,i),n.reject=i=>r(o,i),n}function ae(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof NodeList)&&!(e instanceof Node)&&!(e.el instanceof Node)}function ce(e){return!!e.forEach}function h(e,t,o,r){return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)}function g(e){return c("div",{innerHTML:e}).firstChild}function c(e,...t){let o=e.split("."),r=o[0],n=o.slice(1),i=r==="svg"?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement(r||"div");r==="svg"&&i.setAttribute("xmlns","http://www.w3.org/2000/svg");let d=t[0],l=ae(d)&&d;return n.length&&(i.className=n.join(" ")),se(l,i),ue(l?t.slice(1):t,i),i}function se(e,t){return t&&e&&Object.keys(e).forEach(o=>{let r=e[o];if(o==="class"||o==="className"){let n=r&&r.split(" ");n&&n.length&&t.classList.add(...n)}else o==="innerHTML"||o==="textContent"||typeof r=="function"||o.startsWith("$")?t[o]=r:r!==!1&&r!==void 0&&r!==null&&t.setAttribute(o,r)}),t}function ue(e,t){return t.appendChild(z(e)),t}function z(e,t){return t||(t=document.createDocumentFragment()),e instanceof Node||typeof e=="string"?de(e,t):(ce(e)&&Array.from(e).forEach(o=>o&&z(o,t)),t)}function de(e,t){if(!e)return t;let o=typeof e=="string"?document.createTextNode(e):e;return t instanceof Range?(t.insertNode(o),t.collapse()):t instanceof Node&&t.appendChild(o),t}var M=()=>g('<svg fill="currentColor" viewBox="0 0 24 24"><path d="M5 4h-3v-1h3v1zm10.93 0l.812 1.219c.743 1.115 1.987 1.781 3.328 1.781h1.93v13h-20v-13h3.93c1.341 0 2.585-.666 3.328-1.781l.812-1.219h5.86zm1.07-2h-8l-1.406 2.109c-.371.557-.995.891-1.664.891h-5.93v17h24v-17h-3.93c-.669 0-1.293-.334-1.664-.891l-1.406-2.109zm-11 8c0-.552-.447-1-1-1s-1 .448-1 1 .447 1 1 1 1-.448 1-1zm7 0c1.654 0 3 1.346 3 3s-1.346 3-3 3-3-1.346-3-3 1.346-3 3-3zm0-2c-2.761 0-5 2.239-5 5s2.239 5 5 5 5-2.239 5-5-2.239-5-5-5z" /></svg>'),C=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>'),x=()=>g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z" /></svg>');(function(){if(window.ImageCapture)return;let t=document.createElement("script");t.src="https://unpkg.com/image-capture@0.4.0/lib/imagecapture.min.js",document.head.appendChild(t)})();function S(e){let t=!!window.MediaRecorder;return{filepicker:!0,takephoto:e.includes("takephoto")&&!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia),takevideo:e.includes("takevideo")&&t,takeaudio:e.includes("takeaudio")&&t}}function I(e){let o=(e.video?["video/mp4","video/mpeg","video/webm"]:["audio/mpeg","audio/webm","audio/ogg","audio/wav","audio/mp3","audio/mp4"]).filter(r=>MediaRecorder.isTypeSupported(r))[0];if(!o)throw new Error("No supported mime type found.");return o}function O(e){return e.name=`your${e.type.replace("/",".")}`,e}function F(e){let t=[],o,r;function n(u){u.data.size>0?t.push(u.data):console.error("No data",u)}function i(){return o}function d(){let u=o.getVideoTracks()[0];return new ImageCapture(u).takePhoto().then(O)}function l(){t=[],r=new MediaRecorder(o,{mimeType:I(e)}),r.ondataavailable=n,r.start()}function p(){return new Promise((u,s)=>{r.onstop=()=>{e.isDisposed()&&s(new Error("Disposed."));try{let a=new Blob(t,{type:I(e)});u(O(a))}catch(a){s(a)}},r.stop()})}return setTimeout(function u(){if(e.isDisposed()){r&&r.state!=="inactive"&&r.stop();return}setTimeout(u,1e3)},1e3),navigator.mediaDevices.getUserMedia(e).then(u=>(o=u,{liveSrc:i,capturePhoto:d,beginMediaCapture:l,endMediaCapture:p}))}function N(){let e=navigator.userAgent.toLowerCase();return e.includes("safari/")&&/ip(ad|hone|od)/.test(e)}function R(e){let t=e.onPickFiles,o=e.accept,r=e.sources,n=e.beginCaptureMedia,i=S(r),d=N(),l=(s,a,f)=>i[s]&&c("button.quik-footer-btn.quik-main-footer-btn",{onclick(m){m.preventDefault(),n(s)}},a(),f),p=()=>{let s=i.takevideo,a=i.takephoto,f=s?"video/*;capture=camcorder":a?"image/*,":"";if(!!f)return c("label.quik-footer-btn.quik-main-footer-btn",C(),s?"Take photo or video":"Take photo",c("input.quik-file-input",{type:"file",accept:f,onchange(m){t(m.target.files)}}))},u=c("label.quik-drop-target.quik-content",{ondragover(s){s.preventDefault(),u.classList.add("quik-drop-target-active")},ondragleave(){u.classList.remove("quik-drop-target-active")},ondrop(s){s.preventDefault(),s.stopPropagation();let a=s.dataTransfer.files;!e.multiple&&a.length>1&&(a=[a[0]]),t(a)}},c("input.quik-file-input",{type:"file",accept:o,multiple:e.multiple,onchange(s){t(s.target.files)}}),g('<svg class="quik-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>'),c("h2.quik-header","Upload a file"),c(".quik-instructions",c("span.quik-text","Drag or paste a file here, or choose an option below."),c("footer.quik-footer",c("span.quik-footer-btn.quik-footer-btn-primary",g('<svg fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /></svg>'),"Choose File"),!d&&l("takephoto",M,"Take Photo"),!d&&l("takevideo",C,"Record Video"),d&&p(),l("takeaudio",x,"Record Audio"))));return u}function W(e){let t=e.close;return c(".quikpik",{onmousedown:t,ontouchstart:t},c("div.quik-body",{onmousedown(r){r.stopPropagation()},ontouchstart(r){r.stopPropagation()}},R(e)))}function b(e,t){e.querySelector(".quik-body").firstChild.replaceWith(t)}function X(){return c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename","Uploading..."),c("span.quik-percent","0%")),c("span.quik-progress-bar-wrapper",c("span.quik-progress-bar",{style:"width: 0%"})))}function Y(e,t,o){let r=e.querySelector(".quik-progress-bar");e.querySelector(".quik-filename").textContent=`Uploading ${o}`,e.querySelector(".quik-percent").textContent=Math.round(t)+"%",r.style.width=t+"%",t>=100&&r.classList.add("quik-done-bar")}function $(e,t,o,r){let n=0,i=!1,d=new Image;function l(){let u=o.width;o.width=o.height,o.height=u}function p(u,s,a){if(!s||!i)return;let f=s.getContext("2d");f.translate(s.width/2,s.height/2),f.rotate(a*Math.PI/180),f.drawImage(u,-u.width/2,-u.height/2),f.rotate(-a*Math.PI/180),f.translate(-s.width/2,-s.height/2)}return d.addEventListener("load",()=>{i=!0,o.width=d.width,o.height=d.height,p(d,o,n),r()}),d.addEventListener("error",()=>alert("Failed to load image.")),d.src=e,{save(u="image/png",s=void 0){return n?new Promise(a=>o.toBlob(f=>{f.name=t&&t.name,a(f)},u,s)):Promise.resolve(t)},rotate(){n=(n+90)%360,l(),p(d,o,n)}}}var T=32,P=32;function le(e){let t=e.image,o=e.cropBounds,r=e.scale,n=c("canvas");return n.width=o.width*r,n.height=o.height*r,n.getContext("2d").drawImage(t,o.left*r,o.top*r,o.width*r,o.height*r,0,0,n.width,n.height),new Promise(d=>{n.toBlob(l=>{l.name=t.name,d(l)},"image/png")})}function fe(e){let t=e.parentElement,o=c(".quik-crop");return t.appendChild(o),o}function B(e){let t=e.changedTouches&&e.changedTouches[0];return t&&(e.clientX=t.clientX,e.clientY=t.clientY),e}function H(e,t){e=B(e);let o=t.getBoundingClientRect(),r=Math.max(10,Math.floor(o.width/5)),n=Math.max(10,Math.floor(o.height/5)),i=e.clientX<o.left+n,d=e.clientX>o.right-r,l=e.clientY<o.top+n,p=e.clientY>o.bottom-n;return(l?"n":p?"s":"")+(d?"e":i?"w":"")||"move"}function pe(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=Math.max(o.left,t.left+e.deltaX);return r+t.height>o.bottom&&(r=o.bottom-t.height),n+t.width>o.right&&(n=o.right-t.width),{top:r,left:n}}function me(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.right,t.left+t.width+e.deltaX),n=Math.max(P,r-t.left);if(!e.aspectRatio)return{width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio),{width:n,height:i}}function he(e){let t=e.bounds,o=e.parentBounds,r=Math.min(o.bottom,t.top+t.height+e.deltaY),n=Math.max(T,r-t.top);if(!e.aspectRatio)return{height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio),{width:i,height:n}}function L(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.left,t.left+e.deltaX),n=t.right-r;if(n<P&&(r-=P-n,n=P),!e.aspectRatio)return{left:r,width:n};let i=n*e.aspectRatio;return t.top+i>o.bottom&&(i=o.bottom-t.top,n=i/e.aspectRatio,r=t.right-n),t.bottom-i<o.top&&(i=t.bottom-o.top,n=i/e.aspectRatio,r=t.right-n),{left:r,width:n,height:i}}function ge(e){let t=e.bounds,o=e.parentBounds,r=Math.max(o.top,t.top+e.deltaY),n=t.bottom-r;if(n<T&&(r-=T-n,n=T),!e.aspectRatio)return{top:r,height:n};let i=n/e.aspectRatio;return t.left+i>o.right&&(i=o.right-t.left,n=i*e.aspectRatio,r=t.bottom-n),{width:i,height:n,top:r}}function ke(e){let t={};return e.direction==="sw"&&e.aspectRatio?L(e):e.direction==="nw"&&e.aspectRatio?(t=L(e,"n"),t.top=e.bounds.bottom-t.height,t):(e.direction.includes("s")&&(Object.assign(t,he(e)),e.aspectRatio)||e.direction.includes("n")&&(Object.assign(t,ge(e)),e.aspectRatio)||(e.direction.includes("w")&&Object.assign(t,L(e)),e.direction.includes("e")&&Object.assign(t,me(e))),t)}function V(e){return{left:e.offsetLeft,top:e.offsetTop,height:e.offsetHeight,width:e.offsetWidth,bottom:e.offsetTop+e.offsetHeight,right:e.offsetLeft+e.offsetWidth}}function ve(e,t,o,r,n){let i=V(t),d=e.clientX,l=e.clientY,p={direction:n,aspectRatio:o,parentBounds:i,bounds:V(r),deltaY:0,deltaX:0,applyEvent(u){u=B(u),p.deltaX=u.clientX-d,p.deltaY=u.clientY-l},resize(u){Object.keys(u).forEach(s=>{r.style[s]=Math.round(u[s])+"px"})}};return p}function D(e,t){let o=fe(e),r=!1;h(o,"mousedown",n),h(o,"touchstart",n),h(o,"mousemove",i=>{if(!i.buttons){let d=H(i,o);o.style.cursor=d==="move"?"grabbing":d+"-resize"}});function n(i){if(i.preventDefault(),i=B(i),r)return;r=!0;let d=H(i,o),l=ve(i,e,t,o,d),p=[];function u(a){l.applyEvent(a),l.resize(d==="move"?pe(l):ke(l))}function s(){r=!1,p.forEach(a=>a())}p=[h(document,"mousemove",u),h(document,"touchmove",u),h(document,"mouseup",s),h(document,"touchend",s),h(document,"touchcancel",s)]}return{el:o,dispose(){o.remove()},apply(i){return le({image:i,cropBounds:{top:o.offsetTop-e.offsetTop,left:o.offsetLeft-e.offsetLeft,width:o.offsetWidth,height:o.offsetHeight},scale:i.naturalWidth/e.offsetWidth})}}}function be(e,t){let o=new Image;return new Promise(r=>{o.onload=()=>{r(t(o)),URL.revokeObjectURL(o.src)},o.src=URL.createObjectURL(e)})}function G(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,d=e.onConfirm,l=e.requireCrop,p=e.cropRatio,u,s=c(".quik-content-wrapper",c(".quik-text","Loading...")),a=c("canvas.quik-confirm-item"),f=c(".quik-content",a),m=$(t,o,a,()=>{u=l?D(a,p):void 0,s.appendChild(c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),!l&&c("button.quik-footer-btn",{onclick(){u?(u.dispose(),u=void 0):u=D(a,p)}},g('<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M24 18h-4v-14h-14v-4h-2v4h-4v2h4v14h14v4h2v-4h4v-2zm-18 0v-12h12v12h-12z"/></svg>'),"Crop"),c("button.quik-footer-btn",{onclick:m.rotate},g('<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0c3.31 0 6.291 1.353 8.459 3.522l2.48-2.48 1.061 7.341-7.437-.966 2.489-2.489c-1.808-1.807-4.299-2.928-7.052-2.928-5.514 0-10 4.486-10 10s4.486 10 10 10c3.872 0 7.229-2.216 8.89-5.443l1.717 1.046c-2.012 3.803-6.005 6.397-10.607 6.397-6.627 0-12-5.373-12-12s5.373-12 12-12z" /></svg>')," Rotate"),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(k){k.target.disabled=!0,m.save().then(v=>u?be(v,u.apply):v).then(v=>{v.name||(v.name=o.name),d(v)})}},n))),s.firstChild.replaceWith(f)});return s}function _(e){let t=e.url,o=e.file,r=e.cancelText,n=e.confirmText,i=e.onCancel,d=e.onConfirm,l=o.type.startsWith("video/")?c("video.quik-vid.quik-content",{src:t,controls:!0}):c("audio",{src:t,controls:!0});return c(".quik-content-wrapper",c(".quik-confirm-item",l),c("footer.quik-footer",c("button.quik-footer-btn",{onclick:i},r),c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(p){p.target.disabled=!0,d(o)}},n)))}var we=10;function Ce(e){let t=c("video.quik-vid.quik-content");return t.srcObject=e.recorder.liveSrc(),t.muted=!0,t.controls=!1,t.play(),t}function xe(e,t,o){let r=Date.now(),n=t*60,i=s=>`${Math.floor(s/60)}:${`00${s%60}`.slice(-2)} / ${t}:00`,d,l=c("span.quik-progress-bar",{style:"width: 0%"}),p=c("span.quik-duration",i(0)),u=c(".quik-progress",c("span.quik-progress-text",c("span.quik-filename",e),p),c("span.quik-progress-bar-wrapper",l));return d=setTimeout(function s(){let a=Math.floor((Date.now()-r)/1e3);if(p.textContent=i(a),l.style.width=`${Math.floor(a*100/n)}%`,a>=n){o();return}u.isConnected&&setTimeout(s,1e3)},1e3),u}function J(e){let t=e.onPickFiles,o=e.maxDuration||we,r=e.onCancel,n=e.type,i,d=c("p.quik-info.quik-content",`Waiting for your ${n==="takeaudio"?"microphone":"camera"}...`),l=c("footer.quik-footer",c("button.quik-footer-btn.quik-footer-btn-secondary",{onclick:r},"Cancel")),p=c(".quik-media",d,l),u=()=>!p.isConnected,s=a=>d.replaceWith(c("p.quik-error",a.toString()));return F({video:n!=="takeaudio",audio:n!=="takephoto",isDisposed:u}).then(a=>{let f=()=>{d.textContent="Generating preview...",i&&i.remove(),(n==="takephoto"?a.capturePhoto():a.endMediaCapture()).then(k=>t([k])).catch(s)};d.textContent=n==="takephoto"?"":`Ready to record. You can record up to ${o} minutes of ${n==="takeaudio"?"audio":"video"}.`,n!=="takeaudio"&&p.insertBefore(Ce({recorder:a,onPickFiles:t,onError:s}),d),l.appendChild(c("button.quik-footer-btn.quik-footer-btn-primary",{onclick(m){n==="takephoto"||i?(m.target.disabled=!0,f()):(a.beginMediaCapture(),i=xe("Recording...",o,f),d.textContent="",p.insertBefore(i,l),m.target.innerHTML="",m.target.append(x(),c("span","Stop recording")))}},n==="takephoto"?M():n==="takeaudio"?x():C(),n==="takephoto"?"Take Photo":"Begin Recording"))}).catch(s),p}function qe(e){e=w({sources:["filepicker","takephoto"]},e);let t,o=U(),r=[h(window,"keydown",a=>{(a.key==="Escape"||a.code==="Escape")&&d()}),h(document.body,"paste",a=>{a.clipboardData&&a.clipboardData.files&&a.clipboardData.files.length&&(a.preventDefault(),l(a.clipboardData.files))})],n=y(w({},e),{close:d,uploadFiles:s,onPickFiles:l,beginCaptureMedia:u,promise:o,root:void 0,uploader:void 0});n.root=W(n);function i(){b(n.root,R({onPickFiles:l,beginCaptureMedia:u,accept:n.accept,sources:n.sources}))}function d(){o.resolve(t),n.root.remove(),r.forEach(a=>a()),n.uploader&&(n.uploader.cancel(),n.uploader=void 0)}function l(a){let f=a.length===1?a[0]:void 0;if(f&&f.type!=="image/gif"&&!f.type.startsWith("image/svg")&&f.type.startsWith("image/")){let m=URL.createObjectURL(f);r.push(()=>URL.revokeObjectURL(m)),b(n.root,G(y(w({},e),{url:m,file:f,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>s([k])})));return}s(a)}function p(a){let f=a[0],m=URL.createObjectURL(f);r.push(()=>URL.revokeObjectURL(m)),b(n.root,_(y(w({},e),{url:m,file:f,cancelText:"Cancel",confirmText:"Accept & upload",onCancel:i,onConfirm:k=>s([k])})))}function u(a){b(n.root,J({type:a,onPickFiles:a==="takephoto"?l:p,onCancel:i,maxDuration:n.maxDuration}))}function s(a){if(e.customProgress)n.root.remove(),n.uploader=e.upload({files:a,onProgress(){}}),n.uploader.promise.then(f=>o.resolve(f)).catch(o.reject);else{let f=X();b(n.root,f),n.uploader=e.upload({files:a,onProgress(m,k){Y(f,m,k)}}),n.uploader.promise.then(m=>{t=m,setTimeout(d,250)}).catch(o.reject)}return n.uploader}return o.cancel=d,n}function K(e={}){let t=qe(e);return document.body.appendChild(t.root),t.promise}return ie(ye);})(); |
{ | ||
"name": "quikpik", | ||
"version": "0.0.32", | ||
"version": "0.0.33", | ||
"main": "./dist/quikpik-cjs.js", | ||
@@ -5,0 +5,0 @@ "types": "./types.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
157875
191