@copio/sdk 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/LICENSE +661 -0
  2. package/LICENSE-COMMERCIAL.md +43 -0
  3. package/README.md +155 -147
  4. package/THIRD_PARTY_NOTICES.md +416 -0
  5. package/dist/adapters/image/canvas2d-adapter.js +1 -1
  6. package/dist/adapters/image/index.js +1 -1
  7. package/dist/adapters/image/null-image-processor-adapter.js +1 -1
  8. package/dist/adapters/index.js +1 -1
  9. package/dist/adapters/indexeddb-adapter.js +1 -1
  10. package/dist/adapters/memory-adapter.js +1 -1
  11. package/dist/adapters/ocr/index.js +1 -1
  12. package/dist/adapters/ocr/null-ocr-adapter.js +1 -1
  13. package/dist/adapters/ocr/tesseract-wasm-adapter.js +1 -1
  14. package/dist/adapters/pdf/index.js +1 -1
  15. package/dist/adapters/pdf/null-pdf-adapter.js +1 -1
  16. package/dist/adapters/pdf/pdfkit-adapter.js +1 -1
  17. package/dist/adapters/storage/index.js +1 -1
  18. package/dist/adapters/storage/indexeddb-adapter.js +1 -1
  19. package/dist/adapters/storage/memory-adapter.js +1 -1
  20. package/dist/adapters/sync/index.js +1 -1
  21. package/dist/adapters/sync/null-sync-adapter.js +1 -1
  22. package/dist/adapters/sync/peerjs-adapter.js +1 -1
  23. package/dist/cdn.js +56 -1276
  24. package/dist/{chunk-A5G52Q2W.js → chunk-2AB5L3Y2.js} +2 -2
  25. package/dist/{chunk-DGGK5KEX.js → chunk-4ICUYKSR.js} +2 -2
  26. package/dist/{chunk-E7JYVRJA.js → chunk-5OTO5WFV.js} +2 -2
  27. package/dist/{chunk-N4R55VRR.js → chunk-6DSLE3AY.js} +1 -1
  28. package/dist/chunk-DIU5BGU5.js +2 -0
  29. package/dist/chunk-FAVTIE3M.js +8 -0
  30. package/dist/chunk-FFRDPFTS.js +1395 -0
  31. package/dist/chunk-FQRADJY6.js +2 -0
  32. package/dist/{chunk-N7Q34F2P.js → chunk-G5EUMLYT.js} +4 -4
  33. package/dist/{chunk-IUBYFIV6.js → chunk-GGERQ3CJ.js} +11 -11
  34. package/dist/chunk-IBF5HCYT.js +2 -0
  35. package/dist/{chunk-PVNRK4OH.js → chunk-J7HWZNIP.js} +2 -2
  36. package/dist/chunk-K4NR6OAC.js +2 -0
  37. package/dist/{chunk-SH4P4XSZ.js → chunk-KH5JE65X.js} +2 -2
  38. package/dist/chunk-L4OVZN23.js +2 -0
  39. package/dist/chunk-MEE2NNYB.js +2 -0
  40. package/dist/{chunk-KIMVF5UG.js → chunk-NEEWG3OP.js} +1 -1
  41. package/dist/chunk-NQW6FFN7.js +50 -0
  42. package/dist/{chunk-YHLOPPXM.js → chunk-O6FQFVKY.js} +1 -1
  43. package/dist/{chunk-B7HT2X67.js → chunk-U3V3VZGO.js} +2 -2
  44. package/dist/{chunk-HN3336JN.js → chunk-ULTSZWZO.js} +1 -1
  45. package/dist/{chunk-BKZEOOH4.js → chunk-WETG2JD7.js} +2 -2
  46. package/dist/{chunk-V2FP4EEH.js → chunk-YNY65JUJ.js} +1 -1
  47. package/dist/chunk-ZT72PD2C.js +2 -0
  48. package/dist/core.js +1 -1
  49. package/dist/custom-elements.json +464 -1812
  50. package/dist/export.js +1 -1
  51. package/dist/index.js +11 -19
  52. package/dist/ocr.js +1 -1
  53. package/dist/scanner.js +24 -1257
  54. package/dist/sync.js +1 -1
  55. package/dist/types/js/adapters/storage/blob-store.d.ts +48 -0
  56. package/dist/types/js/adapters/storage/index.d.ts +11 -4
  57. package/dist/types/js/adapters/storage/indexeddb-adapter.d.ts +46 -9
  58. package/dist/types/js/adapters/storage/memory-adapter.d.ts +7 -0
  59. package/dist/types/js/adapters/storage/opfs-adapter.d.ts +160 -0
  60. package/dist/types/js/adapters/storage/storage-port.d.ts +7 -0
  61. package/dist/types/js/routes/ocr/copio-doc-ocr-dialog.d.ts +0 -2
  62. package/dist/types/js/services/doc-repository.d.ts +1 -0
  63. package/dist/types/js/services/export-utils.d.ts +8 -12
  64. package/dist/types/js/services/ocr-service.d.ts +2 -1
  65. package/dist/types/js/utils/module-loader.d.ts +0 -6
  66. package/dist/types/js/utils/utils.d.ts +5 -3
  67. package/dist/types/sdk/core.d.ts +13 -2
  68. package/dist/types/sdk/elements.d.ts +0 -12
  69. package/dist/types/sdk/events.d.ts +4 -4
  70. package/dist/types/sdk/index.d.ts +3 -9
  71. package/dist/types/sdk/models.d.ts +66 -0
  72. package/dist/types/sdk/scanner.d.ts +2 -7
  73. package/dist/types/sdk/styles.d.ts +1 -1
  74. package/dist/types/sdk/version.d.ts +1 -1
  75. package/package.json +4 -3
  76. package/sdk/cdn.js +1 -0
  77. package/sdk/core.js +60 -0
  78. package/sdk/events.js +3 -2
  79. package/sdk/index.js +4 -9
  80. package/sdk/license.js +1 -0
  81. package/sdk/models.js +79 -3
  82. package/sdk/scanner.js +50 -19
  83. package/sdk/styles.js +12 -5
  84. package/sdk/sync.js +1 -0
  85. package/sdk/version.js +2 -1
  86. package/dist/chunk-36F637QU.js +0 -2
  87. package/dist/chunk-4JPEWIT4.js +0 -2
  88. package/dist/chunk-B2EK6INF.js +0 -2
  89. package/dist/chunk-B5BEYYR2.js +0 -8
  90. package/dist/chunk-G65H4ZTJ.js +0 -2
  91. package/dist/chunk-HS6GDZIS.js +0 -2
  92. package/dist/chunk-IZOWC74B.js +0 -2601
  93. package/dist/chunk-K6YP7EET.js +0 -8
  94. package/dist/chunk-LI54F6PA.js +0 -2
  95. package/dist/chunk-OI4WCW7E.js +0 -2
  96. package/dist/chunk-UCV3MQ6I.js +0 -33
  97. package/dist/chunk-XEN5VKAV.js +0 -19
  98. package/dist/types/js/components/copio-header.d.ts +0 -19
  99. package/dist/types/js/components/copio-loader.d.ts +0 -6
  100. package/dist/types/js/core/store.d.ts +0 -2
  101. package/dist/types/js/routes/add-edit/copio-add-edit-dialog.d.ts +0 -9
  102. package/dist/types/js/routes/doc/copio-carousel.d.ts +0 -43
  103. package/dist/types/js/routes/doc/copio-images.d.ts +0 -37
  104. package/dist/types/js/routes/home/copio-row.d.ts +0 -49
  105. package/dist/types/js/styles/cropper-styles.d.ts +0 -5
