@ddict/popup 1.0.2 → 1.0.6

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.
package/dist/popup.es.js CHANGED
@@ -116,14 +116,14 @@ const _hoisted_6$5 = {
116
116
  viewBox: "0 0 24 24",
117
117
  stroke: "currentColor"
118
118
  };
119
- const _hoisted_7$5 = /* @__PURE__ */ createElementVNode("path", {
119
+ const _hoisted_7$3 = /* @__PURE__ */ createElementVNode("path", {
120
120
  "stroke-linecap": "round",
121
121
  "stroke-linejoin": "round",
122
122
  "stroke-width": "2",
123
123
  d: "M13 7l5 5m0 0l-5 5m5-5H6"
124
124
  }, null, -1);
125
125
  const _hoisted_8$2 = [
126
- _hoisted_7$5
126
+ _hoisted_7$3
127
127
  ];
128
128
  const _hoisted_9$2 = ["value"];
129
129
  const _hoisted_10$2 = {
@@ -395,7 +395,7 @@ const _hoisted_5$6 = /* @__PURE__ */ createElementVNode("svg", {
395
395
  const _hoisted_6$4 = [
396
396
  _hoisted_5$6
397
397
  ];
398
- const _hoisted_7$4 = {
398
+ const _hoisted_7$2 = {
399
399
  key: 2,
400
400
  class: "ml-1"
401
401
  };
@@ -433,7 +433,7 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
433
433
  class: "pointer",
434
434
  onClick: _cache[1] || (_cache[1] = (...args) => $options.stop && $options.stop(...args))
435
435
  }, _hoisted_6$4)) : createCommentVNode("", true),
436
- $props.data.ddictSrc ? (openBlock(), createElementBlock("span", _hoisted_7$4, toDisplayString($props.data.ddictSrc), 1)) : createCommentVNode("", true),
436
+ $props.data.ddictSrc ? (openBlock(), createElementBlock("span", _hoisted_7$2, toDisplayString($props.data.ddictSrc), 1)) : createCommentVNode("", true),
437
437
  (openBlock(true), createElementBlock(Fragment, null, renderList($props.data.sentences, (sentence, index) => {
438
438
  return openBlock(), createElementBlock("span", {
439
439
  key: `${sentence.src_translit}-${index}`,
@@ -602,7 +602,7 @@ const _hoisted_5$5 = /* @__PURE__ */ createElementVNode("svg", {
602
602
  const _hoisted_6$3 = [
603
603
  _hoisted_5$5
604
604
  ];
605
- const _hoisted_7$3 = {
605
+ const _hoisted_7$1 = {
606
606
  key: 2,
607
607
  class: "ml-1"
608
608
  };
@@ -645,7 +645,7 @@ const _hoisted_17 = [
645
645
  _hoisted_16
646
646
  ];
647
647
  function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
648
- return openBlock(), createElementBlock("div", null, [
648
+ return openBlock(), createElementBlock(Fragment, null, [
649
649
  createElementVNode("div", _hoisted_1$6, [
650
650
  $props.data ? (openBlock(), createElementBlock("div", _hoisted_2$6, [
651
651
  !$data.playing ? (openBlock(), createElementBlock("span", {
@@ -658,7 +658,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
658
658
  class: "pointer",
659
659
  onClick: _cache[1] || (_cache[1] = (...args) => $options.stop && $options.stop(...args))
660
660
  }, _hoisted_6$3)) : createCommentVNode("", true),
661
- $props.data.ddictTarget ? (openBlock(), createElementBlock("span", _hoisted_7$3, toDisplayString($props.data.ddictTarget), 1)) : createCommentVNode("", true)
661
+ $props.data.ddictTarget ? (openBlock(), createElementBlock("span", _hoisted_7$1, toDisplayString($props.data.ddictTarget), 1)) : createCommentVNode("", true)
662
662
  ])) : createCommentVNode("", true),
663
663
  $props.data ? (openBlock(), createElementBlock("div", {
664
664
  key: 1,
@@ -677,7 +677,7 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
677
677
  }, null, 4)
678
678
  ]),
679
679
  $props.data ? (openBlock(), createElementBlock("p", _hoisted_15, _hoisted_17)) : createCommentVNode("", true)
680
- ]);
680
+ ], 64);
681
681
  }
682
682
  var Result = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$5]]);
683
683
  const _sfc_main$5 = {
@@ -696,30 +696,36 @@ const _sfc_main$5 = {
696
696
  const _hoisted_1$5 = { key: 0 };
697
697
  const _hoisted_2$5 = { class: "card-body p-4" };
698
698
  const _hoisted_3$5 = { class: "card-title font-bold" };
699
- const _hoisted_4$5 = { class: "list-group list-group-flush" };
699
+ const _hoisted_4$5 = { class: "list-decimal" };
700
700
  const _hoisted_5$4 = { class: "capitalize font-bold" };
701
701
  const _hoisted_6$2 = /* @__PURE__ */ createElementVNode("br", null, null, -1);
702
- const _hoisted_7$2 = { class: "italic" };
702
+ const _hoisted_7 = {
703
+ key: 0,
704
+ class: "italic"
705
+ };
703
706
  function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
704
707
  return $props.data.definitions ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
705
708
  createElementVNode("div", _hoisted_2$5, [
706
709
  createElementVNode("h2", _hoisted_3$5, toDisplayString($data.name), 1),
707
- createElementVNode("ul", _hoisted_4$5, [
710
+ createElementVNode("ul", null, [
708
711
  (openBlock(true), createElementBlock(Fragment, null, renderList($props.data.definitions, (dict, index) => {
709
712
  return openBlock(), createElementBlock("li", {
710
713
  key: `${dict.pos}-${index}`,
711
- class: "list-group-item mb-2"
714
+ class: "mb-2"
712
715
  }, [
713
- createElementVNode("h5", _hoisted_5$4, toDisplayString(dict.pos), 1),
714
- (openBlock(true), createElementBlock(Fragment, null, renderList(dict.entry, (entry, index2) => {
715
- return openBlock(), createElementBlock("div", {
716
- key: `${entry.definition_id}-${index2}`
717
- }, [
718
- createElementVNode("span", null, toDisplayString(entry.gloss), 1),
719
- _hoisted_6$2,
720
- createElementVNode("small", _hoisted_7$2, toDisplayString(entry.example), 1)
721
- ]);
722
- }), 128))
716
+ createElementVNode("ul", _hoisted_4$5, [
717
+ createElementVNode("h5", _hoisted_5$4, toDisplayString(dict.pos), 1),
718
+ (openBlock(true), createElementBlock(Fragment, null, renderList(dict.entry, (entry, index2) => {
719
+ return openBlock(), createElementBlock("li", {
720
+ key: `${entry.definition_id}-${index2}`,
721
+ class: "ml-5 mb-2"
722
+ }, [
723
+ createElementVNode("span", null, toDisplayString(entry.gloss), 1),
724
+ _hoisted_6$2,
725
+ entry.example ? (openBlock(), createElementBlock("small", _hoisted_7, '"' + toDisplayString(entry.example) + '"', 1)) : createCommentVNode("", true)
726
+ ]);
727
+ }), 128))
728
+ ])
723
729
  ]);
724
730
  }), 128))
725
731
  ])
@@ -748,21 +754,23 @@ const _sfc_main$4 = {
748
754
  const _hoisted_1$4 = { key: 0 };
749
755
  const _hoisted_2$4 = { class: "card-body p-4" };
750
756
  const _hoisted_3$4 = { class: "card-title" };
751
- const _hoisted_4$4 = { class: "list-group list-group-flush" };
752
- const _hoisted_5$3 = { class: "capitalize font-bold" };
753
- const _hoisted_6$1 = ["onClick"];
754
- const _hoisted_7$1 = { class: "italic" };
757
+ const _hoisted_4$4 = { class: "capitalize font-bold" };
758
+ const _hoisted_5$3 = ["onClick"];
759
+ const _hoisted_6$1 = {
760
+ key: 0,
761
+ class: "italic"
762
+ };
755
763
  function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
756
764
  return $props.data.dict ? (openBlock(), createElementBlock("div", _hoisted_1$4, [
757
765
  createElementVNode("div", _hoisted_2$4, [
758
766
  createElementVNode("h2", _hoisted_3$4, toDisplayString($data.name), 1),
759
- createElementVNode("ul", _hoisted_4$4, [
767
+ createElementVNode("ul", null, [
760
768
  (openBlock(true), createElementBlock(Fragment, null, renderList($props.data.dict, (dict, index) => {
761
769
  return openBlock(), createElementBlock("li", {
762
770
  key: `${dict.pos}-${index}`,
763
- class: "list-group-item mb-2"
771
+ class: "mb-2"
764
772
  }, [
765
- createElementVNode("h5", _hoisted_5$3, toDisplayString(dict.pos), 1),
773
+ createElementVNode("h5", _hoisted_4$4, toDisplayString(dict.pos), 1),
766
774
  (openBlock(true), createElementBlock(Fragment, null, renderList(dict.entry, (entry, index2) => {
767
775
  return openBlock(), createElementBlock("div", {
768
776
  key: `${entry.word}-${index2}`
@@ -770,8 +778,8 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
770
778
  createElementVNode("span", {
771
779
  class: "badge bg-neutral",
772
780
  onClick: ($event) => $options.translate(entry.word)
773
- }, toDisplayString(entry.word), 9, _hoisted_6$1),
774
- createElementVNode("small", _hoisted_7$1, " \u2015 " + toDisplayString(entry.reverse_translation.join(", ")), 1)
781
+ }, toDisplayString(entry.word), 9, _hoisted_5$3),
782
+ entry.reverse_translation ? (openBlock(), createElementBlock("small", _hoisted_6$1, " \u2015 " + toDisplayString(entry.reverse_translation.join(", ")), 1)) : createCommentVNode("", true)
775
783
  ]);
776
784
  }), 128))
777
785
  ]);
@@ -807,7 +815,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
807
815
  (openBlock(true), createElementBlock(Fragment, null, renderList($props.data.examples.example, (example, index) => {
808
816
  return openBlock(), createElementBlock("li", {
809
817
  key: `${example.definition_id}-${index}`,
810
- class: "mt-2 ml-2",
818
+ class: "ml-4 mb-2",
811
819
  innerHTML: example.text
812
820
  }, null, 8, _hoisted_5$2);
813
821
  }), 128))
@@ -832,21 +840,20 @@ const _sfc_main$2 = {
832
840
  const _hoisted_1$2 = { key: 0 };
833
841
  const _hoisted_2$2 = { class: "card-body p-4" };
834
842
  const _hoisted_3$2 = { class: "card-title font-bold" };
835
- const _hoisted_4$2 = { class: "list-group list-group-flush" };
836
- const _hoisted_5$1 = { class: "capitalize font-bold" };
837
- const _hoisted_6 = ["onClick"];
838
- const _hoisted_7 = /* @__PURE__ */ createElementVNode("span", null, null, -1);
843
+ const _hoisted_4$2 = { class: "capitalize font-bold" };
844
+ const _hoisted_5$1 = ["onClick"];
845
+ const _hoisted_6 = /* @__PURE__ */ createElementVNode("span", null, null, -1);
839
846
  function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
840
847
  return $props.data.synsets ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
841
848
  createElementVNode("div", _hoisted_2$2, [
842
849
  createElementVNode("h2", _hoisted_3$2, toDisplayString($data.name), 1),
843
- createElementVNode("ul", _hoisted_4$2, [
850
+ createElementVNode("ul", null, [
844
851
  (openBlock(true), createElementBlock(Fragment, null, renderList($props.data.synsets, (dict, index) => {
845
852
  return openBlock(), createElementBlock("li", {
846
853
  key: `${dict.pos}-${index}`,
847
- class: "list-group-item mb-2"
854
+ class: "mb-2"
848
855
  }, [
849
- createElementVNode("h5", _hoisted_5$1, toDisplayString(dict.pos), 1),
856
+ createElementVNode("h5", _hoisted_4$2, toDisplayString(dict.pos), 1),
850
857
  (openBlock(true), createElementBlock(Fragment, null, renderList(dict.entry, (entry, index2) => {
851
858
  return openBlock(), createElementBlock("div", {
852
859
  key: `${entry.definition_id}-${index2}`
@@ -856,10 +863,10 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
856
863
  key: `${synonym}-${index3}`
857
864
  }, [
858
865
  createElementVNode("span", {
859
- class: "badge bg-neutral ml-1",
866
+ class: "badge bg-neutral mr-1",
860
867
  onClick: ($event) => _ctx.$emit("translate", synonym)
861
- }, toDisplayString(synonym), 9, _hoisted_6),
862
- _hoisted_7
868
+ }, toDisplayString(synonym), 9, _hoisted_5$1),
869
+ _hoisted_6
863
870
  ]);
864
871
  }), 128))
865
872
  ]);
@@ -908,8 +915,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
908
915
  ])) : createCommentVNode("", true);
909
916
  }
910
917
  var More = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render]]);
911
- const _hoisted_1 = { class: "p-1" };
912
- const _hoisted_2 = { class: "mt-3 grid grid-cols-1 md:grid-cols-2 gap-3" };
918
+ const _hoisted_1 = { class: "p-2" };
919
+ const _hoisted_2 = { class: "mt-2 grid grid-cols-1 md:grid-cols-2 gap-3" };
913
920
  const _hoisted_3 = { class: "w-full" };
914
921
  const _hoisted_4 = { class: "w-full" };
915
922
  const __default__ = {
package/dist/popup.umd.js CHANGED
@@ -1 +1 @@
1
- (function(d,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(d=typeof globalThis!="undefined"?globalThis:d||self,t(d.Popup={},d.Vue))})(this,function(d,t){"use strict";var y={isRTL:N};function N(e){return["ar","fa","iw","yi","ur","pa"].indexOf(e)>-1}var h=(e,s)=>{const l=e.__vccOpts||e;for(const[i,r]of s)l[i]=r;return l};const u={props:{select:{type:Object,default:null}},emits:["select"],data(){return{src:"",target:"",recents:{src:[],target:[]}}},watch:{select(e){!e||(this.src=e.src,this.target=e.target,this.loadRecents())}},methods:{onRecentSrc(e){this.src=e,this.onSelect()},onRecentTarget(e){this.target=e,this.onSelect()},swap(){if(this.src==="auto"||!this.select.srcs[this.target]||!this.select.targets[this.src])return;const e=this.target;this.target=this.src,this.src=e,this.onSelect()},onSelect(){const e=JSON.parse(JSON.stringify(this.select));e.src=this.src,e.target=this.target,this.$emit("select",e),this.saveRecents(this.src,this.target)},loadRecents(){const e=JSON.parse(localStorage.getItem("recents"));!e||(this.recents=e)},saveRecents(e,s){this.recents.src.includes(e)||this.recents.src.push(e),this.recents.target.includes(s)||this.recents.target.push(s),this.recents.src.length>3&&this.recents.src.shift(),this.recents.target.length>3&&this.recents.target.shift(),localStorage.setItem("recents",JSON.stringify(this.recents))}}},w={key:0,class:"flex flex-row"},V=["value"],$={key:0,xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},x=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"},null,-1)],S={key:1,xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},b=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 7l5 5m0 0l-5 5m5-5H6"},null,-1)],C=["value"],T={key:1,class:"flex flex-row"},L={class:"grow"},M=["onClick"],D={class:"grow"},j=["onClick"];function I(e,s,l,i,r,o){return t.openBlock(),t.createElementBlock(t.Fragment,null,[l.select?(t.openBlock(),t.createElementBlock("div",w,[t.withDirectives(t.createElementVNode("select",{"onUpdate:modelValue":s[0]||(s[0]=n=>r.src=n),class:"select select-bordered grow",onChange:s[1]||(s[1]=(...n)=>o.onSelect&&o.onSelect(...n))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.select.srcs,(n,a)=>(t.openBlock(),t.createElementBlock("option",{value:a,key:a},t.toDisplayString(n),9,V))),128))],544),[[t.vModelSelect,r.src]]),t.createElementVNode("button",{class:"grow-0 ml-2 mr-2",onClick:s[2]||(s[2]=(...n)=>o.swap&&o.swap(...n))},[r.src!="auto"?(t.openBlock(),t.createElementBlock("svg",$,x)):t.createCommentVNode("",!0),r.src=="auto"?(t.openBlock(),t.createElementBlock("svg",S,b)):t.createCommentVNode("",!0)]),t.withDirectives(t.createElementVNode("select",{"onUpdate:modelValue":s[3]||(s[3]=n=>r.target=n),class:"select select-bordered grow",onChange:s[4]||(s[4]=(...n)=>o.onSelect&&o.onSelect(...n))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.select.targets,(n,a)=>(t.openBlock(),t.createElementBlock("option",{value:a,key:a},t.toDisplayString(n),9,C))),128))],544),[[t.vModelSelect,r.target]])])):t.createCommentVNode("",!0),l.select&&r.src&&r.target&&r.recents?(t.openBlock(),t.createElementBlock("div",T,[t.createElementVNode("div",L,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.recents.src,n=>(t.openBlock(),t.createElementBlock("span",{key:n,onClick:a=>o.onRecentSrc(n),class:"badge badge-sm ml-1 badge-outline"},t.toDisplayString(l.select.srcs[n]),9,M))),128))]),t.createElementVNode("div",D,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.recents.target,n=>(t.openBlock(),t.createElementBlock("span",{key:n,onClick:a=>o.onRecentTarget(n),class:"badge badge-sm ml-1 float-right mt-1"},t.toDisplayString(l.select.targets[n]),9,j))),128))])])):t.createCommentVNode("",!0)],64)}var H=h(u,[["render",I]]),k={INPUT_MAX_LENGTH:5e3,INPUT_DELAY:1e3},m={init:z,autoResize:R};const g=100,E=600,O=10;function z(e,s){s&&(e.maxlength=s),e.spellcheck=!1,p(e,g)}function R(e){if(e.value==""){p(e,g);return}if(e.scrollHeight<g){p(e,g);return}if(e.scrollHeight>E){p(e,E);return}e.style.height.replace("px","")>e.scrollHeight||p(e,e.scrollHeight+O)}function p(e,s){e.style.height=`${s}px`}const B="auto_translate",A={props:{data:{type:Object,default:null},tts:{type:Object,default:null},replace:{type:String,default:""}},data(){return{input:"",INPUT_MAX_LENGTH:k.INPUT_MAX_LENGTH,input_timeout:null,player:new Audio,playing:!1,ttsIndex:0,auto_translate:!0,firstTime:!0}},computed:{rtl(){return this.data?y.isRTL(this.data.src):!1}},watch:{replace(e){this.input=e,(this.firstTime||!this.auto_translate)&&setTimeout(()=>{this.$refs.input.select()},100),this.firstTime=!1},tts(){this.ttsIndex=0},auto_translate(e){e&&this.translate(),localStorage.setItem(B,e)}},mounted(){m.init(this.$refs.input,k.INPUT_MAX_LENGTH),this.player.addEventListener("ended",()=>{if(this.ttsIndex++,this.ttsIndex>=this.tts.src.length){this.stop();return}this.play()}),this.$refs.input.addEventListener("input",()=>{m.autoResize(this.$refs.input),!!this.auto_translate&&(clearTimeout(this.input_timeout),this.input_timeout=setTimeout(this.translate,k.INPUT_DELAY))}),this.$refs.input.addEventListener("keyup",e=>{this.auto_translate||e&&e.keyCode===13&&this.translate()})},created(){localStorage.getItem(B)==="false"&&(this.auto_translate=!1)},methods:{play(){!this.tts.src||(this.player.src=this.tts.src[this.ttsIndex],this.playing=!0,this.player.play().catch(()=>{this.playing=!1}))},stop(){this.playing=!1,this.ttsIndex=0,this.player.pause()},clear(){this.$emit("clear"),this.input="",m.init(this.$refs.input,k.INPUT_MAX_LENGTH),this.$refs.input.focus()},translate(){if(!this.input){this.clear();return}this.$emit("translate",this.input)}}},F={class:"relative indicator w-full"},P={key:0,class:"absolute top-0 left-0 w-4/5 ml-2 text-sm truncate"},U=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})],-1)],G=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"})],-1)],J={key:2,class:"ml-1"},X={key:0},Y=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)],q={class:"cursor-pointer label justify-start"},K=t.createElementVNode("span",{class:"ml-1 label-text text-xs"},"Auto translate",-1);function Q(e,s,l,i,r,o){return t.openBlock(),t.createElementBlock("div",null,[t.createElementVNode("div",F,[l.data?(t.openBlock(),t.createElementBlock("div",P,[r.playing?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"pointer",onClick:s[0]||(s[0]=(...n)=>o.play&&o.play(...n))},U)),r.playing?(t.openBlock(),t.createElementBlock("span",{key:1,class:"pointer",onClick:s[1]||(s[1]=(...n)=>o.stop&&o.stop(...n))},G)):t.createCommentVNode("",!0),l.data.ddictSrc?(t.openBlock(),t.createElementBlock("span",J,t.toDisplayString(l.data.ddictSrc),1)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.sentences,(n,a)=>(t.openBlock(),t.createElementBlock("span",{key:`${n.src_translit}-${a}`,class:"italic"},[n.src_translit?(t.openBlock(),t.createElementBlock("span",X," \u2015 "+t.toDisplayString(n.src_translit),1)):t.createCommentVNode("",!0)]))),128))])):t.createCommentVNode("",!0),r.input!=""?(t.openBlock(),t.createElementBlock("div",{key:1,onClick:s[2]||(s[2]=(...n)=>o.clear&&o.clear(...n)),class:"indicator-item m-3"},Y)):t.createCommentVNode("",!0),t.withDirectives(t.createElementVNode("textarea",{id:"input",ref:"input","onUpdate:modelValue":s[3]||(s[3]=n=>r.input=n),class:"text-lg textarea textarea-bordered w-full pt-5",style:t.normalizeStyle({"text-align":o.rtl?"right":"left"}),autofocus:""},null,4),[[t.vModelText,r.input,void 0,{trim:!0}]])]),t.createElementVNode("label",q,[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":s[4]||(s[4]=n=>r.auto_translate=n),type:"checkbox",class:"toggle toggle-xs"},null,512),[[t.vModelCheckbox,r.auto_translate]]),K])])}var W=h(A,[["render",Q]]);const Z={props:{data:{type:Object,default:null},tts:{type:Object,default:null}},data(){return{player:new Audio,playing:!1,copied:!1,ttsIndex:0}},computed:{rtl(){return this.data?y.isRTL(this.data.target):!1}},watch:{data(e){if(!e){this.$refs.input.value="",m.init(this.$refs.input);return}this.$refs.input.value=e.sentences.map(s=>s.trans).join(""),m.autoResize(this.$refs.input)},tts(){this.ttsIndex=0}},mounted(){m.init(this.$refs.input),m.autoResize(this.$refs.input),this.player.addEventListener("ended",()=>{if(this.ttsIndex++,this.ttsIndex>=this.tts.target.length){this.stop();return}this.play()})},methods:{play(){!this.tts.target||(this.player.src=this.tts.target[this.ttsIndex],this.playing=!0,this.player.play().catch(()=>{this.playing=!1}))},stop(){this.playing=!1,this.ttsIndex=0,this.player.pause()},copy(){const e=this.$refs.input.value;!e||(navigator.clipboard.writeText(e),this.copied=!0,setTimeout(()=>{this.copied=!1},500))}}},v={class:"relative indicator w-full"},tt={key:0,class:"absolute top-0 left-0 w-2/3 ml-2 text-sm truncate"},et=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})],-1)],st=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"})],-1)],nt={key:2,class:"ml-1"},lt={key:0,xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},rt=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"},null,-1)],ot={key:1,xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},at=[t.createElementVNode("path",{d:"M8 2a1 1 0 000 2h2a1 1 0 100-2H8z"},null,-1),t.createElementVNode("path",{d:"M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z"},null,-1)],it={key:0,class:"label justify-end"},ct=[t.createElementVNode("span",{class:"text-xs"},"Powered by Google Translate.",-1)];function dt(e,s,l,i,r,o){return t.openBlock(),t.createElementBlock("div",null,[t.createElementVNode("div",v,[l.data?(t.openBlock(),t.createElementBlock("div",tt,[r.playing?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"pointer",onClick:s[0]||(s[0]=(...n)=>o.play&&o.play(...n))},et)),r.playing?(t.openBlock(),t.createElementBlock("span",{key:1,class:"pointer",onClick:s[1]||(s[1]=(...n)=>o.stop&&o.stop(...n))},st)):t.createCommentVNode("",!0),l.data.ddictTarget?(t.openBlock(),t.createElementBlock("span",nt,t.toDisplayString(l.data.ddictTarget),1)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0),l.data?(t.openBlock(),t.createElementBlock("div",{key:1,onClick:s[2]||(s[2]=(...n)=>o.copy&&o.copy(...n)),class:"indicator-item m-3"},[r.copied?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("svg",lt,rt)),r.copied?(t.openBlock(),t.createElementBlock("svg",ot,at)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0),t.createElementVNode("textarea",{ref:"input",class:"text-lg textarea textarea-bordered w-full pt-5",style:t.normalizeStyle({"text-align":o.rtl?"right":"left"}),readonly:"",spellcheck:"false"},null,4)]),l.data?(t.openBlock(),t.createElementBlock("p",it,ct)):t.createCommentVNode("",!0)])}var ht=h(Z,[["render",dt]]);const mt={props:{data:{type:Object,default:null}},data(){return{name:"Definitions"}}},pt={key:0},_t={class:"card-body p-4"},kt={class:"card-title font-bold"},gt={class:"list-group list-group-flush"},ft={class:"capitalize font-bold"},yt=t.createElementVNode("br",null,null,-1),Et={class:"italic"};function Bt(e,s,l,i,r,o){return l.data.definitions?(t.openBlock(),t.createElementBlock("div",pt,[t.createElementVNode("div",_t,[t.createElementVNode("h2",kt,t.toDisplayString(r.name),1),t.createElementVNode("ul",gt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.definitions,(n,a)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.pos}-${a}`,class:"list-group-item mb-2"},[t.createElementVNode("h5",ft,t.toDisplayString(n.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.definition_id}-${_}`},[t.createElementVNode("span",null,t.toDisplayString(c.gloss),1),yt,t.createElementVNode("small",Et,t.toDisplayString(c.example),1)]))),128))]))),128))])])])):t.createCommentVNode("",!0)}var Nt=h(mt,[["render",Bt]]);const ut={props:{data:{type:Object,default:null}},data(){return{name:"Translations"}},methods:{translate(e){this.$emit("translate",e)}}},wt={key:0},Vt={class:"card-body p-4"},$t={class:"card-title"},xt={class:"list-group list-group-flush"},St={class:"capitalize font-bold"},bt=["onClick"],Ct={class:"italic"};function Tt(e,s,l,i,r,o){return l.data.dict?(t.openBlock(),t.createElementBlock("div",wt,[t.createElementVNode("div",Vt,[t.createElementVNode("h2",$t,t.toDisplayString(r.name),1),t.createElementVNode("ul",xt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.dict,(n,a)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.pos}-${a}`,class:"list-group-item mb-2"},[t.createElementVNode("h5",St,t.toDisplayString(n.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.word}-${_}`},[t.createElementVNode("span",{class:"badge bg-neutral",onClick:f=>o.translate(c.word)},t.toDisplayString(c.word),9,bt),t.createElementVNode("small",Ct," \u2015 "+t.toDisplayString(c.reverse_translation.join(", ")),1)]))),128))]))),128))])])])):t.createCommentVNode("",!0)}var Lt=h(ut,[["render",Tt]]);const Mt={props:{data:{type:Object,default:null}},data(){return{name:"Examples"}}},Dt={key:0},jt={class:"card-body p-4"},It={class:"card-title font-bold"},Ht={class:"list-disc"},Ot=["innerHTML"];function zt(e,s,l,i,r,o){return l.data.examples&&l.data.examples.example?(t.openBlock(),t.createElementBlock("div",Dt,[t.createElementVNode("div",jt,[t.createElementVNode("h2",It,t.toDisplayString(r.name),1),t.createElementVNode("ul",Ht,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.examples.example,(n,a)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.definition_id}-${a}`,class:"mt-2 ml-2",innerHTML:n.text},null,8,Ot))),128))])])])):t.createCommentVNode("",!0)}var Rt=h(Mt,[["render",zt]]);const At={props:{data:{type:Object,default:null}},data(){return{name:"Synonyms"}}},Ft={key:0},Pt={class:"card-body p-4"},Ut={class:"card-title font-bold"},Gt={class:"list-group list-group-flush"},Jt={class:"capitalize font-bold"},Xt=["onClick"],Yt=t.createElementVNode("span",null,null,-1);function qt(e,s,l,i,r,o){return l.data.synsets?(t.openBlock(),t.createElementBlock("div",Ft,[t.createElementVNode("div",Pt,[t.createElementVNode("h2",Ut,t.toDisplayString(r.name),1),t.createElementVNode("ul",Gt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.synsets,(n,a)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.pos}-${a}`,class:"list-group-item mb-2"},[t.createElementVNode("h5",Jt,t.toDisplayString(n.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.definition_id}-${_}`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(c.synonym,(f,ce)=>(t.openBlock(),t.createElementBlock("span",{key:`${f}-${ce}`},[t.createElementVNode("span",{class:"badge bg-neutral ml-1",onClick:ue=>e.$emit("translate",f)},t.toDisplayString(f),9,Xt),Yt]))),128))]))),128))]))),128))])])])):t.createCommentVNode("",!0)}var Kt=h(At,[["render",qt]]);const Qt={props:{data:{type:Object,default:null}},data(){return{name:"See also"}}},Wt={key:0},Zt={class:"card-body p-4"},vt={class:"card-title font-bold"},te=["onClick"],ee=t.createElementVNode("span",null,null,-1);function se(e,s,l,i,r,o){return l.data.related_words&&l.data.related_words.word?(t.openBlock(),t.createElementBlock("div",Wt,[t.createElementVNode("div",Zt,[t.createElementVNode("h2",vt,t.toDisplayString(r.name),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.related_words.word,(n,a)=>(t.openBlock(),t.createElementBlock("span",{key:`${n}-${a}`},[t.createElementVNode("span",{class:"badge bg-neutral",onClick:c=>e.$emit("translate",n)},t.toDisplayString(n),9,te),ee]))),128))])])):t.createCommentVNode("",!0)}var ne=h(Qt,[["render",se]]);const le={class:"p-1"},re={class:"mt-3 grid grid-cols-1 md:grid-cols-2 gap-3"},oe={class:"w-full"},ae={class:"w-full"},ie=Object.assign({name:"Popup",props:{export_data:{type:Object,default:null},export_select:{type:Object,default:null},export_tts:{type:Object,default:null}},data(){return{data:null,select:null,tts:null,replace:""}},computed:{rtl(){return this.data?y.isRTL(this.data.target):!1}},watch:{export_data(e){this.data=e,e.text&&this.replace!=e.text&&(this.replace=e.text)},export_select(e){this.select=e},export_tts(e){this.tts=e}},methods:{clear(){this.data=null,this.$emit("clear")},translateReplace(e){return this.translate(e,!0)},translateSwap(e){return this.translate(e,!0,!0)},translate(e,s,l){if(l){if(!this.data.src||this.data.src==="auto"||!this.data.target)return;const i=JSON.parse(JSON.stringify(this.select));i.src=this.data.target,i.target=this.data.src,this.$emit("srctarget",i)}window.scrollTo(0,0),this.clear(),s&&(this.replace=e),this.$emit("translate",e)},onSelect(e){if(this.$emit("srctarget",e),this.data){const s=this.data.sentences.map(l=>l.orig).join("");this.$emit("translate",s)}}}},{setup(e){return(s,l)=>(t.openBlock(),t.createElementBlock("div",le,[t.createVNode(H,{select:s.select,onSelect:s.onSelect},null,8,["select","onSelect"]),t.createElementVNode("div",re,[t.createElementVNode("div",oe,[t.createVNode(W,{data:s.data,tts:s.tts,replace:s.replace,onTranslate:s.translate,onClear:s.clear},null,8,["data","tts","replace","onTranslate","onClear"])]),t.createElementVNode("div",ae,[t.createVNode(ht,{data:s.data,tts:s.tts},null,8,["data","tts"])])]),s.data?(t.openBlock(),t.createElementBlock("div",{key:0,class:"mt-3 grid grid-cols-1 md:grid-cols-3 gap-3",style:t.normalizeStyle({"text-align":s.rtl?"right":"left"})},[t.createVNode(Nt,{class:"card border",data:s.data},null,8,["data"]),t.createVNode(Lt,{class:"card border",data:s.data,onTranslate:s.translateSwap},null,8,["data","onTranslate"]),t.createVNode(Kt,{class:"card border",data:s.data,onTranslate:s.translateReplace},null,8,["data","onTranslate"]),t.createVNode(ne,{class:"card border",data:s.data,onTranslate:s.translateReplace},null,8,["data","onTranslate"])],4)):t.createCommentVNode("",!0),s.data?(t.openBlock(),t.createElementBlock("div",{key:1,class:"mt-5 grid grid-cols-1 gap-6",style:t.normalizeStyle({"text-align":s.rtl?"right":"left"})},[t.createVNode(Rt,{class:"card border",data:s.data},null,8,["data"])],4)):t.createCommentVNode("",!0)]))}});d.default=ie,Object.defineProperty(d,"__esModule",{value:!0}),d[Symbol.toStringTag]="Module"});
1
+ (function(d,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(d=typeof globalThis!="undefined"?globalThis:d||self,t(d.Popup={},d.Vue))})(this,function(d,t){"use strict";var y={isRTL:N};function N(e){return["ar","fa","iw","yi","ur","pa"].indexOf(e)>-1}var m=(e,s)=>{const l=e.__vccOpts||e;for(const[i,r]of s)l[i]=r;return l};const w={props:{select:{type:Object,default:null}},emits:["select"],data(){return{src:"",target:"",recents:{src:[],target:[]}}},watch:{select(e){!e||(this.src=e.src,this.target=e.target,this.loadRecents())}},methods:{onRecentSrc(e){this.src=e,this.onSelect()},onRecentTarget(e){this.target=e,this.onSelect()},swap(){if(this.src==="auto"||!this.select.srcs[this.target]||!this.select.targets[this.src])return;const e=this.target;this.target=this.src,this.src=e,this.onSelect()},onSelect(){const e=JSON.parse(JSON.stringify(this.select));e.src=this.src,e.target=this.target,this.$emit("select",e),this.saveRecents(this.src,this.target)},loadRecents(){const e=JSON.parse(localStorage.getItem("recents"));!e||(this.recents=e)},saveRecents(e,s){this.recents.src.includes(e)||this.recents.src.push(e),this.recents.target.includes(s)||this.recents.target.push(s),this.recents.src.length>3&&this.recents.src.shift(),this.recents.target.length>3&&this.recents.target.shift(),localStorage.setItem("recents",JSON.stringify(this.recents))}}},V={key:0,class:"flex flex-row"},u=["value"],$={key:0,xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},x=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"},null,-1)],b={key:1,xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},S=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 7l5 5m0 0l-5 5m5-5H6"},null,-1)],C=["value"],T={key:1,class:"flex flex-row"},L={class:"grow"},M=["onClick"],D={class:"grow"},j=["onClick"];function I(e,s,l,i,r,a){return t.openBlock(),t.createElementBlock(t.Fragment,null,[l.select?(t.openBlock(),t.createElementBlock("div",V,[t.withDirectives(t.createElementVNode("select",{"onUpdate:modelValue":s[0]||(s[0]=n=>r.src=n),class:"select select-bordered grow",onChange:s[1]||(s[1]=(...n)=>a.onSelect&&a.onSelect(...n))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.select.srcs,(n,o)=>(t.openBlock(),t.createElementBlock("option",{value:o,key:o},t.toDisplayString(n),9,u))),128))],544),[[t.vModelSelect,r.src]]),t.createElementVNode("button",{class:"grow-0 ml-2 mr-2",onClick:s[2]||(s[2]=(...n)=>a.swap&&a.swap(...n))},[r.src!="auto"?(t.openBlock(),t.createElementBlock("svg",$,x)):t.createCommentVNode("",!0),r.src=="auto"?(t.openBlock(),t.createElementBlock("svg",b,S)):t.createCommentVNode("",!0)]),t.withDirectives(t.createElementVNode("select",{"onUpdate:modelValue":s[3]||(s[3]=n=>r.target=n),class:"select select-bordered grow",onChange:s[4]||(s[4]=(...n)=>a.onSelect&&a.onSelect(...n))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.select.targets,(n,o)=>(t.openBlock(),t.createElementBlock("option",{value:o,key:o},t.toDisplayString(n),9,C))),128))],544),[[t.vModelSelect,r.target]])])):t.createCommentVNode("",!0),l.select&&r.src&&r.target&&r.recents?(t.openBlock(),t.createElementBlock("div",T,[t.createElementVNode("div",L,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.recents.src,n=>(t.openBlock(),t.createElementBlock("span",{key:n,onClick:o=>a.onRecentSrc(n),class:"badge badge-sm ml-1 badge-outline"},t.toDisplayString(l.select.srcs[n]),9,M))),128))]),t.createElementVNode("div",D,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.recents.target,n=>(t.openBlock(),t.createElementBlock("span",{key:n,onClick:o=>a.onRecentTarget(n),class:"badge badge-sm ml-1 float-right mt-1"},t.toDisplayString(l.select.targets[n]),9,j))),128))])])):t.createCommentVNode("",!0)],64)}var H=m(w,[["render",I]]),k={INPUT_MAX_LENGTH:5e3,INPUT_DELAY:1e3},h={init:z,autoResize:R};const g=100,E=600,O=10;function z(e,s){s&&(e.maxlength=s),e.spellcheck=!1,p(e,g)}function R(e){if(e.value==""){p(e,g);return}if(e.scrollHeight<g){p(e,g);return}if(e.scrollHeight>E){p(e,E);return}e.style.height.replace("px","")>e.scrollHeight||p(e,e.scrollHeight+O)}function p(e,s){e.style.height=`${s}px`}const B="auto_translate",A={props:{data:{type:Object,default:null},tts:{type:Object,default:null},replace:{type:String,default:""}},data(){return{input:"",INPUT_MAX_LENGTH:k.INPUT_MAX_LENGTH,input_timeout:null,player:new Audio,playing:!1,ttsIndex:0,auto_translate:!0,firstTime:!0}},computed:{rtl(){return this.data?y.isRTL(this.data.src):!1}},watch:{replace(e){this.input=e,(this.firstTime||!this.auto_translate)&&setTimeout(()=>{this.$refs.input.select()},100),this.firstTime=!1},tts(){this.ttsIndex=0},auto_translate(e){e&&this.translate(),localStorage.setItem(B,e)}},mounted(){h.init(this.$refs.input,k.INPUT_MAX_LENGTH),this.player.addEventListener("ended",()=>{if(this.ttsIndex++,this.ttsIndex>=this.tts.src.length){this.stop();return}this.play()}),this.$refs.input.addEventListener("input",()=>{h.autoResize(this.$refs.input),!!this.auto_translate&&(clearTimeout(this.input_timeout),this.input_timeout=setTimeout(this.translate,k.INPUT_DELAY))}),this.$refs.input.addEventListener("keyup",e=>{this.auto_translate||e&&e.keyCode===13&&this.translate()})},created(){localStorage.getItem(B)==="false"&&(this.auto_translate=!1)},methods:{play(){!this.tts.src||(this.player.src=this.tts.src[this.ttsIndex],this.playing=!0,this.player.play().catch(()=>{this.playing=!1}))},stop(){this.playing=!1,this.ttsIndex=0,this.player.pause()},clear(){this.$emit("clear"),this.input="",h.init(this.$refs.input,k.INPUT_MAX_LENGTH),this.$refs.input.focus()},translate(){if(!this.input){this.clear();return}this.$emit("translate",this.input)}}},F={class:"relative indicator w-full"},P={key:0,class:"absolute top-0 left-0 w-4/5 ml-2 text-sm truncate"},U=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})],-1)],G=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"})],-1)],J={key:2,class:"ml-1"},X={key:0},Y=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)],q={class:"cursor-pointer label justify-start"},K=t.createElementVNode("span",{class:"ml-1 label-text text-xs"},"Auto translate",-1);function Q(e,s,l,i,r,a){return t.openBlock(),t.createElementBlock("div",null,[t.createElementVNode("div",F,[l.data?(t.openBlock(),t.createElementBlock("div",P,[r.playing?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"pointer",onClick:s[0]||(s[0]=(...n)=>a.play&&a.play(...n))},U)),r.playing?(t.openBlock(),t.createElementBlock("span",{key:1,class:"pointer",onClick:s[1]||(s[1]=(...n)=>a.stop&&a.stop(...n))},G)):t.createCommentVNode("",!0),l.data.ddictSrc?(t.openBlock(),t.createElementBlock("span",J,t.toDisplayString(l.data.ddictSrc),1)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.sentences,(n,o)=>(t.openBlock(),t.createElementBlock("span",{key:`${n.src_translit}-${o}`,class:"italic"},[n.src_translit?(t.openBlock(),t.createElementBlock("span",X," \u2015 "+t.toDisplayString(n.src_translit),1)):t.createCommentVNode("",!0)]))),128))])):t.createCommentVNode("",!0),r.input!=""?(t.openBlock(),t.createElementBlock("div",{key:1,onClick:s[2]||(s[2]=(...n)=>a.clear&&a.clear(...n)),class:"indicator-item m-3"},Y)):t.createCommentVNode("",!0),t.withDirectives(t.createElementVNode("textarea",{id:"input",ref:"input","onUpdate:modelValue":s[3]||(s[3]=n=>r.input=n),class:"text-lg textarea textarea-bordered w-full pt-5",style:t.normalizeStyle({"text-align":a.rtl?"right":"left"}),autofocus:""},null,4),[[t.vModelText,r.input,void 0,{trim:!0}]])]),t.createElementVNode("label",q,[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":s[4]||(s[4]=n=>r.auto_translate=n),type:"checkbox",class:"toggle toggle-xs"},null,512),[[t.vModelCheckbox,r.auto_translate]]),K])])}var W=m(A,[["render",Q]]);const Z={props:{data:{type:Object,default:null},tts:{type:Object,default:null}},data(){return{player:new Audio,playing:!1,copied:!1,ttsIndex:0}},computed:{rtl(){return this.data?y.isRTL(this.data.target):!1}},watch:{data(e){if(!e){this.$refs.input.value="",h.init(this.$refs.input);return}this.$refs.input.value=e.sentences.map(s=>s.trans).join(""),h.autoResize(this.$refs.input)},tts(){this.ttsIndex=0}},mounted(){h.init(this.$refs.input),h.autoResize(this.$refs.input),this.player.addEventListener("ended",()=>{if(this.ttsIndex++,this.ttsIndex>=this.tts.target.length){this.stop();return}this.play()})},methods:{play(){!this.tts.target||(this.player.src=this.tts.target[this.ttsIndex],this.playing=!0,this.player.play().catch(()=>{this.playing=!1}))},stop(){this.playing=!1,this.ttsIndex=0,this.player.pause()},copy(){const e=this.$refs.input.value;!e||(navigator.clipboard.writeText(e),this.copied=!0,setTimeout(()=>{this.copied=!1},500))}}},v={class:"relative indicator w-full"},tt={key:0,class:"absolute top-0 left-0 w-2/3 ml-2 text-sm truncate"},et=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"})],-1)],st=[t.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 inline",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"}),t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"})],-1)],nt={key:2,class:"ml-1"},lt={key:0,xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},rt=[t.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"},null,-1)],at={key:1,xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},ot=[t.createElementVNode("path",{d:"M8 2a1 1 0 000 2h2a1 1 0 100-2H8z"},null,-1),t.createElementVNode("path",{d:"M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z"},null,-1)],ct={key:0,class:"label justify-end"},it=[t.createElementVNode("span",{class:"text-xs"},"Powered by Google Translate.",-1)];function dt(e,s,l,i,r,a){return t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createElementVNode("div",v,[l.data?(t.openBlock(),t.createElementBlock("div",tt,[r.playing?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"pointer",onClick:s[0]||(s[0]=(...n)=>a.play&&a.play(...n))},et)),r.playing?(t.openBlock(),t.createElementBlock("span",{key:1,class:"pointer",onClick:s[1]||(s[1]=(...n)=>a.stop&&a.stop(...n))},st)):t.createCommentVNode("",!0),l.data.ddictTarget?(t.openBlock(),t.createElementBlock("span",nt,t.toDisplayString(l.data.ddictTarget),1)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0),l.data?(t.openBlock(),t.createElementBlock("div",{key:1,onClick:s[2]||(s[2]=(...n)=>a.copy&&a.copy(...n)),class:"indicator-item m-3"},[r.copied?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("svg",lt,rt)),r.copied?(t.openBlock(),t.createElementBlock("svg",at,ot)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0),t.createElementVNode("textarea",{ref:"input",class:"text-lg textarea textarea-bordered w-full pt-5",style:t.normalizeStyle({"text-align":a.rtl?"right":"left"}),readonly:"",spellcheck:"false"},null,4)]),l.data?(t.openBlock(),t.createElementBlock("p",ct,it)):t.createCommentVNode("",!0)],64)}var mt=m(Z,[["render",dt]]);const ht={props:{data:{type:Object,default:null}},data(){return{name:"Definitions"}}},pt={key:0},_t={class:"card-body p-4"},kt={class:"card-title font-bold"},gt={class:"list-decimal"},ft={class:"capitalize font-bold"},yt=t.createElementVNode("br",null,null,-1),Et={key:0,class:"italic"};function Bt(e,s,l,i,r,a){return l.data.definitions?(t.openBlock(),t.createElementBlock("div",pt,[t.createElementVNode("div",_t,[t.createElementVNode("h2",kt,t.toDisplayString(r.name),1),t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.definitions,(n,o)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.pos}-${o}`,class:"mb-2"},[t.createElementVNode("ul",gt,[t.createElementVNode("h5",ft,t.toDisplayString(n.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.entry,(c,_)=>(t.openBlock(),t.createElementBlock("li",{key:`${c.definition_id}-${_}`,class:"ml-5 mb-2"},[t.createElementVNode("span",null,t.toDisplayString(c.gloss),1),yt,c.example?(t.openBlock(),t.createElementBlock("small",Et,'"'+t.toDisplayString(c.example)+'"',1)):t.createCommentVNode("",!0)]))),128))])]))),128))])])])):t.createCommentVNode("",!0)}var Nt=m(ht,[["render",Bt]]);const wt={props:{data:{type:Object,default:null}},data(){return{name:"Translations"}},methods:{translate(e){this.$emit("translate",e)}}},Vt={key:0},ut={class:"card-body p-4"},$t={class:"card-title"},xt={class:"capitalize font-bold"},bt=["onClick"],St={key:0,class:"italic"};function Ct(e,s,l,i,r,a){return l.data.dict?(t.openBlock(),t.createElementBlock("div",Vt,[t.createElementVNode("div",ut,[t.createElementVNode("h2",$t,t.toDisplayString(r.name),1),t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.dict,(n,o)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.pos}-${o}`,class:"mb-2"},[t.createElementVNode("h5",xt,t.toDisplayString(n.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.word}-${_}`},[t.createElementVNode("span",{class:"badge bg-neutral",onClick:f=>a.translate(c.word)},t.toDisplayString(c.word),9,bt),c.reverse_translation?(t.openBlock(),t.createElementBlock("small",St," \u2015 "+t.toDisplayString(c.reverse_translation.join(", ")),1)):t.createCommentVNode("",!0)]))),128))]))),128))])])])):t.createCommentVNode("",!0)}var Tt=m(wt,[["render",Ct]]);const Lt={props:{data:{type:Object,default:null}},data(){return{name:"Examples"}}},Mt={key:0},Dt={class:"card-body p-4"},jt={class:"card-title font-bold"},It={class:"list-disc"},Ht=["innerHTML"];function Ot(e,s,l,i,r,a){return l.data.examples&&l.data.examples.example?(t.openBlock(),t.createElementBlock("div",Mt,[t.createElementVNode("div",Dt,[t.createElementVNode("h2",jt,t.toDisplayString(r.name),1),t.createElementVNode("ul",It,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.examples.example,(n,o)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.definition_id}-${o}`,class:"ml-4 mb-2",innerHTML:n.text},null,8,Ht))),128))])])])):t.createCommentVNode("",!0)}var zt=m(Lt,[["render",Ot]]);const Rt={props:{data:{type:Object,default:null}},data(){return{name:"Synonyms"}}},At={key:0},Ft={class:"card-body p-4"},Pt={class:"card-title font-bold"},Ut={class:"capitalize font-bold"},Gt=["onClick"],Jt=t.createElementVNode("span",null,null,-1);function Xt(e,s,l,i,r,a){return l.data.synsets?(t.openBlock(),t.createElementBlock("div",At,[t.createElementVNode("div",Ft,[t.createElementVNode("h2",Pt,t.toDisplayString(r.name),1),t.createElementVNode("ul",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.synsets,(n,o)=>(t.openBlock(),t.createElementBlock("li",{key:`${n.pos}-${o}`,class:"mb-2"},[t.createElementVNode("h5",Ut,t.toDisplayString(n.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(n.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.definition_id}-${_}`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(c.synonym,(f,oe)=>(t.openBlock(),t.createElementBlock("span",{key:`${f}-${oe}`},[t.createElementVNode("span",{class:"badge bg-neutral mr-1",onClick:Be=>e.$emit("translate",f)},t.toDisplayString(f),9,Gt),Jt]))),128))]))),128))]))),128))])])])):t.createCommentVNode("",!0)}var Yt=m(Rt,[["render",Xt]]);const qt={props:{data:{type:Object,default:null}},data(){return{name:"See also"}}},Kt={key:0},Qt={class:"card-body p-4"},Wt={class:"card-title font-bold"},Zt=["onClick"],vt=t.createElementVNode("span",null,null,-1);function te(e,s,l,i,r,a){return l.data.related_words&&l.data.related_words.word?(t.openBlock(),t.createElementBlock("div",Kt,[t.createElementVNode("div",Qt,[t.createElementVNode("h2",Wt,t.toDisplayString(r.name),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.data.related_words.word,(n,o)=>(t.openBlock(),t.createElementBlock("span",{key:`${n}-${o}`},[t.createElementVNode("span",{class:"badge bg-neutral",onClick:c=>e.$emit("translate",n)},t.toDisplayString(n),9,Zt),vt]))),128))])])):t.createCommentVNode("",!0)}var ee=m(qt,[["render",te]]);const se={class:"p-2"},ne={class:"mt-2 grid grid-cols-1 md:grid-cols-2 gap-3"},le={class:"w-full"},re={class:"w-full"},ae=Object.assign({name:"Popup",props:{export_data:{type:Object,default:null},export_select:{type:Object,default:null},export_tts:{type:Object,default:null}},data(){return{data:null,select:null,tts:null,replace:""}},computed:{rtl(){return this.data?y.isRTL(this.data.target):!1}},watch:{export_data(e){this.data=e,e.text&&this.replace!=e.text&&(this.replace=e.text)},export_select(e){this.select=e},export_tts(e){this.tts=e}},methods:{clear(){this.data=null,this.$emit("clear")},translateReplace(e){return this.translate(e,!0)},translateSwap(e){return this.translate(e,!0,!0)},translate(e,s,l){if(l){if(!this.data.src||this.data.src==="auto"||!this.data.target)return;const i=JSON.parse(JSON.stringify(this.select));i.src=this.data.target,i.target=this.data.src,this.$emit("srctarget",i)}window.scrollTo(0,0),this.clear(),s&&(this.replace=e),this.$emit("translate",e)},onSelect(e){if(this.$emit("srctarget",e),this.data){const s=this.data.sentences.map(l=>l.orig).join("");this.$emit("translate",s)}}}},{setup(e){return(s,l)=>(t.openBlock(),t.createElementBlock("div",se,[t.createVNode(H,{select:s.select,onSelect:s.onSelect},null,8,["select","onSelect"]),t.createElementVNode("div",ne,[t.createElementVNode("div",le,[t.createVNode(W,{data:s.data,tts:s.tts,replace:s.replace,onTranslate:s.translate,onClear:s.clear},null,8,["data","tts","replace","onTranslate","onClear"])]),t.createElementVNode("div",re,[t.createVNode(mt,{data:s.data,tts:s.tts},null,8,["data","tts"])])]),s.data?(t.openBlock(),t.createElementBlock("div",{key:0,class:"mt-3 grid grid-cols-1 md:grid-cols-3 gap-3",style:t.normalizeStyle({"text-align":s.rtl?"right":"left"})},[t.createVNode(Nt,{class:"card border",data:s.data},null,8,["data"]),t.createVNode(Tt,{class:"card border",data:s.data,onTranslate:s.translateSwap},null,8,["data","onTranslate"]),t.createVNode(Yt,{class:"card border",data:s.data,onTranslate:s.translateReplace},null,8,["data","onTranslate"]),t.createVNode(ee,{class:"card border",data:s.data,onTranslate:s.translateReplace},null,8,["data","onTranslate"])],4)):t.createCommentVNode("",!0),s.data?(t.openBlock(),t.createElementBlock("div",{key:1,class:"mt-5 grid grid-cols-1 gap-6",style:t.normalizeStyle({"text-align":s.rtl?"right":"left"})},[t.createVNode(zt,{class:"card border",data:s.data},null,8,["data"])],4)):t.createCommentVNode("",!0)]))}});d.default=ae,Object.defineProperty(d,"__esModule",{value:!0}),d[Symbol.toStringTag]="Module"});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddict/popup",
3
- "version": "1.0.2",
3
+ "version": "1.0.6",
4
4
  "files": [
5
5
  "dist"
6
6
  ],