@@ -1,2601 +0,0 @@
1
- import{j as R,k as Bt,q as nt}from"./chunk-HS6GDZIS.js";import{a as re,b as O,c as K}from"./chunk-XEN5VKAV.js";import{a as It,b as ce,c as Tt,h as ue,i as Pt,j as Mt,k as at}from"./chunk-N7Q34F2P.js";import{a as Nt}from"./chunk-IUBYFIV6.js";import{a as Ce,b as st,d as Y}from"./chunk-V2FP4EEH.js";import{b as _t,e as Rt,h as Ot}from"./chunk-G65H4ZTJ.js";function zt(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(i);e&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,o)}return t}function Z(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?zt(Object(t),!0).forEach(function(o){uo(i,o,t[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):zt(Object(t)).forEach(function(o){Object.defineProperty(i,o,Object.getOwnPropertyDescriptor(t,o))})}return i}function He(i){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?He=function(e){return typeof e}:He=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},He(i)}function uo(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ee(){return ee=Object.assign||function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(i[o]=t[o])}return i},ee.apply(this,arguments)}function fo(i,e){if(i==null)return{};var t={},o=Object.keys(i),r,a;for(a=0;a<o.length;a++)r=o[a],!(e.indexOf(r)>=0)&&(t[r]=i[r]);return t}function go(i,e){if(i==null)return{};var t=fo(i,e),o,r;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(i);for(r=0;r<a.length;r++)o=a[r],!(e.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(i,o)&&(t[o]=i[o])}return t}var mo="1.15.6";function J(i){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(i)}var te=J(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Oe=J(/Edge/i),Lt=J(/firefox/i),Te=J(/safari/i)&&!J(/chrome/i)&&!J(/android/i),wt=J(/iP(ad|od|hone)/i),Xt=J(/chrome/i)&&J(/android/i),Gt={capture:!1,passive:!1};function E(i,e,t){i.addEventListener(e,t,!te&&Gt)}function w(i,e,t){i.removeEventListener(e,t,!te&&Gt)}function Ge(i,e){if(e){if(e[0]===">"&&(e=e.substring(1)),i)try{if(i.matches)return i.matches(e);if(i.msMatchesSelector)return i.msMatchesSelector(e);if(i.webkitMatchesSelector)return i.webkitMatchesSelector(e)}catch{return!1}return!1}}function Yt(i){return i.host&&i!==document&&i.host.nodeType?i.host:i.parentNode}function G(i,e,t,o){if(i){t=t||document;do{if(e!=null&&(e[0]===">"?i.parentNode===t&&Ge(i,e):Ge(i,e))||o&&i===t)return i;if(i===t)break}while(i=Yt(i))}return null}var Ft=/\s+/g;function q(i,e,t){if(i&&e)if(i.classList)i.classList[t?"add":"remove"](e);else{var o=(" "+i.className+" ").replace(Ft," ").replace(" "+e+" "," ");i.className=(o+(t?" "+e:"")).replace(Ft," ")}}function m(i,e,t){var o=i&&i.style;if(o){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(i,""):i.currentStyle&&(t=i.currentStyle),e===void 0?t:t[e];!(e in o)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),o[e]=t+(typeof t=="string"?"":"px")}}function ve(i,e){var t="";if(typeof i=="string")t=i;else do{var o=m(i,"transform");o&&o!=="none"&&(t=o+" "+t)}while(!e&&(i=i.parentNode));var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(t)}function Kt(i,e,t){if(i){var o=i.getElementsByTagName(e),r=0,a=o.length;if(t)for(;r<a;r++)t(o[r],r);return o}return[]}function V(){var i=document.scrollingElement;return i||document.documentElement}function _(i,e,t,o,r){if(!(!i.getBoundingClientRect&&i!==window)){var a,n,s,l,c,p,d;if(i!==window&&i.parentNode&&i!==V()?(a=i.getBoundingClientRect(),n=a.top,s=a.left,l=a.bottom,c=a.right,p=a.height,d=a.width):(n=0,s=0,l=window.innerHeight,c=window.innerWidth,p=window.innerHeight,d=window.innerWidth),(e||t)&&i!==window&&(r=r||i.parentNode,!te))do if(r&&r.getBoundingClientRect&&(m(r,"transform")!=="none"||t&&m(r,"position")!=="static")){var u=r.getBoundingClientRect();n-=u.top+parseInt(m(r,"border-top-width")),s-=u.left+parseInt(m(r,"border-left-width")),l=n+a.height,c=s+a.width;break}while(r=r.parentNode);if(o&&i!==window){var v=ve(r||i),f=v&&v.a,y=v&&v.d;v&&(n/=y,s/=f,d/=f,p/=y,l=n+p,c=s+d)}return{top:n,left:s,bottom:l,right:c,width:d,height:p}}}function $t(i,e,t){for(var o=se(i,!0),r=_(i)[e];o;){var a=_(o)[t],n=void 0;if(t==="top"||t==="left"?n=r>=a:n=r<=a,!n)return o;if(o===V())break;o=se(o,!1)}return!1}function xe(i,e,t,o){for(var r=0,a=0,n=i.children;a<n.length;){if(n[a].style.display!=="none"&&n[a]!==b.ghost&&(o||n[a]!==b.dragged)&&G(n[a],t.draggable,i,!1)){if(r===e)return n[a];r++}a++}return null}function Et(i,e){for(var t=i.lastElementChild;t&&(t===b.ghost||m(t,"display")==="none"||e&&!Ge(t,e));)t=t.previousElementSibling;return t||null}function U(i,e){var t=0;if(!i||!i.parentNode)return-1;for(;i=i.previousElementSibling;)i.nodeName.toUpperCase()!=="TEMPLATE"&&i!==b.clone&&(!e||Ge(i,e))&&t++;return t}function jt(i){var e=0,t=0,o=V();if(i)do{var r=ve(i),a=r.a,n=r.d;e+=i.scrollLeft*a,t+=i.scrollTop*n}while(i!==o&&(i=i.parentNode));return[e,t]}function bo(i,e){for(var t in i)if(i.hasOwnProperty(t)){for(var o in e)if(e.hasOwnProperty(o)&&e[o]===i[t][o])return Number(t)}return-1}function se(i,e){if(!i||!i.getBoundingClientRect)return V();var t=i,o=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var r=m(t);if(t.clientWidth<t.scrollWidth&&(r.overflowX=="auto"||r.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(r.overflowY=="auto"||r.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return V();if(o||e)return t;o=!0}}while(t=t.parentNode);return V()}function vo(i,e){if(i&&e)for(var t in e)e.hasOwnProperty(t)&&(i[t]=e[t]);return i}function lt(i,e){return Math.round(i.top)===Math.round(e.top)&&Math.round(i.left)===Math.round(e.left)&&Math.round(i.height)===Math.round(e.height)&&Math.round(i.width)===Math.round(e.width)}var Pe;function Vt(i,e){return function(){if(!Pe){var t=arguments,o=this;t.length===1?i.call(o,t[0]):i.apply(o,t),Pe=setTimeout(function(){Pe=void 0},e)}}}function xo(){clearTimeout(Pe),Pe=void 0}function Zt(i,e,t){i.scrollLeft+=e,i.scrollTop+=t}function Qt(i){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(i).cloneNode(!0):t?t(i).clone(!0)[0]:i.cloneNode(!0)}function Jt(i,e,t){var o={};return Array.from(i.children).forEach(function(r){var a,n,s,l;if(!(!G(r,e.draggable,i,!1)||r.animated||r===t)){var c=_(r);o.left=Math.min((a=o.left)!==null&&a!==void 0?a:1/0,c.left),o.top=Math.min((n=o.top)!==null&&n!==void 0?n:1/0,c.top),o.right=Math.max((s=o.right)!==null&&s!==void 0?s:-1/0,c.right),o.bottom=Math.max((l=o.bottom)!==null&&l!==void 0?l:-1/0,c.bottom)}}),o.width=o.right-o.left,o.height=o.bottom-o.top,o.x=o.left,o.y=o.top,o}var j="Sortable"+new Date().getTime();function yo(){var i=[],e;return{captureAnimationState:function(){if(i=[],!!this.options.animation){var o=[].slice.call(this.el.children);o.forEach(function(r){if(!(m(r,"display")==="none"||r===b.ghost)){i.push({target:r,rect:_(r)});var a=Z({},i[i.length-1].rect);if(r.thisAnimationDuration){var n=ve(r,!0);n&&(a.top-=n.f,a.left-=n.e)}r.fromRect=a}})}},addAnimationState:function(o){i.push(o)},removeAnimationState:function(o){i.splice(bo(i,{target:o}),1)},animateAll:function(o){var r=this;if(!this.options.animation){clearTimeout(e),typeof o=="function"&&o();return}var a=!1,n=0;i.forEach(function(s){var l=0,c=s.target,p=c.fromRect,d=_(c),u=c.prevFromRect,v=c.prevToRect,f=s.rect,y=ve(c,!0);y&&(d.top-=y.f,d.left-=y.e),c.toRect=d,c.thisAnimationDuration&&lt(u,d)&&!lt(p,d)&&(f.top-d.top)/(f.left-d.left)===(p.top-d.top)/(p.left-d.left)&&(l=Eo(f,u,v,r.options)),lt(d,p)||(c.prevFromRect=p,c.prevToRect=d,l||(l=r.options.animation),r.animate(c,f,d,l)),l&&(a=!0,n=Math.max(n,l),clearTimeout(c.animationResetTimer),c.animationResetTimer=setTimeout(function(){c.animationTime=0,c.prevFromRect=null,c.fromRect=null,c.prevToRect=null,c.thisAnimationDuration=null},l),c.thisAnimationDuration=l)}),clearTimeout(e),a?e=setTimeout(function(){typeof o=="function"&&o()},n):typeof o=="function"&&o(),i=[]},animate:function(o,r,a,n){if(n){m(o,"transition",""),m(o,"transform","");var s=ve(this.el),l=s&&s.a,c=s&&s.d,p=(r.left-a.left)/(l||1),d=(r.top-a.top)/(c||1);o.animatingX=!!p,o.animatingY=!!d,m(o,"transform","translate3d("+p+"px,"+d+"px,0)"),this.forRepaintDummy=wo(o),m(o,"transition","transform "+n+"ms"+(this.options.easing?" "+this.options.easing:"")),m(o,"transform","translate3d(0,0,0)"),typeof o.animated=="number"&&clearTimeout(o.animated),o.animated=setTimeout(function(){m(o,"transition",""),m(o,"transform",""),o.animated=!1,o.animatingX=!1,o.animatingY=!1},n)}}}}function wo(i){return i.offsetWidth}function Eo(i,e,t,o){return Math.sqrt(Math.pow(e.top-i.top,2)+Math.pow(e.left-i.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*o.animation}var fe=[],ct={initializeByDefault:!0},Be={mount:function(e){for(var t in ct)ct.hasOwnProperty(t)&&!(t in e)&&(e[t]=ct[t]);fe.forEach(function(o){if(o.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),fe.push(e)},pluginEvent:function(e,t,o){var r=this;this.eventCanceled=!1,o.cancel=function(){r.eventCanceled=!0};var a=e+"Global";fe.forEach(function(n){t[n.pluginName]&&(t[n.pluginName][a]&&t[n.pluginName][a](Z({sortable:t},o)),t.options[n.pluginName]&&t[n.pluginName][e]&&t[n.pluginName][e](Z({sortable:t},o)))})},initializePlugins:function(e,t,o,r){fe.forEach(function(s){var l=s.pluginName;if(!(!e.options[l]&&!s.initializeByDefault)){var c=new s(e,t,e.options);c.sortable=e,c.options=e.options,e[l]=c,ee(o,c.defaults)}});for(var a in e.options)if(e.options.hasOwnProperty(a)){var n=this.modifyOption(e,a,e.options[a]);typeof n<"u"&&(e.options[a]=n)}},getEventProperties:function(e,t){var o={};return fe.forEach(function(r){typeof r.eventProperties=="function"&&ee(o,r.eventProperties.call(t[r.pluginName],e))}),o},modifyOption:function(e,t,o){var r;return fe.forEach(function(a){e[a.pluginName]&&a.optionListeners&&typeof a.optionListeners[t]=="function"&&(r=a.optionListeners[t].call(e[a.pluginName],o))}),r}};function ko(i){var e=i.sortable,t=i.rootEl,o=i.name,r=i.targetEl,a=i.cloneEl,n=i.toEl,s=i.fromEl,l=i.oldIndex,c=i.newIndex,p=i.oldDraggableIndex,d=i.newDraggableIndex,u=i.originalEvent,v=i.putSortable,f=i.extraEventProperties;if(e=e||t&&t[j],!!e){var y,C=e.options,A="on"+o.charAt(0).toUpperCase()+o.substr(1);window.CustomEvent&&!te&&!Oe?y=new CustomEvent(o,{bubbles:!0,cancelable:!0}):(y=document.createEvent("Event"),y.initEvent(o,!0,!0)),y.to=n||t,y.from=s||t,y.item=r||t,y.clone=a,y.oldIndex=l,y.newIndex=c,y.oldDraggableIndex=p,y.newDraggableIndex=d,y.originalEvent=u,y.pullMode=v?v.lastPutMode:void 0;var k=Z(Z({},f),Be.getEventProperties(o,e));for(var D in k)y[D]=k[D];t&&t.dispatchEvent(y),C[A]&&C[A].call(e,y)}}var So=["evt"],$=function(e,t){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=o.evt,a=go(o,So);Be.pluginEvent.bind(b)(e,t,Z({dragEl:h,parentEl:P,ghostEl:x,rootEl:I,nextEl:he,lastDownEl:qe,cloneEl:T,cloneHidden:ne,dragStarted:De,putSortable:B,activeSortable:b.active,originalEvent:r,oldIndex:be,oldDraggableIndex:Me,newIndex:W,newDraggableIndex:ae,hideGhostForTarget:io,unhideGhostForTarget:ro,cloneNowHidden:function(){ne=!0},cloneNowShown:function(){ne=!1},dispatchSortableEvent:function(s){F({sortable:t,name:s,originalEvent:r})}},a))};function F(i){ko(Z({putSortable:B,cloneEl:T,targetEl:h,rootEl:I,oldIndex:be,oldDraggableIndex:Me,newIndex:W,newDraggableIndex:ae},i))}var h,P,x,I,he,qe,T,ne,be,W,Me,ae,Le,B,me=!1,Ye=!1,Ke=[],de,X,dt,pt,Ht,qt,De,ge,_e,Re=!1,Fe=!1,We,L,ht=[],bt=!1,Ve=[],Qe=typeof document<"u",$e=wt,Wt=Oe||te?"cssFloat":"float",Co=Qe&&!Xt&&!wt&&"draggable"in document.createElement("div"),eo=(function(){if(Qe){if(te)return!1;var i=document.createElement("x");return i.style.cssText="pointer-events:auto",i.style.pointerEvents==="auto"}})(),to=function(e,t){var o=m(e),r=parseInt(o.width)-parseInt(o.paddingLeft)-parseInt(o.paddingRight)-parseInt(o.borderLeftWidth)-parseInt(o.borderRightWidth),a=xe(e,0,t),n=xe(e,1,t),s=a&&m(a),l=n&&m(n),c=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+_(a).width,p=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+_(n).width;if(o.display==="flex")return o.flexDirection==="column"||o.flexDirection==="column-reverse"?"vertical":"horizontal";if(o.display==="grid")return o.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(a&&s.float&&s.float!=="none"){var d=s.float==="left"?"left":"right";return n&&(l.clear==="both"||l.clear===d)?"vertical":"horizontal"}return a&&(s.display==="block"||s.display==="flex"||s.display==="table"||s.display==="grid"||c>=r&&o[Wt]==="none"||n&&o[Wt]==="none"&&c+p>r)?"vertical":"horizontal"},Do=function(e,t,o){var r=o?e.left:e.top,a=o?e.right:e.bottom,n=o?e.width:e.height,s=o?t.left:t.top,l=o?t.right:t.bottom,c=o?t.width:t.height;return r===s||a===l||r+n/2===s+c/2},Ao=function(e,t){var o;return Ke.some(function(r){var a=r[j].options.emptyInsertThreshold;if(!(!a||Et(r))){var n=_(r),s=e>=n.left-a&&e<=n.right+a,l=t>=n.top-a&&t<=n.bottom+a;if(s&&l)return o=r}}),o},oo=function(e){function t(a,n){return function(s,l,c,p){var d=s.options.group.name&&l.options.group.name&&s.options.group.name===l.options.group.name;if(a==null&&(n||d))return!0;if(a==null||a===!1)return!1;if(n&&a==="clone")return a;if(typeof a=="function")return t(a(s,l,c,p),n)(s,l,c,p);var u=(n?s:l).options.group.name;return a===!0||typeof a=="string"&&a===u||a.join&&a.indexOf(u)>-1}}var o={},r=e.group;(!r||He(r)!="object")&&(r={name:r}),o.name=r.name,o.checkPull=t(r.pull,!0),o.checkPut=t(r.put),o.revertClone=r.revertClone,e.group=o},io=function(){!eo&&x&&m(x,"display","none")},ro=function(){!eo&&x&&m(x,"display","")};Qe&&!Xt&&document.addEventListener("click",function(i){if(Ye)return i.preventDefault(),i.stopPropagation&&i.stopPropagation(),i.stopImmediatePropagation&&i.stopImmediatePropagation(),Ye=!1,!1},!0);var pe=function(e){if(h){e=e.touches?e.touches[0]:e;var t=Ao(e.clientX,e.clientY);if(t){var o={};for(var r in e)e.hasOwnProperty(r)&&(o[r]=e[r]);o.target=o.rootEl=t,o.preventDefault=void 0,o.stopPropagation=void 0,t[j]._onDragOver(o)}}},Io=function(e){h&&h.parentNode[j]._isOutsideThisEl(e.target)};function b(i,e){if(!(i&&i.nodeType&&i.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(i));this.el=i,this.options=e=ee({},e),i[j]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(i.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return to(i,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(n,s){n.setData("Text",s.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:b.supportPointer!==!1&&"PointerEvent"in window&&(!Te||wt),emptyInsertThreshold:5};Be.initializePlugins(this,i,t);for(var o in t)!(o in e)&&(e[o]=t[o]);oo(e);for(var r in this)r.charAt(0)==="_"&&typeof this[r]=="function"&&(this[r]=this[r].bind(this));this.nativeDraggable=e.forceFallback?!1:Co,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?E(i,"pointerdown",this._onTapStart):(E(i,"mousedown",this._onTapStart),E(i,"touchstart",this._onTapStart)),this.nativeDraggable&&(E(i,"dragover",this),E(i,"dragenter",this)),Ke.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),ee(this,yo())}b.prototype={constructor:b,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(ge=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,h):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,o=this.el,r=this.options,a=r.preventOnFilter,n=e.type,s=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,l=(s||e).target,c=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,p=r.filter;if(No(o),!h&&!(/mousedown|pointerdown/.test(n)&&e.button!==0||r.disabled)&&!c.isContentEditable&&!(!this.nativeDraggable&&Te&&l&&l.tagName.toUpperCase()==="SELECT")&&(l=G(l,r.draggable,o,!1),!(l&&l.animated)&&qe!==l)){if(be=U(l),Me=U(l,r.draggable),typeof p=="function"){if(p.call(this,e,l,this)){F({sortable:t,rootEl:c,name:"filter",targetEl:l,toEl:o,fromEl:o}),$("filter",t,{evt:e}),a&&e.preventDefault();return}}else if(p&&(p=p.split(",").some(function(d){if(d=G(c,d.trim(),o,!1),d)return F({sortable:t,rootEl:d,name:"filter",targetEl:l,fromEl:o,toEl:o}),$("filter",t,{evt:e}),!0}),p)){a&&e.preventDefault();return}r.handle&&!G(c,r.handle,o,!1)||this._prepareDragStart(e,s,l)}}},_prepareDragStart:function(e,t,o){var r=this,a=r.el,n=r.options,s=a.ownerDocument,l;if(o&&!h&&o.parentNode===a){var c=_(o);if(I=a,h=o,P=h.parentNode,he=h.nextSibling,qe=o,Le=n.group,b.dragged=h,de={target:h,clientX:(t||e).clientX,clientY:(t||e).clientY},Ht=de.clientX-c.left,qt=de.clientY-c.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,h.style["will-change"]="all",l=function(){if($("delayEnded",r,{evt:e}),b.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!Lt&&r.nativeDraggable&&(h.draggable=!0),r._triggerDragStart(e,t),F({sortable:r,name:"choose",originalEvent:e}),q(h,n.chosenClass,!0)},n.ignore.split(",").forEach(function(p){Kt(h,p.trim(),ut)}),E(s,"dragover",pe),E(s,"mousemove",pe),E(s,"touchmove",pe),n.supportPointer?(E(s,"pointerup",r._onDrop),!this.nativeDraggable&&E(s,"pointercancel",r._onDrop)):(E(s,"mouseup",r._onDrop),E(s,"touchend",r._onDrop),E(s,"touchcancel",r._onDrop)),Lt&&this.nativeDraggable&&(this.options.touchStartThreshold=4,h.draggable=!0),$("delayStart",this,{evt:e}),n.delay&&(!n.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(Oe||te))){if(b.eventCanceled){this._onDrop();return}n.supportPointer?(E(s,"pointerup",r._disableDelayedDrag),E(s,"pointercancel",r._disableDelayedDrag)):(E(s,"mouseup",r._disableDelayedDrag),E(s,"touchend",r._disableDelayedDrag),E(s,"touchcancel",r._disableDelayedDrag)),E(s,"mousemove",r._delayedDragTouchMoveHandler),E(s,"touchmove",r._delayedDragTouchMoveHandler),n.supportPointer&&E(s,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(l,n.delay)}else l()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){h&&ut(h),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;w(e,"mouseup",this._disableDelayedDrag),w(e,"touchend",this._disableDelayedDrag),w(e,"touchcancel",this._disableDelayedDrag),w(e,"pointerup",this._disableDelayedDrag),w(e,"pointercancel",this._disableDelayedDrag),w(e,"mousemove",this._delayedDragTouchMoveHandler),w(e,"touchmove",this._delayedDragTouchMoveHandler),w(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?E(document,"pointermove",this._onTouchMove):t?E(document,"touchmove",this._onTouchMove):E(document,"mousemove",this._onTouchMove):(E(h,"dragend",this),E(I,"dragstart",this._onDragStart));try{document.selection?Ue(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(me=!1,I&&h){$("dragStarted",this,{evt:t}),this.nativeDraggable&&E(document,"dragover",Io);var o=this.options;!e&&q(h,o.dragClass,!1),q(h,o.ghostClass,!0),b.active=this,e&&this._appendGhost(),F({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(X){this._lastX=X.clientX,this._lastY=X.clientY,io();for(var e=document.elementFromPoint(X.clientX,X.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(X.clientX,X.clientY),e!==t);)t=e;if(h.parentNode[j]._isOutsideThisEl(e),t)do{if(t[j]){var o=void 0;if(o=t[j]._onDragOver({clientX:X.clientX,clientY:X.clientY,target:e,rootEl:t}),o&&!this.options.dragoverBubble)break}e=t}while(t=Yt(t));ro()}},_onTouchMove:function(e){if(de){var t=this.options,o=t.fallbackTolerance,r=t.fallbackOffset,a=e.touches?e.touches[0]:e,n=x&&ve(x,!0),s=x&&n&&n.a,l=x&&n&&n.d,c=$e&&L&&jt(L),p=(a.clientX-de.clientX+r.x)/(s||1)+(c?c[0]-ht[0]:0)/(s||1),d=(a.clientY-de.clientY+r.y)/(l||1)+(c?c[1]-ht[1]:0)/(l||1);if(!b.active&&!me){if(o&&Math.max(Math.abs(a.clientX-this._lastX),Math.abs(a.clientY-this._lastY))<o)return;this._onDragStart(e,!0)}if(x){n?(n.e+=p-(dt||0),n.f+=d-(pt||0)):n={a:1,b:0,c:0,d:1,e:p,f:d};var u="matrix(".concat(n.a,",").concat(n.b,",").concat(n.c,",").concat(n.d,",").concat(n.e,",").concat(n.f,")");m(x,"webkitTransform",u),m(x,"mozTransform",u),m(x,"msTransform",u),m(x,"transform",u),dt=p,pt=d,X=a}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!x){var e=this.options.fallbackOnBody?document.body:I,t=_(h,!0,$e,!0,e),o=this.options;if($e){for(L=e;m(L,"position")==="static"&&m(L,"transform")==="none"&&L!==document;)L=L.parentNode;L!==document.body&&L!==document.documentElement?(L===document&&(L=V()),t.top+=L.scrollTop,t.left+=L.scrollLeft):L=V(),ht=jt(L)}x=h.cloneNode(!0),q(x,o.ghostClass,!1),q(x,o.fallbackClass,!0),q(x,o.dragClass,!0),m(x,"transition",""),m(x,"transform",""),m(x,"box-sizing","border-box"),m(x,"margin",0),m(x,"top",t.top),m(x,"left",t.left),m(x,"width",t.width),m(x,"height",t.height),m(x,"opacity","0.8"),m(x,"position",$e?"absolute":"fixed"),m(x,"zIndex","100000"),m(x,"pointerEvents","none"),b.ghost=x,e.appendChild(x),m(x,"transform-origin",Ht/parseInt(x.style.width)*100+"% "+qt/parseInt(x.style.height)*100+"%")}},_onDragStart:function(e,t){var o=this,r=e.dataTransfer,a=o.options;if($("dragStart",this,{evt:e}),b.eventCanceled){this._onDrop();return}$("setupClone",this),b.eventCanceled||(T=Qt(h),T.removeAttribute("id"),T.draggable=!1,T.style["will-change"]="",this._hideClone(),q(T,this.options.chosenClass,!1),b.clone=T),o.cloneId=Ue(function(){$("clone",o),!b.eventCanceled&&(o.options.removeCloneOnHide||I.insertBefore(T,h),o._hideClone(),F({sortable:o,name:"clone"}))}),!t&&q(h,a.dragClass,!0),t?(Ye=!0,o._loopId=setInterval(o._emulateDragOver,50)):(w(document,"mouseup",o._onDrop),w(document,"touchend",o._onDrop),w(document,"touchcancel",o._onDrop),r&&(r.effectAllowed="move",a.setData&&a.setData.call(o,r,h)),E(document,"drop",o),m(h,"transform","translateZ(0)")),me=!0,o._dragStartId=Ue(o._dragStarted.bind(o,t,e)),E(document,"selectstart",o),De=!0,window.getSelection().removeAllRanges(),Te&&m(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,o=e.target,r,a,n,s=this.options,l=s.group,c=b.active,p=Le===l,d=s.sort,u=B||c,v,f=this,y=!1;if(bt)return;function C(Se,po){$(Se,f,Z({evt:e,isOwner:p,axis:v?"vertical":"horizontal",revert:n,dragRect:r,targetRect:a,canSort:d,fromSortable:u,target:o,completed:k,onMove:function(At,ho){return je(I,t,h,r,At,_(At),e,ho)},changed:D},po))}function A(){C("dragOverAnimationCapture"),f.captureAnimationState(),f!==u&&u.captureAnimationState()}function k(Se){return C("dragOverCompleted",{insertion:Se}),Se&&(p?c._hideClone():c._showClone(f),f!==u&&(q(h,B?B.options.ghostClass:c.options.ghostClass,!1),q(h,s.ghostClass,!0)),B!==f&&f!==b.active?B=f:f===b.active&&B&&(B=null),u===f&&(f._ignoreWhileAnimating=o),f.animateAll(function(){C("dragOverAnimationComplete"),f._ignoreWhileAnimating=null}),f!==u&&(u.animateAll(),u._ignoreWhileAnimating=null)),(o===h&&!h.animated||o===t&&!o.animated)&&(ge=null),!s.dragoverBubble&&!e.rootEl&&o!==document&&(h.parentNode[j]._isOutsideThisEl(e.target),!Se&&pe(e)),!s.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),y=!0}function D(){W=U(h),ae=U(h,s.draggable),F({sortable:f,name:"change",toEl:t,newIndex:W,newDraggableIndex:ae,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),o=G(o,s.draggable,t,!0),C("dragOver"),b.eventCanceled)return y;if(h.contains(e.target)||o.animated&&o.animatingX&&o.animatingY||f._ignoreWhileAnimating===o)return k(!1);if(Ye=!1,c&&!s.disabled&&(p?d||(n=P!==I):B===this||(this.lastPutMode=Le.checkPull(this,c,h,e))&&l.checkPut(this,c,h,e))){if(v=this._getDirection(e,o)==="vertical",r=_(h),C("dragOverValid"),b.eventCanceled)return y;if(n)return P=I,A(),this._hideClone(),C("revert"),b.eventCanceled||(he?I.insertBefore(h,he):I.appendChild(h)),k(!0);var g=Et(t,s.draggable);if(!g||_o(e,v,this)&&!g.animated){if(g===h)return k(!1);if(g&&t===e.target&&(o=g),o&&(a=_(o)),je(I,t,h,r,o,a,e,!!o)!==!1)return A(),g&&g.nextSibling?t.insertBefore(h,g.nextSibling):t.appendChild(h),P=t,D(),k(!0)}else if(g&&Mo(e,v,this)){var S=xe(t,0,s,!0);if(S===h)return k(!1);if(o=S,a=_(o),je(I,t,h,r,o,a,e,!1)!==!1)return A(),t.insertBefore(h,S),P=t,D(),k(!0)}else if(o.parentNode===t){a=_(o);var N=0,z,ye=h.parentNode!==t,H=!Do(h.animated&&h.toRect||r,o.animated&&o.toRect||a,v),we=v?"top":"left",oe=$t(o,"top","top")||$t(h,"top","top"),Ee=oe?oe.scrollTop:void 0;ge!==o&&(z=a[we],Re=!1,Fe=!H&&s.invertSwap||ye),N=Ro(e,o,a,v,H?1:s.swapThreshold,s.invertedSwapThreshold==null?s.swapThreshold:s.invertedSwapThreshold,Fe,ge===o);var Q;if(N!==0){var le=U(h);do le-=N,Q=P.children[le];while(Q&&(m(Q,"display")==="none"||Q===x))}if(N===0||Q===o)return k(!1);ge=o,_e=N;var ke=o.nextElementSibling,ie=!1;ie=N===1;var ze=je(I,t,h,r,o,a,e,ie);if(ze!==!1)return(ze===1||ze===-1)&&(ie=ze===1),bt=!0,setTimeout(Po,30),A(),ie&&!ke?t.appendChild(h):o.parentNode.insertBefore(h,ie?ke:o),oe&&Zt(oe,0,Ee-oe.scrollTop),P=h.parentNode,z!==void 0&&!Fe&&(We=Math.abs(z-_(o)[we])),D(),k(!0)}if(t.contains(h))return k(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){w(document,"mousemove",this._onTouchMove),w(document,"touchmove",this._onTouchMove),w(document,"pointermove",this._onTouchMove),w(document,"dragover",pe),w(document,"mousemove",pe),w(document,"touchmove",pe)},_offUpEvents:function(){var e=this.el.ownerDocument;w(e,"mouseup",this._onDrop),w(e,"touchend",this._onDrop),w(e,"pointerup",this._onDrop),w(e,"pointercancel",this._onDrop),w(e,"touchcancel",this._onDrop),w(document,"selectstart",this)},_onDrop:function(e){var t=this.el,o=this.options;if(W=U(h),ae=U(h,o.draggable),$("drop",this,{evt:e}),P=h&&h.parentNode,W=U(h),ae=U(h,o.draggable),b.eventCanceled){this._nulling();return}me=!1,Fe=!1,Re=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),vt(this.cloneId),vt(this._dragStartId),this.nativeDraggable&&(w(document,"drop",this),w(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),Te&&m(document.body,"user-select",""),m(h,"transform",""),e&&(De&&(e.cancelable&&e.preventDefault(),!o.dropBubble&&e.stopPropagation()),x&&x.parentNode&&x.parentNode.removeChild(x),(I===P||B&&B.lastPutMode!=="clone")&&T&&T.parentNode&&T.parentNode.removeChild(T),h&&(this.nativeDraggable&&w(h,"dragend",this),ut(h),h.style["will-change"]="",De&&!me&&q(h,B?B.options.ghostClass:this.options.ghostClass,!1),q(h,this.options.chosenClass,!1),F({sortable:this,name:"unchoose",toEl:P,newIndex:null,newDraggableIndex:null,originalEvent:e}),I!==P?(W>=0&&(F({rootEl:P,name:"add",toEl:P,fromEl:I,originalEvent:e}),F({sortable:this,name:"remove",toEl:P,originalEvent:e}),F({rootEl:P,name:"sort",toEl:P,fromEl:I,originalEvent:e}),F({sortable:this,name:"sort",toEl:P,originalEvent:e})),B&&B.save()):W!==be&&W>=0&&(F({sortable:this,name:"update",toEl:P,originalEvent:e}),F({sortable:this,name:"sort",toEl:P,originalEvent:e})),b.active&&((W==null||W===-1)&&(W=be,ae=Me),F({sortable:this,name:"end",toEl:P,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){$("nulling",this),I=h=P=x=he=T=qe=ne=de=X=De=W=ae=be=Me=ge=_e=B=Le=b.dragged=b.ghost=b.clone=b.active=null,Ve.forEach(function(e){e.checked=!0}),Ve.length=dt=pt=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":h&&(this._onDragOver(e),To(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,o=this.el.children,r=0,a=o.length,n=this.options;r<a;r++)t=o[r],G(t,n.draggable,this.el,!1)&&e.push(t.getAttribute(n.dataIdAttr)||Bo(t));return e},sort:function(e,t){var o={},r=this.el;this.toArray().forEach(function(a,n){var s=r.children[n];G(s,this.options.draggable,r,!1)&&(o[a]=s)},this),t&&this.captureAnimationState(),e.forEach(function(a){o[a]&&(r.removeChild(o[a]),r.appendChild(o[a]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return G(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var o=this.options;if(t===void 0)return o[e];var r=Be.modifyOption(this,e,t);typeof r<"u"?o[e]=r:o[e]=t,e==="group"&&oo(o)},destroy:function(){$("destroy",this);var e=this.el;e[j]=null,w(e,"mousedown",this._onTapStart),w(e,"touchstart",this._onTapStart),w(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(w(e,"dragover",this),w(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Ke.splice(Ke.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!ne){if($("hideClone",this),b.eventCanceled)return;m(T,"display","none"),this.options.removeCloneOnHide&&T.parentNode&&T.parentNode.removeChild(T),ne=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(ne){if($("showClone",this),b.eventCanceled)return;h.parentNode==I&&!this.options.group.revertClone?I.insertBefore(T,h):he?I.insertBefore(T,he):I.appendChild(T),this.options.group.revertClone&&this.animate(h,T),m(T,"display",""),ne=!1}}};function To(i){i.dataTransfer&&(i.dataTransfer.dropEffect="move"),i.cancelable&&i.preventDefault()}function je(i,e,t,o,r,a,n,s){var l,c=i[j],p=c.options.onMove,d;return window.CustomEvent&&!te&&!Oe?l=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(l=document.createEvent("Event"),l.initEvent("move",!0,!0)),l.to=e,l.from=i,l.dragged=t,l.draggedRect=o,l.related=r||e,l.relatedRect=a||_(e),l.willInsertAfter=s,l.originalEvent=n,i.dispatchEvent(l),p&&(d=p.call(c,l,n)),d}function ut(i){i.draggable=!1}function Po(){bt=!1}function Mo(i,e,t){var o=_(xe(t.el,0,t.options,!0)),r=Jt(t.el,t.options,x),a=10;return e?i.clientX<r.left-a||i.clientY<o.top&&i.clientX<o.right:i.clientY<r.top-a||i.clientY<o.bottom&&i.clientX<o.left}function _o(i,e,t){var o=_(Et(t.el,t.options.draggable)),r=Jt(t.el,t.options,x),a=10;return e?i.clientX>r.right+a||i.clientY>o.bottom&&i.clientX>o.left:i.clientY>r.bottom+a||i.clientX>o.right&&i.clientY>o.top}function Ro(i,e,t,o,r,a,n,s){var l=o?i.clientY:i.clientX,c=o?t.height:t.width,p=o?t.top:t.left,d=o?t.bottom:t.right,u=!1;if(!n){if(s&&We<c*r){if(!Re&&(_e===1?l>p+c*a/2:l<d-c*a/2)&&(Re=!0),Re)u=!0;else if(_e===1?l<p+We:l>d-We)return-_e}else if(l>p+c*(1-r)/2&&l<d-c*(1-r)/2)return Oo(e)}return u=u||n,u&&(l<p+c*a/2||l>d-c*a/2)?l>p+c/2?1:-1:0}function Oo(i){return U(h)<U(i)?1:-1}function Bo(i){for(var e=i.tagName+i.className+i.src+i.href+i.textContent,t=e.length,o=0;t--;)o+=e.charCodeAt(t);return o.toString(36)}function No(i){Ve.length=0;for(var e=i.getElementsByTagName("input"),t=e.length;t--;){var o=e[t];o.checked&&Ve.push(o)}}function Ue(i){return setTimeout(i,0)}function vt(i){return clearTimeout(i)}Qe&&E(document,"touchmove",function(i){(b.active||me)&&i.cancelable&&i.preventDefault()});b.utils={on:E,off:w,css:m,find:Kt,is:function(e,t){return!!G(e,t,e,!1)},extend:vo,throttle:Vt,closest:G,toggleClass:q,clone:Qt,index:U,nextTick:Ue,cancelNextTick:vt,detectDirection:to,getChild:xe,expando:j};b.get=function(i){return i[j]};b.mount=function(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(o){if(!o.prototype||!o.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(o));o.utils&&(b.utils=Z(Z({},b.utils),o.utils)),Be.mount(o)})};b.create=function(i,e){return new b(i,e)};b.version=mo;var M=[],Ae,xt,yt=!1,ft,gt,Ze,Ie;function zo(){function i(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return i.prototype={dragStarted:function(t){var o=t.originalEvent;this.sortable.nativeDraggable?E(document,"dragover",this._handleAutoScroll):this.options.supportPointer?E(document,"pointermove",this._handleFallbackAutoScroll):o.touches?E(document,"touchmove",this._handleFallbackAutoScroll):E(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var o=t.originalEvent;!this.options.dragOverBubble&&!o.rootEl&&this._handleAutoScroll(o)},drop:function(){this.sortable.nativeDraggable?w(document,"dragover",this._handleAutoScroll):(w(document,"pointermove",this._handleFallbackAutoScroll),w(document,"touchmove",this._handleFallbackAutoScroll),w(document,"mousemove",this._handleFallbackAutoScroll)),Ut(),Xe(),xo()},nulling:function(){Ze=xt=Ae=yt=Ie=ft=gt=null,M.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,o){var r=this,a=(t.touches?t.touches[0]:t).clientX,n=(t.touches?t.touches[0]:t).clientY,s=document.elementFromPoint(a,n);if(Ze=t,o||this.options.forceAutoScrollFallback||Oe||te||Te){mt(t,this.options,s,o);var l=se(s,!0);yt&&(!Ie||a!==ft||n!==gt)&&(Ie&&Ut(),Ie=setInterval(function(){var c=se(document.elementFromPoint(a,n),!0);c!==l&&(l=c,Xe()),mt(t,r.options,c,o)},10),ft=a,gt=n)}else{if(!this.options.bubbleScroll||se(s,!0)===V()){Xe();return}mt(t,this.options,se(s,!1),!1)}}},ee(i,{pluginName:"scroll",initializeByDefault:!0})}function Xe(){M.forEach(function(i){clearInterval(i.pid)}),M=[]}function Ut(){clearInterval(Ie)}var mt=Vt(function(i,e,t,o){if(e.scroll){var r=(i.touches?i.touches[0]:i).clientX,a=(i.touches?i.touches[0]:i).clientY,n=e.scrollSensitivity,s=e.scrollSpeed,l=V(),c=!1,p;xt!==t&&(xt=t,Xe(),Ae=e.scroll,p=e.scrollFn,Ae===!0&&(Ae=se(t,!0)));var d=0,u=Ae;do{var v=u,f=_(v),y=f.top,C=f.bottom,A=f.left,k=f.right,D=f.width,g=f.height,S=void 0,N=void 0,z=v.scrollWidth,ye=v.scrollHeight,H=m(v),we=v.scrollLeft,oe=v.scrollTop;v===l?(S=D<z&&(H.overflowX==="auto"||H.overflowX==="scroll"||H.overflowX==="visible"),N=g<ye&&(H.overflowY==="auto"||H.overflowY==="scroll"||H.overflowY==="visible")):(S=D<z&&(H.overflowX==="auto"||H.overflowX==="scroll"),N=g<ye&&(H.overflowY==="auto"||H.overflowY==="scroll"));var Ee=S&&(Math.abs(k-r)<=n&&we+D<z)-(Math.abs(A-r)<=n&&!!we),Q=N&&(Math.abs(C-a)<=n&&oe+g<ye)-(Math.abs(y-a)<=n&&!!oe);if(!M[d])for(var le=0;le<=d;le++)M[le]||(M[le]={});(M[d].vx!=Ee||M[d].vy!=Q||M[d].el!==v)&&(M[d].el=v,M[d].vx=Ee,M[d].vy=Q,clearInterval(M[d].pid),(Ee!=0||Q!=0)&&(c=!0,M[d].pid=setInterval(function(){o&&this.layer===0&&b.active._onTouchMove(Ze);var ke=M[this.layer].vy?M[this.layer].vy*s:0,ie=M[this.layer].vx?M[this.layer].vx*s:0;typeof p=="function"&&p.call(b.dragged.parentNode[j],ie,ke,i,Ze,M[this.layer].el)!=="continue"||Zt(M[this.layer].el,ie,ke)}.bind({layer:d}),24))),d++}while(e.bubbleScroll&&u!==l&&(u=se(u,!1)));yt=c}},30),ao=function(e){var t=e.originalEvent,o=e.putSortable,r=e.dragEl,a=e.activeSortable,n=e.dispatchSortableEvent,s=e.hideGhostForTarget,l=e.unhideGhostForTarget;if(t){var c=o||a;s();var p=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,d=document.elementFromPoint(p.clientX,p.clientY);l(),c&&!c.el.contains(d)&&(n("spill"),this.onSpill({dragEl:r,putSortable:o}))}};function kt(){}kt.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,o=e.putSortable;this.sortable.captureAnimationState(),o&&o.captureAnimationState();var r=xe(this.sortable.el,this.startIndex,this.options);r?this.sortable.el.insertBefore(t,r):this.sortable.el.appendChild(t),this.sortable.animateAll(),o&&o.animateAll()},drop:ao};ee(kt,{pluginName:"revertOnSpill"});function St(){}St.prototype={onSpill:function(e){var t=e.dragEl,o=e.putSortable,r=o||this.sortable;r.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),r.animateAll()},drop:ao};ee(St,{pluginName:"removeOnSpill"});b.mount(new zo);b.mount(St,kt);var no=b;var so=`
2
- .cropper-container {
3
- direction: ltr;
4
- font-size: 0;
5
- line-height: 0;
6
- position: relative;
7
- -ms-touch-action: none;
8
- touch-action: none;
9
- -webkit-user-select: none;
10
- -moz-user-select: none;
11
- -ms-user-select: none;
12
- user-select: none;
13
- }
14
-
15
- .cropper-container img {
16
- display: block;
17
- height: 100%;
18
- image-orientation: 0deg;
19
- max-height: none !important;
20
- max-width: none !important;
21
- min-height: 0 !important;
22
- min-width: 0 !important;
23
- width: 100%;
24
- }
25
-
26
- .cropper-wrap-box,
27
- .cropper-canvas,
28
- .cropper-drag-box,
29
- .cropper-crop-box,
30
- .cropper-modal {
31
- bottom: 0;
32
- left: 0;
33
- position: absolute;
34
- right: 0;
35
- top: 0;
36
- }
37
-
38
- .cropper-wrap-box,
39
- .cropper-canvas {
40
- overflow: hidden;
41
- }
42
-
43
- .cropper-drag-box {
44
- background-color: #fff;
45
- opacity: 0;
46
- }
47
-
48
- .cropper-modal {
49
- background-color: #000;
50
- opacity: 0.5;
51
- }
52
-
53
- .cropper-view-box {
54
- display: block;
55
- height: 100%;
56
- outline-color: rgba(51, 153, 255, 0.75);
57
- outline: 1px solid #39f;
58
- overflow: hidden;
59
- width: 100%;
60
- }
61
-
62
- .cropper-dashed {
63
- border: 0 dashed #eee;
64
- display: block;
65
- opacity: 0.5;
66
- position: absolute;
67
- }
68
-
69
- .cropper-dashed.dashed-h {
70
- border-bottom-width: 1px;
71
- border-top-width: 1px;
72
- height: 33.33333%;
73
- left: 0;
74
- top: 33.33333%;
75
- width: 100%;
76
- }
77
-
78
- .cropper-dashed.dashed-v {
79
- border-left-width: 1px;
80
- border-right-width: 1px;
81
- height: 100%;
82
- left: 33.33333%;
83
- top: 0;
84
- width: 33.33333%;
85
- }
86
-
87
- .cropper-center {
88
- display: block;
89
- height: 0;
90
- left: 50%;
91
- opacity: 0.75;
92
- position: absolute;
93
- top: 50%;
94
- width: 0;
95
- }
96
-
97
- .cropper-center:before,
98
- .cropper-center:after {
99
- background-color: #eee;
100
- content: ' ';
101
- display: block;
102
- position: absolute;
103
- }
104
-
105
- .cropper-center:before {
106
- height: 1px;
107
- left: -3px;
108
- top: 0;
109
- width: 7px;
110
- }
111
-
112
- .cropper-center:after {
113
- height: 7px;
114
- left: 0;
115
- top: -3px;
116
- width: 1px;
117
- }
118
-
119
- .cropper-face,
120
- .cropper-line,
121
- .cropper-point {
122
- display: block;
123
- height: 100%;
124
- opacity: 0.1;
125
- position: absolute;
126
- width: 100%;
127
- }
128
-
129
- .cropper-face {
130
- background-color: #fff;
131
- left: 0;
132
- top: 0;
133
- }
134
-
135
- .cropper-line {
136
- background-color: #39f;
137
- }
138
-
139
- .cropper-line.line-e {
140
- cursor: ew-resize;
141
- right: -3px;
142
- top: 0;
143
- width: 5px;
144
- }
145
-
146
- .cropper-line.line-n {
147
- cursor: ns-resize;
148
- height: 5px;
149
- left: 0;
150
- top: -3px;
151
- }
152
-
153
- .cropper-line.line-w {
154
- cursor: ew-resize;
155
- left: -3px;
156
- top: 0;
157
- width: 5px;
158
- }
159
-
160
- .cropper-line.line-s {
161
- bottom: -3px;
162
- cursor: ns-resize;
163
- height: 5px;
164
- left: 0;
165
- }
166
-
167
- .cropper-point {
168
- width: var(--copio-crop-handle-hit, 48px);
169
- height: var(--copio-crop-handle-hit, 48px);
170
- min-width: 44px;
171
- min-height: 44px;
172
- background-color: transparent;
173
- opacity: 1;
174
- display: flex;
175
- align-items: center;
176
- justify-content: center;
177
- box-sizing: border-box;
178
- touch-action: none;
179
- z-index: 10;
180
- }
181
-
182
- .cropper-point::after {
183
- content: '';
184
- display: block;
185
- width: var(--copio-crop-handle-visual, 16px);
186
- height: var(--copio-crop-handle-visual, 16px);
187
- border-radius: 50%;
188
- background-color: var(--copio-color-primary, #38bdf8);
189
- border: 2.5px solid #ffffff;
190
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
191
- transition: transform 120ms ease;
192
- box-sizing: border-box;
193
- }
194
-
195
- .cropper-point:hover::after,
196
- .cropper-point:active::after {
197
- transform: scale(1.25);
198
- background-color: var(--copio-color-success, #22c55e);
199
- }
200
-
201
- .cropper-point.point-e {
202
- cursor: ew-resize;
203
- margin-top: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
204
- right: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
205
- top: 50%;
206
- }
207
-
208
- .cropper-point.point-n {
209
- cursor: ns-resize;
210
- left: 50%;
211
- margin-left: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
212
- top: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
213
- }
214
-
215
- .cropper-point.point-w {
216
- cursor: ew-resize;
217
- left: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
218
- margin-top: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
219
- top: 50%;
220
- }
221
-
222
- .cropper-point.point-s {
223
- bottom: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
224
- cursor: s-resize;
225
- left: 50%;
226
- margin-left: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
227
- }
228
-
229
- .cropper-point.point-ne {
230
- cursor: nesw-resize;
231
- right: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
232
- top: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
233
- }
234
-
235
- .cropper-point.point-nw {
236
- cursor: nwse-resize;
237
- left: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
238
- top: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
239
- }
240
-
241
- .cropper-point.point-sw {
242
- bottom: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
243
- cursor: nesw-resize;
244
- left: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
245
- }
246
-
247
- .cropper-point.point-se {
248
- bottom: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
249
- cursor: nwse-resize;
250
- right: calc(-1 * var(--copio-crop-handle-hit, 48px) / 2);
251
- }
252
-
253
- .cropper-invisible {
254
- opacity: 0;
255
- }
256
-
257
- .cropper-bg {
258
- background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC');
259
- }
260
-
261
- .cropper-hide {
262
- display: block;
263
- height: 0;
264
- position: absolute;
265
- width: 0;
266
- }
267
-
268
- .cropper-hidden {
269
- display: none !important;
270
- }
271
-
272
- .cropper-move {
273
- cursor: move;
274
- }
275
-
276
- .cropper-crop {
277
- cursor: crosshair;
278
- }
279
-
280
- .cropper-disabled .cropper-drag-box,
281
- .cropper-disabled .cropper-face,
282
- .cropper-disabled .cropper-line,
283
- .cropper-disabled .cropper-point {
284
- cursor: not-allowed;
285
- }
286
- `;var Je=class extends HTMLElement{#e=[];#t=null;#s=null;#d=null;#r=null;#i=!1;#p=null;#h=new Set;#n=null;#l=!0;#c=!0;constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){this.#i||(this.#u(),this.#i=!0),this.#o()}disconnectedCallback(){if(this.#s){try{this.#s.destroy()}catch(o){console.warn("Error destroying Sortable:",o)}this.#s=null}if(this.#t){try{this.#t.destroy()}catch(o){console.warn("Error destroying Cropper:",o)}this.#t=null}this.#d=null,this.#r=null,this.stopCamera(),this.#b(),this.#p&&(this.#p.abort(),this.#p=null);let e=this.shadowRoot.querySelector(".file-input"),t=this.shadowRoot.querySelector(".camera-input");e&&(e.onchange=null),t&&(t.onchange=null),this.#i=!1}setCameraStream(e){this.stopCamera(),this.#n=e||null}stopCamera(){if(this.#n){try{(typeof this.#n.getTracks=="function"?this.#n.getTracks():[]).forEach(t=>{typeof t.stop=="function"&&t.stop()})}catch(e){console.warn("Error stopping camera tracks:",e)}this.#n=null}}#m(e){return e&&typeof e=="string"&&e.startsWith("blob:")&&this.#h.add(e),e}#f(e){if(this.#h.has(e)){try{URL.revokeObjectURL(e)}catch{}this.#h.delete(e)}}#b(){for(let e of this.#h)try{URL.revokeObjectURL(e)}catch{}this.#h.clear()}#u(){let e=`
287
- <style>
288
- ${so}
289
- </style>
290
- <style>
291
- .container {
292
- display: grid;
293
- grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
294
- gap: 0.75rem;
295
- max-width: 100%;
296
- min-height: 140px;
297
- padding: 0.5rem;
298
- border-radius: 8px;
299
- border: 2px dashed transparent;
300
- box-sizing: border-box;
301
- transition: border-color 0.2s, background-color 0.2s;
302
- }
303
- .container.drag-over {
304
- border-color: #3b82f6;
305
- background-color: rgba(59, 130, 246, 0.08);
306
- box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.2);
307
- }
308
- @container copio-scanner (max-width: 400px) {
309
- .container {
310
- grid-template-columns: repeat(2, 1fr);
311
- gap: 0.5rem;
312
- padding: 0.25rem;
313
- }
314
- }
315
- @container copio-scanner (min-width: 401px) and (max-width: 767px) {
316
- .container {
317
- grid-template-columns: repeat(3, 1fr);
318
- gap: 0.75rem;
319
- }
320
- }
321
- @container copio-scanner (min-width: 768px) {
322
- .container {
323
- grid-template-columns: repeat(4, 1fr);
324
- gap: 1rem;
325
- }
326
- }
327
- /* Fallbacks if container queries are unsupported or outside named container */
328
- @supports not (container-type: size) {
329
- @media (min-width: 640px) {
330
- .container {
331
- grid-template-columns: repeat(3, 1fr);
332
- }
333
- }
334
- @media (min-width: 1024px) {
335
- .container {
336
- grid-template-columns: repeat(4, 1fr);
337
- }
338
- }
339
- }
340
- .image-wrapper {
341
- cursor: grab;
342
- position: relative;
343
- user-select: none;
344
- -webkit-user-select: none;
345
- width: 100%;
346
- aspect-ratio: 1;
347
- }
348
- .image-wrapper:active {
349
- cursor: grabbing;
350
- }
351
- .image-wrapper.dragging {
352
- opacity: 0.4;
353
- cursor: grabbing;
354
- }
355
- .image-wrapper.sortable-ghost {
356
- opacity: 0.2;
357
- }
358
- .image-menu {
359
- position: absolute;
360
- top: 4px;
361
- right: 4px;
362
- }
363
- img {
364
- width: 100%;
365
- height: 100%;
366
- object-fit: cover;
367
- border: 1px solid #ccc;
368
- border-radius: 4px;
369
- display: block;
370
- }
371
- #crop-image {
372
- max-width: 100%;
373
- max-height: 100%;
374
- display: block;
375
- }
376
- .crop-wrapper {
377
- width: 100%;
378
- height: 360px;
379
- max-height: min(50vh, 380px);
380
- min-height: 200px;
381
- position: relative;
382
- display: flex;
383
- align-items: center;
384
- justify-content: center;
385
- overflow: visible;
386
- box-sizing: border-box;
387
- margin-bottom: 0.5rem;
388
- }
389
- sl-dialog::part(base) {
390
- position: absolute;
391
- }
392
- sl-dialog::part(overlay) {
393
- position: absolute;
394
- }
395
- sl-dialog::part(panel) {
396
- max-width: calc(100% - 20px);
397
- max-height: calc(100% - 20px);
398
- }
399
- .crop-dialog::part(panel) {
400
- max-width: min(94%, 560px);
401
- max-height: calc(100% - 16px);
402
- display: flex;
403
- flex-direction: column;
404
- }
405
- .crop-dialog::part(body) {
406
- padding: 24px;
407
- overflow: hidden;
408
- display: flex;
409
- align-items: center;
410
- justify-content: center;
411
- flex: 1 1 auto;
412
- min-height: 0;
413
- }
414
- @container copio-scanner (max-width: 400px) {
415
- .crop-wrapper {
416
- height: 240px;
417
- max-height: 42cqh;
418
- min-height: 160px;
419
- }
420
- .crop-dialog::part(panel) {
421
- max-width: calc(100% - 12px);
422
- max-height: calc(100% - 12px);
423
- }
424
- .crop-dialog::part(body) {
425
- padding: 16px;
426
- }
427
- .crop-dialog::part(header) {
428
- padding: 0.5rem 0.75rem;
429
- }
430
- .crop-dialog::part(footer) {
431
- padding: 0.5rem 0.75rem;
432
- }
433
- }
434
- .markdown-card {
435
- width: 100%;
436
- height: 100%;
437
- border: 1px solid #334155;
438
- border-radius: 4px;
439
- background: #0f172a;
440
- color: #f8fafc;
441
- padding: 10px;
442
- box-sizing: border-box;
443
- font-family: monospace;
444
- font-size: 0.72rem;
445
- overflow: hidden;
446
- display: flex;
447
- flex-direction: column;
448
- }
449
- .markdown-card-header {
450
- display: flex;
451
- align-items: center;
452
- gap: 4px;
453
- font-weight: bold;
454
- font-size: 0.75rem;
455
- color: #38bdf8;
456
- margin-bottom: 6px;
457
- white-space: nowrap;
458
- overflow: hidden;
459
- text-overflow: ellipsis;
460
- }
461
- .markdown-card-body {
462
- flex: 1;
463
- opacity: 0.8;
464
- word-break: break-word;
465
- overflow: hidden;
466
- line-height: 1.35;
467
- }
468
- button.add-btn {
469
- width: 100%;
470
- aspect-ratio: 1;
471
- font-size: 1.6rem;
472
- border: 2px dashed #888;
473
- border-radius: 4px;
474
- background: none;
475
- cursor: pointer;
476
- display: flex;
477
- align-items: center;
478
- justify-content: center;
479
- color: #64748b;
480
- transition: border-color 0.15s, color 0.15s, background-color 0.15s;
481
- }
482
- button.add-btn:hover {
483
- border-color: #3b82f6;
484
- color: #3b82f6;
485
- background-color: rgba(59, 130, 246, 0.04);
486
- }
487
- dialog {
488
- border: none;
489
- border-radius: 6px;
490
- padding: 1rem;
491
- }
492
- dialog::backdrop {
493
- background: rgba(0, 0, 0, 0.3);
494
- }
495
- </style>
496
- `;this.shadowRoot.innerHTML=`
497
- ${e}
498
- <div class="container"></div>
499
-
500
- <input type="file" class="file-input" accept="image/*,application/pdf,.md,.markdown,text/plain" multiple style="display: none">
501
- <input type="file" class="camera-input" accept="image/*" capture="environment" style="display: none">
502
-
503
- <sl-dialog label="Edit Markdown Text" class="text-dialog" style="--width: min(92%, 560px)">
504
- <div style="margin-bottom: 1rem;">
505
- <sl-textarea class="text-editor" rows="12" placeholder="Enter markdown content..."></sl-textarea>
506
- </div>
507
- <sl-button slot="footer" variant="default" class="cancel-text">Cancel</sl-button>
508
- <sl-button slot="footer" variant="primary" class="apply-text">Save Text</sl-button>
509
- </sl-dialog>
510
-
511
- <sl-dialog label="Image Data" class="data-dialog">
512
- <div class="exif-data" style="font-size: 0.85rem; line-height: 1.6;"></div>
513
- <sl-button slot="footer" variant="primary" class="close-data">Close</sl-button>
514
- </sl-dialog>
515
-
516
- <sl-dialog label="Crop Image" class="crop-dialog" style="--width: min(94%, 560px)">
517
- <div class="crop-wrapper">
518
- <img id="crop-image" />
519
- </div>
520
- <sl-button slot="footer" variant="default" class="cancel-crop">Cancel</sl-button>
521
- <sl-button slot="footer" variant="primary" class="apply-crop">Apply</sl-button>
522
- </sl-dialog>
523
- `,this.#p&&this.#p.abort(),this.#p=new AbortController;let{signal:t}=this.#p,o=this.shadowRoot.querySelector(".close-data");o&&o.addEventListener("click",()=>{this.shadowRoot.querySelector(".data-dialog")?.hide()},{signal:t});let r=this.shadowRoot.querySelector(".file-input"),a=this.shadowRoot.querySelector(".camera-input"),n=!1,s=async g=>{if(n)return;let S=Array.from(g.target?.files||[]);if(S.length!==0){n=!0;try{await this.addFiles(S)}finally{g.target&&(g.target.value=""),n=!1}}};r&&(r.onchange=s,r.addEventListener("change",s,{signal:t})),a&&(a.onchange=s,a.addEventListener("change",s,{signal:t}));let l=0,c=g=>{let S=g.dataTransfer;if(!S)return!1;if(!S.types||S.types.length===0)return!0;let N=Array.from(S.types);return N.includes("Files")||N.some(z=>z.startsWith("image/")||z.startsWith("public.")||z.includes("pdf")||z.includes("file")||z==="text/uri-list")},p=g=>{c(g)&&(g.preventDefault(),l++,f.classList.add("drag-over"))},d=g=>{c(g)&&(g.preventDefault(),g.stopPropagation(),g.dataTransfer&&(g.dataTransfer.dropEffect="copy"),f.classList.add("drag-over"))},u=()=>{l--,l<=0&&(l=0,f.classList.remove("drag-over"))},v=async g=>{l=0,f.classList.remove("drag-over"),g.preventDefault(),g.stopPropagation();let S=[];if(g.dataTransfer?.files?.length>0)S=Array.from(g.dataTransfer.files);else if(g.dataTransfer?.items?.length>0){for(let N of g.dataTransfer.items)if(N.kind==="file"){let z=N.getAsFile();z&&S.push(z)}}else g.detail?.files&&(S=Array.from(g.detail.files));S.length>0&&await this.addFiles(S)},f=this.shadowRoot.querySelector(".container");f&&(f.addEventListener("dragenter",p,{signal:t}),f.addEventListener("dragover",d,{signal:t}),f.addEventListener("dragleave",u,{signal:t}),f.addEventListener("drop",v,{signal:t}),f.addEventListener("dragend",()=>{l=0,f.classList.remove("drag-over")},{signal:t}),f.addEventListener("click",g=>{g.target===f&&r?.click()},{signal:t}));let y=this.shadowRoot.querySelector(".cancel-crop"),C=this.shadowRoot.querySelector(".apply-crop"),A=this.shadowRoot.querySelector(".cancel-text"),k=this.shadowRoot.querySelector(".apply-text");y&&y.addEventListener("click",()=>this.closeCropDialog(),{signal:t}),C&&C.addEventListener("click",()=>this.applyCrop(),{signal:t}),A&&A.addEventListener("click",()=>this.closeTextDialog(),{signal:t}),k&&k.addEventListener("click",()=>this.applyTextEdit(),{signal:t});let D=this.shadowRoot.querySelector(".crop-dialog");D&&D.addEventListener("sl-hide",()=>{this.#t&&(this.#t.destroy(),this.#t=null),this.#d=null},{signal:t})}#o(){let e=this.shadowRoot.querySelector(".container");if(!e)return;let t=this.#e.map((n,s)=>{if(n.type==="markdown"){let p=n.name||"Markdown Note",d=(n.content||"").slice(0,120);return`
524
- <div class="image-wrapper" data-index="${s}">
525
- <div class="markdown-card">
526
- <div class="markdown-card-header">
527
- <sl-icon name="file-earmark-text"></sl-icon> ${p}
528
- </div>
529
- <div class="markdown-card-body">${d}</div>
530
- </div>
531
- <sl-dropdown class="image-menu" data-index="${s}">
532
- <sl-button slot="trigger" variant="default" size="small" circle>
533
- <sl-icon name="three-dots-vertical"></sl-icon>
534
- </sl-button>
535
- <sl-menu>
536
- <sl-menu-item value="edittext">Edit Text</sl-menu-item>
537
- <sl-menu-item value="download">Download Markdown</sl-menu-item>
538
- <sl-divider></sl-divider>
539
- <sl-menu-item value="delete">Delete</sl-menu-item>
540
- </sl-menu>
541
- </sl-dropdown>
542
- </div>
543
- `}let l=Pt(n.edits),c=n.edits?.filter==="bw";return`
544
- <div class="image-wrapper" data-index="${s}">
545
- <img src="${n.src}" draggable="false">
546
- <sl-dropdown class="image-menu" data-index="${s}">
547
- <sl-button slot="trigger" variant="default" size="small" circle>
548
- <sl-icon name="three-dots-vertical"></sl-icon>
549
- </sl-button>
550
- <sl-menu>
551
- ${this.ocr!==!1?`
552
- <sl-menu-item value="ocr">
553
- <sl-icon slot="prefix" name="card-text"></sl-icon> Extract Text
554
- </sl-menu-item>
555
- <sl-divider></sl-divider>
556
- `:""}
557
- <sl-menu-item value="crop">Crop</sl-menu-item>
558
- <sl-menu-item value="rotate">Rotate</sl-menu-item>
559
- <sl-menu-item value="threshold">
560
- <sl-icon slot="prefix" name="${c?"check-lg":"circle"}"></sl-icon>
561
- ${c?"Remove Black &amp; White":"Black &amp; White"}
562
- </sl-menu-item>
563
- <sl-menu-item value="reset" ?disabled=${!l}>
564
- <sl-icon slot="prefix" name="arrow-counterclockwise"></sl-icon>
565
- Reset to Original
566
- </sl-menu-item>
567
- <sl-menu-item value="showdata">Show Data</sl-menu-item>
568
- <sl-menu-item value="download">Download Image</sl-menu-item>
569
- <sl-divider></sl-divider>
570
- <sl-menu-item value="delete">Delete</sl-menu-item>
571
- </sl-menu>
572
- </sl-dropdown>
573
- </div>
574
- `}).join("");e.innerHTML=`
575
- ${t}
576
- <button class="add-btn add-image-btn" title="Add image, PDF, or Markdown" aria-label="Add image or PDF">
577
- <sl-icon name="plus-lg"></sl-icon>
578
- </button>
579
- <button class="add-btn add-camera-btn" title="Capture from camera" aria-label="Capture from camera">
580
- <sl-icon name="camera"></sl-icon>
581
- </button>
582
- <button class="add-btn add-note-btn" title="New blank note" aria-label="New blank note">
583
- <sl-icon name="file-earmark-plus"></sl-icon>
584
- </button>
585
- `;let o=e.querySelector(".add-image-btn");o&&(o.onclick=()=>{this.shadowRoot.querySelector(".file-input").click()});let r=e.querySelector(".add-camera-btn");r&&(r.onclick=()=>{this.shadowRoot.querySelector(".camera-input").click()});let a=e.querySelector(".add-note-btn");a&&(a.onclick=()=>{this.addBlankNote()}),e.querySelectorAll(".image-menu").forEach(n=>{n.querySelector("sl-menu").addEventListener("sl-select",l=>{l.stopPropagation();let c=parseInt(n.dataset.index),p=l.detail.item.value;if(p==="ocr")n.hide(),this.dispatchEvent(new CustomEvent("copio:ocr-page",{bubbles:!0,composed:!0,detail:{page:this.#e[c],pageIndex:c}}));else if(p==="crop")n.hide(),this.openCropDialog(c);else if(p==="rotate")this.rotateImage(c);else if(p==="threshold")this.thresholdImage(c);else if(p==="reset")n.hide(),this.resetImage(c);else if(p==="showdata")n.hide(),this.showImageData(c);else if(p==="edittext")n.hide(),this.openTextDialog(c);else if(p==="download")this.downloadImage(c);else if(p==="delete"){let[d]=this.#e.splice(c,1);this.#o();let u=d.name||(d.type==="markdown"?"Markdown Note":`Page ${c+1}`);Y.undo(`Deleted ${u}`,()=>{this.#e.splice(c,0,d),this.#o(),Y.success(`Restored ${u}`)},{duration:5e3})}})}),this.#x(e)}#x(e){if(this.#s){try{this.#s.destroy()}catch(t){console.warn("Error destroying Sortable:",t)}this.#s=null}this.#s=no.create(e,{animation:150,draggable:".image-wrapper",chosenClass:"dragging",ghostClass:"sortable-ghost",filter:"sl-dropdown",preventOnFilter:!1,delay:150,delayOnTouchOnly:!0,touchStartThreshold:5,onEnd:t=>{if(t.to!==e)return;let o=t.oldDraggableIndex,r=t.newDraggableIndex;if(o===r)return;let a=this.#e[o];this.#e.splice(o,1),this.#e.splice(r,0,a),this.#o()}})}async openCropDialog(e){this.#d=e;let t=this.#e[e];if(!t||t.type==="markdown")return;let o=this.shadowRoot.querySelector(".crop-dialog"),r=this.shadowRoot.querySelector("#crop-image");t.originalSrc=t.originalSrc||t.src,t.edits=ue(t.edits),r.src=t.originalSrc,o.show();let a=await Rt(),n=t.edits?.crop,s=()=>{this.#t&&this.#t.destroy(),this.#t=new a(r,{viewMode:1,autoCropArea:.88,responsive:!0,ready:()=>{if(n)try{if(n.width>0&&n.height>0)this.#t.setData({x:n.x,y:n.y,width:n.width,height:n.height});else if(n.normalized&&n.normalized.w>0){let l=this.#t.getImageData();this.#t.setData({x:Math.round(n.normalized.x*l.naturalWidth),y:Math.round(n.normalized.y*l.naturalHeight),width:Math.round(n.normalized.w*l.naturalWidth),height:Math.round(n.normalized.h*l.naturalHeight)})}else if(typeof n.w=="number"&&n.w>0){let l=this.#t.getImageData();this.#t.setData({x:Math.round(n.x*l.naturalWidth),y:Math.round(n.y*l.naturalHeight),width:Math.round(n.w*l.naturalWidth),height:Math.round(n.h*l.naturalHeight)})}}catch(l){console.warn("Failed restoring prior crop box:",l)}}})};r.onload=s,r.complete&&r.naturalWidth>0&&!this.#t&&s()}closeCropDialog(){let e=this.shadowRoot.querySelector(".crop-dialog"),t=this.shadowRoot.querySelector("#crop-image");if(t&&(t.onload=null),this.#t){try{this.#t.destroy()}catch(o){console.warn("Error destroying Cropper:",o)}this.#t=null}this.#d=null,e?.hide()}applyCrop(){if(this.#t&&this.#d!==null){let e=this.#e[this.#d];if(!e)return;e.originalSrc=e.originalSrc||e.src||"";let t=this.#t.getData(!0),o=this.#t.getImageData(),r=o?.naturalWidth||1,a=o?.naturalHeight||1,n=Math.max(0,Math.min(1,t.x/r)),s=Math.max(0,Math.min(1,t.y/a)),l=Math.max(0,Math.min(1,t.width/r)),c=Math.max(0,Math.min(1,t.height/a));e.edits={...ue(e.edits),crop:{x:Math.round(t.x),y:Math.round(t.y),width:Math.round(t.width),height:Math.round(t.height),normalized:{x:Number(n.toFixed(4)),y:Number(s.toFixed(4)),w:Number(l.toFixed(4)),h:Number(c.toFixed(4))}}};let p=this.#t.getCroppedCanvas();if(p){let d=Mt(p,{crop:null,rotation:e.edits.rotation,filter:e.edits.filter}),u=e.originalSrc.startsWith("data:image/png"),v=u?"image/png":"image/jpeg";e.src=d.toDataURL(v,u?void 0:.82)}this.#o(),this.closeCropDialog()}}async rotateImage(e){let t=this.#e[e];!t||t.type==="markdown"||(t.originalSrc=t.originalSrc||t.src,t.edits={...ue(t.edits),rotation:((t.edits?.rotation||0)+90)%360},t.src=await at(t.originalSrc,t.edits),this.#o())}async thresholdImage(e){let t=this.#e[e];if(!t||t.type==="markdown")return;t.originalSrc=t.originalSrc||t.src;let o=t.edits?.filter==="bw";t.edits={...ue(t.edits),filter:o?"none":"bw"},t.src=await at(t.originalSrc,t.edits),this.#o(),o?Y.info("Restored color (removed B&W filter)"):Y.success("Applied B&W threshold filter")}resetImage(e){let t=this.#e[e];!t||t.type==="markdown"||(t.edits={crop:null,rotation:0,filter:"none"},t.src=t.originalSrc||t.src,this.#o(),Y.success("Reset page to original"))}addBlankNote(){let e={id:ce(),type:"markdown",name:"New Note",content:""};this.#e.push(e),this.#o(),this.openTextDialog(this.#e.length-1)}downloadImage(e){let t=this.#e[e];if(!t)return;if(t.type==="markdown"){let n=new Blob([t.content||""],{type:"text/markdown;charset=utf-8"}),s=this.#m(URL.createObjectURL(n)),l=document.createElement("a"),c=t.name||`document-${e+1}.md`;l.href=s,l.download=c,l.click(),this.#f(s),Y.success(`Downloaded "${c}"`);return}if(!t.src)return;let o="jpg";if(t.src.startsWith("data:")){let n=t.src.match(/^data:(image\/[a-zA-Z+]+);base64,/);n&&n[1].includes("png")&&(o="png")}let r=document.createElement("a"),a=`image-${e+1}.${o}`;r.href=t.src,r.download=a,r.click(),Y.success(`Downloaded "${a}"`)}openTextDialog(e){this.#r=e;let t=this.shadowRoot.querySelector(".text-dialog"),o=this.shadowRoot.querySelector(".text-editor");o.value=this.#e[e].content||"",t.label=this.#e[e].name||"Note",t.show()}applyTextEdit(){if(this.#r!==null&&this.#e[this.#r]){let e=this.shadowRoot.querySelector(".text-editor");this.#e[this.#r].content=e.value,this.#o(),this.closeTextDialog()}}closeTextDialog(){let e=this.shadowRoot.querySelector(".text-dialog");this.#r=null,e.hide()}showImageData(e){let{src:t,exif:o}=this.#e[e],r=this.shadowRoot.querySelector(`img[src="${t}"]`),a=[];if(a.push(`<strong>Dimensions:</strong> ${r?`${r.naturalWidth} \xD7 ${r.naturalHeight}`:"unknown"}`),o){let n=new Set(["MakerNote","UserComment","FlashPixVersion","ExifVersion","ComponentsConfiguration","SceneType","thumbnail"]);for(let[s,l]of Object.entries(o)){if(n.has(s)||l===void 0||l===null)continue;let c=l instanceof Array?l.join(", "):String(l);c.length>200||a.push(`<strong>${s}:</strong> ${c}`)}}else a.push("<em>No EXIF data available</em>");this.shadowRoot.querySelector(".exif-data").innerHTML=a.join("<br>"),this.shadowRoot.querySelector(".data-dialog").show()}async pdfToImages(e){let t=await e.arrayBuffer();return(await Nt(t)).map(r=>({id:ce(),src:r,originalSrc:r,edits:{crop:null,rotation:0,filter:"none"}}))}async addFiles(e){if(!e||e.length===0)return;let t=[];try{for(let r of e)if(r.type==="application/pdf"){let a=await this.pdfToImages(r);t.push(...a)}else if(r.name?.endsWith(".md")||r.name?.endsWith(".markdown")||r.type==="text/markdown"||r.type==="text/plain"){let a=await r.text();t.push({id:ce(),type:"markdown",name:r.name,content:a})}else{let[a,n]=await Promise.all([Tt(r),It(r)]);t.push({id:ce(),src:a,originalSrc:a,edits:{crop:null,rotation:0,filter:"none"},exif:n})}this.#e.push(...t),this.#o();let o=t.length;Y.success(`Imported ${o} page${o!==1?"s":""}`)}catch(o){console.error("Failed to import files:",o),Y.error("Failed to import files")}}get ocr(){return this.#l!==!1}set ocr(e){this.#l=!!e,this.#i&&this.#o()}get pdf(){return this.#c!==!1}set pdf(e){this.#c=!!e,this.#i&&this.#o()}get images(){return this.#e}set images(e){let t=Array.isArray(e)?e:[];this.#e=t.map(o=>!o||o.type==="markdown"?o:{...o,originalSrc:o.originalSrc||o.src||"",edits:ue(o.edits)}),this.#i&&this.#o()}};customElements.define("copio-images",Je);var et=class extends K{disconnectedCallback(){super.disconnectedCallback(),this.activeSlideIndex=0}updated(e){super.updated(e),e.has("images")&&Array.isArray(this.images)&&this.images.some(t=>t.type==="markdown")&&(!window.marked||!window.marked.parse)&&Ot().then(()=>this.requestUpdate())}static properties={docId:{type:String},docName:{type:String},images:{type:Array},activeSlideIndex:{type:Number,state:!0},ocr:{type:Boolean},pdf:{type:Boolean}};get hasImages(){return(this.images||[]).some(e=>e.type!=="markdown"&&!!e.src)}get hasMarkdown(){return(this.images||[]).some(e=>e.type==="markdown")}get pageCount(){return(this.images||[]).length}static styles=re`
586
- :host {
587
- display: block;
588
- position: absolute;
589
- top: 0;
590
- left: 0;
591
- right: 0;
592
- bottom: 0;
593
- width: 100%;
594
- height: 100%;
595
- z-index: 10;
596
- overflow: hidden;
597
- background: #000;
598
- box-sizing: border-box;
599
- }
600
- sl-carousel {
601
- position: absolute;
602
- top: 0;
603
- padding-top: 16px;
604
- background: white;
605
- z-index: 4;
606
- height: 100%;
607
- width: 100%;
608
- }
609
- sl-carousel-item {
610
- height: 100%;
611
- }
612
- .item {
613
- width: 100%;
614
- height: 100%;
615
- background-repeat: no-repeat;
616
- background-size: contain;
617
- background-position: center;
618
- }
619
- .top-bar {
620
- position: absolute;
621
- top: 0;
622
- left: 0;
623
- right: 0;
624
- height: 56px;
625
- z-index: 10;
626
- display: flex;
627
- align-items: center;
628
- justify-content: space-between;
629
- padding: 0 16px;
630
- background: linear-gradient(to bottom, rgba(15, 23, 42, 0.85) 0%, rgba(15, 23, 42, 0.3) 80%, transparent 100%);
631
- pointer-events: none;
632
- box-sizing: border-box;
633
- }
634
- .top-bar > * {
635
- pointer-events: auto;
636
- }
637
- .top-bar-left {
638
- display: flex;
639
- align-items: center;
640
- gap: 10px;
641
- min-width: 0;
642
- }
643
- .top-bar-right {
644
- display: flex;
645
- align-items: center;
646
- gap: 8px;
647
- }
648
- .back {
649
- font-size: 26px;
650
- cursor: pointer;
651
- appearance: none;
652
- background: rgba(15, 23, 42, 0.6);
653
- border: 1px solid rgba(255, 255, 255, 0.2);
654
- border-radius: 8px;
655
- color: white;
656
- width: 36px;
657
- height: 36px;
658
- display: flex;
659
- align-items: center;
660
- justify-content: center;
661
- transition: background 0.15s;
662
- }
663
- .back:hover {
664
- background: rgba(15, 23, 42, 0.9);
665
- }
666
- .doc-heading {
667
- color: #f8fafc;
668
- font-size: 1.05rem;
669
- font-weight: 600;
670
- white-space: nowrap;
671
- overflow: hidden;
672
- text-overflow: ellipsis;
673
- max-width: 240px;
674
- text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
675
- }
676
- .ocr-btn, .export-btn {
677
- background: rgba(15, 23, 42, 0.75);
678
- backdrop-filter: blur(8px);
679
- color: white;
680
- border: 1px solid rgba(255, 255, 255, 0.2);
681
- border-radius: 8px;
682
- padding: 6px 12px;
683
- height: 36px;
684
- font-size: 13px;
685
- display: flex;
686
- align-items: center;
687
- gap: 6px;
688
- cursor: pointer;
689
- transition: background 0.15s, border-color 0.15s;
690
- box-sizing: border-box;
691
- }
692
- .ocr-btn:hover, .export-btn:hover {
693
- background: rgba(15, 23, 42, 0.95);
694
- border-color: rgba(255, 255, 255, 0.4);
695
- }
696
- .markdown-container {
697
- width: 100%;
698
- height: 100%;
699
- box-sizing: border-box;
700
- padding: 60px 24px 24px 24px;
701
- overflow-y: auto;
702
- background: #151f2a;
703
- color: #f8fafc;
704
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
705
- line-height: 1.6;
706
- }
707
- .markdown-body {
708
- max-width: 800px;
709
- margin: 0 auto;
710
- }
711
- .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
712
- color: #f1f5f9;
713
- margin-top: 1.5em;
714
- margin-bottom: 0.5em;
715
- font-weight: 600;
716
- line-height: 1.25;
717
- border-bottom: 1px solid rgba(255,255,255,0.1);
718
- padding-bottom: 0.3em;
719
- }
720
- .markdown-body h1 { font-size: 2em; }
721
- .markdown-body h2 { font-size: 1.5em; }
722
- .markdown-body h3 { font-size: 1.25em; }
723
- .markdown-body p { margin-top: 0; margin-bottom: 1em; }
724
- .markdown-body ul, .markdown-body ol { padding-left: 2em; margin-bottom: 1em; }
725
- .markdown-body li { margin-bottom: 0.3em; }
726
- .markdown-body code {
727
- background: rgba(255,255,255,0.1);
728
- padding: 0.2em 0.4em;
729
- border-radius: 4px;
730
- font-family: monospace;
731
- font-size: 0.9em;
732
- }
733
- .markdown-body pre {
734
- background: #0f172a;
735
- padding: 1em;
736
- border-radius: 8px;
737
- overflow-x: auto;
738
- border: 1px solid rgba(255,255,255,0.1);
739
- }
740
- .markdown-body pre code { background: none; padding: 0; }
741
- .markdown-body blockquote {
742
- border-left: 4px solid #38bdf8;
743
- margin: 1em 0;
744
- padding-left: 1em;
745
- color: #cbd5e1;
746
- font-style: italic;
747
- }
748
- .markdown-body table {
749
- border-collapse: collapse;
750
- width: 100%;
751
- margin-bottom: 1em;
752
- }
753
- .markdown-body th, .markdown-body td {
754
- border: 1px solid rgba(255,255,255,0.15);
755
- padding: 8px 12px;
756
- text-align: left;
757
- }
758
- .markdown-body th {
759
- background: rgba(255,255,255,0.1);
760
- }
761
- .markdown-body img {
762
- max-width: 100%;
763
- height: auto;
764
- border-radius: 6px;
765
- }
766
- `;constructor(){super(),this.docId="",this.docName="",this.images=[],this.activeSlideIndex=0,this.ocr=!0,this.pdf=!0}handleBackClick(){this.dispatchEvent(new CustomEvent("dialog:close",{bubbles:!0,composed:!1}))}handleOcrClick(){let e=this.images[this.activeSlideIndex];!e||e.type==="markdown"||!e.src||this.dispatchEvent(new CustomEvent("copio:ocr-page",{bubbles:!0,composed:!0,detail:{page:e,pageIndex:this.activeSlideIndex}}))}handleExportSelect(e){if(e.detail?.item?.disabled)return;let t=e.detail?.item?.value,o={docId:this.docId,docName:this.docName,pages:this.images};t==="pdf"?this.dispatchEvent(new CustomEvent("doc:download-pdf",{bubbles:!0,composed:!1,detail:o})):t==="images"?this.dispatchEvent(new CustomEvent("doc:download-images",{bubbles:!0,composed:!1,detail:o})):t==="markdown"&&this.dispatchEvent(new CustomEvent("doc:download-markdown",{bubbles:!0,composed:!1,detail:o}))}handleSlideChange(e){this.activeSlideIndex=e.detail?.index||0}renderItem(e){if(e.type==="markdown"){let t=e.content||"",o=window.marked&&window.marked.parse?window.marked.parse(t):t;return O`
767
- <sl-carousel-item data-id="${e.id}">
768
- <div class="markdown-container">
769
- <div class="markdown-body" .innerHTML=${o}></div>
770
- </div>
771
- </sl-carousel-item>
772
- `}return O`
773
- <sl-carousel-item data-id="${e.id}">
774
- <div class="item" style="background-image: url('${e.src}')"></div>
775
- </sl-carousel-item>
776
- `}render(){let e=this.images[this.activeSlideIndex],t=this.ocr!==!1&&e&&e.type!=="markdown"&&!!e.src;return O`
777
- <div class="top-bar">
778
- <div class="top-bar-left">
779
- <button class="back" @click=${this.handleBackClick} aria-label="Back">←</button>
780
- <span class="doc-heading">${this.docName||"Document"}</span>
781
- </div>
782
-
783
- <div class="top-bar-right">
784
- ${t?O`
785
- <button class="ocr-btn" @click=${this.handleOcrClick} aria-label="Extract text">
786
- <sl-icon name="card-text"></sl-icon>
787
- <span>Extract Text</span>
788
- </button>
789
- `:""}
790
-
791
- <sl-dropdown>
792
- <button slot="trigger" class="export-btn" aria-label="Export document">
793
- <sl-icon name="box-arrow-up"></sl-icon>
794
- <span>Export</span>
795
- <sl-icon name="chevron-down" style="font-size: 0.75rem;"></sl-icon>
796
- </button>
797
- <sl-menu @sl-select=${this.handleExportSelect}>
798
- ${this.pdf!==!1?O`
799
- <sl-menu-item value="pdf" ?disabled=${this.pageCount===0}>
800
- <sl-icon slot="prefix" name="file-earmark-pdf"></sl-icon>
801
- Download as PDF
802
- </sl-menu-item>
803
- `:""}
804
- <sl-menu-item value="images" ?disabled=${this.pageCount===0}>
805
- <sl-icon slot="prefix" name="images"></sl-icon>
806
- Download as Images (ZIP)
807
- </sl-menu-item>
808
- <sl-menu-item value="markdown" ?disabled=${!this.hasMarkdown}>
809
- <sl-icon slot="prefix" name="markdown"></sl-icon>
810
- Download as Markdown
811
- </sl-menu-item>
812
- </sl-menu>
813
- </sl-dropdown>
814
- </div>
815
- </div>
816
-
817
- <sl-carousel
818
- class="sl-carousel"
819
- orientation="vertical"
820
- @sl-slide-change=${this.handleSlideChange}
821
- >
822
- ${this.images.map(o=>this.renderItem(o))}
823
- </sl-carousel>
824
- `}};customElements.define("copio-carousel",et);var tt=class extends K{createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback(),this.#e()}#e=()=>{let e=this.querySelector(".dialog-add-edit-input-name"),t=this.querySelector(".dialog-name-error");if(t&&(t.style.display="none"),e&&(e.classList.remove("input-invalid"),e.style.removeProperty("--sl-input-border-color"),e.style.removeProperty("--sl-input-border-color-focus"),typeof e.setCustomValidity=="function"))try{e.setCustomValidity("")}catch{}};#t=e=>{e.target?.value?.trim()&&this.#e()};#s=e=>{if(e.target!==e.currentTarget)return;this.#e();let t=this.querySelector(".dialog-add-edit-input-id"),o=this.querySelector(".dialog-add-edit-input-name"),r=this.querySelector("copio-images");t&&(t.value=""),o&&(o.value=""),r&&(r.images=[]),this.dispatchEvent(new CustomEvent("dialog:close",{bubbles:!0,composed:!1}))};#d=e=>{if(e.key!=="Enter"||this.querySelector("sl-dialog[open]"))return;if(e.target?.classList?.contains("dialog-add-edit-input-name")){e.preventDefault(),this.#r();return}let t=e.target?.tagName;t==="TEXTAREA"||t==="SL-TEXTAREA"||t==="INPUT"||t==="SL-INPUT"||e.target?.tagName==="SL-BUTTON"||e.target?.tagName==="BUTTON"||(e.preventDefault(),this.#r())};async open(){await this.updateComplete,this.#e();let e=this.querySelector(".dialog-add-edit");e&&(await e.show(),this.querySelector(".dialog-add-edit-input-name")?.focus())}async openEdit(e,t,o){await this.updateComplete,this.#e();let r=this.querySelector(".dialog-add-edit");if(!r)return;let a=this.querySelector(".dialog-add-edit-input-id"),n=this.querySelector(".dialog-add-edit-input-name"),s=this.querySelector("copio-images");a.value=e,n.value=t,await customElements.whenDefined("copio-images"),s.images=o.map(({id:l,src:c,originalSrc:p,edits:d,exif:u,type:v,name:f,content:y})=>({id:l,src:c,originalSrc:p||c,edits:d||{crop:null,rotation:0,filter:"none"},exif:u,type:v,name:f,content:y})),r.open||(await r.show(),n.focus())}#r=()=>{let e=this.querySelector(".dialog-add-edit-input-id"),t=this.querySelector(".dialog-add-edit-input-name"),o=this.querySelector(".dialog-name-error"),r=this.querySelector("copio-images"),a=t?.value?.trim();if(!a){o&&(o.style.display="block"),t&&(t.classList.add("input-invalid"),t.style.setProperty("--sl-input-border-color","#ef4444"),t.style.setProperty("--sl-input-border-color-focus","#ef4444"),typeof t.setCustomValidity=="function"&&(t.setCustomValidity("Please enter a document name"),t.reportValidity?.()),t.focus());return}let n=(r?.images||[]).map(({id:l,src:c,originalSrc:p,edits:d,exif:u,type:v,name:f,content:y})=>({id:l,src:c,originalSrc:p||c,edits:d||{crop:null,rotation:0,filter:"none"},exif:u,type:v,name:f,content:y})),s=e?.value||ce();this.dispatchEvent(new CustomEvent("dialog:save",{bubbles:!0,composed:!1,detail:{id:s,name:a,pages:n}})),this.querySelector(".dialog-add-edit")?.hide()};render(){return O`
825
- <sl-dialog
826
- label="Add / Edit"
827
- class="dialog-add-edit"
828
- style="--width: min(94%, 640px)"
829
- @sl-after-hide=${this.#s}
830
- @keydown=${this.#d}
831
- >
832
- <div style="min-height: min(65cqh, 420px); min-height: 350px;">
833
- <sl-input
834
- disabled
835
- class="dialog-add-edit-input-id"
836
- placeholder="id"
837
- style="display: none"
838
- ></sl-input>
839
- <div class="dialog-name-field" style="max-width: 300px">
840
- <sl-input
841
- class="dialog-add-edit-input-name"
842
- placeholder="Enter name of document or image"
843
- @sl-input=${this.#t}
844
- ></sl-input>
845
- <div
846
- class="dialog-name-error"
847
- style="color: #ef4444; font-size: 0.8rem; margin-top: 4px; display: none;"
848
- >
849
- Please enter a document name
850
- </div>
851
- </div>
852
-
853
- <copio-images
854
- style="display: block; margin-top: 1.5rem"
855
- ></copio-images>
856
-
857
- <br />
858
-
859
- <sl-button
860
- class="dialog-add-edit-savebtn"
861
- style="width: 100%; margin-top: auto;"
862
- slot="footer"
863
- variant="primary"
864
- @click=${this.#r}
865
- >Save</sl-button
866
- >
867
- </div>
868
- </sl-dialog>
869
- `}};customElements.define("copio-add-edit-dialog",tt);var ot=class extends K{static properties={name:{type:String},pages:{type:Array},isRenaming:{type:Boolean,state:!0},renameValue:{type:String,state:!0},ocr:{type:Boolean},pdf:{type:Boolean}};constructor(){super(),this.name="",this.pages=[],this.isRenaming=!1,this.renameValue="",this.ocr=!0,this.pdf=!0}get hasImages(){return(this.pages||[]).some(e=>e.type!=="markdown"&&!!e.src)}get hasMarkdown(){return(this.pages||[]).some(e=>e.type==="markdown")}get pageCount(){return(this.pages||[]).length}static styles=re`
870
- .wrapper {
871
- margin-left: auto;
872
- margin-right: auto;
873
- display: flex;
874
- justify-content: space-between;
875
- align-items: center;
876
- max-width: 768px;
877
- padding: 10px 12px;
878
- border-bottom: 1px solid #e2e8f0;
879
- cursor: pointer;
880
- user-select: none;
881
- }
882
- .inner {
883
- display: flex;
884
- align-items: center;
885
- flex: 1;
886
- min-width: 0;
887
- }
888
- .titles {
889
- display: flex;
890
- flex-direction: column;
891
- margin-left: 12px;
892
- padding: 2px 0;
893
- flex: 1;
894
- min-width: 0;
895
- }
896
- .doc-title {
897
- font-weight: 600;
898
- font-size: 0.95rem;
899
- color: #151f2a;
900
- white-space: nowrap;
901
- overflow: hidden;
902
- text-overflow: ellipsis;
903
- line-height: 1.3;
904
- }
905
- .doc-page-count {
906
- font-size: 0.8rem;
907
- color: #64748b;
908
- margin-top: 2px;
909
- }
910
- .rename-container {
911
- display: flex;
912
- align-items: center;
913
- gap: 6px;
914
- width: 100%;
915
- max-width: 320px;
916
- }
917
- .rename-container sl-input {
918
- flex: 1;
919
- }
920
- button {
921
- appearance: none;
922
- border: none;
923
- color: black;
924
- padding: 3px 4px 3px 7px;
925
- background: white;
926
- cursor: pointer;
927
- }
928
- `;#e(e){this.isRenaming||e.target.closest("sl-dropdown")||e.target.closest(".rename-container")||this.handleView()}#t(e){if(e.detail?.item?.disabled)return;let t=e.detail?.item?.value;t==="delete"&&this.handleDelete(),t==="rename"&&this.startRename(),t==="edit"&&this.handleEdit(),t==="extract-ocr"&&this.handleExtractOcr(),t==="download"&&this.handleDownload(),t==="download-images"&&this.handleDownloadImages(),t==="download-markdown"&&this.handleDownloadMarkdown()}startRename(e){e&&(e.preventDefault(),e.stopPropagation()),this.renameValue=this.name||"",this.isRenaming=!0,this.updateComplete.then(()=>{let t=this.shadowRoot.querySelector(".rename-input");t&&(t.focus(),typeof t.select=="function"&&t.select())})}cancelRename(e){e&&(e.preventDefault(),e.stopPropagation()),this.isRenaming=!1,this.renameValue=this.name||""}commitRename(e){e&&(e.preventDefault(),e.stopPropagation());let t=(this.renameValue||"").trim();if(!t){this.cancelRename();return}if(t!==this.name){let o={id:this.getAttribute("id"),name:t};this.dispatchEvent(new CustomEvent("doc:rename",{bubbles:!0,composed:!1,detail:o})),this.name=t}this.isRenaming=!1}handleRenameKeyDown(e){e.key==="Enter"?(e.preventDefault(),this.commitRename()):e.key==="Escape"&&(e.preventDefault(),this.cancelRename())}handleExtractOcr(){let e={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:extract-ocr",{bubbles:!0,composed:!1,detail:e}))}handleView(){let e={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:view",{bubbles:!0,composed:!1,detail:e}))}handleDelete(){let e={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:delete",{bubbles:!0,composed:!1,detail:e}))}handleEdit(){let e={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:edit",{bubbles:!0,composed:!1,detail:e}))}handleDownload(){let e={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:download",{bubbles:!0,composed:!1,detail:e}))}handleDownloadImages(){let e={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:download-images",{bubbles:!0,composed:!1,detail:e}))}handleDownloadMarkdown(){let e={id:this.getAttribute("id")};this.dispatchEvent(new CustomEvent("doc:download-markdown",{bubbles:!0,composed:!1,detail:e}))}render(){return O`
929
- <div class="wrapper" @click=${this.#e}>
930
- <div class="inner">
931
- <sl-avatar label="Document icon">
932
- <sl-icon slot="icon" name="file-earmark-text"></sl-icon>
933
- </sl-avatar>
934
-
935
- <div class="titles">
936
- ${this.isRenaming?O`
937
- <div class="rename-container" @click=${e=>e.stopPropagation()}>
938
- <sl-input
939
- class="rename-input"
940
- size="small"
941
- .value=${this.renameValue}
942
- @sl-input=${e=>this.renameValue=e.target.value}
943
- @keydown=${this.handleRenameKeyDown}
944
- ></sl-input>
945
- <sl-icon-button
946
- name="check-lg"
947
- label="Save rename"
948
- @click=${this.commitRename}
949
- ></sl-icon-button>
950
- <sl-icon-button
951
- name="x-lg"
952
- label="Cancel rename"
953
- @click=${this.cancelRename}
954
- ></sl-icon-button>
955
- </div>
956
- `:O`
957
- <div class="doc-title">${this.name||"Untitled Document"}</div>
958
- <div class="doc-page-count">
959
- ${this.pageCount} ${this.pageCount===1?"page":"pages"}
960
- </div>
961
- `}
962
- </div>
963
- </div>
964
-
965
- <sl-dropdown>
966
- <sl-button slot="trigger" variant="default" size="small" circle>
967
- <sl-icon name="three-dots-vertical"></sl-icon>
968
- </sl-button>
969
- <sl-menu @sl-select=${this.#t}>
970
- <sl-menu-item value="edit">
971
- <sl-icon slot="prefix" name="sliders"></sl-icon>
972
- Edit
973
- </sl-menu-item>
974
- <sl-menu-item value="rename">
975
- <sl-icon slot="prefix" name="pencil"></sl-icon>
976
- Rename
977
- </sl-menu-item>
978
- ${this.ocr!==!1?O`
979
- <sl-menu-item
980
- value="extract-ocr"
981
- ?disabled=${!this.hasImages}
982
- title=${this.hasImages?"Extract text with OCR":"No image pages in document"}
983
- >
984
- <sl-icon slot="prefix" name="card-text"></sl-icon>
985
- Extract All Text (OCR)
986
- </sl-menu-item>
987
- `:""}
988
- <sl-divider></sl-divider>
989
- ${this.pdf!==!1?O`
990
- <sl-menu-item
991
- value="download"
992
- ?disabled=${this.pageCount===0}
993
- title=${this.pageCount===0?"Document is empty":"Download as PDF"}
994
- >
995
- <sl-icon slot="prefix" name="file-earmark-pdf"></sl-icon>
996
- Download as PDF
997
- </sl-menu-item>
998
- `:""}
999
- <sl-menu-item
1000
- value="download-images"
1001
- ?disabled=${this.pageCount===0}
1002
- title=${this.pageCount===0?"Document is empty":"Download as Images"}
1003
- >
1004
- <sl-icon slot="prefix" name="images"></sl-icon>
1005
- Download as Images
1006
- </sl-menu-item>
1007
- <sl-menu-item
1008
- value="download-markdown"
1009
- ?disabled=${!this.hasMarkdown}
1010
- title=${this.hasMarkdown?"Download as Markdown":"No markdown notes in document"}
1011
- >
1012
- <sl-icon slot="prefix" name="markdown"></sl-icon>
1013
- Download as Markdown
1014
- </sl-menu-item>
1015
- <sl-divider></sl-divider>
1016
- <sl-menu-item value="delete">
1017
- <sl-icon slot="prefix" name="trash"></sl-icon>
1018
- Delete
1019
- </sl-menu-item>
1020
- </sl-menu>
1021
- </sl-dropdown>
1022
- </div>
1023
- `}};customElements.define("copio-row",ot);var it=class extends K{static styles=re`
1024
- header {
1025
- background-color: #151f2a;
1026
- color: white;
1027
- display: flex;
1028
- align-items: center;
1029
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
1030
- padding: 8px;
1031
- }
1032
- .header-left,
1033
- .header-right {
1034
- flex: 1;
1035
- display: flex;
1036
- align-items: center;
1037
- }
1038
- .header-right {
1039
- justify-content: flex-end;
1040
- }
1041
- h1 {
1042
- font-size: 24px;
1043
- margin: 0;
1044
- }
1045
- sl-icon-button::part(base) {
1046
- min-width: 44px;
1047
- min-height: 44px;
1048
- display: inline-flex;
1049
- align-items: center;
1050
- justify-content: center;
1051
- }
1052
- `;static properties={_storageEstimate:{state:!0},_isPersisted:{state:!0}};async connectedCallback(){super.connectedCallback(),await this.#e()}disconnectedCallback(){super.disconnectedCallback()}async#e(){navigator.storage&&(navigator.storage.persisted&&(this._isPersisted=await navigator.storage.persisted()),navigator.storage.estimate&&(this._storageEstimate=await navigator.storage.estimate()))}_formatBytes(e){if(e==null)return"Unknown";if(e===0)return"0 B";let t=1024,o=["B","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(1))+" "+o[r]}#t(e){if(e.detail.item.value==="link-device"){this.dispatchEvent(new CustomEvent("header:link-device",{bubbles:!0,composed:!1}));return}e.detail.item.value==="clear-cache"&&this.dispatchEvent(new CustomEvent("header:clear-cache",{bubbles:!0,composed:!1}))}render(){return O`
1053
- <header>
1054
- <div class="header-left">
1055
- <sl-dropdown @sl-show=${this.#e}>
1056
- <sl-icon-button
1057
- slot="trigger"
1058
- name="list"
1059
- label="Menu"
1060
- style="font-size: 1.5rem; color: white;"
1061
- ></sl-icon-button>
1062
- <sl-menu @sl-select=${this.#t}>
1063
- <sl-menu-item value="link-device">Link another device</sl-menu-item>
1064
- <sl-menu-item value="clear-cache">Clear cache &amp; update</sl-menu-item>
1065
- <sl-divider></sl-divider>
1066
- <sl-menu-item disabled>
1067
- Storage: ${this._formatBytes(this._storageEstimate?.usage)}
1068
- (${this._isPersisted?"Persisted":"Volatile"})
1069
- </sl-menu-item>
1070
- </sl-menu>
1071
- </sl-dropdown>
1072
- </div>
1073
- <h1>COPIO</h1>
1074
- <div class="header-right"></div>
1075
- </header>
1076
- `}};customElements.define("copio-header",it);var rt=class extends K{disconnectedCallback(){super.disconnectedCallback()}static styles=re`
1077
- .lds-roller {
1078
- display: inline-block;
1079
- position: relative;
1080
- width: 80px;
1081
- height: 80px;
1082
- }
1083
- .lds-roller div {
1084
- animation: lds-roller 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
1085
- transform-origin: 40px 40px;
1086
- }
1087
- .lds-roller div:after {
1088
- content: ' ';
1089
- display: block;
1090
- position: absolute;
1091
- width: 7px;
1092
- height: 7px;
1093
- border-radius: 50%;
1094
- background: #fff;
1095
- margin: -4px 0 0 -4px;
1096
- }
1097
- .lds-roller div:nth-child(1) {
1098
- animation-delay: -0.036s;
1099
- }
1100
- .lds-roller div:nth-child(1):after {
1101
- top: 63px;
1102
- left: 63px;
1103
- }
1104
- .lds-roller div:nth-child(2) {
1105
- animation-delay: -0.072s;
1106
- }
1107
- .lds-roller div:nth-child(2):after {
1108
- top: 68px;
1109
- left: 56px;
1110
- }
1111
- .lds-roller div:nth-child(3) {
1112
- animation-delay: -0.108s;
1113
- }
1114
- .lds-roller div:nth-child(3):after {
1115
- top: 71px;
1116
- left: 48px;
1117
- }
1118
- .lds-roller div:nth-child(4) {
1119
- animation-delay: -0.144s;
1120
- }
1121
- .lds-roller div:nth-child(4):after {
1122
- top: 72px;
1123
- left: 40px;
1124
- }
1125
- .lds-roller div:nth-child(5) {
1126
- animation-delay: -0.18s;
1127
- }
1128
- .lds-roller div:nth-child(5):after {
1129
- top: 71px;
1130
- left: 32px;
1131
- }
1132
- .lds-roller div:nth-child(6) {
1133
- animation-delay: -0.216s;
1134
- }
1135
- .lds-roller div:nth-child(6):after {
1136
- top: 68px;
1137
- left: 24px;
1138
- }
1139
- .lds-roller div:nth-child(7) {
1140
- animation-delay: -0.252s;
1141
- }
1142
- .lds-roller div:nth-child(7):after {
1143
- top: 63px;
1144
- left: 17px;
1145
- }
1146
- .lds-roller div:nth-child(8) {
1147
- animation-delay: -0.288s;
1148
- }
1149
- .lds-roller div:nth-child(8):after {
1150
- top: 56px;
1151
- left: 12px;
1152
- }
1153
- @keyframes lds-roller {
1154
- 0% {
1155
- transform: rotate(0deg);
1156
- }
1157
- 100% {
1158
- transform: rotate(360deg);
1159
- }
1160
- }
1161
- `;render(){return O`
1162
- <div
1163
- style="
1164
- background: #151f2a;
1165
- width: 100%;
1166
- position: absolute;
1167
- z-index: 5;
1168
- height: 100%;
1169
- margin: 0;
1170
- padding: 0;
1171
- top: 0;
1172
- left: 0;
1173
- "
1174
- >
1175
- <img
1176
- src="copio.svg"
1177
- style="
1178
- position: absolute;
1179
- top: 50%;
1180
- left: 50%;
1181
- transform: translate(-50%, -50%);
1182
- opacity: 0.3;
1183
- z-index: 1;
1184
- max-width: 320px;
1185
- "
1186
- />
1187
- <div
1188
- class="lds-roller"
1189
- style="
1190
- position: absolute;
1191
- top: calc(50% + -50px);
1192
- left: 50%;
1193
- transform: translate(-50%) scale(1);
1194
- opacity: 0.5;
1195
- "
1196
- >
1197
- <div></div>
1198
- <div></div>
1199
- <div></div>
1200
- <div></div>
1201
- <div></div>
1202
- <div></div>
1203
- <div></div>
1204
- <div></div>
1205
- </div>
1206
- </div>
1207
- `}};customElements.define("copio-loader",rt);var Ct=`
1208
- :host {
1209
- all: initial;
1210
- display: block;
1211
- position: relative;
1212
- width: 100%;
1213
- height: 100%;
1214
- min-height: 200px;
1215
- container-type: size;
1216
- container-name: copio-scanner;
1217
- overflow: hidden;
1218
- contain: layout;
1219
- box-sizing: border-box;
1220
- text-align: left;
1221
- direction: ltr;
1222
- -webkit-font-smoothing: antialiased;
1223
- -moz-osx-font-smoothing: grayscale;
1224
- --copio-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1225
- --copio-font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
1226
- --copio-color-bg: #0b0f17;
1227
- --copio-color-surface: #131b26;
1228
- --copio-color-surface-elevated: #1c2736;
1229
- --copio-color-surface-overlay: rgba(15, 22, 32, 0.88);
1230
- --copio-color-stage-bg: #070a0f;
1231
- --copio-color-text: #f1f5f9;
1232
- --copio-color-text-muted: #94a3b8;
1233
- --copio-color-text-inverse: #090d14;
1234
- --copio-color-primary: #38bdf8;
1235
- --copio-color-primary-hover: #7dd3fc;
1236
- --copio-color-primary-contrast: #06131f;
1237
- --copio-color-success: #22c55e;
1238
- --copio-color-warning: #f59e0b;
1239
- --copio-color-danger: #ef4444;
1240
- --copio-color-border: rgba(148, 163, 184, 0.18);
1241
- --copio-color-border-strong: rgba(148, 163, 184, 0.34);
1242
- --copio-focus-ring: 0 0 0 2px #0b0f17, 0 0 0 4px #38bdf8;
1243
- --copio-radius-sm: 6px;
1244
- --copio-radius-md: 10px;
1245
- --copio-radius-lg: 14px;
1246
- --copio-radius-pill: 9999px;
1247
- --copio-spacing-xs: 4px;
1248
- --copio-spacing-sm: 8px;
1249
- --copio-spacing-md: 12px;
1250
- --copio-spacing-lg: 16px;
1251
- --copio-spacing-xl: 24px;
1252
- --copio-touch-target-min: 44px;
1253
- --copio-crop-handle-hit: 48px;
1254
- --copio-crop-handle-visual: 16px;
1255
- --copio-shadow-elevated: 0 12px 32px -4px rgba(0, 0, 0, 0.55);
1256
- --copio-transition-fast: 150ms cubic-bezier(0.22, 1, 0.36, 1);
1257
- --copio-transition-normal: 240ms cubic-bezier(0.22, 1, 0.36, 1);
1258
- --sl-font-sans: var(--copio-font-family);
1259
- --sl-font-mono: var(--copio-font-mono);
1260
- --sl-color-primary-50: #f0f9ff;
1261
- --sl-color-primary-100: #e0f2fe;
1262
- --sl-color-primary-200: #bae6fd;
1263
- --sl-color-primary-300: #7dd3fc;
1264
- --sl-color-primary-400: #38bdf8;
1265
- --sl-color-primary-500: #0ea5e9;
1266
- --sl-color-primary-600: var(--copio-color-primary);
1267
- --sl-color-primary-700: #0369a1;
1268
- --sl-color-primary-800: #075985;
1269
- --sl-color-primary-900: #0c4a6e;
1270
- --sl-color-primary-950: #082f49;
1271
- font-family: var(--copio-font-family);
1272
- font-size: 14px;
1273
- line-height: 1.5;
1274
- color: var(--copio-color-text);
1275
- background-color: var(--copio-color-bg);
1276
- color-scheme: dark;
1277
- }
1278
-
1279
- :host([theme="dark"]),
1280
- :host(.copio-theme-dark),
1281
- :host-context([data-theme="dark"]),
1282
- :host-context(.sl-theme-dark),
1283
- :host-context(.theme-dark) {
1284
- color-scheme: dark;
1285
- }
1286
-
1287
- /* Light Theme Override */
1288
- :host([theme="light"]),
1289
- :host(.copio-theme-light),
1290
- :host-context([data-theme="light"]),
1291
- :host-context(.sl-theme-light),
1292
- :host-context(.theme-light) {
1293
- --copio-color-bg: #f8fafc;
1294
- --copio-color-surface: #ffffff;
1295
- --copio-color-surface-elevated: #f1f5f9;
1296
- --copio-color-surface-overlay: rgba(255, 255, 255, 0.92);
1297
- --copio-color-stage-bg: #1e293b;
1298
- --copio-color-text: #0f172a;
1299
- --copio-color-text-muted: #475569;
1300
- --copio-color-text-inverse: #ffffff;
1301
- --copio-color-primary: #0284c7;
1302
- --copio-color-primary-hover: #0369a1;
1303
- --copio-color-primary-contrast: #ffffff;
1304
- --copio-color-success: #16a34a;
1305
- --copio-color-warning: #d97706;
1306
- --copio-color-danger: #dc2626;
1307
- --copio-color-border: rgba(15, 23, 42, 0.12);
1308
- --copio-color-border-strong: rgba(15, 23, 42, 0.26);
1309
- --copio-focus-ring: 0 0 0 2px #ffffff, 0 0 0 4px #0284c7;
1310
- --copio-radius-sm: 6px;
1311
- --copio-radius-md: 10px;
1312
- --copio-radius-lg: 14px;
1313
- --copio-shadow-elevated: 0 12px 28px -4px rgba(15, 23, 42, 0.18);
1314
- color-scheme: light;
1315
- }
1316
-
1317
- /* Brand Theme Override (Emerald) */
1318
- :host([theme="brand"]),
1319
- :host(.copio-theme-brand),
1320
- :host-context([data-theme="brand"]),
1321
- :host-context(.theme-brand) {
1322
- --copio-color-bg: #0f111a;
1323
- --copio-color-surface: #181b28;
1324
- --copio-color-surface-elevated: #23273a;
1325
- --copio-color-surface-overlay: rgba(24, 27, 40, 0.90);
1326
- --copio-color-stage-bg: #090a10;
1327
- --copio-color-text: #f8fafc;
1328
- --copio-color-text-muted: #9ca3af;
1329
- --copio-color-text-inverse: #ffffff;
1330
- --copio-color-primary: #10b981;
1331
- --copio-color-primary-hover: #34d399;
1332
- --copio-color-primary-contrast: #042f2e;
1333
- --copio-color-success: #10b981;
1334
- --copio-color-warning: #f59e0b;
1335
- --copio-color-danger: #ef4444;
1336
- --copio-color-border: rgba(16, 185, 129, 0.22);
1337
- --copio-color-border-strong: rgba(16, 185, 129, 0.42);
1338
- --copio-focus-ring: 0 0 0 2px #0f111a, 0 0 0 4px #10b981;
1339
- --copio-radius-sm: 4px;
1340
- --copio-radius-md: 8px;
1341
- --copio-radius-lg: 12px;
1342
- --copio-shadow-elevated: 0 12px 32px -4px rgba(0, 0, 0, 0.65);
1343
- color-scheme: dark;
1344
- }
1345
-
1346
- /* Auto Theme: follows prefers-color-scheme when theme is auto */
1347
- @media (prefers-color-scheme: light) {
1348
- :host([theme="auto"]),
1349
- :host(.copio-theme-auto) {
1350
- --copio-color-bg: #f8fafc;
1351
- --copio-color-surface: #ffffff;
1352
- --copio-color-surface-elevated: #f1f5f9;
1353
- --copio-color-surface-overlay: rgba(255, 255, 255, 0.92);
1354
- --copio-color-stage-bg: #1e293b;
1355
- --copio-color-text: #0f172a;
1356
- --copio-color-text-muted: #475569;
1357
- --copio-color-text-inverse: #ffffff;
1358
- --copio-color-primary: #0284c7;
1359
- --copio-color-primary-hover: #0369a1;
1360
- --copio-color-primary-contrast: #ffffff;
1361
- --copio-color-success: #16a34a;
1362
- --copio-color-warning: #d97706;
1363
- --copio-color-danger: #dc2626;
1364
- --copio-color-border: rgba(15, 23, 42, 0.12);
1365
- --copio-color-border-strong: rgba(15, 23, 42, 0.26);
1366
- --copio-focus-ring: 0 0 0 2px #ffffff, 0 0 0 4px #0284c7;
1367
- --copio-radius-sm: 6px;
1368
- --copio-radius-md: 10px;
1369
- --copio-radius-lg: 14px;
1370
- --copio-shadow-elevated: 0 12px 28px -4px rgba(15, 23, 42, 0.18);
1371
- color-scheme: light;
1372
- }
1373
- }
1374
-
1375
- /* ==========================================================================
1376
- 2. INTERNAL ELEMENT RESET (Scoped to Shadow DOM)
1377
- ========================================================================== */
1378
- *, *::before, *::after {
1379
- box-sizing: border-box;
1380
- }
1381
-
1382
- ::slotted(*) {
1383
- box-sizing: border-box;
1384
- }
1385
-
1386
- /* ==========================================================================
1387
- 3. ROOT CONTAINER & COMPONENT SHELL
1388
- ========================================================================== */
1389
- .copio-scanner-container {
1390
- width: 100%;
1391
- height: 100%;
1392
- position: relative;
1393
- display: flex;
1394
- flex-direction: column;
1395
- overflow: hidden;
1396
- box-sizing: border-box;
1397
- container-type: size;
1398
- container-name: copio-scanner;
1399
- contain: layout;
1400
- background: var(--copio-color-bg);
1401
- color: var(--copio-color-text);
1402
- font-family: var(--copio-font-family);
1403
- font-size: 14px;
1404
- line-height: 1.5;
1405
- text-align: left;
1406
- direction: ltr;
1407
- user-select: none;
1408
- }
1409
-
1410
- /* Header (Shadow Part: header) */
1411
- .copio-header {
1412
- display: flex;
1413
- align-items: center;
1414
- justify-content: space-between;
1415
- gap: var(--copio-spacing-sm);
1416
- padding: var(--copio-spacing-sm) var(--copio-spacing-md);
1417
- background: var(--copio-color-surface);
1418
- border-bottom: 1px solid var(--copio-color-border);
1419
- min-height: 52px;
1420
- flex-shrink: 0;
1421
- z-index: 5;
1422
- box-sizing: border-box;
1423
- }
1424
-
1425
- .copio-header-left {
1426
- display: flex;
1427
- align-items: center;
1428
- gap: var(--copio-spacing-sm);
1429
- min-width: 0;
1430
- }
1431
-
1432
- .copio-mode-badge {
1433
- display: inline-flex;
1434
- align-items: center;
1435
- gap: 5px;
1436
- font-size: 11px;
1437
- font-weight: 600;
1438
- padding: 4px 8px;
1439
- border-radius: var(--copio-radius-pill);
1440
- background: var(--copio-color-surface-elevated);
1441
- color: var(--copio-color-primary);
1442
- border: 1px solid var(--copio-color-border);
1443
- white-space: nowrap;
1444
- }
1445
-
1446
- .copio-title-group {
1447
- display: flex;
1448
- flex-direction: column;
1449
- min-width: 0;
1450
- }
1451
-
1452
- .copio-title {
1453
- font-size: 13px;
1454
- font-weight: 600;
1455
- color: var(--copio-color-text);
1456
- margin: 0;
1457
- white-space: nowrap;
1458
- overflow: hidden;
1459
- text-overflow: ellipsis;
1460
- }
1461
-
1462
- .copio-subtitle {
1463
- font-size: 11px;
1464
- color: var(--copio-color-text-muted);
1465
- margin: 0;
1466
- white-space: nowrap;
1467
- overflow: hidden;
1468
- text-overflow: ellipsis;
1469
- }
1470
-
1471
- .copio-header-actions {
1472
- display: flex;
1473
- align-items: center;
1474
- gap: 6px;
1475
- flex-shrink: 0;
1476
- }
1477
-
1478
- /* Interactive Stage Switcher Pill (Viewfinder vs Workbench) */
1479
- .copio-stage-tabs {
1480
- display: inline-flex;
1481
- background: var(--copio-color-bg);
1482
- padding: 2px;
1483
- border-radius: var(--copio-radius-md);
1484
- border: 1px solid var(--copio-color-border);
1485
- }
1486
-
1487
- .copio-stage-tab {
1488
- appearance: none;
1489
- border: none;
1490
- background: transparent;
1491
- color: var(--copio-color-text-muted);
1492
- font-family: inherit;
1493
- font-size: 11px;
1494
- font-weight: 600;
1495
- padding: 6px 10px;
1496
- min-height: var(--copio-touch-target-min);
1497
- min-width: var(--copio-touch-target-min);
1498
- border-radius: var(--copio-radius-sm);
1499
- cursor: pointer;
1500
- display: inline-flex;
1501
- align-items: center;
1502
- justify-content: center;
1503
- transition: background var(--copio-transition-fast), color var(--copio-transition-fast);
1504
- }
1505
-
1506
- .copio-stage-tab[aria-selected="true"] {
1507
- background: var(--copio-color-surface-elevated);
1508
- color: var(--copio-color-text);
1509
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
1510
- }
1511
-
1512
- /* Touch-Safe Interactive Buttons (>=44px touch invariant) */
1513
- .copio-btn {
1514
- appearance: none;
1515
- border: 1px solid var(--copio-color-border);
1516
- background: var(--copio-color-surface-elevated);
1517
- color: var(--copio-color-text);
1518
- font-family: inherit;
1519
- font-size: 13px;
1520
- font-weight: 600;
1521
- min-height: var(--copio-touch-target-min);
1522
- min-width: var(--copio-touch-target-min);
1523
- padding: 0 12px;
1524
- border-radius: var(--copio-radius-md);
1525
- display: inline-flex;
1526
- align-items: center;
1527
- justify-content: center;
1528
- gap: 7px;
1529
- cursor: pointer;
1530
- transition: all var(--copio-transition-fast);
1531
- white-space: nowrap;
1532
- text-decoration: none;
1533
- box-sizing: border-box;
1534
- }
1535
-
1536
- .copio-btn:hover {
1537
- background: var(--copio-color-primary-hover);
1538
- color: var(--copio-color-primary-contrast);
1539
- border-color: var(--copio-color-primary);
1540
- }
1541
-
1542
- .copio-btn-primary {
1543
- background: var(--copio-color-primary);
1544
- color: var(--copio-color-primary-contrast);
1545
- border-color: var(--copio-color-primary);
1546
- }
1547
-
1548
- .copio-btn-danger {
1549
- background: rgba(239, 68, 68, 0.15);
1550
- color: var(--copio-color-danger);
1551
- border-color: rgba(239, 68, 68, 0.35);
1552
- }
1553
-
1554
- .copio-btn-danger:hover {
1555
- background: var(--copio-color-danger);
1556
- color: #fff;
1557
- }
1558
-
1559
- /* Viewfinder (Shadow Part: viewfinder) */
1560
- .copio-viewfinder,
1561
- .copio-viewfinder-stage {
1562
- position: relative;
1563
- flex: 1 1 auto;
1564
- display: flex;
1565
- flex-direction: column;
1566
- justify-content: space-between;
1567
- background: var(--copio-color-stage-bg);
1568
- overflow: hidden;
1569
- min-height: 0;
1570
- width: 100%;
1571
- }
1572
-
1573
- .copio-viewfinder-feed,
1574
- .copio-camera-feed {
1575
- position: absolute;
1576
- inset: 0;
1577
- display: flex;
1578
- align-items: center;
1579
- justify-content: center;
1580
- padding: 56px 20px 104px 20px;
1581
- background: radial-gradient(circle at 50% 45%, #1e293b 0%, #090d14 75%);
1582
- }
1583
-
1584
- /* Framing Guide Overlay (receipt | card | a4 | auto) */
1585
- .copio-framing-guide {
1586
- position: relative;
1587
- display: flex;
1588
- align-items: center;
1589
- justify-content: center;
1590
- max-width: 100%;
1591
- max-height: 100%;
1592
- border: 1.5px dashed rgba(56, 189, 248, 0.55);
1593
- border-radius: 12px;
1594
- box-shadow: 0 0 0 9999px rgba(4, 7, 12, 0.52);
1595
- transition: all var(--copio-transition-normal);
1596
- overflow: hidden;
1597
- }
1598
-
1599
- .copio-framing-guide[data-aspect="receipt"] {
1600
- aspect-ratio: 1 / 2.1;
1601
- height: 100%;
1602
- }
1603
-
1604
- .copio-framing-guide[data-aspect="card"] {
1605
- aspect-ratio: 1.586 / 1;
1606
- width: 92%;
1607
- max-height: 82%;
1608
- }
1609
-
1610
- .copio-framing-guide[data-aspect="a4"] {
1611
- aspect-ratio: 1 / 1.414;
1612
- height: 96%;
1613
- }
1614
-
1615
- .copio-framing-guide[data-aspect="auto"] {
1616
- width: 94%;
1617
- height: 94%;
1618
- }
1619
-
1620
- /* Corner Targeting Brackets */
1621
- .copio-corner {
1622
- position: absolute;
1623
- width: 22px;
1624
- height: 22px;
1625
- border-color: var(--copio-color-primary);
1626
- border-style: solid;
1627
- border-width: 0;
1628
- pointer-events: none;
1629
- z-index: 2;
1630
- }
1631
- .copio-corner.tl { top: 6px; left: 6px; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 6px; }
1632
- .copio-corner.tr { top: 6px; right: 6px; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 6px; }
1633
- .copio-corner.bl { bottom: 6px; left: 6px; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 6px; }
1634
- .copio-corner.br { bottom: 6px; right: 6px; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 6px; }
1635
-
1636
- .copio-edge-quad {
1637
- position: absolute;
1638
- inset: 12px;
1639
- border: 1px solid rgba(56, 189, 248, 0.28);
1640
- border-radius: 8px;
1641
- background: rgba(56, 189, 248, 0.04);
1642
- pointer-events: none;
1643
- z-index: 1;
1644
- }
1645
-
1646
- .copio-camera-placeholder {
1647
- position: relative;
1648
- z-index: 2;
1649
- display: flex;
1650
- flex-direction: column;
1651
- align-items: center;
1652
- justify-content: center;
1653
- gap: 8px;
1654
- padding: 16px;
1655
- text-align: center;
1656
- color: var(--copio-color-text-muted);
1657
- font-size: 12px;
1658
- font-weight: 500;
1659
- }
1660
-
1661
- .copio-status-dot {
1662
- width: 7px;
1663
- height: 7px;
1664
- border-radius: 50%;
1665
- background: var(--copio-color-primary);
1666
- box-shadow: 0 0 8px var(--copio-color-primary);
1667
- flex-shrink: 0;
1668
- }
1669
-
1670
- /* Top Viewfinder HUD Overlay (Step Pill + Privacy Assurance Badge) */
1671
- .copio-viewfinder-hud-top {
1672
- position: relative;
1673
- z-index: 3;
1674
- display: flex;
1675
- align-items: center;
1676
- justify-content: space-between;
1677
- gap: 8px;
1678
- padding: 10px 14px;
1679
- background: linear-gradient(to bottom, rgba(7, 10, 15, 0.85), transparent);
1680
- }
1681
-
1682
- .copio-step-pill {
1683
- display: inline-flex;
1684
- align-items: center;
1685
- gap: 6px;
1686
- padding: 5px 12px;
1687
- border-radius: var(--copio-radius-pill);
1688
- background: rgba(15, 23, 42, 0.88);
1689
- border: 1px solid rgba(56, 189, 248, 0.45);
1690
- color: #f8fafc;
1691
- font-size: 12px;
1692
- font-weight: 600;
1693
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
1694
- }
1695
-
1696
- .copio-privacy-pill {
1697
- display: inline-flex;
1698
- align-items: center;
1699
- gap: 5px;
1700
- padding: 4px 9px;
1701
- border-radius: var(--copio-radius-pill);
1702
- background: rgba(22, 101, 52, 0.35);
1703
- border: 1px solid rgba(34, 197, 94, 0.4);
1704
- color: #86efac;
1705
- font-size: 11px;
1706
- font-weight: 500;
1707
- }
1708
-
1709
- /* Shutter Dock (Shadow Part: shutter-dock) */
1710
- .copio-shutter-dock {
1711
- position: relative;
1712
- z-index: 3;
1713
- display: flex;
1714
- align-items: center;
1715
- justify-content: space-between;
1716
- gap: 12px;
1717
- padding: 12px 16px;
1718
- background: var(--copio-color-surface);
1719
- border-top: 1px solid var(--copio-color-border);
1720
- min-height: 84px;
1721
- flex-shrink: 0;
1722
- }
1723
-
1724
- .copio-shutter-side {
1725
- flex: 1;
1726
- display: flex;
1727
- align-items: center;
1728
- }
1729
-
1730
- .copio-shutter-side.right {
1731
- justify-content: flex-end;
1732
- }
1733
-
1734
- .copio-shutter-btn {
1735
- appearance: none;
1736
- width: 64px;
1737
- height: 64px;
1738
- border-radius: var(--copio-radius-pill);
1739
- border: 4px solid var(--copio-color-primary);
1740
- background: transparent;
1741
- padding: 4px;
1742
- cursor: pointer;
1743
- display: inline-flex;
1744
- align-items: center;
1745
- justify-content: center;
1746
- transition: transform var(--copio-transition-fast), border-color 150ms ease;
1747
- flex-shrink: 0;
1748
- }
1749
-
1750
- .copio-shutter-btn:hover {
1751
- transform: scale(1.04);
1752
- }
1753
-
1754
- .copio-shutter-btn:active {
1755
- transform: scale(0.94);
1756
- }
1757
-
1758
- .copio-shutter-btn-inner,
1759
- .copio-shutter-inner {
1760
- width: 100%;
1761
- height: 100%;
1762
- border-radius: var(--copio-radius-pill);
1763
- background: var(--copio-color-primary);
1764
- display: flex;
1765
- align-items: center;
1766
- justify-content: center;
1767
- color: var(--copio-color-primary-contrast);
1768
- transition: transform var(--copio-transition-fast);
1769
- }
1770
-
1771
- .copio-shutter-btn:active .copio-shutter-btn-inner,
1772
- .copio-shutter-btn:active .copio-shutter-inner {
1773
- transform: scale(0.88);
1774
- }
1775
-
1776
- /* Stacking Thumbnail Counter Pill in Viewfinder */
1777
- .copio-stack-pill {
1778
- display: inline-flex;
1779
- align-items: center;
1780
- gap: 8px;
1781
- min-height: var(--copio-touch-target-min);
1782
- padding: 4px 12px 4px 6px;
1783
- border-radius: var(--copio-radius-md);
1784
- background: var(--copio-color-surface-elevated);
1785
- border: 1px solid var(--copio-color-primary);
1786
- color: var(--copio-color-text);
1787
- font-size: 12px;
1788
- font-weight: 600;
1789
- cursor: pointer;
1790
- }
1791
-
1792
- .copio-stack-thumb {
1793
- width: 30px;
1794
- height: 36px;
1795
- border-radius: 4px;
1796
- object-fit: cover;
1797
- border: 1px solid rgba(255, 255, 255, 0.35);
1798
- background: #000;
1799
- }
1800
-
1801
- /* Workbench & Filmstrip (Shadow Part: workbench) */
1802
- .copio-workbench,
1803
- .copio-workbench-stage {
1804
- position: relative;
1805
- flex: 1 1 auto;
1806
- display: flex;
1807
- flex-direction: column;
1808
- background: var(--copio-color-bg);
1809
- overflow: hidden;
1810
- min-height: 0;
1811
- width: 100%;
1812
- }
1813
-
1814
- .copio-workbench-main {
1815
- flex: 1;
1816
- display: flex;
1817
- flex-direction: column;
1818
- min-height: 0;
1819
- width: 100%;
1820
- overflow: hidden;
1821
- }
1822
-
1823
- .copio-stage-canvas,
1824
- .copio-canvas-viewport {
1825
- position: relative;
1826
- flex: 1 1 auto;
1827
- display: flex;
1828
- flex-direction: column;
1829
- align-items: center;
1830
- justify-content: center;
1831
- overflow: hidden;
1832
- padding: 16px 20px 44px 20px;
1833
- background: var(--copio-color-stage-bg);
1834
- min-height: 180px;
1835
- }
1836
-
1837
- .copio-canvas-viewport.has-card-switcher {
1838
- padding-top: 66px;
1839
- }
1840
-
1841
- .copio-canvas-viewport.is-cropping {
1842
- padding: 74px 26px 26px 26px;
1843
- }
1844
-
1845
- /* Card Side Switcher */
1846
- .copio-card-side-switcher {
1847
- position: absolute;
1848
- top: 8px;
1849
- left: 50%;
1850
- transform: translateX(-50%);
1851
- z-index: 6;
1852
- display: inline-flex;
1853
- gap: 4px;
1854
- padding: 3px;
1855
- background: var(--copio-color-surface-overlay, rgba(15, 22, 32, 0.88));
1856
- border: 1px solid var(--copio-color-border-strong);
1857
- border-radius: var(--copio-radius-pill);
1858
- backdrop-filter: blur(8px);
1859
- }
1860
-
1861
- .copio-side-pill {
1862
- appearance: none;
1863
- border: none;
1864
- background: transparent;
1865
- color: var(--copio-color-text-muted);
1866
- font-family: inherit;
1867
- font-size: 11px;
1868
- font-weight: 600;
1869
- padding: 6px 12px;
1870
- min-height: var(--copio-touch-target-min);
1871
- min-width: var(--copio-touch-target-min);
1872
- border-radius: var(--copio-radius-pill);
1873
- cursor: pointer;
1874
- display: inline-flex;
1875
- align-items: center;
1876
- justify-content: center;
1877
- }
1878
-
1879
- .copio-side-pill[aria-selected="true"] {
1880
- background: var(--copio-color-primary);
1881
- color: var(--copio-color-primary-contrast);
1882
- }
1883
-
1884
- .copio-stage-figure,
1885
- .copio-canvas-wrapper {
1886
- position: relative;
1887
- display: flex;
1888
- align-items: center;
1889
- justify-content: center;
1890
- max-width: 100%;
1891
- max-height: 100%;
1892
- }
1893
-
1894
- .copio-stage-canvas img,
1895
- .copio-stage-img,
1896
- .copio-stage-image {
1897
- display: block;
1898
- max-width: 100%;
1899
- max-height: 100%;
1900
- width: auto;
1901
- height: auto;
1902
- object-fit: contain;
1903
- box-shadow: var(--copio-shadow-elevated);
1904
- border-radius: var(--copio-radius-sm);
1905
- user-select: none;
1906
- }
1907
-
1908
- .copio-crop-layer {
1909
- position: absolute;
1910
- inset: 0;
1911
- width: 100%;
1912
- height: 100%;
1913
- overflow: hidden;
1914
- z-index: 8;
1915
- touch-action: none;
1916
- }
1917
-
1918
- .copio-crop-box {
1919
- position: absolute;
1920
- border: 2px solid var(--copio-color-primary);
1921
- box-shadow: 0 0 0 9999px rgba(5, 8, 14, 0.68);
1922
- cursor: move;
1923
- touch-action: none;
1924
- box-sizing: border-box;
1925
- }
1926
-
1927
- /* Rule-of-thirds crop grid */
1928
- .copio-crop-grid {
1929
- position: absolute;
1930
- inset: 0;
1931
- pointer-events: none;
1932
- background-image:
1933
- linear-gradient(to right, rgba(56, 189, 248, 0.28) 1px, transparent 1px),
1934
- linear-gradient(to bottom, rgba(56, 189, 248, 0.28) 1px, transparent 1px);
1935
- background-size: 33.333% 33.333%;
1936
- }
1937
-
1938
- /* 48px x 48px Touch Target Handles (exceeds 44px requirement) */
1939
- .copio-crop-handle {
1940
- position: absolute;
1941
- width: var(--copio-crop-handle-hit);
1942
- height: var(--copio-crop-handle-hit);
1943
- min-width: 44px;
1944
- min-height: 44px;
1945
- display: flex;
1946
- align-items: center;
1947
- justify-content: center;
1948
- z-index: 10;
1949
- touch-action: none;
1950
- box-sizing: border-box;
1951
- }
1952
-
1953
- .copio-crop-handle::after {
1954
- content: '';
1955
- width: var(--copio-crop-handle-visual);
1956
- height: var(--copio-crop-handle-visual);
1957
- border-radius: 50%;
1958
- background: var(--copio-color-primary);
1959
- border: 2.5px solid #ffffff;
1960
- box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
1961
- transition: transform 120ms ease;
1962
- box-sizing: border-box;
1963
- }
1964
-
1965
- .copio-crop-handle:hover::after,
1966
- .copio-crop-handle:active::after {
1967
- transform: scale(1.25);
1968
- background: var(--copio-color-success, #22c55e);
1969
- }
1970
-
1971
- .copio-crop-handle.nw { top: -24px; left: -24px; cursor: nwse-resize; }
1972
- .copio-crop-handle.ne { top: -24px; right: -24px; cursor: nesw-resize; }
1973
- .copio-crop-handle.sw { bottom: -24px; left: -24px; cursor: nesw-resize; }
1974
- .copio-crop-handle.se { bottom: -24px; right: -24px; cursor: nwse-resize; }
1975
- .copio-crop-handle.n, .copio-crop-handle.edge-n { top: -24px; left: calc(50% - 24px); cursor: ns-resize; }
1976
- .copio-crop-handle.s, .copio-crop-handle.edge-s { bottom: -24px; left: calc(50% - 24px); cursor: ns-resize; }
1977
- .copio-crop-handle.w, .copio-crop-handle.edge-w { left: -24px; top: calc(50% - 24px); cursor: ew-resize; }
1978
- .copio-crop-handle.e, .copio-crop-handle.edge-e { right: -24px; top: calc(50% - 24px); cursor: ew-resize; }
1979
-
1980
- /* Filmstrip & Reorder Tray */
1981
- .copio-filmstrip,
1982
- .copio-filmstrip-bar {
1983
- display: flex;
1984
- align-items: center;
1985
- gap: 8px;
1986
- padding: 8px 12px;
1987
- background: var(--copio-color-surface);
1988
- border-top: 1px solid var(--copio-color-border);
1989
- overflow-x: auto;
1990
- min-height: 80px;
1991
- flex-shrink: 0;
1992
- }
1993
-
1994
- .copio-filmstrip-scroll {
1995
- display: flex;
1996
- align-items: center;
1997
- gap: 8px;
1998
- }
1999
-
2000
- .copio-filmstrip-item {
2001
- display: flex;
2002
- flex-direction: column;
2003
- align-items: center;
2004
- gap: 4px;
2005
- flex-shrink: 0;
2006
- }
2007
-
2008
- .copio-thumb-container {
2009
- position: relative;
2010
- width: 56px;
2011
- height: 70px;
2012
- border-radius: var(--copio-radius-sm);
2013
- overflow: hidden;
2014
- background: #000;
2015
- border: 2px solid var(--copio-color-border);
2016
- cursor: pointer;
2017
- transition: all var(--copio-transition-fast);
2018
- }
2019
-
2020
- .copio-filmstrip-item.is-active .copio-thumb-container {
2021
- border-color: var(--copio-color-primary);
2022
- box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
2023
- }
2024
-
2025
- .copio-thumb-num {
2026
- position: absolute;
2027
- bottom: 3px;
2028
- right: 3px;
2029
- min-width: 16px;
2030
- height: 16px;
2031
- padding: 0 4px;
2032
- border-radius: 999px;
2033
- background: rgba(15, 23, 42, 0.85);
2034
- color: #f8fafc;
2035
- font-size: 10px;
2036
- font-weight: 700;
2037
- display: inline-flex;
2038
- align-items: center;
2039
- justify-content: center;
2040
- }
2041
-
2042
- .copio-thumb-reorder {
2043
- display: flex;
2044
- align-items: center;
2045
- gap: 4px;
2046
- }
2047
-
2048
- .copio-reorder-btn {
2049
- appearance: none;
2050
- border: 1px solid var(--copio-color-border);
2051
- background: var(--copio-color-surface-elevated);
2052
- color: var(--copio-color-text-muted);
2053
- border-radius: 4px;
2054
- font-size: 9px;
2055
- padding: 2px 5px;
2056
- cursor: pointer;
2057
- }
2058
-
2059
- .copio-reorder-btn:disabled {
2060
- opacity: 0.35;
2061
- cursor: not-allowed;
2062
- }
2063
-
2064
- .copio-thumb-img {
2065
- width: 100%;
2066
- height: 100%;
2067
- object-fit: cover;
2068
- }
2069
-
2070
- /* Edit Action Toolbar & Primary Completion Dock */
2071
- .copio-toolbar,
2072
- .copio-controls-dock {
2073
- display: flex;
2074
- flex-direction: column;
2075
- gap: 8px;
2076
- padding: 10px 12px;
2077
- background: var(--copio-color-surface);
2078
- border-top: 1px solid var(--copio-color-border);
2079
- min-height: 56px;
2080
- flex-shrink: 0;
2081
- z-index: 6;
2082
- }
2083
-
2084
- .copio-edit-toolbar,
2085
- .copio-toolbar-tools {
2086
- display: flex;
2087
- flex-wrap: wrap;
2088
- align-items: center;
2089
- gap: 6px;
2090
- width: 100%;
2091
- }
2092
-
2093
- .copio-toolbar-tools .copio-tool-btn {
2094
- flex: 1 1 56px;
2095
- }
2096
-
2097
- .copio-toolbar-actions {
2098
- display: flex;
2099
- align-items: center;
2100
- gap: 8px;
2101
- width: 100%;
2102
- }
2103
-
2104
- .copio-toolbar-actions .copio-btn-primary {
2105
- width: 100%;
2106
- }
2107
-
2108
- .copio-tool-btn {
2109
- appearance: none;
2110
- border: 1px solid var(--copio-color-border);
2111
- background: var(--copio-color-surface-elevated);
2112
- color: var(--copio-color-text);
2113
- font-family: inherit;
2114
- font-size: 11px;
2115
- font-weight: 600;
2116
- min-height: var(--copio-touch-target-min);
2117
- min-width: var(--copio-touch-target-min);
2118
- padding: 4px 6px;
2119
- border-radius: var(--copio-radius-md);
2120
- display: flex;
2121
- flex-direction: column;
2122
- align-items: center;
2123
- justify-content: center;
2124
- gap: 3px;
2125
- cursor: pointer;
2126
- transition: all var(--copio-transition-fast);
2127
- }
2128
-
2129
- .copio-tool-btn:hover:not(:disabled) {
2130
- border-color: var(--copio-color-border-strong);
2131
- background: rgba(255, 255, 255, 0.06);
2132
- }
2133
-
2134
- .copio-tool-btn[aria-pressed="true"] {
2135
- background: rgba(56, 189, 248, 0.16);
2136
- color: var(--copio-color-primary);
2137
- border-color: var(--copio-color-primary);
2138
- }
2139
-
2140
- .copio-tool-btn.danger {
2141
- color: #fca5a5;
2142
- }
2143
-
2144
- .copio-tool-btn.danger:hover:not(:disabled) {
2145
- background: rgba(239, 68, 68, 0.16);
2146
- border-color: rgba(239, 68, 68, 0.45);
2147
- }
2148
-
2149
- .copio-toast-region {
2150
- position: absolute;
2151
- bottom: 124px;
2152
- left: 12px;
2153
- right: 12px;
2154
- z-index: 30;
2155
- display: flex;
2156
- flex-direction: column;
2157
- gap: 8px;
2158
- pointer-events: none;
2159
- }
2160
-
2161
- .copio-toast {
2162
- pointer-events: auto;
2163
- display: flex;
2164
- align-items: center;
2165
- justify-content: space-between;
2166
- gap: 10px;
2167
- padding: 8px 12px;
2168
- border-radius: var(--copio-radius-md);
2169
- background: #0f172a;
2170
- color: #f8fafc;
2171
- border: 1px solid var(--copio-color-primary);
2172
- box-shadow: var(--copio-shadow-elevated);
2173
- font-size: 12px;
2174
- font-weight: 500;
2175
- position: relative;
2176
- overflow: hidden;
2177
- }
2178
-
2179
- .copio-toast-progress {
2180
- position: absolute;
2181
- bottom: 0;
2182
- left: 0;
2183
- height: 3px;
2184
- background: var(--copio-color-primary);
2185
- transition: width 100ms linear;
2186
- }
2187
-
2188
- .copio-toast-undo-btn,
2189
- .copio-btn-toast-undo {
2190
- appearance: none;
2191
- border: 1px solid rgba(56, 189, 248, 0.45);
2192
- background: rgba(56, 189, 248, 0.16);
2193
- color: #38bdf8;
2194
- font-family: inherit;
2195
- font-size: 12px;
2196
- font-weight: 700;
2197
- min-height: var(--copio-touch-target-min);
2198
- min-width: var(--copio-touch-target-min);
2199
- padding: 0 12px;
2200
- border-radius: var(--copio-radius-sm);
2201
- cursor: pointer;
2202
- flex-shrink: 0;
2203
- }
2204
-
2205
- .copio-ocr-content {
2206
- display: flex;
2207
- flex-direction: column;
2208
- gap: 8px;
2209
- }
2210
-
2211
- .copio-ocr-text {
2212
- margin: 0;
2213
- padding: 10px;
2214
- max-height: 180px;
2215
- overflow: auto;
2216
- background: var(--copio-color-bg);
2217
- color: var(--copio-color-text);
2218
- border: 1px solid var(--copio-color-border);
2219
- border-radius: var(--copio-radius-sm);
2220
- font-family: var(--copio-font-mono);
2221
- font-size: 11px;
2222
- line-height: 1.5;
2223
- white-space: pre-wrap;
2224
- }
2225
-
2226
- .copio-ocr-meta {
2227
- font-size: 11px;
2228
- color: var(--copio-color-text-muted);
2229
- }
2230
-
2231
- /* Slide-up OCR Extraction Sheet */
2232
- .copio-ocr-sheet {
2233
- position: absolute;
2234
- inset: auto 0 0 0;
2235
- max-height: 78%;
2236
- background: var(--copio-color-surface);
2237
- border-top: 1px solid var(--copio-color-primary);
2238
- border-radius: 16px 16px 0 0;
2239
- box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.65);
2240
- z-index: 25;
2241
- display: flex;
2242
- flex-direction: column;
2243
- padding: 14px;
2244
- gap: 10px;
2245
- }
2246
-
2247
- .copio-ocr-header {
2248
- display: flex;
2249
- align-items: center;
2250
- justify-content: space-between;
2251
- gap: 8px;
2252
- }
2253
-
2254
- .copio-ocr-textarea {
2255
- width: 100%;
2256
- min-height: 130px;
2257
- flex: 1;
2258
- resize: none;
2259
- background: var(--copio-color-bg);
2260
- color: var(--copio-color-text);
2261
- border: 1px solid var(--copio-color-border);
2262
- border-radius: var(--copio-radius-sm);
2263
- padding: 10px;
2264
- font-family: var(--copio-font-mono);
2265
- font-size: 11px;
2266
- line-height: 1.5;
2267
- }
2268
-
2269
- /* Container-Scoped Toast Stack */
2270
- .sl-toast-stack,
2271
- .copio-toast-stack-scoped {
2272
- position: absolute !important;
2273
- top: auto !important;
2274
- bottom: 0 !important;
2275
- left: 0 !important;
2276
- right: 0 !important;
2277
- width: 100% !important;
2278
- max-width: 100% !important;
2279
- padding: var(--copio-spacing-md) !important;
2280
- box-sizing: border-box !important;
2281
- z-index: 1000 !important;
2282
- pointer-events: none;
2283
- }
2284
-
2285
- .sl-toast-stack sl-alert,
2286
- .copio-toast-stack-scoped sl-alert {
2287
- pointer-events: auto;
2288
- margin-top: var(--copio-spacing-sm);
2289
- }
2290
-
2291
- /* ==========================================================================
2292
- 4. @container BREAKPOINTS (Strictly Container Queries)
2293
- ========================================================================== */
2294
-
2295
- @container copio-scanner (max-width: 400px) {
2296
- .copio-header {
2297
- padding: 6px 10px;
2298
- min-height: 52px;
2299
- }
2300
- .copio-header-left {
2301
- flex-direction: column;
2302
- align-items: flex-start;
2303
- gap: 2px;
2304
- }
2305
- .copio-mode-badge {
2306
- font-size: 10px;
2307
- padding: 2px 6px;
2308
- }
2309
- .copio-subtitle {
2310
- display: none;
2311
- }
2312
- .copio-filmstrip,
2313
- .copio-filmstrip-bar {
2314
- gap: 6px;
2315
- padding: 6px 8px;
2316
- }
2317
- .copio-tool-btn {
2318
- font-size: 10px;
2319
- padding: 3px 4px;
2320
- }
2321
- .copio-btn {
2322
- padding: 0 8px;
2323
- font-size: 12px;
2324
- }
2325
- }
2326
-
2327
- @container copio-scanner (min-width: 401px) and (max-width: 767px) {
2328
- .copio-header {
2329
- padding: var(--copio-spacing-sm) var(--copio-spacing-md);
2330
- }
2331
- .copio-tool-btn {
2332
- flex-direction: row;
2333
- font-size: 12px;
2334
- gap: 6px;
2335
- }
2336
- }
2337
-
2338
- @container copio-scanner (min-width: 768px) {
2339
- .copio-header {
2340
- padding: var(--copio-spacing-md) var(--copio-spacing-lg);
2341
- }
2342
- .copio-workbench-main {
2343
- flex-direction: row;
2344
- }
2345
- .copio-filmstrip,
2346
- .copio-filmstrip-bar {
2347
- order: -1;
2348
- flex-direction: column;
2349
- width: 168px;
2350
- height: 100%;
2351
- border-top: none;
2352
- border-right: 1px solid var(--copio-color-border);
2353
- overflow-y: auto;
2354
- overflow-x: hidden;
2355
- padding: 12px;
2356
- }
2357
- .copio-filmstrip-scroll {
2358
- flex-direction: column;
2359
- width: 100%;
2360
- }
2361
- .copio-thumb-container {
2362
- width: 112px;
2363
- height: 84px;
2364
- }
2365
- .copio-toolbar,
2366
- .copio-controls-dock {
2367
- flex-direction: row;
2368
- align-items: center;
2369
- justify-content: space-between;
2370
- }
2371
- .copio-toolbar-tools {
2372
- width: auto;
2373
- flex: 1;
2374
- }
2375
- .copio-toolbar-actions {
2376
- width: auto;
2377
- min-width: 200px;
2378
- }
2379
- }
2380
- `,Ne=null;function lo(){if(Ne)return Ne;if(typeof CSSStyleSheet<"u"&&typeof Document<"u"&&"adoptedStyleSheets"in Document.prototype&&"replaceSync"in CSSStyleSheet.prototype)try{return Ne=new CSSStyleSheet,Ne.replaceSync(Ct),Ne}catch{return null}return null}function co(i){if(!i)return;let e=lo();if(e&&"adoptedStyleSheets"in i){let t=i.adoptedStyleSheets||[];t.includes(e)||(i.adoptedStyleSheets=[...t,e])}else if(!i.querySelector("style[data-copio-encapsulated-styles]")){let t=document.createElement("style");t.setAttribute("data-copio-encapsulated-styles",""),t.textContent=Ct,i.appendChild(t)}}var Lo=typeof HTMLElement<"u"?HTMLElement:class{},Dt=class extends Lo{#e=null;#t=null;#s=null;#d=!1;#r="viewfinder";#i=0;#p=0;#h=!1;#n=!1;#l=null;#c=null;#m=0;#f=null;#b=null;#u=null;onShutter=null;get#o(){return this.docId?this.docId:(this.#b||(this.#b=`doc_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`),this.#b)}static get observedAttributes(){return["mode","aspect","stage","doc-id","features","export-formats","ocr-languages","max-pages","asset-base","license-key","theme","ocr","pdf"]}constructor(){super(),typeof this.attachShadow=="function"&&this.attachShadow({mode:"open"}),this.#x()}#x(){let e={storage:this.#t};typeof this.getAttribute=="function"&&(this.hasAttribute("features")&&(e.features=this.getAttribute("features")),this.hasAttribute("export-formats")&&(e.exportFormats=this.getAttribute("export-formats")),this.hasAttribute("ocr-languages")&&(e.ocrLanguages=this.getAttribute("ocr-languages")),this.hasAttribute("max-pages")&&(e.maxPages=this.getAttribute("max-pages")),this.hasAttribute("asset-base")&&(e.assetBase=this.getAttribute("asset-base")),this.hasAttribute("license-key")&&(e.licenseKey=this.getAttribute("license-key")),this.hasAttribute("ocr")&&(e.ocr=this.getAttribute("ocr")!=="false"),this.hasAttribute("pdf")&&(e.pdf=this.getAttribute("pdf")!=="false")),this.#e=new nt(e)}connectedCallback(){this.shadowRoot&&(co(this.shadowRoot),this.#A()),typeof Ce=="function"&&typeof document<"u"&&st()===document.body&&Ce(this.shadowRoot?.querySelector(".copio-scanner-container")||this),this.#e&&(this.#s=this.#e.subscribe(async()=>{let e=await this.getPages();this.dispatch(R.PAGES_CHANGED,{pages:e,docId:this.docId}),this.#a()})),this.hasAttribute&&this.hasAttribute("asset-base")&&_t(this.getAttribute("asset-base")),this.#g(),this.#a()}disconnectedCallback(){if(this.#v(),typeof this.#s=="function"&&(this.#s(),this.#s=null),this.#c&&(clearInterval(this.#c),this.#c=null),typeof Ce=="function"&&typeof document<"u"){let e=this.shadowRoot?.querySelector(".copio-scanner-container")||this;st()===e&&Ce(null)}}attributeChangedCallback(e,t,o){if(!(t===o||!this.#e))switch(e){case"features":this.#e.setFeatures(o),this.#g();break;case"export-formats":this.#e.exportFormats=o,this.#g();break;case"ocr-languages":this.#e.ocrLanguages=o;break;case"asset-base":this.#e.assetBase=o;break;case"license-key":this.#e.licenseKey=o;break;case"ocr":this.#e.ocr=o!=="false",this.#g();break;case"pdf":this.#e.pdf=o!=="false",this.#g();break;case"stage":if(o==="viewfinder"||o==="workbench"){this.#r=o;let r=this.shadowRoot;if(r){let a=r.getElementById("viewfinder-section"),n=r.getElementById("workbench-section");a&&n&&(a.style.display=o==="viewfinder"?"flex":"none",n.style.display=o==="workbench"?"flex":"none")}this.#a()}break;case"max-pages":this.#e.maxPages=o,this.#a();break;case"mode":case"aspect":case"theme":this.#a();break}}#g(){if(typeof this.querySelectorAll!="function")return;let e=[];this.shadowRoot&&e.push(this.shadowRoot),e.push(this);for(let t of e){let o=t.querySelectorAll("copio-carousel, copio-row, copio-images");for(let r of o)"ocr"in r&&(r.ocr=this.ocrEnabled),"pdf"in r&&(r.pdf=this.pdf)}}#A(){if(!this.shadowRoot||this.shadowRoot.innerHTML)return;let e="Align Document Inside Frame";this.aspect==="card"?e="Step 1 of 2: Capture Front of ID Card":this.mode==="batch"&&(e="Batch Capture \xB7 Page 1"),this.shadowRoot.innerHTML=`
2381
- <div class="copio-scanner-container copio-scanner-host" part="scanner-root">
2382
- <header class="copio-header" part="header">
2383
- <div class="copio-header-left">
2384
- <span class="copio-mode-badge" id="mode-badge">${(this.mode||"single").toUpperCase()}</span>
2385
- <div class="copio-title-group">
2386
- <h2 class="copio-title" id="header-title">Copio Scanner</h2>
2387
- <p class="copio-subtitle" id="header-subtitle">Non-destructive mobile document scanner</p>
2388
- </div>
2389
- </div>
2390
- <div class="copio-header-actions" part="header-actions">
2391
- <div class="copio-stage-tabs" role="tablist" aria-label="Scanner Stage">
2392
- <button type="button" class="copio-stage-tab" id="tab-viewfinder" role="tab" aria-selected="true">Camera</button>
2393
- <button type="button" class="copio-stage-tab" id="tab-workbench" role="tab" aria-selected="false">Workbench</button>
2394
- </div>
2395
- <slot name="header-actions"></slot>
2396
- </div>
2397
- </header>
2398
-
2399
- <!-- Viewfinder Stage -->
2400
- <div class="copio-viewfinder copio-viewfinder-stage" part="viewfinder" id="viewfinder-section">
2401
- <div class="copio-viewfinder-hud-top">
2402
- <div class="copio-step-pill" id="step-pill">
2403
- <span class="copio-status-dot"></span>
2404
- <span id="step-pill-text">${e}</span>
2405
- </div>
2406
- <div class="copio-privacy-pill" title="100% Local On-Device Processing">
2407
- <span>\u{1F512} 100% Local</span>
2408
- </div>
2409
- </div>
2410
-
2411
- <div class="copio-camera-feed" id="camera-feed">
2412
- <video id="camera-video" autoplay playsinline muted style="display:none; position:absolute; inset:0; width:100%; height:100%; object-fit:cover; z-index:0;"></video>
2413
- <slot name="viewfinder">
2414
- <div class="copio-framing-guide" id="framing-guide" data-aspect="${this.aspect}">
2415
- <span class="copio-corner tl"></span>
2416
- <span class="copio-corner tr"></span>
2417
- <span class="copio-corner bl"></span>
2418
- <span class="copio-corner br"></span>
2419
- <div class="copio-edge-quad"></div>
2420
- <div class="copio-camera-placeholder">
2421
- <svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
2422
- <path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/>
2423
- <circle cx="12" cy="13" r="4"/>
2424
- </svg>
2425
- <span>Position document within guide lines</span>
2426
- </div>
2427
- </div>
2428
- </slot>
2429
- </div>
2430
-
2431
- <div class="copio-shutter-dock" part="shutter-dock">
2432
- <div class="copio-shutter-side left">
2433
- <button type="button" class="copio-btn copio-btn-secondary" id="btn-import-file" title="Import image from file">
2434
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2435
- <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
2436
- <polyline points="17 8 12 3 7 8"/>
2437
- <line x1="12" y1="3" x2="12" y2="15"/>
2438
- </svg>
2439
- <span>Import</span>
2440
- </button>
2441
- </div>
2442
-
2443
- <slot name="shutter-dock">
2444
- <button type="button" class="copio-shutter-btn" id="btn-shutter" aria-label="Capture page">
2445
- <span class="copio-shutter-btn-inner"></span>
2446
- </button>
2447
- </slot>
2448
-
2449
- <div class="copio-shutter-side right">
2450
- <button type="button" class="copio-stack-pill" id="btn-review" title="Review pages" style="display:none;">
2451
- <span id="review-pill-text">Review (0) \u2192</span>
2452
- </button>
2453
- </div>
2454
- </div>
2455
- </div>
2456
-
2457
- <!-- Workbench Stage -->
2458
- <div class="copio-workbench copio-workbench-stage" part="workbench" id="workbench-section" style="display: none;">
2459
- <div class="copio-workbench-main">
2460
- <div class="copio-canvas-viewport" id="canvas-viewport">
2461
- <div class="copio-card-side-switcher" id="card-side-switcher" style="display:none;" role="tablist" aria-label="Card side switcher">
2462
- <button type="button" role="tab" class="copio-side-pill active" id="btn-card-front" aria-selected="true">1. Front Side</button>
2463
- <button type="button" role="tab" class="copio-side-pill" id="btn-card-back" aria-selected="false">2. Back Side</button>
2464
- </div>
2465
-
2466
- <div class="copio-canvas-wrapper" id="canvas-wrapper">
2467
- <img id="stage-img" class="copio-stage-image" alt="Active document page" />
2468
- </div>
2469
- </div>
2470
-
2471
- <!-- Filmstrip Tray -->
2472
- <div class="copio-filmstrip" id="filmstrip-tray" part="filmstrip">
2473
- <div class="copio-filmstrip-scroll" id="filmstrip-scroll">
2474
- <slot name="filmstrip"></slot>
2475
- </div>
2476
- </div>
2477
- </div>
2478
-
2479
- <!-- Bottom Action Toolbar -->
2480
- <footer class="copio-toolbar" part="toolbar" id="workbench-toolbar">
2481
- <div class="copio-toolbar-tools">
2482
- <button type="button" class="copio-tool-btn" id="btn-retake" title="Retake page">
2483
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2484
- <path d="M23 4v6h-6M1 20v-6h6"/>
2485
- <path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>
2486
- </svg>
2487
- <span>Retake</span>
2488
- </button>
2489
-
2490
- <button type="button" class="copio-tool-btn" id="btn-crop" title="Adjust crop">
2491
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2492
- <path d="M6 2v14a2 2 0 0 0 2 2h14"/>
2493
- <path d="M18 22V8a2 2 0 0 0-2-2H2"/>
2494
- </svg>
2495
- <span id="crop-btn-label">Crop</span>
2496
- </button>
2497
-
2498
- <button type="button" class="copio-tool-btn" id="btn-rotate" title="Rotate 90\xB0">
2499
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2500
- <path d="M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38l5.67-5.67"/>
2501
- </svg>
2502
- <span>Rotate</span>
2503
- </button>
2504
-
2505
- <button type="button" class="copio-tool-btn" id="btn-filter-bw" title="Toggle B&W filter">
2506
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2507
- <circle cx="12" cy="12" r="10"/>
2508
- <path d="M12 2a10 10 0 0 1 0 20z" fill="currentColor"/>
2509
- </svg>
2510
- <span>B&W</span>
2511
- </button>
2512
-
2513
- <button type="button" class="copio-tool-btn" id="btn-ocr" title="Recognize text">
2514
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2515
- <path d="M4 7V4h16v3M9 20h6M12 4v16"/>
2516
- </svg>
2517
- <span>OCR</span>
2518
- </button>
2519
-
2520
- <button type="button" class="copio-tool-btn copio-btn-danger" id="btn-delete" title="Delete active page">
2521
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2522
- <polyline points="3 6 5 6 21 6"/>
2523
- <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
2524
- </svg>
2525
- <span>Delete</span>
2526
- </button>
2527
- </div>
2528
-
2529
- <div class="copio-toolbar-actions">
2530
- <slot name="toolbar">
2531
- <button type="button" class="copio-btn copio-btn-primary" id="btn-primary-complete">
2532
- \u2713 Use Photo
2533
- </button>
2534
- </slot>
2535
- </div>
2536
- </footer>
2537
-
2538
- <!-- Scoped OCR Slide-out / Bottom Sheet -->
2539
- <div class="copio-ocr-sheet" id="ocr-sheet" style="display:none;" part="ocr-sheet">
2540
- <div class="copio-ocr-header">
2541
- <strong class="copio-ocr-title">Text Recognition (OCR)</strong>
2542
- <button type="button" class="copio-btn copio-btn-secondary" id="btn-close-ocr">\u2715</button>
2543
- </div>
2544
- <div class="copio-ocr-body" id="ocr-body">
2545
- <p class="copio-ocr-placeholder">Select text or extract full page data...</p>
2546
- </div>
2547
- </div>
2548
-
2549
- <!-- Container-scoped Toast Region (5s undo) -->
2550
- <div class="copio-toast-region" id="toast-region" aria-live="polite"></div>
2551
- </div>
2552
-
2553
- <!-- Hidden input for file picker fallback -->
2554
- <input type="file" id="internal-file-input" accept="image/*" style="display: none;" />
2555
- <slot></slot>
2556
- </div>
2557
- `,this.#I()}#I(){let e=this.shadowRoot;if(!e)return;e.getElementById("tab-viewfinder")?.addEventListener("click",()=>{this.stage="viewfinder"}),e.getElementById("tab-workbench")?.addEventListener("click",()=>{this.stage="workbench"});let t=e.getElementById("internal-file-input");e.getElementById("btn-import-file")?.addEventListener("click",()=>{t?.click()}),t?.addEventListener("change",async o=>{let r=o.target;r.files&&r.files.length>0&&(await this.addFiles(r.files),r.value="")}),e.getElementById("btn-shutter")?.addEventListener("click",async()=>{await this.#M()}),e.getElementById("btn-review")?.addEventListener("click",()=>{this.stage="workbench"}),e.getElementById("btn-retake")?.addEventListener("click",()=>{this.#h=!0,this.#n=!1,this.stage="viewfinder"}),e.getElementById("btn-rotate")?.addEventListener("click",async()=>{await this.#k()}),e.getElementById("btn-filter-bw")?.addEventListener("click",async()=>{await this.#S()}),e.getElementById("btn-crop")?.addEventListener("click",async()=>{await this.#C()}),e.getElementById("btn-delete")?.addEventListener("click",async()=>{await this.#D()}),e.getElementById("btn-ocr")?.addEventListener("click",async()=>{await this.#R()}),e.getElementById("btn-close-ocr")?.addEventListener("click",()=>{this.#O()}),e.getElementById("btn-primary-complete")?.addEventListener("click",async()=>{await this.#B()}),e.getElementById("btn-card-front")?.addEventListener("click",()=>{this.#i=0,this.#a()}),e.getElementById("btn-card-back")?.addEventListener("click",()=>{this.#i=1,this.#a()}),this.#y()}#y(){let e=this.shadowRoot;if(!e)return;let t=e.getElementById("crop-box"),o=e.querySelectorAll(".copio-crop-handle");if(!t||o.length===0)return;let r=null,a=!1,n=0,s=0,l=null,c=u=>{let v=u.target.closest(".copio-crop-handle");if(v)r=v.getAttribute("data-handle"),a=!1;else if(u.target===t||u.target.classList.contains("copio-crop-grid"))r=null,a=!0;else return;u.preventDefault(),u.stopPropagation(),n=u.clientX,s=u.clientY,l=this.#l?{...this.#l}:{x:.05,y:.05,w:.9,h:.9},window.addEventListener("pointermove",p),window.addEventListener("pointerup",d)},p=u=>{if(!r&&!a||!l)return;let f=(e.getElementById("canvas-wrapper")||e.getElementById("canvas-viewport"))?.getBoundingClientRect()||{width:300,height:400},y=(u.clientX-n)/Math.max(f.width,1),C=(u.clientY-s)/Math.max(f.height,1),{x:A,y:k,w:D,h:g}=l;if(a)A=Math.min(Math.max(0,A+y),1-D),k=Math.min(Math.max(0,k+C),1-g);else if(r){if(r.includes("w")){let S=Math.min(Math.max(0,A+y),A+D-.1);D+=A-S,A=S}if(r.includes("e")&&(D=Math.min(Math.max(.1,D+y),1-A)),r.includes("n")){let S=Math.min(Math.max(0,k+C),k+g-.1);g+=k-S,k=S}r.includes("s")&&(g=Math.min(Math.max(.1,g+C),1-k))}this.#l={x:A,y:k,w:D,h:g},this.#w()},d=()=>{r=null,a=!1,l=null,window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",d)};t.addEventListener("pointerdown",c),o.forEach(u=>{u.addEventListener("pointerdown",c)})}#w(){let e=this.shadowRoot;if(!e||!this.#l)return;let t=e.getElementById("crop-box");t&&(t.style.left=`${(this.#l.x*100).toFixed(1)}%`,t.style.top=`${(this.#l.y*100).toFixed(1)}%`,t.style.width=`${(this.#l.w*100).toFixed(1)}%`,t.style.height=`${(this.#l.h*100).toFixed(1)}%`)}async#a(){if(this.shadowRoot)return this.#f?this.#f:(this.#f=(async()=>{try{await Promise.resolve(),await this.#T()}finally{this.#f=null}})(),this.#f)}async#T(){if(this.shadowRoot)try{let e=await this.getPages();this.#p=e.length;let t=this.shadowRoot,o=t.getElementById("mode-badge");o&&(o.textContent=(this.mode||"single").toUpperCase());let r=t.getElementById("tab-viewfinder"),a=t.getElementById("tab-workbench");r&&r.setAttribute("aria-selected",String(this.#r==="viewfinder")),a&&a.setAttribute("aria-selected",String(this.#r==="workbench"));let n=t.getElementById("viewfinder-section"),s=t.getElementById("workbench-section");n&&s&&(this.#r==="viewfinder"?(n.style.display="flex",s.style.display="none"):(n.style.display="none",s.style.display="flex"));let l=t.getElementById("framing-guide");l&&l.setAttribute("data-aspect",this.aspect||"auto");let c=t.getElementById("step-pill-text");c&&(this.#u?c.textContent="Camera Active \xB7 Tap Shutter to Snap":this.aspect==="card"&&this.maxPages===2?c.textContent=e.length===0?"Step 1 of 2: Capture Front of ID Card":"Step 2 of 2: Capture Back of ID Card":this.aspect==="card"?c.textContent="Align Card Inside Frame":this.mode==="batch"?c.textContent=`Batch Capture \xB7 Page ${e.length+1}`:c.textContent="Align Document Inside Frame");let p=t.getElementById("btn-ocr");p&&(p.style.display=this.ocrEnabled&&this.hasFeature("ocr")?"":"none");let d=t.getElementById("btn-review"),u=t.getElementById("review-pill-text");if(d&&u&&(e.length>0?(d.style.display="inline-flex",u.textContent=`Review (${e.length}) \u2192`):d.style.display="none"),e.length===0){this.#r==="workbench"&&(this.stage="viewfinder");return}this.#i>=e.length&&(this.#i=Math.max(0,e.length-1));let v=e[this.#i],f=t.getElementById("card-side-switcher");if(f){let D=this.aspect==="card"&&this.maxPages===2;f.style.display=D?"flex":"none";let g=t.getElementById("btn-card-front"),S=t.getElementById("btn-card-back");g&&(g.classList.toggle("active",this.#i===0),g.setAttribute("aria-selected",String(this.#i===0))),S&&(S.classList.toggle("active",this.#i===1),S.setAttribute("aria-selected",String(this.#i===1)))}let y=t.getElementById("stage-img");y&&(y.src=this.#n?v.originalSrc||v.src||"":v.src||v.originalSrc||"");let C=t.getElementById("crop-layer");if(this.#n){if(!C){let D=t.getElementById("canvas-wrapper");C=document.createElement("div"),C.className="copio-crop-layer",C.id="crop-layer",C.innerHTML=`
2558
- <div class="copio-crop-box" id="crop-box">
2559
- <div class="copio-crop-grid"></div>
2560
- <span class="copio-crop-handle nw" data-handle="nw"></span>
2561
- <span class="copio-crop-handle ne" data-handle="ne"></span>
2562
- <span class="copio-crop-handle se" data-handle="se"></span>
2563
- <span class="copio-crop-handle sw" data-handle="sw"></span>
2564
- <span class="copio-crop-handle n edge-n" data-handle="n"></span>
2565
- <span class="copio-crop-handle e edge-e" data-handle="e"></span>
2566
- <span class="copio-crop-handle s edge-s" data-handle="s"></span>
2567
- <span class="copio-crop-handle w edge-w" data-handle="w"></span>
2568
- </div>
2569
- `,D?.appendChild(C),this.#y()}C.style.display="block",this.#l=v.edits?.crop||{x:.05,y:.05,w:.9,h:.9},this.#w()}else C&&C.remove();let A=t.getElementById("crop-btn-label");A&&(A.textContent=this.#n?"Apply":"Crop");let k=t.getElementById("btn-primary-complete");k&&(this.aspect==="card"&&this.maxPages===2&&e.length===1?k.textContent="Next: Capture Back (Step 2/2) \u2192":this.aspect==="card"&&e.length>=2?k.textContent="\u2713 Complete ID Scan (2 Sides)":this.mode==="batch"?k.textContent=`\u2713 Complete Scan (${e.length} Pages)`:k.textContent="\u2713 Use Photo"),this.#P(e)}catch{}}#P(e){let t=this.shadowRoot;if(!t)return;let o=t.getElementById("filmstrip-scroll");o&&(o.innerHTML="",e.forEach((r,a)=>{let n=document.createElement("div");n.className=`copio-filmstrip-item ${a===this.#i?"is-active":""}`,n.setAttribute("data-index",String(a)),n.innerHTML=`
2570
- <div class="copio-thumb-container">
2571
- <img src="${r.src||r.originalSrc}" alt="Page ${a+1}" class="copio-thumb-img" />
2572
- <span class="copio-thumb-num">${a+1}</span>
2573
- </div>
2574
- ${this.mode==="batch"?`
2575
- <div class="copio-thumb-reorder">
2576
- <button type="button" class="copio-reorder-btn move-left" title="Move Left" ${a===0?"disabled":""}>\u25C0</button>
2577
- <button type="button" class="copio-reorder-btn move-right" title="Move Right" ${a===e.length-1?"disabled":""}>\u25B6</button>
2578
- </div>
2579
- `:""}
2580
- `,n.querySelector(".copio-thumb-container")?.addEventListener("click",()=>{this.#i=a,this.#n=!1,this.#a()}),this.mode==="batch"&&(n.querySelector(".move-left")?.addEventListener("click",async s=>{s.stopPropagation(),await this.#E(a,a-1)}),n.querySelector(".move-right")?.addEventListener("click",async s=>{s.stopPropagation(),await this.#E(a,a+1)})),o.appendChild(n)}))}async#E(e,t){let o=await this.getPages();if(t<0||t>=o.length||e===t)return;let r=o.map(n=>n.id),[a]=r.splice(e,1);r.splice(t,0,a),await this.#e.reorderPages(this.#o,r),this.#i=t,this.#a()}#v(){this.#u&&(this.#u.getTracks().forEach(r=>r.stop()),this.#u=null);let e=this.shadowRoot,t=e?.getElementById("camera-video");t&&(t.srcObject=null,t.style.display="none");let o=e?.querySelector(".copio-camera-placeholder");o&&(o.style.display="")}async#M(){if(typeof this.onShutter=="function"&&await this.onShutter()!==!1)return;let e=this.shadowRoot,t=e?.getElementById("camera-video");if(this.#u&&t&&t.readyState>=2){let a=document.createElement("canvas");a.width=t.videoWidth||1280,a.height=t.videoHeight||720;let n=a.getContext("2d");if(n){n.drawImage(t,0,0,a.width,a.height);let s=await new Promise(l=>a.toBlob(l,"image/jpeg",.92));if(s){this.#v();let l=new File([s],`capture_${Date.now()}.jpg`,{type:"image/jpeg"});await this.addFiles([l]);return}}}if(!(typeof navigator<"u"&&navigator.webdriver===!0)&&typeof navigator<"u"&&navigator.mediaDevices?.getUserMedia&&t)try{this.#u=await navigator.mediaDevices.getUserMedia({video:{facingMode:{ideal:"environment"},width:{ideal:1920},height:{ideal:1080}},audio:!1}),t.srcObject=this.#u,t.style.display="block",await t.play();let a=e?.querySelector(".copio-camera-placeholder");a&&(a.style.display="none");let n=e?.getElementById("step-pill-text");n&&(n.textContent="Camera Active \xB7 Tap Shutter to Snap");return}catch{}let r=e?.getElementById("internal-file-input");r&&typeof r.click=="function"&&r.click()}async#k(){let t=(await this.getPages())[this.#i];if(!t)return;let r=((t.edits?.rotate||0)+90)%360;await this.#e.applyEdit(this.#o,t.id,{rotate:r}),await this.#a()}async#S(){let t=(await this.getPages())[this.#i];if(!t)return;let r=(t.edits?.filter||"none")==="bw"?"none":"bw";await this.#e.applyEdit(this.#o,t.id,{filter:r}),await this.#a()}async#C(){let t=(await this.getPages())[this.#i];if(t){if(this.#n){this.#n=!1;let o=this.#l;this.#l=null,o&&await this.#e.applyEdit(this.#o,t.id,{crop:o})}else this.#n=!0;await this.#a()}}async#D(){let e=await this.getPages(),t=e[this.#i];if(!t)return;let o=t.id;await this.#e.deletePage(this.#o,o),this.dispatch(R.PAGE_REMOVED,{pageId:o,docId:this.docId}),this.#i>=e.length-1&&(this.#i=Math.max(0,e.length-2)),this.#_(),await this.#a()}#_(){let e=this.shadowRoot;if(!e)return;let t=e.getElementById("toast-region");if(!t)return;this.#c&&clearInterval(this.#c),this.#m=5;let o=()=>{t.innerHTML=`
2581
- <div class="copio-toast copio-toast-undo">
2582
- <span>Page deleted</span>
2583
- <button type="button" class="copio-btn-toast-undo" id="btn-toast-undo">
2584
- Undo (${this.#m}s)
2585
- </button>
2586
- </div>
2587
- `,e.getElementById("btn-toast-undo")?.addEventListener("click",async()=>{clearInterval(this.#c),this.#c=null,t.innerHTML="",await this.#e.undo(this.#o),await this.#a()})};o(),this.#c=setInterval(()=>{this.#m-=1,this.#m<=0?(clearInterval(this.#c),this.#c=null,t.innerHTML=""):o()},1e3)}async#R(){let e=this.shadowRoot;if(!e)return;let t=e.getElementById("ocr-sheet"),o=e.getElementById("ocr-body");if(!(!t||!o)){t.style.display="block",o.innerHTML='<p class="copio-ocr-loading">Recognizing text...</p>';try{let a=(await this.getPages())[this.#i],n=await this.ocr(a?.id||null),s=n.averageConfidence||0,l=s<=1&&s>0?Math.round(s*100):Math.round(s);o.innerHTML=`
2588
- <div class="copio-ocr-content">
2589
- <pre class="copio-ocr-text">${n.text||"No text detected."}</pre>
2590
- <div class="copio-ocr-meta">
2591
- <span>Confidence: ${l}%</span>
2592
- </div>
2593
- </div>
2594
- `}catch(r){o.innerHTML=`<p class="copio-ocr-error">OCR recognition failed: ${r.message}</p>`}}}#O(){let e=this.shadowRoot;if(!e)return;let t=e.getElementById("ocr-sheet");t&&(t.style.display="none")}async#B(){if(this.aspect==="card"&&this.maxPages===2&&this.#p===1){this.stage="viewfinder";return}let e=await this.getPages();if(this.aspect==="card"&&this.maxPages===2&&e.length===1){this.stage="viewfinder";return}let t=e.map((r,a)=>({id:r.id,pageNumber:a+1,label:r.label||`Page ${a+1}`,originalSrc:r.originalSrc,src:r.src,originalPreserved:!0,dimensions:{width:r.width||0,height:r.height||0},edits:r.edits||{crop:{x:0,y:0,w:1,h:1},rotate:0,filter:"none"},ocrText:r.ocrText||null,blob:r.blob||null})),o={mode:this.mode,aspect:this.aspect,docId:this.docId,pageCount:t.length,pages:t};this.mode==="single"&&(o.page=t[0]||null,this.maxPages>1&&(o.maxPages=this.maxPages)),this.dispatch(R.SCAN_COMPLETE,o)}get theme(){return typeof this.getAttribute=="function"&&this.getAttribute("theme")||"dark"}set theme(e){typeof this.setAttribute=="function"&&(e?this.setAttribute("theme",e):this.removeAttribute("theme"))}get mode(){return typeof this.getAttribute=="function"&&this.getAttribute("mode")||"document"}set mode(e){typeof this.setAttribute=="function"&&this.setAttribute("mode",e)}get aspect(){return typeof this.getAttribute=="function"&&this.getAttribute("aspect")||"auto"}set aspect(e){typeof this.setAttribute=="function"&&this.setAttribute("aspect",e)}get stage(){return this.#r}set stage(e){if(e==="viewfinder"||e==="workbench"){this.#r=e,typeof this.setAttribute=="function"&&this.getAttribute("stage")!==e&&this.setAttribute("stage",e);let t=this.shadowRoot;if(t){let o=t.getElementById("viewfinder-section"),r=t.getElementById("workbench-section");o&&r&&(o.style.display=e==="viewfinder"?"flex":"none",r.style.display=e==="workbench"?"flex":"none")}this.#a()}}get docId(){return typeof this.getAttribute=="function"?this.getAttribute("doc-id"):null}set docId(e){typeof this.setAttribute=="function"&&(e?this.setAttribute("doc-id",e):this.removeAttribute("doc-id"))}async rotateActivePage(){return this.#k()}async toggleActivePageBw(){return this.#S()}async toggleCropMode(){return this.#C()}async deleteActivePageWithUndo(){return this.#D()}get features(){return this.#e?this.#e.features:[]}set features(e){if(typeof this.setAttribute=="function"){let t=Array.isArray(e)?e.join(" "):String(e||"");this.setAttribute("features",t)}this.#e&&this.#e.setFeatures(e)}hasFeature(e){return this.#e?this.#e.hasFeature(e):!1}get ocrEnabled(){return this.#e?this.#e.ocr:!0}set ocrEnabled(e){let t=!!e;typeof this.setAttribute=="function"&&this.setAttribute("ocr",t?"true":"false"),this.#e&&(this.#e.ocr=t),this.#g()}get pdf(){return this.#e?this.#e.pdf:!0}set pdf(e){let t=!!e;typeof this.setAttribute=="function"&&this.setAttribute("pdf",t?"true":"false"),this.#e&&(this.#e.pdf=t),this.#g()}get exportFormats(){return this.#e?this.#e.exportFormats:[]}set exportFormats(e){if(typeof this.setAttribute=="function"){let t=Array.isArray(e)?e.join(","):String(e||"");this.setAttribute("export-formats",t)}this.#e&&(this.#e.exportFormats=e)}get ocrLanguages(){return this.#e?this.#e.ocrLanguages:[]}set ocrLanguages(e){if(typeof this.setAttribute=="function"){let t=Array.isArray(e)?e.join(","):String(e||"");this.setAttribute("ocr-languages",t)}this.#e&&(this.#e.ocrLanguages=e)}get maxPages(){return this.#e?this.#e.maxPages:0}set maxPages(e){typeof this.setAttribute=="function"&&this.setAttribute("max-pages",String(e)),this.#e&&(this.#e.maxPages=e)}get assetBase(){return this.#e?this.#e.assetBase:""}set assetBase(e){typeof this.setAttribute=="function"&&this.setAttribute("asset-base",String(e||"")),this.#e&&(this.#e.assetBase=e)}get licenseKey(){return this.#e?this.#e.licenseKey:""}set licenseKey(e){typeof this.setAttribute=="function"&&this.setAttribute("license-key",String(e||"")),this.#e&&(this.#e.licenseKey=e)}get storage(){return this.#t}set storage(e){this.#t=e,this.#e&&this.#e.setStorage(e)}get engine(){return this.#e}set engine(e){e instanceof nt&&(this.#e=e)}dispatch(e,t={}){return Bt(this,e,t)}async open(){this.#d=!0,typeof this.focus=="function"&&this.focus()}async close(){this.#d=!1,this.#v()}get isOpen(){return this.#d}async capture(){return new Promise(e=>{let t=document.createElement("input");t.type="file",t.accept="image/*",t.capture="environment",t.style.display="none",t.onchange=async()=>{try{if(t.files&&t.files.length>0){let o=await this.addFiles([t.files[0]]);e(o[0]||null)}else e(null)}catch(o){this.dispatch(R.ERROR,{code:"CAPTURE_FAILED",message:o.message,error:o}),e(null)}finally{t.remove()}},t.onerror=()=>{t.remove(),e(null)},document.body.appendChild(t),t.click()})}async addFiles(e){try{let t=await this.getPages(),o=null;if(t.length>0){if(this.mode==="single"&&this.maxPages<=1)await this.#e.clear(this.#o);else if(this.#h||this.maxPages>0&&t.length>=this.maxPages){let n=Math.min(this.#i,t.length-1),s=t[n];s&&(o=n,await this.#e.deletePage(this.#o,s.id))}}this.#h=!1;let r=await this.#e.addFiles(e,this.#o);for(let n=0;n<r.length;n++)this.dispatch(R.PAGE_ADDED,{page:r[n],pageNumber:n+1,docId:this.docId,source:"file"});let a=await this.getPages();if(o!==null&&r.length===1&&o<a.length-1){let n=a.map(l=>l.id),s=n.pop();s&&(n.splice(o,0,s),await this.#e.reorderPages(this.#o,n),a=await this.getPages())}return this.#p=a.length,r.length>0&&(this.#i=o!==null?Math.min(o,Math.max(0,a.length-1)):Math.max(0,a.length-1),this.mode==="single"&&(this.#r="workbench",typeof this.setAttribute=="function"&&this.getAttribute("stage")!=="workbench"&&this.setAttribute("stage","workbench"))),this.dispatch(R.PAGES_CHANGED,{pages:a,docId:this.docId}),this.mode==="single"&&r.length>0&&this.maxPages<=1&&this.dispatch(R.SCAN_COMPLETE,{mode:this.mode,aspect:this.aspect,docId:this.docId,pages:a,page:a[a.length-1]||null,pageCount:a.length}),await this.#a(),r}catch(t){throw this.dispatch(R.ERROR,{code:t.code||"ADD_FILES_FAILED",message:t.message,error:t}),t}}async getPages(){return this.#e.getPages(this.#o)}async clear(){this.#v(),this.#i=0,this.#p=0,this.#h=!1,this.#n=!1,await this.#e.clear(this.#o),this.dispatch(R.PAGES_CHANGED,{pages:[],docId:this.docId}),await this.#a()}async exportPdf(e={}){try{let t=await this.#e.exportPdf(this.#o,e);return this.dispatch(R.EXPORT_COMPLETE,{type:"pdf",format:"pdf",blob:t,docId:this.docId}),t}catch(t){throw this.dispatch(R.ERROR,{code:t.code||"EXPORT_FAILED",message:t.message,error:t}),t}}async exportZip(e={}){try{let t=await this.#e.exportZip(this.#o,e);return this.dispatch(R.EXPORT_COMPLETE,{type:"zip",format:"zip",blob:t,docId:this.docId}),t}catch(t){throw this.dispatch(R.ERROR,{code:t.code||"EXPORT_FAILED",message:t.message,error:t}),t}}async ocr(e=null,t={}){try{let o=await this.#e.runOcr(this.#o,e,t);return this.dispatch(R.OCR_COMPLETE,{text:o.text,pages:o.pagesResults,averageConfidence:o.averageConfidence,docId:this.docId,pageId:e}),o}catch(o){throw this.dispatch(R.ERROR,{code:o.code||"OCR_FAILED",message:o.message,error:o}),o}}async runOcr(e=null,t={}){return this.ocr(e,t)}async sync(e={}){try{return await this.#e.sync({onStateChange:o=>{o&&(o.step==="connected"||o.step==="syncing")&&this.dispatch(R.SYNC_CONNECTED,{peerId:o.peerId,mode:o.mode}),e.onStateChange&&e.onStateChange(o)}})}catch(t){throw this.dispatch(R.ERROR,{code:t.code||"SYNC_FAILED",message:t.message,error:t}),t}}};typeof customElements<"u"&&!customElements.get("copio-scanner")&&customElements.define("copio-scanner",Dt);export{Je as a,et as b,tt as c,ot as d,it as e,rt as f,Ct as g,lo as h,co as i,Dt as j};
2595
- /**!
2596
- * Sortable 1.15.6
2597
- * @author RubaXa <trash@rubaxa.org>
2598
- * @author owenm <owen23355@gmail.com>
2599
- * @license MIT
2600
- */
2601
- //# sourceMappingURL=chunk-IZOWC74B.js.map